Starting to use faster EcsPools caching

This commit is contained in:
Pavel Shevaev 2024-11-19 11:27:24 +03:00
parent 8218301b0c
commit 3be17ed0d0
1 changed files with 6 additions and 10 deletions

View File

@ -11,7 +11,7 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
throw new Exception("No entity found");
world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
return null;
}
@ -34,7 +34,7 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
return null;
world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Del(id);
world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Del(id);
return null;
}
@ -59,7 +59,7 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
dv.SetBool(false);
else
dv.SetBool(world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Has(id));
dv.SetBool(world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Has(id));
stack.Push(dv);
return null;
@ -108,22 +108,18 @@
{%- if token_or(f, 'bhl_set', 1) != 0 ~%}
if(dv != null)
{
ref var cmp = ref world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
ref var cmp = ref world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>().Ensure(id);
{%- if f.type is instanceof('\\mtgArrType') -%}
if(dv._obj != null && !dv._obj.Equals(cmp.{{f.name}}))
{%- endif ~%}
{
{{ bhl_bind.val2native(f.type, 'dv', 'cmp.'~f.name) }};
}
//NOTE: uncomment to disable 'dv' variable re-use
//dv.Release();
//dv = Val.New(frm.vm);
//{{ bhl_bind.native2val(f.type, 'cmp.'~f.name, 'dv') }};
}
else
{%- endif ~%}
{
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
var pool = world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>();
if(pool.Has(id))
{
dv = Val.New(frm.vm);
@ -162,7 +158,7 @@
if(e.Unpack(out EcsWorld world, out int id) == false)
throw new Exception("No entity found");
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
var pool = world.GetPoolCached<{{token_or(o, 'bhl_native_class', o.name)}}>();
if(pool.Has(id))
{