Files
OpenRA/OpenRA.Mods.RA/Traits/Attack/AttackLeap.cs
Taryn Hill 4ed53c5952 Simplify return statements.
Remove redundant ‘this’.
Remove unused using directives.
Simplify LINQ chains.
Add some trait property descriptions.
Add readonly where viable.
Add fullstops to some yaml descriptions.
2015-04-01 12:33:17 -05:00

54 lines
1.4 KiB
C#

#region Copyright & License Information
/*
* Copyright 2007-2015 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 COPYING.
*/
#endregion
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
[Desc("Dogs use this attack model.")]
class AttackLeapInfo : AttackFrontalInfo
{
[Desc("Leap speed (in units/tick).")]
public readonly WRange Speed = new WRange(426);
public readonly WAngle Angle = WAngle.FromDegrees(20);
public override object Create(ActorInitializer init) { return new AttackLeap(init.Self, this); }
}
class AttackLeap : AttackFrontal
{
readonly AttackLeapInfo info;
public AttackLeap(Actor self, AttackLeapInfo info)
: base(self, info)
{
this.info = info;
}
public override void DoAttack(Actor self, Target target)
{
if (target.Type != TargetType.Actor || !CanAttack(self, target))
return;
var a = ChooseArmamentForTarget(target);
if (a == null)
return;
if (!target.IsInRange(self.CenterPosition, a.Weapon.Range))
return;
self.CancelActivity();
self.QueueActivity(new Leap(self, target.Actor, a.Weapon, info.Speed, info.Angle));
}
}
}