import struct RandomizationDataEntry
{
	import var id : String;
	import var templateName : CName;
	import var probability : Float;
	import var transform : Transform;
}

import abstract class IRandomizationSupervisor extends IScriptable
{
}

import class ScriptedRandomizationSupervisor extends IRandomizationSupervisor
{
}

class TestRandomizationSupervisor extends ScriptedRandomizationSupervisor
{
	var firstWasGenerated : Bool;

	protected event OnBeginRandomization( out entries : array< RandomizationDataEntry > )
	{
		var i, size : Int32;
		var firstIndex, lastIndex : Int32;
		var tmpEntry : RandomizationDataEntry;
		size = entries.Size();
		for( i = 0; i < size; i += 1 )
		{
			if( entries[ i ].id == "first" )
			{
				firstIndex = i;
			}
			else if( entries[ i ].id == "last" )
			{
				lastIndex = i;
			}
		}
		tmpEntry = entries[ 0 ];
		entries[ 0 ] = entries[ firstIndex ];
		entries[ firstIndex ] = tmpEntry;
		size -= 1;
		tmpEntry = entries[ size ];
		entries[ size ] = entries[ lastIndex ];
		entries[ lastIndex ] = tmpEntry;
		firstWasGenerated = false;
	}

	protected event OnCanBeGenerated( entry : RandomizationDataEntry )
	{
		if( entry.id == "last" )
		{
			return !( firstWasGenerated );
		}
		return true;
	}

	protected event OnMarkGenerated( entry : RandomizationDataEntry )
	{
		if( entry.id == "first" )
		{
			firstWasGenerated = true;
		}
	}

	protected event OnEndRandomization()
	{
	}

}

