class ApplyLightPresetEffector extends Effector
{
	var m_lightPreset : weak< LightPreset_Record >;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_lightPreset = TweakDBInterface.GetApplyLightPresetEffectorRecord( record ).LightPreset();
	}

	protected override function ActionOn( owner : GameObject )
	{
		var toggleLightEvent : ToggleLightEvent;
		var lightPreset : weak< LightPreset_Record >;
		toggleLightEvent = new ToggleLightEvent;
		toggleLightEvent.toggle = m_lightPreset.On();
		owner.QueueEvent( toggleLightEvent );
		lightPreset = m_lightPreset;
		if( m_lightPreset.OverrideColorMin() )
		{
			SendChangeLightEvent( owner, lightPreset.ColorMin(), 1.0, 0.0, '', false );
		}
		SendChangeLightEvent( owner, lightPreset.ColorMax(), lightPreset.Strength(), lightPreset.Time(), lightPreset.Curve(), lightPreset.Loop() );
	}

	protected function SendChangeLightEvent( owner : weak< GameObject >, const colorValues : ref< array< Int32 > >, strength : Float, time : Float, curve : CName, loop : Bool )
	{
		var changeLightEvent : ChangeLightEvent;
		var lightSettings : ScriptLightSettings;
		lightSettings.color = Color( ( ( Uint8 )( colorValues[ 0 ] ) ), ( ( Uint8 )( colorValues[ 1 ] ) ), ( ( Uint8 )( colorValues[ 2 ] ) ), ( ( Uint8 )( colorValues[ 3 ] ) ) );
		lightSettings.strength = strength;
		changeLightEvent = new ChangeLightEvent;
		changeLightEvent.time = time;
		changeLightEvent.curve = curve;
		changeLightEvent.loop = loop;
		changeLightEvent.settings = lightSettings;
		owner.QueueEvent( changeLightEvent );
	}

}

