RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
MobAnimation.java
1package com.osroyale.game.world.entity.mob;
2
3import com.osroyale.game.world.entity.mob.npc.definition.NpcDefinition;
4
5import java.util.EnumSet;
6
41
42public class MobAnimation {
43
44 public static final int PLAYER_STAND = 808;
45 public static final int PLAYER_WALK = 819;
46 public static final int PLAYER_TURN_180 = 820;
47 public static final int PLAYER_TURN_90_CW = 821;
48 public static final int PLAYER_TURN_90_CCW = 822;
49 public static final int PLAYER_TURN = 823;
50 public static final int PLAYER_RUN = 824;
51
52 private int stand;
53 private int turn;
54 private int walk;
55 private int turn180;
56 private int turn90CW;
57 private int turn90CCW;
58 private int run;
59 private final EnumSet<UpdateFlag> updateFlags;
60
61 MobAnimation(EnumSet<UpdateFlag> updateFlags) {
62 this.updateFlags = updateFlags;
63 }
64
65 public void set(int stand, int turn, int walk, int turn180, int turn90cw, int turn90ccw, int run) {
66 this.stand = stand;
67 this.turn = turn;
68 this.walk = walk;
69 this.turn180 = turn180;
70 this.turn90CW = turn90cw;
71 this.turn90CCW = turn90ccw;
72 this.run = run;
73 updateFlags.add(UpdateFlag.APPEARANCE);
74 }
75
76 public void reset() {
77 this.stand = PLAYER_STAND;
78 this.turn = PLAYER_TURN;
79 this.walk = PLAYER_WALK;
80 this.turn180 = PLAYER_TURN_180;
81 this.turn90CW = PLAYER_TURN_90_CW;
82 this.turn90CCW = PLAYER_TURN_90_CCW;
83 this.run = PLAYER_RUN;
84 updateFlags.add(UpdateFlag.APPEARANCE);
85 }
86
87 public void setNpcAnimations(NpcDefinition definition) {
88 this.stand = definition.getStand();
89 this.walk = definition.getWalk();
90 this.turn180 = definition.getTurn180();
91 this.turn90CW = definition.getTurn90CW();
92 this.turn90CCW = definition.getTurn90CCW();
93 updateFlags.add(UpdateFlag.APPEARANCE);
94 }
95
96 public int getStand() {
97 return stand;
98 }
99
100 public int getTurn() {
101 return turn;
102 }
103
104 public int getWalk() {
105 return walk;
106 }
107
108 public int getTurn180() {
109 return turn180 <= 0 || turn180 == PLAYER_TURN_180 ? getWalk() : turn180;
110 }
111
112 public int getTurn90CW() {
113 return turn90CW <= 0 || turn90CW == PLAYER_TURN_90_CW ? getWalk() : turn90CW;
114 }
115
116 public int getTurn90CCW() {
117 return turn90CCW <= 0 || turn90CCW == PLAYER_TURN_90_CCW ? getWalk() : turn90CCW;
118 }
119
120 public int getRun() {
121 return run;
122 }
123
124 public void setStand(int stand) {
125 if (this.stand != stand)
126 updateFlags.add(UpdateFlag.APPEARANCE);
127 this.stand = stand;
128 }
129
130 public void setTurn(int turn) {
131 if (this.turn != turn)
132 updateFlags.add(UpdateFlag.APPEARANCE);
133 this.turn = turn;
134 }
135
136 public void setWalk(int walk) {
137 if (this.walk != walk)
138 updateFlags.add(UpdateFlag.APPEARANCE);
139 this.walk = walk;
140 }
141
142 public void setTurn180(int turn180) {
143 if (this.turn180 != turn180)
144 updateFlags.add(UpdateFlag.APPEARANCE);
145 this.turn180 = turn180;
146 }
147
148 public void setTurn90CW(int turn90cw) {
149 if (turn90CW != turn90cw)
150 updateFlags.add(UpdateFlag.APPEARANCE);
151 turn90CW = turn90cw;
152 }
153
154 public void setTurn90CCW(int turn90ccw) {
155 if (turn90CCW != turn90ccw)
156 updateFlags.add(UpdateFlag.APPEARANCE);
157 turn90CCW = turn90ccw;
158 }
159
160 public void setRun(int run) {
161 if (this.run != run)
162 updateFlags.add(UpdateFlag.APPEARANCE);
163 this.run = run;
164 }
165
166 public MobAnimation copy() {
167 MobAnimation other = new MobAnimation(updateFlags);
168 other.stand = stand;
169 other.turn = turn;
170 other.walk = walk;
171 other.turn180 = turn180;
172 other.turn90CW = turn90CW;
173 other.turn90CCW = turn90CCW;
174 other.run = run;
175 return other;
176 }
177}