-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
103 lines (86 loc) · 3.6 KB
/
Copy pathmain.lua
File metadata and controls
103 lines (86 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- =========================================================
-- FS25_DairyCore - mod entry point
-- =========================================================
-- Author: TisonK
-- =========================================================
-- Loads the DairyCore modules, publishes the g_currentMission.dairyCoreManager
-- handle, and hooks the FS25 mission lifecycle. Companion mod: it reads the
-- ecosystem (SoilFertilizer, MarketDynamics, RandomWorldEvents, WorkerCosts,
-- FuelCosts, NPCFavor, TaxMod, ProStaff, Ritter RLRM) and rides the Time Guard
-- clock. Every cross-mod edge is handle-gated + pcall-wrapped and degrades to
-- neutral when a companion is absent.
-- =========================================================
local modDirectory = g_currentModDirectory
source(modDirectory .. "src/Logger.lua")
source(modDirectory .. "src/DairyConstants.lua")
source(modDirectory .. "src/RLBridge.lua")
source(modDirectory .. "src/DairyCoreManager.lua")
-- Esc RF PDA framework joiner (NO-HOST).
source(g_currentModDirectory .. "src/gui/RfEscModules.lua")
source(g_currentModDirectory .. "src/gui/RfPdaMenuPage.lua")
source(g_currentModDirectory .. "src/gui/RfEscBootstrap.lua")
source(g_currentModDirectory .. "src/gui/RfEscUiDebugger.lua")
source(g_currentModDirectory .. "src/gui/DairyRfPdaGuest.lua")
local dairyCore = DairyCoreManager.new()
getfenv(0)["g_dairyCoreManager"] = dairyCore
local function onMissionLoad(mission)
if mission ~= nil then
mission.dairyCoreManager = dairyCore
end
DCLogger.info("DairyCore loaded")
end
local function onMissionLoadedFinished()
dairyCore:onMissionLoaded()
end
local function onMissionUpdate(mission, dt)
dairyCore:update(dt)
end
local function onMissionSave()
dairyCore:save()
end
local function onMissionDelete()
dairyCore:onMissionDelete()
getfenv(0)["g_dairyCoreManager"] = nil
if g_currentMission ~= nil then
g_currentMission.dairyCoreManager = nil
end
end
Mission00.load = Utils.appendedFunction(Mission00.load, onMissionLoad)
Mission00.loadMission00Finished = Utils.appendedFunction(Mission00.loadMission00Finished, onMissionLoadedFinished)
FSBaseMission.update = Utils.appendedFunction(FSBaseMission.update, onMissionUpdate)
if FSCareerMissionInfo ~= nil and FSCareerMissionInfo.saveToXMLFile ~= nil then
FSCareerMissionInfo.saveToXMLFile = Utils.appendedFunction(
FSCareerMissionInfo.saveToXMLFile,
function() onMissionSave() end
)
else
DCLogger.warning("FSCareerMissionInfo.saveToXMLFile not found - barn state will NOT be saved")
end
FSBaseMission.delete = Utils.prependedFunction(FSBaseMission.delete, onMissionDelete)
if addConsoleCommand ~= nil then
addConsoleCommand("dairyStatus", "Show DairyCore barns, mode, contracts",
"consoleCommandStatus", dairyCore)
end
local function _rfEscTryRegister()
if DairyRfPdaGuest ~= nil and type(DairyRfPdaGuest.tryRegister) == "function" then
pcall(DairyRfPdaGuest.tryRegister)
end
end
-- Esc RF PDA: register module after mission/door ready (retry-safe).
if Mission00 ~= nil then
Mission00.loadMission00Finished = Utils.appendedFunction(Mission00.loadMission00Finished, function()
_rfEscTryRegister()
end)
end
if FSBaseMission ~= nil then
FSBaseMission.onStartMission = Utils.appendedFunction(FSBaseMission.onStartMission, function()
_rfEscTryRegister()
end)
end
if FSBaseMission ~= nil then
FSBaseMission.delete = Utils.appendedFunction(FSBaseMission.delete, function()
if DairyRfPdaGuest ~= nil and type(DairyRfPdaGuest.reset) == "function" then
DairyRfPdaGuest.reset()
end
end)
end