Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- BaleDestroyerTrigger class |
2 | -- |
3 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
4 | |
5 | BaleDestroyerTrigger = {} |
6 | |
7 | local BaleDestroyerTrigger_mt = Class(BaleDestroyerTrigger); |
8 | |
9 | function BaleDestroyerTrigger:onCreate(id) |
10 | g_currentMission:addNonUpdateable(BaleDestroyerTrigger:new(id)); |
11 | end; |
12 | |
13 | function BaleDestroyerTrigger:new(nodeId) |
14 | local self = {}; |
15 | setmetatable(self, BaleDestroyerTrigger_mt); |
16 | |
17 | self.triggerId = nodeId; |
18 | addTrigger(nodeId, "triggerCallback", self); |
19 | |
20 | return self; |
21 | end; |
22 | |
23 | function BaleDestroyerTrigger:delete() |
24 | removeTrigger(self.triggerId); |
25 | end; |
26 | |
27 | function BaleDestroyerTrigger:triggerCallback(triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId) |
28 | if onEnter then |
29 | -- this happens if a compound child of a deleted compound is entering |
30 | if otherActorId ~= 0 then |
31 | local object = g_currentMission:getNodeObject(otherActorId); |
32 | if object ~= nil then |
33 | if object:isa(Bale) then |
34 | playSample(g_currentMission.cashRegistrySound, 1, 1, 0); |
35 | -- TODO: display a particle effect |
36 | |
37 | if g_currentMission:getIsServer() then |
38 | -- print("Bale stored: ", tostring(otherActorId)); |
39 | local difficultyMultiplier = 2 ^ (3 - g_currentMission.missionStats.difficulty); |
40 | local baseValue = object:getValue(); |
41 | g_currentMission:addSharedMoney(baseValue * difficultyMultiplier, "other"); |
42 | g_currentMission:addMoneyChange(baseValue * difficultyMultiplier, FSBaseMission.MONEY_TYPE_SINGLE, true); |
43 | object:delete(); |
44 | end; |
45 | |
46 | end; |
47 | else |
48 | if g_currentMission.nodeToVehicle[otherActorId] == nil then |
49 | -- there is nothing that could end up here, since physics objects are an object, thus this could only introduce bugs |
50 | -- delete(otherActorId); |
51 | end; |
52 | end; |
53 | end; |
54 | end; |
55 | |
56 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de