Mercurial > parpg-core
diff src/parpg/behaviours/base.py @ 75:c3350fc9cd45
Added approach functionality to the BaseBehaviour
author | KarstenBock@gmx.net |
---|---|
date | Thu, 08 Sep 2011 14:20:31 +0200 |
parents | 58661f5b2f6b |
children | 8a7bb62f9f5d |
line wrap: on
line diff
--- a/src/parpg/behaviours/base.py Wed Sep 07 14:48:08 2011 +0200 +++ b/src/parpg/behaviours/base.py Thu Sep 08 14:20:31 2011 +0200 @@ -64,5 +64,35 @@ 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) + def onInstanceActionFinished(self, instance, action): - pass \ No newline at end of file + """@type instance: ??? + @param instance: ??? + @type action: ??? + @param action: ??? + @return: None""" + # First we reset the next behavior + act = self.nextAction + self.nextAction = None + self.idle() + + if act: + act.execute() + + if(action.getId() != 'stand'): + self.idle_counter = 1 + else: + self.idle_counter += 1 \ No newline at end of file