Fixed generation for bound structures
This commit is contained in:
parent
a75a83702b
commit
d6b9d88e87
|
@ -27,12 +27,18 @@ function generate_ecs_components(\mtgMetaInfo $meta)
|
|||
global $GAME_ROOT;
|
||||
|
||||
$gen_root = get_gen_root();
|
||||
$twig = \metagen_cs\get_twig(array(get_twig_inc()));
|
||||
$twig->setCache($GAME_ROOT . "/build/twig/metagen_cs_ecs");
|
||||
$gen_components = new \mtgMetaInfo();
|
||||
$gen_authorings = new \mtgMetaInfo();
|
||||
$lock_file = "$gen_root/ecs.lock";
|
||||
|
||||
if(!\taskman\need_to_regen($lock_file, get_meta_units_files($meta)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
\taskman\ensure_rm($gen_root);
|
||||
\taskman\ensure_write($lock_file, "");
|
||||
touch($lock_file);
|
||||
|
||||
foreach ($meta->getUnits() as $unit)
|
||||
{
|
||||
if(!($unit->object instanceof \mtgUserType))
|
||||
|
@ -42,15 +48,10 @@ function generate_ecs_components(\mtgMetaInfo $meta)
|
|||
if($unit->object->hasToken('ecs_gen_authoring'))
|
||||
$gen_authorings->addUnit($unit);
|
||||
}
|
||||
|
||||
if(!\taskman\need_to_regen($lock_file, get_meta_units_files($gen_components)) &&
|
||||
!\taskman\need_to_regen($lock_file, get_meta_units_files($gen_authorings)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
\taskman\ensure_rm($gen_root);
|
||||
\taskman\ensure_write($lock_file, "");
|
||||
touch($lock_file);
|
||||
|
||||
$twig = \metagen_cs\get_twig(array(get_twig_inc()));
|
||||
_add_twig_support($twig);
|
||||
$twig->setCache($GAME_ROOT . "/build/twig/metagen_cs_ecs");
|
||||
|
||||
foreach ($gen_components->getUnits() as $unit)
|
||||
{
|
||||
|
@ -124,4 +125,16 @@ function get_meta_units_files(\mtgMetaInfo $meta)
|
|||
foreach($meta->getUnits() as $u)
|
||||
$files[$u->file] = true;
|
||||
return array_keys($files);
|
||||
}
|
||||
|
||||
function _add_twig_support(\Twig\Environment $twig)
|
||||
{
|
||||
$twig->addFilter(new \Twig\TwigFilter('ecs_type',
|
||||
function($type)
|
||||
{
|
||||
if(($type instanceof \mtgUserType) && $type->hasToken("bhl_native_class"))
|
||||
return $type->getToken("bhl_native_class");
|
||||
return \metagen_cs\cs_type($type);
|
||||
}
|
||||
));
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
{%- macro ecs_component_field(obj, field) -%}
|
||||
public {{field.type|cs_type}} {{field.name}};
|
||||
public {{field.type|ecs_type}} {{field.name}};
|
||||
{%- endmacro -%}
|
Loading…
Reference in New Issue