Throwing an exception in getters if component is missing
This commit is contained in:
parent
a45406df59
commit
4fe094e39c
|
@ -123,13 +123,15 @@
|
|||
else
|
||||
{%- endif ~%}
|
||||
{
|
||||
dv = Val.New(frm.vm);
|
||||
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
|
||||
if(pool.Has(id))
|
||||
{
|
||||
dv = Val.New(frm.vm);
|
||||
var v = pool.Get(id).{{f.name}};
|
||||
{{ bhl_bind.native2val(f.type, 'v', 'dv') }};
|
||||
}
|
||||
else
|
||||
throw new Exception("No such component '{{token_or(o, 'bhl_native_class', o.name)}}' on entity: " + id);
|
||||
}
|
||||
stack.Push(dv);
|
||||
#endif
|
||||
|
@ -162,10 +164,11 @@
|
|||
|
||||
var pool = world.GetPool<{{token_or(o, 'bhl_native_class', o.name)}}>();
|
||||
|
||||
{%~ if m.returntype %}
|
||||
if(pool.Has(id))
|
||||
{
|
||||
{%~ if m.returntype %}
|
||||
var return_val =
|
||||
{%- endif ~%}
|
||||
|
||||
pool.Get(id).{{m.name}}(
|
||||
{%- for arg in m.args ~%} __{{arg.name}}{% if not loop.last %},{% endif %} {%- endfor ~%}
|
||||
|
@ -174,18 +177,7 @@
|
|||
{{ 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 ~%}
|
||||
throw new Exception("No such component '{{token_or(o, 'bhl_native_class', o.name)}}' on entity: " + id);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue