diff options
Diffstat (limited to 'NET/worlds/console/Staircase.java')
| -rw-r--r-- | NET/worlds/console/Staircase.java | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/NET/worlds/console/Staircase.java b/NET/worlds/console/Staircase.java new file mode 100644 index 0000000..6028aa3 --- /dev/null +++ b/NET/worlds/console/Staircase.java @@ -0,0 +1,312 @@ +/* */ package NET.worlds.console; +/* */ +/* */ import NET.worlds.scape.FrameEvent; +/* */ import NET.worlds.scape.FrameHandler; +/* */ import NET.worlds.scape.Material; +/* */ import NET.worlds.scape.Point3; +/* */ import NET.worlds.scape.Point3Temp; +/* */ import NET.worlds.scape.Portal; +/* */ 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.WObject; +/* */ import NET.worlds.scape.World; +/* */ import java.io.IOException; +/* */ import java.util.Enumeration; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class Staircase +/* */ extends Room +/* */ implements FrameHandler +/* */ { +/* */ public Portal bottom; +/* */ public Portal top; +/* */ private float dzdx; +/* */ private float dzdy; +/* */ +/* */ public Staircase(World world, String name, float x1, float y1, float z1, float x2, float y2, float z2, float ceilingz, int numsteps, Material riser, Material tread, Material left, Material right, Material head, Material ceiling) +/* */ { +/* 64 */ super(world, name); +/* */ +/* 66 */ float dx = (x2 - x1) / numsteps; +/* 67 */ float dy = (y2 - y1) / numsteps; +/* 68 */ float dz = (z2 - z1) / numsteps; +/* 69 */ this.dzdx = (dz / dx); +/* 70 */ this.dzdy = (dz / dy); +/* 71 */ assert (dz >= 0.0F); +/* */ +/* 73 */ float bottomtopz = z1 + ceilingz - z2; +/* 74 */ RoomEnvironment env = getEnvironment(); +/* */ +/* 76 */ env.add(Rect.ceiling(x1, y1, ceilingz, x2, y2, ceiling)); +/* */ +/* 78 */ if (dx > 0.0F) { +/* 79 */ if (dy > 0.0F) +/* */ { +/* 81 */ env.add(new Rect(x1 - 0.1F, y1, z1, x1 - 0.1F, y2, ceilingz, +/* 82 */ left)); +/* 83 */ env.add(new Rect(x2 + 0.1F, y2, z1, x2 + 0.1F, y1, ceilingz, +/* 84 */ right)); +/* 85 */ env.add(new Rect(x2, y1, bottomtopz, x1, y1, ceilingz, head)); +/* 86 */ this.bottom = new Portal(x2, y1, z1, x1, y1, bottomtopz); +/* 87 */ this.top = new Portal(x1, y2, z2, x2, y2, ceilingz); +/* */ +/* 89 */ for (int i = 0; i < numsteps; i++) { +/* 90 */ Rect w = new Rect(x1, y1 + i * dy, z1 + i * dz, x2, y1 + i * +/* 91 */ dy, z1 + (i + 1) * dz, riser); +/* 92 */ w.setTileSize(dz, dz); +/* */ +/* */ +/* 95 */ env.add(w); +/* */ } +/* */ +/* 98 */ for (int i = 0; i < numsteps; i++) { +/* 99 */ Rect w = Rect.floor(x1, y1 + i * dy, z1 + (i + 1) * dz, x2, +/* 100 */ y1 + (i + 1) * dy, tread); +/* 101 */ w.setTileSize(Math.abs(dy), Math.abs(dy)); +/* 102 */ env.add(w); +/* */ } +/* 104 */ this.dzdx = 0.0F; +/* */ } +/* */ else { +/* 107 */ env.add(new Rect(x1, y1 - 0.1F, z1, x2, y1 - 0.1F, ceilingz, +/* 108 */ left)); +/* 109 */ env.add(new Rect(x2, y2 + 0.1F, z1, x1, y2 + 0.1F, ceilingz, +/* 110 */ right)); +/* 111 */ env.add(new Rect(x1, y2, bottomtopz, x1, y1, ceilingz, head)); +/* 112 */ this.bottom = new Portal(x1, y2, z1, x1, y1, bottomtopz); +/* 113 */ this.top = new Portal(x2, y1, z2, x2, y2, ceilingz); +/* */ +/* 115 */ for (int i = 0; i < numsteps; i++) { +/* 116 */ Rect w = new Rect(x1 + i * dx, y1, z1 + i * dz, +/* 117 */ x1 + i * dx, y2, z1 + (i + 1) * dz, riser); +/* 118 */ w.setTileSize(dz, dz); +/* */ +/* */ +/* 121 */ env.add(w); +/* */ } +/* */ +/* 124 */ for (int i = 0; i < numsteps; i++) { +/* 125 */ Rect w = Rect.floor(x1 + i * dx, y2, z1 + (i + 1) * dz, x1 + +/* 126 */ (i + 1) * dx, y1, tread); +/* 127 */ w.setTileSize(Math.abs(dx), Math.abs(dx)); +/* 128 */ env.add(w); +/* */ } +/* 130 */ this.dzdy = 0.0F; +/* */ } +/* */ } +/* 133 */ else if (dy > 0.0F) +/* */ { +/* 135 */ env.add(new Rect(x1, y1 - 0.1F, z1, x2, y1 - 0.1F, ceilingz, +/* 136 */ left)); +/* 137 */ env.add(new Rect(x2, y2 + 0.1F, z1, x1, y2 + 0.1F, ceilingz, +/* 138 */ right)); +/* 139 */ env.add(new Rect(x1, y2, bottomtopz, x1, y1, ceilingz, head)); +/* 140 */ this.bottom = new Portal(x1, y2, z1, x1, y1, bottomtopz); +/* 141 */ this.top = new Portal(x2, y1, z2, x2, y2, ceilingz); +/* */ +/* 143 */ for (int i = 0; i < numsteps; i++) { +/* 144 */ Rect w = new Rect(x1 + i * dx, y1, z1 + i * dz, +/* 145 */ x1 + i * dx, y2, z1 + (i + 1) * dz, riser); +/* 146 */ w.setTileSize(dz, dz); +/* */ +/* */ +/* 149 */ env.add(w); +/* */ } +/* */ +/* 152 */ for (int i = 0; i < numsteps; i++) { +/* 153 */ Rect w = Rect.floor(x1 + (i + 1) * dx, y1, z1 + (i + 1) * +/* 154 */ dz, x1 + i * dx, y2, tread); +/* 155 */ w.setTileSize(Math.abs(dx), Math.abs(dx)); +/* 156 */ env.add(w); +/* */ } +/* 158 */ this.dzdy = 0.0F; +/* */ } +/* */ else { +/* 161 */ env.add(new Rect(x1 + 0.1F, y1, z1, x1 + 0.1F, y2, ceilingz, +/* 162 */ left)); +/* 163 */ env.add(new Rect(x2 - 0.1F, y2, z1, x2 - 0.1F, y1, ceilingz, +/* 164 */ right)); +/* 165 */ env.add(new Rect(x2, y1, bottomtopz, x1, y1, ceilingz, head)); +/* 166 */ this.bottom = new Portal(x2, y1, z1, x1, y1, bottomtopz); +/* 167 */ this.top = new Portal(x1, y2, z2, x2, y2, ceilingz); +/* */ +/* 169 */ for (int i = 0; i < numsteps; i++) { +/* 170 */ Rect w = new Rect(x1, y1 + i * dy, z1 + i * dz, x2, y1 + i * +/* 171 */ dy, z1 + (i + 1) * dz, riser); +/* 172 */ w.setTileSize(dz, dz); +/* */ +/* */ +/* 175 */ env.add(w); +/* */ } +/* */ +/* 178 */ for (int i = 0; i < numsteps; i++) { +/* 179 */ Rect w = Rect.floor(x2, y1 + (i + 1) * dy, z1 + (i + 1) * +/* 180 */ dz, x1, y1 + i * dy, tread); +/* 181 */ w.setTileSize(Math.abs(dy), Math.abs(dy)); +/* 182 */ env.add(w); +/* */ } +/* 184 */ this.dzdx = 0.0F; +/* */ } +/* */ +/* 187 */ env.add(this.bottom); +/* 188 */ env.add(this.top); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 199 */ private Vector<WObject> seenThings = new Vector(); +/* */ +/* */ +/* */ +/* */ +/* 204 */ private Vector<Point3> seenStarts = new Vector(); +/* */ +/* */ public Staircase() {} +/* */ +/* */ public boolean handle(FrameEvent e) +/* */ { +/* 210 */ Enumeration<WObject> stuff = getContents(); +/* 211 */ while (stuff.hasMoreElements()) { +/* 212 */ WObject thing = (WObject)stuff.nextElement(); +/* 213 */ int i = this.seenThings.indexOf(thing); +/* 214 */ if (i == -1) +/* */ { +/* 216 */ this.seenThings.addElement(thing); +/* 217 */ Point3Temp startpos = thing.getPosition(); +/* */ +/* 219 */ Point3Temp topctr = Point3Temp.make(this.top.getScaleX(), 0.0F, +/* 220 */ this.top.getScaleZ()).times(0.5F).times( +/* 221 */ this.top.getObjectToWorldMatrix()); +/* 222 */ Point3Temp bottomctr = Point3Temp.make(this.bottom.getScaleX(), 0.0F, +/* 223 */ this.bottom.getScaleZ()).times(0.5F).times( +/* 224 */ this.bottom.getObjectToWorldMatrix()); +/* 225 */ if (topctr.x == bottomctr.x) { +/* 226 */ float t = (startpos.y - bottomctr.y) / ( +/* 227 */ topctr.y - bottomctr.y); +/* 228 */ if (t < 0.5F) { +/* 229 */ startpos.y = bottomctr.y; +/* */ } else +/* 231 */ startpos.y = topctr.y; +/* 232 */ this.dzdx = 0.0F; +/* 233 */ } else if (topctr.y == bottomctr.y) { +/* 234 */ float t = (startpos.x - bottomctr.x) / ( +/* 235 */ topctr.x - bottomctr.x); +/* 236 */ if (t < 0.5F) { +/* 237 */ startpos.x = bottomctr.x; +/* */ } else +/* 239 */ startpos.x = topctr.x; +/* 240 */ this.dzdy = 0.0F; +/* */ } +/* 242 */ else if (!$assertionsDisabled) { throw new AssertionError(); } +/* 243 */ this.seenStarts.addElement(new Point3(startpos)); +/* 244 */ i = this.seenThings.size() - 1; +/* 245 */ assert (i == this.seenStarts.size() - 1); +/* */ } +/* 247 */ Point3Temp oldpos = (Point3Temp)this.seenStarts.elementAt(i); +/* */ +/* 249 */ Point3Temp pos = thing.getPosition(); +/* 250 */ float deltaz = this.dzdx * (pos.x - oldpos.x) + this.dzdy * ( +/* 251 */ pos.y - oldpos.y) + oldpos.z - pos.z; +/* 252 */ if (deltaz != 0.0F) { +/* 253 */ thing.raise(deltaz); +/* */ } +/* */ } +/* 256 */ return true; +/* */ } +/* */ +/* 259 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 263 */ s.saveVersion(0, classCookie); +/* 264 */ super.saveState(s); +/* 265 */ s.saveFloat(this.dzdx); +/* 266 */ s.saveFloat(this.dzdy); +/* 267 */ s.save(this.bottom); +/* 268 */ s.save(this.top); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 273 */ Stair s = new Stair(); +/* 274 */ r.replace(this, s); +/* 275 */ int version = r.restoreVersion(classCookie); +/* 276 */ if (version != 0) +/* 277 */ throw new TooNewException(); +/* 278 */ s.superRestoreState(r); +/* 279 */ float dzdx = r.restoreFloat(); +/* 280 */ float dzdy = r.restoreFloat(); +/* 281 */ s.bottom = ((Portal)r.restore()); +/* 282 */ s.top = ((Portal)r.restore()); +/* */ +/* 284 */ Point3Temp tllc = s.top.getPosition(); +/* 285 */ Point3Temp bllc = s.bottom.getPosition(); +/* 286 */ s.setRise(tllc.z - bllc.z); +/* 287 */ if (dzdx == 0.0F) { +/* 288 */ if (dzdy > 0.0F) { +/* 289 */ s.setLengthwise(1); +/* 290 */ s.setLength(tllc.y - bllc.y); +/* */ } else { +/* 292 */ s.setLengthwise(3); +/* 293 */ s.setLength(bllc.y - tllc.y); +/* */ } +/* */ } else { +/* 296 */ assert (dzdy == 0.0F); +/* 297 */ if (dzdx > 0.0F) { +/* 298 */ s.setLengthwise(0); +/* 299 */ s.setLength(tllc.x - bllc.x); +/* */ } else { +/* 301 */ s.setLengthwise(2); +/* 302 */ s.setLength(bllc.x - tllc.x); +/* */ } +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\Staircase.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |