class ElevatorTerminalLogicController extends DeviceWidgetControllerBase
{
	[ category = "Widget Refs" ]
	private editable var m_elevatorUpArrowsWidget : inkFlexRef;
	[ category = "Widget Refs" ]
	private editable var m_elevatorDownArrowsWidget : inkFlexRef;
	private var m_forcedElevatorArrowsState : EForcedElevatorArrowsState;

	protected event OnInitialize() {}

	public override function Initialize( gameController : DeviceInkGameControllerBase, widgetData : SDeviceWidgetPackage )
	{
		var isListEmpty : Bool;
		var terminal : Terminal;
		terminal = ( ( Terminal )( gameController.GetOwnerEntity() ) );
		if( terminal )
		{
			m_forcedElevatorArrowsState = terminal.GetDevicePS().GetForcedElevatorArrowsState();
		}
		super.Initialize( gameController, widgetData );
		isListEmpty = widgetData.actionWidgets.Size() == 0;
		inkFlexRef.SetVisible( m_elevatorDownArrowsWidget, false );
		inkFlexRef.SetVisible( m_elevatorUpArrowsWidget, false );
		if( m_forcedElevatorArrowsState != EForcedElevatorArrowsState.Disabled )
		{
			ForceFakeElevatorArrows( m_forcedElevatorArrowsState );
			return;
		}
		if( isListEmpty )
		{
			if( ( ( LiftWidgetCustomData )( widgetData.customData ) ).GetMovementState() == gamePlatformMovementState.MovingUp )
			{
				inkFlexRef.SetVisible( m_elevatorUpArrowsWidget, true );
				( ( ElevatorArrowsLogicController )( inkFlexRef.GetController( m_elevatorDownArrowsWidget ) ) ).PlayAnimationsArrowsUp();
			}
			else if( ( ( LiftWidgetCustomData )( widgetData.customData ) ).GetMovementState() == gamePlatformMovementState.MovingDown )
			{
				inkFlexRef.SetVisible( m_elevatorDownArrowsWidget, true );
				( ( ElevatorArrowsLogicController )( inkFlexRef.GetController( m_elevatorDownArrowsWidget ) ) ).PlayAnimationsArrowsDown();
			}
		}
		else
		{
			inkWidgetRef.SetVisible( m_actionsListWidget, true );
		}
	}

	public function ForceFakeElevatorArrows( arrowsState : EForcedElevatorArrowsState )
	{
		inkWidgetRef.SetVisible( m_actionsListWidget, false );
		inkFlexRef.SetVisible( m_elevatorDownArrowsWidget, false );
		inkFlexRef.SetVisible( m_elevatorUpArrowsWidget, false );
		if( arrowsState == EForcedElevatorArrowsState.ArrowsUp )
		{
			( ( ElevatorArrowsLogicController )( inkFlexRef.GetController( m_elevatorUpArrowsWidget ) ) ).PlayAnimationsArrowsUp();
			inkFlexRef.SetVisible( m_elevatorUpArrowsWidget, true );
		}
		else
		{
			( ( ElevatorArrowsLogicController )( inkFlexRef.GetController( m_elevatorDownArrowsWidget ) ) ).PlayAnimationsArrowsDown();
			inkFlexRef.SetVisible( m_elevatorDownArrowsWidget, true );
		}
	}

}

enum EForcedElevatorArrowsState
{
	Disabled = 0,
	ArrowsUp = 1,
	ArrowsDown = 2,
}

