diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/Animation.java | |
| download | worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip | |
Diffstat (limited to 'NET/worlds/scape/Animation.java')
| -rw-r--r-- | NET/worlds/scape/Animation.java | 357 |
1 files changed, 357 insertions, 0 deletions
diff --git a/NET/worlds/scape/Animation.java b/NET/worlds/scape/Animation.java new file mode 100644 index 0000000..bd6c86f --- /dev/null +++ b/NET/worlds/scape/Animation.java @@ -0,0 +1,357 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.network.URL; +/* */ import java.io.IOException; +/* */ import java.net.MalformedURLException; +/* */ import java.text.MessageFormat; +/* */ import java.util.Date; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ class Animation +/* */ extends TriggeredSwitchableBehavior +/* */ implements FrameHandler, Persister, MouseDownHandler, BumpHandler +/* */ { +/* */ long startFrameTime; +/* */ protected float cycleTime; +/* */ protected String frameList; +/* */ protected int cycles; +/* 33 */ protected int cycleNo = 0; +/* */ +/* */ protected String[] frameListArray; +/* */ +/* */ protected Material[] frameMaterialArray; +/* */ +/* */ protected int frameListCount; +/* */ +/* */ protected int currentFrameNo; +/* */ +/* 43 */ protected boolean animationEnd = true; +/* */ +/* */ +/* */ public Animation() +/* */ { +/* 48 */ this.cycleTime = 1000.0F; +/* 49 */ this.frameList = new String(""); +/* 50 */ this.trigger = new String("none"); +/* 51 */ this.externalTriggerTag = new String(""); +/* 52 */ this.cycles = 0; +/* 53 */ this.frameListArray = new String['È']; +/* 54 */ this.frameMaterialArray = new Material['È']; +/* 55 */ this.frameListCount = 0; +/* */ +/* 57 */ startAnimation(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void ExternalTrigger(Trigger trigger_source, int sequence_no, int event_no) +/* */ { +/* 65 */ this.trigger_source = trigger_source; +/* 66 */ this.sequence_no = sequence_no; +/* 67 */ this.event_no = event_no; +/* 68 */ startAnimation(); +/* */ } +/* */ +/* */ +/* */ public void startAnimation() +/* */ { +/* 74 */ Date timer = new Date(); +/* 75 */ this.startFrameTime = timer.getTime(); +/* 76 */ this.cycleNo = 0; +/* 77 */ this.currentFrameNo = 0; +/* 78 */ this.animationEnd = false; +/* */ } +/* */ +/* 81 */ public float getCycleTime() { return this.cycleTime; } +/* 82 */ public void setCycleTime(float t) { this.cycleTime = t; } +/* */ +/* */ public int getNextFrameNo() +/* */ { +/* 86 */ Date timer = new Date(); +/* 87 */ int nextFrameNo = 0; +/* */ +/* 89 */ if (this.frameListCount > 0) { +/* 90 */ nextFrameNo = (int)(this.frameListCount * ( +/* 91 */ (float)(timer.getTime() - this.startFrameTime) % this.cycleTime) / (this.cycleTime + 1.0F) + 1.0F); +/* 92 */ if (this.currentFrameNo > nextFrameNo) { +/* 93 */ this.cycleNo += 1; +/* */ } +/* */ } +/* */ +/* */ +/* 98 */ return nextFrameNo; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void preprocessFrameList(String frameList) +/* */ { +/* 114 */ int currentIndex = 1; +/* 115 */ int currentSeparator = 0;int nextSeparator = 0; +/* 116 */ int lastSeparator = frameList.lastIndexOf(" "); +/* */ +/* 118 */ if ((lastSeparator != -1) || (frameList.length() != 0)) +/* */ { +/* */ +/* */ +/* 122 */ if (lastSeparator == -1) +/* */ { +/* 124 */ this.frameListArray[currentIndex] = frameList; +/* */ } +/* */ else { +/* 127 */ nextSeparator = frameList.indexOf(" "); +/* */ +/* 129 */ this.frameListArray[currentIndex] = frameList.substring(0, +/* 130 */ nextSeparator); +/* 131 */ currentIndex++; +/* */ +/* 133 */ while (nextSeparator != lastSeparator) { +/* 134 */ currentSeparator = nextSeparator; +/* 135 */ nextSeparator = frameList.indexOf(" ", currentSeparator + 1); +/* 136 */ this.frameListArray[currentIndex] = frameList.substring( +/* 137 */ currentSeparator + 1, nextSeparator); +/* 138 */ currentIndex++; +/* */ } +/* */ +/* 141 */ this.frameListArray[currentIndex] = frameList.substring( +/* 142 */ nextSeparator + 1); +/* 143 */ this.frameListCount = currentIndex; +/* */ } +/* */ } +/* */ +/* */ +/* 148 */ for (currentIndex = 1; currentIndex <= this.frameListCount; currentIndex++) { +/* 149 */ String s = this.frameListArray[currentIndex]; +/* */ URL url; +/* */ try { +/* 152 */ url = new URL(this, s); +/* */ } catch (MalformedURLException e) { URL url; +/* 154 */ url = URL.make("error:\"" + s + '"'); +/* */ } +/* 156 */ this.frameMaterialArray[currentIndex] = new Material(url); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean handle(FrameEvent e) +/* */ { +/* 168 */ if (this.enabled) +/* */ { +/* 170 */ if ((e.receiver instanceof Rect)) { +/* 171 */ int nextFrameNo = getNextFrameNo(); +/* 172 */ if ((this.cycleNo < this.cycles) || (this.cycles == 0)) { +/* 173 */ if ((nextFrameNo > 0) && (nextFrameNo != this.currentFrameNo)) { +/* 174 */ this.currentFrameNo = nextFrameNo; +/* 175 */ Rect Wall = (Rect)e.receiver; +/* 176 */ Wall.setMaterial(this.frameMaterialArray[this.currentFrameNo]); +/* */ } +/* */ +/* */ } +/* 180 */ else if (this.currentFrameNo != this.frameListCount) { +/* 181 */ Rect Wall = (Rect)e.receiver; +/* 182 */ Wall.setMaterial(this.frameMaterialArray[this.frameListCount]); +/* 183 */ this.currentFrameNo = this.frameListCount; +/* */ } +/* */ +/* 186 */ if ((this.cycleNo >= this.cycles) && (this.cycles != 0) && (!this.animationEnd)) { +/* 187 */ this.animationEnd = true; +/* 188 */ if (this.trigger_source != null) { +/* 189 */ this.trigger_source.registerFinishedTriggerTag(this.sequence_no, +/* 190 */ this.event_no); +/* */ } +/* */ } +/* */ } +/* */ } +/* 195 */ return true; +/* */ } +/* */ +/* */ public boolean handle(MouseDownEvent e) +/* */ { +/* 200 */ if ((this.enabled) && +/* 201 */ (this.trigger.equals("click"))) { +/* 202 */ startAnimation(); +/* */ } +/* */ +/* 205 */ return true; +/* */ } +/* */ +/* */ public boolean handle(BumpEventTemp e) +/* */ { +/* 210 */ if ((this.enabled) && +/* 211 */ (this.trigger.equals("bump"))) { +/* 212 */ startAnimation(); +/* */ } +/* */ +/* 215 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 224 */ Object ret = null; +/* 225 */ switch (index - offset) { +/* */ case 0: +/* 227 */ if (mode == 0) +/* 228 */ ret = new ClassProperty(this, index, "Animation"); +/* 229 */ break; +/* */ case 1: +/* 231 */ if (mode == 0) { +/* 232 */ ret = FloatPropertyEditor.make( +/* 233 */ new Property(this, index, "Cycle Time")); +/* 234 */ } else if (mode == 1) { +/* 235 */ ret = new Float(this.cycleTime); +/* 236 */ } else if (mode == 2) +/* 237 */ this.cycleTime = ((Float)value).floatValue(); +/* 238 */ break; +/* */ case 2: +/* 240 */ if (mode == 0) { +/* 241 */ ret = IntegerPropertyEditor.make( +/* 242 */ new Property(this, index, "Cycles")); +/* 243 */ } else if (mode == 1) { +/* 244 */ ret = new Integer(this.cycles); +/* 245 */ } else if (mode == 2) +/* 246 */ this.cycles = ((Integer)value).intValue(); +/* 247 */ break; +/* */ case 3: +/* 249 */ if (mode == 0) { +/* 250 */ ret = StringPropertyEditor.make( +/* 251 */ new Property(this, index, "Trigger")); +/* 252 */ } else if (mode == 1) { +/* 253 */ ret = new String(this.trigger); +/* 254 */ } else if (mode == 2) { +/* 255 */ this.trigger = ((String)value).toString().trim(); +/* 256 */ if (this.trigger.equals("external")) { +/* 257 */ Trigger.TriggeredSwitchableBehaviorList[ +/* 258 */ Trigger.TriggeredSwitchableBehaviorListCount] = this; +/* 259 */ Trigger.TriggeredSwitchableBehaviorListCount += 1; +/* */ } +/* */ } +/* */ +/* 263 */ break; +/* */ case 4: +/* 265 */ if (mode == 0) { +/* 266 */ ret = StringPropertyEditor.make( +/* 267 */ new Property(this, index, "External Trigger Tag")); +/* 268 */ } else if (mode == 1) { +/* 269 */ ret = new String(this.externalTriggerTag); +/* 270 */ } else if (mode == 2) { +/* 271 */ this.externalTriggerTag = ((String)value).toString().trim(); +/* */ } +/* 273 */ break; +/* */ case 5: +/* 275 */ if (mode == 0) { +/* 276 */ ret = StringPropertyEditor.make( +/* 277 */ new Property(this, index, "Frame List")); +/* 278 */ } else if (mode == 1) { +/* 279 */ ret = new String(this.frameList); +/* 280 */ } else if (mode == 2) { +/* 281 */ this.frameList = ((String)value).toString().trim().toLowerCase(); +/* 282 */ preprocessFrameList(this.frameList); +/* */ } +/* 284 */ break; +/* */ default: +/* 286 */ ret = super.properties(index, offset + 6, mode, value); +/* */ } +/* 288 */ if (mode == 2) +/* */ { +/* 290 */ if (this.trigger.equals("none")) { +/* 291 */ startAnimation(); +/* */ } +/* */ } +/* 294 */ return ret; +/* */ } +/* */ +/* */ public String toString() +/* */ { +/* 299 */ return +/* */ +/* */ +/* 302 */ "Animation: cycleTime " + this.cycleTime + ", cycles " + this.cycles + ", enabled " + this.enabled + ", trigger " + this.trigger + ", externalTriggerTag " + this.externalTriggerTag + ", frameList " + this.frameList; +/* */ } +/* */ +/* */ public void saveState(Saver s) +/* */ throws IOException +/* */ { +/* 308 */ s.saveFloat(this.cycleTime); +/* 309 */ s.saveInt(this.cycles); +/* 310 */ s.saveString(this.trigger); +/* 311 */ s.saveString(this.externalTriggerTag); +/* 312 */ s.saveString(this.frameList); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) +/* */ throws IOException +/* */ { +/* 318 */ this.cycleTime = r.restoreFloat(); +/* 319 */ this.cycles = r.restoreInt(); +/* 320 */ this.trigger = r.restoreString(); +/* 321 */ if (this.trigger.equals("external")) { +/* 322 */ Trigger.TriggeredSwitchableBehaviorList[ +/* 323 */ Trigger.TriggeredSwitchableBehaviorListCount] = this; +/* 324 */ Trigger.TriggeredSwitchableBehaviorListCount += 1; +/* */ } +/* 326 */ this.externalTriggerTag = r.restoreString(); +/* 327 */ if (!this.trigger.equals("none")) { +/* 328 */ this.cycleNo = this.cycles; +/* */ } else { +/* 330 */ startAnimation(); +/* */ } +/* 332 */ this.frameList = r.restoreString(); +/* 333 */ preprocessFrameList(this.frameList); +/* */ } +/* */ +/* */ +/* */ public void postRestore(int version) +/* */ { +/* 339 */ String name = getName(); +/* 340 */ String arg1 = name == null ? "<null>" : name; +/* 341 */ SuperRoot owner = getOwner(); +/* 342 */ String oname = ""; +/* 343 */ if (owner != null) { +/* 344 */ oname = owner.getName(); +/* */ } +/* 346 */ String arg2 = oname == null ? "<null>" : oname; +/* 347 */ Object[] arguments = { new String(arg1), new String(arg2) }; +/* 348 */ Console.println(MessageFormat.format( +/* 349 */ Console.message("Animation-obs"), arguments)); +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Animation.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |