Fix style issues from a recent PR.

This commit is contained in:
Paul Chote
2014-12-14 10:55:24 +13:00
parent a50ccd1020
commit ebdb260650
5 changed files with 32 additions and 25 deletions

View File

@@ -55,12 +55,14 @@ namespace OpenRA.Mods.D2k
bool WormAttack(Actor worm)
{
var targetLocation = target.Actor.Location;
// The target has moved too far away
if ((location - targetLocation).Length > NearEnough)
return false;
var lunch = worm.World.ActorMap.GetUnitsAt(targetLocation)
.Where(t => !t.Equals(worm) && weapon.IsValidAgainst(t, worm));
if (!lunch.Any())
return false;
@@ -100,31 +102,33 @@ namespace OpenRA.Mods.D2k
return this;
}
if (stance == AttackState.ReturningUnderground) // Wait for the worm to get back underground
// Wait for the worm to get back underground
if (stance == AttackState.ReturningUnderground)
{
if (self.World.SharedRandom.Next() % 2 == 0) // There is a 50-50 chance that the worm would just go away
// There is a 50-50 chance that the worm would just go away
if (self.World.SharedRandom.Next() % 2 == 0)
{
self.CancelActivity();
self.World.AddFrameEndTask(w => w.Remove(self));
var wormManager = self.World.WorldActor.TraitOrDefault<WormManager>();
if (wormManager != null)
wormManager.DecreaseWorms();
}
else
{
renderUnit.DefaultAnimation.ReplaceAnim("idle");
}
return NextActivity;
}
if (stance == AttackState.Burrowed) // Wait for the worm to get in position
// Wait for the worm to get in position
if (stance == AttackState.Burrowed)
{
// This is so that the worm cancels an attack against a target that has reached solid rock
if (!positionable.CanEnterCell(target.Actor.Location, null, false))
return NextActivity;
var success = WormAttack(self);
if (!success)
if (!WormAttack(self))
{
renderUnit.DefaultAnimation.ReplaceAnim("idle");
return NextActivity;