entities.transmit module

Provides entity transmission functionality.

class entities.transmit.BaseTransmitRules

Bases: core.WeakAutoUnload, Boost.Python.instance

__init__()

Raises an exception This class cannot be instantiated from Python

should_transmit((BaseTransmitRules)self, (BaseEntity)player, (BaseEntity)entity) → bool :

Returns whether the given entity should be transmitted to the given player.

Return type:bool
mode

Returns the transmit mode for these rules.

Return type:TransmitMode
class entities.transmit.TransmitHash

Bases: _entities._transmit.BaseTransmitRules

Transmissions rules where contained pairs are never transmitted to each other.

Example:

from entities.transmit import TransmitHash
from events import Event
from players.entity import Player

h = TransmitHash()

@Event('player_say')
def player_say(game_event):
    player = Player.from_userid(game_event['userid'])
    entity = player.view_entity
    if entity is None:
        return
    # Toggle transmissions with aimed entity
    if h.has_pair(player, entity):
        h.remove_pair(player, entity)
    else:
        h.add_pair(player, entity)
__init__((object)arg1[, (TransmitMode)mode=_entities._transmit.TransmitMode.PREVENT]) → object :

Constructs and initializes the transmit hash.

Parameters:mode (TransmitMode) – The transmit mode for these rules.
add_pair((TransmitHash)self, (BaseEntity)entity, (BaseEntity)other) → None :

Adds the given entity pair to the hash.

Raises:ValueError – If none of the given entities is a player.
clear((TransmitHash)self) → None :

Removes all entities from the hash.

get_count((TransmitHash)self, (BaseEntity)entity) → int :

Returns the amount of pairs associated with the given entity.

Return type:int
get_pairs((TransmitHash)self, (BaseEntity)entity) → list :

Returns a list of all entities associated with the given entity.

Return type:list
has_pair((TransmitHash)self, (BaseEntity)entity, (BaseEntity)other) → bool :

Returns whether the given pair is in the hash.

Return type:bool
remove_pair((TransmitHash)self, (BaseEntity)entity, (BaseEntity)other) → None :

Removes the given pair from the hash.

remove_pairs((TransmitHash)self, (BaseEntity)entity) → None :

Removes all pairs associated with the given entity.

class entities.transmit.TransmitHook(callback)[source]

Bases: core.AutoUnload

Decorator used to create transmit hooks that auto unload.

Example:

from entities.transmit import TransmitHook

@TransmitHook
def transmit_hook(player, indexes, states):
    # Don't transmit anything to this player except himself
    player_index = player.index
    for index in indexes:
        if index == player_index:
            continue
        states[index] = False
__init__(callback)[source]

Registers the transmit hook.

Parameters:callback (function) – Function to register as a transmit hook callback.
class entities.transmit.TransmitManager

Bases: Boost.Python.instance

__init__()

Raises an exception This class cannot be instantiated from Python

register_hook((TransmitManager)self, (object)callback) → None :

Registers a transmit hook.

Parameters:callback (function) – Function to register as a transmit hook callback.
Raises:ValueError – If the given callback is already registered.
unregister_hook((TransmitManager)self, (object)callback) → None :

Unregisters a transmit hook.

Parameters:callback (function) – Function to unregister as a transmit hook callback.
Raises:ValueError – If the given callback was not registered.
class entities.transmit.TransmitMap

Bases: _entities._transmit.BaseTransmitRules

Transmission rules that overrides per-player transmission.

Example:

from entities.transmit import TransmitMap
from events import Event
from players.entity import Player

m = TransmitMap()

@Event('player_say')
def player_say(game_event):
    player = Player.from_userid(game_event['userid'])
    entity = player.view_entity
    if entity is None:
        return
    # Toggle one-way transmissions with aimed entity
    s = m[entity]
    if player in s:
        s.remove(player)
    else:
        s.add(player)
__init__((object)arg1[, (TransmitMode)mode=_entities._transmit.TransmitMode.PREVENT]) → object :

Constructs and initializes the transmit map.

Parameters:mode (TransmitMode) – The transmit mode for these rules.
clear((TransmitMap)self) → None :

Removes all players from the map.

class entities.transmit.TransmitMode

Bases: Boost.Python.enum

ALLOW = _entities._transmit.TransmitMode.ALLOW
PREVENT = _entities._transmit.TransmitMode.PREVENT
names = {'ALLOW': _entities._transmit.TransmitMode.ALLOW, 'PREVENT': _entities._transmit.TransmitMode.PREVENT}
values = {0: _entities._transmit.TransmitMode.ALLOW, 1: _entities._transmit.TransmitMode.PREVENT}
class entities.transmit.TransmitSet

Bases: _entities._transmit.BaseTransmitRules

Transmission rules where contained entities are never transmitted to any player.

Example:

from entities.transmit import TransmitSet
from events import Event
from players.entity import Player

s = TransmitSet()

@Event('player_say')
def player_say(game_event):
    player = Player.from_userid(game_event['userid'])
    entity = player.view_entity
    if entity is None:
        return
    # Toggle transmissions with everything
    if entity in s:
        s.remove(entity)
    else:
        s.add(entity)
__init__((object)arg1[, (TransmitMode)mode=_entities._transmit.TransmitMode.PREVENT]) → object :

Constructs and initializes the transmit set.

Parameters:mode (TransmitMode) – The transmit mode for these rules.
add((TransmitSet)self, (BaseEntity)entity) → None :

Adds the given entity to the set.

Raises:ValueError – If the given entity is not networked.
clear((TransmitSet)self) → None :

Removes all entities from the set.

remove((TransmitSet)self, (BaseEntity)entity) → None :

Removes the given entity from the set.

class entities.transmit.TransmitStates

Bases: Boost.Python.instance

__init__((object)arg1) → None