1package com.runehive.game.world.region;
3import com.runehive.game.world.entity.mob.npc.Npc;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.ground.GroundItem;
6import com.runehive.game.world.object.CustomGameObject;
7import com.runehive.game.world.object.GameObject;
8import com.runehive.game.world.position.Position;
9import com.runehive.net.packet.out.SendAddObject;
10import com.runehive.net.packet.out.SendGroundItem;
11import com.runehive.net.packet.out.SendRemoveObject;
14import java.util.concurrent.ConcurrentHashMap;
15import java.util.concurrent.ConcurrentLinkedDeque;
17import static com.runehive.game.world.region.Region.SIZE;
30 private Deque<Player>
players =
new ConcurrentLinkedDeque<>();
33 private Deque<Npc>
npcs =
new ConcurrentLinkedDeque<>();
36 private Map<Position, List<GameObject>>
objects;
75 if (item.isRegistered() && item.item.matchesId(
id)) {
104 List<GameObject> objs =
getObjects().getOrDefault(
object.getPosition(),
new LinkedList<>());
105 if (objs.add(
object))
111 List<GameObject> objs =
getObjects().get(
object.getPosition());
121 if (other.getIndex() + 1 > index) {
122 index = other.getIndex() + 1;
134 if (
items.isEmpty()) {
143 return npcs.contains(npc);
148 return players.contains(player);
153 List<GameObject> objs =
getObjects().get(
object.getPosition());
154 return objs !=
null && objs.contains(
object);
160 return objs !=
null && !objs.isEmpty();
165 if (
object.getId() ==
id) {
174 for (Map.Entry<
Position, List<GameObject>> entry : entrySet) {
182 System.err.println(
"haha we got it " + obj.
getId());
198 for (Map.Entry<
Position, List<GameObject>> entry : entrySet) {
216 for (
GroundItem groundItem : entry.getValue()) {
217 if (!groundItem.isRegistered())
220 if (!groundItem.canSee(player))
236 objects =
new ConcurrentHashMap<>();
242 skipped =
new ConcurrentLinkedDeque<>();
256 flags =
new int[SIZE * SIZE];
257 return flags[x + y * SIZE];
270 flags =
new int[SIZE * SIZE];
271 flags[x + y * SIZE] |= flag;
284 flags =
new int[SIZE * SIZE];
285 flags[x + y * SIZE] &= ~flag;
boolean isValid()
Validates this npc based on its current region and registered state.
Represents a non-player character in the in-game world.
This class represents a character controlled by a player.
void send(OutgoingPacket encoder)
Represents a single Ground item on the world map.
Represents a static game object loaded from the map fs.
Represents a single tile on the game world.
Represents a single region.
int[] flags
The clipping flags within the region.
boolean containsPlayer(Player player)
void removePlayer(Player player)
Removes a player from this block.
GameObject getCustomObject(int id, Position position)
void addPlayer(Player player)
Adds a player to this block.
Map< Position, List< GameObject > > getObjects()
Deque< GameObject > skipped
A list of removed objects in this region.
void removeGroundItem(GroundItem item)
Adds a ground item to this block.
void skip(GameObject gameObject)
void removeNpc(Npc npc)
Removes an npc from this block.
Deque< GameObject > getRemovedObjects()
Collection< Npc > getNpcs()
boolean containsNpc(Npc npc)
void removeObject(GameObject object)
Removes an object from this block.
Set< GroundItem > getGroundItems(Position position)
Gets a Set of GroundItems.
GameObject getGameObject(int id, Position position)
void unsetFlags(int x, int y, int flag)
Gets a single tile in this region from the specified height, x and y coordinates.
boolean containsObject(Position position)
Map< Position, List< GameObject > > objects
A list of objects in this region.
List< GameObject > getGameObjects(Position position)
void addObject(GameObject object)
Adds an object to this block.
GroundItem getGroundItem(int id, Position position)
The method that retrieves the item with id on position.
void addNpc(Npc npc)
Adds an npc to this block.
void sendGameObjects(Player player)
void sendGroundItems(Player player)
The method which handles updating when the specified player enters a new region.
Deque< Npc > npcs
A list of npcs in this region.
void addGroundItem(GroundItem item)
Adds a ground item to this block.
void setFlags(int x, int y, int flag)
Gets a single tile in this region from the specified height, x and y coordinates.
Map< Position, Set< GroundItem > > getGroundItems()
Collection< Player > getPlayers()
Map< Position, Set< GroundItem > > groundItems
A list of ground items in this region.
int getFlags(int x, int y)
Gets a single tile in this region from the specified height, x and y coordinates.
boolean containsObject(GameObject object)
Deque< Player > players
A list of players in this region.
Represents a game object.
default int getId()
Gets the object id.