Replace IDisableMove with upgradability

This commit is contained in:
atlimit8
2015-09-25 16:55:33 -05:00
parent 0fc04b7a4a
commit c827dbe183
23 changed files with 82 additions and 77 deletions

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
}
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated, INotifyKilled,
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, IDisableMove, INotifyActorDisposing
INotifyOwnerChanged, INotifyAddedToWorld, ITick, INotifySold, INotifyActorDisposing
{
public readonly CargoInfo Info;
readonly Actor self;
@@ -228,7 +228,6 @@ namespace OpenRA.Mods.Common.Traits
return Info.UnloadVoice;
}
public bool MoveDisabled(Actor self) { return reserves.Any(); }
public bool HasSpace(int weight) { return totalWeight + reservedWeight + weight <= Info.MaxWeight; }
public bool IsEmpty(Actor self) { return cargo.Count == 0; }

View File

@@ -695,14 +695,12 @@ namespace OpenRA.Mods.Common.Traits
{
readonly Mobile mobile;
readonly bool rejectMove;
readonly IDisableMove[] moveDisablers;
public bool OverrideSelection { get { return false; } }
public MoveOrderTargeter(Actor self, Mobile unit)
{
this.mobile = unit;
rejectMove = !self.AcceptsOrder("Move");
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
}
public string OrderID { get { return "Move"; } }
@@ -723,8 +721,7 @@ namespace OpenRA.Mods.Common.Traits
if (mobile.IsTraitDisabled
|| (!explored && !mobile.Info.MoveIntoShroud)
|| (explored && mobile.Info.MovementCostForCell(self.World, location) == int.MaxValue)
|| moveDisablers.Any(d => d.MoveDisabled(self)))
|| (explored && mobile.Info.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = mobile.Info.BlockedCursor;
return true;

View File

@@ -1,28 +0,0 @@
#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

@@ -18,12 +18,11 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new DisableOnUpgrade(this); }
}
public class DisableOnUpgrade : UpgradableTrait<DisableOnUpgradeInfo>, IDisable, IDisableMove
public class DisableOnUpgrade : UpgradableTrait<DisableOnUpgradeInfo>, IDisable
{
public DisableOnUpgrade(DisableOnUpgradeInfo info)
: base(info) { }
public bool Disabled { get { return !IsTraitDisabled; } }
public bool MoveDisabled(Actor self) { return !IsTraitDisabled; }
}
}