Make player stance colours universally respected

This commit is contained in:
Gustas
2023-02-25 13:42:43 +02:00
committed by Matthias Mailänder
parent 2f331548e1
commit 5fc36bd45f
38 changed files with 110 additions and 88 deletions

View File

@@ -75,8 +75,8 @@ namespace OpenRA.Mods.Common.Traits
{
this.info = info;
startcolor = info.StartColorUsePlayerColor ? Color.FromArgb(info.StartColorAlpha, self.Owner.Color) : Color.FromArgb(info.StartColorAlpha, info.StartColor);
endcolor = info.EndColorUsePlayerColor ? Color.FromArgb(info.EndColorAlpha, self.Owner.Color) : Color.FromArgb(info.EndColorAlpha, info.EndColor ?? startcolor);
startcolor = info.StartColorUsePlayerColor ? Color.FromArgb(info.StartColorAlpha, Player.ActorColor(self)) : Color.FromArgb(info.StartColorAlpha, info.StartColor);
endcolor = info.EndColorUsePlayerColor ? Color.FromArgb(info.EndColorAlpha, Player.ActorColor(self)) : Color.FromArgb(info.EndColorAlpha, info.EndColor ?? startcolor);
trail = new ContrailRenderable(self.World, startcolor, endcolor, info.StartWidth, info.EndWidth ?? info.StartWidth, info.TrailLength, info.TrailDelay, info.ZOffset);
body = self.Trait<BodyOrientation>();

View File

@@ -30,7 +30,6 @@ namespace OpenRA.Mods.Common.Traits.Render
{
readonly DebugVisualizations debugVis;
readonly SpriteFont font;
readonly Actor self;
readonly WVec offset;
SquadManagerBotModule[] squadManagerModules;
@@ -43,8 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var yOffset = buildingInfo?.Dimensions.Y ?? 1;
offset = new WVec(0, 512 * yOffset, 0);
this.self = self;
color = GetColor();
color = self.OwnerColor();
font = Game.Renderer.Fonts[info.Font];
debugVis = self.World.WorldActor.TraitOrDefault<DebugVisualizations>();
@@ -60,15 +58,7 @@ namespace OpenRA.Mods.Common.Traits.Render
tagString = self.ToString();
}
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
color = GetColor();
}
Color GetColor()
{
return self.EffectiveOwner != null && self.EffectiveOwner.Disguised ? self.EffectiveOwner.Owner.Color : self.Owner.Color;
}
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) => color = self.OwnerColor();
IEnumerable<IRenderable> IRenderAnnotationsWhenSelected.RenderAnnotations(Actor self, WorldRenderer wr)
{

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
: base(self, info)
{
font = Game.Renderer.Fonts[info.Font];
color = info.UsePlayerColor ? self.Owner.Color : info.Color;
color = info.UsePlayerColor ? self.OwnerColor() : info.Color;
name = self.Owner.PlayerName;
if (name.Length > info.MaxLength)
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
if (Info.UsePlayerColor)
color = newOwner.Color;
color = self.OwnerColor();
name = self.Owner.PlayerName;
if (name.Length > Info.MaxLength)

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits.Render
self.CenterPosition,
Info.Range,
0,
Info.UsePlayerColor ? self.Owner.Color : Info.Color,
Info.UsePlayerColor ? self.OwnerColor() : Info.Color,
Info.Width,
Info.BorderColor,
Info.BorderWidth);

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits.Render
{
this.info = info;
font = Game.Renderer.Fonts[info.Font];
color = info.UsePlayerColor ? self.Owner.Color : info.Color;
color = info.UsePlayerColor ? self.OwnerColor() : info.Color;
label = new CachedTransform<int, string>(g => self.World.ControlGroups.Groups[g]);
}
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
if (info.UsePlayerColor)
color = newOwner.Color;
color = self.OwnerColor();
}
}
}

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
: base(self, info)
{
font = Game.Renderer.Fonts[info.Font];
color = info.UsePlayerColor ? self.Owner.Color : info.Color;
color = info.UsePlayerColor ? self.OwnerColor() : info.Color;
}
protected override IEnumerable<IRenderable> RenderDecoration(Actor self, WorldRenderer wr, int2 screenPos)
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
if (Info.UsePlayerColor)
color = newOwner.Color;
color = self.OwnerColor();
}
}
}