Add a range marker to the nuke targeter.
This commit is contained in:
committed by
Paul Chote
parent
8f9c212921
commit
b32346d65f
@@ -9,14 +9,18 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
class NukePowerInfo : SupportPowerInfo
|
public class NukePowerInfo : SupportPowerInfo
|
||||||
{
|
{
|
||||||
[WeaponReference]
|
[WeaponReference]
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
@@ -99,6 +103,21 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Amount of time after detonation to remove the camera.")]
|
[Desc("Amount of time after detonation to remove the camera.")]
|
||||||
public readonly int CameraRemoveDelay = 25;
|
public readonly int CameraRemoveDelay = 25;
|
||||||
|
|
||||||
|
[Desc("Range circle color.")]
|
||||||
|
public readonly Color CircleColor = Color.FromArgb(128, Color.Red);
|
||||||
|
|
||||||
|
[Desc("Range circle width in pixel.")]
|
||||||
|
public readonly float CircleWidth = 1;
|
||||||
|
|
||||||
|
[Desc("Range circle border color.")]
|
||||||
|
public readonly Color CircleBorderColor = Color.FromArgb(64, Color.Red);
|
||||||
|
|
||||||
|
[Desc("Range circle border width in pixel.")]
|
||||||
|
public readonly float CircleBorderWidth = 3;
|
||||||
|
|
||||||
|
[Desc("Render circles based on these distance ranges while targeting.")]
|
||||||
|
public readonly WDist[] CircleRanges = null;
|
||||||
|
|
||||||
public WeaponInfo WeaponInfo { get; private set; }
|
public WeaponInfo WeaponInfo { get; private set; }
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
|
||||||
@@ -189,5 +208,41 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
||||||
|
{
|
||||||
|
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
||||||
|
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||||
|
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
||||||
|
self.World.OrderGenerator = new SelectNukePowerTarget(order, manager, info, MouseButton.Left);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SelectNukePowerTarget : SelectGenericPowerTarget
|
||||||
|
{
|
||||||
|
readonly NukePowerInfo info;
|
||||||
|
|
||||||
|
public SelectNukePowerTarget(string order, SupportPowerManager manager, NukePowerInfo info, MouseButton button)
|
||||||
|
: base(order, manager, info.Cursor, button)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World world)
|
||||||
|
{
|
||||||
|
if (info.CircleRanges == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var centerPosition = wr.World.Map.CenterOfCell(wr.Viewport.ViewToWorld(Viewport.LastMousePos));
|
||||||
|
foreach (var range in info.CircleRanges)
|
||||||
|
yield return new RangeCircleAnnotationRenderable(
|
||||||
|
centerPosition,
|
||||||
|
range,
|
||||||
|
0,
|
||||||
|
info.CircleColor,
|
||||||
|
info.CircleWidth,
|
||||||
|
info.CircleBorderColor,
|
||||||
|
info.CircleBorderWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user