RallyPoint palette tracks owner
This commit is contained in:
@@ -20,16 +20,13 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
{
|
{
|
||||||
readonly Actor building;
|
readonly Actor building;
|
||||||
readonly RallyPoint rp;
|
readonly RallyPoint rp;
|
||||||
readonly string paletteName;
|
|
||||||
readonly Animation flag;
|
readonly Animation flag;
|
||||||
readonly Animation circles;
|
readonly Animation circles;
|
||||||
|
|
||||||
public RallyPointIndicator(Actor building, string paletteName)
|
public RallyPointIndicator(Actor building, RallyPoint rp)
|
||||||
{
|
{
|
||||||
this.building = building;
|
this.building = building;
|
||||||
this.paletteName = paletteName;
|
this.rp = rp;
|
||||||
|
|
||||||
rp = building.Trait<RallyPoint>();
|
|
||||||
|
|
||||||
flag = new Animation(building.World, rp.Info.Image);
|
flag = new Animation(building.World, rp.Info.Image);
|
||||||
flag.PlayRepeating(rp.Info.FlagSequence);
|
flag.PlayRepeating(rp.Info.FlagSequence);
|
||||||
@@ -63,7 +60,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
return SpriteRenderable.None;
|
return SpriteRenderable.None;
|
||||||
|
|
||||||
var pos = wr.World.Map.CenterOfCell(cachedLocation);
|
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));
|
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,17 +32,24 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
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;
|
[Sync] public CPos Location;
|
||||||
public RallyPointInfo Info;
|
public RallyPointInfo Info;
|
||||||
|
public string PaletteName { get; private set; }
|
||||||
|
|
||||||
public RallyPoint(Actor self, RallyPointInfo info)
|
public RallyPoint(Actor self, RallyPointInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
Location = self.Location + info.Offset;
|
Location = self.Location + info.Offset;
|
||||||
var palette = info.IsPlayerPalette ? info.Palette + self.Owner.InternalName : info.Palette;
|
PaletteName = info.IsPlayerPalette ? info.Palette + self.Owner.InternalName : info.Palette;
|
||||||
self.World.AddFrameEndTask(w => w.Add(new RallyPointIndicator(self, 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
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
|
|||||||
Reference in New Issue
Block a user