-
Notifications
You must be signed in to change notification settings - Fork 0
/
SteeringPresets.java
62 lines (48 loc) · 2.26 KB
/
SteeringPresets.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
package com.kjellvos.aletho.zombieshooter.gdx.pathfinding;
import com.badlogic.gdx.ai.steer.behaviors.*;
import com.badlogic.gdx.ai.steer.utils.Path;
import com.badlogic.gdx.ai.steer.utils.paths.LinePath;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.kjellvos.aletho.zombieshooter.gdx.ashley.components.SteeringComponent;
public class SteeringPresets {
public static Wander<Vector2> getWander(SteeringComponent scom){
Wander<Vector2> wander = new Wander<Vector2>(scom)
.setWanderRate(1000F)
.setWanderOffset(-1.6F)
.setWanderRadius(3.2F);
return wander;
}
public static Seek<Vector2> getSeek(SteeringComponent seeker, SteeringComponent target){
Seek<Vector2> seek = new Seek<Vector2>(seeker,target);
return seek;
}
public static Seek<Vector2> getSeek(SteeringComponent seeker, SeekablePoint target){
Seek<Vector2> seek = new Seek<Vector2>(seeker,target);
return seek;
}
public static Flee<Vector2> getFlee(SteeringComponent runner, SteeringComponent fleeingFrom){
Flee<Vector2> seek = new Flee<Vector2>(runner,fleeingFrom);
return seek;
}
public static Arrive<Vector2> getArrive(SteeringComponent runner, SteeringComponent target){
Arrive<Vector2> arrive = new Arrive<Vector2>(runner, target)
.setTimeToTarget(0.01F) // default 0.1f
.setArrivalTolerance(0.0001F) //
.setDecelerationRadius(1F);
return arrive;
}
public static Arrive<Vector2> getArrive(SteeringComponent runner, SeekablePoint target){
Arrive<Vector2> arrive = new Arrive<Vector2>(runner, target)
.setTimeToTarget(1F) // default 0.1f
.setArrivalTolerance(0.1F) //
.setDecelerationRadius(4F);
return arrive;
}
public static FollowPath<Vector2, LinePath.LinePathParam> getFollowPath(SteeringComponent steer, Path<Vector2, LinePath.LinePathParam> path ) {
FollowPath<Vector2, LinePath.LinePathParam> followPath = new FollowPath<Vector2, LinePath.LinePathParam>(steer, path)
.setDecelerationRadius(1F)
.setArriveEnabled(true);
return followPath;
}
}