class ActivatedDeviceIndustrialArm extends ActivatedDeviceTrap
{
	default m_controllerTypeName = 'ActivatedDeviceController';
	instanceeditable var m_loopAnimation : EIndustrialArmAnimations;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		super.OnTakeControl( ri );
		m_controller = ( ( ActivatedDeviceController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

	protected override function ResolveGameplayState()
	{
		super.ResolveGameplayState();
		RefreshAnimation();
	}

	public const override function DeterminGameplayRole() : EGameplayRole
	{
		return EGameplayRole.Distract;
	}

	protected event OnAreaEnter( evt : AreaEnteredEvent )
	{
		if( GetDevicePS().ShouldActivateTrapOnAreaEnter() && !( GetDevicePS().IsDisabled() ) )
		{
			SendIndustrialArmAnimFeature( ( ( Int32 )( m_loopAnimation ) ), true, false, false );
			SpawnVFXs( GetDevicePS().GetVFX() );
			SendIndustrialArmDamageEvent();
		}
	}

	protected function SendIndustrialArmDamageEvent()
	{
		var evt : IndustrialArmDamageEvent;
		evt = new IndustrialArmDamageEvent;
		GameInstance.GetDelaySystem( GetGame() ).DelayEvent( this, evt, GetDevicePS().GetAnimationTime() );
	}

	protected event OnQuestSetIndustrialArmAnimationOverride( evt : QuestSetIndustrialArmAnimationOverride )
	{
		RefreshAnimation();
	}

	protected event OnIndustrialArmDamageEvent( evt : IndustrialArmDamageEvent )
	{
		DoAttack( GetDevicePS().GetAttackType() );
	}

	protected event OnAreaExit( evt : AreaExitedEvent )
	{
		RefreshAnimation();
	}

	protected override function RefreshAnimation()
	{
		if( GetDevicePS().GetIndustrialArmAnimationOverride() != -1 )
		{
			SendIndustrialArmAnimFeature( GetDevicePS().GetIndustrialArmAnimationOverride(), false, false, false );
		}
		else
		{
			SendIndustrialArmAnimFeature( ( ( Int32 )( m_loopAnimation ) ), false, false, false );
		}
	}

	protected override function StartGlitching( glitchState : EGlitchState, optional intensity : Float )
	{
		GameObjectEffectHelper.ActivateEffectAction( this, gamedataFxActionType.Start, GetDevicePS().GetActivationVFXname() );
		SendIndustrialArmAnimFeature( ( ( Int32 )( m_loopAnimation ) ), false, true, false );
	}

	protected override function StopGlitching()
	{
		GameObjectEffectHelper.ActivateEffectAction( this, gamedataFxActionType.BreakLoop, GetDevicePS().GetActivationVFXname() );
		RefreshAnimation();
	}

	protected function SendIndustrialArmAnimFeature( idleAnimNumber : Int32, isRotate : Bool, isDistraction : Bool, isPoke : Bool )
	{
		var animFeature : AnimFeature_IndustrialArm;
		animFeature = new AnimFeature_IndustrialArm;
		animFeature.idleAnimNumber = idleAnimNumber;
		animFeature.isRotate = isRotate;
		animFeature.isDistraction = isDistraction;
		animFeature.isPoke = isPoke;
		ApplyAnimFeatureToReplicate( this, 'IndustrialArm', animFeature );
	}

}

enum EIndustrialArmAnimations
{
	Idle = 0,
	RepairLoop = 1,
	RepairLoop2 = 2,
	RepairLoopBroken = 3,
	RepairLoopBelow = 4,
	RepairLoopBelowBroken = 5,
	CarDestroy = 6,
	Repair_below_loop_high = 7,
	Repair_below_loop_low = 8,
	Repair_below_loop_medium = 9,
	Repair_loop_high = 10,
	Repair_loop_medium = 11,
}

class IndustrialArmDamageEvent extends Event
{
}

