# HG changeset patch # User KarstenBock@gmx.net # Date 1315396442 -7200 # Node ID 58661f5b2f6b1914e7ec59785c333ae181ca0814 # Parent 9aebbf4e02f7cc741191728706fc51b9cac74a64 Removed layer as attribute of BaseBehaviour and added it as a parameter to the attachToLayer method. diff -r 9aebbf4e02f7 -r 58661f5b2f6b src/parpg/behaviours/base.py --- a/src/parpg/behaviours/base.py Wed Sep 07 13:24:02 2011 +0200 +++ b/src/parpg/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 9aebbf4e02f7 -r 58661f5b2f6b src/parpg/behaviours/npc.py --- a/src/parpg/behaviours/npc.py Wed Sep 07 13:24:02 2011 +0200 +++ b/src/parpg/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 9aebbf4e02f7 -r 58661f5b2f6b src/parpg/behaviours/player.py --- a/src/parpg/behaviours/player.py Wed Sep 07 13:24:02 2011 +0200 +++ b/src/parpg/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 9aebbf4e02f7 -r 58661f5b2f6b src/parpg/components/fifeagent.py --- a/src/parpg/components/fifeagent.py Wed Sep 07 13:24:02 2011 +0200 +++ b/src/parpg/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 9aebbf4e02f7 -r 58661f5b2f6b src/parpg/gamemodel.py --- a/src/parpg/gamemodel.py Wed Sep 07 13:24:02 2011 +0200 +++ b/src/parpg/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