local cwd = (...):gsub('%.gizmo$', '') .. "." local Parent = require(cwd .. "parent") local Gizmo = Parent:extend() local defaultEffect = { {"simpleMessage", "", "ERROR 000 NO EVENT"}, } 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 self.drawDebugBox = true 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 self.charId = self.properties.charId or 1 self.charset = self.properties.charset or nil self.cantTurn = self.properties.cantTurn or self.cantTurn 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() self.scene.events:startEvent(self, defaultEffect) end return Gizmo;