class ToggleLight extends ActionBool
{

	public function SetProperties( status : worldTrafficLightColor )
	{
		var isGreen : Bool;
		actionName = 'ToggleLight';
		if( status == worldTrafficLightColor.GREEN )
		{
			isGreen = true;
		}
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( actionName, isGreen, 'LocKey#17842', 'LocKey#17843' );
	}

}

class TrafficLightGreen extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'TrafficLightGreen';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( actionName, true, 'LocKey#17842', 'LocKey#17842' );
	}

}

class TrafficLightRed extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'TrafficLightRed';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( actionName, true, 'LocKey#17843', 'LocKey#17843' );
	}

}

class TrafficLightController extends ScriptableDeviceComponent
{

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

}

class TrafficLightControllerPS extends ScriptableDeviceComponentPS
{
	default m_deviceName = "LocKey#127";
	default m_tweakDBRecord = T"Devices.TrafficLight";
	default m_tweakDBDescriptionRecord = T"device_descriptions.TrafficLight";

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

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

	protected override function GameAttached()
	{
		super.GameAttached();
		if( IsDisabled() )
		{
			ForceEnableDevice();
		}
	}

	public function IsMasterDestroyed() : Bool
	{
		var masters : array< DeviceComponentPS >;
		var i : Int32;
		var master : DestructibleMasterDeviceControllerPS;
		GetParents( masters );
		for( i = 0; i < masters.Size(); i += 1 )
		{
			master = ( ( DestructibleMasterDeviceControllerPS )( masters[ i ] ) );
			if( master )
			{
				return master.IsDestroyed();
			}
		}
		return false;
	}

	public function OnMasterDeviceDestroyed( evt : MasterDeviceDestroyed ) : EntityNotificationType
	{
		if( !( IsDisabled() ) )
		{
			ForceDisableDevice();
		}
		UseNotifier( evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

}

