Browse Source

die consequences: remove states and COL

Bastien Sevajol 9 years ago
parent
commit
7fe1d048b9

+ 1 - 0
intelligine/synergy/event/attack/NearAttackableAction.py View File

@@ -21,4 +21,5 @@ class NearAttackableAction(Action):
21 21
             obj_attackable = synergy_manager.get_map().get_object(obj_id_attackable)
22 22
             obj_attackable.hurted(randint(0, 2))
23 23
             if obj_attackable.get_life_points() <= 0:
24
+                obj_attackable.die()
24 25
                 Signals.signal(ACTION_DIE).send(obj=obj_attackable, context=context)

+ 7 - 1
intelligine/synergy/object/BaseBug.py View File

@@ -48,4 +48,10 @@ class BaseBug(Transportable):
48 48
         return Brain(self._context, self)
49 49
 
50 50
     def get_brain(self):
51
-        return self._brain
51
+        return self._brain
52
+
53
+    def die(self):
54
+        # TODO: Ca peut buger si pas , allow_not_in=True, pk ?
55
+        self._remove_state(ALIVE, allow_not_in=True)
56
+        self._remove_state(ATTACKABLE, allow_not_in=True)
57
+        self._remove_col(COL_ALIVE, allow_not_in=True)

+ 6 - 0
intelligine/synergy/object/Bug.py View File

@@ -8,3 +8,9 @@ class Bug(BaseBug):
8 8
         super().__init__(collection, context)
9 9
         context.metas.states.add(self.get_id(), WALKER)
10 10
         context.metas.collections.add(self.get_id(), COL_WALKER)
11
+
12
+    def die(self):
13
+        super().die()
14
+        # TODO: Ca peut buger si pas , allow_not_in=True, pk ?
15
+        self._remove_state(WALKER, allow_not_in=True)
16
+        self._remove_col(COL_WALKER, allow_not_in=True)