group NPC runtime data together
This commit is contained in:
parent
e9de6a384c
commit
71d5a3bff2
|
@ -39,14 +39,17 @@ this.runtimeData = {
|
||||||
-- used for checking when entering wandering NPC's house, will probably remove
|
-- used for checking when entering wandering NPC's house, will probably remove
|
||||||
byCell = {}
|
byCell = {}
|
||||||
},
|
},
|
||||||
-- NPCs who have been moved
|
-- holder for all NPC data
|
||||||
movedNPCs = {},
|
NPCs = {
|
||||||
-- NPCs who stick around in bad weather and have been moved
|
-- NPCs who have been moved
|
||||||
movedBadWeatherNPCs = {},
|
moved = {},
|
||||||
-- NPCs who have been disabled
|
-- NPCs who stick around in bad weather and have been moved
|
||||||
disabledNPCs = {},
|
movedBadWeather = {},
|
||||||
-- NPCs who stick around in bad weather and have been disabled
|
-- NPCs who have been disabled
|
||||||
disabledBadWeatherNPCs = {},
|
disabled = {},
|
||||||
|
-- NPCs who stick around in bad weather and have been disabled
|
||||||
|
disabledBadWeather = {}
|
||||||
|
},
|
||||||
-- positions that haven't been used
|
-- positions that haven't been used
|
||||||
positions = {},
|
positions = {},
|
||||||
-- player companions
|
-- player companions
|
||||||
|
|
|
@ -16,11 +16,12 @@ local function moveNPC(homeData)
|
||||||
-- add to in memory table
|
-- add to in memory table
|
||||||
local badWeather = checks.isBadWeatherNPC(npc)
|
local badWeather = checks.isBadWeatherNPC(npc)
|
||||||
if badWeather then
|
if badWeather then
|
||||||
common.runtimeData.movedBadWeatherNPCs[homeData.ogPlaceName] = common.runtimeData.movedBadWeatherNPCs[homeData.ogPlaceName] or {}
|
common.runtimeData.NPCs.movedBadWeather[homeData.ogPlaceName] =
|
||||||
common.runtimeData.movedBadWeatherNPCs[homeData.ogPlaceName][npc.id] = homeData
|
common.runtimeData.NPCs.movedBadWeather[homeData.ogPlaceName] or {}
|
||||||
|
common.runtimeData.NPCs.movedBadWeather[homeData.ogPlaceName][npc.id] = homeData
|
||||||
else
|
else
|
||||||
common.runtimeData.movedNPCs[homeData.ogPlaceName] = common.runtimeData.movedNPCs[homeData.ogPlaceName] or {}
|
common.runtimeData.NPCs.moved[homeData.ogPlaceName] = common.runtimeData.NPCs.moved[homeData.ogPlaceName] or {}
|
||||||
common.runtimeData.movedNPCs[homeData.ogPlaceName][npc.id] = homeData
|
common.runtimeData.NPCs.moved[homeData.ogPlaceName][npc.id] = homeData
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set npc data, so we can move NPCs back after a load
|
-- set npc data, so we can move NPCs back after a load
|
||||||
|
@ -45,11 +46,11 @@ local function disableNPC(npc, cell)
|
||||||
-- same thing as moveNPC, but disables instead
|
-- same thing as moveNPC, but disables instead
|
||||||
-- add to runtimeData
|
-- add to runtimeData
|
||||||
if checks.isBadWeatherNPC(npc) then
|
if checks.isBadWeatherNPC(npc) then
|
||||||
common.runtimeData.disabledBadWeatherNPCs[cell.id] = common.runtimeData.disabledBadWeatherNPCs[cell.id] or {}
|
common.runtimeData.NPCs.disabledBadWeather[cell.id] = common.runtimeData.NPCs.disabledBadWeather[cell.id] or {}
|
||||||
common.runtimeData.disabledBadWeatherNPCs[cell.id][npc.id] = npc
|
common.runtimeData.NPCs.disabledBadWeather[cell.id][npc.id] = npc
|
||||||
else
|
else
|
||||||
common.runtimeData.disabledNPCs[cell.id] = common.runtimeData.disabledNPCs[cell.id] or {}
|
common.runtimeData.NPCs.disabled[cell.id] = common.runtimeData.NPCs.disabled[cell.id] or {}
|
||||||
common.runtimeData.disabledNPCs[cell.id][npc.id] = npc
|
common.runtimeData.NPCs.disabled[cell.id][npc.id] = npc
|
||||||
end
|
end
|
||||||
-- set NPC data
|
-- set NPC data
|
||||||
npc.data.NPCsGoHome = {disabled = true}
|
npc.data.NPCsGoHome = {disabled = true}
|
||||||
|
@ -132,11 +133,12 @@ local function checkForMovedOrDisabledNPCs(cell)
|
||||||
if npc.data.NPCsGoHome.disabled then
|
if npc.data.NPCsGoHome.disabled then
|
||||||
-- disabled NPC
|
-- disabled NPC
|
||||||
if badWeather then
|
if badWeather then
|
||||||
common.runtimeData.disabledBadWeatherNPCs[cell.id] = common.runtimeData.disabledBadWeatherNPCs[cell.id] or {}
|
common.runtimeData.NPCs.disabledBadWeather[cell.id] =
|
||||||
common.runtimeData.disabledBadWeatherNPCs[cell.id][npc.id] = npc
|
common.runtimeData.NPCs.disabledBadWeather[cell.id] or {}
|
||||||
|
common.runtimeData.NPCs.disabledBadWeather[cell.id][npc.id] = npc
|
||||||
else
|
else
|
||||||
common.runtimeData.disabledNPCs[cell.id] = common.runtimeData.disabledNPCs[cell.id] or {}
|
common.runtimeData.NPCs.disabled[cell.id] = common.runtimeData.NPCs.disabled[cell.id] or {}
|
||||||
common.runtimeData.disabledNPCs[cell.id][npc.id] = npc
|
common.runtimeData.NPCs.disabled[cell.id][npc.id] = npc
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- homed NPC
|
-- homed NPC
|
||||||
|
@ -147,11 +149,13 @@ local function checkForMovedOrDisabledNPCs(cell)
|
||||||
|
|
||||||
-- add to in memory table
|
-- add to in memory table
|
||||||
if badWeather then
|
if badWeather then
|
||||||
common.runtimeData.movedBadWeatherNPCs[homeData.ogPlaceName] = common.runtimeData.movedBadWeatherNPCs[homeData.ogPlaceName] or {}
|
common.runtimeData.NPCs.movedBadWeather[homeData.ogPlaceName] =
|
||||||
common.runtimeData.movedBadWeatherNPCs[cell.id][npc.id] = homeData
|
common.runtimeData.NPCs.movedBadWeather[homeData.ogPlaceName] or {}
|
||||||
|
common.runtimeData.NPCs.movedBadWeather[cell.id][npc.id] = homeData
|
||||||
else
|
else
|
||||||
common.runtimeData.movedNPCs[homeData.ogPlaceName] = common.runtimeData.movedNPCs[homeData.ogPlaceName] or {}
|
common.runtimeData.NPCs.moved[homeData.ogPlaceName] =
|
||||||
common.runtimeData.movedNPCs[cell.id][npc.id] = homeData
|
common.runtimeData.NPCs.moved[homeData.ogPlaceName] or {}
|
||||||
|
common.runtimeData.NPCs.moved[cell.id][npc.id] = homeData
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -216,8 +220,8 @@ this.processNPCs = function(cell)
|
||||||
-- LuaFormatter off
|
-- LuaFormatter off
|
||||||
-- check for bad weather NPCs that have been disabled, and re-enable them
|
-- check for bad weather NPCs that have been disabled, and re-enable them
|
||||||
if config.keepBadWeatherNPCs then
|
if config.keepBadWeatherNPCs then
|
||||||
if not common.isEmptyTable(common.runtimeData.movedBadWeatherNPCs[cell.id]) then putNPCsBack(common.runtimeData.movedBadWeatherNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.movedBadWeather[cell.id]) then putNPCsBack(common.runtimeData.NPCs.movedBadWeather[cell.id]) end
|
||||||
if not common.isEmptyTable(common.runtimeData.disabledBadWeatherNPCs[cell.id]) then reEnableNPCs(common.runtimeData.disabledBadWeatherNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.disabledBadWeather[cell.id]) then reEnableNPCs(common.runtimeData.NPCs.disabledBadWeather[cell.id]) end
|
||||||
end
|
end
|
||||||
elseif night then
|
elseif night then
|
||||||
log(common.logLevels.large, "[PROC] !!Good or bad weather and night!!")
|
log(common.logLevels.large, "[PROC] !!Good or bad weather and night!!")
|
||||||
|
@ -228,10 +232,10 @@ this.processNPCs = function(cell)
|
||||||
else
|
else
|
||||||
log(common.logLevels.large, "[PROC] !!Good weather and not night!!")
|
log(common.logLevels.large, "[PROC] !!Good weather and not night!!")
|
||||||
-- put everyone back
|
-- put everyone back
|
||||||
if not common.isEmptyTable(common.runtimeData.movedNPCs[cell.id]) then putNPCsBack(common.runtimeData.movedNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.moved[cell.id]) then putNPCsBack(common.runtimeData.NPCs.moved[cell.id]) end
|
||||||
if not common.isEmptyTable(common.runtimeData.movedBadWeatherNPCs[cell.id]) then putNPCsBack(common.runtimeData.movedBadWeatherNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.movedBadWeather[cell.id]) then putNPCsBack(common.runtimeData.NPCs.movedBadWeather[cell.id]) end
|
||||||
if not common.isEmptyTable(common.runtimeData.disabledNPCs[cell.id]) then reEnableNPCs(common.runtimeData.disabledNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.disabled[cell.id]) then reEnableNPCs(common.runtimeData.NPCs.disabled[cell.id]) end
|
||||||
if not common.isEmptyTable(common.runtimeData.disabledBadWeatherNPCs[cell.id]) then reEnableNPCs(common.runtimeData.disabledBadWeatherNPCs[cell.id]) end
|
if not common.isEmptyTable(common.runtimeData.NPCs.disabledBadWeather[cell.id]) then reEnableNPCs(common.runtimeData.NPCs.disabledBadWeather[cell.id]) end
|
||||||
-- LuaFormatter on
|
-- LuaFormatter on
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,9 +101,8 @@ local function updateCells()
|
||||||
log(common.logLevels.large, "[MAIN] Applying changes to cell %s", cell.id)
|
log(common.logLevels.large, "[MAIN] Applying changes to cell %s", cell.id)
|
||||||
|
|
||||||
-- initialize runtime data if needed
|
-- initialize runtime data if needed
|
||||||
for _, t in pairs({"movedNPCs", "movedBadWeatherNPCs", "disabledNPCs", "disabledBadWeatherNPCs"}) do
|
for _, t in pairs(common.runtimeData.NPCs) do t[cell.id] = t[cell.id] or {} end
|
||||||
common.runtimeData[t][cell.id] = common.runtimeData[t][cell.id] or {}
|
|
||||||
end
|
|
||||||
applyChanges(cell)
|
applyChanges(cell)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue