Scriptname _00E_AddMusicScript extends ObjectReference  
{Dynamically adds and removes music.}

Auto State WaitingForActivate

Event OnTriggerEnter(ObjectReference akActionRef)

	If akActionRef == PlayerREF
		MusicToPlay.Add()
		Levelsystem.RemoveSilence()
		If Config_RemoveOnLeave == True
			GoToState("WaitingForLeave")
		Else
			GoToState("Done")
		EndIf
	EndIf
EndEvent

EndState

State WaitingForLeave

Event OnTriggerLeave(ObjectReference akActionRef)
	If akActionRef == PlayerREF
		MusicToPlay.Remove()
		If Config_ActivateMultipleTimes
			GoToState("WaitingForActivate")
		Else
			GoToState("Done")
		EndIf
	EndIf
EndEvent

EndState

State Done

; Do nothing

EndState

;=====================================================================================
;              							 PROPERTIES                 					 
;=====================================================================================	

_00E_QuestFunctions Property Levelsystem Auto

Bool Property Config_RemoveOnLeave = False Auto
{If checked, removes the music once the player leaves the triggerbox. Check this if you want to check Config_ActivateMultipleTimes!}
Bool Property Config_ActivateMultipleTimes = False Auto
{If checked, the triggerbox will reset after the player leaving}

MusicType Property MusicToPlay Auto
Actor Property PlayerREF Auto