unhardcode rallypoint sprites
This commit is contained in:
@@ -20,22 +20,22 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
{
|
{
|
||||||
readonly Actor building;
|
readonly Actor building;
|
||||||
readonly RallyPoint rp;
|
readonly RallyPoint rp;
|
||||||
readonly string palettePrefix;
|
readonly string paletteName;
|
||||||
readonly Animation flag;
|
readonly Animation flag;
|
||||||
readonly Animation circles;
|
readonly Animation circles;
|
||||||
|
|
||||||
public RallyPointIndicator(Actor building, string palettePrefix)
|
public RallyPointIndicator(Actor building, string paletteName)
|
||||||
{
|
{
|
||||||
this.building = building;
|
this.building = building;
|
||||||
this.palettePrefix = palettePrefix;
|
this.paletteName = paletteName;
|
||||||
|
|
||||||
rp = building.Trait<RallyPoint>();
|
rp = building.Trait<RallyPoint>();
|
||||||
|
|
||||||
flag = new Animation(building.World, "rallypoint");
|
flag = new Animation(building.World, rp.Info.Image);
|
||||||
circles = new Animation(building.World, "rallypoint");
|
flag.PlayRepeating(rp.Info.FlagSequence);
|
||||||
|
|
||||||
flag.PlayRepeating("flag");
|
circles = new Animation(building.World, rp.Info.Image);
|
||||||
circles.Play("circles");
|
circles.Play(rp.Info.CirclesSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPos cachedLocation;
|
CPos cachedLocation;
|
||||||
@@ -43,10 +43,11 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
{
|
{
|
||||||
flag.Tick();
|
flag.Tick();
|
||||||
circles.Tick();
|
circles.Tick();
|
||||||
|
|
||||||
if (cachedLocation != rp.Location)
|
if (cachedLocation != rp.Location)
|
||||||
{
|
{
|
||||||
cachedLocation = rp.Location;
|
cachedLocation = rp.Location;
|
||||||
circles.Play("circles");
|
circles.Play(rp.Info.CirclesSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!building.IsInWorld || building.IsDead)
|
if (!building.IsInWorld || building.IsDead)
|
||||||
@@ -62,7 +63,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(palettePrefix + building.Owner.InternalName);
|
var palette = wr.Palette(paletteName);
|
||||||
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
|
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Used to waypoint units after production or repair is finished.")]
|
[Desc("Used to waypoint units after production or repair is finished.")]
|
||||||
public class RallyPointInfo : ITraitInfo
|
public class RallyPointInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string IndicatorPalettePrefix = "player";
|
public readonly string Image = "rallypoint";
|
||||||
|
[SequenceReference("Image")] public readonly string FlagSequence = "flag";
|
||||||
|
[SequenceReference("Image")] public readonly string CirclesSequence = "circles";
|
||||||
|
|
||||||
|
[Desc("Custom indicator palette name")]
|
||||||
|
public readonly string Palette = "player";
|
||||||
|
|
||||||
|
[Desc("Custom palette is a player palette BaseName")]
|
||||||
|
public readonly bool IsPlayerPalette = true;
|
||||||
|
|
||||||
public readonly CVec Offset = new CVec(1, 3);
|
public readonly CVec Offset = new CVec(1, 3);
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
public object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
||||||
@@ -26,11 +35,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public class RallyPoint : IIssueOrder, IResolveOrder, ISync
|
public class RallyPoint : IIssueOrder, IResolveOrder, ISync
|
||||||
{
|
{
|
||||||
[Sync] public CPos Location;
|
[Sync] public CPos Location;
|
||||||
|
public RallyPointInfo Info;
|
||||||
|
|
||||||
public RallyPoint(Actor self, RallyPointInfo info)
|
public RallyPoint(Actor self, RallyPointInfo info)
|
||||||
{
|
{
|
||||||
Location = self.Location + info.RallyPoint;
|
Info = info;
|
||||||
self.World.AddFrameEndTask(w => w.Add(new RallyPointIndicator(self, info.IndicatorPalettePrefix)));
|
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
|
|||||||
Reference in New Issue
Block a user