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
|
/* */ package NET.worlds.scape;
/* */
/* */ import java.io.IOException;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ProximitySensor
/* */ extends Sensor
/* */ implements FrameHandler
/* */ {
/* */ public ProximitySensor(Action a)
/* */ {
/* 34 */ if (a != null) {
/* 35 */ addAction(a);
/* */ }
/* */ }
/* */
/* */
/* 40 */ private boolean _wasin = false;
/* 41 */ private Point3 _start = new Point3(0.0F, 0.0F, 0.0F);
/* 42 */ private Point3 _end = new Point3(1.0F, 1.0F, 1.0F);
/* 43 */ private boolean _triggerin = true;
/* 44 */ private boolean _triggerout = false;
/* 45 */ private boolean _silentTeleport = false;
/* */ private Room _lastRoom;
/* */
/* */ public ProximitySensor() {}
/* */
/* 50 */ public boolean handle(FrameEvent e) { SuperRoot owner = getOwner();
/* 51 */ if (!(owner instanceof WObject))
/* 52 */ return true;
/* 53 */ WObject wo = (WObject)owner;
/* 54 */ Pilot pilot = Pilot.getActive();
/* 55 */ Room room = pilot.getRoom();
/* 56 */ boolean teleport = room != this._lastRoom;
/* 57 */ this._lastRoom = room;
/* */
/* 59 */ Point3Temp pos = pilot.getPosition();
/* */
/* 61 */ BoundBoxTemp bbt = BoundBoxTemp.make(Point3Temp.make(this._start).times(wo),
/* 62 */ Point3Temp.make(this._end).times(wo));
/* */
/* */
/* */
/* */
/* */
/* 68 */ if ((pilot.getRoom() == wo.getRoom()) && (bbt.contains(pos)))
/* */ {
/* 70 */ if (!this._wasin) {
/* 71 */ this._wasin = true;
/* */
/* 73 */ if ((this._triggerin) && ((!teleport) || (!this._silentTeleport))) {
/* 74 */ trigger(e);
/* */ }
/* */
/* */ }
/* */ }
/* 79 */ else if (this._wasin) {
/* 80 */ this._wasin = false;
/* */
/* 82 */ if ((this._triggerout) && ((!teleport) || (!this._silentTeleport))) {
/* 83 */ trigger(e);
/* */ }
/* */ }
/* 86 */ return true;
/* */ }
/* */
/* */
/* */
/* */
/* */ public Object properties(int index, int offset, int mode, Object value)
/* */ throws NoSuchPropertyException
/* */ {
/* 95 */ Object ret = null;
/* 96 */ switch (index - offset) {
/* */ case 0:
/* 98 */ if (mode == 0) {
/* 99 */ ret = Point3PropertyEditor.make(new Property(this, index,
/* 100 */ "Start"));
/* */ }
/* 102 */ else if (mode == 1) {
/* 103 */ ret = new Point3(this._start);
/* 104 */ } else if (mode == 2)
/* 105 */ this._start = ((Point3)value);
/* 106 */ break;
/* */ case 1:
/* 108 */ if (mode == 0) {
/* 109 */ ret = Point3PropertyEditor.make(new Property(this, index,
/* 110 */ "End"));
/* */ }
/* 112 */ else if (mode == 1) {
/* 113 */ ret = new Point3(this._end);
/* 114 */ } else if (mode == 2)
/* 115 */ this._end = ((Point3)value);
/* 116 */ break;
/* */ case 2:
/* 118 */ if (mode == 0) {
/* 119 */ ret = BooleanPropertyEditor.make(new Property(this, index,
/* 120 */ "Trigger on entry"), "Don't trigger when entered",
/* 121 */ "Trigger when entered");
/* */ }
/* 123 */ else if (mode == 1) {
/* 124 */ ret = new Boolean(this._triggerin);
/* 125 */ } else if (mode == 2)
/* 126 */ this._triggerin = ((Boolean)value).booleanValue();
/* 127 */ break;
/* */ case 3:
/* 129 */ if (mode == 0) {
/* 130 */ ret = BooleanPropertyEditor.make(new Property(this, index,
/* 131 */ "Trigger on exit"), "Don't trigger when exited",
/* 132 */ "Trigger when exited");
/* */ }
/* 134 */ else if (mode == 1) {
/* 135 */ ret = new Boolean(this._triggerout);
/* 136 */ } else if (mode == 2)
/* 137 */ this._triggerout = ((Boolean)value).booleanValue();
/* 138 */ break;
/* */ case 4:
/* 140 */ if (mode == 0) {
/* 141 */ ret = BooleanPropertyEditor.make(new Property(this, index,
/* 142 */ "Teleport trigger"), "Don't trigger on teleports",
/* 143 */ "Trigger on teleports");
/* */ }
/* 145 */ else if (mode == 1) {
/* 146 */ ret = new Boolean(!this._silentTeleport);
/* 147 */ } else if (mode == 2)
/* 148 */ this._silentTeleport = (!((Boolean)value).booleanValue());
/* 149 */ break;
/* */ default:
/* 151 */ ret = super.properties(index, offset + 5, mode, value);
/* */ }
/* */
/* 154 */ return ret;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* 161 */ private static Object classCookie = new Object();
/* */
/* */ public void saveState(Saver s) throws IOException
/* */ {
/* 165 */ s.saveVersion(2, classCookie);
/* 166 */ super.saveState(s);
/* 167 */ s.saveBoolean(this._triggerin);
/* 168 */ s.saveBoolean(this._triggerout);
/* 169 */ s.saveBoolean(this._silentTeleport);
/* 170 */ s.save(this._start);
/* 171 */ s.save(this._end);
/* */ }
/* */
/* */ public void restoreState(Restorer r) throws IOException, TooNewException
/* */ {
/* 176 */ switch (r.restoreVersion(classCookie)) {
/* */ case 2:
/* 178 */ super.restoreState(r);
/* 179 */ this._triggerin = r.restoreBoolean();
/* 180 */ this._triggerout = r.restoreBoolean();
/* 181 */ this._silentTeleport = r.restoreBoolean();
/* 182 */ this._start = ((Point3)r.restore());
/* 183 */ this._end = ((Point3)r.restore());
/* 184 */ break;
/* */ case 1:
/* 186 */ super.restoreState(r);
/* 187 */ this._triggerin = r.restoreBoolean();
/* 188 */ this._triggerout = r.restoreBoolean();
/* 189 */ this._start = ((Point3)r.restore());
/* 190 */ this._end = ((Point3)r.restore());
/* 191 */ break;
/* */ default:
/* 193 */ throw new TooNewException();
/* */ }
/* */
/* */ }
/* */
/* */
/* */
/* */
/* */ public String toString()
/* */ {
/* 203 */ return
/* 204 */ super.toString() + "[" + (this._triggerin ? "I" : " ") + (this._triggerout ? "O" : " ") + this._start + " to " + this._end + "]";
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ProximitySensor.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|