///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Human_AIAnimStateConnections.cpp
// Author : Will Plano
// Date   : 05/08/2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header...
#include "Actor/Vertebrates/Human/AVP_Human_AIAnimStateConnections.h"

#include "Actor/AVP_Actor_AIAnimStateConnection.h"

static const AVP_Actor_AIAnimStateConnectionListEntry s_axConnectionList[] = 
{
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, 								AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_SLOW, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_SLOW, 			AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, 								AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_MEDIUM, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_MEDIUM, 			AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, 								AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_FAST, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_IDLE_TO_MOVE_FAST, 			AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW_TO_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.5f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW_TO_IDLE,				AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM,					AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM_TO_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.5f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM_TO_IDLE,			AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM,					AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM,					AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST_TO_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.5f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST_TO_IDLE,				AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST,						AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, true, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_CROUCH_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_CROUCH_IDLE,				AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE,						AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE_TO_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE_TO_IDLE,				AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE, 						AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_MOVE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.2f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_MOVE, 						AVP_Human_AIAnimStateMachine::HUMAN_STATE_CROUCH_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_COVER_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_COVER_IDLE,					AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE,							AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE_TO_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE_TO_IDLE,					AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE,							AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE_TO_COVER_POPUP, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE_TO_COVER_POPUP,			AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_POPUP ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_POPUP,						AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_POPUP_TO_COVER_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_POPUP_TO_COVER_IDLE,			AVP_Human_AIAnimStateMachine::HUMAN_STATE_COVER_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_PANIC_IDLE,							AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.2f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_PANIC_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.2f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IN_GAMESCENE,						AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IN_MOVE,							AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_SITTING_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.2f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_SITTING_IDLE,						AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.2f, false, false ) ),

	// Idle -> Alert.Idle
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_ALERT_IDLE,				AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_ALERT_IDLE,					AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE,						AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.3f, false, true ) ),

	// Alert.Idle -> Idle
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE,							AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),

	// Idle -> Aggressive.Idle
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::ACTOR_STATE_IDLE,								AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_AGGRESSIVE_IDLE,			AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_IDLE_TO_AGGRESSIVE_IDLE,			AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE,					AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, true ) ),

	// Alert.Idle -> Aggressive.Idle
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE,							AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE_TO_AGGRESSIVE_IDLE,	AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE_TO_AGGRESSIVE_IDLE,		AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE,					AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, true ) ),

	// Aggressive.Idle -> Alert.Idle
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE,					AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE_TO_ALERT_IDLE,	AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, false ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE_TO_ALERT_IDLE,		AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE,						AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.1f, false, true ) ),

	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW_TO_IDLE,				AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM_TO_IDLE,			AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST_TO_IDLE,				AVP_Human_AIAnimStateMachine::HUMAN_STATE_ALERT_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),

	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_SLOW_TO_IDLE,				AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_MEDIUM_TO_IDLE,			AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),
	AVP_Actor_AIAnimStateConnectionListEntry( AVP_Human_AIAnimStateMachine::VERTEBRATE_STATE_MOVE_FAST_TO_IDLE,				AVP_Human_AIAnimStateMachine::HUMAN_STATE_AGGRESSIVE_IDLE, AVP_Actor_AIAnimStateConnectionData( 1.0f, 0.05f, false, true ) ),

	AVP_Actor_AIAnimStateConnectionListEntry( -1, -1 ) // terminator
};

bool AVP_Human_AIAnimStateConnections::s_bInitialised = false;
const AVP_Actor_AIAnimStateConnectionData* AVP_Human_AIAnimStateConnections::s_aapxConnectionsMatrix[ AVP_Human_AIAnimStateMachine::HUMAN_STATE_END ][ AVP_Human_AIAnimStateMachine::HUMAN_STATE_END ];

const AVP_Actor_AIAnimStateConnectionData* AVP_Human_AIAnimStateConnections::GetConnectionData( const u_int uStateFrom, const u_int uStateTo )
{
	if ( !s_bInitialised )
	{
		s_bInitialised = true;
		for ( u_int uFromItr = 0; uFromItr < AVP_Human_AIAnimStateMachine::HUMAN_STATE_END; ++uFromItr )
		{
			for ( u_int uToItr = 0; uToItr < AVP_Human_AIAnimStateMachine::HUMAN_STATE_END; ++uToItr )
			{
				s_aapxConnectionsMatrix[ uFromItr ][ uToItr ] = NULL;
			}
		}
		for ( u_int uConnItr = 0; s_axConnectionList[ uConnItr ].m_iStateFrom != -1; ++uConnItr )
		{
			s_aapxConnectionsMatrix[ s_axConnectionList[ uConnItr ].m_iStateFrom ][ s_axConnectionList[ uConnItr ].m_iStateTo ] = &( s_axConnectionList[ uConnItr ].m_xStateData );
		}
	}
	return s_aapxConnectionsMatrix[ uStateFrom ][ uStateTo ];
}
