Created
December 8, 2014 02:59
-
-
Save Langerz82/6ff01e9c99e36270835e to your computer and use it in GitHub Desktop.
Activated Object Reference is a generic script that enables simplification of child scripts for two-state Objects with conditions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ Activated Object Reference is a generic script that enables | |
+ simplification of child scripts for two-state Objects with conditions. | |
+ Override the ObjectActive and ObjectInactive functions into order | |
+ modify the ObjectReference when the conditions occur. Also override | |
+ the IsObjectActive and IsObjectInactive on your custom conditions. | |
+ | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
ScriptName ActivatedObjectReference extends ObjectReference | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ PROPERTIES | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
Float Property fCheckActiveInterval Auto ; Desired Update check time/5.0 ex. | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ GENERAL FUNCTIONS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
; Object gets Toggled. | |
Function ObjectToggle() | |
EndFunction | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ OVERRIDE FUNCTIONS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
; Override Function - Is the Object Active? | |
Bool Function isObjectActive() | |
return true | |
EndFunction | |
; Override Function - Is the Object InActive? | |
Bool Function isObjectInactive() | |
return true | |
EndFunction | |
; Override Function - When Object becomes Active. | |
Function ObjectActive() | |
EndFunction | |
; Override Function - When Object becomes Inactive. | |
Function ObjectInactive() | |
EndFunction | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ STATES | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
State Active | |
Event OnBeginState() | |
;Debug.Notification("ActivatedObjectReference(state:Active,func:OnBeginState)") | |
ObjectActive() | |
EndEvent | |
Function ObjectToggle() | |
;Debug.Notification("ActivatedObjectReference(state:Active,func:ObjectToggle)") | |
If (Self.isDisabled()) | |
return | |
EndIf | |
If (IsObjectInactive()) | |
GoToState("Inactive") | |
EndIf | |
EndFunction | |
EndState | |
Auto State Inactive | |
Event OnBeginState() | |
;Debug.Notification("ActivatedObjectReference(state:Inactive,func:OnBeginState)") | |
ObjectInactive() | |
EndEvent | |
Function ObjectToggle() | |
;Debug.Notification("ActivatedObjectReference(state:Inactive,func:ObjectToggle)") | |
If (Self.isDisabled()) | |
return | |
EndIf | |
If (IsObjectActive()) | |
GoToState("Active") | |
EndIf | |
EndFunction | |
EndState | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ EVENTS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
Event OnUpdate() | |
;Debug.Notification("ActivatedObjectReference(func:OnUpdate)") | |
RegisterForSingleUpdate(fCheckActiveInterval) | |
ObjectToggle() | |
EndEvent | |
Event OnInit() | |
;Debug.Notification("ActivatedObjectReference(func:OnInit)") | |
RegisterForSingleLOSGain(Game.GetPlayer(), Self) | |
ObjectToggle() | |
EndEvent | |
Event OnGainLOS(Actor akViewer, ObjectReference akTarget) | |
;Debug.Notification("ActivatedObjectReference(func:OnGainLOS)") | |
RegisterForSingleLOSLost(Game.GetPlayer(), Self) | |
RegisterForSingleUpdate(fCheckActiveInterval) | |
ObjectToggle() | |
EndEvent | |
Event OnLostLOS(Actor akViewer, ObjectReference akTarget) | |
;Debug.Notification("ActivatedObjectReference(func:OnLostLOS)") | |
RegisterForSingleLOSGain(Game.GetPlayer(), Self) | |
UnregisterForUpdate() ; Stop polling | |
EndEvent | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment