Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | --[[ OilPump class |
2 | OilPumps pump oil! |
3 | Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
4 | --]] |
5 | |
6 | OilPump = {} |
7 | |
8 | local OilPump_mt = Class(OilPump); |
9 | |
10 | function OilPump:onCreate(id) |
11 | g_currentMission:addUpdateable(OilPump:new(id)); |
12 | --print("created OilPump, id: ", id); |
13 | end; |
14 | |
15 | function OilPump:new(name) |
16 | local self = {}; |
17 | setmetatable(self, OilPump_mt); |
18 | |
19 | self.axisTable = {0, 0, 0}; |
20 | self.me = name; |
21 | |
22 | self.head = getChildAt(self.me, 1); |
23 | self.cylinders = getChildAt(self.me, 2); |
24 | self.innerCylinders = getChildAt(self.cylinders, 0); |
25 | |
26 | self.speed = 0.0012; |
27 | self.zRotationMin = 0; |
28 | self.zRotationMax = Utils.degToRad(40); |
29 | self.timer = math.random() * 2 * math.pi; |
30 | |
31 | return self; |
32 | end; |
33 | |
34 | function OilPump:delete() |
35 | |
36 | end; |
37 | |
38 | function OilPump:update(dt) |
39 | self.timer = self.timer + dt * 0.001; |
40 | if self.timer >= 2 * math.pi then self.timer = 0; end; |
41 | local sinValue = (math.sin(self.timer) + 1) / 2; -- renders a number that goes from 0 to 1 and back |
42 | local zRotation = self.zRotationMax * sinValue; |
43 | local fakeValue = 2.105 - 1.977 / math.cos(zRotation - self.zRotationMax / 2); |
44 | local xRotation = Utils.degToRad(-fakeValue * 15); |
45 | local yScale = 1 + 0.5 * sinValue; |
46 | setRotation(self.head, 0, 0, zRotation); |
47 | setRotation(self.cylinders, 0, 0, xRotation); |
48 | setScale(self.innerCylinders, 1, yScale, 1); |
49 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de