class SecurityGateResponse extends Event
{
	var scanSuccessful : Bool;
}

class InitiateScanner extends Event
{
	var trespasserEntryIndex : Int32;
}

class SecurityGate extends InteractiveMasterDevice
{
	default m_controllerTypeName = 'SecurityGateController';
	private var m_sideA : TriggerComponent;
	private var m_sideB : TriggerComponent;
	private var m_scanningArea : TriggerComponent;
	private var m_trespassersDataList : array< TrespasserEntry >;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
		EntityRequestComponentsInterface.RequestComponent( ri, 'sideA', 'gameStaticTriggerAreaComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'sideB', 'gameStaticTriggerAreaComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'scanningArea', 'gameStaticTriggerAreaComponent', false );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_sideA = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'sideA' ) ) );
		m_sideB = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'sideB' ) ) );
		m_scanningArea = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'scanningArea' ) ) );
		super.OnTakeControl( ri );
		m_controller = ( ( SecurityGateController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

	public const override function GetDevicePS() : SecurityGateControllerPS
	{
		return GetController().GetPS();
	}

	private const override function GetController() : SecurityGateController
	{
		return ( ( SecurityGateController )( m_controller ) );
	}

	protected event OnAreaEnter( evt : AreaEnteredEvent )
	{
		GetDevicePS().UpdateTrespassersList( evt, true );
	}

	protected event OnAreaExit( evt : AreaExitedEvent )
	{
		GetDevicePS().UpdateTrespassersList( evt, false );
	}

	protected event OnSecurityGateResponse( evt : SecurityGateResponse )
	{
		GameObjectEffectHelper.BreakEffectLoopEvent( this, 'scan' );
	}

	protected event OnInitiateScanner( evt : InitiateScanner )
	{
		GameObjectEffectHelper.StartEffectEvent( this, 'scan' );
	}

	protected override function StartGlitching( glitchState : EGlitchState, optional intensity : Float )
	{
		GetDevicePS().TurnAuthorizationModuleOFF();
		GameObjectEffectHelper.StartEffectEvent( this, 'fx_distraction' );
	}

	protected override function StopGlitching()
	{
		GetDevicePS().TurnAuthorizationModuleON();
		GameObjectEffectHelper.BreakEffectLoopEvent( this, 'fx_distraction' );
	}

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

}

