RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
AnimationDefinition.java
1package com.osroyale.fs.cache.decoder;
2
3import io.netty.buffer.ByteBuf;
4
38
39public final class AnimationDefinition {
40
41 public final int id;
42
43 public int length;
44 public int[] primary;
45 public int secondary[];
46 public int[] duration;
47 public int padding;
48 public int interleaveOrder[];
49 public boolean allowsRotation;
50 public int priority;
51 public int shield;
52 public int weapon;
53 public int resetCycle;
54 public int runFlag;
55 public int walkFlag;
56 public int type;
57
58 public AnimationDefinition(final int id) {
59 this.id = id;
60
61 padding = -1;
62 allowsRotation = false;
63 priority = 5;
64 shield = -1;
65 weapon = -1;
66 resetCycle = 99;
67 runFlag = -1;
68 walkFlag = -1;
69 type = 1;
70 }
71
72 public void decode(ByteBuf buffer) {
73 while(true) {
74 final int opcode = buffer.readUnsignedByte();
75
76 if (opcode == 0) {
77 break;
78 } else if (opcode == 1) {
79 length = buffer.readUnsignedShort();
80 primary = new int[length];
81 secondary = new int[length];
82 duration = new int[length];
83
84 for (int i = 0; i < length; i++) {
85 duration[i] = buffer.readUnsignedShort();
86 }
87
88 for (int i = 0; i < length; i++) {
89 primary[i] = buffer.readUnsignedShort();
90 secondary[i] = -1;
91 }
92
93 for (int i = 0; i < length; i++) {
94 primary[i] += buffer.readUnsignedShort() << 16;
95 }
96 } else if (opcode == 2) {
97 padding = buffer.readUnsignedShort();
98 } else if (opcode == 3) {
99 int len = buffer.readUnsignedByte();
100 interleaveOrder = new int[len + 1];
101 for (int i = 0; i < len; i++) {
102 interleaveOrder[i] = buffer.readUnsignedByte();
103 }
104 interleaveOrder[len] = 9999999;
105 } else if (opcode == 4) {
106 allowsRotation = true;
107 } else if (opcode == 5) {
108 priority = buffer.readUnsignedByte();
109 } else if (opcode == 6) {
110 shield = buffer.readUnsignedShort();
111 } else if (opcode == 7) {
112 weapon = buffer.readUnsignedShort();
113 } else if (opcode == 8) {
114 resetCycle = buffer.readUnsignedByte();
115 } else if (opcode == 9) {
116 runFlag = buffer.readUnsignedByte();
117 } else if (opcode == 10) {
118 walkFlag = buffer.readUnsignedByte();
119 } else if (opcode == 11) {
120 type = buffer.readUnsignedByte();
121 } else if (opcode == 12) {
122 int len = buffer.readUnsignedByte();
123
124 for (int i = 0; i < len; i++) {
125 buffer.readUnsignedShort();
126 }
127
128 for (int i = 0; i < len; i++) {
129 buffer.readUnsignedShort();
130 }
131 } else if (opcode == 13) {
132 int len = buffer.readUnsignedByte();
133 for (int i = 0; i < len; i++) {
134 buffer.readUnsignedMedium();
135 }
136 } else if (opcode == 14) {
137 buffer.readUnsignedInt();
138 } else if (opcode == 15) {
139 int len = buffer.readUnsignedShort();
140
141 for (int index = 0; index < len; ++index) {
142 buffer.readUnsignedShort();
143 buffer.readUnsignedMedium();
144 }
145 } else if (opcode == 16) {
146 buffer.readUnsignedShort();
147 buffer.readUnsignedShort();
148 } else if (opcode == 17) {
149
150 int len = buffer.readUnsignedByte();
151 for (int i = 0; i < len; ++i) {
152 buffer.readUnsignedByte();
153 }
154 }
155 }
156 if (length == 0) {
157 length = 1;
158 primary = new int[1];
159 primary[0] = -1;
160 secondary = new int[1];
161 secondary[0] = -1;
162 duration = new int[1];
163 duration[0] = -1;
164 }
165
166 if (runFlag == -1) {
167 runFlag = (interleaveOrder == null) ? 0 : 2;
168 }
169
170 if (priority == -1) {
171 priority = (interleaveOrder == null) ? 0 : 2;
172 }
173
174 durationTime = calculateDuration();
175 }
176
177 public int durationTime = 0;
178
179 private int calculateDuration() {
180 int duration = 0;
181 if (this.duration == null) {
182 return 0;
183 }
184 for (final int i : this.duration) {
185 /*if (i < 0 || i > 30) {
186 continue;
187 }*/
188 duration += Math.abs(i) * 20;
189 }
190 return duration;
191 }
192
193}