RuneHive-Game
Loading...
Searching...
No Matches
Graphic.java
Go to the documentation of this file.
1package com.runehive.game;
2
3import java.util.Objects;
4
5/**
6 * Represents a single graphic that can be used by entities. Also known as GFX.
7 *
8 * @author Michael | Chex
9 */
10public final class Graphic implements Comparable<Graphic> {
11
12 public static final int HIGH_HEIGHT = 0x640000;
13
14 public static final int NORMAL_ID = 308;
15 public static final int LUNAR_ID = 747;
16 public static final int RESET_ID = 0xFFFF;
17 public static final Graphic RESET = new Graphic(RESET_ID, UpdatePriority.VERY_LOW);
20
21 /** The graphic id. */
22 private final int id;
23
24 /** The delay of this graphic. */
25 private final int delay;
26
27 /** The height of this graphic. */
28 private final int height;
29
30 /** The priority of the graphic. */
31 private final UpdatePriority priority;
32
33 /**
34 * Constructs a new {@code Graphic} object with no delay, a low height, and
35 * normal priotiry.
36 *
37 * @param id
38 * The graphic id.
39 */
40 public Graphic(int id) {
41 this(id, 0, false);
42 }
43
44 /**
45 * Constructs a new {@code Graphic} object with no delay and normal
46 * priotiry.
47 *
48 * @param id
49 * The graphic id.
50 *
51 * @param high
52 * The graphic height state.
53 */
54 public Graphic(int id, boolean high) {
55 this(id, 0, high);
56 }
57
58 /**
59 * Constructs a new {@code Graphic} object with a low height and normal
60 * priotiry.
61 *
62 * @param id
63 * The graphic id.
64 *
65 * @param delay
66 * The graphic delay.
67 */
68 public Graphic(int id, int delay) {
69 this(id, delay, false);
70 }
71
72 /**
73 * Constructs a new {@code Graphic} object with a normal priotiry.
74 *
75 * @param id
76 * The graphic id.
77 *
78 * @param delay
79 * The graphic delay.
80 *
81 * @param high
82 * The graphic height state.
83 */
84 public Graphic(int id, int delay, boolean high) {
85 this(id, delay, high, UpdatePriority.NORMAL);
86 }
87
88 /**
89 * Constructs a new {@code Graphic} object with no delay and a low height.
90 *
91 * @param id
92 * The graphic id.
93 * @param priority
94 * The graphic priority.
95 */
97 this(id, 0, false, priority);
98 }
99
100 /**
101 * Constructs a new {@code Graphic} object with no delay.
102 *
103 * @param id
104 * The graphic id.
105 *
106 * @param high
107 * The graphic height state.
108 * @param priority
109 * The graphic priority.
110 */
111 public Graphic(int id, boolean high, UpdatePriority priority) {
112 this(id, 0, high, priority);
113 }
114
115 /**
116 * Constructs a new {@code Graphic} object with a low height.
117 *
118 * @param id
119 * The graphic id.
120 *
121 * @param delay
122 * The graphic delay.
123 * @param priority
124 * The graphic priority.
125 */
126 public Graphic(int id, int delay, UpdatePriority priority) {
127 this(id, delay, false, priority);
128 }
129
130 /**
131 * Constructs a new {@code Graphic} object.
132 *
133 * @param id
134 * The graphic id.
135 *
136 * @param delay
137 * The graphic delay.
138 *
139 * @param high
140 * The graphic height state.
141 * @param priority
142 * The graphic priority.
143 */
144 public Graphic(int id, int delay, boolean high, UpdatePriority priority) {
145 this(id, delay, high ? HIGH_HEIGHT : 0, priority);
146 }
147
148 public Graphic(int id, int delay, int height, UpdatePriority priority) {
149 this.id = id;
150 this.delay = delay;
151 this.height = height;
152 this.priority = priority;
153 }
154
155 public Graphic(int id, int delay, int height) {
156 this.id = id;
157 this.delay = delay;
158 this.height = height;
159 this.priority = UpdatePriority.NORMAL;
160 }
161
162 /**
163 * Gets the delay of this graphic.
164 *
165 * @return delay
166 */
167 public int getDelay() {
168 return delay;
169 }
170
171 /**
172 * Gets the height of this graphic.
173 *
174 * @return height
175 */
176 public int getHeight() {
177 return height;
178 }
179
180 /**
181 * Gets the id of this graphic.
182 *
183 * @return id
184 */
185 public int getId() {
186 return id;
187 }
188
189 @Override
190 public int hashCode() {
191 return Objects.hash(id, delay, height, priority);
192 }
193
194 @Override
195 public boolean equals(Object obj) {
196 if (obj instanceof Graphic) {
197 Graphic other = (Graphic) obj;
198 return id == other.id && height == other.height && delay == other.delay && priority == other.priority;
199 }
200 return obj == this;
201 }
202
203 @Override
204 public int compareTo(Graphic other) {
205 return other.priority.ordinal() - priority.ordinal();
206 }
207
208 @Override
209 public String toString() {
210 return String.format("Graphic[id=%s, delay=%s, height=%s, priority=%s]", id, delay, height, priority);
211 }
212
213}
static final Graphic LUNAR_TELE
Definition Graphic.java:19
Graphic(int id, boolean high, UpdatePriority priority)
Constructs a new Graphic object with no delay.
Definition Graphic.java:111
final int height
The height of this graphic.
Definition Graphic.java:28
Graphic(int id, UpdatePriority priority)
Constructs a new Graphic object with no delay and a low height.
Definition Graphic.java:96
Graphic(int id, int delay, int height, UpdatePriority priority)
Definition Graphic.java:148
Graphic(int id)
Constructs a new Graphic object with no delay, a low height, and normal priotiry.
Definition Graphic.java:40
static final int HIGH_HEIGHT
Definition Graphic.java:12
static final Graphic RESET
Definition Graphic.java:17
final int delay
The delay of this graphic.
Definition Graphic.java:25
int getDelay()
Gets the delay of this graphic.
Definition Graphic.java:167
static final Graphic NORMAL_TELE
Definition Graphic.java:18
static final int RESET_ID
Definition Graphic.java:16
int getId()
Gets the id of this graphic.
Definition Graphic.java:185
int getHeight()
Gets the height of this graphic.
Definition Graphic.java:176
Graphic(int id, int delay, int height)
Definition Graphic.java:155
Graphic(int id, int delay)
Constructs a new Graphic object with a low height and normal priotiry.
Definition Graphic.java:68
static final int NORMAL_ID
Definition Graphic.java:14
Graphic(int id, boolean high)
Constructs a new Graphic object with no delay and normal priotiry.
Definition Graphic.java:54
boolean equals(Object obj)
Definition Graphic.java:195
Graphic(int id, int delay, UpdatePriority priority)
Constructs a new Graphic object with a low height.
Definition Graphic.java:126
int compareTo(Graphic other)
Definition Graphic.java:204
Graphic(int id, int delay, boolean high)
Constructs a new Graphic object with a normal priotiry.
Definition Graphic.java:84
Graphic(int id, int delay, boolean high, UpdatePriority priority)
Constructs a new Graphic object.
Definition Graphic.java:144
final UpdatePriority priority
The priority of the graphic.
Definition Graphic.java:31
final int id
The graphic id.
Definition Graphic.java:22
static final int LUNAR_ID
Definition Graphic.java:15
Represents different priorities for updating.