Create #9435 DisableMovementOnUpgrade, rename DisableUpgrade to DisableOnUpgrade and Fixed not showing the blocked move cursor when movement is disabled.

This commit is contained in:
Nolt
2015-09-25 12:59:31 -03:00
committed by ABrandau
parent 0e9257abcf
commit 7994d08702
7 changed files with 48 additions and 9 deletions

View File

@@ -692,12 +692,14 @@ namespace OpenRA.Mods.Common.Traits
{
readonly MobileInfo unitType;
readonly bool rejectMove;
readonly IDisableMove[] moveDisablers;
public bool OverrideSelection { get { return false; } }
public MoveOrderTargeter(Actor self, MobileInfo unitType)
{
this.unitType = unitType;
rejectMove = !self.AcceptsOrder("Move");
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
}
public string OrderID { get { return "Move"; } }
@@ -716,7 +718,9 @@ namespace OpenRA.Mods.Common.Traits
cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? unitType.Cursor) : unitType.BlockedCursor;
if ((!explored && !unitType.MoveIntoShroud) || (explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue))
if ((!explored && !unitType.MoveIntoShroud)
|| (explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue)
|| moveDisablers.Any(d => d.MoveDisabled(self)))
cursor = unitType.BlockedCursor;
return true;

View File

@@ -0,0 +1,28 @@
#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.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Disable the ability to move and turn of the actor when this trait is enabled by an upgrade.")]
public class DisableMovementInfo : UpgradableTraitInfo
{
public override object Create(ActorInitializer init) { return new DisableMovementOnUpgrade(this); }
}
public class DisableMovementOnUpgrade : UpgradableTrait<DisableMovementInfo>, IDisableMove
{
public DisableMovementOnUpgrade(DisableMovementInfo info)
: base(info) { }
public bool MoveDisabled(Actor self) { return !IsTraitDisabled; }
}
}

View File

@@ -13,14 +13,14 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Disable the actor when this trait is enabled by an upgrade.")]
public class DisableUpgradeInfo : UpgradableTraitInfo
public class DisableOnUpgradeInfo : UpgradableTraitInfo
{
public override object Create(ActorInitializer init) { return new DisableUpgrade(this); }
public override object Create(ActorInitializer init) { return new DisableOnUpgrade(this); }
}
public class DisableUpgrade : UpgradableTrait<DisableUpgradeInfo>, IDisable, IDisableMove
public class DisableOnUpgrade : UpgradableTrait<DisableOnUpgradeInfo>, IDisable, IDisableMove
{
public DisableUpgrade(DisableUpgradeInfo info)
public DisableOnUpgrade(DisableOnUpgradeInfo info)
: base(info) { }
public bool Disabled { get { return !IsTraitDisabled; } }