1 package SteeringProperties;
2
3 import SteeringStuff.SteeringType;
4 import XMLSteeringProperties.XMLPeopleAvoidanceProperties;
5
6
7
8
9
10 public class PeopleAvoidanceProperties extends SteeringProperties {
11
12
13
14
15 private int repulsiveForce;
16
17
18
19
20 private int distance;
21
22
23 private boolean circumvention;
24
25
26 private boolean deceleration;
27
28
29 private boolean acceleration;
30
31
32 private double projection;
33
34 public PeopleAvoidanceProperties() {
35 super(SteeringType.PEOPLE_AVOIDANCE);
36 this.repulsiveForce = 200;
37 this.distance = 300;
38 this.circumvention = false;
39 this.deceleration = false;
40 this.acceleration = false;
41 this.projection = 16;
42 }
43
44 public PeopleAvoidanceProperties(BehaviorType behaviorType) {
45 super(SteeringType.PEOPLE_AVOIDANCE, behaviorType);
46 this.repulsiveForce = 200;
47 this.distance = 300;
48 this.circumvention = false;
49 this.deceleration = false;
50 this.acceleration = false;
51 this.projection = 16;
52 setNewBehaviorType(behaviorType);
53 }
54
55 public PeopleAvoidanceProperties(XMLPeopleAvoidanceProperties xml) {
56 super(SteeringType.PEOPLE_AVOIDANCE, xml.active, xml.weight, xml.behavior);
57 this.repulsiveForce = xml.repulsiveForce;
58 this.distance = xml.distance;
59 this.circumvention = xml.circumvention;
60 this.deceleration = xml.deceleration;
61 this.acceleration = xml.acceleration;
62 this.projection = xml.projection;
63 }
64
65 public PeopleAvoidanceProperties(int forceFromOtherPeople, int distanceFromOtherPeople, boolean goRoundPartner, boolean deceleration, boolean acceleration, double visionInTicks) {
66 super(SteeringType.PEOPLE_AVOIDANCE);
67 this.repulsiveForce = forceFromOtherPeople;
68 this.distance = distanceFromOtherPeople;
69 this.circumvention = goRoundPartner;
70 this.deceleration = false;
71 this.acceleration = false;
72 this.projection = visionInTicks;
73 }
74
75 protected void setNewBehaviorType(BehaviorType behaviorType) {
76 if (behaviorType.equals(BehaviorType.BASIC)) {
77 circumvention = false;
78 deceleration = false;
79 acceleration = false;
80 projection = 0;
81 }
82 else if (behaviorType.equals(BehaviorType.ADVANCED)) {
83 circumvention = true;
84 deceleration = true;
85 acceleration = true;
86 projection = 16;
87 }
88 }
89
90 public int getRepulsiveForce() {
91 return repulsiveForce;
92 }
93
94 public void setRepulsiveForce(int orderOfTheForce) {
95 this.repulsiveForce = orderOfTheForce;
96 }
97
98 public int getDistanceFromOtherPeople() {
99 return distance;
100 }
101
102 public void setDistanceFromOtherPeople(int distanceFromOtherPeople) {
103 this.distance = distanceFromOtherPeople;
104 }
105
106 public boolean isCircumvention() {
107 return circumvention;
108 }
109
110 public void setCircumvention(boolean goRoundPartner) {
111 this.circumvention = goRoundPartner;
112 }
113
114
115
116
117
118 public double getProjection() {
119 return projection;
120 }
121
122
123
124
125
126 public void setProjection(double projection) {
127 this.projection = projection;
128 }
129
130 public boolean isAcceleration() {
131 return acceleration;
132 }
133
134 public void setAcceleration(boolean acceleration) {
135 this.acceleration = acceleration;
136 }
137
138 public boolean isDeceleration() {
139 return deceleration;
140 }
141
142 public void setDeceleration(boolean deceleration) {
143 this.deceleration = deceleration;
144 }
145
146 @Override
147 public String getSpecialText() {
148 String text = "";
149 text += " * Repulsive Force: " + repulsiveForce + "\n";
150 text += " * Distance: " + distance + "\n";
151 text += " * Circumvention: " + circumvention + "\n";
152 text += " * Deceleration: " + deceleration + "\n";
153 text += " * Acceleration: " + deceleration + "\n";
154 text += " * Projection: " + projection + "\n";
155 return text;
156 }
157
158 @Override
159 public void setProperties(SteeringProperties newProperties) {
160 this.repulsiveForce = ((PeopleAvoidanceProperties)newProperties).getRepulsiveForce();
161 this.distance = ((PeopleAvoidanceProperties)newProperties).getDistanceFromOtherPeople();
162 this.circumvention = ((PeopleAvoidanceProperties)newProperties).isCircumvention();
163 this.deceleration = ((PeopleAvoidanceProperties)newProperties).isDeceleration();
164 this.acceleration = ((PeopleAvoidanceProperties)newProperties).isAcceleration();
165 this.projection = ((PeopleAvoidanceProperties)newProperties).getProjection();
166 }
167
168 public XMLPeopleAvoidanceProperties getXMLProperties() {
169 XMLPeopleAvoidanceProperties xmlProp = new XMLPeopleAvoidanceProperties();
170 xmlProp.repulsiveForce = repulsiveForce;
171 xmlProp.distance = distance;
172 xmlProp.circumvention = circumvention;
173 xmlProp.deceleration = deceleration;
174 xmlProp.acceleration = acceleration;
175 xmlProp.projection = projection;
176 xmlProp.active = active;
177 xmlProp.weight = weight;
178 xmlProp.behavior = behaviorType;
179 return xmlProp;
180 }
181 }