summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/AnimateAction.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/AnimateAction.java
downloadworlds.jar-main.tar.xz
worlds.jar-main.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/AnimateAction.java')
-rw-r--r--NET/worlds/scape/AnimateAction.java262
1 files changed, 262 insertions, 0 deletions
diff --git a/NET/worlds/scape/AnimateAction.java b/NET/worlds/scape/AnimateAction.java
new file mode 100644
index 0000000..a7dc951
--- /dev/null
+++ b/NET/worlds/scape/AnimateAction.java
@@ -0,0 +1,262 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.core.Std;
+/* */ import java.io.IOException;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class AnimateAction
+/* */ extends Action
+/* */ {
+/* */ int startTime;
+/* 33 */ public int cycleTime = 1000;
+/* */
+/* */
+/* 36 */ public String frameList = "";
+/* */
+/* 38 */ protected int frameListCount = 0;
+/* */
+/* */
+/* */
+/* 42 */ protected Material[] frameMaterialArray = null;
+/* */
+/* 44 */ public int cycles = 0;
+/* 45 */ public boolean infiniteLoop = false;
+/* */
+/* */ protected int cycleNo;
+/* */ protected int currentFrameNo;
+/* 49 */ private boolean running = false;
+/* */
+/* */ public AnimateAction() {
+/* 52 */ startAnimation();
+/* */ }
+/* */
+/* */ public void startAnimation() {
+/* 56 */ this.cycleNo = 0;
+/* 57 */ this.currentFrameNo = -1;
+/* 58 */ this.startTime = Std.getRealTime();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void preprocessFrameList(String frameList)
+/* */ {
+/* 69 */ this.frameMaterialArray = AnimatingDoor.namesToMaterialArray(this,
+/* 70 */ frameList);
+/* 71 */ this.frameListCount = (this.frameMaterialArray == null ? 0 :
+/* 72 */ this.frameMaterialArray.length);
+/* */ }
+/* */
+/* */
+/* */
+/* */ public void detach()
+/* */ {
+/* 79 */ if (this.frameMaterialArray != null) {
+/* 80 */ int i = this.frameMaterialArray.length;
+/* 81 */ do { this.frameMaterialArray[i].setKeepLoaded(false);i--;
+/* 80 */ } while (i >= 0);
+/* */
+/* 82 */ this.frameMaterialArray = null;
+/* 83 */ this.frameListCount = 0;
+/* */ }
+/* 85 */ super.detach();
+/* */ }
+/* */
+/* */
+/* */ public Persister trigger(Event e, Persister seqID)
+/* */ {
+/* 91 */ Object owner = getOwner();
+/* 92 */ if (!(owner instanceof Animatable)) {
+/* 93 */ this.frameMaterialArray = null;
+/* 94 */ this.frameListCount = 0;
+/* 95 */ return null;
+/* */ }
+/* */
+/* 98 */ Animatable o = (Animatable)owner;
+/* */
+/* */
+/* */
+/* 102 */ if (!o.hasClump()) {
+/* 103 */ this.frameMaterialArray = null;
+/* 104 */ this.frameListCount = 0;
+/* 105 */ return seqID;
+/* */ }
+/* */
+/* */
+/* 109 */ if (this.frameMaterialArray == null) {
+/* 110 */ preprocessFrameList(this.frameList);
+/* */ }
+/* */
+/* 113 */ if (seqID == null)
+/* */ {
+/* 115 */ if ((this.running) && (!this.infiniteLoop)) {
+/* 116 */ return null;
+/* */ }
+/* 118 */ startAnimation();
+/* */ }
+/* */
+/* 121 */ int nextFrameNo = 0;
+/* 122 */ if ((this.frameListCount == 0) || (this.cycleTime <= 0)) {
+/* 123 */ this.cycleNo = 1000000000;
+/* */ } else {
+/* 125 */ int runTime = Std.getRealTime() - this.startTime;
+/* 126 */ long frameNo = this.frameListCount * runTime / this.cycleTime;
+/* 127 */ this.cycleNo = ((int)(frameNo / this.frameListCount));
+/* 128 */ nextFrameNo = (int)(frameNo - this.cycleNo * this.frameListCount);
+/* */ }
+/* */
+/* 131 */ if ((this.cycleNo >= this.cycles) && (!this.infiniteLoop)) {
+/* 132 */ nextFrameNo = this.frameListCount - 1;
+/* 133 */ this.running = false;
+/* */ } else {
+/* 135 */ this.running = true;
+/* */ }
+/* 137 */ if (nextFrameNo != this.currentFrameNo) {
+/* 138 */ this.currentFrameNo = nextFrameNo;
+/* 139 */ if ((o.hasClump()) && (this.currentFrameNo >= 0)) {
+/* 140 */ o.setMaterial(this.frameMaterialArray[this.currentFrameNo]);
+/* */ }
+/* */ }
+/* */
+/* 144 */ return this.running ? this : null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 154 */ Object ret = null;
+/* 155 */ switch (index - offset) {
+/* */ case 0:
+/* 157 */ if (mode == 0) {
+/* 158 */ ret = IntegerPropertyEditor.make(
+/* 159 */ new Property(this, index, "Cycle Time"));
+/* 160 */ } else if (mode == 1) {
+/* 161 */ ret = new Integer(this.cycleTime);
+/* 162 */ } else if (mode == 2)
+/* 163 */ this.cycleTime = ((Integer)value).intValue();
+/* 164 */ break;
+/* */ case 1:
+/* 166 */ if (mode == 0) {
+/* 167 */ ret = IntegerPropertyEditor.make(
+/* 168 */ new Property(this, index, "Cycles"));
+/* 169 */ } else if (mode == 1) {
+/* 170 */ ret = new Integer(this.cycles);
+/* 171 */ } else if (mode == 2)
+/* 172 */ this.cycles = ((Integer)value).intValue();
+/* 173 */ break;
+/* */ case 2:
+/* 175 */ if (mode == 0) {
+/* 176 */ ret = BooleanPropertyEditor.make(
+/* 177 */ new Property(this, index, "Infinite Loop"),
+/* 178 */ "False", "True");
+/* 179 */ } else if (mode == 1) {
+/* 180 */ ret = new Boolean(this.infiniteLoop);
+/* 181 */ } else if (mode == 2) {
+/* 182 */ this.infiniteLoop = ((Boolean)value).booleanValue();
+/* */ }
+/* 184 */ break;
+/* */ case 3:
+/* 186 */ if (mode == 0) {
+/* 187 */ ret = StringPropertyEditor.make(
+/* 188 */ new Property(this, index, "Frame List"));
+/* 189 */ } else if (mode == 1) {
+/* 190 */ ret = new String(this.frameList);
+/* 191 */ } else if (mode == 2) {
+/* 192 */ this.frameList = ((String)value).toString().trim().toLowerCase();
+/* 193 */ preprocessFrameList(this.frameList);
+/* */ }
+/* 195 */ break;
+/* */ default:
+/* 197 */ ret = super.properties(index, offset + 4, mode, value);
+/* */ }
+/* 199 */ return ret;
+/* */ }
+/* */
+/* */ public String toString() {
+/* 203 */ String ret = super.toString() +
+/* 204 */ "[cycleTime " + this.cycleTime + ", cycles " + this.cycles + ",";
+/* 205 */ if (!this.infiniteLoop)
+/* 206 */ ret = ret + " not ";
+/* 207 */ ret = ret + "Infinite ]";
+/* */
+/* 209 */ return ret;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* 215 */ private static Object classCookie = new Object();
+/* */
+/* */ public void saveState(Saver s) throws IOException {
+/* 218 */ s.saveVersion(3, classCookie);
+/* 219 */ super.saveState(s);
+/* 220 */ s.saveBoolean(this.infiniteLoop);
+/* 221 */ s.saveInt(this.cycleTime);
+/* 222 */ s.saveInt(this.cycles);
+/* 223 */ s.saveString(this.frameList);
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r) throws IOException, TooNewException {
+/* 227 */ switch (r.restoreVersion(classCookie)) {
+/* */ case 3:
+/* 229 */ super.restoreState(r);
+/* 230 */ this.infiniteLoop = r.restoreBoolean();
+/* 231 */ this.cycleTime = r.restoreInt();
+/* 232 */ this.cycles = r.restoreInt();
+/* 233 */ this.frameList = r.restoreString();
+/* 234 */ break;
+/* */ case 2:
+/* 236 */ super.restoreState(r);
+/* 237 */ this.cycleTime = r.restoreInt();
+/* 238 */ this.cycles = r.restoreInt();
+/* 239 */ this.infiniteLoop = (this.cycles == 0);
+/* 240 */ this.frameList = r.restoreString();
+/* 241 */ break;
+/* */ case 1:
+/* 243 */ super.restoreState(r);
+/* */ case 0:
+/* 245 */ this.cycleTime = ((int)r.restoreFloat());
+/* 246 */ this.cycles = r.restoreInt();
+/* 247 */ this.infiniteLoop = (this.cycles == 0);
+/* 248 */ this.frameList = r.restoreString();
+/* 249 */ break;
+/* */ default:
+/* 251 */ throw new TooNewException();
+/* */ }
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\AnimateAction.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file