Add Jorge dialogable NPC

This commit is contained in:
Your Name 2026-08-11 20:10:03 -04:00
parent e5e80c2754
commit 0d05e83c18
11 changed files with 46 additions and 1 deletions

View file

@ -474,6 +474,11 @@ function Room:createEntity(class, color, x, y)
self:registerNpc(entity)
return entity
end
if class == "jorge" then
local entity = Jorge:new(x, y)
self:registerNpc(entity)
return entity
end
local props = globalAssetProperties and globalAssetProperties[class]
local behavior = props and props.class or "immoveable"
@ -599,12 +604,25 @@ function Room:attemptDelete(mouseX, mouseY, color)
for index = #self.doors, 1, -1 do
if removedEntities[self.doors[index]] then table.remove(self.doors, index) end
end
-- NPCs are stamped into every collision layer, but are kept in their own
-- registry rather than in self.collideables. Remove them directly so a
-- right-click works no matter which editor colour is currently selected.
for index = #self.npcs, 1, -1 do
if self.npcs[index]:occupiesCell(cell) then table.remove(self.npcs, index) end
end
self:tick()
end
function Room:attemptPlace(name, props, mouseX, mouseY, color)
if not props or not props.sprites then return end
local cell = self:getCellFromMousePos(mouseX, mouseY)
-- Jorge is one dialogable NPC with three display channels, not three
-- independently placeable color-layer entities.
if name == "jorge" then
self:createEntity(name, nil, cell.x, cell.y)
self:tick()
return
end
-- "white" (or nil) means every channel; otherwise just the picked channel
local colors
@ -703,7 +721,7 @@ function Room:serialize(includePlayers)
end
for _, npc in ipairs(self.npcs) do
table.insert(objects, { class = "npc", x = npc.x, y = npc.y })
table.insert(objects, { class = npc.saveClass or "npc", x = npc.x, y = npc.y })
end
return { objects = objects }