changeset 57:ba85e5aff370

Removed the pos value from the fifeagent component. getItemActions of Gamescenecontroller gets the position by calling a method of the behaviour.
author KarstenBock@gmx.net
date Fri, 09 Sep 2011 15:30:23 +0200
parents 3f6299f975fe
children d4f213b99d41
files components/fifeagent.py entities/character.py gamemodel.py gamescenecontroller.py
diffstat 4 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/components/fifeagent.py	Fri Sep 09 15:18:17 2011 +0200
+++ b/components/fifeagent.py	Fri Sep 09 15:30:23 2011 +0200
@@ -12,14 +12,13 @@
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from bGrease.component import Component
-from bGrease.geometry import Vec2d
 
 class FifeAgent(Component):
     """Component that stores the values for a fife agent"""
     
     def __init__(self):
         """Constructor"""
-        Component.__init__(self, identifier=str, layer=object, behaviour=object, gfx=str, pos=Vec2d)
+        Component.__init__(self, identifier=str, layer=object, behaviour=object, gfx=str)
 
         
 def setup_behaviour(agent):
--- a/entities/character.py	Fri Sep 09 15:18:17 2011 +0200
+++ b/entities/character.py	Fri Sep 09 15:30:23 2011 +0200
@@ -17,7 +17,7 @@
 class Character(Entity):
     def __init__(self, world, view_name, real_name, desc, statistics, max_bulk,
                  identifier, layer=None, behaviour=None, dialogue=None, 
-                 gfx=None, pos=Vec2d(0.0, 0.0), items=None
+                 gfx=None, items=None
                  ):
         self.characterstats.statistics = statistics
         
@@ -34,4 +34,3 @@
         self.fifeagent.layer = layer
         self.fifeagent.behaviour = behaviour
         self.fifeagent.gfx = gfx
-        self.fifeagent.pos = pos
--- a/gamemodel.py	Fri Sep 09 15:18:17 2011 +0200
+++ b/gamemodel.py	Fri Sep 09 15:30:23 2011 +0200
@@ -502,7 +502,6 @@
         inst_dict["identifier"] = inst_id
         inst_dict["world"]= world
         inst_dict["type"] = object_type
-        inst_dict["pos"] = Vec2d(x_pos, y_pos)
         inst_dict["gfx"] = object_id
         if agent.has_key("Open"):
             inst_dict["is_open"] = parseBool(agent["Open"])
--- a/gamescenecontroller.py	Fri Sep 09 15:18:17 2011 +0200
+++ b/gamescenecontroller.py	Fri Sep 09 15:30:23 2011 +0200
@@ -20,6 +20,7 @@
 import random
 import glob
 import os
+import logging
 
 from fife import fife
 from fife import extensions
@@ -37,7 +38,6 @@
     from gamemodel import GameModel
     from parpg import PARPGApplication
 
-import logging
 
 logger = logging.getLogger('gamescenecontroller')
 
@@ -428,9 +428,11 @@
         obj = self.model.game_state.\
                         getObjectById(obj_id,
                                       self.model.game_state.current_map_name)
+        obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates()
         player = self.model.game_state.getObjectById("PlayerCharacter")
         is_player = obj.fifeagent.identifier == player.fifeagent.identifier
         
+        
         #TODO: Check all actions to be compatible with the grease components
         if obj is not None:
             if obj.dialogue and not is_player:
@@ -440,7 +442,7 @@
             if obj.description:
                 actions.append(["Examine", "Examine",
                                 player.fifeagent.behaviour.approach, 
-                                [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                                [obj_pos.x, obj_pos.y],
                                 ExamineAction(self, 
                                               obj_id, obj.description.view_name, 
                                               obj.description.desc)])
@@ -448,27 +450,27 @@
             if obj.change_map:
                 actions.append(["Change Map", "Change Map",
                    player.fifeagent.behaviour.approach, 
-                   [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                   [obj_pos.x, obj_pos.y],
                    ChangeMapAction(self, obj.target_map_name,
                                    obj.target_pos)])
             
             if obj.lockable:
                 actions.append(["Open", "Open", 
                                 player.fifeagent.behaviour.approach,
-                                [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                                [obj_pos.x, obj_pos.y],
                                 OpenBoxAction(self, obj)])
                 actions.append(["Unlock", "Unlock", 
                                 player.fifeagent.behaviour.approach,
-                                [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                                [obj_pos.x, obj_pos.y],
                                 UnlockBoxAction(self, obj)])
                 actions.append(["Lock", "Lock", 
                                 player.fifeagent.behaviour.approach,
-                                [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                                [obj_pos.x, obj_pos.y],
                                 LockBoxAction(self, obj)])
             if obj.containable:
                 actions.append(["Pick Up", "Pick Up", 
                                 player.fifeagent.behaviour.approach,
-                                [obj.fifeagent.pos.x, obj.fifeagent.pos.y],
+                                [obj_pos.x, obj_pos.y],
                                 PickUpAction(self, obj)])
 
         return actions