1 /**
2 Ladder Segment
3 */
4
5 #include Library_Ladder
6
7 local index;
8
9 // Called from the ladder object to set a master and the segment index.
SetMaster(object new_master,int new_index,...)10 public func SetMaster(object new_master, int new_index, ...)
11 {
12 // First perform setting the master in the library function.
13 _inherited(new_master, new_index, ...);
14 // Then set index and attach to master object.
15 index = new_index;
16 AddVertex(0, new_master->GetY() - GetY());
17 SetAction("Attach", master);
18 return;
19 }
20
21 // Returns whether the ladder can be climbed.
CanNotBeClimbed(bool is_climbing)22 public func CanNotBeClimbed(bool is_climbing)
23 {
24 var test_height = 10;
25 if (is_climbing)
26 test_height = 8;
27 if (GBackSolid(1, test_height) && GBackSolid(-1, test_height))
28 return true;
29 return false;
30 }
31
32 // Returns the segment (start x, start y, end x, end y, angle) on which the clonk can climb.
33 // The coordinate value must be specified with a precision of a 1000.
GetLadderData()34 public func GetLadderData()
35 {
36 return [
37 GetX(1000),
38 GetY(1000) + 4000,
39 GetX(1000),
40 GetY(1000) - 4000,
41 0
42 ];
43 }
44
OnLadderGrab(object clonk)45 public func OnLadderGrab(object clonk)
46 {
47 if (master)
48 master->OnLadderGrab(clonk, this, index);
49 return;
50 }
51
OnLadderClimb(object clonk)52 public func OnLadderClimb(object clonk)
53 {
54 if (master)
55 master->OnLadderClimb(clonk, this, index);
56 return;
57 }
58
OnLadderReleased(object clonk)59 public func OnLadderReleased(object clonk)
60 {
61 if (master)
62 master->OnLadderReleased(clonk, this, index);
63 return;
64 }
65
66 // Main ladder object is saved.
SaveScenarioObject()67 public func SaveScenarioObject() { return false; }
68
69 /*-- Graphics --*/
70
SetPreviousLadder(object ladder)71 public func SetPreviousLadder(object ladder)
72 {
73 _inherited(ladder);
74
75 if (!this->GetNextLadder())
76 SetGraphics("Top");
77 else
78 SetGraphics(nil);
79 }
80
SetNextLadder(object ladder)81 public func SetNextLadder(object ladder)
82 {
83 _inherited(ladder);
84
85 if (!this->GetPreviousLadder())
86 SetGraphics("Bottom");
87 else
88 SetGraphics(nil);
89 }
90
91 /*-- Properties --*/
92
93 local ActMap = {
94 Attach = {
95 Prototype = Action,
96 Name = "Attach",
97 FacetBase = 1,
98 Procedure = DFA_ATTACH,
99 },
100 };
101
102 local Plane = 220;