feat: add an index in the battlesystem world
This commit is contained in:
parent
c9644b2e86
commit
e30ab97e96
2 changed files with 13 additions and 0 deletions
|
@ -35,6 +35,11 @@ function Parent:new(world, x, y, z)
|
|||
self:register()
|
||||
end
|
||||
|
||||
function Parent:setIndexName(indexName)
|
||||
self.indexName = indexName
|
||||
self.world.index[self.indexName] = self
|
||||
end
|
||||
|
||||
function Parent:register()
|
||||
self.world:registerActor(self)
|
||||
end
|
||||
|
@ -42,6 +47,9 @@ end
|
|||
function Parent:destroy()
|
||||
self.world:destroyActor(self)
|
||||
self.isDestroyed = true
|
||||
if (self.indexName ~= nil) then
|
||||
self.world.index[self.indexName] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function Parent:update(dt)
|
||||
|
|
|
@ -29,6 +29,7 @@ function World:new(scene, battlefile)
|
|||
self.globalID = 0
|
||||
|
||||
self.map = Map(scene, HEIGHT, BORDER_BOTTOM, "city")
|
||||
self.index = {}
|
||||
|
||||
self.isBattleActive = false
|
||||
end
|
||||
|
@ -68,6 +69,10 @@ function World:getActorInCase(x, y, notThisActor)
|
|||
return nil
|
||||
end
|
||||
|
||||
function World:getActorByName(name)
|
||||
return self.index[name]
|
||||
end
|
||||
|
||||
-- UPDATE FUNCTION
|
||||
-- Update all actors
|
||||
|
||||
|
|
Loading…
Reference in a new issue