Add powered neon wire rendering
This commit is contained in:
parent
cb1b5006b9
commit
17140fe39f
4 changed files with 71 additions and 0 deletions
14
world.lua
14
world.lua
|
|
@ -494,6 +494,20 @@ function World:wireSwitchColorsAt(room, localCell, circuitId)
|
|||
return colors
|
||||
end
|
||||
|
||||
-- A valid wire is bright only while every switch at its sole terminal cell is
|
||||
-- pressed. Rendering reads this derived state rather than entity sprite flags
|
||||
-- so every segment of a cross-room component agrees in the same frame.
|
||||
function World:wirePoweredAt(room, localCell, circuitId)
|
||||
local worldCell = self:worldCell(room, localCell)
|
||||
local component = worldCell and self.circuitComponents and
|
||||
self.circuitComponents[circuitId] and self.circuitComponents[circuitId][cellKey(worldCell)]
|
||||
if not component or not component.valid then return false end
|
||||
for switch in pairs(component.switches) do
|
||||
if not (self.circuitState and self.circuitState.switchPressed[switch]) then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function World:wireColorAt(room, localCell, circuitId, visibleColors)
|
||||
local colors = self:wireSwitchColorsAt(room, localCell, circuitId)
|
||||
if not colors then return nil end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue