class Window extends Door
{
	default m_controllerTypeName = 'WindowController';
	protected var m_soloCollider : IComponent;
	protected var m_strongSoloHandle : MeshComponent;
	private var m_duplicateDestruction : Bool;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
		EntityRequestComponentsInterface.RequestComponent( ri, 'solo_collider', 'IComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'solo_handle', 'MeshComponent', false );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		super.OnTakeControl( ri );
		m_soloCollider = ( ( IComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'solo_collider' ) ) );
		m_strongSoloHandle = ( ( MeshComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'solo_handle' ) ) );
		m_controller = ( ( WindowController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

	private const override function GetController() : WindowController
	{
		return ( ( WindowController )( m_controller ) );
	}

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

	protected event OnActionDemolition( evt : ActionDemolition )
	{
		if( m_strongSoloHandle && m_soloCollider )
		{
			m_strongSoloHandle.Toggle( false );
			m_soloCollider.Toggle( false );
		}
		else
		{
			super.OnActionDemolition( evt );
		}
	}

	protected event OnPhysicalDestructionEvent( evt : PhysicalDestructionEvent )
	{
		if( ( evt.levelOfDestruction == 0 ) && !( m_duplicateDestruction ) )
		{
			m_duplicateDestruction = true;
			if( IsConnectedToSecuritySystem() )
			{
				GetDevicePS().TriggerSecuritySystemNotification( GetPlayerMainObject(), GetWorldPosition(), ESecurityNotificationType.ILLEGAL_ACTION );
			}
		}
	}

	protected override function SetSoloAppearance()
	{
		if( m_strongSoloHandle && m_soloCollider )
		{
			if( GetDevicePS().IsDemolitionSkillCheckActive() )
			{
				if( !( m_strongSoloHandle.IsEnabled() ) )
				{
					m_strongSoloHandle.Toggle( true );
				}
				if( !( m_soloCollider.IsEnabled() ) )
				{
					m_soloCollider.Toggle( true );
				}
			}
			else
			{
				if( m_strongSoloHandle.IsEnabled() )
				{
					m_strongSoloHandle.Toggle( false );
				}
				if( m_soloCollider.IsEnabled() )
				{
					m_soloCollider.Toggle( false );
				}
			}
		}
	}

}

