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) { } }