RuneHive-Game
Loading...
Searching...
No Matches
RegionDefinition.java
Go to the documentation of this file.
1package com.runehive.game.world.region;
2
3import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
4import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
5
6/**
7 * Represents a single region definition.
8 *
9 * @author Ryley Kimmel <ryley.kimmel@live.com>
10 * @author Artem Batutin <artembatutin@gmail.com>
11 */
12public final class RegionDefinition {
13
14 /** The region definitions. */
15 private final static Int2ObjectMap<RegionDefinition> DEFINITIONS = new Int2ObjectOpenHashMap<>(8192);
16
17 /** The hash of the region coordinates. */
18 private final int hash;
19
20 /** The terrain file id. */
21 private final int terrainFile;
22
23 /** The object file id. */
24 private final int objectFile;
25
26 /**
27 * Constructs a new {@link RegionDefinition} with the specified hash,
28 * terrain file id, object file id and preload state.
29 *
30 * @param hash The hash of the region coordinates.
31 * @param terrainFile The terrain file id.
32 * @param objectFile The object file id.
33 */
35 this.hash = hash;
36 this.terrainFile = terrainFile;
37 this.objectFile = objectFile;
38 }
39
40 /**
41 * Gets a {@link RegionDefinition}.
42 *
43 * @param region region hash to get definition from.
44 * @return region definition
45 */
46 public static RegionDefinition get(int region) {
47 return DEFINITIONS.get(region);
48 }
49
50 /**
51 * Returns the flag if the region exists.
52 *
53 * @param region region hash to check.
54 * @return contains flag.
55 */
56 public static boolean contains(int region) {
57 return DEFINITIONS.containsKey(region);
58 }
59
60 /**
61 * Adds a {@link RegionDefinition}.
62 *
63 * @param definition definition to add.
64 */
65 public static void set(RegionDefinition definition) {
66 DEFINITIONS.put(definition.getHash(), definition);
67 }
68
69 /**
70 * Gets the regional definitions.
71 *
72 * @return region definitions.
73 */
74 public static Int2ObjectMap<RegionDefinition> getDefinitions() {
75 return DEFINITIONS;
76 }
77
78 /**
79 * Returns the coordinate hash.
80 */
81 public int getHash() {
82 return hash;
83 }
84
85 /**
86 * Returns the terrain file id.
87 */
88 public int getTerrainFile() {
89 return terrainFile;
90 }
91
92 /**
93 * Returns the object file id.
94 */
95 public int getObjectFile() {
96 return objectFile;
97 }
98
99}
static boolean contains(int region)
Returns the flag if the region exists.
static final Int2ObjectMap< RegionDefinition > DEFINITIONS
The region definitions.
static Int2ObjectMap< RegionDefinition > getDefinitions()
Gets the regional definitions.
RegionDefinition(int hash, int terrainFile, int objectFile)
Constructs a new RegionDefinition with the specified hash, terrain file id, object file id and preloa...
final int hash
The hash of the region coordinates.
int getTerrainFile()
Returns the terrain file id.
int getObjectFile()
Returns the object file id.