RallyPoint palette tracks owner

This commit is contained in:
atlimit8
2015-10-30 20:09:39 -05:00
parent 168dab9707
commit faa1a49604
2 changed files with 13 additions and 9 deletions

View File

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

View File

@@ -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<IOrderTargeter> Orders