Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
FarmlandManager
DescriptionThis class handles all basic functionality for land ownershipParent
AbstractManagerFunctions
- addStateChangeListener
- consoleCommandBuyAllFarmlands
- consoleCommandBuyFarmland
- consoleCommandSellAllFarmlands
- consoleCommandSellFarmland
- consoleCommandShowFarmlands
- convertWorldToLocalPosition
- delete
- farmDestroyed
- getCanAccessLandAtWorldPosition
- getFarmlandAtWorldPosition
- getFarmlandById
- getFarmlandIdAtWorldPosition
- getFarmlandOwner
- getFarmlands
- getIsOwnedByFarmAtWorldPosition
- getIsValidFarmlandId
- getLocalMap
- getOwnedFarmlandIdsByFarmId
- getOwnerIdAtWorldPosition
- getPricePerHa
- initDataStructures
- loadFarmlandData
- loadFromXMLFile
- loadMapData
- new
- removeStateChangeListener
- saveToXMLFile
- setLandOwnership
- unloadMapData
addStateChangeListener
DescriptionAdds a farmland state change listenerDefinition
addStateChangeListener(table listener)Arguments
table | listener | state listener |
438 | function FarmlandManager:addStateChangeListener(listener) |
439 | if listener ~= nil and listener.onFarmlandStateChanged ~= nil then |
440 | self.stateChangeListener[listener] = listener |
441 | end |
442 | end |
consoleCommandBuyAllFarmlands
DescriptionDefinitionconsoleCommandBuyAllFarmlands()Code
475 | function FarmlandManager:consoleCommandBuyAllFarmlands() |
476 | if (g_currentMission:getIsServer() or g_currentMission.isMasterUser) and g_currentMission:getIsClient() then |
477 | local farmId = g_currentMission.player.farmId |
478 | |
479 | for k, _ in pairs(g_farmlandManager:getFarmlands()) do |
480 | g_client:getServerConnection():sendEvent(FarmlandStateEvent.new(k, farmId, 0)) |
481 | end |
482 | return "Bought all farmlands" |
483 | else |
484 | return "Command not allowed" |
485 | end |
486 | end |
consoleCommandBuyFarmland
DescriptionDefinitionconsoleCommandBuyFarmland()Code
455 | function FarmlandManager:consoleCommandBuyFarmland(farmlandId) |
456 | if (g_currentMission:getIsServer() or g_currentMission.isMasterUser) and g_currentMission:getIsClient() then |
457 | farmlandId = tonumber(farmlandId) |
458 | if farmlandId == nil then |
459 | return "Invalid farmland id. Use gsFarmlandBuy <farmlandId>" |
460 | end |
461 | |
462 | local farmId = g_currentMission.player.farmId |
463 | |
464 | -- send buy request |
465 | g_client:getServerConnection():sendEvent(FarmlandStateEvent.new(farmlandId, farmId, 0)) |
466 | |
467 | return "Bought farmland "..farmlandId |
468 | else |
469 | return "Command not allowed" |
470 | end |
471 | end |
consoleCommandSellAllFarmlands
DescriptionDefinitionconsoleCommandSellAllFarmlands()Code
508 | function FarmlandManager:consoleCommandSellAllFarmlands() |
509 | if (g_currentMission:getIsServer() or g_currentMission.isMasterUser) and g_currentMission:getIsClient() then |
510 | for k, _ in pairs(g_farmlandManager:getFarmlands()) do |
511 | g_client:getServerConnection():sendEvent(FarmlandStateEvent.new(k, FarmlandManager.NO_OWNER_FARM_ID, 0)) |
512 | end |
513 | return "Sold all farmlands" |
514 | else |
515 | return "Command not allowed" |
516 | end |
517 | end |
consoleCommandSellFarmland
DescriptionDefinitionconsoleCommandSellFarmland()Code
490 | function FarmlandManager:consoleCommandSellFarmland(farmlandId) |
491 | if (g_currentMission:getIsServer() or g_currentMission.isMasterUser) and g_currentMission:getIsClient() then |
492 | farmlandId = tonumber(farmlandId) |
493 | if farmlandId == nil then |
494 | return "Invalid farmland id. Use gsFarmlandSell <farmlandId>" |
495 | end |
496 | |
497 | -- send sell request |
498 | g_client:getServerConnection():sendEvent(FarmlandStateEvent.new(farmlandId, FarmlandManager.NO_OWNER_FARM_ID, 0)) |
499 | |
500 | return "Sold farmland "..farmlandId |
501 | else |
502 | return "Command not allowed" |
503 | end |
504 | end |
consoleCommandShowFarmlands
DescriptionDefinitionconsoleCommandShowFarmlands()Code
521 | function FarmlandManager:consoleCommandShowFarmlands() |
522 | if not g_currentMission:getHasDrawable(self) then |
523 | g_currentMission:addDrawable(self) |
524 | return "showFarmlands = true\nUse F5 to enter debug mode for enabling overlay" |
525 | else |
526 | g_currentMission:removeDrawable(self) |
527 | return "showFarmlands = false" |
528 | end |
529 | end |
convertWorldToLocalPosition
DescriptionConverts world to local positionDefinition
convertWorldToLocalPosition(float worldPosX, float worldPosZ)Arguments
float | worldPosX | world position x |
float | worldPosZ | world position z |
float | localPosX | local position x |
float | localPosZ | local position z |
419 | function FarmlandManager:convertWorldToLocalPosition(worldPosX, worldPosZ) |
420 | local terrainSize = g_currentMission.terrainSize |
421 | return math.floor(self.localMapWidth * (worldPosX+terrainSize*0.5) / terrainSize), |
422 | math.floor(self.localMapHeight * (worldPosZ+terrainSize*0.5) / terrainSize) |
423 | end |
delete
DescriptionDeletes farm land managerDefinition
delete()Code
255 | function FarmlandManager:delete() |
256 | end |
farmDestroyed
DescriptionDefinitionfarmDestroyed()Code
427 | function FarmlandManager:farmDestroyed(farmId) |
428 | for _, farmland in pairs(self:getFarmlands()) do |
429 | if self:getFarmlandOwner(farmland.id) == farmId then |
430 | self:setLandOwnership(farmland.id, FarmlandManager.NO_OWNER_FARM_ID) |
431 | end |
432 | end |
433 | end |
getCanAccessLandAtWorldPosition
DescriptionChecks if farm can access the given world positionDefinition
getCanAccessLandAtWorldPosition(integer farmId, float worldPosX, float worldPosZ)Arguments
integer | farmId | farm id |
float | worldPosX | world position x |
float | worldPosZ | world position z |
boolean | canAccess | true if farm can access the land |
285 | function FarmlandManager:getCanAccessLandAtWorldPosition(farmId, worldPosX, worldPosZ) |
286 | if farmId == FarmlandManager.NO_OWNER_FARM_ID or farmId == nil then |
287 | return false |
288 | end |
289 | |
290 | local farmlandId = self:getFarmlandIdAtWorldPosition(worldPosX, worldPosZ) |
291 | local ownerFarmId = self.farmlandMapping[farmlandId] |
292 | if ownerFarmId == farmId then |
293 | return true |
294 | end |
295 | |
296 | return g_currentMission.accessHandler:canFarmAccessOtherId(farmId, ownerFarmId) |
297 | end |
getFarmlandAtWorldPosition
DescriptionDefinitiongetFarmlandAtWorldPosition()Code
324 | function FarmlandManager:getFarmlandAtWorldPosition(worldPosX, worldPosZ) |
325 | local farmlandId = self:getFarmlandIdAtWorldPosition(worldPosX, worldPosZ) |
326 | return self.farmlands[farmlandId] |
327 | end |
getFarmlandById
DescriptionGets farmland by idDefinition
getFarmlandById(integer farmlandId)Arguments
integer | farmlandId | farmland id |
table | farmland | farmland object |
382 | function FarmlandManager:getFarmlandById(farmlandId) |
383 | return self.farmlands[farmlandId] |
384 | end |
getFarmlandIdAtWorldPosition
DescriptionGets farmland id at given world positionDefinition
getFarmlandIdAtWorldPosition(float worldPosX, float worldPosZ)Arguments
float | worldPosX | world position x |
float | worldPosZ | world position z |
integer | farmlandId | farmland id. if 0, world position is no valid/buyable farmland |
317 | function FarmlandManager:getFarmlandIdAtWorldPosition(worldPosX, worldPosZ) |
318 | local localPosX, localPosZ = self:convertWorldToLocalPosition(worldPosX, worldPosZ) |
319 | return getBitVectorMapPoint(self.localMap, localPosX, localPosZ, 0, self.numberOfBits) |
320 | end |
getFarmlandOwner
DescriptionGets farmland ownerDefinition
getFarmlandOwner(integer farmlandId)Arguments
integer | farmlandId | farmland id |
integer | farmId | id of farm. Returns 0 if land is not owned by anyone |
303 | function FarmlandManager:getFarmlandOwner(farmlandId) |
304 | --#debug assert(type(farmlandId ~= "table")) -- ensure farmland id and not farmland itself it given |
305 | if farmlandId == nil or self.farmlandMapping[farmlandId] == nil then |
306 | return FarmlandManager.NO_OWNER_FARM_ID |
307 | end |
308 | |
309 | return self.farmlandMapping[farmlandId] |
310 | end |
getFarmlands
DescriptionGets all farmlandsDefinition
getFarmlands()Return Values
table | farmlands | all available farmlands |
389 | function FarmlandManager:getFarmlands() |
390 | return self.farmlands |
391 | end |
getIsOwnedByFarmAtWorldPosition
DescriptionChecks if farm owns given world positionDefinition
getIsOwnedByFarmAtWorldPosition(integer farmId, float worldPosX, float worldPosZ)Arguments
integer | farmId | farm id |
float | worldPosX | world position x |
float | worldPosZ | world position z |
boolean | isOwned | true if farm owns world position point, else false |
271 | function FarmlandManager:getIsOwnedByFarmAtWorldPosition(farmId, worldPosX, worldPosZ) |
272 | if farmId == FarmlandManager.NO_OWNER_FARM_ID or farmId == nil then |
273 | return false |
274 | end |
275 | local farmlandId = self:getFarmlandIdAtWorldPosition(worldPosX, worldPosZ) |
276 | return self.farmlandMapping[farmlandId] == farmId |
277 | end |
getIsValidFarmlandId
DescriptionChecks if given farmland-id is validDefinition
getIsValidFarmlandId(integer farmlandId)Arguments
integer | farmlandId | farmland id |
boolean | isValid | true if id is valid, else false |
340 | function FarmlandManager:getIsValidFarmlandId(farmlandId) |
341 | if farmlandId == nil or farmlandId == 0 or farmlandId < 0 then |
342 | return false |
343 | end |
344 | if self:getFarmlandById(farmlandId) == nil then |
345 | return false |
346 | end |
347 | return true |
348 | end |
getLocalMap
DescriptionGets farmland bit vector handleDefinition
getLocalMap()Return Values
integer | mapHandle | id of bitvector |
261 | function FarmlandManager:getLocalMap() |
262 | return self.localMap |
263 | end |
getOwnedFarmlandIdsByFarmId
DescriptionGets list of owned farmland ids for given farmDefinition
getOwnedFarmlandIdsByFarmId(integer farmId)Arguments
integer | farmId | farm id |
farmlandIds | table | list of farmland ids owned by given farm id |
403 | function FarmlandManager:getOwnedFarmlandIdsByFarmId(id) |
404 | local farmlandIds = {} |
405 | for farmlandId, farmId in pairs(self.farmlandMapping) do |
406 | if farmId == id then |
407 | table.insert(farmlandIds, farmlandId) |
408 | end |
409 | end |
410 | return farmlandIds |
411 | end |
getOwnerIdAtWorldPosition
DescriptionDefinitiongetOwnerIdAtWorldPosition()Code
331 | function FarmlandManager:getOwnerIdAtWorldPosition(worldPosX, worldPosZ) |
332 | local farmlandId = self:getFarmlandIdAtWorldPosition(worldPosX, worldPosZ) |
333 | return self:getFarmlandOwner(farmlandId) |
334 | end |
getPricePerHa
DescriptionDefinitiongetPricePerHa()Code
395 | function FarmlandManager:getPricePerHa() |
396 | return self.pricePerHa |
397 | end |
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
27 | function FarmlandManager:initDataStructures() |
28 | self.farmlands = {} |
29 | self.sortedFarmlandIds = {} |
30 | -- mapping table farmland id to farm id |
31 | self.farmlandMapping = {} |
32 | self.localMap = nil |
33 | self.localMapWidth = 0 |
34 | self.localMapHeight = 0 |
35 | self.numberOfBits = 8 |
36 | self.stateChangeListener = {} |
37 | end |
loadFarmlandData
DescriptionLoad data on map loadDefinition
loadFarmlandData()Return Values
boolean | true | if loading was successful else false |
51 | function FarmlandManager:loadFarmlandData(xmlFile) |
52 | local filename = Utils.getFilename(getXMLString(xmlFile, "map.farmlands#densityMapFilename"), g_currentMission.baseDirectory) |
53 | |
54 | -- number of channels for farmland bit vector |
55 | self.numberOfBits = Utils.getNoNil(getXMLInt(xmlFile, "map.farmlands#numChannels"), 8) |
56 | self.pricePerHa = Utils.getNoNil(getXMLFloat(xmlFile, "map.farmlands#pricePerHa"), 60000) |
57 | |
58 | FarmlandManager.NOT_BUYABLE_FARM_ID = 2^self.numberOfBits-1 |
59 | |
60 | -- load a bitvector |
61 | self.localMap = createBitVectorMap("FarmlandMap") |
62 | local success = loadBitVectorMapFromFile(self.localMap, filename, self.numberOfBits) |
63 | if not success then |
64 | Logging.xmlWarning(xmlFile, "Loading farmland file '%s' failed!", filename) |
65 | return false |
66 | end |
67 | |
68 | self.localMapWidth, self.localMapHeight = getBitVectorMapSize(self.localMap) |
69 | |
70 | local farmlandSizeMapping = {} |
71 | local farmlandCenterData = {} |
72 | local numOfFarmlands = 0 |
73 | local maxFarmlandId = 0 |
74 | local missingFarmlandDefinitions = false |
75 | |
76 | for x = 0, self.localMapWidth - 1 do |
77 | for y = 0, self.localMapHeight - 1 do |
78 | local value = getBitVectorMapPoint(self.localMap, x, y, 0, self.numberOfBits) |
79 | |
80 | if value > 0 then |
81 | if self.farmlandMapping[value] == nil then |
82 | farmlandSizeMapping[value] = 0 |
83 | farmlandCenterData[value] = {sumPosX=0, sumPosZ=0} |
84 | self.farmlandMapping[value] = FarmlandManager.NO_OWNER_FARM_ID |
85 | numOfFarmlands = numOfFarmlands + 1 |
86 | maxFarmlandId = math.max(value, maxFarmlandId) |
87 | end |
88 | |
89 | farmlandSizeMapping[value] = farmlandSizeMapping[value] + 1 |
90 | farmlandCenterData[value].sumPosX = farmlandCenterData[value].sumPosX + (x-0.5) |
91 | farmlandCenterData[value].sumPosZ = farmlandCenterData[value].sumPosZ + (y-0.5) |
92 | else |
93 | missingFarmlandDefinitions = true |
94 | end |
95 | end |
96 | end |
97 | |
98 | if missingFarmlandDefinitions then |
99 | Logging.xmlWarning(xmlFile, "Farmland-Id was not set for all pixels in farmland-infoLayer!") |
100 | end |
101 | |
102 | local isNewSavegame = not g_currentMission.missionInfo.isValid |
103 | |
104 | local i = 0 |
105 | while true do |
106 | local key = string.format("map.farmlands.farmland(%d)", i) |
107 | if not hasXMLProperty(xmlFile, key) then |
108 | break |
109 | end |
110 | |
111 | local farmland = Farmland.new() |
112 | if farmland:load(xmlFile, key) and self.farmlands[farmland.id] == nil and self.farmlandMapping[farmland.id] ~= nil then |
113 | self.farmlands[farmland.id] = farmland |
114 | table.insert(self.sortedFarmlandIds, farmland.id) |
115 | |
116 | -- If default should be owned... |
117 | local shouldAddDefaults = isNewSavegame and g_currentMission.missionInfo.hasInitiallyOwnedFarmlands and not g_currentMission.missionDynamicInfo.isMultiplayer |
118 | -- ... then set only default farmlands to owned |
119 | if shouldAddDefaults and g_currentMission:getIsServer() and farmland.defaultFarmProperty then |
120 | self:setLandOwnership(farmland.id, FarmManager.SINGLEPLAYER_FARM_ID) |
121 | end |
122 | else |
123 | if self.farmlandMapping[farmland.id] == nil then |
124 | Logging.xmlError(xmlFile, "Farmland-Id " .. tostring(farmland.id) .. " not defined in farmland ownage file '"..filename.."'. Skipping farmland definition!") |
125 | end |
126 | if self.farmlands[farmland.id] ~= nil then |
127 | Logging.xmlError(xmlFile, "Farmland-id '"..tostring(farmland.id).."' already exists! Ignore it!") |
128 | end |
129 | farmland:delete() |
130 | end |
131 | |
132 | i = i + 1 |
133 | end |
134 | |
135 | for index, _ in pairs(self.farmlandMapping) do |
136 | if index ~= FarmlandManager.NOT_BUYABLE_FARM_ID and self.farmlands[index] == nil then |
137 | Logging.xmlError(xmlFile, "Farmland-Id " .. tostring(index) .. " not defined in farmland xml file!") |
138 | end |
139 | end |
140 | |
141 | local transformFactor = g_currentMission.terrainSize / self.localMapWidth |
142 | local pixelToSqm = transformFactor*transformFactor |
143 | |
144 | for id, farmland in pairs(self.farmlands) do |
145 | local ha = MathUtil.areaToHa(farmlandSizeMapping[id], pixelToSqm) |
146 | farmland:setArea(ha) |
147 | |
148 | local posX = ((farmlandCenterData[id].sumPosX / farmlandSizeMapping[id]) - self.localMapWidth*0.5) * transformFactor |
149 | local posZ = ((farmlandCenterData[id].sumPosZ / farmlandSizeMapping[id]) - self.localMapHeight*0.5) * transformFactor |
150 | self.farmlands[id]:setFarmlandIndicatorPosition(posX, posZ) |
151 | end |
152 | |
153 | g_messageCenter:subscribe(MessageType.FARM_DELETED, self.farmDestroyed, self) |
154 | |
155 | if g_currentMission:getIsServer() then |
156 | if g_addCheatCommands then |
157 | -- master user only cheats (will be added in setMasterUserLocal too) |
158 | addConsoleCommand("gsFarmlandBuy", "Buys farmland with given id", "consoleCommandBuyFarmland", self) |
159 | addConsoleCommand("gsFarmlandBuyAll", "Buys all farmlands", "consoleCommandBuyAllFarmlands", self) |
160 | addConsoleCommand("gsFarmlandSell", "Sells farmland with given id", "consoleCommandSellFarmland", self) |
161 | addConsoleCommand("gsFarmlandSellAll", "Sells all farmlands", "consoleCommandSellAllFarmlands", self) |
162 | addConsoleCommand("gsFarmlandShow", "Show farmlands", "consoleCommandShowFarmlands", self) |
163 | end |
164 | end |
165 | |
166 | return true |
167 | end |
loadFromXMLFile
DescriptionLoad farmland ownage data from xml savegame fileDefinition
loadFromXMLFile(string filename)Arguments
string | filename | xml filename |
221 | function FarmlandManager:loadFromXMLFile(xmlFilename) |
222 | if xmlFilename == nil then |
223 | return false |
224 | end |
225 | |
226 | local xmlFile = loadXMLFile("farmlandXML", xmlFilename) |
227 | if xmlFile == 0 then |
228 | return false |
229 | end |
230 | |
231 | local farmlandCounter = 0 |
232 | while true do |
233 | local key = string.format("farmlands.farmland(%d)", farmlandCounter) |
234 | local farmlandId = getXMLInt(xmlFile, key .. "#id") |
235 | if farmlandId == nil then |
236 | break |
237 | end |
238 | local farmId = getXMLInt(xmlFile, key .. "#farmId") |
239 | if farmId > FarmlandManager.NO_OWNER_FARM_ID then |
240 | self:setLandOwnership(farmlandId, farmId) |
241 | end |
242 | |
243 | farmlandCounter = farmlandCounter + 1 |
244 | end |
245 | |
246 | delete(xmlFile) |
247 | |
248 | g_farmManager:mergeFarmlandsForSingleplayer() |
249 | |
250 | return true |
251 | end |
loadMapData
DescriptionLoad data on map loadDefinition
loadMapData()Return Values
boolean | true | if loading was successful else false |
43 | function FarmlandManager:loadMapData(xmlFile) |
44 | FarmlandManager:superClass().loadMapData(self) |
45 | return XMLUtil.loadDataFromMapXML(xmlFile, "farmlands", g_currentMission.baseDirectory, self, self.loadFarmlandData) |
46 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
20 | function FarmlandManager.new(customMt) |
21 | local self = AbstractManager.new(customMt or FarmlandManager_mt) |
22 | return self |
23 | end |
removeStateChangeListener
DescriptionRemoves a farmland state change listenerDefinition
removeStateChangeListener(table listener)Arguments
table | listener | state listener |
447 | function FarmlandManager:removeStateChangeListener(listener) |
448 | if listener ~= nil then |
449 | self.stateChangeListener[listener] = nil |
450 | end |
451 | end |
saveToXMLFile
DescriptionWrite farmland ownage data to savegame fileDefinition
saveToXMLFile(string xmlFilename)Arguments
string | xmlFilename | file path |
boolean | true | if loading was successful else false |
197 | function FarmlandManager:saveToXMLFile(xmlFilename) |
198 | -- save farmland to xml |
199 | local xmlFile = createXMLFile("farmlandsXML", xmlFilename, "farmlands") |
200 | if xmlFile ~= nil then |
201 | local index = 0 |
202 | for farmlandId, farmId in pairs(self.farmlandMapping) do |
203 | local farmlandKey = string.format("farmlands.farmland(%d)", index) |
204 | setXMLInt(xmlFile, farmlandKey.."#id", farmlandId) |
205 | setXMLInt(xmlFile, farmlandKey.."#farmId", Utils.getNoNil(farmId, FarmlandManager.NO_OWNER_FARM_ID)) |
206 | index = index + 1 |
207 | end |
208 | |
209 | saveXMLFile(xmlFile) |
210 | delete(xmlFile) |
211 | |
212 | return true |
213 | end |
214 | |
215 | return false |
216 | end |
setLandOwnership
DescriptionSets farm land ownershipDefinition
setLandOwnership(integer farmlandId, integer farmId)Arguments
integer | farmlandId | farm land id |
integer | farmId | farm id. set farmid to 0 to sell farm land |
354 | function FarmlandManager:setLandOwnership(farmlandId, farmId) |
355 | if not self:getIsValidFarmlandId(farmlandId) then |
356 | return false |
357 | end |
358 | if farmId == nil or farmId < FarmlandManager.NO_OWNER_FARM_ID or farmId == FarmlandManager.NOT_BUYABLE_FARM_ID then |
359 | return false |
360 | end |
361 | |
362 | local farmland = self:getFarmlandById(farmlandId) |
363 | if farmland == nil then |
364 | Logging.warning("Farmland id %d not defined in map!", farmlandId) |
365 | return false |
366 | end |
367 | |
368 | self.farmlandMapping[farmlandId] = farmId |
369 | farmland.isOwned = farmId ~= FarmlandManager.NO_OWNER_FARM_ID |
370 | |
371 | for _, listener in pairs(self.stateChangeListener) do |
372 | listener:onFarmlandStateChanged(farmlandId, farmId) |
373 | end |
374 | |
375 | return true |
376 | end |
unloadMapData
DescriptionUnload data on mission deleteDefinition
unloadMapData()Code
171 | function FarmlandManager:unloadMapData() |
172 | removeConsoleCommand("gsFarmlandBuy") |
173 | removeConsoleCommand("gsFarmlandBuyAll") |
174 | removeConsoleCommand("gsFarmlandSell") |
175 | removeConsoleCommand("gsFarmlandSellAll") |
176 | removeConsoleCommand("gsFarmlandShow") |
177 | |
178 | g_messageCenter:unsubscribeAll(self) |
179 | |
180 | if self.localMap ~= nil then |
181 | delete(self.localMap) |
182 | self.localMap = nil |
183 | end |
184 | if (self.farmlands ~= nil) then |
185 | for _, farmland in pairs(self.farmlands) do |
186 | farmland:delete() |
187 | end |
188 | end |
189 | |
190 | FarmlandManager:superClass().unloadMapData(self) |
191 | end |