Change WithColoredOverlay to use a color instead of a palette.
This commit is contained in:
@@ -19,17 +19,23 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Display a colored overlay when a timed condition is active.")]
|
[Desc("Display a colored overlay when a timed condition is active.")]
|
||||||
public class WithColoredOverlayInfo : ConditionalTraitInfo
|
public class WithColoredOverlayInfo : ConditionalTraitInfo
|
||||||
{
|
{
|
||||||
[PaletteReference]
|
[Desc("Color to overlay.")]
|
||||||
[Desc("Palette to use when rendering the overlay")]
|
public readonly Color Color = Color.FromArgb(128, 128, 0, 0);
|
||||||
public readonly string Palette = "invuln";
|
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new WithColoredOverlay(this); }
|
public override object Create(ActorInitializer init) { return new WithColoredOverlay(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithColoredOverlay : ConditionalTrait<WithColoredOverlayInfo>, IRenderModifier
|
public class WithColoredOverlay : ConditionalTrait<WithColoredOverlayInfo>, IRenderModifier
|
||||||
{
|
{
|
||||||
|
readonly float3 tint;
|
||||||
|
readonly float alpha;
|
||||||
|
|
||||||
public WithColoredOverlay(WithColoredOverlayInfo info)
|
public WithColoredOverlay(WithColoredOverlayInfo info)
|
||||||
: base(info) { }
|
: base(info)
|
||||||
|
{
|
||||||
|
tint = new float3(info.Color.R, info.Color.G, info.Color.B) / 255f;
|
||||||
|
alpha = info.Color.A / 255f;
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||||
{
|
{
|
||||||
@@ -45,10 +51,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
yield return a;
|
yield return a;
|
||||||
|
|
||||||
if (!a.IsDecoration && a is IPalettedRenderable)
|
if (!a.IsDecoration && a is IModifyableRenderable ma)
|
||||||
yield return ((IPalettedRenderable)a).WithPalette(wr.Palette(Info.Palette))
|
yield return ma.WithTint(tint, ma.TintModifiers | TintModifiers.ReplaceColor).WithAlpha(alpha);
|
||||||
.WithZOffset(a.ZOffset + 1)
|
|
||||||
.AsDecoration();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class ReplaceWithColoredOverlayPalette : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "WithColoredOverlay Palette changed to Color."; } }
|
||||||
|
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "The Palette field has been removed from WithColoredOverlay. You must now specify the Color directly.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly List<string> locations = new List<string>();
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
if (locations.Any())
|
||||||
|
yield return "You must define new Color fields on the following traits:\n" +
|
||||||
|
UpdateUtils.FormatMessageList(locations);
|
||||||
|
|
||||||
|
locations.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
foreach (var node in actorNode.ChildrenMatching("WithColoredOverlay"))
|
||||||
|
if (node.RemoveNodes("Palette") > 0)
|
||||||
|
locations.Add("{0}: {1} ({2})".F(actorNode.Key, node.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,6 +86,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
// Bleed only changes here
|
// Bleed only changes here
|
||||||
new RenameMPTraits(),
|
new RenameMPTraits(),
|
||||||
new RemovePlayerHighlightPalette(),
|
new RemovePlayerHighlightPalette(),
|
||||||
|
new ReplaceWithColoredOverlayPalette(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1019,7 +1019,7 @@
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
GenericName: Destroyed Vehicle
|
GenericName: Destroyed Vehicle
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
@@ -1118,7 +1118,7 @@
|
|||||||
ValidPowerStates: Low, Critical
|
ValidPowerStates: Low, Critical
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: lowpower
|
RequiresCondition: lowpower
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
|
|
||||||
^Selectable:
|
^Selectable:
|
||||||
Selectable:
|
Selectable:
|
||||||
|
|||||||
@@ -90,12 +90,6 @@
|
|||||||
G: 255
|
G: 255
|
||||||
B: 255
|
B: 255
|
||||||
A: 64
|
A: 64
|
||||||
PaletteFromRGBA@disabled:
|
|
||||||
Name: disabled
|
|
||||||
R: 0
|
|
||||||
G: 0
|
|
||||||
B: 0
|
|
||||||
A: 180
|
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
Name: shroud
|
Name: shroud
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
|
|||||||
@@ -269,7 +269,7 @@
|
|||||||
TargetTypes: Ground, Vehicle
|
TargetTypes: Ground, Vehicle
|
||||||
RequiresForceFire: true
|
RequiresForceFire: true
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeMed
|
Weapon: UnitExplodeMed
|
||||||
EmptyWeapon: UnitExplodeMed
|
EmptyWeapon: UnitExplodeMed
|
||||||
@@ -510,7 +510,7 @@
|
|||||||
^DisableOnLowPower:
|
^DisableOnLowPower:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: disabled
|
RequiresCondition: disabled
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
GrantConditionOnPowerState@LOWPOWER:
|
GrantConditionOnPowerState@LOWPOWER:
|
||||||
Condition: lowpower
|
Condition: lowpower
|
||||||
ValidPowerStates: Low, Critical
|
ValidPowerStates: Low, Critical
|
||||||
|
|||||||
@@ -38,12 +38,6 @@
|
|||||||
Scale: -1
|
Scale: -1
|
||||||
Offset: 255
|
Offset: 255
|
||||||
AllowModifiers: false
|
AllowModifiers: false
|
||||||
PaletteFromRGBA@disabled:
|
|
||||||
Name: disabled
|
|
||||||
R: 0
|
|
||||||
G: 0
|
|
||||||
B: 0
|
|
||||||
A: 180
|
|
||||||
PaletteFromPaletteWithAlpha@effect75alpha:
|
PaletteFromPaletteWithAlpha@effect75alpha:
|
||||||
Name: effect75alpha
|
Name: effect75alpha
|
||||||
BasePalette: effect
|
BasePalette: effect
|
||||||
|
|||||||
@@ -1011,7 +1011,7 @@
|
|||||||
Types: Husk
|
Types: Husk
|
||||||
ForceHealthPercentage: 25
|
ForceHealthPercentage: 25
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: GroundActor, Husk, NoAutoTarget
|
TargetTypes: GroundActor, Husk, NoAutoTarget
|
||||||
RequiresForceFire: true
|
RequiresForceFire: true
|
||||||
@@ -1187,7 +1187,7 @@
|
|||||||
^DisableOnLowPower:
|
^DisableOnLowPower:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: disabled
|
RequiresCondition: disabled
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
GrantConditionOnPowerState@LOWPOWER:
|
GrantConditionOnPowerState@LOWPOWER:
|
||||||
Condition: lowpower
|
Condition: lowpower
|
||||||
ValidPowerStates: Low, Critical
|
ValidPowerStates: Low, Critical
|
||||||
@@ -1225,7 +1225,7 @@
|
|||||||
^DisabledByPowerOutage:
|
^DisabledByPowerOutage:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: disabled
|
RequiresCondition: disabled
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
GrantCondition@IDISABLE:
|
GrantCondition@IDISABLE:
|
||||||
RequiresCondition: power-outage
|
RequiresCondition: power-outage
|
||||||
Condition: disabled
|
Condition: disabled
|
||||||
|
|||||||
@@ -64,24 +64,6 @@
|
|||||||
G: 255
|
G: 255
|
||||||
B: 255
|
B: 255
|
||||||
A: 64
|
A: 64
|
||||||
PaletteFromRGBA@invuln:
|
|
||||||
Name: invuln
|
|
||||||
R: 128
|
|
||||||
G: 0
|
|
||||||
B: 0
|
|
||||||
A: 128
|
|
||||||
PaletteFromRGBA@invuln2:
|
|
||||||
Name: invuln2
|
|
||||||
R: 0
|
|
||||||
G: 0
|
|
||||||
B: 128
|
|
||||||
A: 128
|
|
||||||
PaletteFromRGBA@disabled:
|
|
||||||
Name: disabled
|
|
||||||
R: 0
|
|
||||||
G: 0
|
|
||||||
B: 0
|
|
||||||
A: 180
|
|
||||||
ShroudPalette@shroud:
|
ShroudPalette@shroud:
|
||||||
Name: shroud
|
Name: shroud
|
||||||
ShroudPalette@fog:
|
ShroudPalette@fog:
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
^EmpVisualEffects:
|
^EmpVisualEffects:
|
||||||
WithColoredOverlay@EMPDISABLE:
|
WithColoredOverlay@EMPDISABLE:
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
WithIdleOverlay@EMPDISABLE:
|
WithIdleOverlay@EMPDISABLE:
|
||||||
Sequence: emp-overlay
|
Sequence: emp-overlay
|
||||||
Palette: effect
|
Palette: effect
|
||||||
@@ -1284,7 +1284,7 @@
|
|||||||
^DisableOnLowPower:
|
^DisableOnLowPower:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: disabled
|
RequiresCondition: disabled
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
GrantConditionOnPowerState@LOWPOWER:
|
GrantConditionOnPowerState@LOWPOWER:
|
||||||
Condition: lowpower
|
Condition: lowpower
|
||||||
ValidPowerStates: Low, Critical
|
ValidPowerStates: Low, Critical
|
||||||
@@ -1295,7 +1295,7 @@
|
|||||||
^DisableOnPowerDown:
|
^DisableOnPowerDown:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
RequiresCondition: disabled
|
RequiresCondition: disabled
|
||||||
Palette: disabled
|
Color: 000000B4
|
||||||
GrantCondition@IDISABLE:
|
GrantCondition@IDISABLE:
|
||||||
RequiresCondition: powerdown
|
RequiresCondition: powerdown
|
||||||
Condition: disabled
|
Condition: disabled
|
||||||
|
|||||||
@@ -111,12 +111,6 @@
|
|||||||
G: 255
|
G: 255
|
||||||
B: 255
|
B: 255
|
||||||
A: 64
|
A: 64
|
||||||
PaletteFromRGBA@disabled:
|
|
||||||
Name: disabled
|
|
||||||
R: 0
|
|
||||||
G: 0
|
|
||||||
B: 0
|
|
||||||
A: 180
|
|
||||||
TSShroudPalette@shroud:
|
TSShroudPalette@shroud:
|
||||||
Name: shroud
|
Name: shroud
|
||||||
VoxelNormalsPalette@normals:
|
VoxelNormalsPalette@normals:
|
||||||
|
|||||||
Reference in New Issue
Block a user