Replace IDisableMove with upgradability
This commit is contained in:
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly IPositionable positionable;
|
||||
readonly IMove movement;
|
||||
readonly IDisableMove[] moveDisablers;
|
||||
readonly IDisabledTrait disableable;
|
||||
WPos start, end;
|
||||
int length;
|
||||
int ticks = 0;
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
positionable = self.Trait<IPositionable>();
|
||||
movement = self.TraitOrDefault<IMove>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
disableable = movement as IDisabledTrait;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.length = length;
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (moveDisablers.Any(d => d.MoveDisabled(self)))
|
||||
if (disableable != null && disableable.IsTraitDisabled)
|
||||
return this;
|
||||
|
||||
var pos = length > 1
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
static readonly List<CPos> NoPath = new List<CPos>();
|
||||
|
||||
readonly Mobile mobile;
|
||||
readonly IDisableMove[] moveDisablers;
|
||||
readonly WDist nearEnough;
|
||||
readonly Func<List<CPos>> getPath;
|
||||
readonly Actor ignoredActor;
|
||||
@@ -43,7 +42,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, CPos destination)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
getPath = () =>
|
||||
{
|
||||
@@ -65,7 +63,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, CPos destination, WDist nearEnough)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
getPath = () => self.World.WorldActor.Trait<IPathFinder>()
|
||||
.FindUnitPath(mobile.ToCell, destination, self);
|
||||
@@ -76,7 +73,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, CPos destination, SubCell subCell, WDist nearEnough)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
getPath = () => self.World.WorldActor.Trait<IPathFinder>()
|
||||
.FindUnitPathToRange(mobile.FromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
|
||||
@@ -87,7 +83,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, CPos destination, Actor ignoredActor)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
getPath = () =>
|
||||
{
|
||||
@@ -107,7 +102,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, Target target, WDist range)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
getPath = () =>
|
||||
{
|
||||
@@ -125,7 +119,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Move(Actor self, Func<List<CPos>> getPath)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
|
||||
this.getPath = getPath;
|
||||
|
||||
@@ -155,7 +148,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceled)
|
||||
return NextActivity;
|
||||
|
||||
if (mobile.IsTraitDisabled || moveDisablers.Any(d => d.MoveDisabled(self)))
|
||||
if (mobile.IsTraitDisabled)
|
||||
return this;
|
||||
|
||||
if (destination == mobile.ToCell)
|
||||
|
||||
@@ -11,18 +11,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public class Turn : Activity
|
||||
{
|
||||
readonly IDisableMove[] moveDisablers;
|
||||
readonly IDisabledTrait disablable;
|
||||
readonly int desiredFacing;
|
||||
|
||||
public Turn(Actor self, int desiredFacing)
|
||||
{
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
disablable = self.TraitOrDefault<IMove>() as IDisabledTrait;
|
||||
this.desiredFacing = desiredFacing;
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
if (IsCanceled)
|
||||
return NextActivity;
|
||||
if (moveDisablers.Any(d => d.MoveDisabled(self)))
|
||||
if (disablable != null && disablable.IsTraitDisabled)
|
||||
return this;
|
||||
|
||||
var facing = self.Trait<IFacing>();
|
||||
|
||||
Reference in New Issue
Block a user