diff --git a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs index 366fefb1f7..0c3ac93922 100644 --- a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs +++ b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs @@ -20,16 +20,13 @@ namespace OpenRA.Mods.Common.Effects { readonly Actor building; readonly RallyPoint rp; - readonly string paletteName; readonly Animation flag; readonly Animation circles; - public RallyPointIndicator(Actor building, string paletteName) + public RallyPointIndicator(Actor building, RallyPoint rp) { this.building = building; - this.paletteName = paletteName; - - rp = building.Trait(); + this.rp = rp; flag = new Animation(building.World, rp.Info.Image); flag.PlayRepeating(rp.Info.FlagSequence); @@ -63,7 +60,7 @@ namespace OpenRA.Mods.Common.Effects return SpriteRenderable.None; var pos = wr.World.Map.CenterOfCell(cachedLocation); - var palette = wr.Palette(paletteName); + var palette = wr.Palette(rp.PaletteName); return circles.Render(pos, palette).Concat(flag.Render(pos, palette)); } } diff --git a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs index 61e5fda934..0c27c807c6 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs @@ -32,17 +32,24 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); } } - public class RallyPoint : IIssueOrder, IResolveOrder, ISync + public class RallyPoint : IIssueOrder, IResolveOrder, ISync, INotifyOwnerChanged { [Sync] public CPos Location; public RallyPointInfo Info; + public string PaletteName { get; private set; } public RallyPoint(Actor self, RallyPointInfo info) { Info = info; Location = self.Location + info.Offset; - var palette = info.IsPlayerPalette ? info.Palette + self.Owner.InternalName : info.Palette; - self.World.AddFrameEndTask(w => w.Add(new RallyPointIndicator(self, palette))); + PaletteName = info.IsPlayerPalette ? info.Palette + self.Owner.InternalName : info.Palette; + self.World.Add(new RallyPointIndicator(self, this)); + } + + public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + { + if (Info.IsPlayerPalette) + PaletteName = Info.Palette + newOwner.InternalName; } public IEnumerable Orders