class PropagateStatusEffectInAreaEffector extends ApplyEffectToDismemberedEffector
{
	private var m_statusEffect : TweakDBID;
	private var m_range : Float;
	private var m_duration : Float;
	private var m_applicationTarget : CName;
	private var m_propagateToInstigator : Bool;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_statusEffect = TweakDBInterface.GetForeignKey( record + T".statusEffect", T"" );
		m_range = TweakDBInterface.GetFloat( record + T".range", 2.0 );
		m_duration = TweakDBInterface.GetFloat( record + T".duration", 0.0 );
		m_applicationTarget = TweakDBInterface.GetCName( record + T"applicationTarget", '' );
		m_propagateToInstigator = TweakDBInterface.GetBool( record + T".propagateToInstigator", true );
	}

	protected export override function ActionOn( owner : GameObject )
	{
		ProcessAction( owner );
	}

	protected export override function RepeatedAction( owner : GameObject )
	{
		ProcessAction( owner );
	}

	private function ProcessAction( owner : GameObject )
	{
		var targetPosition : Vector4;
		var effect : EffectInstance;
		var target : weak< GameObject >;
		var dismembermentInfo : DismembermentInstigatedInfo;
		dismembermentInfo = GetDismembermentInfo();
		if( dismembermentInfo.wasTargetAlreadyDead || dismembermentInfo.wasTargetAlreadyDefeated )
		{
			return;
		}
		if( m_applicationTarget == 'Dismemberment' )
		{
			targetPosition = dismembermentInfo.targetPosition;
		}
		else
		{
			if( GetApplicationTarget( owner, m_applicationTarget, target ) )
			{
				targetPosition = target.GetWorldPosition();
			}
			else
			{
				return;
			}
		}
		if( m_propagateToInstigator )
		{
			effect = GameInstance.GetGameEffectSystem( owner.GetGame() ).CreateEffectStatic( 'applyStatusEffect', 'inRange', owner );
		}
		else
		{
			effect = GameInstance.GetGameEffectSystem( owner.GetGame() ).CreateEffectStatic( 'applyStatusEffect', 'inRangeNoInstigator', owner );
		}
		EffectData.SetVector( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.position, targetPosition );
		EffectData.SetFloat( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.radius, m_range );
		EffectData.SetFloat( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.duration, m_duration );
		EffectData.SetVariant( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.statusEffect, m_statusEffect );
		effect.Run();
	}

}

