# HG changeset patch # User KarstenBock@gmx.net # Date 1315396442 -7200 # Node ID bf506f7393224db75f040978d24cffc24e4b4e18 # Parent b8f421f74280055576f539fc6323712402153096 Removed layer as attribute of BaseBehaviour and added it as a parameter to the attachToLayer method. diff -r b8f421f74280 -r bf506f739322 behaviours/base.py --- a/behaviours/base.py Wed Sep 07 13:24:02 2011 +0200 +++ b/behaviours/base.py Wed Sep 07 13:54:02 2011 +0200 @@ -19,20 +19,21 @@ class BaseBehaviour (fife.InstanceActionListener): """Fife agent listener""" - def __init__(self, layer=None): + def __init__(self): fife.InstanceActionListener.__init__(self) - self.layer = layer self.agent = None self.state = None self.speed = 0 self.idle_counter = 1 - def attachToLayer(self, agent_ID): + def attachToLayer(self, agent_ID, layer): """Attaches to a certain layer @type agent_ID: String @param agent_ID: ID of the layer to attach to. + @type layer: Fife layer + @param layer: Layer of the agent to attach the behaviour to @return: None""" - self.agent = self.layer.getInstance(agent_ID) + self.agent = layer.getInstance(agent_ID) self.agent.addActionListener(self) self.state = _AGENT_STATE_NONE diff -r b8f421f74280 -r bf506f739322 behaviours/npc.py --- a/behaviours/npc.py Wed Sep 07 13:24:02 2011 +0200 +++ b/behaviours/npc.py Wed Sep 07 13:54:02 2011 +0200 @@ -20,8 +20,8 @@ class NPCBehaviour(BaseBehaviour): """This is a basic NPC behaviour""" - def __init__(self, parent=None, layer=None): - super(NPCBehaviour, self).__init__(layer) + def __init__(self, parent=None): + super(NPCBehaviour, self).__init__() self.parent = parent self.state = base._AGENT_STATE_NONE diff -r b8f421f74280 -r bf506f739322 behaviours/player.py --- a/behaviours/player.py Wed Sep 07 13:24:02 2011 +0200 +++ b/behaviours/player.py Wed Sep 07 13:54:02 2011 +0200 @@ -17,8 +17,8 @@ from base import BaseBehaviour class PlayerBehaviour (BaseBehaviour): - def __init__(self, parent=None, layer=None): - super(PlayerBehaviour, self).__init__(layer) + def __init__(self, parent=None): + super(PlayerBehaviour, self).__init__() self.parent = parent self.idle_counter = 1 self.speed = 0 diff -r b8f421f74280 -r bf506f739322 components/fifeagent.py --- a/components/fifeagent.py Wed Sep 07 13:24:02 2011 +0200 +++ b/components/fifeagent.py Wed Sep 07 13:54:02 2011 +0200 @@ -24,5 +24,5 @@ def setup_behaviour(agent): """Attach the behaviour to the layer""" - if agent.behaviour: - agent.behaviour.attachToLayer(agent.identifier) \ No newline at end of file + if agent.behaviour: + agent.behaviour.attachToLayer(agent.identifier, agent.layer) \ No newline at end of file diff -r b8f421f74280 -r bf506f739322 gamemodel.py --- a/gamemodel.py Wed Sep 07 13:24:02 2011 +0200 +++ b/gamemodel.py Wed Sep 07 13:54:02 2011 +0200 @@ -31,6 +31,7 @@ from parpg.dialogueparsers import YamlDialogueParser, DialogueFormatError from parpg.entities import createEntity from parpg import behaviours +from parpg.components import fifeagent try: import xml.etree.cElementTree as ElementTree @@ -677,6 +678,10 @@ if obj_type == "Character": obj.fifeagent.behaviour.parent = obj + fifeagent.setup_behaviour(obj.fifeagent) + obj.fifeagent.behaviour.speed = self.settings.parpg.PCSpeed + #Start the behaviour + obj.fifeagent.behaviour.idle() # create the agent #obj.setup() #obj.behaviour.speed = self.settings.parpg.PCSpeed