-
dg authored
git-svn-id: http://svn.net-core.org/repos/t-engine4@4 51575b47-30f0-44d4-a5cc-537603b46e54
dg authoredgit-svn-id: http://svn.net-core.org/repos/t-engine4@4 51575b47-30f0-44d4-a5cc-537603b46e54
Entity.lua 813 B
module(..., package.seeall, class.make)
local next_uid = 1
-- Setup the uids repository as a weak value table, when the entities are no more used anywhere else they disappear from there too
setmetatable(__uids, {__mode="v"})
function _M:init(t)
print("entity init")
t = t or {}
self.uid = next_uid
__uids[self.uid] = self
self.display = t.display or '.'
self.color_r = t.color_r or 0
self.color_g = t.color_g or 0
self.color_b = t.color_b or 0
self.block_sight = t.block_sight
self.block_move = t.block_move
next_uid = next_uid + 1
end
-- If we are cloned we need a new uid
function _M:cloned()
self.uid = next_uid
__uids[self.uid] = self
next_uid = next_uid + 1
end
function _M:check(prop, ...)
if type(self[prop]) == "function" then return self[prop](...)
else return self[prop]
end
end