|
@@ -11,6 +11,7 @@ from synergine2_cocos2d.actor import Actor
|
11
|
11
|
from synergine2_xyz.exception import UnknownAnimationIndex
|
12
|
12
|
|
13
|
13
|
from opencombat.exception import UnknownWeapon
|
|
14
|
+from opencombat.exception import WrongMode
|
14
|
15
|
from opencombat.exception import UnknownFiringAnimation
|
15
|
16
|
from opencombat.gui.animation import ANIMATION_CRAWL
|
16
|
17
|
from opencombat.gui.animation import ANIMATION_WALK
|
|
@@ -19,6 +20,7 @@ from opencombat.gui.const import MODE_MAN_CRAWLING
|
19
|
20
|
from opencombat.gui.image import TileImageCacheManager
|
20
|
21
|
from opencombat.gui.weapon import RIFFLE
|
21
|
22
|
from opencombat.gui.weapon import WeaponImageApplier
|
|
23
|
+from opencombat.user_action import UserAction
|
22
|
24
|
|
23
|
25
|
if typing.TYPE_CHECKING:
|
24
|
26
|
from opencombat.gui.fire import GuiFiringEvent
|
|
@@ -40,6 +42,7 @@ class BaseActor(Actor):
|
40
|
42
|
]
|
41
|
43
|
weapons_firing_image_scheme = {}
|
42
|
44
|
weapon_image_scheme = {}
|
|
45
|
+ move_for_gui_actions = {}
|
43
|
46
|
|
44
|
47
|
def __init__(
|
45
|
48
|
self,
|
|
@@ -69,10 +72,25 @@ class BaseActor(Actor):
|
69
|
72
|
|
70
|
73
|
@property
|
71
|
74
|
def mode(self) -> str:
|
72
|
|
- # FIXME: When man is moving (crawling for example), must change mode
|
73
|
|
- # and man must stay "crawled"
|
74
|
75
|
return self._mode
|
75
|
76
|
|
|
77
|
+ @mode.setter
|
|
78
|
+ def mode(self, value) -> None:
|
|
79
|
+ if value not in self.get_modes():
|
|
80
|
+ raise WrongMode('Actor "{}" has no mode "{}" ({})'.format(
|
|
81
|
+ self.__class__.__name__,
|
|
82
|
+ value,
|
|
83
|
+ ', '.join(self.get_modes()),
|
|
84
|
+ ))
|
|
85
|
+
|
|
86
|
+ self._mode = value
|
|
87
|
+
|
|
88
|
+ def get_mode_for_gui_action(self, gui_action: str) -> str:
|
|
89
|
+ try:
|
|
90
|
+ return self.move_for_gui_actions[gui_action]
|
|
91
|
+ except KeyError:
|
|
92
|
+ return self.get_default_mode()
|
|
93
|
+
|
76
|
94
|
@property
|
77
|
95
|
def weapons(self) -> typing.List[str]:
|
78
|
96
|
return []
|
|
@@ -199,6 +217,18 @@ class Man(BaseActor):
|
199
|
217
|
'actors/man_weap1_firing3.png',
|
200
|
218
|
],
|
201
|
219
|
},
|
|
220
|
+ MODE_MAN_CRAWLING: {
|
|
221
|
+ RIFFLE: [
|
|
222
|
+ 'actors/man_weap1_firing1.png',
|
|
223
|
+ 'actors/man_weap1_firing2.png',
|
|
224
|
+ 'actors/man_weap1_firing3.png',
|
|
225
|
+ ]
|
|
226
|
+ }
|
|
227
|
+ }
|
|
228
|
+ move_for_gui_actions = {
|
|
229
|
+ UserAction.ORDER_MOVE: MODE_MAN_STAND_UP,
|
|
230
|
+ UserAction.ORDER_MOVE_FAST: MODE_MAN_STAND_UP,
|
|
231
|
+ UserAction.ORDER_MOVE_CRAWL: MODE_MAN_CRAWLING,
|
202
|
232
|
}
|
203
|
233
|
|
204
|
234
|
def __init__(
|