entities.dictionary module
Provides helper class to store entity instances.
-
class entities.dictionary.EntityDictionary(*args, **kwargs)[source]
Bases: AutoUnload
, dict
Helper class used to store entity instances.
-
__init__(factory=<class 'entities._base.Entity'>, *args, **kwargs)[source]
Initializes the dictionary.
- Parameters:
factory (callable) –
Factory class or function used to create missing instances. Set to
None to disable this feature.
Factory signature: index, *args, **kwargs
args (tuple) – Arguments passed to the factory class or function.
kwargs (dict) – Keyword arguments passed to the factory class or function.
-
from_inthandle(inthandle)[source]
Returns an entity instance from an inthandle.
- Parameters:
inthandle (int) – The inthandle.
- Return type:
Entity
-
on_automatically_removed(index)[source]
Called when an index is automatically removed.
- Parameters:
index (int) – The index of the entity instance being removed.
-
class entities.dictionary.SyncedEntityDictionary(*args, **kwargs)[source]
Bases: EntityDictionary
Helper class used to keep entity instances synced with the game.
-
__init__(factory=<class 'entities._base.Entity'>, iterator=<filters.entities.EntityIter object>, *args, **kwargs)[source]
Initializes the dictionary.
- Parameters:
factory (callable) –
Factory class or function.
Factory signature: index, *args, **kwargs
iterator (iterable) – Iterator used to generates instances on initialization and resync.
args (tuple) – Arguments passed to the factory class or function.
kwargs (dict) – Keyword arguments passed to the factory class or function.
- Raises:
ValueError – If the factory is set to None.
-
on_automatically_created(index)[source]
Called when an index is automatically added.
- Parameters:
index (int) – The index of the entity instance being added.
-
resync()[source]
Resync the dictionary with the game.