room changes
This commit is contained in:
parent
8fae34b803
commit
38eaba2fa6
7 changed files with 2333 additions and 2108 deletions
25
room.lua
25
room.lua
|
|
@ -130,17 +130,30 @@ function Room:update(dt)
|
|||
end
|
||||
end
|
||||
|
||||
function Room:draw()
|
||||
-- A room's view is defined by the colour player copies that are in that room,
|
||||
-- independent of which of those copies is currently being controlled. A caller
|
||||
-- may supply another set for World's porous boundary without altering sprites
|
||||
-- or colour blending.
|
||||
function Room:getRenderChannels()
|
||||
if gameWorld and gameWorld.roomBrowseMode then return {"red", "green", "blue"} end
|
||||
local channels = {}
|
||||
for _, color in ipairs({"red", "green", "blue"}) do
|
||||
if self.player[color] then table.insert(channels, color) end
|
||||
end
|
||||
return channels
|
||||
end
|
||||
|
||||
function Room:draw(drawChannels)
|
||||
if gameWorld and gameWorld.levels and gameWorld.levels[self.name] == self and
|
||||
not gameWorld.drawingRoomNeighborhood then
|
||||
return gameWorld:drawRoomNeighborhood(self)
|
||||
end
|
||||
self:drawWiresAt(0, 0, width / gridWidth, nil, false)
|
||||
drawChannels = drawChannels or self:getRenderChannels()
|
||||
self:drawWiresAt(0, 0, width / gridWidth, nil, false, drawChannels)
|
||||
|
||||
-- draw only the channels the player has. Each object just exposes sprites per
|
||||
-- Draw only the channels active in this view. Each object just exposes sprites per
|
||||
-- channel via Entity:draw(channel); a door registered on all three channels
|
||||
-- naturally draws its red sprite on the red pass, etc. No per-object logic.
|
||||
local drawChannels = gameWorld and gameWorld.roomBrowseMode and {"red", "green", "blue"} or self.colorsPlayerHas
|
||||
for _, channel in ipairs(drawChannels) do
|
||||
if self.player[channel] then self.player[channel]:draw(channel) end
|
||||
for _, entity in pairs(self.collideables[channel]) do entity:draw(channel) end
|
||||
|
|
@ -190,7 +203,7 @@ function Room:removeWire(cell, circuitId)
|
|||
return true
|
||||
end
|
||||
|
||||
function Room:drawWiresAt(originX, originY, cellSize, selectedCircuit, editorColors)
|
||||
function Room:drawWiresAt(originX, originY, cellSize, selectedCircuit, editorColors, renderChannels)
|
||||
local ids = {}
|
||||
for _, row in pairs(self.wires) do
|
||||
for _, tracks in pairs(row) do
|
||||
|
|
@ -205,7 +218,7 @@ function Room:drawWiresAt(originX, originY, cellSize, selectedCircuit, editorCol
|
|||
local showAllChannels = gameWorld and gameWorld.roomBrowseMode
|
||||
local visibleColors = {red = showAllChannels, green = showAllChannels, blue = showAllChannels}
|
||||
if not showAllChannels then
|
||||
for _, color in ipairs(self.colorsPlayerHas or {}) do visibleColors[color] = true end
|
||||
for _, color in ipairs(renderChannels or self:getRenderChannels()) do visibleColors[color] = true end
|
||||
end
|
||||
local editorIsOn = editorView ~= nil and editorView ~= "off"
|
||||
for _, circuitId in ipairs(ordered) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue