diff --git a/OpenRA.Game/Activities/Activity.cs b/OpenRA.Game/Activities/Activity.cs
index 45187373a8..eb4719ac7e 100644
--- a/OpenRA.Game/Activities/Activity.cs
+++ b/OpenRA.Game/Activities/Activity.cs
@@ -26,7 +26,7 @@ namespace OpenRA.Activities
public readonly Color Color;
public readonly Sprite Tile;
- public TargetLineNode(Target target, Color color, Sprite tile = null)
+ public TargetLineNode(in Target target, Color color, Sprite tile = null)
{
// Note: Not all activities are drawable. In that case, pass Target.Invalid as target,
// if "yield break" in TargetLineNode(Actor self) is not feasible.
diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs
index 3193fc4c8e..683bbf4608 100644
--- a/OpenRA.Game/GameRules/WeaponInfo.cs
+++ b/OpenRA.Game/GameRules/WeaponInfo.cs
@@ -163,7 +163,7 @@ namespace OpenRA.GameRules
}
/// Checks if the weapon is valid against (can target) the target.
- public bool IsValidAgainst(Target target, World world, Actor firedBy)
+ public bool IsValidAgainst(in Target target, World world, Actor firedBy)
{
if (target.Type == TargetType.Actor)
return IsValidAgainst(target.Actor, firedBy);
@@ -220,20 +220,24 @@ namespace OpenRA.GameRules
}
/// Applies all the weapon's warheads to the target.
- public void Impact(Target target, WarheadArgs args)
+ public void Impact(in Target target, WarheadArgs args)
{
var world = args.SourceActor.World;
foreach (var warhead in Warheads)
{
if (warhead.Delay > 0)
- world.AddFrameEndTask(w => w.Add(new DelayedImpact(warhead.Delay, warhead, target, args)));
+ {
+ // Lambdas can't use 'in' variables, so capture a copy for later
+ var delayedTarget = target;
+ world.AddFrameEndTask(w => w.Add(new DelayedImpact(warhead.Delay, warhead, delayedTarget, args)));
+ }
else
warhead.DoImpact(target, args);
}
}
/// Applies all the weapon's warheads to the target. Only use for projectile-less, special-case impacts.
- public void Impact(Target target, Actor firedBy)
+ public void Impact(in Target target, Actor firedBy)
{
// The impact will happen immediately at target.CenterPosition.
var args = new WarheadArgs
diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs
index 1ad80898ae..f1c9767295 100644
--- a/OpenRA.Game/Network/Order.cs
+++ b/OpenRA.Game/Network/Order.cs
@@ -55,7 +55,7 @@ namespace OpenRA
public readonly string OrderString;
public readonly Actor Subject;
public readonly bool Queued;
- public readonly Target Target;
+ public ref readonly Target Target => ref target;
public readonly Actor[] GroupedActors;
public string TargetString;
@@ -66,15 +66,18 @@ namespace OpenRA
public OrderType Type = OrderType.Fields;
public bool SuppressVisualFeedback;
- public Target VisualFeedbackTarget;
+ public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget;
public Player Player { get { return Subject != null ? Subject.Owner : null; } }
- Order(string orderString, Actor subject, Target target, string targetString, bool queued, Actor[] extraActors, CPos extraLocation, uint extraData, Actor[] groupedActors = null)
+ readonly Target target;
+ readonly Target visualFeedbackTarget;
+
+ Order(string orderString, Actor subject, in Target target, string targetString, bool queued, Actor[] extraActors, CPos extraLocation, uint extraData, Actor[] groupedActors = null)
{
OrderString = orderString ?? "";
Subject = subject;
- Target = target;
+ this.target = target;
TargetString = targetString;
Queued = queued;
ExtraActors = extraActors;
@@ -278,9 +281,15 @@ namespace OpenRA
public Order(string orderString, Actor subject, bool queued, Actor[] extraActors = null, Actor[] groupedActors = null)
: this(orderString, subject, Target.Invalid, null, queued, extraActors, CPos.Zero, 0, groupedActors) { }
- public Order(string orderString, Actor subject, Target target, bool queued, Actor[] extraActors = null, Actor[] groupedActors = null)
+ public Order(string orderString, Actor subject, in Target target, bool queued, Actor[] extraActors = null, Actor[] groupedActors = null)
: this(orderString, subject, target, null, queued, extraActors, CPos.Zero, 0, groupedActors) { }
+ public Order(string orderString, Actor subject, Target target, Target visualFeedbackTarget, bool queued)
+ : this(orderString, subject, target, null, queued, null, CPos.Zero, 0, null)
+ {
+ this.visualFeedbackTarget = visualFeedbackTarget;
+ }
+
public byte[] Serialize()
{
var minLength = 1 + OrderString.Length + 1;
diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs
index 59ccace228..a71b7e0e82 100644
--- a/OpenRA.Game/Orders/UnitOrderGenerator.cs
+++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs
@@ -196,15 +196,17 @@ namespace OpenRA.Orders
public readonly IOrderTargeter Order;
public readonly IIssueOrder Trait;
public readonly string Cursor;
- public readonly Target Target;
+ public ref readonly Target Target => ref target;
- public UnitOrderResult(Actor actor, IOrderTargeter order, IIssueOrder trait, string cursor, Target target)
+ readonly Target target;
+
+ public UnitOrderResult(Actor actor, IOrderTargeter order, IIssueOrder trait, string cursor, in Target target)
{
Actor = actor;
Order = order;
Trait = trait;
Cursor = cursor;
- Target = target;
+ this.target = target;
}
}
diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs
index 31468407cc..7ae0cb05b1 100644
--- a/OpenRA.Game/Traits/Target.cs
+++ b/OpenRA.Game/Traits/Target.cs
@@ -83,7 +83,7 @@ namespace OpenRA.Traits
}
public static Target FromPos(WPos p) { return new Target(p); }
- public static Target FromTargetPositions(Target t) { return new Target(t.CenterPosition, t.Positions.ToArray()); }
+ public static Target FromTargetPositions(in Target t) { return new Target(t.CenterPosition, t.Positions.ToArray()); }
public static Target FromCell(World w, CPos c, SubCell subCell = SubCell.FullCell) { return new Target(w, c, subCell); }
public static Target FromActor(Actor a) { return a != null ? new Target(a) : Invalid; }
public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); }
diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs
index 79ce28ef36..e539f4b410 100644
--- a/OpenRA.Game/Traits/TraitsInterfaces.cs
+++ b/OpenRA.Game/Traits/TraitsInterfaces.cs
@@ -128,7 +128,7 @@ namespace OpenRA.Traits
public interface IIssueOrder
{
IEnumerable Orders { get; }
- Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued);
+ Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued);
}
[Flags]
@@ -147,9 +147,9 @@ namespace OpenRA.Traits
{
string OrderID { get; }
int OrderPriority { get; }
- bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
+ bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
bool IsQueued { get; }
- bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers);
+ bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers);
}
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
@@ -517,7 +517,7 @@ namespace OpenRA.Traits
int Delay { get; }
bool IsValidAgainst(Actor victim, Actor firedBy);
bool IsValidAgainst(FrozenActor victim, Actor firedBy);
- void DoImpact(Target target, WarheadArgs args);
+ void DoImpact(in Target target, WarheadArgs args);
}
public interface IRulesetLoaded { void RulesetLoaded(Ruleset rules, TInfo info); }
diff --git a/OpenRA.Mods.Cnc/Activities/Infiltrate.cs b/OpenRA.Mods.Cnc/Activities/Infiltrate.cs
index 257635cb2d..86beabbfac 100644
--- a/OpenRA.Mods.Cnc/Activities/Infiltrate.cs
+++ b/OpenRA.Mods.Cnc/Activities/Infiltrate.cs
@@ -24,14 +24,14 @@ namespace OpenRA.Mods.Cnc.Activities
readonly INotifyInfiltration[] notifiers;
Actor enterActor;
- public Infiltrate(Actor self, Target target, Infiltrates infiltrates)
+ public Infiltrate(Actor self, in Target target, Infiltrates infiltrates)
: base(self, target, Color.Crimson)
{
this.infiltrates = infiltrates;
notifiers = self.TraitsImplementing().ToArray();
}
- protected override void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor)
+ protected override void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor)
{
if (infiltrates.IsTraitDisabled)
Cancel(self, true);
diff --git a/OpenRA.Mods.Cnc/Activities/Leap.cs b/OpenRA.Mods.Cnc/Activities/Leap.cs
index 3910613490..d86517ea65 100644
--- a/OpenRA.Mods.Cnc/Activities/Leap.cs
+++ b/OpenRA.Mods.Cnc/Activities/Leap.cs
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Activities
int ticks = 0;
WPos targetPosition;
- public Leap(Actor self, Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
+ public Leap(Actor self, in Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible)
{
this.mobile = mobile;
this.targetMobile = targetMobile;
diff --git a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs
index dfeba82da7..fa9c7bc86d 100644
--- a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs
+++ b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.Activities
BitSet lastVisibleTargetTypes;
Player lastVisibleOwner;
- public LeapAttack(Actor self, Target target, bool allowMovement, bool forceAttack, AttackLeap attack, AttackLeapInfo info, Color? targetLineColor = null)
+ public LeapAttack(Actor self, in Target target, bool allowMovement, bool forceAttack, AttackLeap attack, AttackLeapInfo info, Color? targetLineColor = null)
{
this.target = target;
this.targetLineColor = targetLineColor;
diff --git a/OpenRA.Mods.Cnc/Projectiles/DropPodImpact.cs b/OpenRA.Mods.Cnc/Projectiles/DropPodImpact.cs
index 56f7e1b137..bd7bc0c320 100644
--- a/OpenRA.Mods.Cnc/Projectiles/DropPodImpact.cs
+++ b/OpenRA.Mods.Cnc/Projectiles/DropPodImpact.cs
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Effects
int weaponDelay;
bool impacted = false;
- public DropPodImpact(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, Target target,
+ public DropPodImpact(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, in Target target,
int delay, string entryEffect, string entrySequence, string entryPalette)
{
this.target = target;
diff --git a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs
index 5be0b1ab33..81c56804d1 100644
--- a/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs
+++ b/OpenRA.Mods.Cnc/Projectiles/IonCannon.cs
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Cnc.Effects
int weaponDelay;
bool impacted = false;
- public IonCannon(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, Target target, string effect, string sequence, string palette, int delay)
+ public IonCannon(Player firedBy, WeaponInfo weapon, World world, WPos launchPos, in Target target, string effect, string sequence, string palette, int delay)
{
this.target = target;
this.firedBy = firedBy;
diff --git a/OpenRA.Mods.Cnc/Traits/Attack/AttackLeap.cs b/OpenRA.Mods.Cnc/Traits/Attack/AttackLeap.cs
index c8eeec49c2..1f5361344a 100644
--- a/OpenRA.Mods.Cnc/Traits/Attack/AttackLeap.cs
+++ b/OpenRA.Mods.Cnc/Traits/Attack/AttackLeap.cs
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
this.info = info;
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
if (target.Type != TargetType.Actor)
return false;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Traits
leapToken = self.RevokeCondition(leapToken);
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new LeapAttack(self, newTarget, allowMove, forceAttack, this, info, targetLineColor);
}
diff --git a/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs
index dc800fd31d..3e95c6cc8f 100644
--- a/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs
+++ b/OpenRA.Mods.Cnc/Traits/Attack/AttackPopupTurreted.cs
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
if (state == PopupState.Closed)
{
diff --git a/OpenRA.Mods.Cnc/Traits/Attack/AttackTDGunboatTurreted.cs b/OpenRA.Mods.Cnc/Traits/Attack/AttackTDGunboatTurreted.cs
index c423e5b322..15f2b2d070 100644
--- a/OpenRA.Mods.Cnc/Traits/Attack/AttackTDGunboatTurreted.cs
+++ b/OpenRA.Mods.Cnc/Traits/Attack/AttackTDGunboatTurreted.cs
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Traits
public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)
: base(self, info) { }
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
}
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly Color? targetLineColor;
bool hasTicked;
- public AttackTDGunboatTurretedActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public AttackTDGunboatTurretedActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
attack = self.Trait();
this.target = target;
diff --git a/OpenRA.Mods.Cnc/Traits/Attack/AttackTesla.cs b/OpenRA.Mods.Cnc/Traits/Attack/AttackTesla.cs
index 5835ea1e82..7058e0013d 100644
--- a/OpenRA.Mods.Cnc/Traits/Attack/AttackTesla.cs
+++ b/OpenRA.Mods.Cnc/Traits/Attack/AttackTesla.cs
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc.Traits
charges = info.MaxCharges;
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
if (!IsReachableTarget(target, true))
return false;
@@ -70,15 +70,15 @@ namespace OpenRA.Mods.Cnc.Traits
return base.CanAttack(self, target);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
--charges;
timeToRecharge = info.ReloadDelay;
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new ChargeAttack(this, newTarget, forceAttack, targetLineColor);
}
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly bool forceAttack;
readonly Color? targetLineColor;
- public ChargeAttack(AttackTesla attack, Target target, bool forceAttack, Color? targetLineColor = null)
+ public ChargeAttack(AttackTesla attack, in Target target, bool forceAttack, Color? targetLineColor = null)
{
this.attack = attack;
this.target = target;
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly AttackTesla attack;
readonly Target target;
- public ChargeFire(AttackTesla attack, Target target)
+ public ChargeFire(AttackTesla attack, in Target target)
{
this.attack = attack;
this.target = target;
diff --git a/OpenRA.Mods.Cnc/Traits/Disguise.cs b/OpenRA.Mods.Cnc/Traits/Disguise.cs
index 82e6ec8ff9..f943efe763 100644
--- a/OpenRA.Mods.Cnc/Traits/Disguise.cs
+++ b/OpenRA.Mods.Cnc/Traits/Disguise.cs
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Disguise")
return new Order(order.OrderID, self, target, queued);
@@ -244,9 +244,9 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.RevealDisguiseOn.HasFlag(RevealDisguiseType.Attack))
DisguiseAs(null);
diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs
index fb6f54345c..2742f1e16b 100644
--- a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs
+++ b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "Infiltrate")
return null;
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Cnc.Traits
? Info.Voice : null;
}
- public bool CanInfiltrateTarget(Actor self, Target target)
+ public bool CanInfiltrateTarget(Actor self, in Target target)
{
switch (target.Type)
{
diff --git a/OpenRA.Mods.Cnc/Traits/MadTank.cs b/OpenRA.Mods.Cnc/Traits/MadTank.cs
index fada306fcb..6147c14d16 100644
--- a/OpenRA.Mods.Cnc/Traits/MadTank.cs
+++ b/OpenRA.Mods.Cnc/Traits/MadTank.cs
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "DetonateAttack" && order.OrderID != "Detonate")
return null;
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Cnc.Traits
assignTargetOnFirstRun = true;
}
- public DetonationSequence(Actor self, MadTank mad, Target target)
+ public DetonationSequence(Actor self, MadTank mad, in Target target)
{
this.self = self;
this.mad = mad;
diff --git a/OpenRA.Mods.Cnc/Traits/Minelayer.cs b/OpenRA.Mods.Cnc/Traits/Minelayer.cs
index a24a61f9cb..15f5d748a6 100644
--- a/OpenRA.Mods.Cnc/Traits/Minelayer.cs
+++ b/OpenRA.Mods.Cnc/Traits/Minelayer.cs
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
switch (order.OrderID)
{
@@ -299,9 +299,9 @@ namespace OpenRA.Mods.Cnc.Traits
{
public string OrderID { get { return "BeginMinefield"; } }
public int OrderPriority { get { return 5; } }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
diff --git a/OpenRA.Mods.Cnc/Traits/PortableChrono.cs b/OpenRA.Mods.Cnc/Traits/PortableChrono.cs
index c45865d641..ef142881c3 100644
--- a/OpenRA.Mods.Cnc/Traits/PortableChrono.cs
+++ b/OpenRA.Mods.Cnc/Traits/PortableChrono.cs
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "PortableChronoDeploy")
{
@@ -172,9 +172,9 @@ namespace OpenRA.Mods.Cnc.Traits
public string OrderID { get { return "PortableChronoTeleport"; } }
public int OrderPriority { get { return 5; } }
public bool IsQueued { get; protected set; }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (modifiers.HasModifier(TargetModifiers.ForceMove))
{
diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs
index ca1637b48e..e405300402 100644
--- a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs
+++ b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
wsb = init.Self.TraitsImplementing().Single(w => w.Info.Name == info.Body);
}
- void INotifyTeslaCharging.Charging(Actor self, Target target)
+ void INotifyTeslaCharging.Charging(Actor self, in Target target)
{
wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
}
diff --git a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs
index 539070cabc..63b984d078 100644
--- a/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs
+++ b/OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
info.Palette, info.IsPlayerPalette);
}
- void INotifyTeslaCharging.Charging(Actor self, Target target)
+ void INotifyTeslaCharging.Charging(Actor self, in Target target)
{
charging = true;
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);
diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs
index 23e497bec5..81b98dcdae 100644
--- a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs
+++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Traits
base.Created(self);
}
- void INotifyBurstComplete.FiredBurst(Actor self, Target target, Armament a)
+ void INotifyBurstComplete.FiredBurst(Actor self, in Target target, Armament a)
{
self.World.IssueOrder(new Order("Stop", self, false));
}
diff --git a/OpenRA.Mods.Cnc/Traits/TDGunboat.cs b/OpenRA.Mods.Cnc/Traits/TDGunboat.cs
index e9b53ee98b..e75590d01e 100644
--- a/OpenRA.Mods.Cnc/Traits/TDGunboat.cs
+++ b/OpenRA.Mods.Cnc/Traits/TDGunboat.cs
@@ -202,16 +202,16 @@ namespace OpenRA.Mods.Cnc.Traits
public Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null) { return null; }
- public Activity MoveWithinRange(Target target, WDist range,
+ public Activity MoveWithinRange(in Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
- public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
+ public Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
- public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
+ public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
public Activity ReturnToCell(Actor self) { return null; }
- public Activity MoveToTarget(Actor self, Target target,
+ public Activity MoveToTarget(Actor self, in Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
- public Activity MoveIntoTarget(Actor self, Target target) { return null; }
+ public Activity MoveIntoTarget(Actor self, in Target target) { return null; }
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.Cnc.Traits
// Actors with TDGunboat always move
public MovementType CurrentMovementTypes { get { return MovementType.Horizontal; } set { } }
- public bool CanEnterTargetNow(Actor self, Target target)
+ public bool CanEnterTargetNow(Actor self, in Target target)
{
return false;
}
diff --git a/OpenRA.Mods.Cnc/TraitsInterfaces.cs b/OpenRA.Mods.Cnc/TraitsInterfaces.cs
index 22471d325b..f93aedbb00 100644
--- a/OpenRA.Mods.Cnc/TraitsInterfaces.cs
+++ b/OpenRA.Mods.Cnc/TraitsInterfaces.cs
@@ -14,5 +14,5 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[RequireExplicitImplementation]
- public interface INotifyTeslaCharging { void Charging(Actor self, Target target); }
+ public interface INotifyTeslaCharging { void Charging(Actor self, in Target target); }
}
diff --git a/OpenRA.Mods.Common/Activities/Air/Fly.cs b/OpenRA.Mods.Common/Activities/Air/Fly.cs
index 81062991b0..c4e8239698 100644
--- a/OpenRA.Mods.Common/Activities/Air/Fly.cs
+++ b/OpenRA.Mods.Common/Activities/Air/Fly.cs
@@ -31,13 +31,13 @@ namespace OpenRA.Mods.Common.Activities
bool useLastVisibleTarget;
readonly List positionBuffer = new List();
- 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();
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)
{
diff --git a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs
index 4a3ebe124d..5476231ceb 100644
--- a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs
+++ b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs b/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs
index a06c3fefa3..eac5b579d4 100644
--- a/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs
+++ b/OpenRA.Mods.Common/Activities/Air/FlyFollow.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs
index f9f42ed6a1..2f5354838d 100644
--- a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs
+++ b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Air/Land.cs b/OpenRA.Mods.Common/Activities/Air/Land.cs
index e6023cab83..4532af072d 100644
--- a/OpenRA.Mods.Common/Activities/Air/Land.cs
+++ b/OpenRA.Mods.Common/Activities/Air/Land.cs
@@ -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();
this.target = target;
diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs
index 4855c3aa70..9cbb3f1f9a 100644
--- a/OpenRA.Mods.Common/Activities/Attack.cs
+++ b/OpenRA.Mods.Common/Activities/Attack.cs
@@ -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)
{
diff --git a/OpenRA.Mods.Common/Activities/CaptureActor.cs b/OpenRA.Mods.Common/Activities/CaptureActor.cs
index 21dcf59ea9..b2f5340d97 100644
--- a/OpenRA.Mods.Common/Activities/CaptureActor.cs
+++ b/OpenRA.Mods.Common/Activities/CaptureActor.cs
@@ -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();
}
- 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)
{
diff --git a/OpenRA.Mods.Common/Activities/DeliverUnit.cs b/OpenRA.Mods.Common/Activities/DeliverUnit.cs
index 7992dc3bca..b26ae7dd62 100644
--- a/OpenRA.Mods.Common/Activities/DeliverUnit.cs
+++ b/OpenRA.Mods.Common/Activities/DeliverUnit.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Demolish.cs b/OpenRA.Mods.Common/Activities/Demolish.cs
index 8c5818819e..28c5cd8cdd 100644
--- a/OpenRA.Mods.Common/Activities/Demolish.cs
+++ b/OpenRA.Mods.Common/Activities/Demolish.cs
@@ -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 damageTypes)
: base(self, target, Color.Crimson)
{
diff --git a/OpenRA.Mods.Common/Activities/DonateCash.cs b/OpenRA.Mods.Common/Activities/DonateCash.cs
index 31fa3d7380..41c2fde121 100644
--- a/OpenRA.Mods.Common/Activities/DonateCash.cs
+++ b/OpenRA.Mods.Common/Activities/DonateCash.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/DonateExperience.cs b/OpenRA.Mods.Common/Activities/DonateExperience.cs
index 04089126c0..01432b94d4 100644
--- a/OpenRA.Mods.Common/Activities/DonateExperience.cs
+++ b/OpenRA.Mods.Common/Activities/DonateExperience.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Enter.cs b/OpenRA.Mods.Common/Activities/Enter.cs
index 91887588eb..656dfba59d 100644
--- a/OpenRA.Mods.Common/Activities/Enter.cs
+++ b/OpenRA.Mods.Common/Activities/Enter.cs
@@ -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();
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
///
- protected virtual void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor) { }
+ protected virtual void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor) { }
///
/// Called when the actor is ready to transition from approaching to entering the target actor.
diff --git a/OpenRA.Mods.Common/Activities/Move/Follow.cs b/OpenRA.Mods.Common/Activities/Move/Follow.cs
index 8fb23f531a..f142d1cf70 100644
--- a/OpenRA.Mods.Common/Activities/Move/Follow.cs
+++ b/OpenRA.Mods.Common/Activities/Move/Follow.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs
index e6c25af018..286d98dd45 100644
--- a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs
+++ b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs
index c79ac68951..76d932e514 100644
--- a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs
+++ b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs
@@ -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)
{
diff --git a/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs b/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
index fba62e4a88..3c61c65f47 100644
--- a/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
+++ b/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
@@ -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();
this.target = target;
diff --git a/OpenRA.Mods.Common/Activities/RepairBridge.cs b/OpenRA.Mods.Common/Activities/RepairBridge.cs
index 4ffd63f410..24bbdff483 100644
--- a/OpenRA.Mods.Common/Activities/RepairBridge.cs
+++ b/OpenRA.Mods.Common/Activities/RepairBridge.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/RepairBuilding.cs b/OpenRA.Mods.Common/Activities/RepairBuilding.cs
index e364f832ad..e6261b51eb 100644
--- a/OpenRA.Mods.Common/Activities/RepairBuilding.cs
+++ b/OpenRA.Mods.Common/Activities/RepairBuilding.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/RideTransport.cs b/OpenRA.Mods.Common/Activities/RideTransport.cs
index 51113da2c7..a6b80c38a9 100644
--- a/OpenRA.Mods.Common/Activities/RideTransport.cs
+++ b/OpenRA.Mods.Common/Activities/RideTransport.cs
@@ -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();
diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs
index 49438de35f..2b4f8a6739 100644
--- a/OpenRA.Mods.Common/Activities/Transform.cs
+++ b/OpenRA.Mods.Common/Activities/Transform.cs
@@ -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;
diff --git a/OpenRA.Mods.Common/Activities/UnloadCargo.cs b/OpenRA.Mods.Common/Activities/UnloadCargo.cs
index acecfd8d24..e1a286a0d0 100644
--- a/OpenRA.Mods.Common/Activities/UnloadCargo.cs
+++ b/OpenRA.Mods.Common/Activities/UnloadCargo.cs
@@ -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();
diff --git a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs
index bf0f517d9e..d3c0c0c201 100644
--- a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs
+++ b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs
@@ -33,9 +33,9 @@ namespace OpenRA.Mods.Common.Orders
public string OrderID { get; private set; }
public int OrderPriority { get; private set; }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Actor)
return false;
diff --git a/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs
index 609c942eed..34138432a2 100644
--- a/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs
+++ b/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs
@@ -70,10 +70,7 @@ namespace OpenRA.Mods.Common.Orders
if (repairBuilding == null)
yield break;
- yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), mi.Modifiers.HasModifier(Modifiers.Shift))
- {
- VisualFeedbackTarget = Target.FromActor(underCursor)
- };
+ yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), Target.FromActor(underCursor), mi.Modifiers.HasModifier(Modifiers.Shift));
}
protected override void Tick(World world)
diff --git a/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs b/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs
index 53f5a40c4f..fa8f4a6e9b 100644
--- a/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs
+++ b/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs
@@ -32,12 +32,12 @@ namespace OpenRA.Mods.Common.Orders
public string OrderID { get; private set; }
public int OrderPriority { get; private set; }
public bool? ForceAttack = null;
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor);
public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
var type = target.Type;
if (type != TargetType.Actor && type != TargetType.FrozenActor)
diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs
index dad6586097..17a5ebae08 100644
--- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs
+++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs
@@ -875,20 +875,20 @@ namespace OpenRA.Mods.Common.Traits
return new Fly(self, Target.FromCell(self.World, cell), WDist.FromCells(nearEnough), targetLineColor: targetLineColor);
}
- public Activity MoveWithinRange(Target target, WDist range,
+ public Activity MoveWithinRange(in Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return new Fly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
}
- public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
+ public Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return new Fly(self, target, minRange, maxRange,
initialTargetPosition, targetLineColor);
}
- public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
+ public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return new FlyFollow(self, target, minRange, maxRange,
@@ -934,13 +934,13 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Activity MoveToTarget(Actor self, Target target,
+ public Activity MoveToTarget(Actor self, in Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return new Fly(self, target, initialTargetPosition, targetLineColor);
}
- public Activity MoveIntoTarget(Actor self, Target target)
+ public Activity MoveIntoTarget(Actor self, in Target target)
{
return new Land(self, target);
}
@@ -978,9 +978,11 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public bool CanEnterTargetNow(Actor self, Target target)
+ public bool CanEnterTargetNow(Actor self, in Target target)
{
- if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
+ // Lambdas can't use 'in' variables, so capture a copy for later
+ var targetActor = target;
+ if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != targetActor.Actor)))
return false;
MakeReservation(target.Actor);
@@ -1015,7 +1017,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (!IsTraitDisabled &&
(order.OrderID == "Enter" || order.OrderID == "Move" || order.OrderID == "Land" || order.OrderID == "ForceEnter"))
@@ -1250,7 +1252,7 @@ namespace OpenRA.Mods.Common.Traits
OrderID = "Move";
}
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
{
// Always prioritise orders over selecting other peoples actors or own actors that are already selected
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
@@ -1259,7 +1261,7 @@ namespace OpenRA.Mods.Common.Traits
return modifiers.HasModifier(TargetModifiers.ForceMove);
}
- public virtual bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public virtual bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false;
diff --git a/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs b/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs
index cd06feeeba..4b1b602928 100644
--- a/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs
+++ b/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs
@@ -48,12 +48,12 @@ namespace OpenRA.Mods.Common.Traits
aircraftInfo = self.Info.TraitInfo();
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new FlyAttack(self, source, newTarget, forceAttack, targetLineColor);
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
// Don't fire while landed or when outside the map.
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude
diff --git a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs
index 2df5ea89ba..7f55041ad0 100644
--- a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs
+++ b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
OnRemovedFromWorld(self);
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
throw new NotImplementedException("AttackBomber requires a scripted target");
}
diff --git a/OpenRA.Mods.Common/Traits/AmmoPool.cs b/OpenRA.Mods.Common/Traits/AmmoPool.cs
index c4379f147b..f4925d0fed 100644
--- a/OpenRA.Mods.Common/Traits/AmmoPool.cs
+++ b/OpenRA.Mods.Common/Traits/AmmoPool.cs
@@ -96,13 +96,13 @@ namespace OpenRA.Mods.Common.Traits
RemainingTicks = Info.ReloadDelay;
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (a != null && Info.Armaments.Contains(a.Info.Name))
TakeAmmo(self, 1);
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
void UpdateCondition(Actor self)
{
diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs
index f3f4ba3c57..5a96050db7 100644
--- a/OpenRA.Mods.Common/Traits/Armament.cs
+++ b/OpenRA.Mods.Common/Traits/Armament.cs
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
a();
}
- protected virtual bool CanFire(Actor self, Target target)
+ protected virtual bool CanFire(Actor self, in Target target)
{
if (IsReloading || IsTraitPaused)
return false;
@@ -249,7 +249,7 @@ namespace OpenRA.Mods.Common.Traits
// Note: facing is only used by the legacy positioning code
// The world coordinate model uses Actor.Orientation
- public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
+ public virtual Barrel CheckFire(Actor self, IFacing facing, in Target target)
{
if (!CanFire(self, target))
return null;
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Traits
return barrel;
}
- protected virtual void FireBarrel(Actor self, IFacing facing, Target target, Barrel barrel)
+ protected virtual void FireBarrel(Actor self, IFacing facing, in Target target, Barrel barrel)
{
foreach (var na in notifyAttacks)
na.PreparingAttack(self, target, this, barrel);
@@ -316,6 +316,8 @@ namespace OpenRA.Mods.Common.Traits
GuidedTarget = target
};
+ // Lambdas can't use 'in' variables, so capture a copy for later
+ var delayedTarget = target;
ScheduleDelayedAction(Info.FireDelay, () =>
{
if (args.Weapon.Projectile != null)
@@ -331,14 +333,14 @@ namespace OpenRA.Mods.Common.Traits
Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
foreach (var na in notifyAttacks)
- na.Attacking(self, target, this, barrel);
+ na.Attacking(self, delayedTarget, this, barrel);
Recoil = Info.Recoil;
}
});
}
- protected virtual void UpdateBurst(Actor self, Target target)
+ protected virtual void UpdateBurst(Actor self, in Target target)
{
if (--Burst > 0)
{
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs
index 6e43018a55..430fefcd95 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
return () => armaments;
}
- public bool TargetInFiringArc(Actor self, Target target, int facingTolerance)
+ public bool TargetInFiringArc(Actor self, in Target target, int facingTolerance)
{
if (facing == null)
return true;
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw, facingTolerance);
}
- protected virtual bool CanAttack(Actor self, Target target)
+ protected virtual bool CanAttack(Actor self, in Target target)
{
if (!self.IsInWorld || IsTraitDisabled || IsTraitPaused)
return false;
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Traits
return true;
}
- public virtual void DoAttack(Actor self, Target target)
+ public virtual void DoAttack(Actor self, in Target target)
{
if (!CanAttack(self, target))
return;
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order is AttackOrderTargeter)
return new Order(order.OrderID, self, target, queued);
@@ -226,9 +226,9 @@ namespace OpenRA.Mods.Common.Traits
return order.OrderString == attackOrderName || order.OrderString == forceAttackOrderName ? Info.Voice : null;
}
- public abstract Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
+ public abstract Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
- public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
+ public bool HasAnyValidWeapons(in Target t, bool checkForCenterTargetingWeapons = false)
{
if (IsTraitDisabled)
return false;
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.Traits
return false;
}
- public virtual WPos GetTargetPosition(WPos pos, Target target)
+ public virtual WPos GetTargetPosition(WPos pos, in Target target)
{
return HasAnyValidWeapons(target, true) ? target.CenterPosition : target.Positions.PositionClosestTo(pos);
}
@@ -298,7 +298,7 @@ namespace OpenRA.Mods.Common.Traits
return max;
}
- public WDist GetMinimumRangeVersusTarget(Target target)
+ public WDist GetMinimumRangeVersusTarget(in Target target)
{
if (IsTraitDisabled)
return WDist.Zero;
@@ -324,7 +324,7 @@ namespace OpenRA.Mods.Common.Traits
return min != WDist.MaxValue ? min : WDist.Zero;
}
- public WDist GetMaximumRangeVersusTarget(Target target)
+ public WDist GetMaximumRangeVersusTarget(in Target target)
{
if (IsTraitDisabled)
return WDist.Zero;
@@ -382,7 +382,7 @@ namespace OpenRA.Mods.Common.Traits
&& a.Weapon.IsValidAgainst(t, self.World, self));
}
- public void AttackTarget(Target target, AttackSource source, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
+ public void AttackTarget(in Target target, AttackSource source, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
{
if (IsTraitDisabled)
return;
@@ -395,9 +395,9 @@ namespace OpenRA.Mods.Common.Traits
OnResolveAttackOrder(self, activity, target, queued, forceAttack);
}
- public virtual void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack) { }
+ public virtual void OnResolveAttackOrder(Actor self, Activity activity, in Target target, bool queued, bool forceAttack) { }
- public bool IsReachableTarget(Target target, bool allowMove)
+ public bool IsReachableTarget(in Target target, bool allowMove)
{
return HasAnyValidWeapons(target)
&& (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo()));
@@ -427,9 +427,9 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get; private set; }
public int OrderPriority { get; private set; }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
- bool CanTargetActor(Actor self, Target target, ref TargetModifiers modifiers, ref string cursor)
+ bool CanTargetActor(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
{
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Traits
return true;
}
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
switch (target.Type)
{
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs b/OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs
index c303624a8d..100300abfa 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs
@@ -63,14 +63,14 @@ namespace OpenRA.Mods.Common.Traits
base.Tick(self);
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
charging = base.CanAttack(self, target) && IsReachableTarget(target, true);
return ChargeLevel >= info.ChargeLevel && charging;
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
void INotifySold.Selling(Actor self) { ChargeLevel = 0; }
void INotifySold.Sold(Actor self) { }
}
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs
index 7601474561..48bd574acb 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
bool opportunityForceAttack;
bool opportunityTargetIsPersistentTarget;
- public void SetRequestedTarget(Actor self, Target target, bool isForceAttack = false)
+ public void SetRequestedTarget(Actor self, in Target target, bool isForceAttack = false)
{
RequestedTarget = target;
requestedForceAttack = isForceAttack;
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
base.Created(self);
}
- protected bool CanAimAtTarget(Actor self, Target target, bool forceAttack)
+ protected bool CanAimAtTarget(Actor self, in Target target, bool forceAttack)
{
if (target.Type == TargetType.Actor && !target.Actor.CanBeViewedByPlayer(self.Owner))
return false;
@@ -154,12 +154,12 @@ namespace OpenRA.Mods.Common.Traits
base.Tick(self);
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new AttackActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
}
- public override void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack)
+ public override void OnResolveAttackOrder(Actor self, Activity activity, in Target target, bool queued, bool forceAttack)
{
// We can improve responsiveness for turreted actors by preempting
// the last order (usually a move) and setting the target immediately
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Traits
bool wasMovingWithinRange;
bool hasTicked;
- public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public AttackActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
attack = self.Trait();
move = allowMove ? self.TraitOrDefault() : null;
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFrontal.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFrontal.cs
index 50a405afb0..6e53c85189 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackFrontal.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackFrontal.cs
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
Info = info;
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
if (!base.CanAttack(self, target))
return false;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
return TargetInFiringArc(self, target, 4 * Info.FacingTolerance);
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new Activities.Attack(self, newTarget, allowMove, forceAttack, targetLineColor);
}
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs
index 793587af6a..2a3c1833e1 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
}
- public override void DoAttack(Actor self, Target target)
+ public override void DoAttack(Actor self, in Target target)
{
if (!CanAttack(self, target))
return;
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackOmni.cs b/OpenRA.Mods.Common/Traits/Attack/AttackOmni.cs
index 64e0c9cc9e..6af3355984 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackOmni.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackOmni.cs
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public AttackOmni(Actor self, AttackOmniInfo info)
: base(self, info) { }
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new SetTarget(this, newTarget, allowMove, forceAttack, targetLineColor);
}
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Color? targetLineColor;
Target target;
- public SetTarget(AttackOmni attack, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
+ public SetTarget(AttackOmni attack, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
this.target = target;
this.targetLineColor = targetLineColor;
diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs b/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs
index 1ae4611ead..8224777490 100644
--- a/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs
+++ b/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
turrets = self.TraitsImplementing().Where(t => info.Turrets.Contains(t.Info.Turret)).ToArray();
}
- protected override bool CanAttack(Actor self, Target target)
+ protected override bool CanAttack(Actor self, in Target target)
{
if (target.Type == TargetType.Invalid)
return false;
diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs
index 2d68b6f673..5e05b22f8a 100644
--- a/OpenRA.Mods.Common/Traits/AutoTarget.cs
+++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Traits
Attack(self, target, allowMove);
}
- void Attack(Actor self, Target target, bool allowMove)
+ void Attack(Actor self, in Target target, bool allowMove)
{
foreach (var ab in ActiveAttackBases)
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);
diff --git a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
index 41b1805529..f7f428126f 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/PrimaryBuilding.cs
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == OrderID)
return new Order(order.OrderID, self, false);
diff --git a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs
index b3f1915738..cd035638e7 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new RallyPointOrderTargeter(Info.Cursor); }
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == OrderID)
{
@@ -140,11 +140,11 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "SetRallyPoint"; } }
public int OrderPriority { get { return 0; } }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool ForceSet { get; private set; }
public bool IsQueued { get; protected set; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs
index 5d83c0229e..e3b48db8ec 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
}
// 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)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Enter" || order.OrderID == "Move")
return new Order(order.OrderID, self, target, queued);
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Traits
{
readonly TransformsIntoAircraft aircraft;
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
{
// Always prioritise orders over selecting other peoples actors or own actors that are already selected
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false;
diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoEntersTunnels.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoEntersTunnels.cs
index d691dce88d..ec9c221d6a 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoEntersTunnels.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoEntersTunnels.cs
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
return self.CurrentActivity is Transform || transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused);
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "EnterTunnel")
return new Order(order.OrderID, self, target, queued) { SuppressVisualFeedback = true };
diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs
index 9373be162d..d267c0ef57 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
}
// 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)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order is MoveOrderTargeter)
return new Order("Move", self, target, queued);
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
{
readonly TransformsIntoMobile mobile;
readonly bool rejectMove;
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
{
// Always prioritise orders over selecting other peoples actors or own actors that are already selected
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false;
diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs
index a657ab0c46..97985f3661 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "EnterTransport")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs
index 3762faaea9..5438686886 100644
--- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs
+++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
return Info.RepairActors.Contains(target.Info.Name);
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Repair")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/Captures.cs b/OpenRA.Mods.Common/Traits/Captures.cs
index a73d754d7e..ac1d30d212 100644
--- a/OpenRA.Mods.Common/Traits/Captures.cs
+++ b/OpenRA.Mods.Common/Traits/Captures.cs
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "CaptureActor")
return null;
diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs
index 494dd8186c..ae0734b311 100644
--- a/OpenRA.Mods.Common/Traits/Cargo.cs
+++ b/OpenRA.Mods.Common/Traits/Cargo.cs
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Unload")
return new Order(order.OrderID, self, queued);
diff --git a/OpenRA.Mods.Common/Traits/Carryall.cs b/OpenRA.Mods.Common/Traits/Carryall.cs
index 0d4d714f1b..d2bf3c9177 100644
--- a/OpenRA.Mods.Common/Traits/Carryall.cs
+++ b/OpenRA.Mods.Common/Traits/Carryall.cs
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "PickupUnit" || order.OrderID == "DeliverUnit" || order.OrderID == "Unload")
return new Order(order.OrderID, self, target, queued);
@@ -383,7 +383,7 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "DeliverUnit"; } }
public int OrderPriority { get { return 6; } }
public bool IsQueued { get; protected set; }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public CarryallDeliverUnitTargeter(AircraftInfo aircraftInfo, CarryallInfo info)
{
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
}
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (!info.AllowDropOff || !modifiers.HasModifier(TargetModifiers.ForceMove))
return false;
diff --git a/OpenRA.Mods.Common/Traits/Cloak.cs b/OpenRA.Mods.Common/Traits/Cloak.cs
index 434745c5b8..9d0b4e0884 100644
--- a/OpenRA.Mods.Common/Traits/Cloak.cs
+++ b/OpenRA.Mods.Common/Traits/Cloak.cs
@@ -108,9 +108,9 @@ namespace OpenRA.Mods.Common.Traits
public void Uncloak(int time) { remainingTime = Math.Max(remainingTime, time); }
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { if (Info.UncloakOn.HasFlag(UncloakType.Attack)) Uncloak(); }
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { if (Info.UncloakOn.HasFlag(UncloakType.Attack)) Uncloak(); }
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
void INotifyDamage.Damaged(Actor self, AttackInfo e)
{
diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs
index 7232a2fbe3..e1382ac943 100644
--- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs
+++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnAttack.cs
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- bool TargetChanged(Target lastTarget, Target target)
+ bool TargetChanged(in Target lastTarget, in Target target)
{
// Invalidate reveal changing the target.
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
return false;
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (IsTraitDisabled || IsTraitPaused)
return;
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
protected override void TraitDisabled(Actor self)
{
diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs
index f847d3750e..93f5288610 100644
--- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs
+++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "GrantConditionOnDeploy")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/DeliversCash.cs b/OpenRA.Mods.Common/Traits/DeliversCash.cs
index ee06db804f..09fe3b7a53 100644
--- a/OpenRA.Mods.Common/Traits/DeliversCash.cs
+++ b/OpenRA.Mods.Common/Traits/DeliversCash.cs
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new DeliversCashOrderTargeter(info); }
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "DeliverCash")
return null;
diff --git a/OpenRA.Mods.Common/Traits/DeliversExperience.cs b/OpenRA.Mods.Common/Traits/DeliversExperience.cs
index 7e04d2c315..e9ca4fbc00 100644
--- a/OpenRA.Mods.Common/Traits/DeliversExperience.cs
+++ b/OpenRA.Mods.Common/Traits/DeliversExperience.cs
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "DeliverExperience")
return null;
diff --git a/OpenRA.Mods.Common/Traits/Demolition.cs b/OpenRA.Mods.Common/Traits/Demolition.cs
index 35a9c10f86..173f06580b 100644
--- a/OpenRA.Mods.Common/Traits/Demolition.cs
+++ b/OpenRA.Mods.Common/Traits/Demolition.cs
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new DemolitionOrderTargeter(info); }
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "C4")
return null;
diff --git a/OpenRA.Mods.Common/Traits/EngineerRepair.cs b/OpenRA.Mods.Common/Traits/EngineerRepair.cs
index aebf6b2ea1..45e73ba7fa 100644
--- a/OpenRA.Mods.Common/Traits/EngineerRepair.cs
+++ b/OpenRA.Mods.Common/Traits/EngineerRepair.cs
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "EngineerRepair")
return null;
diff --git a/OpenRA.Mods.Common/Traits/EntersTunnels.cs b/OpenRA.Mods.Common/Traits/EntersTunnels.cs
index a1abb46574..6141e25357 100644
--- a/OpenRA.Mods.Common/Traits/EntersTunnels.cs
+++ b/OpenRA.Mods.Common/Traits/EntersTunnels.cs
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
return !requireForceMove || modifiers.HasModifier(TargetModifiers.ForceMove);
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "EnterTunnel")
return null;
diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs
index 27bbe76433..9acfe9c333 100644
--- a/OpenRA.Mods.Common/Traits/Harvester.cs
+++ b/OpenRA.Mods.Common/Traits/Harvester.cs
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Deliver" || order.OrderID == "Harvest")
return new Order(order.OrderID, self, target, queued);
@@ -364,9 +364,9 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "Harvest"; } }
public int OrderPriority { get { return 10; } }
public bool IsQueued { get; protected set; }
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
diff --git a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs
index 814c95a185..992ac6373a 100644
--- a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs
+++ b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs
@@ -88,13 +88,13 @@ namespace OpenRA.Mods.Common.Traits
Panic();
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (self.World.SharedRandom.Next(100) < info.AttackPanicChance)
Panic();
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
int ISpeedModifier.GetSpeedModifier()
{
diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs
index 2f7f2a24ca..77ad893c70 100644
--- a/OpenRA.Mods.Common/Traits/Mobile.cs
+++ b/OpenRA.Mods.Common/Traits/Mobile.cs
@@ -602,19 +602,19 @@ namespace OpenRA.Mods.Common.Traits
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), ignoreActor, evaluateNearestMovableCell, targetLineColor));
}
- public Activity MoveWithinRange(Target target, WDist range,
+ public Activity MoveWithinRange(in Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return WrapMove(new MoveWithinRange(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor));
}
- public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
+ public Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return WrapMove(new MoveWithinRange(self, target, minRange, maxRange, initialTargetPosition, targetLineColor));
}
- public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
+ public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
return WrapMove(new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor));
@@ -675,7 +675,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Activity MoveToTarget(Actor self, Target target,
+ public Activity MoveToTarget(Actor self, in Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
if (target.Type == TargetType.Invalid)
@@ -684,7 +684,7 @@ namespace OpenRA.Mods.Common.Traits
return WrapMove(new MoveAdjacentTo(self, target, initialTargetPosition, targetLineColor));
}
- public Activity MoveIntoTarget(Actor self, Target target)
+ public Activity MoveIntoTarget(Actor self, in Target target)
{
if (target.Type == TargetType.Invalid)
return null;
@@ -711,7 +711,7 @@ namespace OpenRA.Mods.Common.Traits
return NearestMoveableCell(target, 1, 10);
}
- public bool CanEnterTargetNow(Actor self, Target target)
+ public bool CanEnterTargetNow(Actor self, in Target target)
{
if (target.Type == TargetType.FrozenActor && !target.FrozenActor.IsValid)
return false;
@@ -904,7 +904,7 @@ namespace OpenRA.Mods.Common.Traits
}
// 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)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order is MoveOrderTargeter)
return new Order("Move", self, target, queued);
@@ -968,7 +968,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Mobile mobile;
readonly LocomotorInfo locomotorInfo;
readonly bool rejectMove;
- public bool TargetOverridesSelection(Actor self, Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
+ public bool TargetOverridesSelection(Actor self, in Target target, List actorsAt, CPos xy, TargetModifiers modifiers)
{
// Always prioritise orders over selecting other peoples actors or own actors that are already selected
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
@@ -988,7 +988,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
- public bool CanTarget(Actor self, Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
+ public bool CanTarget(Actor self, in Target target, List othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (rejectMove || target.Type != TargetType.Terrain || (mobile.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false;
diff --git a/OpenRA.Mods.Common/Traits/Passenger.cs b/OpenRA.Mods.Common/Traits/Passenger.cs
index 1bdb88f343..673da4dd65 100644
--- a/OpenRA.Mods.Common/Traits/Passenger.cs
+++ b/OpenRA.Mods.Common/Traits/Passenger.cs
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "EnterTransport")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs b/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs
index de805d4746..552846ef30 100644
--- a/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs
+++ b/OpenRA.Mods.Common/Traits/ReloadAmmoPool.cs
@@ -66,13 +66,13 @@ namespace OpenRA.Mods.Common.Traits
});
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (Info.ResetOnFire)
remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier()));
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
void ITick.Tick(Actor self)
{
diff --git a/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs
index ee3cfd8eaf..77497874ce 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithAttackAnimation.cs
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
wsb.PlayCustomAnimation(self, Info.Sequence);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
{
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
if (a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
{
diff --git a/OpenRA.Mods.Common/Traits/Render/WithAttackOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithAttackOverlay.cs
index a13f986f07..5f7b3506e6 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithAttackOverlay.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithAttackOverlay.cs
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
overlay.PlayThen(info.Sequence, () => attacking = false);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Attack)
{
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Preparation)
{
diff --git a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs
index f9178ed220..710384e2b5 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
- public void Attacking(Actor self, Target target, Armament a)
+ public void Attacking(Actor self, in Target target, Armament a)
{
var info = GetDisplayInfo();
if (!info.AttackSequences.TryGetValue(a.Info.Name, out var sequence))
@@ -146,12 +146,12 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
Attacking(self, target, a);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { }
void ITick.Tick(Actor self)
{
diff --git a/OpenRA.Mods.Common/Traits/Render/WithMuzzleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithMuzzleOverlay.cs
index 30a9a12d13..fd08e58a4f 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithMuzzleOverlay.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithMuzzleOverlay.cs
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (a == null || barrel == null || !armaments.Contains(a))
return;
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.Render
anims[barrel].Animation.PlayThen(sequence, () => visible[barrel] = false);
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
IEnumerable IRender.Render(Actor self, WorldRenderer wr)
{
diff --git a/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs
index d943f587b8..67dc93a443 100644
--- a/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs
+++ b/OpenRA.Mods.Common/Traits/Render/WithTurretAttackAnimation.cs
@@ -64,13 +64,13 @@ namespace OpenRA.Mods.Common.Traits.Render
PlayAttackAnimation(self);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
NotifyAttack(self);
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
NotifyAttack(self);
diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs
index b3330f1d59..70ecabef45 100644
--- a/OpenRA.Mods.Common/Traits/Repairable.cs
+++ b/OpenRA.Mods.Common/Traits/Repairable.cs
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "Repair")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs
index b61f02f72e..d35b7e9482 100644
--- a/OpenRA.Mods.Common/Traits/RepairableNear.cs
+++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "RepairNear")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/RepairsBridges.cs b/OpenRA.Mods.Common/Traits/RepairsBridges.cs
index 2983cec864..d142b14ea0 100644
--- a/OpenRA.Mods.Common/Traits/RepairsBridges.cs
+++ b/OpenRA.Mods.Common/Traits/RepairsBridges.cs
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new RepairBridgeOrderTargeter(info); }
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "RepairBridge")
return new Order(order.OrderID, self, target, queued);
diff --git a/OpenRA.Mods.Common/Traits/RevealOnFire.cs b/OpenRA.Mods.Common/Traits/RevealOnFire.cs
index d6afdf6dda..38dfb7d89c 100644
--- a/OpenRA.Mods.Common/Traits/RevealOnFire.cs
+++ b/OpenRA.Mods.Common/Traits/RevealOnFire.cs
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (IsTraitDisabled)
return;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- Player GetTargetPlayer(Target target)
+ Player GetTargetPlayer(in Target target)
{
if (target.Type == TargetType.Actor)
return target.Actor.Owner;
@@ -74,6 +74,6 @@ namespace OpenRA.Mods.Common.Traits
return null;
}
- void INotifyAttack.PreparingAttack(Actor self, OpenRA.Traits.Target target, Armament a, Barrel barrel) { }
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
}
}
diff --git a/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs b/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs
index 8e9fe37cd9..aef3dde90c 100644
--- a/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs
+++ b/OpenRA.Mods.Common/Traits/Sound/AttackSounds.cs
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
Game.Sound.Play(SoundType.World, info.Sounds, self.World, self.CenterPosition);
}
- void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Attack)
{
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
}
}
- void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
+ void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Preparation)
{
diff --git a/OpenRA.Mods.Common/Traits/Transforms.cs b/OpenRA.Mods.Common/Traits/Transforms.cs
index bef966c057..b1921ee2ff 100644
--- a/OpenRA.Mods.Common/Traits/Transforms.cs
+++ b/OpenRA.Mods.Common/Traits/Transforms.cs
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
+ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID == "DeployTransform")
return new Order(order.OrderID, self, queued);
diff --git a/OpenRA.Mods.Common/Traits/Turreted.cs b/OpenRA.Mods.Common/Traits/Turreted.cs
index 6e98d4de8b..3e79d126b6 100644
--- a/OpenRA.Mods.Common/Traits/Turreted.cs
+++ b/OpenRA.Mods.Common/Traits/Turreted.cs
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public bool FaceTarget(Actor self, Target target)
+ public bool FaceTarget(Actor self, in Target target)
{
if (IsTraitDisabled || IsTraitPaused || attack == null || attack.IsTraitDisabled || attack.IsTraitPaused)
return false;
diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs
index e75fb18675..009005d7ae 100644
--- a/OpenRA.Mods.Common/TraitsInterfaces.cs
+++ b/OpenRA.Mods.Common/TraitsInterfaces.cs
@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
[RequireExplicitImplementation]
public interface INotifyAttack
{
- void Attacking(Actor self, Target target, Armament a, Barrel barrel);
- void PreparingAttack(Actor self, Target target, Armament a, Barrel barrel);
+ void Attacking(Actor self, in Target target, Armament a, Barrel barrel);
+ void PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel);
}
[RequireExplicitImplementation]
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); }
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
- public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
+ public interface INotifyBurstComplete { void FiredBurst(Actor self, in Target target, Armament a); }
public interface INotifyChat { bool OnChat(string from, string message); }
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced, string productionType, TypeDictionary init); }
@@ -414,21 +414,21 @@ namespace OpenRA.Mods.Common.Traits
{
Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null);
- Activity MoveWithinRange(Target target, WDist range,
+ Activity MoveWithinRange(in Target target, WDist range,
WPos? initialTargetPosition = null, Color? targetLineColor = null);
- Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
+ Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null);
- Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
+ Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null);
- Activity MoveToTarget(Actor self, Target target,
+ Activity MoveToTarget(Actor self, in Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null);
Activity ReturnToCell(Actor self);
- Activity MoveIntoTarget(Actor self, Target target);
+ Activity MoveIntoTarget(Actor self, in Target target);
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
CPos NearestMoveableCell(CPos target);
MovementType CurrentMovementTypes { get; set; }
- bool CanEnterTargetNow(Actor self, Target target);
+ bool CanEnterTargetNow(Actor self, in Target target);
}
public interface IWrapMove
diff --git a/OpenRA.Mods.Common/Util.cs b/OpenRA.Mods.Common/Util.cs
index 2a130fd589..81b95e3995 100644
--- a/OpenRA.Mods.Common/Util.cs
+++ b/OpenRA.Mods.Common/Util.cs
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common
return cells.SelectMany(c => Neighbours(c, allowDiagonal)).Distinct();
}
- public static IEnumerable AdjacentCells(World w, Target target)
+ public static IEnumerable AdjacentCells(World w, in Target target)
{
var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct();
return ExpandFootprint(cells, true);
diff --git a/OpenRA.Mods.Common/Warheads/ChangeOwnerWarhead.cs b/OpenRA.Mods.Common/Warheads/ChangeOwnerWarhead.cs
index 3d0acbd1ee..ca31040ea4 100644
--- a/OpenRA.Mods.Common/Warheads/ChangeOwnerWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/ChangeOwnerWarhead.cs
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly WDist Range = WDist.FromCells(1);
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
var firedBy = args.SourceActor;
var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :
diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs
index a09419cce8..acba4aebfc 100644
--- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Warheads
return true;
}
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
diff --git a/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs
index aa73775823..b68786c08c 100644
--- a/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/CreateResourceWarhead.cs
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Warheads
}
// TODO: Allow maximum resource splatter to be defined. (Per tile, and in total).
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
diff --git a/OpenRA.Mods.Common/Warheads/DamageWarhead.cs b/OpenRA.Mods.Common/Warheads/DamageWarhead.cs
index 7a74a733cc..68449d8a1f 100644
--- a/OpenRA.Mods.Common/Warheads/DamageWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/DamageWarhead.cs
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads
return base.IsValidAgainst(victim, firedBy);
}
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
var firedBy = args.SourceActor;
diff --git a/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs b/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs
index 84372fbf12..a2af79a314 100644
--- a/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/DestroyResourceWarhead.cs
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly int[] Size = { 0, 0 };
// TODO: Allow maximum resource removal to be defined. (Per tile, and in total).
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
diff --git a/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs b/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs
index 0d0cebedc6..760d8032bc 100644
--- a/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Warheads
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(Weapon.ToLowerInvariant()));
}
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
diff --git a/OpenRA.Mods.Common/Warheads/FlashPaletteEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/FlashPaletteEffectWarhead.cs
index dfe2f7d57b..1d2b76da20 100644
--- a/OpenRA.Mods.Common/Warheads/FlashPaletteEffectWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/FlashPaletteEffectWarhead.cs
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Duration of the flashing, measured in ticks. Set to -1 to default to the `Length` of the `FlashPaletteEffect`.")]
public readonly int Duration = 0;
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
foreach (var flash in args.SourceActor.World.WorldActor.TraitsImplementing())
if (flash.Info.Type == FlashType)
diff --git a/OpenRA.Mods.Common/Warheads/GrantExternalConditionWarhead.cs b/OpenRA.Mods.Common/Warheads/GrantExternalConditionWarhead.cs
index 9255ad59e3..20218a1f8b 100644
--- a/OpenRA.Mods.Common/Warheads/GrantExternalConditionWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/GrantExternalConditionWarhead.cs
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly WDist Range = WDist.FromCells(1);
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
var firedBy = args.SourceActor;
var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :
diff --git a/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs b/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs
index a8ebe75d6e..c3ec4ac2c3 100644
--- a/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/LeaveSmudgeWarhead.cs
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Percentual chance the smudge is created.")]
public readonly int Chance = 100;
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
diff --git a/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs b/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs
index c30c8f06f4..2c1d41f940 100644
--- a/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs
+++ b/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Warheads
[Desc("Shake multipliers by the X and Y axis, comma-separated.")]
public readonly float2 Multiplier = new float2(0, 0);
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
args.SourceActor.World.WorldActor.Trait().AddEffect(Duration, target.CenterPosition, Intensity, Multiplier);
}
diff --git a/OpenRA.Mods.Common/Warheads/Warhead.cs b/OpenRA.Mods.Common/Warheads/Warhead.cs
index 6405022f9b..6b8b9a313d 100644
--- a/OpenRA.Mods.Common/Warheads/Warhead.cs
+++ b/OpenRA.Mods.Common/Warheads/Warhead.cs
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Warheads
}
/// Applies the warhead's effect against the target.
- public abstract void DoImpact(Target target, WarheadArgs args);
+ public abstract void DoImpact(in Target target, WarheadArgs args);
/// Checks if the warhead is valid against (can do something to) the actor.
public virtual bool IsValidAgainst(Actor victim, Actor firedBy)
diff --git a/OpenRA.Mods.D2k/Activities/SwallowActor.cs b/OpenRA.Mods.D2k/Activities/SwallowActor.cs
index 83cef0b1cc..e75fb730b0 100644
--- a/OpenRA.Mods.D2k/Activities/SwallowActor.cs
+++ b/OpenRA.Mods.D2k/Activities/SwallowActor.cs
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.D2k.Activities
AttackState stance;
int attackingToken = Actor.InvalidConditionToken;
- public SwallowActor(Actor self, Target target, Armament a, IFacing facing)
+ public SwallowActor(Actor self, in Target target, Armament a, IFacing facing)
{
this.target = target;
this.facing = facing;
diff --git a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs
index 9296205e87..4695b5cae2 100644
--- a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs
+++ b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.D2k.Traits
Info = info;
}
- public override void DoAttack(Actor self, Target target)
+ public override void DoAttack(Actor self, in Target target)
{
// This is so that the worm does not launch an attack against a target that has reached solid rock
if (target.Type != TargetType.Actor || !CanAttack(self, target))
@@ -70,14 +70,14 @@ namespace OpenRA.Mods.D2k.Traits
self.QueueActivity(false, new SwallowActor(self, target, a, facing));
}
- public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
+ public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new SwallowTarget(self, newTarget, allowMove, forceAttack);
}
public class SwallowTarget : Attack
{
- public SwallowTarget(Actor self, Target target, bool allowMovement, bool forceAttack)
+ public SwallowTarget(Actor self, in Target target, bool allowMovement, bool forceAttack)
: base(self, target, allowMovement, forceAttack) { }
protected override Target RecalculateTarget(Actor self, out bool targetIsHiddenActor)
diff --git a/OpenRA.Mods.D2k/Warheads/DamagesConcreteWarhead.cs b/OpenRA.Mods.D2k/Warheads/DamagesConcreteWarhead.cs
index d9e5cd36b5..102ed61c1a 100644
--- a/OpenRA.Mods.D2k/Warheads/DamagesConcreteWarhead.cs
+++ b/OpenRA.Mods.D2k/Warheads/DamagesConcreteWarhead.cs
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.D2k.Warheads
[FieldLoader.Require]
public readonly int Damage = 0;
- public override void DoImpact(Target target, WarheadArgs args)
+ public override void DoImpact(in Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;