From e22a293f03816dba6e68597c55cdd5f4dcd715b9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 20 Mar 2021 16:08:10 +0100 Subject: [PATCH] feat:make actor able to load sti properties --- .../core/modules/world/actors/baseactor.lua | 4 ++++ sonic-radiance.love/core/modules/world/baseworld.lua | 7 +++++-- sonic-radiance.love/core/modules/world/maps/sti.lua | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sonic-radiance.love/core/modules/world/actors/baseactor.lua b/sonic-radiance.love/core/modules/world/actors/baseactor.lua index a82f1c2..1cd0a0b 100644 --- a/sonic-radiance.love/core/modules/world/actors/baseactor.lua +++ b/sonic-radiance.love/core/modules/world/actors/baseactor.lua @@ -45,6 +45,10 @@ function BaseActor:new(world, type, x, y, z, w, h, d, isSolid) self:register() end +function BaseActor:setProperties(properties) + -- Do something here +end + function BaseActor:setManagers(world) self.world = world self.scene = world.scene diff --git a/sonic-radiance.love/core/modules/world/baseworld.lua b/sonic-radiance.love/core/modules/world/baseworld.lua index 889420a..f16e67e 100644 --- a/sonic-radiance.love/core/modules/world/baseworld.lua +++ b/sonic-radiance.love/core/modules/world/baseworld.lua @@ -102,10 +102,13 @@ function BaseWorld:initActors( ) self.currentCreationID = 0 end -function BaseWorld:newActor(name, x, y, z) +function BaseWorld:newActor(name, x, y, z, properties) local debugstring = " at (" .. x .. ";" .. y .. ")." core.debug:print("world2D", "adding actor " .. name .. debugstring) - self.obj.index[name](self, x, y) + local actor = self.obj.index[name](self, x, y) + if (properties ~= nil) then + actor:setProperties(properties) + end end function BaseWorld:newCollision(name, x, y, z, w, h, d) diff --git a/sonic-radiance.love/core/modules/world/maps/sti.lua b/sonic-radiance.love/core/modules/world/maps/sti.lua index 86980a7..6554959 100644 --- a/sonic-radiance.love/core/modules/world/maps/sti.lua +++ b/sonic-radiance.love/core/modules/world/maps/sti.lua @@ -90,7 +90,7 @@ function StiMap:batchActor(objectlayer, object) for i=1, cellHor do for j=1, cellVert do - self.world:newActor(name, x + (i-1)*gwidth, y + (j-1)*gheight, z) + self.world:newActor(name, x + (i-1)*gwidth, y + (j-1)*gheight, z, object.properties) end end end @@ -104,7 +104,7 @@ function StiMap:newActor(objectlayer, object) y = y + z end - self.world:newActor(objectlayer.name, object.x, y, z) + self.world:newActor(objectlayer.name, object.x, y, z, object.properties) end function StiMap:newCollision(objectlayer, object)