File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
addons/source-python/packages/source-python/entities Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,15 @@ def find_or_create(cls, classname):
212212
213213 return entity
214214
215+ @classmethod
216+ def from_inthandle (cls , inthandle ):
217+ """Create an entity instance from an inthandle.
218+ :param int inthandle:
219+ The inthandle.
220+ :rtype: Entity
221+ """
222+ return cls (index_from_inthandle (inthandle ))
223+
215224 @classmethod
216225 def _obj (cls , ptr ):
217226 """Return an entity instance of the given pointer."""
Original file line number Diff line number Diff line change 1010from core import AutoUnload
1111# Entities
1212from entities .entity import Entity
13+ from entities .helpers import index_from_inthandle
1314# Listeners
1415from listeners import on_entity_deleted_listener_manager
1516
@@ -60,6 +61,14 @@ def __delitem__(self, index):
6061 # Remove the given index from the dictionary...
6162 super ().__delitem__ (index )
6263
64+ def from_inthandle (self , inthandle ):
65+ """Get an entity instance from an inthandle.
66+
67+ :param int inthandle: The inthandle.
68+ :rtype: Entity
69+ """
70+ return self [index_from_inthandle (inthandle )]
71+
6372 def on_automatically_removed (self , index ):
6473 """Called when an index is automatically removed."""
6574
You can’t perform that action at this time.
0 commit comments