diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/console/Stair.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/console/Stair.java')
| -rw-r--r-- | NET/worlds/console/Stair.java | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/NET/worlds/console/Stair.java b/NET/worlds/console/Stair.java new file mode 100644 index 0000000..f36a5f6 --- /dev/null +++ b/NET/worlds/console/Stair.java @@ -0,0 +1,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 + */
\ No newline at end of file |