Difference between revisions of "GetActorOwner - ObjectReference"

imported>Fireundubh
(explicit vs. inherited ownership)
imported>Fireundubh
 
Line 35: Line 35:


ActorBase Function GetInheritedOwner(ObjectReference aObj, ObjectReference aContainer)
ActorBase Function GetInheritedOwner(ObjectReference aObj, ObjectReference aContainer)
    ActorBase actorOwner = aObj.GetActorOwner()
ActorBase actorOwner
    If !actorOwner  
        If aContainer
; if the object exists
            actorOwner = aContainer.GetActorOwner()
; try to get the object's explicit owner
            If !actorOwner
If aObj
                actorOwner = aContainer.GetParentCell().GetActorOwner()
actorOwner = aObj.GetActorOwner()
            EndIf
        EndIf
; if the object does not have an explicit owner
        If !actorOwner  
; and if the container exists
            actorOwner = aObj.GetParentCell().GetActorOwner()
; try to get the container's explicit owner
        EndIf
If !actorOwner
    EndIf
If aContainer
    Return actorOwner
actorOwner = aContainer.GetActorOwner()
; but if the container also does not have an explicit owner
; try to get the parent cell of the container's explicit owner
If !actorOwner
actorOwner = aContainer.GetParentCell().GetActorOwner()
EndIf
EndIf
; if even the parent cell of the container does not have an explicit owner
; try one last time to get the parent cell of the object's explicit owner
If !actorOwner
actorOwner = aObj.GetParentCell().GetActorOwner()
EndIf
EndIf
EndIf
; returns an explicit owner, inherited owner, or none
Return actorOwner
EndFunction
EndFunction
</source>
</source>
Anonymous user