Ignore:
Timestamp:
09/05/13 13:58:24 (8 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Protagonist actions, now required for operating doors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/protagonist.py

    r277 r281  
    44
    55from nagslang import render
    6 from nagslang.constants import COLLISION_TYPE_PLAYER, ZORDER_MID, \
    7     WEREWOLF_SOAK_FACTOR, PROTAGONIST_HEALTH_MIN_LEVEL, \
    8     PROTAGONIST_HEALTH_MAX_LEVEL
     6from nagslang.constants import (
     7    COLLISION_TYPE_PLAYER, ZORDER_MID, WEREWOLF_SOAK_FACTOR,
     8    PROTAGONIST_HEALTH_MIN_LEVEL, PROTAGONIST_HEALTH_MAX_LEVEL,
     9    NON_GAME_OBJECT_COLLIDERS)
    910from nagslang.events import FireEvent
    1011from nagslang.game_object import GameObject, Physicser, make_body
     
    217218            self.go_werewolf()
    218219
    219     def act_on(self, target):
     220    def get_current_interactible(self):
     221        for shape in self.get_space().shape_query(self.get_shape()):
     222            if shape.collision_type in NON_GAME_OBJECT_COLLIDERS:
     223                # No game object here.
     224                continue
     225            interactible = shape.physicser.game_object.interactible
     226            if interactible is not None:
     227                return interactible
     228        return None
     229
     230    def perform_action(self):
    220231        """Perform an action on the target.
    221232        """
    222         # TODO: Decide how best to do this.
    223         pass
     233        interactible = self.get_current_interactible()
     234        if interactible is None:
     235            # Nothing to interact with.
     236            return
     237        action = interactible.select_action(self)
     238        if action is None:
     239            # Nothing to do with it.
     240            return
     241        return action.perform(self)
    224242
    225243    def attack(self):
Note: See TracChangeset for help on using the changeset viewer.