Scriptname _00E_FS_NQ07_LightScript extends activemagiceffect  

;=====================================================================================
;              							EVENTS                  					 
;=====================================================================================

bool bActive

Event OnEffectStart(Actor akTarget, Actor akCaster)

	bActive = true
	EnableAllRefsInFormlist()

EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)

	bActive = false
	DisableAllRefsInFormlist()

EndEvent

;=====================================================================================
;              							FUNCTIONS                  					 
;=====================================================================================

Function EnableAllRefsInFormlist()

	int iIndex = _00E_FS_NQ07_LightList.GetSize()
 
	while iIndex > 0
 
		if ! bActive
			return
		endif
		
		iIndex -= 1
		ObjectReference ref = _00E_FS_NQ07_LightList.GetAt(iIndex) as ObjectReference
		ref.EnableNoWait()
		ref.GetLinkedRef().EnableNoWait()
		
		if ref.Is3DLoaded()
			_00E_TeleportOutVFX.Play(ref)
			MAGIllusionNightEyeOn.Play(ref)
		endif
	
	endwhile

EndFunction

Function DisableAllRefsInFormlist()

	int iIndex = _00E_FS_NQ07_LightList.GetSize()
 
	while iIndex > 0
 
		iIndex -= 1
		ObjectReference ref = _00E_FS_NQ07_LightList.GetAt(iIndex) as ObjectReference
		if ref.Is3DLoaded()
			MAGIllusionNightEyeOff.Play(ref)
		endif
		ref.DisableNoWait()
		ref.GetLinkedRef().DisableNoWait()
  
	endwhile

EndFunction

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

VisualEffect Property _00E_TeleportOutVFX Auto

Sound Property MAGIllusionNightEyeOn Auto
Sound Property MAGIllusionNightEyeOff Auto

FormList Property _00E_FS_NQ07_LightList Auto