51 public static final int DEFAULT_INSTANCE = 0;
56 private boolean registered;
57 private boolean visible;
59 private Region currentRegion;
60 public int instance = DEFAULT_INSTANCE;
66 public Entity(
Position position,
boolean visible) {
67 setPosition(position);
73 public int getIndex() {
81 public Position getCenterPosition() {
99 public final boolean isRegistered() {
103 public boolean isVisible() {
107 public Region getRegion() {
108 return currentRegion;
112 return position.getX();
116 return position.getY();
120 return position.getHeight();
123 public void setIndex(
int index) {
127 public void setWidth(
int width) {
131 public void setLength(
int length) {
135 protected void setRegistered(
boolean registered) {
136 this.registered = registered;
139 public void setVisible(
boolean visible) {
140 this.visible = visible;
143 public void setPosition(Position position) {
144 Region region = position.getRegion();
146 if (!registered || (region == currentRegion && position.getHeight() ==
getHeight())) {
147 this.position = position;
151 if (currentRegion !=
null) {
155 this.position = position;
159 public void setX(
int x) {
163 public void setY(
int y) {
167 public void setZ(
int z) {
168 position =
new Position(
getX(),
getY(), z);
171 public boolean is(EntityType type) {
182 setRegistered(
false);
192 return isRegistered() && currentRegion !=
null;
216 public void onStep() {
235 public abstract boolean equals(Object obj);
238 public abstract int hashCode();
241 public String toString() {
242 return String.format(
"Entity[registered=%s, visible=%s, position=%s, type=%s", isRegistered(), isVisible(),
getPosition(),
getType());