T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic class RadiusProximity<T extends com.badlogic.gdx.math.Vector<T>> extends ProximityBase<T>
RadiusProximity elaborates any agents contained in the specified list that are within the radius of the owner.
Note that this implementation checks the AI time of the current frame through the GdxAI.getTimepiece().getTime() method in order to calculate neighbors only once per frame (assuming delta time is always
greater than 0, if time has changed the frame has changed too). This means that
update the timepiece on each frame the proximity instance will be
calculated only the very first time, which is not what you want of course.Proximity.findNeighbors(ProximityCallback)
method.Proximity.ProximityCallback<T extends com.badlogic.gdx.math.Vector<T>>| Modifier and Type | Field and Description |
|---|---|
protected float |
radius
The radius of this proximity.
|
agents, owner| Constructor and Description |
|---|
RadiusProximity(Steerable<T> owner,
java.lang.Iterable<? extends Steerable<T>> agents,
float radius)
Creates a
RadiusProximity for the specified owner, agents and radius. |
| Modifier and Type | Method and Description |
|---|---|
int |
findNeighbors(Proximity.ProximityCallback<T> callback)
Finds the agents that are within the immediate area of the owner.
|
float |
getRadius()
Returns the radius of this proximity.
|
void |
setRadius(float radius)
Sets the radius of this proximity.
|
getAgents, getOwner, setAgents, setOwnerpublic float getRadius()
public void setRadius(float radius)
public int findNeighbors(Proximity.ProximityCallback<T> callback)
ProximityreportNeighbor method of the specified callback.