Mercurial > fife-parpg
view clients/rio_de_hola/scripts/agents/agent.py @ 374:1115f7cae9a3
Editor:
* The editor will now force filenames to be lowercase, as VFS does not like uppercase path names.
* If a map filename does not have a .xml extension on save, it will be automatically added.
* Log modules set to "all" by default. Only new users will be affected by this without having to modify or remove their configuration file.
* Log level set to LOGLEVEL_WARN
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 21 Nov 2009 13:11:56 +0000 |
parents | 9a1529f9625e |
children |
line wrap: on
line source
import fife from scripts.common.common import ProgrammingError class Agent(fife.InstanceActionListener): def __init__(self, model, agentName, layer, uniqInMap=True): fife.InstanceActionListener.__init__(self) self.model = model self.agentName = agentName self.layer = layer if uniqInMap: self.agent = layer.getInstance(agentName) self.agent.addActionListener(self) def onInstanceActionFinished(self, instance, action): raise ProgrammingError('No OnActionFinished defined for Agent') def start(self): raise ProgrammingError('No start defined for Agent') def create_anonymous_agents(model, objectName, layer, agentClass): agents = [] instances = [a for a in layer.getInstances() if a.getObject().getId() == objectName] i = 0 for a in instances: agentName = '%s:i:%d' % (objectName, i) i += 1 agent = agentClass(model, agentName, layer, False) agent.agent = a a.addActionListener(agent) agents.append(agent) return agents