Sprache Deutsch Language English

Script Dokumentation LS 2015 - BeehivePlaceable (Patch 1.3)

Script Dokumentation Übersicht

scripts/placeables/BeehivePlaceable.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
2
3BeehivePlaceable = {};
4BeehivePlaceable_mt = Class(BeehivePlaceable, Placeable);
5
6InitStaticObjectClass(BeehivePlaceable, "BeehivePlaceable", ObjectIds.OBJECT_BEEHIVE_PLACEABLE);
7
8function BeehivePlaceable:new(isServer, isClient, customMt)
9 local mt = customMt;
10 if mt == nil then
11 mt = BeehivePlaceable_mt;
12 end;
13
14 local self = Placeable:new(isServer, isClient, mt);
15
16 registerObjectClassName(self, "BeehivePlaceable");
17
18 self.incomePerHour = 0;
19
20 return self;
21end;
22
23function BeehivePlaceable:delete()
24 unregisterObjectClassName(self);
25 g_currentMission.environment:removeHourChangeListener(self);
26 if self.particleSystems ~= nil then
27 Utils.deleteParticleSystem(self.particleSystems);
28 end;
29 BeehivePlaceable:superClass().delete(self);
30end;
31
32function BeehivePlaceable:deleteFinal()
33 BeehivePlaceable:superClass().deleteFinal(self);
34end;
35
36function BeehivePlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom)
37 if not BeehivePlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then
38 return false;
39 end;
40
41 local xmlFile = loadXMLFile("TempXML", xmlFilename);
42
43 local difficultyMultiplier = 2 ^ (3 - g_currentMission.missionStats.difficulty); --4 2 1
44 self.incomePerHour = difficultyMultiplier * Utils.getNoNil(getXMLFloat(xmlFile, "placeable.incomePerHour"), 100);
45
46 self.particleSystems = {};
47 Utils.loadParticleSystem(xmlFile, self.particleSystems, "placeable.particleSystem", self.nodeId, true, nil, self.baseDirectory);
48
49 delete(xmlFile);
50
51 return true;
52end;
53
54function BeehivePlaceable:finalizePlacement()
55 BeehivePlaceable:superClass().finalizePlacement(self);
56 g_currentMission.environment:addHourChangeListener(self);
57end
58
59function BeehivePlaceable:hourChanged()
60 if self.isServer then
61 g_currentMission:addSharedMoney(self.incomePerHour, "other");
62 g_currentMission:addMoneyChange(self.incomePerHour, FSBaseMission.MONEY_TYPE_HOUR_CHANGED);
63 end;
64end;
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht