summaryrefslogtreecommitdiff
path: root/NET/worlds/console/Stair.java
blob: f36a5f6ef8783108165ca7747bac79576e08f62c (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
249
250
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.scape.Material;
/*     */ import NET.worlds.scape.NoSuchPropertyException;
/*     */ import NET.worlds.scape.Point3;
/*     */ import NET.worlds.scape.Point3Temp;
/*     */ import NET.worlds.scape.Portal;
/*     */ import NET.worlds.scape.Property;
/*     */ import NET.worlds.scape.Rect;
/*     */ import NET.worlds.scape.Restorer;
/*     */ import NET.worlds.scape.Room;
/*     */ import NET.worlds.scape.RoomEnvironment;
/*     */ import NET.worlds.scape.Saver;
/*     */ import NET.worlds.scape.TooNewException;
/*     */ import NET.worlds.scape.World;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Stair
/*     */   extends Room
/*     */ {
/*     */   public Portal bottom;
/*     */   public Portal top;
/*     */   private int _lengthwise;
/*     */   static final int PLUSX = 0;
/*     */   static final int PLUSY = 1;
/*     */   static final int MINUSX = 2;
/*     */   static final int MINUSY = 3;
/*     */   private float _length;
/*     */   private float _width;
/*     */   private float _rise;
/*     */   
/*     */   public Stair(World world, String name, float width, float length, float rise, float ceilingz, int numsteps, Material riser, Material tread, Material left, Material right, Material head, Material ceiling)
/*     */   {
/*  70 */     super(world, name);
/*     */     
/*  72 */     this._lengthwise = 1;
/*  73 */     this._length = length;
/*  74 */     this._width = width;
/*  75 */     this._rise = rise;
/*     */     
/*  77 */     RoomEnvironment env = getEnvironment();
/*     */     
/*  79 */     env.add(Rect.ceiling(0.0F, 0.0F, ceilingz, width, length, ceiling));
/*     */     
/*  81 */     float lowerz = ceilingz - rise;
/*  82 */     env.add(new Rect(-0.1F, 0.0F, 0.0F, -0.1F, length, ceilingz, left));
/*  83 */     env.add(new Rect(width + 0.1F, length, 0.0F, width + 0.1F, 0.0F, ceilingz, 
/*  84 */       right));
/*  85 */     env.add(new Rect(width, 0.0F, lowerz, 0.0F, 0.0F, ceilingz, head));
/*  86 */     this.bottom = new Portal(width, 0.0F, 0.0F, 0.0F, 0.0F, lowerz);
/*  87 */     this.top = new Portal(0.0F, length, rise, width, length, ceilingz);
/*     */     
/*  89 */     float dy = length / numsteps;
/*  90 */     float dz = rise / numsteps;
/*     */     
/*  92 */     for (int i = 0; i < numsteps; i++) {
/*  93 */       Rect w = new Rect(0.0F, i * dy, i * dz, width, i * dy, (i + 1) * dz, 
/*  94 */         riser);
/*  95 */       w.setTileSize(dz, dz);
/*     */       
/*     */ 
/*  98 */       env.add(w);
/*     */     }
/*     */     
/* 101 */     for (int i = 0; i < numsteps; i++) {
/* 102 */       Rect w = Rect.floor(0.0F, i * dy, (i + 1) * dz, width, (i + 1) * dy, 
/* 103 */         tread);
/* 104 */       w.setTileSize(dy, dy);
/* 105 */       env.add(w);
/*     */     }
/*     */     
/* 108 */     env.add(this.bottom);
/* 109 */     env.add(this.top);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Stair() {}
/*     */   
/*     */ 
/*     */   void setLength(float len)
/*     */   {
/* 119 */     this._length = len;
/*     */   }
/*     */   
/*     */   void setRise(float r)
/*     */   {
/* 124 */     this._rise = r;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   void setLengthwise(int lw)
/*     */   {
/* 132 */     this._lengthwise = lw;
/*     */   }
/*     */   
/*     */   public float floorHeight(float x, float y, float z)
/*     */   {
/* 137 */     float dist = 0.0F;
/* 138 */     switch (this._lengthwise) {
/*     */     case 0: 
/* 140 */       dist = x;
/* 141 */       break;
/*     */     case 2: 
/* 143 */       dist = this._length - x;
/* 144 */       break;
/*     */     case 1: 
/* 146 */       dist = y;
/* 147 */       break;
/*     */     case 3: 
/* 149 */       dist = this._length - y;
/* 150 */       break;
/*     */     default: 
/* 152 */       if (!$assertionsDisabled) throw new AssertionError();
/*     */       break; }
/* 154 */     return dist / this._length * this._rise;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Point3 surfaceNormal(float x, float y)
/*     */   {
/* 162 */     Point3 A = new Point3(this._width, 0.0F, 0.0F);
/* 163 */     Point3Temp B = Point3Temp.make(0.0F, this._length, this._rise);
/* 164 */     A.cross(B);
/* 165 */     A.normalize();
/* 166 */     return A;
/*     */   }
/*     */   
/* 169 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/* 173 */     s.saveVersion(1, classCookie);
/* 174 */     super.saveState(s);
/* 175 */     s.saveFloat(this._length);
/* 176 */     s.saveFloat(this._rise);
/* 177 */     s.saveInt(this._lengthwise);
/* 178 */     s.save(this.bottom);
/* 179 */     s.save(this.top);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/* 184 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 1: 
/* 186 */       super.restoreState(r);
/* 187 */       this._length = r.restoreFloat();
/* 188 */       this._rise = r.restoreFloat();
/* 189 */       this._lengthwise = r.restoreInt();
/* 190 */       this.bottom = ((Portal)r.restore());
/* 191 */       this.top = ((Portal)r.restore());
/* 192 */       break;
/*     */     case 0: 
/* 194 */       super.restoreState(r);
/* 195 */       this._length = r.restoreFloat();
/* 196 */       this._rise = r.restoreFloat();
/* 197 */       this.bottom = ((Portal)r.restore());
/* 198 */       this.top = ((Portal)r.restore());
/* 199 */       setLengthwise(1);
/* 200 */       break;
/*     */     default: 
/* 202 */       throw new TooNewException();
/*     */     }
/*     */   }
/*     */   
/*     */   void superRestoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/* 208 */     super.restoreState(r);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 217 */     Object ret = null;
/*     */     
/* 219 */     switch (index - offset) {
/*     */     case 0: 
/* 221 */       if (mode == 0) {
/* 222 */         ret = new Property(this, index, "Length");
/* 223 */       } else if (mode == 1)
/* 224 */         ret = new Float(this._length);
/* 225 */       break;
/*     */     case 1: 
/* 227 */       if (mode == 0) {
/* 228 */         ret = new Property(this, index, "Rise");
/* 229 */       } else if (mode == 1)
/* 230 */         ret = new Float(this._rise);
/* 231 */       break;
/*     */     case 2: 
/* 233 */       if (mode == 0) {
/* 234 */         ret = new Property(this, index, "Direction");
/* 235 */       } else if (mode == 1)
/* 236 */         ret = new Integer(this._lengthwise);
/* 237 */       break;
/*     */     default: 
/* 239 */       ret = super.properties(index, offset + 3, mode, value);
/*     */     }
/*     */     
/* 242 */     return ret;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\Stair.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */