Skip to content

Commit bef3fa7

Browse files
authored
Add files via upload
1 parent 56b00b4 commit bef3fa7

33 files changed

Lines changed: 9313 additions & 0 deletions
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
local DensityMapHeightManager_mt = Class(DensityMapHeightManager, AbstractManager)
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+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
---Load data on map load
119+
-- @return boolean true if loading was successful else false
120+
function DensityMapHeightManager:loadMapData(xmlFile, missionInfo, baseDirectory)
121+
DensityMapHeightManager:superClass().loadMapData(self)
122+
123+
if g_addCheatCommands then
124+
-- server only cheats
125+
if g_server ~= nil then
126+
addConsoleCommand("gsTipCollisionsShow", "Shows the collisions for tipping on the ground", "consoleCommandShowTipCollisions", self)
127+
addConsoleCommand("gsTipCollisionsUpdate", "Updates the collisions for tipping on the ground around the current camera", "consoleCommandUpdateTipCollisions", self)
128+
addConsoleCommand("gsTipAnywhereAdd", "Tips a fillType", "consoleCommandTipAnywhereAdd", self, "fillTypeName; amount; [length]; [rows]; [spacing]")
129+
addConsoleCommand("gsTipAnywhereAddAll", "Tips a heap of every fill type that can be tipped", "consoleCommandTipAnywhereAddAll", self)
130+
addConsoleCommand("gsTipAnywhereClear", "Clears tip area", "consoleCommandTipAnywhereClear", self)
131+
end
132+
133+
addConsoleCommand("gsDensityMapToggleDebug", "Toggles debug mode", "consoleCommandToggleDebug", self)
134+
addConsoleCommand("gsPlacementCollisionsShow", "Shows the collisions for placement and terraforming", "consoleCommandShowPlacementCollisions", self)
135+
end
136+
137+
self:loadDefaultTypes(missionInfo, baseDirectory)
138+
local success = XMLUtil.loadDataFromMapXML(xmlFile, "densityMapHeightTypes", baseDirectory, self, self.loadDensityMapHeightTypes, missionInfo, baseDirectory)
139+
140+
for i=#self.modDensityHeightMapTypeFilenames, 1, -1 do
141+
local filename = self.modDensityHeightMapTypeFilenames[i]
142+
143+
local heightTypesXmlFile = loadXMLFile("heightTypes", filename)
144+
self:loadDensityMapHeightTypes(heightTypesXmlFile, missionInfo, baseDirectory, false)
145+
delete(heightTypesXmlFile)
146+
147+
self.modDensityHeightMapTypeFilenames[i] = nil
148+
end
149+
150+
return success
151+
end

economy/Farmland.lua

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
---This class wraps all farmland data
12+
local Farmland_mt = Class(Farmland)
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
---Create field definition object
28+
-- @return table instance Instance of object
29+
function Farmland.new(customMt)
30+
local self = setmetatable({}, customMt or Farmland_mt)
31+
32+
self.isOwned = false
33+
self.xWorldPos = nil
34+
self.zWorldPos = nil
35+
self.field = nil
36+
37+
return self
38+
end
39+
40+
41+
---Load farmland data from xml
42+
-- @param integer xmlFile handle of xml file
43+
-- @param string key current xml element key
44+
-- @return boolean true if loading was successful else false
45+
function Farmland:load(xmlFile, key)
46+
self.id = xmlFile:getValue(key.."#id")
47+
48+
if self.id == nil or self.id == 0 then
49+
Logging.xmlError(xmlFile, "Invalid farmland id '%s'!", self.id)
50+
return false
51+
end
52+
53+
self.xWorldPos, self.zWorldPos = xmlFile:getValue(key .. "#indicatorPosition")
54+
55+
local name = xmlFile:getValue(key.."#name")
56+
if name ~= nil then
57+
name = g_i18n:convertText(name, g_currentMission.loadingMapModName)
58+
end
59+
self.name = name or tostring(self.id)
60+
61+
self.areaInHa = xmlFile:getValue(key.."#areaInHa", 2.5)
62+
63+
self.fixedPrice = xmlFile:getValue(key.."#price")
64+
if self.fixedPrice == nil then
65+
self.priceFactor = xmlFile:getValue(key.."#priceScale", 1)
66+
end
67+
self.price = self.fixedPrice or 1
68+
69+
self:updatePrice()
70+
71+
self.npcIndex = g_npcManager:getRandomIndex()
72+
local npc = g_npcManager:getNPCByName(xmlFile:getValue(key.."#npcName"))
73+
if npc ~= nil then
74+
self.npcIndex = npc.index
75+
end
76+
77+
self.isOwned = false
78+
self.showOnFarmlandsScreen = xmlFile:getValue(key.."#showOnFarmlandsScreen", true)
79+
self.defaultFarmProperty = xmlFile:getValue(key.."#defaultFarmProperty", false)
80+
self.farmId = FarmlandManager.NO_OWNER_FARM_ID
81+
82+
return true
83+
end
84+
85+
86+
---Delete field definition object
87+
function Farmland:delete()
88+
if self.mapHotspot ~= nil then
89+
g_currentMission:removeMapHotspot(self.mapHotspot)
90+
self.mapHotspot:delete()
91+
self.mapHotspot = nil
92+
end
93+
end
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
---Set farmland area indicator world position
110+
-- @param float xWorldPos farmland indicator x world position
111+
-- @param float zWorldPos farmland size in ha
112+
function Farmland:setIndicatorPosition(xWorldPos, zWorldPos)
113+
self.xWorldPos, self.zWorldPos = xWorldPos, zWorldPos
114+
115+
if self.mapHotspot ~= nil then
116+
self.mapHotspot:setWorldPosition(xWorldPos, zWorldPos)
117+
end
118+
end
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
---Set farmland area
146+
-- @param float areaInHa farmland size in ha
147+
function Farmland:setArea(areaInHa)
148+
self.areaInHa = areaInHa
149+
if self.fixedPrice == nil then
150+
self:updatePrice()
151+
end
152+
end

0 commit comments

Comments
 (0)