Skip to content

Commit bcec498

Browse files
author
L'In20Cible
committed
Added Entity.parent property.
1 parent 29f34bf commit bcec498

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

addons/source-python/data/source-python/entities/CBaseEntity.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@
8383
render_fx = m_nRenderFX
8484
render_mode_prop = m_nRenderMode
8585
move_type = movetype
86+
parent_inthandle = m_pParent

addons/source-python/packages/source-python/entities/_base.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,33 @@ def set_model(self, model):
320320
get_model, set_model,
321321
doc="""Property to get/set the entity's model.""")
322322

323+
def get_parent(self):
324+
"""Return the entity's parent.
325+
326+
:rtype: Entity
327+
"""
328+
# Get the parent handle...
329+
parent_inthandle = self.parent_inthandle
330+
331+
# Does the entity have no parent?
332+
if parent_inthandle == -1:
333+
return None
334+
335+
# Return the parent of the entity...
336+
return Entity(index_from_inthandle(parent_inthandle))
337+
338+
def set_parent(self, parent):
339+
"""Set the parent of the entity.
340+
341+
:param Entity parent:
342+
The parent of the entity.
343+
"""
344+
self.set_parent(parent)
345+
346+
parent = property(
347+
get_parent, set_parent,
348+
doc="""Property to get/set the parent of the entity.""")
349+
323350
@property
324351
def model_header(self):
325352
"""Return the entity's model header.

0 commit comments

Comments
 (0)