RuneHive-Game
Loading...
Searching...
No Matches
Interactable.java
Go to the documentation of this file.
1package com.runehive.game.world;
2
3import com.runehive.game.world.position.Position;
4
5/**
6 * An object implementing {@code Interactable} has uses.
7 *
8 * @author Michael | Chex
9 */
10public interface Interactable {
11
12 /** @return the current location */
14
15 /** @return the x coordinate of the {@link #getPosition()} */
16 default int getX() {
17 return getPosition().getX();
18 }
19
20 /** @return the y coordinate of the {@link #getPosition()} */
21 default int getY() {
22 return getPosition().getY();
23 }
24
25 /** @return the z coordinate of the {@link #getPosition()} */
26 default int getHeight() {
27 return getPosition().getHeight();
28 }
29
30 /** @return the width */
31 int width();
32
33 /** @return the length */
34 int length();
35
36 /**
37 * Creates a new instance of an {@link Interactable}.
38 *
39 * @param position the position.
40 * @return a new instance
41 */
43 return new Interactable() {
44 @Override
45 public Position getPosition() {
46 return position;
47 }
48
49 @Override
50 public int width() {
51 return 1;
52 }
53
54 @Override
55 public int length() {
56 return 1;
57 }
58 };
59 }
60
61 /**
62 * Creates a new instance of an {@link Interactable}.
63 *
64 * @param position the position.
65 * @param width the width
66 * @param length the length
67 * @return a new instance
68 */
70 return new Interactable() {
71 @Override
72 public Position getPosition() {
73 return position;
74 }
75
76 @Override
77 public int width() {
78 return width;
79 }
80
81 @Override
82 public int length() {
83 return length;
84 }
85 };
86 }
87
88}
Represents a single tile on the game world.
Definition Position.java:14
int getHeight()
Gets the height coordinate, or height.
Definition Position.java:51
int getY()
Gets the absolute y coordinate.
Definition Position.java:46
int getX()
Gets the absolute x coordinate.
Definition Position.java:41
An object implementing Interactable has uses.
static Interactable create(Position position)
Creates a new instance of an Interactable.
static Interactable create(Position position, int width, int length)
Creates a new instance of an Interactable.