|
@@ -3,6 +3,10 @@ import random
|
3
|
3
|
import time
|
4
|
4
|
import typing
|
5
|
5
|
|
|
6
|
+from synergine2.simulation import Event
|
|
7
|
+from synergine2.simulation import disable_when
|
|
8
|
+from synergine2.simulation import config_value
|
|
9
|
+
|
6
|
10
|
from opencombat.const import COLLECTION_ALIVE
|
7
|
11
|
from opencombat.simulation.base import AliveSubjectBehaviour
|
8
|
12
|
from opencombat.simulation.event import NoLongerVisibleOpponent
|
|
@@ -10,45 +14,6 @@ from opencombat.simulation.event import FireEvent
|
10
|
14
|
from opencombat.simulation.event import DieEvent
|
11
|
15
|
from opencombat.simulation.event import NewVisibleOpponent
|
12
|
16
|
from opencombat.simulation.mechanism import OpponentVisibleMechanism
|
13
|
|
-from opencombat.user_action import UserAction
|
14
|
|
-from synergine2.simulation import Event
|
15
|
|
-# from synergine2_xyz.move.simulation import MoveToBehaviour as BaseMoveToBehaviour
|
16
|
|
-#
|
17
|
|
-#
|
18
|
|
-# class MoveToBehaviour(BaseMoveToBehaviour):
|
19
|
|
-# def is_terminated(self) -> bool:
|
20
|
|
-# return COLLECTION_ALIVE not in self.subject.collections
|
21
|
|
-#
|
22
|
|
-# def _can_move_to_next_step(self, move_to_data: dict) -> bool:
|
23
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE:
|
24
|
|
-# return time.time() - move_to_data['last_intention_time'] >= \
|
25
|
|
-# self.subject.walk_duration
|
26
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE_FAST:
|
27
|
|
-# return time.time() - move_to_data['last_intention_time'] >= \
|
28
|
|
-# self.subject.run_duration
|
29
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE_CRAWL:
|
30
|
|
-# return time.time() - move_to_data['last_intention_time'] >= \
|
31
|
|
-# self.subject.crawl_duration
|
32
|
|
-#
|
33
|
|
-# raise NotImplementedError(
|
34
|
|
-# 'Gui action {} unknown'.format(move_to_data['gui_action'])
|
35
|
|
-# )
|
36
|
|
-#
|
37
|
|
-# # FIXME remove this func when code with new move
|
38
|
|
-# def get_move_duration(self, move_to_data: dict) -> float:
|
39
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE:
|
40
|
|
-# return self.subject.walk_duration
|
41
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE_FAST:
|
42
|
|
-# return self.subject.run_duration
|
43
|
|
-# if move_to_data['gui_action'] == UserAction.ORDER_MOVE_CRAWL:
|
44
|
|
-# return self.subject.crawl_duration
|
45
|
|
-#
|
46
|
|
-# raise NotImplementedError(
|
47
|
|
-# 'Gui action {} unknown'.format(move_to_data['gui_action'])
|
48
|
|
-# )
|
49
|
|
-#
|
50
|
|
-# def finalize_event(self, move_to_data: dict, event: Event) -> None:
|
51
|
|
-# event.move_duration = self.get_move_duration(move_to_data)
|
52
|
17
|
|
53
|
18
|
|
54
|
19
|
class LookAroundBehaviour(AliveSubjectBehaviour):
|
|
@@ -86,6 +51,7 @@ class LookAroundBehaviour(AliveSubjectBehaviour):
|
86
|
51
|
|
87
|
52
|
return new_visible_subject_events + no_longer_visible_subject_events
|
88
|
53
|
|
|
54
|
+ @disable_when(config_value('_runtime.placement_mode'))
|
89
|
55
|
def run(self, data):
|
90
|
56
|
visible_subjects = data[self.visible_mechanism]['visible_subjects']
|
91
|
57
|
visible_subject_ids = [s.id for s in visible_subjects]
|
|
@@ -106,7 +72,6 @@ class LookAroundBehaviour(AliveSubjectBehaviour):
|
106
|
72
|
}
|
107
|
73
|
|
108
|
74
|
|
109
|
|
-@disable_when(config_value('_runtime.placement_mode'))
|
110
|
75
|
class EngageOpponent(AliveSubjectBehaviour):
|
111
|
76
|
visible_mechanism = OpponentVisibleMechanism
|
112
|
77
|
use = [visible_mechanism]
|
|
@@ -141,6 +106,7 @@ class EngageOpponent(AliveSubjectBehaviour):
|
141
|
106
|
|
142
|
107
|
return events
|
143
|
108
|
|
|
109
|
+ @disable_when(config_value('_runtime.placement_mode'))
|
144
|
110
|
def run(self, data):
|
145
|
111
|
visible_subjects = data[self.visible_mechanism]['visible_subjects']
|
146
|
112
|
if not visible_subjects:
|