/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.network.URL; /* */ import java.io.IOException; /* */ import java.util.StringTokenizer; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class WearWall /* */ extends Rect /* */ { /* 26 */ char limb = ' '; /* */ /* */ /* */ /* */ /* */ /* */ /* 33 */ String tileList = ""; /* */ /* */ /* */ WObject[] subs; /* */ /* */ /* */ public void rebuild() /* */ { /* 41 */ unbuild(); /* */ /* 43 */ if (this.limb == ' ') { /* 44 */ return; /* */ } /* */ /* 47 */ int count = 0; /* 48 */ StringTokenizer st = new StringTokenizer(this.tileList); /* 49 */ while (st.hasMoreTokens()) { /* 50 */ count++; /* 51 */ st.nextToken(); /* */ } /* */ /* 54 */ if (count == 0) { /* 55 */ return; /* */ } /* */ /* */ /* 59 */ float width = getScaleX(); /* 60 */ float height = getScaleZ(); /* */ /* 62 */ int wNum = 1; /* 63 */ int hNum = 1; /* */ /* 65 */ while (wNum * hNum < count) /* */ { /* */ /* 68 */ if (height * (wNum + 1) > width * (hNum + 1)) { /* 69 */ hNum++; /* */ } else { /* 71 */ wNum++; /* */ } /* */ } /* */ /* 75 */ this.subs = new WObject[count]; /* 76 */ float tw = 1.0F / wNum; /* 77 */ float th = 1.0F / hNum; /* */ /* */ /* 80 */ float wHalfSide = tw * getScaleX(); /* 81 */ float hHalfSide = th * getScaleZ(); /* 82 */ float sideLen = wHalfSide < hHalfSide ? wHalfSide : hHalfSide; /* */ /* 84 */ wHalfSide = (sideLen - 6.0F) / getScaleX() / 2.0F; /* 85 */ hHalfSide = (sideLen - 6.0F) / getScaleZ() / 2.0F; /* */ /* 87 */ st = new StringTokenizer(this.tileList); /* */ /* 89 */ float y = -1.0F / getScaleY(); /* 90 */ float z = 1.0F - th / 2.0F; /* 91 */ int i = 0; /* 92 */ for (int row = 0; row < hNum; z -= th) { /* 93 */ float x = tw / 2.0F; /* 94 */ for (int col = 0; col < wNum; x += tw) { /* 95 */ if (!st.hasMoreTokens()) { /* 96 */ return; /* */ } /* 98 */ Material m = null; /* 99 */ String s = st.nextToken(); /* 100 */ String bodyType = null; /* */ try { /* 102 */ char c = s.charAt(0); /* 103 */ if ((c == 'C') || (c == 'T')) { /* 104 */ if ((this.limb == 'H') || (this.limb == 'E')) { /* */ break label780; /* */ } /* 107 */ if (c == 'C') { /* 108 */ m = PosableShape.readColor(s, 1); /* */ } else /* 110 */ m = PosableShape.readTexture(s, 1); /* */ } else { /* 112 */ String name = PosableShape.readName(s, 0); /* 113 */ if (this.limb == 'H') { /* 114 */ bodyType = name; /* 115 */ } else { if (this.limb != 'E') break label780; /* 116 */ name = PosableShape.getFace(name); /* */ /* 118 */ m = PosableShape.readTexture(name, 0); /* */ } /* */ } /* */ } /* */ catch (StringIndexOutOfBoundsException e) /* */ { /* */ break label780; /* */ } /* */ /* 127 */ if (bodyType != null) { /* 128 */ s = PosableShape.getAvURL(bodyType).getAbsolute(); /* */ int start; /* 130 */ if ((s != null) && ((start = s.indexOf(".0E")) >= 0)) /* */ { /* 132 */ int start = PosableShape.skipLimb(s, start + 3); /* 133 */ if (start >= 0) /* */ { /* */ /* */ /* 137 */ int headIndex = s.lastIndexOf("NS"); /* 138 */ if (headIndex >= 0) /* */ { /* */ /* */ /* */ /* */ /* */ /* 145 */ PosableShape p = /* 146 */ new PosableShape(URL.make(s.substring(0, start) + /* 147 */ "PGNG" + PosableShape.getBodyType(bodyType) + /* 148 */ "Q" + s.substring(headIndex + 1)), false); /* */ /* 150 */ p.scale(750.0F / getScaleX(), /* 151 */ 750.0F / getScaleY(), /* 152 */ 750.0F / getScaleZ()); /* 153 */ p.spin(0.0F, 1.0F, 1.0F, 180.0F); /* 154 */ p.spin(0.0F, 1.0F, 0.0F, 180.0F); /* 155 */ p.moveTo(x, y * 10.0F, z - hHalfSide / 2.0F); /* 156 */ WearAction action = new WearAction(); /* 157 */ action.limb = this.limb; /* 158 */ action.val = bodyType; /* 159 */ p.addAction(action); /* 160 */ p.addHandler(new ClickSensor(action, 1)); /* 161 */ add(p); /* 162 */ this.subs[i] = p; /* 163 */ } } } } else if (m != null) { /* 164 */ m.setAmbient(0.75F); /* 165 */ m.setDiffuse(0.0F); /* 166 */ Rect r = new Rect(x - wHalfSide, y, z - hHalfSide, /* 167 */ x + wHalfSide, y, z + hHalfSide, m); /* 168 */ WearAction action = new WearAction(); /* 169 */ action.limb = this.limb; /* 170 */ action.val = s; /* 171 */ r.addAction(action); /* 172 */ r.addHandler(new ClickSensor(action, 1)); /* 173 */ add(r); /* 174 */ this.subs[i] = r; /* */ } /* */ label780: /* 94 */ col++; i++; /* */ } /* 92 */ row++; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void unbuild() /* */ { /* 184 */ if (this.subs != null) { /* 185 */ int i = this.subs.length; /* 186 */ do { if (this.subs[i] != null) { /* 187 */ this.subs[i].detach(); /* */ } /* 185 */ i--; } while (i >= 0); /* */ } /* */ /* 188 */ this.subs = null; /* */ } /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 197 */ Object ret = null; /* 198 */ switch (index - offset) { /* */ case 0: /* 200 */ if (mode == 0) { /* 201 */ ret = StringPropertyEditor.make( /* 202 */ new Property(this, index, "Limb")); /* 203 */ } else if (mode == 1) { /* 204 */ ret = new String(this.limb); /* 205 */ } else if (mode == 2) { /* 206 */ String s = (String)value; /* 207 */ if (s.length() >= 1) { /* 208 */ this.limb = s.charAt(0); /* 209 */ rebuild(); /* */ } /* */ } /* 212 */ break; /* */ case 1: /* 214 */ if (mode == 0) { /* 215 */ ret = StringPropertyEditor.make( /* 216 */ new Property(this, index, "Tile List")); /* 217 */ } else if (mode == 1) { /* 218 */ ret = new String(this.tileList); /* 219 */ } else if (mode == 2) { /* 220 */ this.tileList = ((String)value); /* 221 */ rebuild(); /* */ } /* 223 */ break; /* */ default: /* 225 */ ret = super.properties(index, offset + 2, mode, value); /* */ } /* 227 */ return ret; /* */ } /* */ /* 230 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 234 */ unbuild(); /* 235 */ s.saveVersion(2, classCookie); /* 236 */ super.saveState(s); /* 237 */ rebuild(); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 242 */ int vers = r.restoreVersion(classCookie); /* 243 */ switch (vers) { /* */ case 0: /* 245 */ super.restoreState(r); /* 246 */ r.restoreString(); /* 247 */ r.restoreString(); /* 248 */ break; /* */ case 1: /* 250 */ super.restoreState(r); /* 251 */ r.restoreString(); /* 252 */ break; /* */ case 2: /* 254 */ super.restoreState(r); /* 255 */ break; /* */ default: /* 257 */ throw new TooNewException(); /* */ } /* 259 */ rebuild(); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WearWall.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */