class HoloDeviceController extends ScriptableDeviceComponent
{

	public const override function GetPS() : HoloDeviceControllerPS
	{
		return ( ( HoloDeviceControllerPS )( GetBasePS() ) );
	}

}

class HoloDeviceControllerPS extends ScriptableDeviceComponentPS
{
	default m_tweakDBRecord = T"Devices.HoloDevice";
	default m_tweakDBDescriptionRecord = T"device_descriptions.HoloDevice";
	private persistent var m_isPlaying : Bool;

	protected event OnInstantiated()
	{
		super.OnInstantiated();
		if( !( IsStringValid( m_deviceName ) ) )
		{
			m_deviceName = "LocKey#222";
		}
	}

	protected override function Initialize()
	{
		super.Initialize();
	}

	protected virtual function ActionTogglePlay() : TogglePlay
	{
		var action : TogglePlay;
		action = new TogglePlay;
		action.clearanceLevel = DefaultActionsParametersHolder.GetInteractiveClearance();
		action.SetUp( this );
		action.SetProperties( m_isPlaying );
		action.AddDeviceName( m_deviceName );
		return action;
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		super.GetActions( actions, context );
		if( !( IsUserAuthorized( context.processInitiatorObject.GetEntityID() ) ) )
		{
			return false;
		}
		if( TogglePlay.IsDefaultConditionMet( this, context ) )
		{
			actions.PushBack( ActionTogglePlay() );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	public function OnPlay( evt : TogglePlay ) : EntityNotificationType
	{
		if( IsUnpowered() || IsDisabled() )
		{
			return SendActionFailedEvent( evt, evt.GetRequesterID(), "Disabled or Unpowered" );
		}
		m_isPlaying = !( m_isPlaying );
		evt.prop.first = m_isPlaying;
		UseNotifier( evt );
		if( !( IsFinal() ) )
		{
		}
		return EntityNotificationType.SendThisEventToEntity;
	}

	public const override function GetClearance() : Clearance
	{
		return Clearance.CreateClearance( 2, 2 );
	}

	public function IsPlaying() : Bool
	{
		return m_isPlaying;
	}

}

