Browse Source

enhance move system

Bastien Sevajol 6 years ago
parent
commit
edb1f45ae6
1 changed files with 8 additions and 0 deletions
  1. 8 0
      synergine2_xyz/move/simulation.py

+ 8 - 0
synergine2_xyz/move/simulation.py View File

@@ -108,6 +108,7 @@ class FinishMoveEvent(Event):
108 108
         from_position: typing.Tuple[int, int],
109 109
         to_position: typing.Tuple[int, int],
110 110
         gui_action: typing.Any,
111
+        move_duration: float=0.0,
111 112
         *args,
112 113
         **kwargs
113 114
     ):
@@ -116,6 +117,7 @@ class FinishMoveEvent(Event):
116 117
         self.from_position = from_position
117 118
         self.to_position = to_position
118 119
         self.gui_action = gui_action
120
+        self.move_duration = move_duration
119 121
 
120 122
     def repr_debug(self) -> str:
121 123
         return '{}: subject_id:{}, from_position:{} to_position: {}'.format(
@@ -133,6 +135,7 @@ class StartMoveEvent(Event):
133 135
         from_position: typing.Tuple[int, int],
134 136
         to_position: typing.Tuple[int, int],
135 137
         gui_action: typing.Any,
138
+        move_duration: float=0.0,
136 139
         *args,
137 140
         **kwargs
138 141
     ):
@@ -141,6 +144,7 @@ class StartMoveEvent(Event):
141 144
         self.from_position = from_position
142 145
         self.to_position = to_position
143 146
         self.gui_action = gui_action
147
+        self.move_duration = move_duration
144 148
 
145 149
     def repr_debug(self) -> str:
146 150
         return '{}: subject_id:{}, from_position:{} to_position: {}'.format(
@@ -177,6 +181,9 @@ class MoveToBehaviour(SubjectBehaviour):
177 181
     def _is_fresh_new_step(self, move_to_data: dict) -> bool:
178 182
         return move_to_data['just_reach'] or move_to_data['initial']
179 183
 
184
+    def finalize_event(self, move_to_data: dict, event: Event) -> None:
185
+        pass
186
+
180 187
     def action(self, data) -> [Event]:
181 188
         # TODO: MoveToIntention doit être configurable
182 189
         try:
@@ -221,5 +228,6 @@ class MoveToBehaviour(SubjectBehaviour):
221 228
         move.initial = False
222 229
         # Note: Need to explicitly set to update shared data
223 230
         self.subject.intentions.set(move)
231
+        self.finalize_event(data, event)
224 232
 
225 233
         return [event]