summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Trigger.java
blob: 69772b7ebedea63fca8c050e6df348c698e76cee (plain) (blame)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import NET.worlds.console.Console;
/*     */ import java.io.IOException;
/*     */ import java.text.MessageFormat;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class Trigger
/*     */   extends SwitchableBehavior
/*     */   implements FrameHandler, Persister, MouseDownHandler, BumpHandler
/*     */ {
/*  23 */   public static TriggeredSwitchableBehavior[] TriggeredSwitchableBehaviorList = new TriggeredSwitchableBehavior['Ϩ'];
/*  24 */   public static int TriggeredSwitchableBehaviorListCount = 0;
/*     */   
/*     */   public String trigger;
/*     */   
/*     */   public String targetTriggerTag;
/*     */   public String[][] targetTriggerTagArray;
/*     */   public int targetTriggerTagCount;
/*     */   public int[] finishedTriggerTagSequenceNo;
/*     */   public int[] finishedTriggerTagEventNo;
/*     */   public int finishedTriggerTagCount;
/*     */   
/*     */   public Trigger()
/*     */   {
/*  37 */     this.trigger = new String("none");
/*  38 */     this.targetTriggerTag = new String("");
/*  39 */     this.targetTriggerTagArray = new String[20][10];
/*  40 */     this.targetTriggerTagCount = 0;
/*  41 */     this.finishedTriggerTagSequenceNo = new int[50];
/*  42 */     this.finishedTriggerTagEventNo = new int[50];
/*  43 */     this.finishedTriggerTagCount = 0;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private void addTargetTriggerTagArray(String[] sequentialTargetTriggerTagArray, String targetTriggerTag)
/*     */   {
/*  51 */     int currentIndex = 1;
/*  52 */     int currentSeparator = 0;int nextSeparator = 0;
/*  53 */     int lastSeparator = targetTriggerTag.lastIndexOf("+");
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  58 */     if ((lastSeparator == -1) && (targetTriggerTag.length() == 0))
/*     */     {
/*  60 */       currentIndex = 0;
/*  61 */       sequentialTargetTriggerTagArray[0] = String.valueOf(currentIndex);
/*     */ 
/*     */     }
/*  64 */     else if (lastSeparator == -1)
/*     */     {
/*  66 */       sequentialTargetTriggerTagArray[currentIndex] = 
/*  67 */         targetTriggerTag;
/*  68 */       sequentialTargetTriggerTagArray[0] = 
/*  69 */         String.valueOf(currentIndex);
/*     */     }
/*     */     else {
/*  72 */       nextSeparator = targetTriggerTag.indexOf("+");
/*     */       
/*  74 */       sequentialTargetTriggerTagArray[currentIndex] = 
/*  75 */         targetTriggerTag.substring(0, nextSeparator);
/*  76 */       currentIndex++;
/*     */       
/*  78 */       while (nextSeparator != lastSeparator) {
/*  79 */         currentSeparator = nextSeparator;
/*  80 */         nextSeparator = targetTriggerTag.indexOf("+", 
/*  81 */           currentSeparator + 1);
/*  82 */         sequentialTargetTriggerTagArray[currentIndex] = 
/*  83 */           targetTriggerTag.substring(currentSeparator + 1, 
/*  84 */           nextSeparator);
/*  85 */         currentIndex++;
/*     */       }
/*     */       
/*  88 */       sequentialTargetTriggerTagArray[currentIndex] = 
/*  89 */         targetTriggerTag.substring(nextSeparator + 1);
/*  90 */       sequentialTargetTriggerTagArray[0] = 
/*  91 */         String.valueOf(currentIndex);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void preprocessTargetTriggerTag(String targetTriggerTag)
/*     */   {
/* 100 */     int currentIndex = 1;
/* 101 */     int currentSeparator = 0;int nextSeparator = 0;
/* 102 */     int lastSeparator = targetTriggerTag.lastIndexOf(" ");
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 107 */     if ((lastSeparator != -1) || (targetTriggerTag.length() != 0))
/*     */     {
/*     */ 
/*     */ 
/* 111 */       if (lastSeparator == -1)
/*     */       {
/* 113 */         addTargetTriggerTagArray(this.targetTriggerTagArray[currentIndex], 
/* 114 */           targetTriggerTag);
/* 115 */         this.targetTriggerTagCount = currentIndex;
/*     */       }
/*     */       else {
/* 118 */         nextSeparator = targetTriggerTag.indexOf(" ");
/*     */         
/* 120 */         addTargetTriggerTagArray(this.targetTriggerTagArray[currentIndex], 
/* 121 */           targetTriggerTag.substring(0, nextSeparator));
/* 122 */         currentIndex++;
/*     */         
/* 124 */         while (nextSeparator != lastSeparator) {
/* 125 */           currentSeparator = nextSeparator;
/* 126 */           nextSeparator = targetTriggerTag.indexOf(" ", 
/* 127 */             currentSeparator + 1);
/* 128 */           addTargetTriggerTagArray(
/* 129 */             this.targetTriggerTagArray[currentIndex], 
/* 130 */             targetTriggerTag.substring(currentSeparator + 1, 
/* 131 */             nextSeparator));
/* 132 */           currentIndex++;
/*     */         }
/*     */         
/* 135 */         addTargetTriggerTagArray(this.targetTriggerTagArray[currentIndex], 
/* 136 */           targetTriggerTag.substring(nextSeparator + 1));
/* 137 */         this.targetTriggerTagCount = currentIndex;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void activateTrigger()
/*     */   {
/* 150 */     for (int j = 1; j <= this.targetTriggerTagCount; j++)
/*     */     {
/* 152 */       boolean match = false;
/* 153 */       int i = 0;
/* 154 */       while ((!match) && (i < TriggeredSwitchableBehaviorListCount))
/*     */       {
/* 156 */         if ((this.targetTriggerTagArray[j][1].equals(TriggeredSwitchableBehaviorList[i].externalTriggerTag)) && 
/* 157 */           (TriggeredSwitchableBehaviorList[i] != null)) {
/* 158 */           TriggeredSwitchableBehaviorList[i].ExternalTrigger(
/* 159 */             this, j, 1);
/*     */         }
/*     */         
/* 162 */         i++;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public void activateSequenceTrigger()
/*     */   {
/* 176 */     for (int j = this.finishedTriggerTagCount; j > 0; j--) {
/* 177 */       int sequence_no = this.finishedTriggerTagSequenceNo[j];
/* 178 */       int event_no = this.finishedTriggerTagEventNo[j];
/*     */       
/*     */ 
/* 181 */       if (Integer.valueOf(this.targetTriggerTagArray[sequence_no][0]).intValue() > event_no)
/*     */       {
/* 183 */         boolean match = false;
/* 184 */         int i = 0;
/* 185 */         while ((!match) && (i < TriggeredSwitchableBehaviorListCount))
/*     */         {
/*     */ 
/* 188 */           if ((this.targetTriggerTagArray[sequence_no][(event_no + 1)].equals(TriggeredSwitchableBehaviorList[i].externalTriggerTag)) && 
/* 189 */             (TriggeredSwitchableBehaviorList[i] != null)) {
/* 190 */             TriggeredSwitchableBehaviorList[i].ExternalTrigger(
/* 191 */               this, sequence_no, event_no + 1);
/*     */           }
/*     */           
/* 194 */           i++;
/*     */         }
/*     */       }
/*     */     }
/*     */     
/* 199 */     this.finishedTriggerTagCount = 0;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public synchronized void registerFinishedTriggerTag(int sequence_no, int event_no)
/*     */   {
/* 208 */     this.finishedTriggerTagCount += 1;
/* 209 */     this.finishedTriggerTagSequenceNo[this.finishedTriggerTagCount] = sequence_no;
/* 210 */     this.finishedTriggerTagEventNo[this.finishedTriggerTagCount] = event_no;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean handle(FrameEvent e)
/*     */   {
/* 218 */     if ((this.enabled) && 
/* 219 */       (this.finishedTriggerTagCount > 0)) {
/* 220 */       activateSequenceTrigger();
/*     */     }
/*     */     
/* 223 */     return true;
/*     */   }
/*     */   
/*     */   public boolean handle(MouseDownEvent e)
/*     */   {
/* 228 */     if ((this.enabled) && 
/* 229 */       (this.trigger.equals("click"))) {
/* 230 */       activateTrigger();
/*     */     }
/*     */     
/*     */ 
/* 234 */     return true;
/*     */   }
/*     */   
/*     */   public boolean handle(BumpEventTemp e)
/*     */   {
/* 239 */     if ((this.enabled) && 
/* 240 */       (this.trigger.equals("bump"))) {
/* 241 */       activateTrigger();
/*     */     }
/*     */     
/* 244 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 253 */     Object ret = null;
/* 254 */     switch (index - offset) {
/*     */     case 0: 
/* 256 */       if (mode == 0) {
/* 257 */         ret = StringPropertyEditor.make(
/* 258 */           new Property(this, index, "Trigger"));
/* 259 */       } else if (mode == 1) {
/* 260 */         ret = new String(this.trigger);
/* 261 */       } else if (mode == 2) {
/* 262 */         this.trigger = ((String)value).toString().trim();
/*     */       }
/* 264 */       break;
/*     */     case 1: 
/* 266 */       if (mode == 0) {
/* 267 */         ret = StringPropertyEditor.make(
/* 268 */           new Property(this, index, "Target Trigger Tag"));
/* 269 */       } else if (mode == 1) {
/* 270 */         ret = new String(this.targetTriggerTag);
/* 271 */       } else if (mode == 2) {
/* 272 */         this.targetTriggerTag = ((String)value).toString().trim();
/* 273 */         preprocessTargetTriggerTag(this.targetTriggerTag);
/*     */       }
/* 275 */       break;
/*     */     default: 
/* 277 */       ret = super.properties(index, offset + 2, mode, value);
/*     */     }
/* 279 */     return ret;
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/* 284 */     return 
/* 285 */       super.toString() + "[enabled " + this.enabled + ", trigger " + this.trigger + ", targetTriggerTag " + this.targetTriggerTag + "]";
/*     */   }
/*     */   
/*     */   public void saveState(Saver s)
/*     */     throws IOException
/*     */   {
/* 291 */     s.saveString(this.trigger);
/* 292 */     s.saveString(this.targetTriggerTag);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r)
/*     */     throws IOException
/*     */   {
/* 298 */     this.trigger = r.restoreString();
/* 299 */     this.targetTriggerTag = r.restoreString();
/* 300 */     preprocessTargetTriggerTag(this.targetTriggerTag);
/*     */   }
/*     */   
/*     */   public void postRestore(int version)
/*     */   {
/* 305 */     String name = getName();
/* 306 */     String arg1 = name == null ? "<null>" : name;
/* 307 */     SuperRoot owner = getOwner();
/* 308 */     String oname = "";
/* 309 */     if (owner != null) {
/* 310 */       oname = owner.getName();
/*     */     }
/* 312 */     String arg2 = oname == null ? "<null>" : oname;
/* 313 */     Object[] arguments = { new String(arg1), new String(arg2) };
/* 314 */     Console.println(MessageFormat.format(
/* 315 */       Console.message("Trigger-obs"), arguments));
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Trigger.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */