RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
SquareArea.java
1package com.osroyale.game.world.position.impl;
2
3import com.osroyale.game.world.position.Area;
4import com.osroyale.game.world.position.Position;
5import com.osroyale.util.Utility;
6
43
44public final class SquareArea extends Area {
45
47 private final String name;
48
50 private final int swX;
51
55 private final int swY;
56
60 private final int neX;
61
65 private final int neY;
66
70 private final int height;
71
84 public SquareArea(int swX, int swY, int neX, int neY) {
85 this("Unknown", swX, swY, neX, neY, 0);
86 }
87
103 public SquareArea(String name, int swX, int swY, int neX, int neY) {
104 this(name, swX, swY, neX, neY, 0);
105 }
106
124 public SquareArea(String name, int swX, int swY, int neX, int neY, int height) {
125 this.name = name;
126 this.swX = swX;
127 this.swY = swY;
128 this.neX = neX;
129 this.neY = neY;
130 this.height = height;
131 }
132
136 public String getName() {
137 return name;
138 }
139
143 public int getNeX() {
144 return neX;
145 }
146
150 public int getNeY() {
151 return neY;
152 }
153
157 public int getSwX() {
158 return swX;
159 }
160
164 public int getSwY() {
165 return swY;
166 }
167
171 public int getZ() {
172 return height;
173 }
174
175 @Override
176 public boolean inArea(Position position) {
177 return position.getX() >= swX && position.getX() <= neX && position.getY() >= swY && position.getY() <= neY;
178 }
179
180 @Override
181 public Position getRandomLocation() {
182 final int dx = Math.abs(getNeX() - getSwX()) + 1;
183 final int dy = Math.abs(getNeY() - getSwY()) + 1;
184 return new Position(getSwX() + Utility.random(dx), getSwY() + Utility.random(dy));
185 }
186
187}
SquareArea(int swX, int swY, int neX, int neY)
SquareArea(String name, int swX, int swY, int neX, int neY)
SquareArea(String name, int swX, int swY, int neX, int neY, int height)