From 5365f23c30c8819dbecdc3b931dcbf4818c36d5f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 7 Apr 2019 13:31:25 +0200 Subject: [PATCH] modules/world: port all actor functions from IP --- gamecore/modules/world/baseworld.lua | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 8068062..1b8951a 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -16,10 +16,44 @@ function BaseWorld:registerActor(actor) table.insert(self.actors, actor) end +function World:removeActor(actor) + for i,v in ipairs(self.actors) do + if v == actor then + table.remove(self.actors, i) + end + end +end + +function World:moveActor(actor, x, y, filter) + self.actors[actor].x = x + self.actors[actor].y = y + -- as the baseworld have no collision function, we return empty collision + -- datas, but from the same type than bump2D will return + return x, y, {}, 0 +end + +function World:queryRect(x, y, w, h) + local query = {} + local x2, y2 = x + w, y + h + for i,v in ipairs(self.actors) do + if (v.x >= x) and (v.x + v.w >= x1) and + (v.y >= y) and (v.y + v.h >= y1) then + + table.insert(query, v) + end + end + + return v +end + function BaseWorld:countActors() return #self.actors end +function World:getActors() + return self.actors +end + -- UPDATE FUNCTIONS -- All update functions