Rallypoint Polish: Improved artwork, correct positioning, doesn't disappear when the building is offscreen, targeting cursor.

This commit is contained in:
Paul Chote
2010-11-27 14:27:03 +13:00
parent d6733e62d6
commit d559b5cdb7
5 changed files with 78 additions and 18 deletions

View File

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

View File

@@ -324,6 +324,7 @@
<Compile Include="Widgets\Delegates\SettingsMenuDelegate.cs" /> <Compile Include="Widgets\Delegates\SettingsMenuDelegate.cs" />
<Compile Include="Widgets\Delegates\VideoPlayerDelegate.cs" /> <Compile Include="Widgets\Delegates\VideoPlayerDelegate.cs" />
<Compile Include="TargetableSubmarine.cs" /> <Compile Include="TargetableSubmarine.cs" />
<Compile Include="Effects\RallyPoint.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -22,25 +23,16 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new RallyPoint(init.self); } public object Create(ActorInitializer init) { return new RallyPoint(init.self); }
} }
public class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick public class RallyPoint : IIssueOrder, IResolveOrder
{ {
[Sync] [Sync]
public int2 rallyPoint; public int2 rallyPoint;
public Animation anim;
public RallyPoint(Actor self) public RallyPoint(Actor self)
{ {
var info = self.Info.Traits.Get<RallyPointInfo>(); var info = self.Info.Traits.Get<RallyPointInfo>();
rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]); rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]);
anim = new Animation("flagfly"); self.World.AddFrameEndTask(w => w.Add(new Effects.RallyPoint(self)));
anim.PlayRepeating("idle");
}
public IEnumerable<Renderable> 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));
} }
public IEnumerable<IOrderTargeter> Orders public IEnumerable<IOrderTargeter> Orders
@@ -62,8 +54,6 @@ namespace OpenRA.Mods.RA
rallyPoint = order.TargetLocation; rallyPoint = order.TargetLocation;
} }
public void Tick(Actor self) { anim.Tick(); }
class RallyPointOrderTargeter : IOrderTargeter class RallyPointOrderTargeter : IOrderTargeter
{ {
public string OrderID { get { return "SetRallyPoint"; } } public string OrderID { get { return "SetRallyPoint"; } }
@@ -76,7 +66,12 @@ namespace OpenRA.Mods.RA
public bool CanTargetLocation(Actor self, int2 location, List<Actor> actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) public bool CanTargetLocation(Actor self, int2 location, List<Actor> 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 public bool IsQueued { get { return false; } } // unused

View File

@@ -87,8 +87,11 @@ rank:
Start: 0 Start: 0
Length: * Length: *
flagfly: rallypoint:
idle: flag:flagfly
Start: 0
Length: *
circles:fpls
Start: 0 Start: 0
Length: * Length: *

View File

@@ -849,8 +849,11 @@ v2:
Start: 0 Start: 0
Facings: 32 Facings: 32
flagfly: rallypoint:
idle: flag:flagfly
Start: 0
Length: *
circles:fpls
Start: 0 Start: 0
Length: * Length: *