add Effect.ChangeLighting(red, green, blue, ambient) to Lua API
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Eluant;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
@@ -18,11 +19,13 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public class EffectGlobal : ScriptGlobal
|
||||
{
|
||||
readonly IEnumerable<FlashPaletteEffect> fpes;
|
||||
readonly GlobalLightingPaletteEffect lighting;
|
||||
|
||||
public EffectGlobal(ScriptContext context)
|
||||
: base(context)
|
||||
{
|
||||
fpes = context.World.WorldActor.TraitsImplementing<FlashPaletteEffect>();
|
||||
lighting = context.World.WorldActor.TraitOrDefault<GlobalLightingPaletteEffect>();
|
||||
}
|
||||
|
||||
[Desc("Controls the `FlashPaletteEffect` trait.")]
|
||||
@@ -32,5 +35,17 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
if (fpe.Info.Type == type)
|
||||
fpe.Enable(ticks);
|
||||
}
|
||||
|
||||
[Desc("Dynamically adjusts the `GlobalLightingPaletteEffect` trait.")]
|
||||
public void ChangeLighting(double red, double green, double blue, double ambient)
|
||||
{
|
||||
if (lighting == null)
|
||||
throw new LuaException("GlobalLightingPaletteEffect needs to be added to the World actor first.");
|
||||
|
||||
lighting.Red = (float)red;
|
||||
lighting.Green = (float)green;
|
||||
lighting.Blue = (float)blue;
|
||||
lighting.Ambient = (float)ambient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user