diff --git a/sonic-radiance.love/game/utils/gizmo/properties.lua b/sonic-radiance.love/game/utils/gizmo/properties.lua index f57b46e..4f0bb73 100644 --- a/sonic-radiance.love/game/utils/gizmo/properties.lua +++ b/sonic-radiance.love/game/utils/gizmo/properties.lua @@ -1,4 +1,5 @@ return { isSolid = false, needButton = true, -- "useButton" or "onContact" + destroy = "none", } \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/actors/gizmo.lua b/sonic-radiance.love/scenes/overworld/actors/gizmo.lua index 6f4df2e..76f6eb8 100644 --- a/sonic-radiance.love/scenes/overworld/actors/gizmo.lua +++ b/sonic-radiance.love/scenes/overworld/actors/gizmo.lua @@ -15,6 +15,10 @@ function Gizmo:new(world, x, y, w, h, overrides) self.event = defaultEvent end +function Gizmo:getUniqueId() + return "gizmo" .. ":" .. self.mapname .. ":" .. self.x .. ":" .. self.y +end + function Gizmo:setProperties(properties) self:setDefaultProperties() self:replaceProperties(properties) @@ -39,6 +43,10 @@ function Gizmo:applyProperties() local data = require("datas.gamedata.events." .. self.properties.event) self.event = data.actions end + self.uniqueId = self:getUniqueId() + if (game.destroyedGizmo[self.uniqueId] == true) then + self:destroy() + end end function Gizmo:setDefaultProperties() @@ -58,6 +66,16 @@ function Gizmo:replaceProperties(properties) end function Gizmo:doAction() + self:action() + if (self.properties.destroy ~= "none") then + if (self.properties.destroy == "forever") then + game.destroyedGizmo[self.uniqueId] = true + end + self:destroy() + end +end + +function Gizmo:action() self.scene.events:startEvent(self, self.event) end