Mercurial > parpg-source
diff behaviours/base.py @ 48:1bdadb768bcf
Added approach functionality to the BaseBehaviour
author | KarstenBock@gmx.net |
---|---|
date | Thu, 08 Sep 2011 14:20:31 +0200 |
parents | bf506f739322 |
children | b4a525456c99 |
line wrap: on
line diff
--- a/behaviours/base.py Wed Sep 07 14:48:08 2011 +0200 +++ b/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