| 12345678910111213141516171819202122232425262728293031323334 |
- --[[
- ECS Entity class
- @author : Eiyeron Fulmincendii
- An entity is not much more than its own ID and a few helpers to manage its own components via the holder world.
- ]]--
- local class = require("class")
- local object = require("object")
- Entity = class(object)
- function Entity:init(index, world)
- self.__destroyed = false
- self.__destroy_required = false
- self.__eid = index
- self.__world = world
- end
- function Entity:addComponent(component_type, ...)
- self.__world:attachComponentToEntity(self, component_type, ...)
- end
- function Entity:removeComponent(component_type)
- self.__world:detachComponentFromEntity(self, component_type)
- end
- function Entity:hasComponent(component_type)
- return self.__world:entityHasComponent(self, component_type)
- end
- function Entity:getComponent(component_type)
- return self.__world:entityGetComponent(self, component_type)
- end
- return Entity
|