class LimfaticNanoChargeSystemEffector extends ContinuousEffector
{
	var m_maxDistance : Float;
	var m_statusEffectID : TweakDBID;
	var m_ownerID : EntityID;
	var m_statusEffectIsApplied : Bool;

	protected export override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		var statusEffectRecord : StatusEffect_Record;
		m_maxDistance = TDB.GetFloat( record + T".maxDistance" );
		statusEffectRecord = TDB.GetStatusEffectRecord( TDB.GetForeignKey( record + T".statusEffect" ) );
		if( statusEffectRecord )
		{
			m_statusEffectID = statusEffectRecord.GetID();
		}
	}

	protected export override function Uninitialize( game : GameInstance )
	{
		if( m_statusEffectIsApplied )
		{
			GameInstance.GetStatusEffectSystem( game ).RemoveStatusEffect( m_ownerID, m_statusEffectID );
			m_statusEffectIsApplied = false;
		}
	}

	protected override function ContinuousAction( owner : GameObject, instigator : GameObject )
	{
		m_ownerID = owner.GetEntityID();
		ProcessEffector( owner );
	}

	private function ProcessEffector( owner : GameObject )
	{
		var targets : array< TS_TargetPartInfo >;
		var searchQuery : TargetSearchQuery;
		if( !( TDBID.IsValid( m_statusEffectID ) ) )
		{
			return;
		}
		searchQuery.testedSet = TargetingSet.Complete;
		searchQuery.searchFilter = TSF_EnemyNPC();
		searchQuery.includeSecondaryTargets = false;
		searchQuery.maxDistance = m_maxDistance;
		searchQuery.filterObjectByDistance = true;
		GameInstance.GetTargetingSystem( owner.GetGame() ).GetTargetParts( owner, searchQuery, targets );
		if( targets.Size() > 0 )
		{
			if( m_statusEffectIsApplied )
			{
				StatusEffectHelper.RemoveStatusEffect( owner, m_statusEffectID );
				m_statusEffectIsApplied = false;
			}
		}
		else if( !( m_statusEffectIsApplied ) )
		{
			StatusEffectHelper.ApplyStatusEffect( owner, m_statusEffectID );
			m_statusEffectIsApplied = true;
		}
	}

}

