add entity:require_component
This commit is contained in:
@@ -63,6 +63,13 @@ local Entity = {__index={
|
||||
get_skeleton=function(self) return entities.get_skeleton(self.eid) end,
|
||||
set_skeleton=function(self, s) return entities.set_skeleton(self.eid, s) end,
|
||||
get_component=function(self, name) return self.components[name] end,
|
||||
require_component=function(self, name)
|
||||
local component = self.components[name]
|
||||
if not component then
|
||||
error(("entity has no required component '%s'"):format(name))
|
||||
end
|
||||
return component
|
||||
end,
|
||||
has_component=function(self, name) return self.components[name] ~= nil end,
|
||||
get_uid=function(self) return self.eid end,
|
||||
def_index=function(self) return entities.get_def(self.eid) end,
|
||||
|
||||
Reference in New Issue
Block a user