Use in parameter for Target
This commit is contained in:
@@ -31,13 +31,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
bool useLastVisibleTarget;
|
||||
readonly List<WPos> positionBuffer = new List<WPos>();
|
||||
|
||||
public Fly(Actor self, Target t, WDist nearEnough, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
public Fly(Actor self, in Target t, WDist nearEnough, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
: this(self, t, initialTargetPosition, targetLineColor)
|
||||
{
|
||||
this.nearEnough = nearEnough;
|
||||
}
|
||||
|
||||
public Fly(Actor self, Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
public Fly(Actor self, in Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
target = t;
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value);
|
||||
}
|
||||
|
||||
public Fly(Actor self, Target t, WDist minRange, WDist maxRange,
|
||||
public Fly(Actor self, in Target t, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
: this(self, t, initialTargetPosition, targetLineColor)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
bool hasTicked;
|
||||
bool returnToBase;
|
||||
|
||||
public FlyAttack(Actor self, AttackSource source, Target target, bool forceAttack, Color? targetLineColor)
|
||||
public FlyAttack(Actor self, AttackSource source, in Target target, bool forceAttack, Color? targetLineColor)
|
||||
{
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
WDist exitRange;
|
||||
bool targetIsVisibleActor;
|
||||
|
||||
public FlyAttackRun(Actor self, Target t, WDist exitRange)
|
||||
public FlyAttackRun(Actor self, in Target t, WDist exitRange)
|
||||
{
|
||||
ChildHasPriority = false;
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
WDist exitRange;
|
||||
readonly AttackAircraft attackAircraft;
|
||||
|
||||
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, Target t, WDist exitRange)
|
||||
public StrafeAttackRun(Actor self, AttackAircraft attackAircraft, in Target t, WDist exitRange)
|
||||
{
|
||||
ChildHasPriority = false;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
bool useLastVisibleTarget;
|
||||
bool wasMovingWithinRange;
|
||||
|
||||
public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
public FlyFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
this.endingDelay = endingDelay;
|
||||
}
|
||||
|
||||
public FlyOffMap(Actor self, Target target, int endingDelay = 25)
|
||||
public FlyOffMap(Actor self, in Target target, int endingDelay = 25)
|
||||
: this(self, endingDelay)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
@@ -40,16 +40,16 @@ namespace OpenRA.Mods.Common.Activities
|
||||
assignTargetOnFirstRun = true;
|
||||
}
|
||||
|
||||
public Land(Actor self, Target target, WAngle? facing = null, Color? targetLineColor = null)
|
||||
public Land(Actor self, in Target target, WAngle? facing = null, Color? targetLineColor = null)
|
||||
: this(self, target, new WDist(-1), WVec.Zero, facing, targetLineColor: targetLineColor) { }
|
||||
|
||||
public Land(Actor self, Target target, WDist landRange, WAngle? facing = null, Color? targetLineColor = null)
|
||||
public Land(Actor self, in Target target, WDist landRange, WAngle? facing = null, Color? targetLineColor = null)
|
||||
: this(self, target, landRange, WVec.Zero, facing, targetLineColor: targetLineColor) { }
|
||||
|
||||
public Land(Actor self, Target target, WVec offset, WAngle? facing = null, Color? targetLineColor = null)
|
||||
public Land(Actor self, in Target target, WVec offset, WAngle? facing = null, Color? targetLineColor = null)
|
||||
: this(self, target, WDist.Zero, offset, facing, targetLineColor: targetLineColor) { }
|
||||
|
||||
public Land(Actor self, Target target, WDist landRange, WVec offset, WAngle? facing = null, CPos[] clearCells = null, Color? targetLineColor = null)
|
||||
public Land(Actor self, in Target target, WDist landRange, WVec offset, WAngle? facing = null, CPos[] clearCells = null, Color? targetLineColor = null)
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
this.target = target;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
WDist maxRange;
|
||||
AttackStatus attackStatus = AttackStatus.UnableToAttack;
|
||||
|
||||
public Attack(Actor self, Target target, bool allowMovement, bool forceAttack, Color? targetLineColor = null)
|
||||
public Attack(Actor self, in Target target, bool allowMovement, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
this.targetLineColor = targetLineColor;
|
||||
@@ -64,8 +64,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
{
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
|
||||
// Lambdas can't use 'in' variables, so capture a copy for later
|
||||
var rangeTarget = target;
|
||||
lastVisibleMaximumRange = attackTraits.Where(x => !x.IsTraitDisabled)
|
||||
.Min(x => x.GetMaximumRangeVersusTarget(target));
|
||||
.Min(x => x.GetMaximumRangeVersusTarget(rangeTarget));
|
||||
|
||||
if (target.Type == TargetType.Actor)
|
||||
{
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Actor enterActor;
|
||||
CaptureManager enterCaptureManager;
|
||||
|
||||
public CaptureActor(Actor self, Target target)
|
||||
public CaptureActor(Actor self, in Target target)
|
||||
: base(self, target, Color.Crimson)
|
||||
{
|
||||
manager = self.Trait<CaptureManager>();
|
||||
}
|
||||
|
||||
protected override void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor)
|
||||
protected override void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor)
|
||||
{
|
||||
if (target.Type == TargetType.Actor && enterActor != target.Actor)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
assignTargetOnFirstRun = true;
|
||||
}
|
||||
|
||||
public DeliverUnit(Actor self, Target destination, WDist deliverRange)
|
||||
public DeliverUnit(Actor self, in Target destination, WDist deliverRange)
|
||||
{
|
||||
this.destination = destination;
|
||||
this.deliverRange = deliverRange;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Actor enterActor;
|
||||
IDemolishable[] enterDemolishables;
|
||||
|
||||
public Demolish(Actor self, Target target, EnterBehaviour enterBehaviour, int delay,
|
||||
public Demolish(Actor self, in Target target, EnterBehaviour enterBehaviour, int delay,
|
||||
int flashes, int flashesDelay, int flashInterval, BitSet<DamageType> damageTypes)
|
||||
: base(self, target, Color.Crimson)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly int payload;
|
||||
readonly int playerExperience;
|
||||
|
||||
public DonateCash(Actor self, Target target, int payload, int playerExperience)
|
||||
public DonateCash(Actor self, in Target target, int payload, int playerExperience)
|
||||
: base(self, target, Color.Yellow)
|
||||
{
|
||||
this.payload = payload;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Actor enterActor;
|
||||
GainsExperience enterGainsExperience;
|
||||
|
||||
public DonateExperience(Actor self, Target target, int level, int playerExperience)
|
||||
public DonateExperience(Actor self, in Target target, int level, int playerExperience)
|
||||
: base(self, target, Color.Yellow)
|
||||
{
|
||||
this.level = level;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
bool useLastVisibleTarget;
|
||||
EnterState lastState = EnterState.Approaching;
|
||||
|
||||
protected Enter(Actor self, Target target, Color? targetLineColor = null)
|
||||
protected Enter(Actor self, in Target target, Color? targetLineColor = null)
|
||||
{
|
||||
move = self.Trait<IMove>();
|
||||
this.target = target;
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
/// Called early in the activity tick to allow subclasses to update state.
|
||||
/// Call Cancel(self, true) if it is no longer valid to enter
|
||||
/// </summary>
|
||||
protected virtual void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor) { }
|
||||
protected virtual void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the actor is ready to transition from approaching to entering the target actor.
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
bool useLastVisibleTarget;
|
||||
bool wasMovingWithinRange;
|
||||
|
||||
public Follow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
public Follow(Actor self, in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
protected CPos lastVisibleTargetLocation;
|
||||
bool useLastVisibleTarget;
|
||||
|
||||
public MoveAdjacentTo(Actor self, Target target, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
public MoveAdjacentTo(Actor self, in Target target, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
this.targetLineColor = targetLineColor;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly WDist maxRange;
|
||||
readonly WDist minRange;
|
||||
|
||||
public MoveWithinRange(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
public MoveWithinRange(Actor self, in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
: base(self, target, initialTargetPosition, targetLineColor)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly WDist targetMovementThreshold;
|
||||
WPos targetStartPos;
|
||||
|
||||
public VisualMoveIntoTarget(Actor self, Target target, WDist targetMovementThreshold, Color? targetLineColor = null)
|
||||
public VisualMoveIntoTarget(Actor self, in Target target, WDist targetMovementThreshold, Color? targetLineColor = null)
|
||||
{
|
||||
mobile = self.Trait<Mobile>();
|
||||
this.target = target;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
BridgeHut enterHut;
|
||||
LegacyBridgeHut enterLegacyHut;
|
||||
|
||||
public RepairBridge(Actor self, Target target, EnterBehaviour enterBehaviour, string notification)
|
||||
public RepairBridge(Actor self, in Target target, EnterBehaviour enterBehaviour, string notification)
|
||||
: base(self, target, Color.Yellow)
|
||||
{
|
||||
this.enterBehaviour = enterBehaviour;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
IHealth enterHealth;
|
||||
EngineerRepairable enterEngineerRepariable;
|
||||
|
||||
public RepairBuilding(Actor self, Target target, EngineerRepairInfo info)
|
||||
public RepairBuilding(Actor self, in Target target, EngineerRepairInfo info)
|
||||
: base(self, target, Color.Yellow)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Cargo enterCargo;
|
||||
Aircraft enterAircraft;
|
||||
|
||||
public RideTransport(Actor self, Target target)
|
||||
public RideTransport(Actor self, in Target target)
|
||||
: base(self, target, Color.Green)
|
||||
{
|
||||
passenger = self.Trait<Passenger>();
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly Target target;
|
||||
readonly Color? targetLineColor;
|
||||
|
||||
public IssueOrderAfterTransform(string orderString, Target target, Color? targetLineColor = null)
|
||||
public IssueOrderAfterTransform(string orderString, in Target target, Color? targetLineColor = null)
|
||||
{
|
||||
this.orderString = orderString;
|
||||
this.target = target;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
assignTargetOnFirstRun = true;
|
||||
}
|
||||
|
||||
public UnloadCargo(Actor self, Target destination, WDist unloadRange, bool unloadAll = true)
|
||||
public UnloadCargo(Actor self, in Target destination, WDist unloadRange, bool unloadAll = true)
|
||||
{
|
||||
this.self = self;
|
||||
cargo = self.Trait<Cargo>();
|
||||
|
||||
Reference in New Issue
Block a user