Merge pull request #6653 from pchote/empdisable
Disable movement of EMPd actors
This commit is contained in:
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
new AttackMove.AttackMoveActivity(self, new Move.Move(target.Location, WRange.FromCells(2))),
|
new AttackMove.AttackMoveActivity(self, new Move.Move(self, target.Location, WRange.FromCells(2))),
|
||||||
new Wait(25),
|
new Wait(25),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new DisableUpgrade(this); }
|
public object Create(ActorInitializer init) { return new DisableUpgrade(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DisableUpgrade : IUpgradable, IDisable
|
public class DisableUpgrade : IUpgradable, IDisable, IDisableMove
|
||||||
{
|
{
|
||||||
readonly DisableUpgradeInfo info;
|
readonly DisableUpgradeInfo info;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
@@ -44,5 +44,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool Disabled { get { return enabled; } }
|
public bool Disabled { get { return enabled; } }
|
||||||
|
|
||||||
|
public bool MoveDisabled(Actor self) { return enabled; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
|
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
|
||||||
|
|
||||||
self.QueueActivity(new Move(currentLocation, 8));
|
self.QueueActivity(new Move(self, currentLocation, 8));
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, currentLocation), Color.Green);
|
self.SetTargetLine(Target.FromCell(self.World, currentLocation), Color.Green);
|
||||||
}
|
}
|
||||||
@@ -585,7 +585,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.SetTargetLine(Target.FromCell(self.World, moveTo.Value), Color.Green, false);
|
self.SetTargetLine(Target.FromCell(self.World, moveTo.Value), Color.Green, false);
|
||||||
self.QueueActivity(new Move(moveTo.Value, 0));
|
self.QueueActivity(new Move(self, moveTo.Value, 0));
|
||||||
|
|
||||||
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
|
Log.Write("debug", "OnNudge #{0} from {1} to {2}",
|
||||||
self.ActorID, self.Location, moveTo.Value);
|
self.ActorID, self.Location, moveTo.Value);
|
||||||
@@ -631,13 +631,13 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity ScriptedMove(CPos cell) { return new Move(cell); }
|
public Activity ScriptedMove(CPos cell) { return new Move(self, cell); }
|
||||||
public Activity MoveTo(CPos cell, int nearEnough) { return new Move(cell, nearEnough); }
|
public Activity MoveTo(CPos cell, int nearEnough) { return new Move(self, cell, nearEnough); }
|
||||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
|
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Move(self, cell, ignoredActor); }
|
||||||
public Activity MoveWithinRange(Target target, WRange range) { return new MoveWithinRange(self, target, WRange.Zero, range); }
|
public Activity MoveWithinRange(Target target, WRange range) { return new MoveWithinRange(self, target, WRange.Zero, range); }
|
||||||
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new MoveWithinRange(self, target, minRange, maxRange); }
|
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new MoveWithinRange(self, target, minRange, maxRange); }
|
||||||
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); }
|
public Activity MoveFollow(Actor self, Target target, WRange minRange, WRange maxRange) { return new Follow(self, target, minRange, maxRange); }
|
||||||
public Activity MoveTo(Func<List<CPos>> pathFunc) { return new Move(pathFunc); }
|
public Activity MoveTo(Func<List<CPos>> pathFunc) { return new Move(self, pathFunc); }
|
||||||
|
|
||||||
public void OnNotifyBlockingMove(Actor self, Actor blocking)
|
public void OnNotifyBlockingMove(Actor self, Actor blocking)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
static readonly List<CPos> NoPath = new List<CPos>();
|
static readonly List<CPos> NoPath = new List<CPos>();
|
||||||
|
|
||||||
CPos? destination;
|
readonly Mobile mobile;
|
||||||
WRange nearEnough;
|
readonly IEnumerable<IDisableMove> moveDisablers;
|
||||||
|
readonly WRange nearEnough;
|
||||||
|
readonly Func<List<CPos>> getPath;
|
||||||
|
readonly Actor ignoreBuilding;
|
||||||
|
|
||||||
List<CPos> path;
|
List<CPos> path;
|
||||||
Func<Actor, Mobile, List<CPos>> getPath;
|
CPos? destination;
|
||||||
Actor ignoreBuilding;
|
|
||||||
|
|
||||||
// For dealing with blockers
|
// For dealing with blockers
|
||||||
bool hasWaited;
|
bool hasWaited;
|
||||||
@@ -35,9 +38,12 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
// Scriptable move order
|
// Scriptable move order
|
||||||
// Ignores lane bias and nearby units
|
// Ignores lane bias and nearby units
|
||||||
public Move(CPos destination)
|
public Move(Actor self, CPos destination)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) =>
|
mobile = self.Trait<Mobile>();
|
||||||
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
|
|
||||||
|
getPath = () =>
|
||||||
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||||
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
||||||
.WithoutLaneBias());
|
.WithoutLaneBias());
|
||||||
@@ -46,28 +52,37 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HACK: for legacy code
|
// HACK: for legacy code
|
||||||
public Move(CPos destination, int nearEnough)
|
public Move(Actor self, CPos destination, int nearEnough)
|
||||||
: this(destination, WRange.FromCells(nearEnough)) { }
|
: this(self, destination, WRange.FromCells(nearEnough)) { }
|
||||||
|
|
||||||
public Move(CPos destination, WRange nearEnough)
|
public Move(Actor self, CPos destination, WRange nearEnough)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) => self.World.WorldActor.Trait<PathFinder>()
|
mobile = self.Trait<Mobile>();
|
||||||
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
|
|
||||||
|
getPath = () => self.World.WorldActor.Trait<PathFinder>()
|
||||||
.FindUnitPath(mobile.toCell, destination, self);
|
.FindUnitPath(mobile.toCell, destination, self);
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = nearEnough;
|
this.nearEnough = nearEnough;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(CPos destination, SubCell subCell, WRange nearEnough)
|
public Move(Actor self, CPos destination, SubCell subCell, WRange nearEnough)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) => self.World.WorldActor.Trait<PathFinder>()
|
mobile = self.Trait<Mobile>();
|
||||||
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
|
|
||||||
|
getPath = () => self.World.WorldActor.Trait<PathFinder>()
|
||||||
.FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
|
.FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = nearEnough;
|
this.nearEnough = nearEnough;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(CPos destination, Actor ignoreBuilding)
|
public Move(Actor self, CPos destination, Actor ignoreBuilding)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) =>
|
mobile = self.Trait<Mobile>();
|
||||||
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
|
|
||||||
|
getPath = () =>
|
||||||
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||||
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
||||||
.WithIgnoredBuilding(ignoreBuilding));
|
.WithIgnoredBuilding(ignoreBuilding));
|
||||||
@@ -77,9 +92,12 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.ignoreBuilding = ignoreBuilding;
|
this.ignoreBuilding = ignoreBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Target target, WRange range)
|
public Move(Actor self, Target target, WRange range)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) =>
|
mobile = self.Trait<Mobile>();
|
||||||
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
|
|
||||||
|
getPath = () =>
|
||||||
{
|
{
|
||||||
if (!target.IsValidFor(self))
|
if (!target.IsValidFor(self))
|
||||||
return NoPath;
|
return NoPath;
|
||||||
@@ -88,15 +106,19 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
mobile.toCell, mobile.toSubCell, target.CenterPosition, range, self);
|
mobile.toCell, mobile.toSubCell, target.CenterPosition, range, self);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.destination = null;
|
destination = null;
|
||||||
this.nearEnough = range;
|
nearEnough = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move(Func<List<CPos>> getPath)
|
public Move(Actor self, Func<List<CPos>> getPath)
|
||||||
{
|
{
|
||||||
this.getPath = (_1, _2) => getPath();
|
mobile = self.Trait<Mobile>();
|
||||||
this.destination = null;
|
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||||
this.nearEnough = WRange.Zero;
|
|
||||||
|
this.getPath = getPath;
|
||||||
|
|
||||||
|
destination = null;
|
||||||
|
nearEnough = WRange.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HashList<T>(List<T> xs)
|
static int HashList<T>(List<T> xs)
|
||||||
@@ -111,14 +133,15 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
List<CPos> EvalPath(Actor self, Mobile mobile)
|
List<CPos> EvalPath(Actor self, Mobile mobile)
|
||||||
{
|
{
|
||||||
var path = getPath(self, mobile).TakeWhile(a => a != mobile.toCell).ToList();
|
var path = getPath().TakeWhile(a => a != mobile.toCell).ToList();
|
||||||
mobile.PathHash = HashList(path);
|
mobile.PathHash = HashList(path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var mobile = self.Trait<Mobile>();
|
if (moveDisablers.Any(d => d.MoveDisabled(self)))
|
||||||
|
return this;
|
||||||
|
|
||||||
if (destination == mobile.toCell)
|
if (destination == mobile.toCell)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
@@ -297,7 +320,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
var ret = InnerTick(self, mobile);
|
var ret = InnerTick(self, move.mobile);
|
||||||
mobile.IsMoving = ret is MovePart;
|
mobile.IsMoving = ret is MovePart;
|
||||||
|
|
||||||
if (moveFraction > moveFractionTotal)
|
if (moveFraction > moveFractionTotal)
|
||||||
|
|||||||
@@ -54,17 +54,11 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
|
|
||||||
void Move(Actor actor, CPos dest)
|
void Move(Actor actor, CPos dest)
|
||||||
{
|
{
|
||||||
if (actor.HasTrait<Aircraft>())
|
var move = actor.TraitOrDefault<IMove>();
|
||||||
{
|
if (move == null)
|
||||||
if (actor.HasTrait<Helicopter>())
|
return;
|
||||||
actor.QueueActivity(new HeliFly(actor, Target.FromCell(actor.World, dest)));
|
|
||||||
else
|
actor.QueueActivity(move.MoveTo(dest, 2));
|
||||||
actor.QueueActivity(new Fly(actor, Target.FromCell(actor.World, dest)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
actor.QueueActivity(new Move.Move(dest, 2));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Send reinforcements consisting of multiple units. Supports ground-based, naval and air units. " +
|
[Desc("Send reinforcements consisting of multiple units. Supports ground-based, naval and air units. " +
|
||||||
|
|||||||
@@ -324,9 +324,9 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
public void AttackMove(Actor actor, CPos location, double nearEnough)
|
public void AttackMove(Actor actor, CPos location, double nearEnough)
|
||||||
{
|
{
|
||||||
if (actor.HasTrait<AttackMove>())
|
if (actor.HasTrait<AttackMove>())
|
||||||
actor.QueueActivity(new AttackMove.AttackMoveActivity(actor, new Move.Move(location, (int)nearEnough)));
|
actor.QueueActivity(new AttackMove.AttackMoveActivity(actor, new Move.Move(actor, location, (int)nearEnough)));
|
||||||
else
|
else
|
||||||
actor.QueueActivity(new Move.Move(location, (int)nearEnough));
|
actor.QueueActivity(new Move.Move(actor, location, (int)nearEnough));
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
"close enough to complete the activity.")]
|
"close enough to complete the activity.")]
|
||||||
public void AttackMove(CPos cell, int closeEnough = 0)
|
public void AttackMove(CPos cell, int closeEnough = 0)
|
||||||
{
|
{
|
||||||
self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Move.Move(cell, WRange.FromCells(closeEnough))));
|
var move = self.TraitOrDefault<IMove>();
|
||||||
|
if (move == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self.QueueActivity(new AttackMove.AttackMoveActivity(self, move.MoveTo(cell, closeEnough)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
"(in cells) that will be considered close enough to complete the activity.")]
|
"(in cells) that will be considered close enough to complete the activity.")]
|
||||||
public void Move(CPos cell, int closeEnough = 0)
|
public void Move(CPos cell, int closeEnough = 0)
|
||||||
{
|
{
|
||||||
self.QueueActivity(new Move.Move(cell, WRange.FromCells(closeEnough)));
|
self.QueueActivity(new Move.Move(self, cell, WRange.FromCells(closeEnough)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[ScriptActorPropertyActivity]
|
[ScriptActorPropertyActivity]
|
||||||
[Desc("Moves within the cell grid, ignoring lane biases.")]
|
[Desc("Moves within the cell grid, ignoring lane biases.")]
|
||||||
public void ScriptedMove(CPos cell)
|
public void ScriptedMove(CPos cell)
|
||||||
{
|
{
|
||||||
self.QueueActivity(new Move.Move(cell));
|
self.QueueActivity(new Move.Move(self, cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
[ScriptActorPropertyActivity]
|
[ScriptActorPropertyActivity]
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var um = a.TraitOrDefault<UpgradeManager>();
|
var um = a.TraitOrDefault<UpgradeManager>();
|
||||||
if (um == null)
|
if (um == null)
|
||||||
return;
|
continue;
|
||||||
|
|
||||||
foreach (var u in Upgrades)
|
foreach (var u in Upgrades)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
Priority: 3
|
Priority: 3
|
||||||
TargetableBuilding:
|
TargetableBuilding:
|
||||||
TargetTypes: Ground, C4
|
TargetTypes: Ground, Building, C4
|
||||||
Building:
|
Building:
|
||||||
Dimensions: 1,1
|
Dimensions: 1,1
|
||||||
Footprint: x
|
Footprint: x
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
LineBuildNode:
|
LineBuildNode:
|
||||||
Types: wall
|
Types: wall
|
||||||
TargetableBuilding:
|
TargetableBuilding:
|
||||||
TargetTypes: Ground, C4
|
TargetTypes: Ground, Wall, C4
|
||||||
RenderBuildingWall:
|
RenderBuildingWall:
|
||||||
Type: wall
|
Type: wall
|
||||||
GivesExperience:
|
GivesExperience:
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
Voice: Infantry
|
Voice: Infantry
|
||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground, Infantry
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
WithDeathAnimation:
|
WithDeathAnimation:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
Voice: Vehicle
|
Voice: Vehicle
|
||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground, Vehicle
|
||||||
Repairable:
|
Repairable:
|
||||||
RepairBuildings: gadept
|
RepairBuildings: gadept
|
||||||
Passenger:
|
Passenger:
|
||||||
@@ -289,7 +289,7 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
Voice: Vehicle
|
Voice: Vehicle
|
||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground, Vehicle
|
||||||
Repairable:
|
Repairable:
|
||||||
RepairBuildings: gadept
|
RepairBuildings: gadept
|
||||||
Passenger:
|
Passenger:
|
||||||
|
|||||||
@@ -1130,10 +1130,13 @@ EMPulseCannon:
|
|||||||
Warhead@target: SpreadDamage
|
Warhead@target: SpreadDamage
|
||||||
Spread: 0
|
Spread: 0
|
||||||
Damage: 0
|
Damage: 0
|
||||||
|
PreventProne: true
|
||||||
|
ValidTargets: Vehicle
|
||||||
Warhead@emp: GrantUpgrade
|
Warhead@emp: GrantUpgrade
|
||||||
Range: 3c0
|
Range: 3c0
|
||||||
Duration: 250
|
Duration: 250
|
||||||
Upgrades: empdisable
|
Upgrades: empdisable
|
||||||
|
ValidTargets: Vehicle
|
||||||
|
|
||||||
TiberiumExplosion:
|
TiberiumExplosion:
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: SpreadDamage
|
||||||
|
|||||||
Reference in New Issue
Block a user