class SendScoreRequest extends ScriptableSystemRequest
{
	var m_score : Int32;
	var m_gameName : String;
}

class SideScrollerMiniGameScoreSystem extends ScriptableSystem
{
	private var scoreData : Int32[ 3 ];
	private var gameNames : String[ 3 ];

	private export override function OnAttach()
	{
		var i : Int32;
		for( i = 0; i < scoreData.Size(); i = i + 1 )
		{
			scoreData[ i ] = 0;
		}
		gameNames[ 0 ] = "RoachRace";
		gameNames[ 1 ] = "Panzer";
		gameNames[ 2 ] = "QuadRacer";
	}

	private const function GetGameId( const gameName : ref< String > ) : Int32
	{
		var i : Int32;
		for( i = 0; i < gameNames.Size(); i = i + 1 )
		{
			if( gameNames[ i ] == gameName )
			{
				return i;
			}
		}
		return -1;
	}

	private function OnSendScore( request : SendScoreRequest )
	{
		var id : Int32;
		var score : Int32;
		id = GetGameId( request.m_gameName );
		if( id >= 0 )
		{
			score = ( ( Int32 )( request.m_score ) );
			if( scoreData[ id ] < score )
			{
				scoreData[ id ] = score;
			}
		}
	}

	public const function GetMaxScore( const gameName : ref< String > ) : Int32
	{
		var id : Int32;
		id = GetGameId( gameName );
		if( id >= 0 )
		{
			return scoreData[ id ];
		}
		return -1;
	}

}

