class SimpleTriggerAttackEffect extends Effector
{
	var m_owner : weak< GameObject >;
	var m_attackTDBID : TweakDBID;
	var m_shouldDelay : Bool;

	protected export override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		var effectorRecord : TriggerAttackEffector_Record;
		effectorRecord = TweakDBInterface.GetTriggerAttackEffectorRecord( record );
		m_attackTDBID = effectorRecord.AttackRecord().GetID();
		m_shouldDelay = TweakDBInterface.GetBool( record + T".shouldDelay", false );
	}

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

	protected override function ActionOn( owner : GameObject )
	{
		var i : Int32;
		var attack : Attack_GameEffect;
		var tempArr : array< String >;
		var flag : SHitFlag;
		var hitFlags : array< SHitFlag >;
		var delayEvent : TriggerAttackEffectorWithDelay;
		tempArr = TweakDBInterface.GetAttackRecord( m_attackTDBID ).HitFlags();
		for( i = 0; i < tempArr.Size(); i += 1 )
		{
			flag.flag = ( ( hitFlag )( ( ( Int32 )( EnumValueFromString( "hitFlag", tempArr[ i ] ) ) ) ) );
			flag.source = 'Attack';
			hitFlags.PushBack( flag );
		}
		attack = RPGManager.PrepareGameEffectAttack( owner.GetGame(), owner, owner, m_attackTDBID, , hitFlags, owner );
		if( m_shouldDelay )
		{
			delayEvent = new TriggerAttackEffectorWithDelay;
			delayEvent.attack = attack;
			owner.QueueEvent( delayEvent );
		}
		else
		{
			attack.StartAttack();
		}
		Uninitialize( owner.GetGame() );
	}

}

class TriggerAttackEffectorWithDelay extends Event
{
	var attack : Attack_GameEffect;
}

