Prevent doors closing through occupants

This commit is contained in:
Your Name 2026-08-12 00:21:53 -04:00
parent bf09a8844a
commit 9731202739
5 changed files with 108 additions and 6 deletions

View file

@ -11,6 +11,7 @@ function Door:initialize(x, y, color)
collision = "unmoveable",
sprite = loadSprite("art/game/door_" .. color:sub(1, 1) .. ".png"),
})
self.isDoor = true
self.locked = true
self:refreshSprites()
end
@ -27,10 +28,10 @@ function Door:refreshSprites()
self.sprites = { [self.doorColor] = sprite }
end
function Door:setColors(colors)
function Door:setColors(colors, canClose)
if colors[self.doorColor] then
if self.locked then self:unlock() end
else
elseif canClose ~= false then
if not self.locked then self:lock() end
end