Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions addons/source-python/packages/source-python/entities/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ def find_or_create(cls, classname):

return entity

@classmethod
def from_inthandle(cls, inthandle):
"""Create an entity instance from an inthandle.
:param int inthandle:
The inthandle.
:rtype: Entity
"""
return cls(index_from_inthandle(inthandle))

@classmethod
def _obj(cls, ptr):
"""Return an entity instance of the given pointer."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from core import AutoUnload
# Entities
from entities.entity import Entity
from entities.helpers import index_from_inthandle
# Listeners
from listeners import on_entity_deleted_listener_manager

Expand Down Expand Up @@ -60,6 +61,14 @@ def __delitem__(self, index):
# Remove the given index from the dictionary...
super().__delitem__(index)

def from_inthandle(self, inthandle):
"""Get an entity instance from an inthandle.

:param int inthandle: The inthandle.
:rtype: Entity
"""
return self[index_from_inthandle(inthandle)]

def on_automatically_removed(self, index):
"""Called when an index is automatically removed."""

Expand Down