From ce5454d509b0a927710b5a27ce16281730eed166 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 21 Nov 2023 13:37:57 +0300 Subject: [PATCH] More strict checks during entity unpacking --- tpl/bind_ecslite.twig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tpl/bind_ecslite.twig b/tpl/bind_ecslite.twig index 891b1b2..e2a0e3c 100644 --- a/tpl/bind_ecslite.twig +++ b/tpl/bind_ecslite.twig @@ -8,8 +8,8 @@ EcsPackedEntityWithWorld e = default; stack.PopRelease().Decode(ref e); - if (e.Unpack(out EcsWorld world, out int id) == false) - return null; + if(e.Unpack(out EcsWorld world, out int id) == false) + throw new Exception("No entity found"); ref var cmp = ref world.GetPool<{{o.name}}>().Ensure(id); @@ -31,7 +31,7 @@ EcsPackedEntityWithWorld e = default; stack.PopRelease().Decode(ref e); - if (e.Unpack(out EcsWorld world, out int id) == false) + if(e.Unpack(out EcsWorld world, out int id) == false) return null; world.GetPool<{{o.name}}>().Del(id); @@ -56,7 +56,7 @@ var dv = bhl.Val.New(frm.vm); - if (e.Unpack(out EcsWorld world, out int id) == false) + if(e.Unpack(out EcsWorld world, out int id) == false) dv.SetBool(false); else dv.SetBool(world.GetPool<{{o.name}}>().Has(id)); @@ -101,8 +101,8 @@ EcsPackedEntityWithWorld e = default; stack.PopRelease().Decode(ref e); - if (e.Unpack(out EcsWorld world, out int id) == false) - return null; + if(e.Unpack(out EcsWorld world, out int id) == false) + throw new Exception("No entity found"); ref var cmp = ref world.GetPool<{{o.name}}>().Ensure(id); var v = cmp.{{f.name}}; @@ -145,8 +145,8 @@ stack.PopRelease().Decode(ref e); - if (e.Unpack(out EcsWorld world, out int id) == false) - return null; + if(e.Unpack(out EcsWorld world, out int id) == false) + throw new Exception("No entity found"); ref var cmp = ref world.GetPool<{{o.name}}>().Ensure(id);