enum ESmartHousePreset
{
	MorningPreset = 0,
	EveningPreset = 1,
	NightPreset = 2,
}

class ChangePresetEvent extends Event
{
	editable var presetID : ESmartHousePreset;

	public constexpr function GetFriendlyDescription() : String
	{
		return "Change Preset";
	}

}

class EnableTimeCallbacks extends Event
{

	public constexpr function GetFriendlyDescription() : String
	{
		return "Enable Time Callbacks";
	}

}

class DisableTimeCallbacks extends Event
{

	public constexpr function GetFriendlyDescription() : String
	{
		return "Disable Time Callbacks";
	}

}

class SmartHouse extends InteractiveMasterDevice
{
	default m_controllerTypeName = 'SmartHouseController';
	protected var m_timetableActive : Bool;
	default m_timetableActive = true;

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

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

	protected event OnGameAttached()
	{
		super.OnGameAttached();
		GetDevicePS().RegisterFactCallback();
	}

	protected event OnDetach()
	{
		super.OnDetach();
		GetDevicePS().UninitializeTimetable();
		GetDevicePS().UnregisterFactCallback();
	}

	protected event OnTimeTableCallback( evt : PresetTimetableEvent )
	{
		if( m_timetableActive )
		{
			GetDevicePS().ActivatePreset( evt.arrayPosition );
		}
	}

	protected event OnFactChanged( evt : FactChangedEvent )
	{
		super.OnFactChanged( evt );
		if( GetDevicePS().GetCustomizationFact() == evt.GetFactName() )
		{
			NotifyParents();
		}
	}

	protected event OnQuestChangePreset( evt : ChangePresetEvent )
	{
		GetDevicePS().QuestForcePreset( StringToName( ( ( String )( evt.presetID ) ) ) );
	}

	protected event OnEnableTimeCallbacks( evt : EnableTimeCallbacks )
	{
		m_timetableActive = true;
	}

	protected event OnDisableTimeCallbacks( evt : DisableTimeCallbacks )
	{
		m_timetableActive = false;
	}

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

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

}

