Fixed Component Ref

This commit is contained in:
wrenge 2023-01-25 16:35:53 +03:00
parent 13c2ff02ae
commit 6fae999687
1 changed files with 9 additions and 6 deletions

View File

@ -784,6 +784,7 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
var dv = bhl.Val.New(frm.vm);
dv._obj = e.GetInternalWorld();
dv._num = e.GetInternalId();
dv._num2 = e.GetInternalGen();
dv.type = cl;
stack.Push(dv);
@ -907,9 +908,10 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
delegate(VM.Frame frm, Val ctx, ref Val v, FieldSymbol fld) {
#if !BHL_FRONT
var pool = ((Leopotam.Ecs.EcsWorld)ctx.obj).GetPool<ecs.{{o.name}}>();
int idx = (int)ctx._num;
ref var f = ref pool.GetItem(idx);
var ent = ((EcsWorld)ctx._obj).RestoreEntityFromInternalId((int)ctx._num, (int)ctx._num2);
if(!ent.IsAlive() || !ent.Has<ecs.{{o.name}}>())
throw new System.Exception("Component '{{o.name}}' is no longer valid");
ref var f = ref ent.Ensure<ecs.{{o.name}}>();
{{ _self.native2val(f.type, 'f.' ~ f.name, 'v') }};
#endif
@ -925,9 +927,10 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
delegate(VM.Frame frm, ref Val ctx, Val v, FieldSymbol fld) {
#if !BHL_FRONT
var pool = ((Leopotam.Ecs.EcsWorld)ctx.obj).GetPool<ecs.{{o.name}}>();
int idx = (int)ctx._num;
ref var f = ref pool.GetItem(idx);
var ent = ((EcsWorld)ctx._obj).RestoreEntityFromInternalId((int)ctx._num, (int)ctx._num2);
if(!ent.IsAlive() || !ent.Has<ecs.{{o.name}}>())
throw new System.Exception("Component '{{o.name}}' is no longer valid");
ref var f = ref ent.Ensure<ecs.{{o.name}}>();
{{ _self.val2native(f.type, 'v', 'f.' ~ f.name) }};
#endif