class DayPassedEvent extends Event
{
}

class ApartmentScreen extends LcdScreen
{
	default m_controllerTypeName = 'ApartmentScreenController';
	var timeSystemCallbackID : Uint32;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		EntityRequestComponentsInterface.RequestComponent( ri, 'ui', 'worlduiWidgetComponent', false );
		super.OnRequestComponents( ri );
	}

	public override function ResavePersistentData( ps : PersistentState ) : Bool
	{
		return false;
	}

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

	protected override function ResolveGameplayState()
	{
		super.ResolveGameplayState();
		RegisterDayUpdateCallback();
	}

	protected event OnDetach()
	{
		RegisterDayUpdateCallback();
		super.OnDetach();
	}

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

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

	private function RegisterDayUpdateCallback()
	{
		var timeout : GameTime;
		var entryTime : GameTime;
		var evt : DayPassedEvent;
		evt = new DayPassedEvent;
		timeout = GameTime.MakeGameTime( 0, 24, 0, 0 );
		entryTime = GameTime.MakeGameTime( 0, 24, 0, 0 );
		timeSystemCallbackID = GameInstance.GetTimeSystem( GetGame() ).RegisterIntervalListener( this, evt, entryTime, timeout, -1 );
	}

	private function UnregisterDayUpdateCallback()
	{
		if( timeSystemCallbackID > ( ( Uint32 )( 0 ) ) )
		{
			GameInstance.GetTimeSystem( GetGame() ).UnregisterListener( timeSystemCallbackID );
		}
	}

	protected event OnDayPassed( evt : DayPassedEvent )
	{
		GetDevicePS().UpdateRentState();
	}

	public const function GetCurrentRentStatus() : ERentStatus
	{
		return GetDevicePS().GetCurrentRentStatus();
	}

	public const function GetCurrentOverdueValue() : Int32
	{
		return GetDevicePS().GetCurrentOverdueValue();
	}

	public const function ShouldShowOverdueValue() : Bool
	{
		return GetDevicePS().ShouldShowOverdueValue();
	}

}

