RuneHive-Game
Loading...
Searching...
No Matches
Animation.java
Go to the documentation of this file.
1package com.runehive.game;
2
3import java.util.Objects;
4
5/**
6 * Class that models a single animation used by an entity.
7 *
8 * @author Michael | Chex
9 */
10public class Animation implements Comparable<Animation> {
11
12 public static final int RESET_ID = 65535;
13 public static final int NORMAL_TELE_ID = 714;
14 public static final int LUNAR_TELE_ID = 1816;
15
19
20
21 /** The animation id. */
22 private final int id;
23
24 /** The delay before playing the animation. */
25 private final int delay;
26
27 /** The animation priority. */
28 private final UpdatePriority priority;
29
30 /**
31 * Creates a new instance of the animation with a hidden delay of 0.
32 *
33 * @param id
34 * The id of the animation being used.
35 */
36 public Animation(int id) {
37 this(id, 0, UpdatePriority.NORMAL);
38 }
39
40 /**
41 * Creates a new instance of the animation with a specified delay.
42 *
43 * @param id
44 * The id of the animation being used.
45 * @param delay
46 * The delay of the animation in seconds.
47 */
48 public Animation(int id, int delay) {
50 }
51
52 /**
53 * Creates a new instance of the animation with a hidden delay of 0.
54 *
55 * @param id
56 * The id of the animation being used.
57 * @param priority
58 * The priority level of the animation.
59 */
61 this(id, 0, priority);
62 }
63
64 /**
65 * Creates a new instance of the animation with a specified delay.
66 *
67 * @param id
68 * The id of the animation being used.
69 * @param delay
70 * The delay of the animation in seconds.
71 * @param priority
72 * The priority level of the animation.
73 */
74 public Animation(int id, int delay, UpdatePriority priority) {
75 this.priority = priority;
76 this.id = id;
77 this.delay = delay;
78 }
79
80 /**
81 * Gets the animation delay.
82 *
83 * @return The delay.
84 */
85 public int getDelay() {
86 return delay;
87 }
88
89 /**
90 * Gets the animation id.
91 *
92 * @return The id.
93 */
94 public int getId() {
95 return id;
96 }
97
98 @Override
99 public int hashCode() {
100 return Objects.hash(id, delay, priority);
101 }
102
103 @Override
104 public boolean equals(Object obj) {
105 if (obj instanceof Animation) {
106 Animation other = (Animation) obj;
107 return id == other.id && delay == other.delay && priority == other.priority;
108 }
109 return obj == this;
110 }
111
112 @Override
113 public int compareTo(Animation other) {
114 if (other == null || other.priority == null) {
115 return 1;
116 }
117
118 return other.priority.compareTo(priority);
119 }
120
121 @Override
122 public String toString() {
123 return String.format("Animation[priority=%s, id=%s, delay=%s]", priority, id, delay);
124 }
125
126 public boolean isReset() {
127 return id == -1 || id == RESET_ID;
128 }
129
130}
final UpdatePriority priority
The animation priority.
int compareTo(Animation other)
final int id
The animation id.
final int delay
The delay before playing the animation.
static final int RESET_ID
static final int NORMAL_TELE_ID
Animation(int id, int delay)
Creates a new instance of the animation with a specified delay.
Animation(int id, UpdatePriority priority)
Creates a new instance of the animation with a hidden delay of 0.
static final Animation LUNAR_TELE
static final Animation NORMAL_TELE
int getId()
Gets the animation id.
static final Animation RESET
Animation(int id)
Creates a new instance of the animation with a hidden delay of 0.
Animation(int id, int delay, UpdatePriority priority)
Creates a new instance of the animation with a specified delay.
static final int LUNAR_TELE_ID
int getDelay()
Gets the animation delay.
boolean equals(Object obj)
Represents different priorities for updating.