import abstract class BehaviorBlackboard extends IScriptable
{
}

import abstract class BehaviorDelegate extends BehaviorBlackboard
{
	public import function GetParent() : BehaviorDelegate;
}

import class ScriptBehaviorDelegate extends BehaviorDelegate
{
}

import struct AIDelegateAttrRef
{
	import var name : CName;
}

import struct AIDelegateTaskRef
{
	import var name : CName;
}

class TestBehaviorDelegate extends ScriptBehaviorDelegate
{
	editable var integer : Int32;
	editable var floatValue : Float;
	const editable var names : array< CName >;
	editable inlined var command : AICommand;
	editable var newProperty2 : Bool;
	editable var newProperty : Bool;
	editable var newProperty3 : Bool;
	editable var newProperty4 : Bool;
	editable var nodeRef : NodeRef;

	public constexpr function GetGetterValue() : CName
	{
		return 'getterValue';
	}

	public function GetSomethingElse() : NodeRef
	{
		return nodeRef;
	}

	public constexpr function IsSomething() : Bool
	{
		return false;
	}

	public function TestTask( context : ScriptExecutionContext ) {}

	public function TaskFoo( context : ScriptExecutionContext ) {}

	public constexpr function TaskBar() : Bool
	{
		return true;
	}

}

class TestBehaviorDelegateTask extends AIbehaviortaskScript
{
	editable inlined var attrRef : AIDelegateAttrRef;
	editable inlined var taskRef : AIDelegateTaskRef;
}

class ActionWeightCondition extends AIbehaviorconditionScript
{
	editable inlined var selectedActionIndex : AIArgumentMapping;
	editable var thisIndex : Int32;

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( thisIndex == ( ( Int32 )( ScriptExecutionContext.GetMappingValue( context, selectedActionIndex ) ) ) )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class ActionWeightManagerDelegate extends ScriptBehaviorDelegate
{
	const editable var actionsConditions : array< String >;
	var actionsWeights : array< Int32 >;
	var lowestWeight : Int32;
	var selectedActionIndex : Int32;

	public export function ProcessActionToPlay( context : ScriptExecutionContext ) : Bool
	{
		var aiComponent : AIHumanComponent;
		var i : Int32;
		if( ( actionsWeights.Size() == 0 ) && ( actionsConditions.Size() != 0 ) )
		{
			actionsWeights.Resize( actionsConditions.Size() );
		}
		lowestWeight = 999;
		selectedActionIndex = 999;
		aiComponent = ( ( ScriptedPuppet )( ScriptExecutionContext.GetOwner( context ) ) ).GetAIControllerComponent();
		if( !( aiComponent ) )
		{
			return true;
		}
		if( !( aiComponent.CheckTweakCondition( "MeleeBaseCondition" ) ) )
		{
			return true;
		}
		for( i = 0; i < actionsConditions.Size(); i += 1 )
		{
			if( aiComponent.CheckTweakCondition( actionsConditions[ i ] ) )
			{
				if( actionsWeights[ i ] <= lowestWeight )
				{
					selectedActionIndex = i;
					lowestWeight = actionsWeights[ i ];
				}
			}
		}
		if( selectedActionIndex == 999 )
		{
		}
		return true;
	}

	public export function WeightUpdate() : Bool
	{
		actionsWeights[ selectedActionIndex ] += 1;
		return true;
	}

}

