Make Mobile a PausableConditionalTrait
This commit is contained in:
@@ -21,7 +21,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Unit is able to move.")]
|
||||
public class MobileInfo : ConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo,
|
||||
public class MobileInfo : PausableConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo,
|
||||
IEditorActorOptions
|
||||
{
|
||||
[Desc("Which Locomotor does this trait use. Must be defined on the World actor.")]
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class Mobile : ConditionalTrait<MobileInfo>, INotifyCreated, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
|
||||
public class Mobile : PausableConditionalTrait<MobileInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
|
||||
IFacing, IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier, INotifyBecomingIdle
|
||||
{
|
||||
readonly Actor self;
|
||||
@@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Nudge(Actor self, Actor nudger, bool force)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
if (IsTraitDisabled || IsTraitPaused)
|
||||
return;
|
||||
|
||||
// Initial fairly braindead implementation.
|
||||
@@ -683,7 +683,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Nudge(self, blocking, true);
|
||||
}
|
||||
|
||||
IEnumerable<IOrderTargeter> IIssueOrder.Orders { get { yield return new MoveOrderTargeter(self, this); } }
|
||||
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsTraitDisabled)
|
||||
yield return new MoveOrderTargeter(self, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Returns a valid order even if the unit can't move to the target
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
@@ -696,6 +703,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void IResolveOrder.ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
|
||||
if (order.OrderString == "Move")
|
||||
{
|
||||
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(order.Target.CenterPosition));
|
||||
@@ -718,6 +728,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
switch (order.OrderString)
|
||||
{
|
||||
case "Move":
|
||||
@@ -770,7 +783,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
cursor = self.World.Map.Contains(location) ?
|
||||
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? mobile.Info.Cursor) : mobile.Info.BlockedCursor;
|
||||
|
||||
if (mobile.IsTraitDisabled
|
||||
if (mobile.IsTraitPaused
|
||||
|| (!explored && !locomotorInfo.MoveIntoShroud)
|
||||
|| (explored && locomotorInfo.MovementCostForCell(self.World, location) == int.MaxValue))
|
||||
cursor = mobile.Info.BlockedCursor;
|
||||
|
||||
Reference in New Issue
Block a user