Browse Source

Transformed food from food object

Bastien Sevajol 9 years ago
parent
commit
19f6f7a484

+ 7 - 2
intelligine/display/pygame/config.py View File

1
 from intelligine.synergy.Colony import Colony
1
 from intelligine.synergy.Colony import Colony
2
 from intelligine.synergy.Environment import Environment
2
 from intelligine.synergy.Environment import Environment
3
 from intelligine.synergy.Simulation import Simulation
3
 from intelligine.synergy.Simulation import Simulation
4
-from intelligine.synergy.object.StockedFood import StockedFood
5
 from intelligine.synergy.object.Food import Food
4
 from intelligine.synergy.object.Food import Food
6
 from intelligine.synergy.object.Rock import Rock
5
 from intelligine.synergy.object.Rock import Rock
7
 from intelligine.synergy.object.ant.Ant import Ant
6
 from intelligine.synergy.object.ant.Ant import Ant
8
 from intelligine.synergy.object.ant.Egg import Egg
7
 from intelligine.synergy.object.ant.Egg import Egg
9
 
8
 
10
 
9
 
10
+def stocked_food(food):
11
+    food.transform_to_stocked()
12
+
11
 map_config = {
13
 map_config = {
12
     'simulation': {
14
     'simulation': {
13
         'base': Simulation
15
         'base': Simulation
21
         'egg': Egg,
23
         'egg': Egg,
22
         'rock': Rock,
24
         'rock': Rock,
23
         'food': Food,
25
         'food': Food,
24
-        'stocked_food': StockedFood
26
+        'stocked_food': Food
27
+    },
28
+    'callbacks': {
29
+        'stocked_food': [stocked_food]
25
     }
30
     }
26
 }
31
 }

+ 19 - 14
intelligine/sandbox/exploration/map.tmx View File

180
   </tile>
180
   </tile>
181
   <tile id="2">
181
   <tile id="2">
182
    <properties>
182
    <properties>
183
+    <property name="callbacks" value="stocked_food"/>
183
     <property name="object" value="stocked_food"/>
184
     <property name="object" value="stocked_food"/>
184
    </properties>
185
    </properties>
185
   </tile>
186
   </tile>
186
   <tile id="3">
187
   <tile id="3">
187
    <properties>
188
    <properties>
188
     <property name="actions" value="clone(),"/>
189
     <property name="actions" value="clone(),"/>
190
+    <property name="callbacks" value="stocked_food"/>
189
     <property name="object" value="stocked_food"/>
191
     <property name="object" value="stocked_food"/>
190
    </properties>
192
    </properties>
191
   </tile>
193
   </tile>
192
   <tile id="4">
194
   <tile id="4">
193
    <properties>
195
    <properties>
194
     <property name="actions" value="clone(2),"/>
196
     <property name="actions" value="clone(2),"/>
197
+    <property name="callbacks" value="stocked_food"/>
195
     <property name="object" value="stocked_food"/>
198
     <property name="object" value="stocked_food"/>
196
    </properties>
199
    </properties>
197
   </tile>
200
   </tile>
198
   <tile id="5">
201
   <tile id="5">
199
    <properties>
202
    <properties>
200
     <property name="actions" value="clone(3),"/>
203
     <property name="actions" value="clone(3),"/>
204
+    <property name="callbacks" value="stocked_food"/>
201
     <property name="object" value="stocked_food"/>
205
     <property name="object" value="stocked_food"/>
202
    </properties>
206
    </properties>
203
   </tile>
207
   </tile>
204
   <tile id="6">
208
   <tile id="6">
205
    <properties>
209
    <properties>
206
     <property name="actions" value="clone(4),"/>
210
     <property name="actions" value="clone(4),"/>
211
+    <property name="callbacks" value="stocked_food"/>
207
     <property name="object" value="stocked_food"/>
212
     <property name="object" value="stocked_food"/>
208
    </properties>
213
    </properties>
209
   </tile>
214
   </tile>
2331
    <tile gid="241"/>
2336
    <tile gid="241"/>
2332
    <tile gid="241"/>
2337
    <tile gid="241"/>
2333
    <tile gid="241"/>
2338
    <tile gid="241"/>
2334
-   <tile gid="1"/>
2339
+   <tile gid="0"/>
2335
    <tile gid="241"/>
2340
    <tile gid="241"/>
2336
    <tile gid="241"/>
2341
    <tile gid="241"/>
2337
    <tile gid="241"/>
2342
    <tile gid="241"/>
2428
    <tile gid="241"/>
2433
    <tile gid="241"/>
2429
    <tile gid="241"/>
2434
    <tile gid="241"/>
2430
    <tile gid="241"/>
2435
    <tile gid="241"/>
2431
-   <tile gid="1"/>
2432
-   <tile gid="1"/>
2433
-   <tile gid="1"/>
2434
-   <tile gid="1"/>
2436
+   <tile gid="0"/>
2437
+   <tile gid="0"/>
2438
+   <tile gid="0"/>
2439
+   <tile gid="0"/>
2435
    <tile gid="241"/>
2440
    <tile gid="241"/>
2436
    <tile gid="241"/>
2441
    <tile gid="241"/>
2437
    <tile gid="241"/>
2442
    <tile gid="241"/>
2528
    <tile gid="241"/>
2533
    <tile gid="241"/>
2529
    <tile gid="241"/>
2534
    <tile gid="241"/>
2530
    <tile gid="241"/>
2535
    <tile gid="241"/>
2531
-   <tile gid="1"/>
2536
+   <tile gid="0"/>
2532
    <tile gid="241"/>
2537
    <tile gid="241"/>
2533
    <tile gid="241"/>
2538
    <tile gid="241"/>
2534
    <tile gid="0"/>
2539
    <tile gid="0"/>
2627
    <tile gid="241"/>
2632
    <tile gid="241"/>
2628
    <tile gid="241"/>
2633
    <tile gid="241"/>
2629
    <tile gid="241"/>
2634
    <tile gid="241"/>
2630
-   <tile gid="1"/>
2631
-   <tile gid="1"/>
2632
-   <tile gid="1"/>
2635
+   <tile gid="0"/>
2636
+   <tile gid="0"/>
2637
+   <tile gid="0"/>
2633
    <tile gid="241"/>
2638
    <tile gid="241"/>
2634
    <tile gid="0"/>
2639
    <tile gid="0"/>
2635
    <tile gid="241"/>
2640
    <tile gid="241"/>
2727
    <tile gid="241"/>
2732
    <tile gid="241"/>
2728
    <tile gid="241"/>
2733
    <tile gid="241"/>
2729
    <tile gid="241"/>
2734
    <tile gid="241"/>
2730
-   <tile gid="1"/>
2735
+   <tile gid="0"/>
2731
    <tile gid="244"/>
2736
    <tile gid="244"/>
2732
-   <tile gid="1"/>
2737
+   <tile gid="0"/>
2733
    <tile gid="241"/>
2738
    <tile gid="241"/>
2734
    <tile gid="0"/>
2739
    <tile gid="0"/>
2735
    <tile gid="241"/>
2740
    <tile gid="241"/>
2827
    <tile gid="241"/>
2832
    <tile gid="241"/>
2828
    <tile gid="241"/>
2833
    <tile gid="241"/>
2829
    <tile gid="241"/>
2834
    <tile gid="241"/>
2830
-   <tile gid="1"/>
2831
-   <tile gid="1"/>
2832
-   <tile gid="1"/>
2835
+   <tile gid="0"/>
2836
+   <tile gid="0"/>
2837
+   <tile gid="0"/>
2833
    <tile gid="241"/>
2838
    <tile gid="241"/>
2834
    <tile gid="0"/>
2839
    <tile gid="0"/>
2835
    <tile gid="241"/>
2840
    <tile gid="241"/>

+ 2 - 1
intelligine/synergy/event/transport/PutableAction.py View File

29
 
29
 
30
         # TODO: DEBUG
30
         # TODO: DEBUG
31
         if isinstance(obj_transported, Food):
31
         if isinstance(obj_transported, Food):
32
-            obj_transported.set_position((-1, 0, 0))
32
+            #obj_transported.set_position((-1, 0, 0))
33
+            obj_transported.transform_to_stocked()

+ 9 - 1
intelligine/synergy/object/Food.py View File

1
 from intelligine.synergy.object.ressource.Ressource import Resource
1
 from intelligine.synergy.object.ressource.Ressource import Resource
2
-from intelligine.cst import TYPE, TYPE_RESOURCE_EXPLOITABLE
2
+from intelligine.cst import TYPE, TYPE_RESOURCE_EXPLOITABLE, TYPE_RESOURCE_EATABLE, COL_EATABLE, COL_SMELL, SMELL_FOOD, \
3
+    TRANSPORTABLE
3
 
4
 
4
 
5
 
5
 class Food(Resource):
6
 class Food(Resource):
12
         clone = self.__class__(self._collection, self._context)
13
         clone = self.__class__(self._collection, self._context)
13
         self._collection.add_object(clone)
14
         self._collection.add_object(clone)
14
         return clone
15
         return clone
16
+
17
+    def transform_to_stocked(self):
18
+        self._context.metas.list.remove(TYPE, self.get_id(), TYPE_RESOURCE_EXPLOITABLE)
19
+        self._context.metas.list.add(TYPE, self.get_id(), TYPE_RESOURCE_EATABLE)
20
+        self._add_col(COL_EATABLE)
21
+        self._add_col(COL_SMELL)
22
+        self._set_smell(SMELL_FOOD)

+ 3 - 0
intelligine/synergy/object/StockedFood.py View File

11
         self._add_col(COL_EATABLE)
11
         self._add_col(COL_EATABLE)
12
         self._add_col(COL_SMELL)
12
         self._add_col(COL_SMELL)
13
         self._set_smell(SMELL_FOOD)
13
         self._set_smell(SMELL_FOOD)
14
+
15
+    def __new__(cls, *args, **kwargs):
16
+        return Food(*args, **kwargs)

+ 2 - 2
intelligine/tests/simulation/mode/TestChangeMode.py View File

1
 from intelligine.synergy.Environment import Environment
1
 from intelligine.synergy.Environment import Environment
2
 from intelligine.synergy.object.Food import Food
2
 from intelligine.synergy.object.Food import Food
3
-from intelligine.synergy.object.StockedFood import StockedFood
4
 from intelligine.tests.simulation.mode.Base import Base
3
 from intelligine.tests.simulation.mode.Base import Base
5
 from intelligine.synergy.Colony import Colony
4
 from intelligine.synergy.Colony import Colony
6
 from intelligine.synergy.Simulation import Simulation
5
 from intelligine.synergy.Simulation import Simulation
65
             def get_start_objects(self, collection, context):
64
             def get_start_objects(self, collection, context):
66
                 foods = []
65
                 foods = []
67
                 food = Food(collection, context)
66
                 food = Food(collection, context)
68
-                stocked_food = StockedFood(collection, context)
67
+                stocked_food = Food(collection, context)
68
+                stocked_food.transform_to_stocked()
69
                 food.set_position((0, 0, -20))
69
                 food.set_position((0, 0, -20))
70
                 stocked_food.set_position((0, 0, 0))
70
                 stocked_food.set_position((0, 0, 0))
71
                 foods.append(stocked_food)
71
                 foods.append(stocked_food)