Skip to content
Permalink
Browse files

Added from_inthandle() to the Entity and EntityDictionary classes. (#272

)

* Added from_inthandle() to the Weapon and WeaponDictionary classes.

* Added from_inthandle() to the Entity and EntityDictionary classes.
  • Loading branch information...
vinci6k authored and Ayuto committed Feb 10, 2019
1 parent 7ea507d commit 6bf64cccaf4ff69703fdc582446d6a06ca7f095d
@@ -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."""
@@ -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

@@ -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."""

0 comments on commit 6bf64cc

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.