diff gamescenecontroller.py @ 158:04854cf6e1ac

The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
author KarstenBock@gmx.net
date Sat, 12 Nov 2011 20:54:25 +0100
parents 2241722311bf
children 75c0b728ccf3
line wrap: on
line diff
--- a/gamescenecontroller.py	Sat Nov 12 16:27:39 2011 +0100
+++ b/gamescenecontroller.py	Sat Nov 12 20:54:25 2011 +0100
@@ -426,10 +426,10 @@
             npc_info.general.identifier, 
             self.model.game_state.current_map_name
         )
-        npc_pos = npc.fifeagent.behaviour.getLocation().getLayerCoordinates()
+        npc_behaviour = npc.fifeagent.behaviour
+        npc_pos = npc_behaviour.getLocation().getLayerCoordinates()
         self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\
-            behaviour.approach([npc_pos.x,
-                                npc_pos.y],
+            behaviour.approach(npc_behaviour.agent,
                                TalkAction(self, npc))
 
     def getItemActions(self, obj_id):
@@ -442,7 +442,8 @@
         obj = self.model.game_state.\
                         getObjectById(obj_id,
                                       self.model.game_state.current_map_name)
-        obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates()
+        #obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates()
+        agent = obj.fifeagent.behaviour.agent
         player = self.model.game_state.getObjectById("PlayerCharacter")
         is_player = obj.general.identifier == player.general.identifier
         
@@ -456,7 +457,7 @@
             if obj.description and obj.description.desc:
                 actions.append(["Examine", "Examine",
                                 player.fifeagent.behaviour.approach, 
-                                [obj_pos.x, obj_pos.y],
+                                agent,
                                 ExamineAction(self, 
                                               obj_id, obj.description.view_name, 
                                               obj.description.desc)])
@@ -464,7 +465,7 @@
             if obj.change_map:
                 actions.append(["Change Map", "Change Map",
                    player.fifeagent.behaviour.approach, 
-                   [obj_pos.x, obj_pos.y],
+                   agent,
                    ChangeMapAction(self, obj.change_map.target_map,
                                    obj.change_map.target_position)])
             
@@ -473,23 +474,23 @@
                     if not obj.lockable.locked:
                         actions.append(["Open", "Open", 
                                         player.fifeagent.behaviour.approach,
-                                        [obj_pos.x, obj_pos.y],
+                                        agent,
                                         OpenAction(self, obj)])
                 else:
                     actions.append(["Close", "Close", 
                                     player.fifeagent.behaviour.approach,
-                                    [obj_pos.x, obj_pos.y],
+                                    agent,
                                     CloseAction(self, obj)])
                 if obj.lockable.locked:
                     actions.append(["Unlock", "Unlock", 
                                     player.fifeagent.behaviour.approach,
-                                    [obj_pos.x, obj_pos.y],
+                                    agent,
                                     UnlockAction(self, obj)])
                 else:
                     if obj.lockable.closed:
                         actions.append(["Lock", "Lock", 
                                         player.fifeagent.behaviour.approach,
-                                        [obj_pos.x, obj_pos.y],
+                                        agent,
                                         LockAction(self, obj)])
             if obj.container:
                 if obj.characterstats:
@@ -498,12 +499,12 @@
                 elif not obj.lockable or not obj.lockable.closed:
                     actions.append(["Examine contents", "Examine Contents",
                                     player.fifeagent.behaviour.approach,
-                                    [obj_pos.x, obj_pos.y],
+                                    agent,
                                     ExamineContentsAction(self, obj)])
             if obj.containable:
                 actions.append(["Pick Up", "Pick Up", 
                                 player.fifeagent.behaviour.approach,
-                                [obj_pos.x, obj_pos.y],
+                                agent,
                                 PickUpAction(self, obj)])
 
         return actions