|
@@ -94,7 +94,9 @@ class MoveToMechanism(SubjectMechanism):
|
94
|
94
|
}
|
95
|
95
|
|
96
|
96
|
except IndexError: # TODO: Specialize ? No movement left
|
97
|
|
- return None
|
|
97
|
+ return {
|
|
98
|
+ 'finished': True,
|
|
99
|
+ }
|
98
|
100
|
except KeyError: # TODO: Specialize ? No MoveIntention
|
99
|
101
|
return None
|
100
|
102
|
|
|
@@ -156,6 +158,8 @@ class MoveToBehaviour(SubjectBehaviour):
|
156
|
158
|
def run(self, data):
|
157
|
159
|
move_to_data = data[self.move_to_mechanism]
|
158
|
160
|
if move_to_data:
|
|
161
|
+ if move_to_data.get('finished'):
|
|
162
|
+ return move_to_data
|
159
|
163
|
|
160
|
164
|
if self._can_move_to_next_step(move_to_data):
|
161
|
165
|
move_to_data['reach_next'] = True
|
|
@@ -174,11 +178,18 @@ class MoveToBehaviour(SubjectBehaviour):
|
174
|
178
|
return move_to_data['just_reach'] or move_to_data['initial']
|
175
|
179
|
|
176
|
180
|
def action(self, data) -> [Event]:
|
177
|
|
- new_path = data['new_path']
|
178
|
181
|
# TODO: MoveToIntention doit être configurable
|
179
|
|
- move = self.subject.intentions.get(MoveToIntention)
|
180
|
|
- move = typing.cast(MoveToIntention, move)
|
|
182
|
+ try:
|
|
183
|
+ if data.get('finished'):
|
|
184
|
+ self.subject.intentions.remove(MoveToIntention)
|
|
185
|
+ return []
|
|
186
|
+ move = self.subject.intentions.get(MoveToIntention)
|
|
187
|
+ except KeyError: # TODO: Specialize exception
|
|
188
|
+ # Action don't exist anymore
|
|
189
|
+ return []
|
181
|
190
|
|
|
191
|
+ move = typing.cast(MoveToIntention, move)
|
|
192
|
+ new_path = data['new_path']
|
182
|
193
|
if new_path:
|
183
|
194
|
move.path = new_path
|
184
|
195
|
move.path_progression = -1
|