Browse Source

die states and col removes

Bastien Sevajol 9 years ago
parent
commit
22db7b7291

+ 2 - 18
intelligine/synergy/Simulation.py View File

@@ -1,33 +1,17 @@
1 1
 from synergine.synergy.Simulation import Simulation as BaseSimulation
2
-from synergine_xyz.cst import POSITION, POSITIONS
3
-#from intelligine.synergy.event.attack.NearAttackableAction import NearAttackableAction
2
+from synergine_xyz.cst import POSITIONS
4 3
 from intelligine.synergy.event.transport.PutableAction import PutableAction
5 4
 from intelligine.synergy.event.transport.TakeableAction import TakeableAction
6
-from intelligine.synergy.event.move.MoveAction import MoveAction
7
-from intelligine.synergy.event.CycleAction import CycleAction
8
-from intelligine.cst import COL_TRANSPORTER_CARRYING, COL_TRANSPORTER_NOT_CARRYING, COL_TRANSPORTER, \
9
-    COL_WALKER, ACTION_DIE, COL_ALIVE, ALIVE, ATTACKABLE
5
+from intelligine.cst import COL_TRANSPORTER_CARRYING, COL_TRANSPORTER_NOT_CARRYING
10 6
 
11 7
 
12 8
 class Simulation(BaseSimulation):
13 9
 
14
-    @staticmethod
15
-    def event_bug_die(bug, context):
16
-        context.metas.collections.remove_list(bug.get_id(),
17
-                                              [COL_TRANSPORTER, \
18
-                                               COL_TRANSPORTER_CARRYING, \
19
-                                               COL_TRANSPORTER_NOT_CARRYING, \
20
-                                               COL_WALKER, \
21
-                                               COL_ALIVE],
22
-                                              allow_not_in=True)
23
-        context.metas.states.remove_list(bug.get_id(), [ALIVE, ATTACKABLE], allow_not_in=True)
24
-
25 10
     def connect_actions_signals(self, Signals):
26 11
         Signals.signal(PutableAction).connect(lambda obj, context: \
27 12
             context.metas.collections.add_remove(obj.get_id(), COL_TRANSPORTER_NOT_CARRYING, COL_TRANSPORTER_CARRYING))
28 13
         Signals.signal(TakeableAction).connect(lambda obj, context: \
29 14
             context.metas.collections.add_remove(obj.get_id(), COL_TRANSPORTER_CARRYING, COL_TRANSPORTER_NOT_CARRYING))
30
-        Signals.signal(ACTION_DIE).connect(lambda obj, context: self.event_bug_die(obj, context))
31 15
 
32 16
     def end_cycle(self, context):
33 17
         if context.get_cycle() % 100 is 0:

+ 5 - 6
intelligine/synergy/object/BaseBug.py View File

@@ -19,6 +19,11 @@ class BaseBug(Transportable):
19 19
         self._parts = {}
20 20
         self._init_parts()
21 21
 
22
+    def die(self):
23
+        self._remove_state(ALIVE)
24
+        self._remove_state(ATTACKABLE)
25
+        self._remove_col(COL_ALIVE)
26
+
22 27
     def _init_parts(self):
23 28
         for body_part_name in self._body_parts:
24 29
             self._set_body_part(body_part_name, self._body_parts[body_part_name](self, self._context))
@@ -49,9 +54,3 @@ class BaseBug(Transportable):
49 54
 
50 55
     def get_brain(self):
51 56
         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)

+ 2 - 3
intelligine/synergy/object/Bug.py View File

@@ -11,6 +11,5 @@ class Bug(BaseBug):
11 11
 
12 12
     def die(self):
13 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)
14
+        self._remove_state(WALKER)
15
+        self._remove_col(COL_WALKER)

+ 3 - 1
intelligine/synergy/object/ant/Ant.py View File

@@ -1,7 +1,8 @@
1 1
 from intelligine.core.exceptions import PheromoneException
2 2
 from intelligine.synergy.object.Bug import Bug
3 3
 from intelligine.cst import CARRYING, TRANSPORTER, ATTACKER, COL_TRANSPORTER, COL_TRANSPORTER_NOT_CARRYING, \
4
-    COL_FIGHTER, MOVE_MODE_EXPLO, MOVE_MODE_GOHOME, CARRIED, BODY_PART_PHEROMONE_GLAND, TYPE, TYPE_ANT
4
+    COL_FIGHTER, MOVE_MODE_EXPLO, MOVE_MODE_GOHOME, CARRIED, BODY_PART_PHEROMONE_GLAND, TYPE, TYPE_ANT, \
5
+    COL_TRANSPORTER_CARRYING
5 6
 from intelligine.synergy.object.Food import Food
6 7
 from intelligine.simulation.object.pheromone.MovementPheromoneGland import MovementPheromoneGland
7 8
 from intelligine.simulation.object.brain.AntBrain import AntBrain
@@ -29,6 +30,7 @@ class Ant(Bug):
29 30
         self._remove_state(ATTACKER)
30 31
         self._remove_col(COL_TRANSPORTER)
31 32
         self._remove_col(COL_TRANSPORTER_NOT_CARRYING)
33
+        self._remove_col(COL_TRANSPORTER_CARRYING, allow_not_in=True)
32 34
         self._remove_col(COL_FIGHTER)
33 35
 
34 36
     def _get_brain_instance(self):