Trying to implement more optimal access to components, not using Ensure for getters

This commit is contained in:
Pavel Shevaev 2024-11-05 19:39:20 +03:00
parent 587b3b607d
commit a45406df59
1 changed files with 24 additions and 9 deletions

View File

@ -11,7 +11,7 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
throw new Exception("No entity found");
ref var cmp = ref world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
return null;
}
@ -160,17 +160,32 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
throw new Exception("No entity found");
ref var cmp = ref world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
{%~ if m.returntype %}
var return_val =
{%- endif ~%}
{%~ if m.returntype %}
if(pool.Has(id))
{
var return_val =
cmp.{{m.name}}(
{%- for arg in m.args ~%} __{{arg.name}}{% if not loop.last %},{% endif %} {%- endfor ~%}
);
pool.Get(id).{{m.name}}(
{%- for arg in m.args ~%} __{{arg.name}}{% if not loop.last %},{% endif %} {%- endfor ~%}
);
{{ bhl_bind.return_val(m, 'return_val') }}
{{ bhl_bind.return_val(m, 'return_val') }}
}
else
{
//unspecified value
var dv = bhl.Val.New(frm.vm);
stack.Push(dv);
}
{%- else ~%}
pool.Ensure(id).{{m.name}}(
{%- for arg in m.args ~%} __{{arg.name}}{% if not loop.last %},{% endif %} {%- endfor ~%}
);
{%- endif ~%}
return null;
}