summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/BuildStairs.java
blob: 0b3d086e9d0d67fb8935fac04bf254b3ecc85d41 (plain) (blame)
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
package NET.worlds.scape;

import java.awt.Color;
import java.io.IOException;

public class BuildStairs extends SwitchableBehavior implements FrameHandler, Persister {
   protected boolean doBuild = false;
   protected boolean built = false;
   protected WrStaircase stairs = null;
   protected String stairName = "staircase";
   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 int numsteps = 10;
   protected Material riser = new Material(Color.gray);
   protected Material tread = 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.stairs = new WrStaircase(
         world,
         this.stairName,
         this.length,
         this.width,
         this.pWidth,
         this.pHeight,
         this.dz,
         this.lintelZ,
         this.numsteps,
         this.riser,
         this.tread,
         this.left,
         this.right,
         this.doorpost,
         this.lintel,
         this.ceiling
      );
      end1.biconnect(this.stairs.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, "BuildStairs");
            }
            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 = IntegerPropertyEditor.make(new Property(this, index, "Number of Steps"));
            } else if (mode == 1) {
               ret = new Integer(this.numsteps);
            } else if (mode == 2) {
               this.numsteps = (Integer)value;
            }
            break;
         case 4:
            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 5:
            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 6:
            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 7:
            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 8:
            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 9:
            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 10:
            if (mode == 0) {
               ret = new Property(this, index, "Riser Material");
            } else if (mode == 1) {
               ret = this.riser;
            }
            break;
         case 11:
            if (mode == 0) {
               ret = new Property(this, index, "Tread Material");
            } else if (mode == 1) {
               ret = this.tread;
            }
            break;
         case 12:
            if (mode == 0) {
               ret = new Property(this, index, "Left Wall Material");
            } else if (mode == 1) {
               ret = this.left;
            }
            break;
         case 13:
            if (mode == 0) {
               ret = new Property(this, index, "Right Wall Material");
            } else if (mode == 1) {
               ret = this.right;
            }
            break;
         case 14:
            if (mode == 0) {
               ret = new Property(this, index, "Doorpost Material");
            } else if (mode == 1) {
               ret = this.doorpost;
            }
            break;
         case 15:
            if (mode == 0) {
               ret = new Property(this, index, "Lintel Material");
            } else if (mode == 1) {
               ret = this.lintel;
            }
            break;
         case 16:
            if (mode == 0) {
               ret = new Property(this, index, "Ceiling Material");
            } else if (mode == 1) {
               ret = this.ceiling;
            }
            break;
         default:
            ret = super.properties(index, offset + 17, mode, value);
      }

      return ret;
   }

   @Override
   public String toString() {
      return "Stairs: 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.saveInt(this.numsteps);
   }

   @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.numsteps = r.restoreInt();
   }

   @Override
   public void postRestore(int version) {
   }
}