better wirer behavior etc
This commit is contained in:
parent
bc4976b324
commit
6a5c2fc951
24 changed files with 11347 additions and 8198 deletions
43
world.lua
43
world.lua
|
|
@ -429,13 +429,16 @@ function World:resolveCircuits()
|
|||
local position = {x = x, y = y}
|
||||
local key = cellKey(position)
|
||||
local tracks = self.wireMatrix[y] and self.wireMatrix[y][x]
|
||||
local runCount, powered = 0, tracks ~= nil
|
||||
-- A circuit can be started with a click before the author drags its
|
||||
-- first segment. Those zero-length fragments are not a completed
|
||||
-- electrical run, so they must not permanently lock a door that also
|
||||
-- has real door-to-switch routes. Only valid components participate
|
||||
-- in the door's AND condition.
|
||||
local runCount, powered = 0, true
|
||||
for circuitId in pairs(tracks or {}) do
|
||||
runCount = runCount + 1
|
||||
local component = components[circuitId] and components[circuitId][key]
|
||||
if not component or not component.valid then
|
||||
powered = false
|
||||
else
|
||||
if component and component.valid then
|
||||
runCount = runCount + 1
|
||||
for switch in pairs(component.switches) do
|
||||
if not switchPressed[switch] then powered = false end
|
||||
end
|
||||
|
|
@ -676,7 +679,35 @@ end
|
|||
|
||||
function World:switchPlayerColor(room, color)
|
||||
local player = room.player[color]
|
||||
if not player then return false end
|
||||
if not player then
|
||||
-- A colour copy can be parked in another world room. Number keys are a
|
||||
-- direct way to resume controlling it: keep every copy where it is, but
|
||||
-- make its owner the active room and select that colour there.
|
||||
local destination
|
||||
for name, candidate in pairs(self.levels or {}) do
|
||||
if self:roomLocation(name) and candidate.player[color] then
|
||||
destination = candidate
|
||||
break
|
||||
end
|
||||
end
|
||||
if not destination then return false end
|
||||
|
||||
for _, possibleColor in ipairs(room:getPossibleColors()) do
|
||||
room:setActiveColor(possibleColor, false)
|
||||
end
|
||||
for _, possibleColor in ipairs(destination:getPossibleColors()) do
|
||||
destination:setActiveColor(possibleColor, possibleColor == color)
|
||||
end
|
||||
|
||||
currentRoom = destination
|
||||
self.lastRoom = destination.name
|
||||
destination.player[color]:playSwitchSound(true)
|
||||
self:markDirty(room)
|
||||
self:markDirty(destination)
|
||||
self:flushRuntime()
|
||||
setEditorRoomName(destination.name)
|
||||
return true
|
||||
end
|
||||
local activeColors = room:getActiveColors()
|
||||
local canSwitch = #activeColors ~= 1 or activeColors[1] ~= color
|
||||
if canSwitch then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue