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

@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits
{
var temp = currentDisplayValue;
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color, FloatingText.FormatCashTick(temp), 30)));
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.OwnerColor(), FloatingText.FormatCashTick(temp), 30)));
currentDisplayTick = info.TickRate;
currentDisplayValue = 0;
}

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
void AddCashTick(Actor self, int amount)
{
self.World.AddFrameEndTask(w => w.Add(
new FloatingText(self.CenterPosition, self.Owner.Color, FloatingText.FormatCashTick(amount), info.DisplayDuration)));
new FloatingText(self.CenterPosition, self.OwnerColor(), FloatingText.FormatCashTick(amount), info.DisplayDuration)));
}
void ModifyCash(Actor self, int amount)

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
var maxHP = healthInfo.MaxHP > 0 ? healthInfo.MaxHP : 1;
var damageText = $"{-e.Damage.Value} ({e.Damage.Value * 100 / maxHP}%)";
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color, damageText, 30)));
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.OwnerColor(), damageText, 30)));
}
}
}

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
var amount = collector.Owner.PlayerActor.Trait<PlayerResources>().ChangeCash(info.Amount);
if (info.UseCashTick)
w.Add(new FloatingText(collector.CenterPosition, collector.Owner.Color, FloatingText.FormatCashTick(amount), 30));
w.Add(new FloatingText(collector.CenterPosition, collector.OwnerColor(), FloatingText.FormatCashTick(amount), 30));
});
base.Activate(collector);

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
{
foreach (var exitCell in exitCells)
{
var color = self.Owner.Color;
var color = self.OwnerColor();
var vec = exitCell - self.Location;
var center = wr.World.Map.CenterOfCell(exitCell);
yield return new TextAnnotationRenderable(manager.Font, center, 0, color, vec.ToString());
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits
continue;
var exitCellCenter = self.World.Map.CenterOfCell(exitCells[i]);
yield return new LineAnnotationRenderable(spawnPos, exitCellCenter, 1, self.Owner.Color);
yield return new LineAnnotationRenderable(spawnPos, exitCellCenter, 1, self.OwnerColor());
}
}
}

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
var displayedBounty = GetDisplayedBountyValue(self);
if (Info.ShowBounty && self.IsInWorld && displayedBounty != 0 && e.Attacker.Owner.IsAlliedWith(self.World.RenderPlayer))
e.Attacker.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color, FloatingText.FormatCashTick(displayedBounty), 30)));
e.Attacker.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.OwnerColor(), FloatingText.FormatCashTick(displayedBounty), 30)));
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().ChangeCash(GetBountyValue(self));
}

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
return;
self.World.AddFrameEndTask(w => w.Add(
new FloatingText(self.CenterPosition, self.Owner.Color, FloatingText.FormatCashTick(amount), info.DisplayDuration)));
new FloatingText(self.CenterPosition, self.OwnerColor(), FloatingText.FormatCashTick(amount), info.DisplayDuration)));
}
}
}

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
playerRadarPing = radarPings.Add(
() => self.Owner.IsAlliedWith(self.World.RenderPlayer),
order.Target.CenterPosition,
self.Owner.Color,
self.OwnerColor(),
info.Duration);
}
});

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Radar
if (IsTraitDisabled || (viewer != null && !Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(viewer))))
return;
var color = Game.Settings.Game.UsePlayerStanceColors ? Player.PlayerRelationshipColor(self) : self.Owner.Color;
var color = self.OwnerColor();
if (modifier != null)
color = modifier.RadarColorOverride(self, color);

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();
}
}
}