/
Navigator.java
148 lines (126 loc) · 4.25 KB
/
Navigator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package net.citizensnpcs.api.ai;
import java.util.function.Function;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.ai.event.CancelReason;
import net.citizensnpcs.api.npc.NPC;
/**
* Represents the pathfinding AI of an {@link NPC}. The navigator can path towards a single target at a time.
*/
public interface Navigator {
/**
* Cancels any running navigation towards a target.
*/
void cancelNavigation();
/**
* Cancels any running navigation towards a target with a specific {@link CancelReason}.
*/
void cancelNavigation(CancelReason reason);
/**
* Returns the {@link NavigatorParameters} local to this navigator. These parameters are copied to local target
* parameters when a new target is started.
*
* @see #getLocalParameters()
* @return The default parameters
*/
NavigatorParameters getDefaultParameters();
/**
* Returns the current {@link EntityTarget} of the navigator, if any. May return null.
*
* @return The current entity target
*/
EntityTarget getEntityTarget();
/**
* Returns the {@link NavigatorParameters} local to any current target execution. These are updated independently of
* the default parameters.
*
* @see #getDefaultParameters()
* @return The local parameters
*/
NavigatorParameters getLocalParameters();
/**
* @return The {@link NPC} attached to this navigator
*/
NPC getNPC();
/**
*
* @return The current {@link PathStrategy} or null if the navigator is not pathfinding
*/
PathStrategy getPathStrategy();
/**
* Returns the current {@link Location} being navigated towards - this is not necessarily permanent and may change,
* for example when pathing towards a moving {@link Entity}. May return null.
*
* @return The target location
*/
Location getTargetAsLocation();
/**
* @return The current {@link TargetType} of the navigator
*/
TargetType getTargetType();
/**
* @see #getTargetType()
* @return Whether the navigator is currently pathing towards a target.
*/
boolean isNavigating();
/**
* @return Whether the navigator is currently paused
*/
boolean isPaused();
/**
* Sets whether the navigator is paused and shouldn't process the path for now.
*
* @param paused
* Whether the navigator should be paused or not
*/
void setPaused(boolean paused);
/**
* Sets the current navigation to an entity target. The NPC will walk towards them in a straight line without
* pathfinding.
*
* @param target
* The {@link Entity} to walk towards
* @param aggressive
* Whether to attack the target when close enough
*/
void setStraightLineTarget(Entity target, boolean aggressive);
/**
* Sets the current navigation to a {@link Location} destination. The NPC will walk straight towards it without
* pathfinding.
*
* @param target
* The destination
*/
void setStraightLineTarget(Location target);
/**
* Sets the current navigation to an entity target.
*
* @param target
* The {@link Entity} to path towards
* @param aggressive
* Whether to attack the target when close enough
*/
void setTarget(Entity target, boolean aggressive);
/**
* Sets the current navigation to the specified strategy.
*
* @param strategy
*/
void setTarget(Function<NavigatorParameters, PathStrategy> strategy);
/**
* Sets the current navigation using a list of {@link Vector}s which will be moved between sequentially using the
* Citizens movement logic <em>without</em> pathfinding.
*
* @param path
* The path
*/
void setTarget(Iterable<Vector> path);
/**
* Sets the current navigation to a {@link Location} destination.
*
* @param target
* The destination
*/
void setTarget(Location target);
}