diff src/parpg/objects/action.py @ 146:6e1eb964a6e5

Fixed dropping items on the map.
author KarstenBock@gmx.net
date Mon, 03 Oct 2011 18:25:31 +0200
parents 140e5e93f026
children 7214224b8d83
line wrap: on
line diff
--- a/src/parpg/objects/action.py	Mon Oct 03 14:12:17 2011 +0200
+++ b/src/parpg/objects/action.py	Mon Oct 03 18:25:31 2011 +0200
@@ -425,20 +425,16 @@
         
     def execute(self):
         map_name = self.model.game_state.current_map_name
-        map_item_values = {}
-        map_item_values["ViewName"] = self.item.name
-        map_item_values["ObjectType"] = "MapItem"
-        map_item_values["ItemType"] = self.item.item_type
-        map_item_values["Map"] = map_name
-        coords = self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\
-                                        getLocation().getExactLayerCoordinates()
-        map_item_values["Position"] = (coords.x, coords.y)
-        map_item_values["Rotation"] = 0
-        map_item_values["item"] = self.item
-        agent = {}
-        agent[self.item.ID] = map_item_values
-        self.model.addAgent("All", agent)
-        self.model.placeAgents()
+        identifier = self.item.entity.general.identifier
+        agent_values = self.model.items[identifier]
+        coords = (self.model.game_state.getObjectById("PlayerCharacter").
+                  fifeagent.behaviour.getLocation().getExactLayerCoordinates()
+                  )
+        agent_values["Position"] = (coords.x, coords.y)
+        agent_values["Rotation"] = 0
+        self.model.deleteObject(identifier)
+        self.model.addAgent(map_name, {identifier: agent_values})
+        self.model.placeAgents(self.item.entity.world)
         super(DropItemAction, self).execute()
         
 class DropItemFromContainerAction(DropItemAction):