|
@@ -0,0 +1,47 @@
|
|
1
|
+# coding: utf-8
|
|
2
|
+import time
|
|
3
|
+import typing
|
|
4
|
+
|
|
5
|
+from synergine2.config import Config
|
|
6
|
+from synergine2.simulation import SimulationBehaviour
|
|
7
|
+from synergine2.simulation import Simulation
|
|
8
|
+from synergine2.simulation import Event
|
|
9
|
+from synergine2_xyz.move.intention import MoveToIntention
|
|
10
|
+from synergine2_xyz.simulation import XYZSimulation
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+class RequestMoveBehaviour(SimulationBehaviour):
|
|
14
|
+ move_intention_class = MoveToIntention
|
|
15
|
+
|
|
16
|
+ @classmethod
|
|
17
|
+ def merge_data(cls, new_data, start_data=None):
|
|
18
|
+ # TODO: behaviour/Thing dedicated to Gui -> Simulation ?
|
|
19
|
+ pass # This behaviour is designed to be launch by terminal
|
|
20
|
+
|
|
21
|
+ def __init__(
|
|
22
|
+ self,
|
|
23
|
+ config: Config,
|
|
24
|
+ simulation: Simulation,
|
|
25
|
+ ):
|
|
26
|
+ super().__init__(config, simulation)
|
|
27
|
+ self.simulation = typing.cast(XYZSimulation, self.simulation)
|
|
28
|
+
|
|
29
|
+ def run(self, data):
|
|
30
|
+ # TODO: behaviour/Thing dedicated to Gui -> Simulation ?
|
|
31
|
+ pass # This behaviour is designed to be launch by terminal
|
|
32
|
+
|
|
33
|
+ def action(self, data) -> typing.List[Event]:
|
|
34
|
+ subject_id = data['subject_id']
|
|
35
|
+ move_to = data['move_to']
|
|
36
|
+
|
|
37
|
+ try:
|
|
38
|
+ subject = self.simulation.subjects.index[subject_id]
|
|
39
|
+ subject.intentions.set(self.move_intention_class(
|
|
40
|
+ move_to,
|
|
41
|
+ gui_action=data['gui_action'],
|
|
42
|
+ ))
|
|
43
|
+ except KeyError:
|
|
44
|
+ # TODO: log error here
|
|
45
|
+ pass
|
|
46
|
+
|
|
47
|
+ return []
|