comparison gamemodel.py @ 92:84b5808d995c

Added Graphics component.
author KarstenBock@gmx.net
date Tue, 27 Sep 2011 15:50:28 +0200
parents 4a8a0cd7f79a
children c0db5f521695
comparison
equal deleted inserted replaced
91:d2451ecb1433 92:84b5808d995c
332 unique_agent_id = self.createUniqueID(agent.keys()[0]) 332 unique_agent_id = self.createUniqueID(agent.keys()[0])
333 del agent[agent.keys()[0]] 333 del agent[agent.keys()[0]]
334 agent[unique_agent_id] = agent_values 334 agent[unique_agent_id] = agent_values
335 self.agents[namespace].update(agent) 335 self.agents[namespace].update(agent)
336 object_model = "" 336 object_model = ""
337 if agent_values["Entity"].has_key("fifeagent") \ 337 if agent_values["Entity"].has_key("graphics") \
338 and agent_values["Entity"]["fifeagent"].has_key("gfx"): 338 and agent_values["Entity"]["graphics"].has_key("gfx"):
339 object_model = agent_values["Entity"]["fifeagent"]["gfx"] 339 object_model = agent_values["Entity"]["graphics"]["gfx"]
340 else: 340 else:
341 object_model = self.object_db[agent_values["Template"]]["fifeagent"]["gfx"] 341 object_model = self.object_db[agent_values["Template"]]["graphics"]["gfx"]
342 import_file = self.agent_import_files[object_model] 342 import_file = self.agent_import_files[object_model]
343 loadImportFile(self.obj_loader, import_file, self.engine) 343 loadImportFile(self.obj_loader, import_file, self.engine)
344 344
345 def readAgentsOfMap(self, map_name): 345 def readAgentsOfMap(self, map_name):
346 """Read the agents of the map 346 """Read the agents of the map
398 self.game_state.maps[map_name] = new_map 398 self.game_state.maps[map_name] = new_map
399 new_map.load(map_file) 399 new_map.load(map_file)
400 400
401 def createAgent(self, agent, inst_id, world): 401 def createAgent(self, agent, inst_id, world):
402 entity_data = deepcopy(agent["Entity"]) 402 entity_data = deepcopy(agent["Entity"])
403 entity_data["fifeagent"] = {}
403 if agent.has_key("Template"): 404 if agent.has_key("Template"):
404 entity_data = self.checkAttributes(entity_data, agent["Template"]) 405 entity_data = self.checkAttributes(entity_data, agent["Template"])
405 object_id = entity_data["fifeagent"]["gfx"] \ 406 object_id = entity_data["graphics"]["gfx"] \
406 if entity_data["fifeagent"].has_key("gfx") \ 407 if entity_data["graphics"].has_key("gfx") \
407 else "generic_item" 408 else "generic_item"
408 map_obj = self.fife_model.getObject(str(object_id), "PARPG") 409 map_obj = self.fife_model.getObject(str(object_id), "PARPG")
409 if not map_obj: 410 if not map_obj:
410 logging.warning("Object with inst_id={0}, ns=PARPG, " 411 logging.warning("Object with inst_id={0}, ns=PARPG, "
411 "could not be found. " 412 "could not be found. "