diff --git a/OpenRA.Mods.RA/Effects/RallyPoint.cs b/OpenRA.Mods.RA/Effects/RallyPoint.cs new file mode 100755 index 0000000000..618ef42943 --- /dev/null +++ b/OpenRA.Mods.RA/Effects/RallyPoint.cs @@ -0,0 +1,58 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using System.Collections.Generic; +using System.Linq; +using OpenRA.Effects; +using OpenRA.Graphics; +using OpenRA.Mods.RA; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Effects +{ + class RallyPoint : IEffect + { + Actor building; + RA.RallyPoint rp; + public Animation flag = new Animation("rallypoint"); + public Animation circles = new Animation("rallypoint"); + + public RallyPoint(Actor building) + { + this.building = building; + rp = building.Trait(); + flag.PlayRepeating("flag"); + circles.Play("circles"); + } + + public void Tick( World world ) + { + flag.Tick(); + circles.Tick(); + if (!building.IsInWorld || building.IsDead()) + world.AddFrameEndTask(w => w.Remove(this)); + } + + public IEnumerable Render() + { + if (building.IsInWorld && building.Owner == building.World.LocalPlayer && building.World.Selection.Actors.Contains(building)) + { + var pos = Traits.Util.CenterOfCell(rp.rallyPoint); + yield return new Renderable(circles.Image, + pos - .5f * circles.Image.size, + building.Owner.Palette, (int)pos.Y); + + yield return new Renderable(flag.Image, + pos + new float2(-1,-17), + building.Owner.Palette, (int)pos.Y); + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 3cead6e810..c54f30db40 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -324,6 +324,7 @@ + diff --git a/OpenRA.Mods.RA/RallyPoint.cs b/OpenRA.Mods.RA/RallyPoint.cs index 55a0dd2a30..4943dc1fa4 100755 --- a/OpenRA.Mods.RA/RallyPoint.cs +++ b/OpenRA.Mods.RA/RallyPoint.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Traits; +using OpenRA.Mods.RA.Effects; namespace OpenRA.Mods.RA { @@ -22,25 +23,16 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new RallyPoint(init.self); } } - public class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick + public class RallyPoint : IIssueOrder, IResolveOrder { [Sync] public int2 rallyPoint; - public Animation anim; public RallyPoint(Actor self) { var info = self.Info.Traits.Get(); rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]); - anim = new Animation("flagfly"); - anim.PlayRepeating("idle"); - } - - public IEnumerable Render(Actor self) - { - if (self.Owner == self.World.LocalPlayer && self.World.Selection.Actors.Contains(self)) - yield return Traits.Util.Centered(self, - anim.Image, Traits.Util.CenterOfCell(rallyPoint)); + self.World.AddFrameEndTask(w => w.Add(new Effects.RallyPoint(self))); } public IEnumerable Orders @@ -62,8 +54,6 @@ namespace OpenRA.Mods.RA rallyPoint = order.TargetLocation; } - public void Tick(Actor self) { anim.Tick(); } - class RallyPointOrderTargeter : IOrderTargeter { public string OrderID { get { return "SetRallyPoint"; } } @@ -76,7 +66,12 @@ namespace OpenRA.Mods.RA public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { - return self.World.Map.IsInMap(location); + if (self.World.Map.IsInMap(location)) + { + cursor = "ability"; + return true; + } + return false; } public bool IsQueued { get { return false; } } // unused diff --git a/mods/cnc/sequences/misc.yaml b/mods/cnc/sequences/misc.yaml index 12ec49cd5a..657fb8ad46 100644 --- a/mods/cnc/sequences/misc.yaml +++ b/mods/cnc/sequences/misc.yaml @@ -87,8 +87,11 @@ rank: Start: 0 Length: * -flagfly: - idle: +rallypoint: + flag:flagfly + Start: 0 + Length: * + circles:fpls Start: 0 Length: * diff --git a/mods/ra/sequences.yaml b/mods/ra/sequences.yaml index 406f67534e..a591a21179 100644 --- a/mods/ra/sequences.yaml +++ b/mods/ra/sequences.yaml @@ -849,8 +849,11 @@ v2: Start: 0 Facings: 32 -flagfly: - idle: +rallypoint: + flag:flagfly + Start: 0 + Length: * + circles:fpls Start: 0 Length: *