diff gamemodel.py @ 86:a9cc5559ec2a

Move the identifier field from the FifeAgent component to the new General component. Added General Entity.
author KarstenBock@gmx.net
date Sat, 24 Sep 2011 15:48:24 +0200
parents bb9e2f2548c6
children 0411a4bcceee
line wrap: on
line diff
--- a/gamemodel.py	Fri Sep 23 15:09:02 2011 +0200
+++ b/gamemodel.py	Sat Sep 24 15:48:24 2011 +0200
@@ -437,7 +437,6 @@
             inst.act('default', target, True)        
 
             
-        entity_data["fifeagent"]["identifier"] = inst_id
         if entity_data["fifeagent"].has_key("behaviour"):
             entity_data["fifeagent"]["behaviour"] = getattr(behaviours, entity_data["fifeagent"]["behaviour"])()
         else:
@@ -446,7 +445,7 @@
             entity_data["dialogue"] = {}
             entity_data["dialogue"]["dialogue"] = self.dialogues[inst_id]           
                        
-        obj = self.createMapObject(self.active_map.agent_layer, entity_data, world)
+        obj = self.createMapObject(self.active_map.agent_layer, entity_data, inst_id, world)
 
         if agent.has_key("Inventory"):
             inv = agent["Inventory"]
@@ -477,9 +476,10 @@
                     raise Exception("Item %s is not containable or equipable." % item_type)
 
     def create_item(self, item_data, world, item_type, data):
-        item = createEntity(item_data, world, None)
+        identifier = self.createUniqueID(data["ID"])
+        item = createEntity(item_data, identifier, world, None)
         item.containable.item_type = item_type
-        self.game_state.addObject(self.createUniqueID(data["ID"]), None, item)
+        self.game_state.addObject(identifier, None, item)
         return item
 
     def placeAgents(self, world):
@@ -544,7 +544,7 @@
         self.active_map.makeActive()
         self.game_state.current_map_name = map_name
 
-    def createMapObject (self, layer, attributes, world):
+    def createMapObject (self, layer, attributes, inst_id, world):
         """Create an object and add it to the current map.
            @type layer: fife.Layer
            @param layer: FIFE layer object exists in
@@ -559,7 +559,7 @@
             extra['fifeagent'] = {}
             extra['fifeagent']['layer'] = layer
         
-        obj = createEntity(attributes, world, extra)
+        obj = createEntity(attributes, inst_id, world, extra)
         if obj:
             self.addObject(layer, obj)
         return obj
@@ -590,11 +590,11 @@
            @type instance: fife.Instance
            @param instance: FIFE instance of object
            @return: None"""
-        ref = self.game_state.getObjectById(obj.fifeagent.identifier,
+        ref = self.game_state.getObjectById(obj.general.identifier,
                                             self.game_state.current_map_name) 
         if ref is None:
             # no, add it to the game state
-            self.game_state.addObject(obj.fifeagent.identifier, self.game_state.current_map_name, obj)
+            self.game_state.addObject(obj.general.identifier, self.game_state.current_map_name, obj)
         else:
             # yes, use the current game state data
             obj.fifeagent.pos.X = ref.X
@@ -625,7 +625,7 @@
            @return: Status of result (True/False)"""
         for game_object in \
            self.game_state.getObjectsFromMap(self.game_state.current_map_name):
-            if (game_object.fifeagent.identifier == ident):
+            if (game_object.general.identifier == ident):
                 # we found a match
                 return game_object
         # no match