diff src/parpg/behaviours/base.py @ 83:9f8faf6e974d

Added BaseBehaviour. Moved methods from MovingAgentBehaviour to BaseBehaviour.
author KarstenBock@gmx.net
date Fri, 09 Sep 2011 15:18:17 +0200
parents 62cff91a19cb
children d89e88a90c9e
line wrap: on
line diff
--- a/src/parpg/behaviours/base.py	Fri Sep 09 15:05:23 2011 +0200
+++ b/src/parpg/behaviours/base.py	Fri Sep 09 15:18:17 2011 +0200
@@ -23,8 +23,6 @@
         fife.InstanceActionListener.__init__(self)
         self.agent = None
         self.state = None
-        self.speed = 0
-        self.idle_counter = 1
     
     def attachToLayer(self, agent_ID, layer):
         """Attaches to a certain layer
@@ -57,26 +55,11 @@
         self.agent = layer.getInstance(self.parent.fifeagent.identifier)
         self.agent.addActionListener(self)
         self.state = _AGENT_STATE_NONE
-        self.idle_counter = 1
     
     def idle(self):
         """@return: None"""
         self.state = _AGENT_STATE_IDLE
-        self.agent.act('stand', self.agent.getFacingLocation())
-
-    def approach(self, location, action=None):
-        """Approaches a location and then perform an action (if set).
-           @type loc: fife.Location
-           @param loc: the location to approach
-           @type action: Action
-           @param action: The action to schedule for execution after the approach.
-           @return: None"""
-        self.state = _AGENT_STATE_APPROACH
-        self.nextAction = action
-        boxLocation = tuple([int(float(i)) for i in location])
-        l = fife.Location(self.agent.getLocation())
-        l.setLayerCoordinates(fife.ModelCoordinate(*boxLocation))
-        self.agent.move('run', l, self.speed + 1)        
+        self.agent.act('stand', self.agent.getFacingLocation())       
         
     def onInstanceActionFinished(self, instance, action):
         """@type instance: ???
@@ -91,11 +74,7 @@
         
         if act:
             act.execute()
-            
-        if(action.getId() != 'stand'):
-            self.idle_counter = 1
-        else:
-            self.idle_counter += 1 
+          
             
     def getLocation(self):
         """Get the agents position as a fife.Location object. 
@@ -110,22 +89,4 @@
         self.state = _AGENT_STATE_TALK
         self.pc = pc.behaviour.agent
         self.idle()
-        
-    def run(self, location):
-        """Makes the PC run to a certain location
-           @type location: fife.ScreenPoint
-           @param location: Screen position to run to.
-           @return: None"""
-        self.state = _AGENT_STATE_RUN
-        self.nextAction = None
-        self.agent.move('run', location, self.speed + 1)
-
-    def walk(self, location):
-        """Makes the PC walk to a certain location.
-           @type location: fife.ScreenPoint
-           @param location: Screen position to walk to.
-           @return: None"""
-        self.state = _AGENT_STATE_RUN
-        self.nextAction = None 
-        self.agent.move('walk', location, self.speed - 1)
         
\ No newline at end of file