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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
package NET.worlds.scape;
import java.awt.Color;
import java.io.IOException;
public class BuildRamp extends SwitchableBehavior implements FrameHandler, Persister {
protected boolean doBuild = false;
protected boolean built = false;
protected WrRamp ramp = null;
protected String stairName = "ramp";
protected float length = 1000.0F;
protected float width = 300.0F;
protected float pWidth = 250.0F;
protected float pHeight = 240.0F;
protected float dz = 300.0F;
protected float lintelZ = 50.0F;
protected float floorTileX = 300.0F;
protected float floorTileY = 200.0F;
protected float ceilTileX = 300.0F;
protected float ceilTileY = 200.0F;
protected float leftTileX = 100.0F;
protected float leftTileY = 100.0F;
protected float rightTileX = 100.0F;
protected float rightTileY = 100.0F;
protected Material floor = new Material(Color.green);
protected Material left = new Material(Color.cyan);
protected Material right = new Material(Color.red);
protected Material doorpost = new Material(Color.yellow);
protected Material lintel = new Material(Color.magenta);
protected Material ceiling = new Material(Color.blue);
protected String worldURL = null;
protected void build(Portal end1) {
Room room = end1.getRoom();
World world = room.getWorld();
this.ramp = new WrRamp(
world,
this.stairName,
this.length,
this.width,
this.pWidth,
this.pHeight,
this.dz,
this.lintelZ,
this.floorTileX,
this.floorTileY,
this.ceilTileX,
this.ceilTileY,
this.leftTileX,
this.leftTileY,
this.rightTileX,
this.rightTileY,
this.floor,
this.left,
this.right,
this.doorpost,
this.lintel,
this.ceiling
);
end1.biconnect(this.ramp.portal1);
this.built = true;
end1.removeHandler(this);
}
protected void unbuild(Portal end1) {
this.built = false;
}
@Override
public boolean handle(FrameEvent e) {
if (!this.built && this.doBuild && e.target instanceof Portal) {
this.build((Portal)e.target);
} else if (this.built && !this.doBuild && e.target instanceof Portal) {
this.unbuild((Portal)e.target);
}
return true;
}
@Override
public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
Object ret = null;
switch (index - offset) {
case 0:
if (mode == 0) {
ret = new ClassProperty(this, index, "BuildRamp");
}
break;
case 1:
if (mode == 0) {
ret = BooleanPropertyEditor.make(new Property(this, index, "Build now?"), "Later", "Now");
} else if (mode == 1) {
ret = new Boolean(this.doBuild);
} else if (mode == 2) {
this.doBuild = (Boolean)value;
}
break;
case 2:
if (mode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "Staircase Name"));
} else if (mode == 1) {
ret = this.stairName;
} else if (mode == 2) {
this.stairName = (String)value;
}
break;
case 3:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Portal-to-portal Distance"));
} else if (mode == 1) {
ret = new Float(this.length);
} else if (mode == 2) {
this.length = (Float)value;
}
break;
case 4:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Stairwell Width"));
} else if (mode == 1) {
ret = new Float(this.width);
} else if (mode == 2) {
this.width = (Float)value;
}
break;
case 5:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Portal Width"));
} else if (mode == 1) {
ret = new Float(this.pWidth);
} else if (mode == 2) {
this.pWidth = (Float)value;
}
break;
case 6:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Portal Height"));
} else if (mode == 1) {
ret = new Float(this.pHeight);
} else if (mode == 2) {
this.pHeight = (Float)value;
}
break;
case 7:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Total Rise"));
} else if (mode == 1) {
ret = new Float(this.dz);
} else if (mode == 2) {
this.dz = (Float)value;
}
break;
case 8:
if (mode == 0) {
ret = FloatPropertyEditor.make(new Property(this, index, "Lintel Height"));
} else if (mode == 1) {
ret = new Float(this.lintelZ);
} else if (mode == 2) {
this.lintelZ = (Float)value;
}
break;
case 9:
if (mode == 0) {
ret = Point2PropertyEditor.make(new Property(this, index, "Floor Tile Size"));
} else if (mode == 1) {
Point2 coords = new Point2();
coords.x = this.floorTileX;
coords.y = this.floorTileY;
ret = coords;
} else if (mode == 2) {
this.floorTileX = ((Point2)value).x;
this.floorTileY = ((Point2)value).y;
}
break;
case 10:
if (mode == 0) {
ret = Point2PropertyEditor.make(new Property(this, index, "Ceiling Tile Size"));
} else if (mode == 1) {
Point2 coords = new Point2();
coords.x = this.ceilTileX;
coords.y = this.ceilTileY;
ret = coords;
} else if (mode == 2) {
this.ceilTileX = ((Point2)value).x;
this.ceilTileY = ((Point2)value).y;
}
break;
case 11:
if (mode == 0) {
ret = Point2PropertyEditor.make(new Property(this, index, "Left Wall Tile Size"));
} else if (mode == 1) {
Point2 coords = new Point2();
coords.x = this.leftTileX;
coords.y = this.leftTileY;
ret = coords;
} else if (mode == 2) {
this.leftTileX = ((Point2)value).x;
this.leftTileY = ((Point2)value).y;
}
break;
case 12:
if (mode == 0) {
ret = Point2PropertyEditor.make(new Property(this, index, "Right Wall Tile Size"));
} else if (mode == 1) {
Point2 coords = new Point2();
coords.x = this.rightTileX;
coords.y = this.rightTileY;
ret = coords;
} else if (mode == 2) {
this.rightTileX = ((Point2)value).x;
this.rightTileY = ((Point2)value).y;
}
break;
case 13:
if (mode == 0) {
ret = new Property(this, index, "Floor Material");
} else if (mode == 1) {
ret = this.floor;
}
break;
case 14:
if (mode == 0) {
ret = new Property(this, index, "Left Wall Material");
} else if (mode == 1) {
ret = this.left;
}
break;
case 15:
if (mode == 0) {
ret = new Property(this, index, "Right Wall Material");
} else if (mode == 1) {
ret = this.right;
}
break;
case 16:
if (mode == 0) {
ret = new Property(this, index, "Doorpost Material");
} else if (mode == 1) {
ret = this.doorpost;
}
break;
case 17:
if (mode == 0) {
ret = new Property(this, index, "Lintel Material");
} else if (mode == 1) {
ret = this.lintel;
}
break;
case 18:
if (mode == 0) {
ret = new Property(this, index, "Ceiling Material");
} else if (mode == 1) {
ret = this.ceiling;
}
break;
default:
ret = super.properties(index, offset + 19, mode, value);
}
return ret;
}
@Override
public String toString() {
return "Ramp: built=" + this.built;
}
@Override
public void saveState(Saver s) throws IOException {
s.saveBoolean(this.built);
s.saveString(this.stairName);
s.saveFloat(this.length);
s.saveFloat(this.width);
s.saveFloat(this.pWidth);
s.saveFloat(this.pHeight);
s.saveFloat(this.dz);
s.saveFloat(this.lintelZ);
s.saveFloat(this.floorTileX);
s.saveFloat(this.floorTileY);
s.saveFloat(this.ceilTileX);
s.saveFloat(this.ceilTileY);
s.saveFloat(this.leftTileX);
s.saveFloat(this.leftTileY);
s.saveFloat(this.rightTileX);
s.saveFloat(this.rightTileY);
}
@Override
public void restoreState(Restorer r) throws IOException {
this.built = r.restoreBoolean();
this.stairName = r.restoreString();
this.length = r.restoreFloat();
this.width = r.restoreFloat();
this.pWidth = r.restoreFloat();
this.pHeight = r.restoreFloat();
this.dz = r.restoreFloat();
this.lintelZ = r.restoreFloat();
this.floorTileX = r.restoreFloat();
this.floorTileY = r.restoreFloat();
this.ceilTileX = r.restoreFloat();
this.ceilTileY = r.restoreFloat();
this.leftTileX = r.restoreFloat();
this.leftTileY = r.restoreFloat();
this.rightTileX = r.restoreFloat();
this.rightTileY = r.restoreFloat();
}
@Override
public void postRestore(int version) {
}
}
|