-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathEconomy.lua
More file actions
43 lines (39 loc) · 1.66 KB
/
Copy pathEconomy.lua
File metadata and controls
43 lines (39 loc) · 1.66 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
local INLOS_ACCESS = {inlos = true}
local spSetUnitRulesParam=Spring.SetUnitRulesParam
GG.att_EconomyChange={}
return {
---@type AttributesHandlerFactory
Economy = {
handledAttributeNames={econ=true,energy=true},
new = function(unitID, unitDefID)
local econMultCur = 1
local energyMultCur = 1
return {
newDataHandler = function(frame)
local econMult = 1
local energyMult = 1
return {
fold = function(data)
econMult = econMult * (data.econ or 1)
energyMult = energyMult * (data.energy or 1)
end,
apply = function()
GG.att_EconomyChange[unitID] = econMult
if econMult ~= econMultCur or energyMult ~= energyMultCur then
spSetUnitRulesParam(unitID, "totalEconomyChange", econMult, INLOS_ACCESS)
spSetUnitRulesParam(unitID, "metalGenerationFactor", econMult, INLOS_ACCESS)
spSetUnitRulesParam(unitID, "energyGenerationFactor", econMult * energyMult, INLOS_ACCESS)
econMultCur = econMult
energyMultCur = energyMult
end
end
}
end,
clear = function()
GG.att_EconomyChange[unitID] = nil
-- Reset logic can be added here if needed
end
}
end
}
}