class DestructibleMasterDeviceController extends MasterController
{

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

}

class DestructibleMasterDeviceControllerPS extends MasterControllerPS
{
	protected var m_isDestroyed : Bool;

	protected event OnInstantiated()
	{
		super.OnInstantiated();
	}

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

	protected override function GameAttached() {}

	public const function IsDestroyed() : Bool
	{
		return m_isDestroyed;
	}

	protected override function OnRefreshSlavesEvent( evt : RefreshSlavesEvent ) : EntityNotificationType
	{
		m_isDestroyed = true;
		RefreshSlaves();
		return EntityNotificationType.DoNotNotifyEntity;
	}

	protected function RefreshSlaves()
	{
		var i : Int32;
		var evt : MasterDeviceDestroyed;
		var devices : array< DeviceComponentPS >;
		devices = GetImmediateSlaves();
		evt = ActionMasterDeviceDestroyed();
		for( i = 0; i < devices.Size(); i += 1 )
		{
			if( devices[ i ] && devices[ i ].IsAttachedToGame() )
			{
				ExecutePSAction( evt, devices[ i ] );
			}
		}
	}

	protected function ActionMasterDeviceDestroyed() : MasterDeviceDestroyed
	{
		var delayEvent : MasterDeviceDestroyed;
		delayEvent = new MasterDeviceDestroyed;
		delayEvent.SetUp( this );
		delayEvent.SetProperties();
		delayEvent.AddDeviceName( m_deviceName );
		return delayEvent;
	}

}

