class RemoveStatusEffectsEffector extends Effector
{
	private var m_effectTypes : array< String >;
	private var m_effectString : array< String >;
	private var m_effectTags : array< CName >;

	protected export override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_effectString = TDB.GetStringArray( record + T".statusEffects" );
		m_effectTypes = TDB.GetStringArray( record + T".effectTypes" );
		m_effectTags = TDB.GetCNameArray( record + T".effectTags" );
	}

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

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

	private function ProcessAction( owner : GameObject )
	{
		var i : Int32;
		var type : gamedataStatusEffectType;
		for( i = 0; i < m_effectString.Size(); i += 1 )
		{
			StatusEffectHelper.RemoveStatusEffect( owner, TDBID.Create( m_effectString[ i ] ) );
		}
		for( i = 0; i < m_effectTypes.Size(); i += 1 )
		{
			type = ( ( gamedataStatusEffectType )( ( ( Int32 )( EnumValueFromString( "gamedataStatusEffectType", m_effectTypes[ i ] ) ) ) ) );
			if( type != gamedataStatusEffectType.Invalid )
			{
				StatusEffectHelper.RemoveAllStatusEffectsByType( owner, type );
			}
		}
		for( i = 0; i < m_effectTags.Size(); i += 1 )
		{
			StatusEffectHelper.RemoveStatusEffectsWithTag( owner, m_effectTags[ i ] );
		}
	}

}

class RemoveStatusEffectOnAttackEffector extends ModifyAttackEffector
{
	private var m_effectTypes : array< String >;
	private var m_effectString : array< String >;
	private var m_effectTags : array< CName >;
	var m_owner : weak< GameObject >;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_effectString = TDB.GetStringArray( record + T".statusEffects" );
		m_effectTypes = TDB.GetStringArray( record + T".effectTypes" );
		m_effectTags = TDB.GetCNameArray( record + T".effectTags" );
	}

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

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

	private function ProcessAction( owner : GameObject )
	{
		var i : Int32;
		var type : gamedataStatusEffectType;
		var hitEvent : gameHitEvent;
		hitEvent = GetHitEvent();
		for( i = 0; i < m_effectString.Size(); i += 1 )
		{
			StatusEffectHelper.RemoveStatusEffect( hitEvent.target, TDBID.Create( m_effectString[ i ] ) );
		}
		for( i = 0; i < m_effectTypes.Size(); i += 1 )
		{
			type = ( ( gamedataStatusEffectType )( ( ( Int32 )( EnumValueFromString( "gamedataStatusEffectType", m_effectTypes[ i ] ) ) ) ) );
			if( type != gamedataStatusEffectType.Invalid )
			{
				StatusEffectHelper.RemoveAllStatusEffectsByType( hitEvent.target, type );
			}
		}
		for( i = 0; i < m_effectTags.Size(); i += 1 )
		{
			StatusEffectHelper.RemoveStatusEffectsWithTag( hitEvent.target, m_effectTags[ i ] );
		}
	}

}

class RemoveDOTStatusEffectsEffector extends Effector
{
	protected var m_ownerEntityID : EntityID;
	protected var m_delay : Float;

	protected export override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_delay = TDB.GetFloat( record + T".delay" );
	}

	protected export override function ActionOn( owner : GameObject )
	{
		m_ownerEntityID = owner.GetEntityID();
		if( owner && ( m_delay >= 0.0 ) )
		{
			StatusEffectHelper.RemoveStatusEffectsWithTag( owner, 'DoT', m_delay );
		}
	}

	protected export override function Uninitialize( game : GameInstance )
	{
		if( EntityID.IsDefined( m_ownerEntityID ) && ( m_delay < 0.0 ) )
		{
			StatusEffectHelper.RemoveStatusEffectsWithTag( game, m_ownerEntityID, 'DoT' );
		}
	}

}

