diff gamescenecontroller.py @ 88:0411a4bcceee

Fixed moving between maps.
author KarstenBock@gmx.net
date Mon, 26 Sep 2011 15:44:42 +0200
parents a9cc5559ec2a
children 485d866a847f
line wrap: on
line diff
--- a/gamescenecontroller.py	Sat Sep 24 16:48:06 2011 +0200
+++ b/gamescenecontroller.py	Mon Sep 26 15:44:42 2011 +0200
@@ -32,6 +32,8 @@
                            UnlockBoxAction, LockBoxAction, TalkAction, \
                            PickUpAction, DropItemAction
 
+from parpg.world import World
+
 #For debugging/code analysis
 if False:
     from gamesceneview import GameSceneView
@@ -41,7 +43,7 @@
 
 logger = logging.getLogger('gamescenecontroller')
 
-class GameSceneController(ControllerBase):
+class GameSceneController(World, ControllerBase):
     '''
     This controller handles inputs when the game is in "scene" state.
     "Scene" state is when the player can move around and interact
@@ -68,6 +70,7 @@
                                 view,
                                 model,
                                 application)
+        World.__init__(self)
         #this can be helpful for IDEs code analysis
         if False:
             assert(isinstance(self.engine, fife.Engine))
@@ -327,18 +330,19 @@
         if self.model.map_change:
             self.pause(True)
             if self.model.active_map:
-                player_char = self.model.game_state.getObjectById("PlayerCharacter").fifeagent
-                self.model.game_state.getObjectById("PlayerCharacter").fifeagent = None
-                pc_agent = self.model.agents[self.model.ALL_AGENTS_KEY]\
-                                                ["PlayerCharacter"]
-                pc_agent.update(player_char.getStateForSaving())
+                self.model.updateObjectDB(self)
+                player_char = self.model.game_state.\
+                    getObjectById("PlayerCharacter").fifeagent
+                pc_agent = self.model.agents\
+                    [self.model.ALL_AGENTS_KEY]["PlayerCharacter"]
                 pc_agent["Map"] = self.model.target_map_name 
                 pc_agent["Position"] = self.model.target_position
-                pc_agent["Inventory"] = \
-                        player_char.inventory.serializeInventory()
                 player_agent = self.model.active_map.\
                                     agent_layer.getInstance("PlayerCharacter")
-                self.model.active_map.agent_layer.deleteInstance(player_agent)
+                self.model.game_state.deleteObject("PlayerCharacter")
+                self.model.game_state.deleteObjectsFromMap(
+                    self.model.game_state.current_map_name
+                )
             
             self.model.loadMap(self.model.target_map_name)