summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WearWall.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/WearWall.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/WearWall.java')
-rw-r--r--NET/worlds/scape/WearWall.java223
1 files changed, 223 insertions, 0 deletions
diff --git a/NET/worlds/scape/WearWall.java b/NET/worlds/scape/WearWall.java
new file mode 100644
index 0000000..ff8ca02
--- /dev/null
+++ b/NET/worlds/scape/WearWall.java
@@ -0,0 +1,223 @@
+package NET.worlds.scape;
+
+import NET.worlds.network.URL;
+import java.io.IOException;
+import java.util.StringTokenizer;
+
+public class WearWall extends Rect {
+ char limb = ' ';
+ String tileList = "";
+ WObject[] subs;
+ private static Object classCookie = new Object();
+
+ WearWall() {
+ }
+
+ public void rebuild() {
+ this.unbuild();
+ if (this.limb != ' ') {
+ int count = 0;
+ StringTokenizer st = new StringTokenizer(this.tileList);
+
+ while (st.hasMoreTokens()) {
+ count++;
+ st.nextToken();
+ }
+
+ if (count != 0) {
+ float width = this.getScaleX();
+ float height = this.getScaleZ();
+ int wNum = 1;
+ int hNum = 1;
+
+ while (wNum * hNum < count) {
+ if (height * (wNum + 1) > width * (hNum + 1)) {
+ hNum++;
+ } else {
+ wNum++;
+ }
+ }
+
+ this.subs = new WObject[count];
+ float tw = 1.0F / wNum;
+ float th = 1.0F / hNum;
+ float wHalfSide = tw * this.getScaleX();
+ float hHalfSide = th * this.getScaleZ();
+ float sideLen = wHalfSide < hHalfSide ? wHalfSide : hHalfSide;
+ wHalfSide = (sideLen - 6.0F) / this.getScaleX() / 2.0F;
+ hHalfSide = (sideLen - 6.0F) / this.getScaleZ() / 2.0F;
+ st = new StringTokenizer(this.tileList);
+ float y = -1.0F / this.getScaleY();
+ float z = 1.0F - th / 2.0F;
+ int i = 0;
+
+ for (int row = 0; row < hNum; z -= th) {
+ float x = tw / 2.0F;
+
+ for (int col = 0; col < wNum; x += tw) {
+ if (!st.hasMoreTokens()) {
+ return;
+ }
+
+ Material m = null;
+ String s = st.nextToken();
+ String bodyType = null;
+
+ label91: {
+ try {
+ char c = s.charAt(0);
+ if (c != 'C' && c != 'T') {
+ String name = PosableShape.readName(s, 0);
+ if (this.limb == 'H') {
+ bodyType = name;
+ } else {
+ if (this.limb != 'E') {
+ break label91;
+ }
+
+ name = PosableShape.getFace(name);
+ m = PosableShape.readTexture(name, 0);
+ }
+ } else {
+ if (this.limb == 'H' || this.limb == 'E') {
+ break label91;
+ }
+
+ if (c == 'C') {
+ m = PosableShape.readColor(s, 1);
+ } else {
+ m = PosableShape.readTexture(s, 1);
+ }
+ }
+ } catch (StringIndexOutOfBoundsException var25) {
+ break label91;
+ }
+
+ if (bodyType != null) {
+ s = PosableShape.getAvURL(bodyType).getAbsolute();
+ int start;
+ if (s != null && (start = s.indexOf(".0E")) >= 0) {
+ start = PosableShape.skipLimb(s, start + 3);
+ if (start >= 0) {
+ int headIndex = s.lastIndexOf("NS");
+ if (headIndex >= 0) {
+ PosableShape p = new PosableShape(
+ URL.make(s.substring(0, start) + "PGNG" + PosableShape.getBodyType(bodyType) + "Q" + s.substring(headIndex + 1)), false
+ );
+ p.scale(750.0F / this.getScaleX(), 750.0F / this.getScaleY(), 750.0F / this.getScaleZ());
+ p.spin(0.0F, 1.0F, 1.0F, 180.0F);
+ p.spin(0.0F, 1.0F, 0.0F, 180.0F);
+ p.moveTo(x, y * 10.0F, z - hHalfSide / 2.0F);
+ WearAction action = new WearAction();
+ action.limb = this.limb;
+ action.val = bodyType;
+ p.addAction(action);
+ p.addHandler(new ClickSensor(action, 1));
+ this.add(p);
+ this.subs[i] = p;
+ }
+ }
+ }
+ } else if (m != null) {
+ m.setAmbient(0.75F);
+ m.setDiffuse(0.0F);
+ Rect r = new Rect(x - wHalfSide, y, z - hHalfSide, x + wHalfSide, y, z + hHalfSide, m);
+ WearAction action = new WearAction();
+ action.limb = this.limb;
+ action.val = s;
+ r.addAction(action);
+ r.addHandler(new ClickSensor(action, 1));
+ this.add(r);
+ this.subs[i] = r;
+ }
+ }
+
+ col++;
+ i++;
+ }
+
+ row++;
+ }
+ }
+ }
+ }
+
+ private void unbuild() {
+ if (this.subs != null) {
+ int i = this.subs.length;
+
+ while (--i >= 0) {
+ if (this.subs[i] != null) {
+ this.subs[i].detach();
+ }
+ }
+ }
+
+ this.subs = null;
+ }
+
+ @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 = StringPropertyEditor.make(new Property(this, index, "Limb"));
+ } else if (mode == 1) {
+ ret = new String("" + this.limb);
+ } else if (mode == 2) {
+ String s = (String)value;
+ if (s.length() >= 1) {
+ this.limb = s.charAt(0);
+ this.rebuild();
+ }
+ }
+ break;
+ case 1:
+ if (mode == 0) {
+ ret = StringPropertyEditor.make(new Property(this, index, "Tile List"));
+ } else if (mode == 1) {
+ ret = new String(this.tileList);
+ } else if (mode == 2) {
+ this.tileList = (String)value;
+ this.rebuild();
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 2, mode, value);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ this.unbuild();
+ s.saveVersion(2, classCookie);
+ super.saveState(s);
+ this.rebuild();
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ int vers = r.restoreVersion(classCookie);
+ switch (vers) {
+ case 0:
+ super.restoreState(r);
+ r.restoreString();
+ r.restoreString();
+ break;
+ case 1:
+ super.restoreState(r);
+ r.restoreString();
+ break;
+ case 2:
+ super.restoreState(r);
+ break;
+ default:
+ throw new TooNewException();
+ }
+
+ this.rebuild();
+ }
+}