ScriptName _00E_AltIshmartepPuzzleDoorScript Extends ObjectReference
{
- Each ring should have its linkedRef point to the keyhole
}

import debug
import utility

ObjectReference property doorBase auto
{base piece of the door} 

ObjectReference property largeRing auto
{large rotating disk of the door}

objectReference property mediumRing auto
{medium rotating disk of the door}

objectReference property smallRing auto
{small rotating disk of the door}

objectReference property doorFX auto
{dust FX for when doors opens}

ObjectReference Property collision Auto
ObjectReference Property rotatingDisk Auto

Sound Property opening Auto

Bool doOnce = True

Event OnTriggerEnter( ObjectReference ref )

	if( doOnce == true )
		doOnce = false
		openDoor()
	EndIf
	
EndEvent

Function openDoor()

	gotoState("busy")
	
	rotatingDisk.TranslateTo( 4368.0000, 2144.0000, 1584.0000, 0.0000, -89.9720, 180.0000, 80 )
	collision.Enable()
	
	;play FX
	doorFX.playAnimation("FXDoorOpen")
	
	smallRing.PlayAnimationAndWait( "Trigger01", "Turned0" + 1 )
	smallRing.PlayAnimation( "Open" )
	Wait( 1 )
	mediumRing.PlayAnimationAndWait( "Trigger01", "Turned0" + 1 )
	mediumRing.PlayAnimation( "Open" )
	Wait( 1 )
	largeRing.PlayAnimationAndWait( "Trigger01", "Turned0" + 1 )
	largeRing.PlayAnimation( "Open" )
	
	;open main door
	opening.Play( Self )
	doorBase.playAnimation("Open")
	

		
endFunction

STATE busy
	; This is the state when I'm busy animating
		EVENT onActivate (objectReference triggerRef)
			;do nothing
		endEVENT
endState