class InteractiveMasterDevice extends InteractiveDevice
{

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

	protected const override function GetController() : MasterController
	{
		return ( ( MasterController )( m_controller ) );
	}

	protected override function CreateBlackboard()
	{
		m_blackboard = IBlackboard.Create( GetAllBlackboardDefs().MasterDeviceBaseBlackboard );
	}

	public const override function GetBlackboardDef() : MasterDeviceBaseBlackboardDef
	{
		return GetDevicePS().GetBlackboardDef();
	}

	protected event OnSlaveStateChanged( evt : PSDeviceChangedEvent )
	{
		m_isUIdirty = true;
		super.OnSlaveStateChanged( evt );
	}

	protected event OnRequestSlaveThumbnailWidgetsUpdate( evt : RequestThumbnailWidgetsUpdateEvent )
	{
		RequestThumbnailWidgetsUpdate( GetBlackboard() );
	}

	public const virtual function GetDefaultGlitchVideoPath() : ResRef
	{
		return R"";
	}

	public const virtual function GetBroadcastGlitchVideoPath() : ResRef
	{
		return R"";
	}

	protected event OnDeviceWidgetUpdate( evt : RequestDeviceWidgetUpdateEvent )
	{
		if( PersistentID.IsDefined( evt.requester ) )
		{
			RequestDeviceWidgetsUpdate( GetBlackboard(), evt.requester );
		}
		else
		{
			RequestDeviceWidgetsUpdate( GetBlackboard() );
		}
	}

	protected event OnRequestSlaveDevicesWidgetsUpdate( evt : RequestDeviceWidgetsUpdateEvent )
	{
		RequestDeviceWidgetsUpdate( GetBlackboard(), evt.requesters );
	}

	protected override function RequestThumbnailWidgetsUpdate( blackboard : IBlackboard )
	{
		GetDevicePS().RequestThumbnailWidgetsUpdate( blackboard );
	}

	protected function RequestDeviceWidgetsUpdate( blackboard : IBlackboard, const devices : ref< array< PersistentID > > )
	{
		GetDevicePS().RequestDeviceWidgetsUpdate( blackboard, devices );
	}

	protected function RequestDeviceWidgetsUpdate( blackboard : IBlackboard, deviceID : PersistentID )
	{
		GetDevicePS().RequestDeviceWidgetsUpdate( blackboard, deviceID );
	}

	public const virtual function ShouldShowTerminalTitle() : Bool
	{
		return false;
	}

	protected override function NotifyConnectionHighlightSystem( IsHighlightON : Bool, IsHighlightedByMasterDevice : Bool ) : Bool
	{
		var slaveDevices : array< DeviceComponentPS >;
		var i : Int32;
		var highlightEvent : NotifyHighlightedDevice;
		if( !( super.NotifyConnectionHighlightSystem( IsHighlightON, IsHighlightedByMasterDevice ) ) )
		{
			return false;
		}
		slaveDevices = GetDevicePS().GetImmediateSlaves();
		highlightEvent = new NotifyHighlightedDevice;
		highlightEvent.IsDeviceHighlighted = IsHighlightON;
		highlightEvent.IsNotifiedByMasterDevice = true;
		for( i = 0; i < slaveDevices.Size(); i += 1 )
		{
			GameInstance.GetPersistencySystem( GetGame() ).QueuePSEvent( slaveDevices[ i ].GetID(), slaveDevices[ i ].GetClassName(), highlightEvent );
		}
		return true;
	}

	protected event OnSetAsQuestImportantEvent( evt : SetAsQuestImportantEvent )
	{
		super.OnSetAsQuestImportantEvent( evt );
		if( evt.PropagateToSlaves() )
		{
			GetDevicePS().SetSlavesAsQuestImportant( evt.IsImportant() );
		}
	}

	protected event OnPerformedAction( evt : PerformedAction )
	{
		var skillcheckAction : ActionSkillCheck;
		var authOffAction : SetAuthorizationModuleOFF;
		super.OnPerformedAction( evt );
		skillcheckAction = ( ( ActionSkillCheck )( evt.m_action ) );
		authOffAction = ( ( SetAuthorizationModuleOFF )( evt.m_action ) );
		if( authOffAction )
		{
			SucceedGameplayObjective( GetDevicePS().GetControlPanelObjectiveData() );
		}
		if( skillcheckAction )
		{
			if( skillcheckAction.IsCompleted() )
			{
				SucceedGameplayObjective( GetDevicePS().GetControlPanelObjectiveData() );
			}
		}
	}

	public virtual function ShouldAlwaysUpdateDeviceWidgets() : Bool
	{
		return false;
	}

	protected event OnCleanPasswordEvent( evt : CleanPasswordEvent )
	{
		if( GetBlackboard() )
		{
			GetBlackboard().SetBool( GetBlackboardDef().CleanPassword, true );
			GetBlackboard().SignalBool( GetBlackboardDef().CleanPassword );
			GetBlackboard().FireCallbacks();
		}
	}

}

class CleanPasswordEvent extends Event
{
}

