|
@@ -1,7 +1,9 @@
|
1
|
1
|
from intelligine.core.exceptions import BodyPartAlreadyExist
|
2
|
2
|
from intelligine.synergy.object.Transportable import Transportable
|
3
|
|
-from intelligine.cst import ALIVE, ATTACKABLE, COL_ALIVE, COLONY
|
|
3
|
+from intelligine.cst import COL_ALIVE, COLONY, ACTION_DIE
|
4
|
4
|
from intelligine.simulation.object.brain.Brain import Brain
|
|
5
|
+from intelligine.cst import ALIVE, ATTACKABLE
|
|
6
|
+from synergine.core.Signals import Signals
|
5
|
7
|
|
6
|
8
|
|
7
|
9
|
class BaseBug(Transportable):
|
|
@@ -14,12 +16,14 @@ class BaseBug(Transportable):
|
14
|
16
|
context.metas.collections.add(self.get_id(), COL_ALIVE)
|
15
|
17
|
context.metas.value.set(COLONY, self.get_id(), collection.get_id())
|
16
|
18
|
self._life_points = 10
|
|
19
|
+ self._alive = True
|
17
|
20
|
self._movements_count = -1
|
18
|
21
|
self._brain = self._get_brain_instance()
|
19
|
22
|
self._parts = {}
|
20
|
23
|
self._init_parts()
|
21
|
24
|
|
22
|
25
|
def die(self):
|
|
26
|
+ self._set_alive(False)
|
23
|
27
|
self._remove_state(ALIVE)
|
24
|
28
|
self._remove_state(ATTACKABLE)
|
25
|
29
|
self._remove_col(COL_ALIVE)
|
|
@@ -38,6 +42,15 @@ class BaseBug(Transportable):
|
38
|
42
|
|
39
|
43
|
def hurted(self, points):
|
40
|
44
|
self._life_points -= points
|
|
45
|
+ if self.get_life_points() <= 0 and self.is_alive():
|
|
46
|
+ self.die()
|
|
47
|
+ Signals.signal(ACTION_DIE).send(obj=self, context=self._context)
|
|
48
|
+
|
|
49
|
+ def is_alive(self):
|
|
50
|
+ return self._alive
|
|
51
|
+
|
|
52
|
+ def _set_alive(self, alive):
|
|
53
|
+ self._alive = bool(alive)
|
41
|
54
|
|
42
|
55
|
def get_life_points(self):
|
43
|
56
|
return self._life_points
|