sonic-radiance/sonic-radiance.love/scenes/overworld/actors/gizmo.lua

55 lines
1.5 KiB
Lua
Raw Normal View History

2021-03-20 17:23:14 +01:00
local cwd = (...):gsub('%.gizmo$', '') .. "."
local Parent = require(cwd .. "parent")
local Gizmo = Parent:extend()
2021-03-20 21:08:54 +01:00
local defaultEffect = {
{"simpleMessage", "", "ERROR 000 NO EVENT"},
}
2021-03-20 17:23:14 +01:00
function Gizmo:new(world, x, y, w, h, overrides)
local w = w or 16;
local h = h or 16;
Gizmo.super.new(self, world, "gizmo", x, y, w, h, false)
self.overrides = overrides
end
function Gizmo:setProperties(properties)
self:setDefaultProperties()
self:replaceProperties(properties)
if (self.overrides ~= nil) then
self:replaceProperties(self.overrides)
end
self:applyProperties()
end
function Gizmo:applyProperties()
-- Apply properties to the internal item system
self.isSolid = self.properties.isSolid
self.mainHitbox.isSolid = self.properties.isSolid
if (self.isSolid) then
self:addHitbox("btnInput", "btnInput", -1, -1, self.w + 2, self.h + 2, false)
end
self.needButton = self.properties.needButton
end
function Gizmo:setDefaultProperties()
local default = require "game.utils.gizmo.properties"
self.properties = {}
for key, value in pairs(default) do
self.properties[key] = value
end
end
function Gizmo:replaceProperties(properties)
for key, _ in pairs(properties) do
if (properties[key] ~= nil) then
self.properties[key] = properties[key]
end
end
end
function Gizmo:doAction()
2021-03-20 21:08:54 +01:00
self.scene.events:startEvent(self, defaultEffect)
2021-03-20 17:23:14 +01:00
end
return Gizmo;