|
@@ -77,18 +77,20 @@ def find_new_parking(self):
|
77
|
77
|
mark_path(path, self)
|
78
|
78
|
return new_parking, path
|
79
|
79
|
else:
|
|
80
|
+ print('cant find parking for', self)
|
80
|
81
|
self.FSM.FSM.ToTransition('toEnterParallelPark')
|
|
82
|
+
|
81
|
83
|
def get_lane_point(self):
|
82
|
84
|
|
83
|
85
|
|
84
|
86
|
self.point = self.path[self.path_index]
|
85
|
87
|
#print(self.path_index, 'path index')
|
86
|
|
-
|
87
|
|
- v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
|
88
|
|
- tv = v.normalized()
|
89
|
|
- nv = Vector([-tv.y, tv.x, 0]) #rotate 90 degrees
|
90
|
|
- self.last_lane_point = self.lane_point
|
91
|
|
- self.lane_point = self.point + self.manager.lane_position * nv
|
|
88
|
+ if self.point != self.last_lane_point:
|
|
89
|
+ v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
|
|
90
|
+ tv = v.normalized()
|
|
91
|
+ nv = Vector([-tv.y, tv.x, 0]) #rotate 90 degrees
|
|
92
|
+ self.last_lane_point = self.lane_point
|
|
93
|
+ self.lane_point = self.point + self.manager.lane_position * nv
|
92
|
94
|
|
93
|
95
|
|
94
|
96
|
|
|
@@ -124,7 +126,9 @@ def delta_to_vect(self):
|
124
|
126
|
delta_mult = -.1
|
125
|
127
|
mult = 1.0
|
126
|
128
|
deltamove = delta[2] * delta_mult
|
127
|
|
- self.obj.applyMovement([0, deltamove, 0], True)
|
|
129
|
+ #self.obj.applyMovement([0, deltamove, 0], True)
|
|
130
|
+ f = deltamove * 5000
|
|
131
|
+ self.obj.applyForce([0, f, 0], True)
|
128
|
132
|
|
129
|
133
|
|
130
|
134
|
def apply_gas(self):
|
|
@@ -224,19 +228,22 @@ class EnterParallelPark(State):
|
224
|
228
|
self.FSM.owner.obj.applyMovement([0, -6, 0], True)
|
225
|
229
|
self.FSM.owner.target.status = 'in_use'
|
226
|
230
|
self.FSM.owner.obj.worldPosition.z += .9
|
227
|
|
- self.FSM.owner.obj.suspendDynamics()
|
228
|
|
- self.FSM.owner.obj.suspendPhysics()
|
229
|
|
- self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
|
230
|
231
|
self.FSM.owner.active = False
|
231
|
232
|
self.FSM.owner.start_empty = self.FSM.owner.target
|
232
|
|
- self.FSM.owner.last_point = self.FSM.owner.obj.worldPosition
|
233
|
|
- self.FSM.owner.point = self.FSM.owner.obj.worldPosition
|
|
233
|
+ self.FSM.owner.last_point = self.FSM.owner.target.obj.worldPosition.copy()
|
|
234
|
+ self.FSM.owner.last__lane_point = self.FSM.owner.obj.worldPosition
|
|
235
|
+ self.FSM.owner.point = self.FSM.owner.target.obj.worldPosition.copy()
|
|
236
|
+
|
234
|
237
|
clear_markers(self)
|
|
238
|
+
|
|
239
|
+ self.FSM.owner.obj.suspendDynamics()
|
|
240
|
+ self.FSM.owner.obj.suspendPhysics()
|
235
|
241
|
super(EnterParallelPark, self).Enter()
|
236
|
242
|
|
237
|
243
|
def Execute(self):
|
238
|
244
|
self.FSM.stateLife += 1
|
239
|
|
-
|
|
245
|
+ if self.FSM.stateLife == 2:
|
|
246
|
+ self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
|
240
|
247
|
#self.FSM.ToTransition('toActivate')
|
241
|
248
|
|
242
|
249
|
|
|
@@ -266,7 +273,7 @@ class NavigateToTarget(State):
|
266
|
273
|
#print('target', self.FSM.owner.target.obj.worldPosition)
|
267
|
274
|
|
268
|
275
|
#emergency exit
|
269
|
|
- if self.FSM.stateLife > 60 * 90:
|
|
276
|
+ if self.FSM.stateLife > 30 * 60:
|
270
|
277
|
self.FSM.ToTransition('toEnterParallelPark')
|
271
|
278
|
|
272
|
279
|
#print('doing NavigateToTarget')
|