RuneHive-Game
Loading...
Searching...
No Matches
GameObjectDefinition.java
Go to the documentation of this file.
1
package
com.runehive.game.world.object;
2
3
/**
4
* Represents a single type of object.
5
*
6
* @author Graham Edgecombe
7
*/
8
public
class
GameObjectDefinition
{
9
10
/** The maximum number of object definitions */
11
public
static
final
int
MAX_DEFINITIONS
= 47501;
12
13
/** The definitions array. */
14
public
static
final
GameObjectDefinition
[]
definitions
=
new
GameObjectDefinition
[
MAX_DEFINITIONS
];
15
16
/**
17
* Adds a definition. TODO better way?
18
*
19
* @param def
20
* The definition.
21
*/
22
23
24
public
static
void
addDefinition
(
GameObjectDefinition
def) {
25
definitions
[def.getId()] = def;
26
}
27
28
/**
29
* Gets an object definition by its id.
30
*
31
* @param id
32
* The id.
33
* @return The definition.
34
*/
35
public
static
GameObjectDefinition
forId
(
int
id
) {
36
if
(
id < 0 || id >
=
definitions
.length) {
37
return
null
;
38
}
39
return
definitions
[
id
];
40
}
41
42
/** The id. */
43
private
int
id
;
44
45
/** The name. */
46
private
String
name
;
47
48
/** The description. */
49
private
String
desc
;
50
51
/** X size. */
52
private
int
width
;
53
54
/** Y size. */
55
private
int
length
;
56
/**
57
* Custom distance check
58
*/
59
private
int
distance
= 1;
60
61
/** Solid flag. */
62
private
boolean
solid
;
63
64
/** Walkable flag. */
65
private
boolean
impenetrable
;
66
67
/** 'Has actions' flag. */
68
private
boolean
hasActions
;
69
70
/** The wall flag, {@code false} by default. */
71
private
final
boolean
wall
;
72
73
/** The decoration flag, {@code false} by default. */
74
private
final
boolean
decoration
;
75
76
private
final
int
walkingFlag
;
77
78
/** Creates the definition. */
79
public
GameObjectDefinition
(
int
id
, String
name
, String
desc
,
int
width
,
int
length
,
int
distance
,
boolean
solid
,
boolean
impenetrable
,
boolean
hasActions
,
boolean
wall
,
boolean
decoration
,
int
walkingFlag
) {
80
this.id =
id
;
81
this.name =
name
;
82
this.desc =
desc
;
83
this.width =
width
;
84
this.length =
length
;
85
this.distance =
distance
;
86
this.solid =
solid
;
87
this.impenetrable =
impenetrable
;
88
this.hasActions =
hasActions
;
89
this.wall =
wall
;
90
this.decoration =
decoration
;
91
this.walkingFlag =
walkingFlag
;
92
}
93
94
/** @return The id. */
95
public
int
getId
() {
96
return
this.id;
97
}
98
99
/** @return The name. */
100
public
String
getName
() {
101
return
name
;
102
}
103
104
/** @return The description. */
105
public
String
getDescription
() {
106
return
desc
;
107
}
108
109
/** @return The x size. */
110
public
int
getWidth
() {
111
return
width
;
112
}
113
114
/** @return The y size. */
115
public
int
getLength
() {
116
return
length
;
117
}
118
119
public
int
getDistance
() {
120
return
distance
;
121
}
122
123
/** @return The solid flag. */
124
public
boolean
isSolid
() {
125
return
solid
;
126
}
127
128
/** @return The impenetrable flag. */
129
public
boolean
isImpenetrable
() {
130
return
impenetrable
;
131
}
132
133
/** @return A flag indicating that this object has some actions. */
134
public
boolean
hasActions
() {
135
return
hasActions
;
136
}
137
138
public
boolean
isWall
() {
139
return
wall
;
140
}
141
142
public
boolean
isDecoration
() {
143
return
decoration
;
144
}
145
146
public
int
getWalkingFlag
() {
147
return
walkingFlag
;
148
}
149
150
@Override
151
public
String
toString
() {
152
return
String.format(
"[id=%s, name=%s, width=%s, length=%s, distance=%s, wall=%s, impenetrable=%s, solid=%s"
,
id
,
name
,
width
,
length
,
distance
,
wall
,
impenetrable
,
solid
);
153
}
154
}
com.runehive.game.world.object.GameObjectDefinition.getId
int getId()
Definition
GameObjectDefinition.java:95
com.runehive.game.world.object.GameObjectDefinition.getDistance
int getDistance()
Definition
GameObjectDefinition.java:119
com.runehive.game.world.object.GameObjectDefinition.isWall
boolean isWall()
Definition
GameObjectDefinition.java:138
com.runehive.game.world.object.GameObjectDefinition.solid
boolean solid
Solid flag.
Definition
GameObjectDefinition.java:62
com.runehive.game.world.object.GameObjectDefinition.width
int width
X size.
Definition
GameObjectDefinition.java:52
com.runehive.game.world.object.GameObjectDefinition.impenetrable
boolean impenetrable
Walkable flag.
Definition
GameObjectDefinition.java:65
com.runehive.game.world.object.GameObjectDefinition.wall
final boolean wall
The wall flag, false by default.
Definition
GameObjectDefinition.java:71
com.runehive.game.world.object.GameObjectDefinition.isSolid
boolean isSolid()
Definition
GameObjectDefinition.java:124
com.runehive.game.world.object.GameObjectDefinition.hasActions
boolean hasActions()
Definition
GameObjectDefinition.java:134
com.runehive.game.world.object.GameObjectDefinition.hasActions
boolean hasActions
'Has actions' flag.
Definition
GameObjectDefinition.java:68
com.runehive.game.world.object.GameObjectDefinition.getWidth
int getWidth()
Definition
GameObjectDefinition.java:110
com.runehive.game.world.object.GameObjectDefinition.definitions
static final GameObjectDefinition[] definitions
The definitions array.
Definition
GameObjectDefinition.java:14
com.runehive.game.world.object.GameObjectDefinition.desc
String desc
The description.
Definition
GameObjectDefinition.java:49
com.runehive.game.world.object.GameObjectDefinition.toString
String toString()
Definition
GameObjectDefinition.java:151
com.runehive.game.world.object.GameObjectDefinition.getLength
int getLength()
Definition
GameObjectDefinition.java:115
com.runehive.game.world.object.GameObjectDefinition.walkingFlag
final int walkingFlag
Definition
GameObjectDefinition.java:76
com.runehive.game.world.object.GameObjectDefinition.GameObjectDefinition
GameObjectDefinition(int id, String name, String desc, int width, int length, int distance, boolean solid, boolean impenetrable, boolean hasActions, boolean wall, boolean decoration, int walkingFlag)
Creates the definition.
Definition
GameObjectDefinition.java:79
com.runehive.game.world.object.GameObjectDefinition.getDescription
String getDescription()
Definition
GameObjectDefinition.java:105
com.runehive.game.world.object.GameObjectDefinition.getWalkingFlag
int getWalkingFlag()
Definition
GameObjectDefinition.java:146
com.runehive.game.world.object.GameObjectDefinition.getName
String getName()
Definition
GameObjectDefinition.java:100
com.runehive.game.world.object.GameObjectDefinition.MAX_DEFINITIONS
static final int MAX_DEFINITIONS
The maximum number of object definitions.
Definition
GameObjectDefinition.java:11
com.runehive.game.world.object.GameObjectDefinition.addDefinition
static void addDefinition(GameObjectDefinition def)
Adds a definition.
Definition
GameObjectDefinition.java:24
com.runehive.game.world.object.GameObjectDefinition.name
String name
The name.
Definition
GameObjectDefinition.java:46
com.runehive.game.world.object.GameObjectDefinition.length
int length
Y size.
Definition
GameObjectDefinition.java:55
com.runehive.game.world.object.GameObjectDefinition.isImpenetrable
boolean isImpenetrable()
Definition
GameObjectDefinition.java:129
com.runehive.game.world.object.GameObjectDefinition.distance
int distance
Custom distance check.
Definition
GameObjectDefinition.java:59
com.runehive.game.world.object.GameObjectDefinition.id
int id
The id.
Definition
GameObjectDefinition.java:43
com.runehive.game.world.object.GameObjectDefinition.isDecoration
boolean isDecoration()
Definition
GameObjectDefinition.java:142
com.runehive.game.world.object.GameObjectDefinition.forId
static GameObjectDefinition forId(int id)
Gets an object definition by its id.
Definition
GameObjectDefinition.java:35
com.runehive.game.world.object.GameObjectDefinition.decoration
final boolean decoration
The decoration flag, false by default.
Definition
GameObjectDefinition.java:74