Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
ff393b9793 | |
|
341882c786 | |
|
019a69ace9 | |
|
2c707d28e7 |
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [1.0.5] - 2023-02-03
|
||||
### Added
|
||||
- Meta deterministic generation for authoring components
|
||||
|
||||
## [1.0.4] - 2023-01-27
|
||||
### Added
|
||||
- Support for `bhl_native_class` token
|
||||
### Changed
|
||||
- `ecs_serializable` now `serializable`
|
||||
- Fields are not serializaed by default
|
||||
- `serializable` token now applicable to fields
|
||||
|
||||
## [1.0.1] - 2023-01-25
|
||||
### Fixed
|
||||
- Wrong type generation
|
||||
|
|
|
@ -4,9 +4,9 @@ This package is used for code generation of C# meta structs for LeoECS using Twi
|
|||
ecs.meta
|
||||
```
|
||||
struct TestComponent
|
||||
@bhl_ecs_component @ecs_gen_component @ecs_gen_authoring @ecs_serializable
|
||||
pos : Vector3
|
||||
fwd : Vector3
|
||||
@bhl_ecs_component @ecs_gen_component @ecs_gen_authoring @serializable
|
||||
pos : Vector3 @serializable
|
||||
fwd : Vector3 @serializable
|
||||
width : float
|
||||
length : float
|
||||
end
|
||||
|
@ -17,5 +17,5 @@ to be added on game object.
|
|||
# Tags:
|
||||
@ecs_gen_component - generates C# component
|
||||
@ecs_gen_authoring - generates authoring monobehaviour to be added on game object
|
||||
@ecs_serializable - makes component editable in inspector
|
||||
@serializable - makes component editable in inspector
|
||||
@ecs_tag - marks component tag
|
|
@ -7,7 +7,8 @@
|
|||
"twig/twig" : "v3.4.3",
|
||||
"bit/metagen" : "^v2.0.2",
|
||||
"bit/metagen_cs" : "^v1.0.5",
|
||||
"bit/taskman_helpers" : "^v1.0.6"
|
||||
"bit/taskman_helpers" : "^v1.0.6",
|
||||
"ramsey/uuid" : "^v3"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace metagen_cs_ecs;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
function supported_tokens()
|
||||
{
|
||||
return [
|
||||
'ecs_serializable',
|
||||
'serializable',
|
||||
'ecs_gen_component',
|
||||
'ecs_gen_authoring',
|
||||
'ecs_tag',
|
||||
|
@ -94,6 +96,7 @@ function generate_ecs_components(\mtgMetaInfo $meta)
|
|||
$unit_name = $unit->object->getName();
|
||||
$filePath = str_replace(".", "/", $unit_name);
|
||||
$file = "$gen_root/{$filePath}AuthoringComponent.cs";
|
||||
$fileMeta = "$gen_root/{$filePath}AuthoringComponent.cs.meta";
|
||||
$name_components = explode('.', $unit_name);
|
||||
$class_name = end($name_components);
|
||||
if($class_name != $unit_name)
|
||||
|
@ -105,17 +108,23 @@ function generate_ecs_components(\mtgMetaInfo $meta)
|
|||
if(empty($namespace))
|
||||
$namespace = "ecs";
|
||||
|
||||
if($unit->object->hasToken('ecs_gen_authoring'))
|
||||
{
|
||||
\taskman\ensure_write_if_differs(
|
||||
$file,
|
||||
$twig->render('codegen_ecs_authoring.twig', [
|
||||
'namespace' => $namespace,
|
||||
'class_name' => $class_name,
|
||||
'obj' => $unit->object
|
||||
])
|
||||
);
|
||||
}
|
||||
\taskman\ensure_write_if_differs(
|
||||
$file,
|
||||
$twig->render('codegen_ecs_authoring.twig', [
|
||||
'namespace' => $namespace,
|
||||
'class_name' => $class_name,
|
||||
'obj' => $unit->object
|
||||
])
|
||||
);
|
||||
|
||||
$uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, $file);
|
||||
$guid = bin2hex($uuid->getBytes());
|
||||
\taskman\ensure_write_if_differs(
|
||||
$fileMeta,
|
||||
$twig->render('codegen_ecs_authoring_meta.twig', [
|
||||
'guid' => $guid,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: {{guid}}
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -8,7 +8,7 @@ using {{imp}};
|
|||
namespace {{namespace}}
|
||||
{
|
||||
{% endif %}
|
||||
{% if has_token(obj, 'ecs_serializable') %}
|
||||
{% if has_token(obj, 'serializable') %}
|
||||
[System.Serializable]
|
||||
{% endif %}
|
||||
{% apply trim('\n:, ', 'right') %}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{%- macro ecs_component_field(obj, field) -%}
|
||||
{%- if not has_token(field, 'serializable') -%}
|
||||
[System.NonSerialized]
|
||||
{%- endif -%}
|
||||
public {{field.type|ecs_type}} {{field.name}};
|
||||
{%- endmacro -%}
|
Loading…
Reference in New Issue