ScriptName xLVMotionStructureBase extends ObjectReference

string Property SIGNATURE Auto
string Property TYPE_TAG Auto
int Property MotionID Auto Hidden
int Property sequence = 0 Auto

int Property VoiceLevel000 = 0 Auto
int Property VoiceLevel001 = 1 Auto
int Property VoiceLevel002 = 2 Auto
int Property VoiceLevel003 = 1 Auto
int Property VoiceLevel004 = 2 Auto
int Property VoiceLevel005 = 1 Auto
int Property VoiceLevel006 = 2 Auto
int Property VoiceLevel007 = 1 Auto
int Property VoiceLevel008 = 1 Auto
int Property VoiceLevel009 = 2 Auto
int Property VoiceLevelFin = 3 Auto

float Property SoundDuration000 = 2.0 Auto
float Property SoundDuration001 = 2.0 Auto
float Property SoundDuration002 = 2.0 Auto
float Property SoundDuration003 = 2.0 Auto
float Property SoundDuration004 = 2.0 Auto
float Property SoundDuration005 = 2.0 Auto
float Property SoundDuration006 = 2.0 Auto
float Property SoundDuration007 = 2.0 Auto
float Property SoundDuration008 = 2.0 Auto
float Property SoundDuration009 = 2.0 Auto
float Property SoundDurationFin = 2.0 Auto

float Property EnvDuration000 = 2.0 Auto
float Property EnvDuration001 = 2.0 Auto
float Property EnvDuration002 = 2.0 Auto
float Property EnvDuration003 = 2.0 Auto
float Property EnvDuration004 = 2.0 Auto
float Property EnvDuration005 = 2.0 Auto
float Property EnvDuration006 = 2.0 Auto
float Property EnvDuration007 = 2.0 Auto
float Property EnvDuration008 = 2.0 Auto
float Property EnvDuration009 = 2.0 Auto
float Property EnvDurationFin = 2.0 Auto

int Property current_index = 0 Auto Hidden

;;--------------------------------------------------------------------------------;;
;; Virtual Functions
;;--------------------------------------------------------------------------------;;
Idle Function GetIdle( int target_id, int sequence_id )
	return None
EndFunction

Function Copy( xLVMotionStructureBase p )
	if ( p == None )
		return
	endif
	self.SetMotionID( p.GetMotionID() )
	self.sequence = p.sequence
	
	self.VoiceLevel000 = p.VoiceLevel000
	self.VoiceLevel001 = p.VoiceLevel001
	self.VoiceLevel002 = p.VoiceLevel002
	self.VoiceLevel003 = p.VoiceLevel003
	self.VoiceLevel004 = p.VoiceLevel004
	self.VoiceLevel005 = p.VoiceLevel005
	self.VoiceLevel006 = p.VoiceLevel006
	self.VoiceLevel007 = p.VoiceLevel007
	self.VoiceLevel008 = p.VoiceLevel008
	self.VoiceLevel009 = p.VoiceLevel009
	self.VoiceLevelFin = p.VoiceLevelFin
	
	self.SoundDuration000 = p.SoundDuration000
	self.SoundDuration001 = p.SoundDuration001
	self.SoundDuration002 = p.SoundDuration002
	self.SoundDuration003 = p.SoundDuration003
	self.SoundDuration004 = p.SoundDuration004
	self.SoundDuration005 = p.SoundDuration005
	self.SoundDuration006 = p.SoundDuration006
	self.SoundDuration007 = p.SoundDuration007
	self.SoundDuration008 = p.SoundDuration008
	self.SoundDuration009 = p.SoundDuration009
	self.SoundDurationFin = p.SoundDurationFin

	self.EnvDuration000 = p.EnvDuration000
	self.EnvDuration001 = p.EnvDuration001
	self.EnvDuration002 = p.EnvDuration002
	self.EnvDuration003 = p.EnvDuration003
	self.EnvDuration004 = p.EnvDuration004
	self.EnvDuration005 = p.EnvDuration005
	self.EnvDuration006 = p.EnvDuration006
	self.EnvDuration007 = p.EnvDuration007
	self.EnvDuration008 = p.EnvDuration008
	self.EnvDuration009 = p.EnvDuration009
	self.EnvDurationFin = p.EnvDurationFin
	
EndFunction

int Function GetExpressionType( int target_id, int sequence_id )
	return 0
EndFunction 

int Function GetExpressionStrength( int target_id, int sequence_id )
	return 0
EndFunction 

;;--------------------------------------------------------------------------------;;
string Function GetSignature()
	return SIGNATURE
EndFunction

Function SetMotionID( int n )
	MotionID = n
EndFunction

int Function GetMotionID()
	return MotionID
EndFunction

bool Function IsValid()
	if ( sequence <= 0 )
		return False
	endif
		
	return True
EndFunction

Function SetSequenceSize( int n )
	sequence = n
	if ( sequence < 0 )
		sequence = 0
	elseif ( sequence > 9 )
		sequence = 9
	endif
EndFunction

int Function GetSequenceSize()
	return sequence
EndFunction

bool Function IsFinalSequence()
	if ( current_index == ( sequence - 1 ) )
		return True
	endif
	return False
EndFunction

int Function BindIndex( int id )
	int index = id
	if ( index < 0 )
		index = 0
	endif
	if ( index >= sequence )
		index = sequence - 1
	endif
	return index
EndFunction

Function SequenceReset()
	current_index = 0
EndFunction

Function SequenceNext()
	current_index = BindIndex( current_index + 1 )
EndFunction

Function SequencePrev()
	current_index = BindIndex( current_index - 1 )
EndFunction

int Function GetCurrentIndex()
	return current_index
EndFunction

int Function SetCurrentIndex( int n )
	current_index = BindIndex( n )
EndFunction

Idle Function GetCurrentIdle( int target_id )
	return GetIdle( target_id, current_index )
EndFunction

Idle Function GetFinishIdle( int target_id )
	return GetIdle( target_id, -1 )
EndFunction

int Function GetVoiceLevel( int id )

	if ( id == 0 )
		return VoiceLevel000
	elseif ( id == 1 )
		return VoiceLevel001
	elseif ( id == 2 )
		return VoiceLevel002
	elseif ( id == 3 )
		return VoiceLevel003
	elseif ( id == 4 )
		return VoiceLevel004
	elseif ( id == 5 )
		return VoiceLevel005
	elseif ( id == 6 )
		return VoiceLevel006
	elseif ( id == 7 )
		return VoiceLevel007
	elseif ( id == 8 )
		return VoiceLevel008
	elseif ( id == 9 )
		return VoiceLevel009
	elseif ( id == -1 )
		return VoiceLevelFin
	endif
	
	return 0
EndFunction

int Function GetCurrentVoiceLevel()
	return GetVoiceLevel( current_index )
EndFunction

int Function GetFinishVoiceLevel()
	return VoiceLevelFin
EndFunction

float Function GetSoundDuration( int id )
	if ( id == 0 )
		return SoundDuration000
	elseif ( id == 1 )
		return SoundDuration001
	elseif ( id == 2 )
		return SoundDuration002
	elseif ( id == 3 )
		return SoundDuration003
	elseif ( id == 4 )
		return SoundDuration004
	elseif ( id == 5 )
		return SoundDuration005
	elseif ( id == 6 )
		return SoundDuration006
	elseif ( id == 7 )
		return SoundDuration007
	elseif ( id == 8 )
		return SoundDuration008
	elseif ( id == 9 )
		return SoundDuration009
	elseif ( id == -1 )
		return SoundDurationFin
	endif
	
	return 2.0
EndFunction

float Function GetEnvDuration( int id )
	if ( id == 0 )
		return EnvDuration000
	elseif ( id == 1 )
		return EnvDuration001
	elseif ( id == 2 )
		return EnvDuration002
	elseif ( id == 3 )
		return EnvDuration003
	elseif ( id == 4 )
		return EnvDuration004
	elseif ( id == 5 )
		return EnvDuration005
	elseif ( id == 6 )
		return EnvDuration006
	elseif ( id == 7 )
		return EnvDuration007
	elseif ( id == 8 )
		return EnvDuration008
	elseif ( id == 9 )
		return EnvDuration009
	elseif ( id == -1 )
		return EnvDurationFin
	endif
	
	return 2.0
EndFunction

bool Function HasFinishSequence()
	return True
EndFunction

bool Function HasTypeTag( string s )

	int result = StringUtil.Find( TYPE_TAG, s, 0 )

	if ( result == -1 )
		return False
	endif
	return True
EndFunction

int Function GetCurrentExpressionType( int target_id )
	return GetExpressionType( target_id, current_index )
EndFunction

int Function GetCurrentExpressionStrength( int target_id )
	return GetExpressionStrength( target_id, current_index )
EndFunction

int Function GetFinishExpressionType( int target_id )
	return GetExpressionType( target_id, -1 )
EndFunction 

int Function GetFinishExpressionStrength( int target_id )
	return GetExpressionStrength( target_id, -1 )
EndFunction 


