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 | |
3 | BeehivePlaceable = {}; |
4 | BeehivePlaceable_mt = Class(BeehivePlaceable, Placeable); |
5 | |
6 | InitStaticObjectClass(BeehivePlaceable, "BeehivePlaceable", ObjectIds.OBJECT_BEEHIVE_PLACEABLE); |
7 | |
8 | function 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; |
21 | end; |
22 | |
23 | function 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); |
30 | end; |
31 | |
32 | function BeehivePlaceable:deleteFinal() |
33 | BeehivePlaceable:superClass().deleteFinal(self); |
34 | end; |
35 | |
36 | function 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; |
52 | end; |
53 | |
54 | function BeehivePlaceable:finalizePlacement() |
55 | BeehivePlaceable:superClass().finalizePlacement(self); |
56 | g_currentMission.environment:addHourChangeListener(self); |
57 | end |
58 | |
59 | function 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; |
64 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de