Prevent doors closing through occupants
This commit is contained in:
parent
bf09a8844a
commit
9731202739
5 changed files with 108 additions and 6 deletions
21
room.lua
21
room.lua
|
|
@ -538,10 +538,29 @@ end
|
|||
function Room:resolveSwitchesAndDoors()
|
||||
local setDoorColors = self:switchCheck()
|
||||
for _, door in pairs(self.doors) do
|
||||
door:setColors(setDoorColors)
|
||||
door:setColors(setDoorColors, self:doorCanClose(door))
|
||||
end
|
||||
end
|
||||
|
||||
-- Match World:doorCanClose for ordinary room-local doors. All colour layers
|
||||
-- count, while other layers of the same doorway do not obstruct each other.
|
||||
function Room:doorCanClose(door)
|
||||
for _, cell in ipairs(door:getOccupiedCells()) do
|
||||
for _, player in pairs(self.player or {}) do
|
||||
if player:occupiesCell(cell) then return false end
|
||||
end
|
||||
for _, entities in pairs(self.collideables or {}) do
|
||||
for _, entity in ipairs(entities) do
|
||||
if entity ~= door and not entity.isDoor and entity:occupiesCell(cell) and
|
||||
not (entity.canPassOver and entity:canPassOver()) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function Room:playerJoinCheck(previousPositions, newPositions)
|
||||
local activate = {}
|
||||
local deactivate = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue