1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
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();
}
}
|