View Javadoc

1   package SteeringProperties;
2   
3   import SteeringStuff.SteeringType;
4   import java.io.Serializable;
5   
6   /**
7    * All the specific steering properties extend this class.
8    * @author Marki
9    */
10  public abstract class SteeringProperties implements Serializable {
11  
12      /**These types are especially for SteeringGui or other similar aplication. They distinguish the type of behavior to show user features of the basic bahavior
13       * (just reimplemented steerings of Craig W. Reynolds), advanced behavior, etc. For other usage of this steering library use the type OWN (which is also default),
14       * which allows to set any values you want.
15       * BASIC type sets the advanced features false, 0 etc. ADVANCED type sets the full behavior with values of atributes best for majority of situations.
16       * OWN doesn't change anything, but the SteeringGui sets all the properties editable.
17       * (Even if the BASIC type is set, it allows you to change and use some advanced features.)*/
18      public enum BehaviorType {BASIC, ADVANCED, OWN};
19  
20      /**The type of the steering.*/
21      protected SteeringType type;
22  
23      /**Whether the steering is active. Steering manager doesn't use this value, but the user can.*/
24      protected boolean active;
25  
26      /**The weight of the steering. The return steering force will be multiplied by this value in the combination of the steerings forces.*/
27      protected double weight;
28  
29      /**The behavior type. Steering manager doesn't use this value, but user can.*/
30      protected BehaviorType behaviorType;
31  
32      public SteeringProperties(SteeringType type) {
33          this.type = type;
34          active = false;
35          weight = 1;
36          behaviorType = BehaviorType.OWN;
37      }
38  
39      public SteeringProperties(SteeringType type, BehaviorType behaviorType) {
40          this.type = type;
41          active = false;
42          weight = 1;
43          this.behaviorType = behaviorType;
44      }
45  
46      public SteeringProperties(SteeringType type, boolean active, double weight) {
47          this.type = type;
48          this.active = active;
49          this.weight = weight;
50          behaviorType = BehaviorType.OWN;
51      }
52  
53      public SteeringProperties(SteeringType type, boolean active, double weight, BehaviorType behaviorType) {
54          this.type = type;
55          this.active = active;
56          this.weight = weight;
57          this.behaviorType = behaviorType;
58      }
59      
60      public SteeringType getType() {
61          return type;
62      }
63  
64      public void setType(SteeringType type) {
65          this.type = type;
66      }
67  
68      public boolean isActive() {
69          return active;
70      }
71  
72      public void setActive(boolean active) {
73          this.active = active;
74      }
75  
76      public double getWeight() {
77          return weight;
78      }
79  
80      public void setWeight(double weight) {
81          this.weight = weight;
82      }
83  
84      public BehaviorType getBehaviorType() {
85          return behaviorType;
86      }
87  
88      public void setBehaviorType(BehaviorType behaviorType) {
89          if (this.behaviorType != behaviorType && behaviorType != BehaviorType.OWN) {
90              setNewBehaviorType(behaviorType);
91          }
92          this.behaviorType = behaviorType;
93      }
94  
95      public String getText() {
96          String text = "* " + type.getName() + "\n";
97          text += "  * Weight: " + weight + "\n";
98          text += getSpecialText();
99          return text;
100     }
101 
102     protected abstract void setNewBehaviorType(BehaviorType behaviorType);
103 
104     public abstract void setProperties(SteeringProperties newProperties);
105 
106     public abstract String getSpecialText();
107 }