summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Trigger.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/Trigger.java')
-rw-r--r--NET/worlds/scape/Trigger.java323
1 files changed, 323 insertions, 0 deletions
diff --git a/NET/worlds/scape/Trigger.java b/NET/worlds/scape/Trigger.java
new file mode 100644
index 0000000..69772b7
--- /dev/null
+++ b/NET/worlds/scape/Trigger.java
@@ -0,0 +1,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
+ */ \ No newline at end of file