Mercurial > parpg-core
comparison src/parpg/gamescenecontroller.py @ 190:a22e92090018
The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
author | KarstenBock@gmx.net |
---|---|
date | Sat, 12 Nov 2011 20:54:25 +0100 |
parents | 487fba82abff |
children | 191f89a22303 |
comparison
equal
deleted
inserted
replaced
189:61d158ce6bc3 | 190:a22e92090018 |
---|---|
424 # out | 424 # out |
425 npc = self.model.game_state.getObjectById( | 425 npc = self.model.game_state.getObjectById( |
426 npc_info.general.identifier, | 426 npc_info.general.identifier, |
427 self.model.game_state.current_map_name | 427 self.model.game_state.current_map_name |
428 ) | 428 ) |
429 npc_pos = npc.fifeagent.behaviour.getLocation().getLayerCoordinates() | 429 npc_behaviour = npc.fifeagent.behaviour |
430 npc_pos = npc_behaviour.getLocation().getLayerCoordinates() | |
430 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\ | 431 self.model.game_state.getObjectById("PlayerCharacter").fifeagent.\ |
431 behaviour.approach([npc_pos.x, | 432 behaviour.approach(npc_behaviour.agent, |
432 npc_pos.y], | |
433 TalkAction(self, npc)) | 433 TalkAction(self, npc)) |
434 | 434 |
435 def getItemActions(self, obj_id): | 435 def getItemActions(self, obj_id): |
436 """Given the objects ID, return the text strings and callbacks. | 436 """Given the objects ID, return the text strings and callbacks. |
437 @type obj_id: string | 437 @type obj_id: string |
440 @return: List of text and callbacks""" | 440 @return: List of text and callbacks""" |
441 actions = [] | 441 actions = [] |
442 obj = self.model.game_state.\ | 442 obj = self.model.game_state.\ |
443 getObjectById(obj_id, | 443 getObjectById(obj_id, |
444 self.model.game_state.current_map_name) | 444 self.model.game_state.current_map_name) |
445 obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates() | 445 #obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates() |
446 agent = obj.fifeagent.behaviour.agent | |
446 player = self.model.game_state.getObjectById("PlayerCharacter") | 447 player = self.model.game_state.getObjectById("PlayerCharacter") |
447 is_player = obj.general.identifier == player.general.identifier | 448 is_player = obj.general.identifier == player.general.identifier |
448 | 449 |
449 | 450 |
450 #TODO: Check all actions to be compatible with the grease components | 451 #TODO: Check all actions to be compatible with the grease components |
454 if obj.characterstats and not is_player: | 455 if obj.characterstats and not is_player: |
455 actions.append(["Attack", "Attack", self.nullFunc, obj]) | 456 actions.append(["Attack", "Attack", self.nullFunc, obj]) |
456 if obj.description and obj.description.desc: | 457 if obj.description and obj.description.desc: |
457 actions.append(["Examine", "Examine", | 458 actions.append(["Examine", "Examine", |
458 player.fifeagent.behaviour.approach, | 459 player.fifeagent.behaviour.approach, |
459 [obj_pos.x, obj_pos.y], | 460 agent, |
460 ExamineAction(self, | 461 ExamineAction(self, |
461 obj_id, obj.description.view_name, | 462 obj_id, obj.description.view_name, |
462 obj.description.desc)]) | 463 obj.description.desc)]) |
463 | 464 |
464 if obj.change_map: | 465 if obj.change_map: |
465 actions.append(["Change Map", "Change Map", | 466 actions.append(["Change Map", "Change Map", |
466 player.fifeagent.behaviour.approach, | 467 player.fifeagent.behaviour.approach, |
467 [obj_pos.x, obj_pos.y], | 468 agent, |
468 ChangeMapAction(self, obj.change_map.target_map, | 469 ChangeMapAction(self, obj.change_map.target_map, |
469 obj.change_map.target_position)]) | 470 obj.change_map.target_position)]) |
470 | 471 |
471 if obj.lockable: | 472 if obj.lockable: |
472 if obj.lockable.closed: | 473 if obj.lockable.closed: |
473 if not obj.lockable.locked: | 474 if not obj.lockable.locked: |
474 actions.append(["Open", "Open", | 475 actions.append(["Open", "Open", |
475 player.fifeagent.behaviour.approach, | 476 player.fifeagent.behaviour.approach, |
476 [obj_pos.x, obj_pos.y], | 477 agent, |
477 OpenAction(self, obj)]) | 478 OpenAction(self, obj)]) |
478 else: | 479 else: |
479 actions.append(["Close", "Close", | 480 actions.append(["Close", "Close", |
480 player.fifeagent.behaviour.approach, | 481 player.fifeagent.behaviour.approach, |
481 [obj_pos.x, obj_pos.y], | 482 agent, |
482 CloseAction(self, obj)]) | 483 CloseAction(self, obj)]) |
483 if obj.lockable.locked: | 484 if obj.lockable.locked: |
484 actions.append(["Unlock", "Unlock", | 485 actions.append(["Unlock", "Unlock", |
485 player.fifeagent.behaviour.approach, | 486 player.fifeagent.behaviour.approach, |
486 [obj_pos.x, obj_pos.y], | 487 agent, |
487 UnlockAction(self, obj)]) | 488 UnlockAction(self, obj)]) |
488 else: | 489 else: |
489 if obj.lockable.closed: | 490 if obj.lockable.closed: |
490 actions.append(["Lock", "Lock", | 491 actions.append(["Lock", "Lock", |
491 player.fifeagent.behaviour.approach, | 492 player.fifeagent.behaviour.approach, |
492 [obj_pos.x, obj_pos.y], | 493 agent, |
493 LockAction(self, obj)]) | 494 LockAction(self, obj)]) |
494 if obj.container: | 495 if obj.container: |
495 if obj.characterstats: | 496 if obj.characterstats: |
496 #TODO: This is reserved for a possible "Steal" action. | 497 #TODO: This is reserved for a possible "Steal" action. |
497 pass | 498 pass |
498 elif not obj.lockable or not obj.lockable.closed: | 499 elif not obj.lockable or not obj.lockable.closed: |
499 actions.append(["Examine contents", "Examine Contents", | 500 actions.append(["Examine contents", "Examine Contents", |
500 player.fifeagent.behaviour.approach, | 501 player.fifeagent.behaviour.approach, |
501 [obj_pos.x, obj_pos.y], | 502 agent, |
502 ExamineContentsAction(self, obj)]) | 503 ExamineContentsAction(self, obj)]) |
503 if obj.containable: | 504 if obj.containable: |
504 actions.append(["Pick Up", "Pick Up", | 505 actions.append(["Pick Up", "Pick Up", |
505 player.fifeagent.behaviour.approach, | 506 player.fifeagent.behaviour.approach, |
506 [obj_pos.x, obj_pos.y], | 507 agent, |
507 PickUpAction(self, obj)]) | 508 PickUpAction(self, obj)]) |
508 | 509 |
509 return actions | 510 return actions |
510 | 511 |
511 def saveGame(self, *args, **kwargs): | 512 def saveGame(self, *args, **kwargs): |