How to use the flax.component.IOpenable function in flax

To help you get started, we’ve selected a few flax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eevee / flax / flax / component.py View on Github external
def cant_walk_through_closed_doors(event, door):
    if not IOpenable(door.entity).open:
        event.cancel()
github eevee / flax / flax / component.py View on Github external
def color(self):
        # TODO what if it doesn't exist
        if ILockable(self.entity).locked:
            return self.locked[1]
        # TODO what if it doesn't exist
        elif IOpenable(self.entity).open:
            return self.open[1]
        else:
            return self.closed[1]
github eevee / flax / flax / component.py View on Github external
def blocks(self, actor):
        return not IOpenable(self.entity).open
github eevee / flax / flax / component.py View on Github external
def sprite(self):
        # TODO what if it doesn't exist
        if ILockable(self.entity).locked:
            return self.locked[0]
        # TODO what if it doesn't exist
        elif IOpenable(self.entity).open:
            return self.open[0]
        else:
            return self.closed[0]
github eevee / flax / flax / world.py View on Github external
new_pos = self.current_map.find(self.player).position + direction
        if new_pos not in self.current_map:
            return None
        tile = self.current_map.tiles[new_pos]

        if tile.creature:
            return MeleeAttack(self.player, direction)

        arch = tile.architecture

        if ILockable in arch and ILockable(arch).locked:
            key = next((item for item in IContainer(self.player).inventory if item.isa(Key)), None)
            if key:
                return Unlock(self.player, arch, key)

        if IOpenable in arch and not IOpenable(arch).open:
            return Open(self.player, arch)

        return Walk(self.player, direction)