Skip to content
Snippets Groups Projects
Commit 500fc5fa authored by dg's avatar dg
Browse files

Fix objects not recharging (I think)

git-svn-id: http://svn.net-core.org/repos/t-engine4@2338 51575b47-30f0-44d4-a5cc-537603b46e54
parent 3c614341
No related branches found
No related tags found
No related merge requests found
......@@ -121,3 +121,8 @@ function _M:removeEntity(e)
if not self.entities[e.uid] then error("Entity "..e.uid.." not present in the game") end
self.entities[e.uid] = nil
end
--- Does the game have this entity ?
function _M:hasEntity(e)
return self.entities[e.uid]
end
......@@ -52,6 +52,13 @@ function _M:resolve(t, last, on_entity)
end
end
--- Loaded, we add ourself back to the game
function _M:loaded()
engine.Entity.loaded(self)
if not game:hasEntity(self) then game:addEntity(self) end
end
--- Can this object act at all
-- Most object will want to answer false, only recharging and stuff needs them
function _M:canAct()
......
......@@ -103,6 +103,9 @@ function _M:addObject(inven_id, o)
self:onAddObject(o)
-- Make sure the object is registered with the game, if need be
if not game:hasEntity(o) then game:addEntity(o) end
return true, #inven
end
......@@ -171,6 +174,9 @@ function _M:removeObject(inven, item, no_unstack)
self:onRemoveObject(o)
-- Make sure the object is registered with the game, if need be
if not game:hasEntity(o) then game:addEntity(o) end
return o, finish
end
......
......@@ -61,6 +61,9 @@ function _M:getUseDesc()
end
function _M:useObject(who, ...)
-- Make sure the object is registered with the game, if need be
if not game:hasEntity(self) then game:addEntity(self) end
if self.use_power then
if self.power >= self.use_power.power then
local rets = { self.use_power.use(self, who, ...) }
......
......@@ -108,7 +108,7 @@ newEntity{
newEntity{
define_as = "ROCK_VAULT",
type = "wall", subtype = "grass",
name = "huge lose rock", image = "terrain/grass.png", add_displays = {class.new{image="terrain/rock_grass.png"}},
name = "huge loose rock", image = "terrain/grass.png", add_displays = {class.new{image="terrain/rock_grass.png"}},
display = '+', color=colors.GREY, back_color={r=44,g=95,b=43},
notice = true,
always_remember = true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment