class CheckThreat extends AIbehaviorconditionScript
{
	editable inlined var m_targetObjectMapping : AIArgumentMapping;
	protected var m_targetThreat : weak< GameObject >;

	protected export override function Activate( context : ScriptExecutionContext )
	{
		SetUpdateInterval( context, RandomizeOffsetForUpdateInterval( 0.1 ) );
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var trackerComponent : TargetTrackerComponent;
		var threats : array< TrackedLocation >;
		var i : Int32;
		m_targetThreat = ( ( weak< weak< GameObject > > )( ScriptExecutionContext.GetMappingValue( context, m_targetObjectMapping ) ) );
		trackerComponent = GetPuppet( context ).GetTargetTrackerComponent();
		if( !( trackerComponent ) )
		{
			return false;
		}
		if( !( m_targetThreat ) )
		{
			return false;
		}
		threats = trackerComponent.GetThreats( true );
		if( threats.Size() == 0 )
		{
			return false;
		}
		for( i = 0; i < threats.Size(); i += 1 )
		{
			if( threats[ i ].entity == m_targetThreat )
			{
				return AIActionHelper.TryChangingAttitudeToHostile( GetPuppet( context ), m_targetThreat );
			}
		}
		return false;
	}

}

class CheckDroppedThreat extends CheckThreat
{

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var tte : TargetTrackingExtension;
		var threatData : DroppedThreatData;
		tte = ( ( TargetTrackingExtension )( GetPuppet( context ).GetTargetTrackerComponent() ) );
		if( !( tte ) )
		{
			return false;
		}
		threatData = tte.GetRecentlyDroppedThreat();
		return ( ( Bool )( threatData.threat ) );
	}

}

