-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.cs
194 lines (167 loc) · 4.19 KB
/
sketch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
datablock fxDTSBrickData(BrickStraightSketchData) {
brickFile = "./bricks/straight_sketch.blb";
category = "Special";
subCategory = "DUNGEONS!!!!!!!!";
uiName = "Straight Sketch ";
iconName = "";
isSketchBrick = true;
};
datablock fxDTSBrickData(BrickCeilingSketchData) {
brickFile = "./bricks/ceiling_sketch.blb";
category = "Special";
subCategory = "DUNGEONS!!!!!!!!";
uiName = "Ceiling Sketch ";
iconName = "";
isSketchBrick = false;
};
datablock fxDTSBrickData(BrickFloorSketchData) {
brickFile = "./bricks/floor_sketch.blb";
category = "Special";
subCategory = "DUNGEONS!!!!!!!!";
uiName = "Floor Sketch ";
iconName = "";
isSketchBrick = false;
};
datablock fxDTSBrickData(BrickCornerSketchData) {
brickFile = "./bricks/corner_sketch.blb";
category = "Special";
subCategory = "DUNGEONS!!!!!!!!";
uiName = "Corner Sketch ";
iconName = "";
isSketchBrick = true;
};
// used to differentiate between one kind of corner and another
datablock fxDTSBrickData(BrickCorner1SketchData) {
brickFile = "./bricks/corner_sketch.blb";
uiName = "Corner Sketch 1 ";
isSketchBrick = true;
isInteractable = true;
};
function BrickCorner1SketchData::onLook(%this, %brick, %player) {
%player.client.centerPrint("|---", 0.3);
}
datablock fxDTSBrickData(BrickCorner2SketchData) {
brickFile = "./bricks/corner_sketch.blb";
uiName = "Corner Sketch 2 ";
isSketchBrick = true;
isInteractable = true;
};
function BrickCorner2SketchData::onLook(%this, %brick, %player) {
%player.client.centerPrint("---|", 0.3);
}
// returns a vector to test along for corner 1. reverse the vector to test for corner 2
function cornerVectorHelper(%orientation) {
if(%orientation == 0) {
return "0 -1 0";
}
else if(%orientation == 1) {
return "-1 0 0";
}
else if(%orientation == 2) {
return "0 1 0";
}
else if(%orientation == 3) {
return "1 0 0";
}
}
function BrickCornerSketchData::onPlant(%this, %obj) {
Parent::onPlant(%this, %obj);
%this.determineCornerType(%obj);
}
function BrickCornerSketchData::determineCornerType(%this, %obj) {
%start = %obj.getPosition();
// test for corner 1
%raycast = containerRaycast(
%start,
vectorAdd(
%start,
vectorScale(cornerVectorHelper(%obj.angleId), 8)
),
$TypeMasks::fxBrickObjectType,
%obj
);
if(isObject(%raycast)) {
%obj.setDatablock(BrickCorner1SketchData);
}
// test for corner 2
%raycast = containerRaycast(
%start,
vectorAdd(
%start,
vectorScale(cornerVectorHelper(%obj.angleId), -8)
),
$TypeMasks::fxBrickObjectType,
%obj
);
if(isObject(%raycast)) {
%obj.setDatablock(BrickCorner2SketchData);
}
}
// %direction & 1 means refresh down
// %direction & 2 means refresh up
function fxDTSBrickData::determineType(%this, %obj, %direction) {
%upBrick = %obj.getUpBrick(0);
%bottomBrick = %obj.getDownBrick(0);
%hasBottomBrick = false;
if(
isObject(%bottomBrick)
&& %bottomBrick.getDatablock().isSketchBrick
) {
%hasBottomBrick = true;
// refresh bottom brick's type
if(%direction & 1) {
%this.determineType(%bottomBrick, 1);
}
}
%hasUpBrick = false;
if(
isObject(%upBrick)
&& %upBrick.getDatablock().isSketchBrick
) {
%hasUpBrick = true;
// refresh bottom brick's type
if(%direction & 2) {
%this.determineType(%upBrick, 2);
}
}
if(%hasBottomBrick && %hasUpBrick) {
%obj.setColor(1);
}
else if(%hasBottomBrick) {
%obj.setColor(2);
}
else {
%obj.setColor(0);
}
}
deActivatePackage(MiniDungeonsSketch);
package MiniDungeonsSketch {
function fxDTSBrickData::onPlant(%this, %obj) {
Parent::onPlant(%this, %obj);
// determine if we're a bottom, middle, or top brick
if(%this.isSketchBrick) {
%this.determineType(%obj, 3);
}
}
function fxDTSBrickData::onLoadPlant(%this, %obj) {
Parent::onPlant(%this, %obj);
// determine if we're a bottom, middle, or top brick
if(%this.isSketchBrick) {
%this.determineType(%obj, 3);
}
}
function fxDTSBrickData::onDeath(%this, %obj) {
if(%obj.isPlanted && %this.isSketchBrick) {
%upBrick = %obj.getUpBrick(0);
%bottomBrick = %obj.getDownBrick(0);
}
Parent::onDeath(%this, %obj);
if(%upBrick) {
%this.determineType(%upBrick, 2);
}
if(%bottomBrick) {
%this.determineType(%bottomBrick, 1);
}
}
};
activatePackage(MiniDungeonsSketch);