idk even anymore
This commit is contained in:
parent
7fa9171ba1
commit
febaaaacc7
13 changed files with 2239 additions and 1508 deletions
30
room.lua
30
room.lua
|
|
@ -423,6 +423,10 @@ function Room:tick()
|
|||
for _, door in pairs(self.doors) do
|
||||
door:setColors(setDoorColors)
|
||||
end
|
||||
-- Door:setColors can change collision from unmoveable to none. Rebuild once
|
||||
-- more after that state change so an open-looking door is passable on the
|
||||
-- very next input, rather than leaving the previous tick's solid cell here.
|
||||
self:createCollideablesMatrix()
|
||||
self:nextRoomCheck()
|
||||
end
|
||||
|
||||
|
|
@ -653,7 +657,10 @@ function Room:attemptPlace(name, props, mouseX, mouseY, color)
|
|||
end
|
||||
|
||||
function Room:load(name)
|
||||
local room = readFromSource("rooms/" .. name .. ".sav")
|
||||
-- Runtime rooms are game state: let LÖVE resolve them from its save
|
||||
-- directory, where Room:save writes autosaves. Source files remain the
|
||||
-- shipped/editor versions until the editor explicitly saves one.
|
||||
local room = love.filesystem.read("rooms/" .. name .. ".sav")
|
||||
if not room then
|
||||
-- no save yet: start with a blank room to build in the editor
|
||||
print("no save for '" .. name .. "', starting blank")
|
||||
|
|
@ -672,10 +679,19 @@ function Room:save()
|
|||
local name = self.name or "test"
|
||||
local room = TSerial.pack(self:serialize(), nil, true)
|
||||
|
||||
local success = writeToSource("rooms/" .. name .. ".sav", room)
|
||||
local success = love.filesystem.write("rooms/" .. name .. ".sav", room)
|
||||
if not success then error "great job u fool" end
|
||||
end
|
||||
|
||||
-- This is intentionally separate from Room:save. It is the editor's explicit
|
||||
-- "write this level into the project" action; gameplay autosaves must never
|
||||
-- call it.
|
||||
function Room:saveToSource(name)
|
||||
name = name or self.name or "test"
|
||||
local room = TSerial.pack(self:serialize(), nil, true)
|
||||
return writeToSource("rooms/" .. name .. ".sav", room)
|
||||
end
|
||||
|
||||
function Room:serialize()
|
||||
local objects = {}
|
||||
|
||||
|
|
@ -734,14 +750,18 @@ function nextRoom(pos)
|
|||
newPos.y = gridHeight
|
||||
end
|
||||
|
||||
local currentName = currentRoom.name
|
||||
local nextName = gameWorld and currentName and gameWorld:getNeighbor(currentName, exit)
|
||||
currentRoom:save()
|
||||
|
||||
currentRoom = Room:new{
|
||||
-- name = "test",
|
||||
-- Missing map neighbours intentionally wrap back into the room just exited.
|
||||
-- A placed neighbour gets the same carried player state at its opposite edge.
|
||||
currentRoom = Room:new{
|
||||
name = nextName or currentName,
|
||||
player = {
|
||||
x = newPos.x, y = newPos.y, activeColors = currentRoom:getActiveColors()
|
||||
}
|
||||
}
|
||||
if currentRoom.name then setEditorRoomName(currentRoom.name) end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue