Use in parameter for Target

This commit is contained in:
teinarss
2020-08-19 20:47:59 +02:00
committed by abcdefg30
parent 13a8b6bda2
commit 13581c030d
113 changed files with 259 additions and 240 deletions

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Activities
public readonly Color Color; public readonly Color Color;
public readonly Sprite Tile; 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, // Note: Not all activities are drawable. In that case, pass Target.Invalid as target,
// if "yield break" in TargetLineNode(Actor self) is not feasible. // if "yield break" in TargetLineNode(Actor self) is not feasible.

View File

@@ -163,7 +163,7 @@ namespace OpenRA.GameRules
} }
/// <summary>Checks if the weapon is valid against (can target) the target.</summary> /// <summary>Checks if the weapon is valid against (can target) the target.</summary>
public bool IsValidAgainst(Target target, World world, Actor firedBy) public bool IsValidAgainst(in Target target, World world, Actor firedBy)
{ {
if (target.Type == TargetType.Actor) if (target.Type == TargetType.Actor)
return IsValidAgainst(target.Actor, firedBy); return IsValidAgainst(target.Actor, firedBy);
@@ -220,20 +220,24 @@ namespace OpenRA.GameRules
} }
/// <summary>Applies all the weapon's warheads to the target.</summary> /// <summary>Applies all the weapon's warheads to the target.</summary>
public void Impact(Target target, WarheadArgs args) public void Impact(in Target target, WarheadArgs args)
{ {
var world = args.SourceActor.World; var world = args.SourceActor.World;
foreach (var warhead in Warheads) foreach (var warhead in Warheads)
{ {
if (warhead.Delay > 0) 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 else
warhead.DoImpact(target, args); warhead.DoImpact(target, args);
} }
} }
/// <summary>Applies all the weapon's warheads to the target. Only use for projectile-less, special-case impacts.</summary> /// <summary>Applies all the weapon's warheads to the target. Only use for projectile-less, special-case impacts.</summary>
public void Impact(Target target, Actor firedBy) public void Impact(in Target target, Actor firedBy)
{ {
// The impact will happen immediately at target.CenterPosition. // The impact will happen immediately at target.CenterPosition.
var args = new WarheadArgs var args = new WarheadArgs

View File

@@ -55,7 +55,7 @@ namespace OpenRA
public readonly string OrderString; public readonly string OrderString;
public readonly Actor Subject; public readonly Actor Subject;
public readonly bool Queued; public readonly bool Queued;
public readonly Target Target; public ref readonly Target Target => ref target;
public readonly Actor[] GroupedActors; public readonly Actor[] GroupedActors;
public string TargetString; public string TargetString;
@@ -66,15 +66,18 @@ namespace OpenRA
public OrderType Type = OrderType.Fields; public OrderType Type = OrderType.Fields;
public bool SuppressVisualFeedback; public bool SuppressVisualFeedback;
public Target VisualFeedbackTarget; public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget;
public Player Player { get { return Subject != null ? Subject.Owner : null; } } 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 ?? ""; OrderString = orderString ?? "";
Subject = subject; Subject = subject;
Target = target; this.target = target;
TargetString = targetString; TargetString = targetString;
Queued = queued; Queued = queued;
ExtraActors = extraActors; ExtraActors = extraActors;
@@ -278,9 +281,15 @@ namespace OpenRA
public Order(string orderString, Actor subject, bool queued, Actor[] extraActors = null, Actor[] groupedActors = null) 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) { } : 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) { } : 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() public byte[] Serialize()
{ {
var minLength = 1 + OrderString.Length + 1; var minLength = 1 + OrderString.Length + 1;

View File

@@ -196,15 +196,17 @@ namespace OpenRA.Orders
public readonly IOrderTargeter Order; public readonly IOrderTargeter Order;
public readonly IIssueOrder Trait; public readonly IIssueOrder Trait;
public readonly string Cursor; 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; Actor = actor;
Order = order; Order = order;
Trait = trait; Trait = trait;
Cursor = cursor; Cursor = cursor;
Target = target; this.target = target;
} }
} }

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Traits
} }
public static Target FromPos(WPos p) { return new Target(p); } 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 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 FromActor(Actor a) { return a != null ? new Target(a) : Invalid; }
public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); } public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); }

View File

@@ -128,7 +128,7 @@ namespace OpenRA.Traits
public interface IIssueOrder public interface IIssueOrder
{ {
IEnumerable<IOrderTargeter> Orders { get; } IEnumerable<IOrderTargeter> Orders { get; }
Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued); Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued);
} }
[Flags] [Flags]
@@ -147,9 +147,9 @@ namespace OpenRA.Traits
{ {
string OrderID { get; } string OrderID { get; }
int OrderPriority { get; } int OrderPriority { get; }
bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor); bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
bool IsQueued { get; } bool IsQueued { get; }
bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers); bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers);
} }
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
@@ -517,7 +517,7 @@ namespace OpenRA.Traits
int Delay { get; } int Delay { get; }
bool IsValidAgainst(Actor victim, Actor firedBy); bool IsValidAgainst(Actor victim, Actor firedBy);
bool IsValidAgainst(FrozenActor 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<TInfo> { void RulesetLoaded(Ruleset rules, TInfo info); } public interface IRulesetLoaded<TInfo> { void RulesetLoaded(Ruleset rules, TInfo info); }

View File

@@ -24,14 +24,14 @@ namespace OpenRA.Mods.Cnc.Activities
readonly INotifyInfiltration[] notifiers; readonly INotifyInfiltration[] notifiers;
Actor enterActor; Actor enterActor;
public Infiltrate(Actor self, Target target, Infiltrates infiltrates) public Infiltrate(Actor self, in Target target, Infiltrates infiltrates)
: base(self, target, Color.Crimson) : base(self, target, Color.Crimson)
{ {
this.infiltrates = infiltrates; this.infiltrates = infiltrates;
notifiers = self.TraitsImplementing<INotifyInfiltration>().ToArray(); notifiers = self.TraitsImplementing<INotifyInfiltration>().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) if (infiltrates.IsTraitDisabled)
Cancel(self, true); Cancel(self, true);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc.Activities
int ticks = 0; int ticks = 0;
WPos targetPosition; 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.mobile = mobile;
this.targetMobile = targetMobile; this.targetMobile = targetMobile;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.Activities
BitSet<TargetableType> lastVisibleTargetTypes; BitSet<TargetableType> lastVisibleTargetTypes;
Player lastVisibleOwner; 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.target = target;
this.targetLineColor = targetLineColor; this.targetLineColor = targetLineColor;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Effects
int weaponDelay; int weaponDelay;
bool impacted = false; 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) int delay, string entryEffect, string entrySequence, string entryPalette)
{ {
this.target = target; this.target = target;

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Cnc.Effects
int weaponDelay; int weaponDelay;
bool impacted = false; 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.target = target;
this.firedBy = firedBy; this.firedBy = firedBy;

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
this.info = info; 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) if (target.Type != TargetType.Actor)
return false; return false;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Traits
leapToken = self.RevokeCondition(leapToken); 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); return new LeapAttack(self, newTarget, allowMove, forceAttack, this, info, targetLineColor);
} }

View File

@@ -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) if (state == PopupState.Closed)
{ {

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Cnc.Traits
public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info) public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)
: base(self, 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); return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
} }
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly Color? targetLineColor; readonly Color? targetLineColor;
bool hasTicked; 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<AttackTDGunboatTurreted>(); attack = self.Trait<AttackTDGunboatTurreted>();
this.target = target; this.target = target;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc.Traits
charges = info.MaxCharges; charges = info.MaxCharges;
} }
protected override bool CanAttack(Actor self, Target target) protected override bool CanAttack(Actor self, in Target target)
{ {
if (!IsReachableTarget(target, true)) if (!IsReachableTarget(target, true))
return false; return false;
@@ -70,15 +70,15 @@ namespace OpenRA.Mods.Cnc.Traits
return base.CanAttack(self, target); 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; --charges;
timeToRecharge = info.ReloadDelay; 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); return new ChargeAttack(this, newTarget, forceAttack, targetLineColor);
} }
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly bool forceAttack; readonly bool forceAttack;
readonly Color? targetLineColor; 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.attack = attack;
this.target = target; this.target = target;
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.Cnc.Traits
readonly AttackTesla attack; readonly AttackTesla attack;
readonly Target target; readonly Target target;
public ChargeFire(AttackTesla attack, Target target) public ChargeFire(AttackTesla attack, in Target target)
{ {
this.attack = attack; this.attack = attack;
this.target = target; this.target = target;

View File

@@ -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") if (order.OrderID == "Disguise")
return new Order(order.OrderID, self, target, queued); 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)) if (info.RevealDisguiseOn.HasFlag(RevealDisguiseType.Attack))
DisguiseAs(null); DisguiseAs(null);

View File

@@ -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") if (order.OrderID != "Infiltrate")
return null; return null;
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Cnc.Traits
? Info.Voice : null; ? Info.Voice : null;
} }
public bool CanInfiltrateTarget(Actor self, Target target) public bool CanInfiltrateTarget(Actor self, in Target target)
{ {
switch (target.Type) switch (target.Type)
{ {

View File

@@ -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") if (order.OrderID != "DetonateAttack" && order.OrderID != "Detonate")
return null; return null;
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Cnc.Traits
assignTargetOnFirstRun = true; assignTargetOnFirstRun = true;
} }
public DetonationSequence(Actor self, MadTank mad, Target target) public DetonationSequence(Actor self, MadTank mad, in Target target)
{ {
this.self = self; this.self = self;
this.mad = mad; this.mad = mad;

View File

@@ -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) switch (order.OrderID)
{ {
@@ -299,9 +299,9 @@ namespace OpenRA.Mods.Cnc.Traits
{ {
public string OrderID { get { return "BeginMinefield"; } } public string OrderID { get { return "BeginMinefield"; } }
public int OrderPriority { get { return 5; } } public int OrderPriority { get { return 5; } }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;

View File

@@ -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") if (order.OrderID == "PortableChronoDeploy")
{ {
@@ -172,9 +172,9 @@ namespace OpenRA.Mods.Cnc.Traits
public string OrderID { get { return "PortableChronoTeleport"; } } public string OrderID { get { return "PortableChronoTeleport"; } }
public int OrderPriority { get { return 5; } } public int OrderPriority { get { return 5; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (modifiers.HasModifier(TargetModifiers.ForceMove)) if (modifiers.HasModifier(TargetModifiers.ForceMove))
{ {

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
wsb = init.Self.TraitsImplementing<WithSpriteBody>().Single(w => w.Info.Name == info.Body); wsb = init.Self.TraitsImplementing<WithSpriteBody>().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)); wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
} }

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
info.Palette, info.IsPlayerPalette); info.Palette, info.IsPlayerPalette);
} }
void INotifyTeslaCharging.Charging(Actor self, Target target) void INotifyTeslaCharging.Charging(Actor self, in Target target)
{ {
charging = true; charging = true;
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false); overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Traits
base.Created(self); 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)); self.World.IssueOrder(new Order("Stop", self, false));
} }

View File

@@ -202,16 +202,16 @@ namespace OpenRA.Mods.Cnc.Traits
public Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null, public Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = null) { return 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; } 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; } 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; } WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
public Activity ReturnToCell(Actor self) { 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; } 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 Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos) public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.Cnc.Traits
// Actors with TDGunboat always move // Actors with TDGunboat always move
public MovementType CurrentMovementTypes { get { return MovementType.Horizontal; } set { } } 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; return false;
} }

View File

@@ -14,5 +14,5 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits namespace OpenRA.Mods.Cnc.Traits
{ {
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyTeslaCharging { void Charging(Actor self, Target target); } public interface INotifyTeslaCharging { void Charging(Actor self, in Target target); }
} }

View File

@@ -31,13 +31,13 @@ namespace OpenRA.Mods.Common.Activities
bool useLastVisibleTarget; bool useLastVisibleTarget;
readonly List<WPos> positionBuffer = new List<WPos>(); readonly List<WPos> positionBuffer = new List<WPos>();
public Fly(Actor self, Target t, WDist nearEnough, WPos? initialTargetPosition = null, Color? targetLineColor = null) public Fly(Actor self, in Target t, WDist nearEnough, WPos? initialTargetPosition = null, Color? targetLineColor = null)
: this(self, t, initialTargetPosition, targetLineColor) : this(self, t, initialTargetPosition, targetLineColor)
{ {
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
public Fly(Actor self, Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null) public Fly(Actor self, in Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
aircraft = self.Trait<Aircraft>(); aircraft = self.Trait<Aircraft>();
target = t; target = t;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Activities
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
: this(self, t, initialTargetPosition, targetLineColor) : this(self, t, initialTargetPosition, targetLineColor)
{ {

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
bool hasTicked; bool hasTicked;
bool returnToBase; 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.source = source;
this.target = target; this.target = target;
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Activities
WDist exitRange; WDist exitRange;
bool targetIsVisibleActor; bool targetIsVisibleActor;
public FlyAttackRun(Actor self, Target t, WDist exitRange) public FlyAttackRun(Actor self, in Target t, WDist exitRange)
{ {
ChildHasPriority = false; ChildHasPriority = false;
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.Common.Activities
WDist exitRange; WDist exitRange;
readonly AttackAircraft attackAircraft; 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; ChildHasPriority = false;

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
bool useLastVisibleTarget; bool useLastVisibleTarget;
bool wasMovingWithinRange; 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) WPos? initialTargetPosition, Color? targetLineColor = null)
{ {
this.target = target; this.target = target;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Activities
this.endingDelay = endingDelay; 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(self, endingDelay)
{ {
this.target = target; this.target = target;

View File

@@ -40,16 +40,16 @@ namespace OpenRA.Mods.Common.Activities
assignTargetOnFirstRun = true; 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) { } : 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) { } : 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) { } : this(self, target, WDist.Zero, offset, facing, targetLineColor: targetLineColor) { }
public Land(Actor self, Target target, WDist landRange, WVec offset, WAngle? facing = null, CPos[] clearCells = null, Color? targetLineColor = null) public Land(Actor self, in Target target, WDist landRange, WVec offset, WAngle? facing = null, CPos[] clearCells = null, Color? targetLineColor = null)
{ {
aircraft = self.Trait<Aircraft>(); aircraft = self.Trait<Aircraft>();
this.target = target; this.target = target;

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Activities
WDist maxRange; WDist maxRange;
AttackStatus attackStatus = AttackStatus.UnableToAttack; 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.target = target;
this.targetLineColor = targetLineColor; this.targetLineColor = targetLineColor;
@@ -64,8 +64,11 @@ namespace OpenRA.Mods.Common.Activities
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain) || target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
{ {
lastVisibleTarget = Target.FromPos(target.CenterPosition); 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) lastVisibleMaximumRange = attackTraits.Where(x => !x.IsTraitDisabled)
.Min(x => x.GetMaximumRangeVersusTarget(target)); .Min(x => x.GetMaximumRangeVersusTarget(rangeTarget));
if (target.Type == TargetType.Actor) if (target.Type == TargetType.Actor)
{ {

View File

@@ -22,13 +22,13 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor; Actor enterActor;
CaptureManager enterCaptureManager; CaptureManager enterCaptureManager;
public CaptureActor(Actor self, Target target) public CaptureActor(Actor self, in Target target)
: base(self, target, Color.Crimson) : base(self, target, Color.Crimson)
{ {
manager = self.Trait<CaptureManager>(); manager = self.Trait<CaptureManager>();
} }
protected override void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor) protected override void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor)
{ {
if (target.Type == TargetType.Actor && enterActor != target.Actor) if (target.Type == TargetType.Actor && enterActor != target.Actor)
{ {

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Activities
assignTargetOnFirstRun = true; assignTargetOnFirstRun = true;
} }
public DeliverUnit(Actor self, Target destination, WDist deliverRange) public DeliverUnit(Actor self, in Target destination, WDist deliverRange)
{ {
this.destination = destination; this.destination = destination;
this.deliverRange = deliverRange; this.deliverRange = deliverRange;

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor; Actor enterActor;
IDemolishable[] enterDemolishables; IDemolishable[] enterDemolishables;
public Demolish(Actor self, Target target, EnterBehaviour enterBehaviour, int delay, public Demolish(Actor self, in Target target, EnterBehaviour enterBehaviour, int delay,
int flashes, int flashesDelay, int flashInterval, BitSet<DamageType> damageTypes) int flashes, int flashesDelay, int flashInterval, BitSet<DamageType> damageTypes)
: base(self, target, Color.Crimson) : base(self, target, Color.Crimson)
{ {

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
readonly int payload; readonly int payload;
readonly int playerExperience; 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) : base(self, target, Color.Yellow)
{ {
this.payload = payload; this.payload = payload;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor; Actor enterActor;
GainsExperience enterGainsExperience; 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) : base(self, target, Color.Yellow)
{ {
this.level = level; this.level = level;

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities
bool useLastVisibleTarget; bool useLastVisibleTarget;
EnterState lastState = EnterState.Approaching; EnterState lastState = EnterState.Approaching;
protected Enter(Actor self, Target target, Color? targetLineColor = null) protected Enter(Actor self, in Target target, Color? targetLineColor = null)
{ {
move = self.Trait<IMove>(); move = self.Trait<IMove>();
this.target = target; this.target = target;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Activities
/// Called early in the activity tick to allow subclasses to update state. /// Called early in the activity tick to allow subclasses to update state.
/// Call Cancel(self, true) if it is no longer valid to enter /// Call Cancel(self, true) if it is no longer valid to enter
/// </summary> /// </summary>
protected virtual void TickInner(Actor self, Target target, bool targetIsDeadOrHiddenActor) { } protected virtual void TickInner(Actor self, in Target target, bool targetIsDeadOrHiddenActor) { }
/// <summary> /// <summary>
/// Called when the actor is ready to transition from approaching to entering the target actor. /// Called when the actor is ready to transition from approaching to entering the target actor.

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Activities
bool useLastVisibleTarget; bool useLastVisibleTarget;
bool wasMovingWithinRange; 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) WPos? initialTargetPosition, Color? targetLineColor = null)
{ {
this.target = target; this.target = target;

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Activities
protected CPos lastVisibleTargetLocation; protected CPos lastVisibleTargetLocation;
bool useLastVisibleTarget; 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.target = target;
this.targetLineColor = targetLineColor; this.targetLineColor = targetLineColor;

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist maxRange; readonly WDist maxRange;
readonly WDist minRange; 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
: base(self, target, initialTargetPosition, targetLineColor) : base(self, target, initialTargetPosition, targetLineColor)
{ {

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist targetMovementThreshold; readonly WDist targetMovementThreshold;
WPos targetStartPos; WPos targetStartPos;
public VisualMoveIntoTarget(Actor self, Target target, WDist targetMovementThreshold, Color? targetLineColor = null) public VisualMoveIntoTarget(Actor self, in Target target, WDist targetMovementThreshold, Color? targetLineColor = null)
{ {
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
this.target = target; this.target = target;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
BridgeHut enterHut; BridgeHut enterHut;
LegacyBridgeHut enterLegacyHut; 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) : base(self, target, Color.Yellow)
{ {
this.enterBehaviour = enterBehaviour; this.enterBehaviour = enterBehaviour;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
IHealth enterHealth; IHealth enterHealth;
EngineerRepairable enterEngineerRepariable; EngineerRepairable enterEngineerRepariable;
public RepairBuilding(Actor self, Target target, EngineerRepairInfo info) public RepairBuilding(Actor self, in Target target, EngineerRepairInfo info)
: base(self, target, Color.Yellow) : base(self, target, Color.Yellow)
{ {
this.info = info; this.info = info;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
Cargo enterCargo; Cargo enterCargo;
Aircraft enterAircraft; Aircraft enterAircraft;
public RideTransport(Actor self, Target target) public RideTransport(Actor self, in Target target)
: base(self, target, Color.Green) : base(self, target, Color.Green)
{ {
passenger = self.Trait<Passenger>(); passenger = self.Trait<Passenger>();

View File

@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Target target; readonly Target target;
readonly Color? targetLineColor; 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.orderString = orderString;
this.target = target; this.target = target;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Activities
assignTargetOnFirstRun = true; 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; this.self = self;
cargo = self.Trait<Cargo>(); cargo = self.Trait<Cargo>();

View File

@@ -33,9 +33,9 @@ namespace OpenRA.Mods.Common.Orders
public string OrderID { get; private set; } public string OrderID { get; private set; }
public int OrderPriority { get; private set; } public int OrderPriority { get; private set; }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Actor) if (target.Type != TargetType.Actor)
return false; return false;

View File

@@ -70,10 +70,7 @@ namespace OpenRA.Mods.Common.Orders
if (repairBuilding == null) if (repairBuilding == null)
yield break; yield break;
yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), mi.Modifiers.HasModifier(Modifiers.Shift)) yield return new Order(orderId, underCursor, Target.FromActor(repairBuilding), Target.FromActor(underCursor), mi.Modifiers.HasModifier(Modifiers.Shift));
{
VisualFeedbackTarget = Target.FromActor(underCursor)
};
} }
protected override void Tick(World world) protected override void Tick(World world)

View File

@@ -32,12 +32,12 @@ namespace OpenRA.Mods.Common.Orders
public string OrderID { get; private set; } public string OrderID { get; private set; }
public int OrderPriority { get; private set; } public int OrderPriority { get; private set; }
public bool? ForceAttack = null; public bool? ForceAttack = null;
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor); 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 abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
var type = target.Type; var type = target.Type;
if (type != TargetType.Actor && type != TargetType.FrozenActor) if (type != TargetType.Actor && type != TargetType.FrozenActor)

View File

@@ -875,20 +875,20 @@ namespace OpenRA.Mods.Common.Traits
return new Fly(self, Target.FromCell(self.World, cell), WDist.FromCells(nearEnough), targetLineColor: targetLineColor); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return new Fly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return new Fly(self, target, minRange, maxRange, return new Fly(self, target, minRange, maxRange,
initialTargetPosition, targetLineColor); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return new FlyFollow(self, target, minRange, maxRange, 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return new Fly(self, target, initialTargetPosition, targetLineColor); 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); 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; return false;
MakeReservation(target.Actor); 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 && if (!IsTraitDisabled &&
(order.OrderID == "Enter" || order.OrderID == "Move" || order.OrderID == "Land" || order.OrderID == "ForceEnter")) (order.OrderID == "Enter" || order.OrderID == "Move" || order.OrderID == "Land" || order.OrderID == "ForceEnter"))
@@ -1250,7 +1252,7 @@ namespace OpenRA.Mods.Common.Traits
OrderID = "Move"; OrderID = "Move";
} }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers)
{ {
// Always prioritise orders over selecting other peoples actors or own actors that are already selected // 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))) 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); return modifiers.HasModifier(TargetModifiers.ForceMove);
} }
public virtual bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public virtual bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -48,12 +48,12 @@ namespace OpenRA.Mods.Common.Traits
aircraftInfo = self.Info.TraitInfo<AircraftInfo>(); aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
} }
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); 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. // Don't fire while landed or when outside the map.
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
OnRemovedFromWorld(self); 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"); throw new NotImplementedException("AttackBomber requires a scripted target");
} }

View File

@@ -96,13 +96,13 @@ namespace OpenRA.Mods.Common.Traits
RemainingTicks = Info.ReloadDelay; 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)) if (a != null && Info.Armaments.Contains(a.Info.Name))
TakeAmmo(self, 1); 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) void UpdateCondition(Actor self)
{ {

View File

@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
a(); a();
} }
protected virtual bool CanFire(Actor self, Target target) protected virtual bool CanFire(Actor self, in Target target)
{ {
if (IsReloading || IsTraitPaused) if (IsReloading || IsTraitPaused)
return false; return false;
@@ -249,7 +249,7 @@ namespace OpenRA.Mods.Common.Traits
// Note: facing is only used by the legacy positioning code // Note: facing is only used by the legacy positioning code
// The world coordinate model uses Actor.Orientation // 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)) if (!CanFire(self, target))
return null; return null;
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Traits
return barrel; 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) foreach (var na in notifyAttacks)
na.PreparingAttack(self, target, this, barrel); na.PreparingAttack(self, target, this, barrel);
@@ -316,6 +316,8 @@ namespace OpenRA.Mods.Common.Traits
GuidedTarget = target GuidedTarget = target
}; };
// Lambdas can't use 'in' variables, so capture a copy for later
var delayedTarget = target;
ScheduleDelayedAction(Info.FireDelay, () => ScheduleDelayedAction(Info.FireDelay, () =>
{ {
if (args.Weapon.Projectile != null) 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); Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
foreach (var na in notifyAttacks) foreach (var na in notifyAttacks)
na.Attacking(self, target, this, barrel); na.Attacking(self, delayedTarget, this, barrel);
Recoil = Info.Recoil; Recoil = Info.Recoil;
} }
}); });
} }
protected virtual void UpdateBurst(Actor self, Target target) protected virtual void UpdateBurst(Actor self, in Target target)
{ {
if (--Burst > 0) if (--Burst > 0)
{ {

View File

@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
return () => armaments; return () => armaments;
} }
public bool TargetInFiringArc(Actor self, Target target, int facingTolerance) public bool TargetInFiringArc(Actor self, in Target target, int facingTolerance)
{ {
if (facing == null) if (facing == null)
return true; return true;
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw, facingTolerance); 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) if (!self.IsInWorld || IsTraitDisabled || IsTraitPaused)
return false; return false;
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Traits
return true; return true;
} }
public virtual void DoAttack(Actor self, Target target) public virtual void DoAttack(Actor self, in Target target)
{ {
if (!CanAttack(self, target)) if (!CanAttack(self, target))
return; 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) if (order is AttackOrderTargeter)
return new Order(order.OrderID, self, target, queued); 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; 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) if (IsTraitDisabled)
return false; return false;
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.Traits
return false; 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); return HasAnyValidWeapons(target, true) ? target.CenterPosition : target.Positions.PositionClosestTo(pos);
} }
@@ -298,7 +298,7 @@ namespace OpenRA.Mods.Common.Traits
return max; return max;
} }
public WDist GetMinimumRangeVersusTarget(Target target) public WDist GetMinimumRangeVersusTarget(in Target target)
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return WDist.Zero; return WDist.Zero;
@@ -324,7 +324,7 @@ namespace OpenRA.Mods.Common.Traits
return min != WDist.MaxValue ? min : WDist.Zero; return min != WDist.MaxValue ? min : WDist.Zero;
} }
public WDist GetMaximumRangeVersusTarget(Target target) public WDist GetMaximumRangeVersusTarget(in Target target)
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return WDist.Zero; return WDist.Zero;
@@ -382,7 +382,7 @@ namespace OpenRA.Mods.Common.Traits
&& a.Weapon.IsValidAgainst(t, self.World, self)); && 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) if (IsTraitDisabled)
return; return;
@@ -395,9 +395,9 @@ namespace OpenRA.Mods.Common.Traits
OnResolveAttackOrder(self, activity, target, queued, forceAttack); 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) return HasAnyValidWeapons(target)
&& (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo<IMoveInfo>())); && (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo<IMoveInfo>()));
@@ -427,9 +427,9 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get; private set; } public string OrderID { get; private set; }
public int OrderPriority { get; private set; } public int OrderPriority { get; private set; }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> 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); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Traits
return true; return true;
} }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
switch (target.Type) switch (target.Type)
{ {

View File

@@ -63,14 +63,14 @@ namespace OpenRA.Mods.Common.Traits
base.Tick(self); 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); charging = base.CanAttack(self, target) && IsReachableTarget(target, true);
return ChargeLevel >= info.ChargeLevel && charging; return ChargeLevel >= info.ChargeLevel && charging;
} }
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { ChargeLevel = 0; } void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { } void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
void INotifySold.Selling(Actor self) { ChargeLevel = 0; } void INotifySold.Selling(Actor self) { ChargeLevel = 0; }
void INotifySold.Sold(Actor self) { } void INotifySold.Sold(Actor self) { }
} }

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
bool opportunityForceAttack; bool opportunityForceAttack;
bool opportunityTargetIsPersistentTarget; 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; RequestedTarget = target;
requestedForceAttack = isForceAttack; requestedForceAttack = isForceAttack;
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
base.Created(self); 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)) if (target.Type == TargetType.Actor && !target.Actor.CanBeViewedByPlayer(self.Owner))
return false; return false;
@@ -154,12 +154,12 @@ namespace OpenRA.Mods.Common.Traits
base.Tick(self); 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); 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 // We can improve responsiveness for turreted actors by preempting
// the last order (usually a move) and setting the target immediately // the last order (usually a move) and setting the target immediately
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Traits
bool wasMovingWithinRange; bool wasMovingWithinRange;
bool hasTicked; 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<AttackFollow>(); attack = self.Trait<AttackFollow>();
move = allowMove ? self.TraitOrDefault<IMove>() : null; move = allowMove ? self.TraitOrDefault<IMove>() : null;

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
Info = info; Info = info;
} }
protected override bool CanAttack(Actor self, Target target) protected override bool CanAttack(Actor self, in Target target)
{ {
if (!base.CanAttack(self, target)) if (!base.CanAttack(self, target))
return false; return false;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
return TargetInFiringArc(self, target, 4 * Info.FacingTolerance); 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); return new Activities.Attack(self, newTarget, allowMove, forceAttack, targetLineColor);
} }

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation)); 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)) if (!CanAttack(self, target))
return; return;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public AttackOmni(Actor self, AttackOmniInfo info) public AttackOmni(Actor self, AttackOmniInfo info)
: base(self, 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); return new SetTarget(this, newTarget, allowMove, forceAttack, targetLineColor);
} }
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Color? targetLineColor; readonly Color? targetLineColor;
Target target; 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.target = target;
this.targetLineColor = targetLineColor; this.targetLineColor = targetLineColor;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
turrets = self.TraitsImplementing<Turreted>().Where(t => info.Turrets.Contains(t.Info.Turret)).ToArray(); turrets = self.TraitsImplementing<Turreted>().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) if (target.Type == TargetType.Invalid)
return false; return false;

View File

@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Traits
Attack(self, target, allowMove); 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) foreach (var ab in ActiveAttackBases)
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove); ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);

View File

@@ -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) if (order.OrderID == OrderID)
return new Order(order.OrderID, self, false); return new Order(order.OrderID, self, false);

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new RallyPointOrderTargeter(Info.Cursor); } 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) if (order.OrderID == OrderID)
{ {
@@ -140,11 +140,11 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "SetRallyPoint"; } } public string OrderID { get { return "SetRallyPoint"; } }
public int OrderPriority { get { return 0; } } public int OrderPriority { get { return 0; } }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool ForceSet { get; private set; } public bool ForceSet { get; private set; }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
} }
// Note: Returns a valid order even if the unit can't move to the target // 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") if (order.OrderID == "Enter" || order.OrderID == "Move")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly TransformsIntoAircraft aircraft; readonly TransformsIntoAircraft aircraft;
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers)
{ {
// Always prioritise orders over selecting other peoples actors or own actors that are already selected // 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))) 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 int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (target.Type != TargetType.Terrain || (aircraft.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
return self.CurrentActivity is Transform || transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused); 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") if (order.OrderID == "EnterTunnel")
return new Order(order.OrderID, self, target, queued) { SuppressVisualFeedback = true }; return new Order(order.OrderID, self, target, queued) { SuppressVisualFeedback = true };

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
} }
// Note: Returns a valid order even if the unit can't move to the target // 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) if (order is MoveOrderTargeter)
return new Order("Move", self, target, queued); return new Order("Move", self, target, queued);
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly TransformsIntoMobile mobile; readonly TransformsIntoMobile mobile;
readonly bool rejectMove; readonly bool rejectMove;
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers)
{ {
// Always prioritise orders over selecting other peoples actors or own actors that are already selected // 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))) 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 int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (rejectMove || target.Type != TargetType.Terrain || (mobile.Info.RequiresForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -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") if (order.OrderID == "EnterTransport")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
return Info.RepairActors.Contains(target.Info.Name); 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") if (order.OrderID == "Repair")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -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") if (order.OrderID != "CaptureActor")
return null; return null;

View File

@@ -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") if (order.OrderID == "Unload")
return new Order(order.OrderID, self, queued); return new Order(order.OrderID, self, queued);

View File

@@ -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") if (order.OrderID == "PickupUnit" || order.OrderID == "DeliverUnit" || order.OrderID == "Unload")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);
@@ -383,7 +383,7 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "DeliverUnit"; } } public string OrderID { get { return "DeliverUnit"; } }
public int OrderPriority { get { return 6; } } public int OrderPriority { get { return 6; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public CarryallDeliverUnitTargeter(AircraftInfo aircraftInfo, CarryallInfo info) public CarryallDeliverUnitTargeter(AircraftInfo aircraftInfo, CarryallInfo info)
{ {
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info; this.info = info;
} }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (!info.AllowDropOff || !modifiers.HasModifier(TargetModifiers.ForceMove)) if (!info.AllowDropOff || !modifiers.HasModifier(TargetModifiers.ForceMove))
return false; return false;

View File

@@ -108,9 +108,9 @@ namespace OpenRA.Mods.Common.Traits
public void Uncloak(int time) { remainingTime = Math.Max(remainingTime, time); } 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) void INotifyDamage.Damaged(Actor self, AttackInfo e)
{ {

View File

@@ -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. // Invalidate reveal changing the target.
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor) if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
return false; 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) if (IsTraitDisabled || IsTraitPaused)
return; 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) protected override void TraitDisabled(Actor self)
{ {

View File

@@ -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") if (order.OrderID == "GrantConditionOnDeploy")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new DeliversCashOrderTargeter(info); } 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") if (order.OrderID != "DeliverCash")
return null; return null;

View File

@@ -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") if (order.OrderID != "DeliverExperience")
return null; return null;

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new DemolitionOrderTargeter(info); } 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") if (order.OrderID != "C4")
return null; return null;

View File

@@ -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") if (order.OrderID != "EngineerRepair")
return null; return null;

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
return !requireForceMove || modifiers.HasModifier(TargetModifiers.ForceMove); 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") if (order.OrderID != "EnterTunnel")
return null; return null;

View File

@@ -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") if (order.OrderID == "Deliver" || order.OrderID == "Harvest")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);
@@ -364,9 +364,9 @@ namespace OpenRA.Mods.Common.Traits
public string OrderID { get { return "Harvest"; } } public string OrderID { get { return "Harvest"; } }
public int OrderPriority { get { return 10; } } public int OrderPriority { get { return 10; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; } public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;

View File

@@ -88,13 +88,13 @@ namespace OpenRA.Mods.Common.Traits
Panic(); 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) if (self.World.SharedRandom.Next(100) < info.AttackPanicChance)
Panic(); 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() int ISpeedModifier.GetSpeedModifier()
{ {

View File

@@ -602,19 +602,19 @@ namespace OpenRA.Mods.Common.Traits
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), ignoreActor, evaluateNearestMovableCell, targetLineColor)); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return WrapMove(new MoveWithinRange(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor)); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return WrapMove(new MoveWithinRange(self, target, minRange, maxRange, initialTargetPosition, targetLineColor)); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
return WrapMove(new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor)); 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) WPos? initialTargetPosition = null, Color? targetLineColor = null)
{ {
if (target.Type == TargetType.Invalid) if (target.Type == TargetType.Invalid)
@@ -684,7 +684,7 @@ namespace OpenRA.Mods.Common.Traits
return WrapMove(new MoveAdjacentTo(self, target, initialTargetPosition, targetLineColor)); 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) if (target.Type == TargetType.Invalid)
return null; return null;
@@ -711,7 +711,7 @@ namespace OpenRA.Mods.Common.Traits
return NearestMoveableCell(target, 1, 10); 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) if (target.Type == TargetType.FrozenActor && !target.FrozenActor.IsValid)
return false; 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 // 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) if (order is MoveOrderTargeter)
return new Order("Move", self, target, queued); return new Order("Move", self, target, queued);
@@ -968,7 +968,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Mobile mobile; readonly Mobile mobile;
readonly LocomotorInfo locomotorInfo; readonly LocomotorInfo locomotorInfo;
readonly bool rejectMove; readonly bool rejectMove;
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers)
{ {
// Always prioritise orders over selecting other peoples actors or own actors that are already selected // 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))) 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 int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; } public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, in Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{ {
if (rejectMove || target.Type != TargetType.Terrain || (mobile.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove))) if (rejectMove || target.Type != TargetType.Terrain || (mobile.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false; return false;

View File

@@ -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") if (order.OrderID == "EnterTransport")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -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) if (Info.ResetOnFire)
remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier())); 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) void ITick.Tick(Actor self)
{ {

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
wsb.PlayCustomAnimation(self, Info.Sequence); 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) 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) if (a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
{ {

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
overlay.PlayThen(info.Sequence, () => attacking = false); 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) 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) if (info.DelayRelativeTo == AttackDelayType.Preparation)
{ {

View File

@@ -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(); var info = GetDisplayInfo();
if (!info.AttackSequences.TryGetValue(a.Info.Name, out var sequence)) 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); 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) void ITick.Tick(Actor self)
{ {

View File

@@ -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)) if (a == null || barrel == null || !armaments.Contains(a))
return; return;
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.Render
anims[barrel].Animation.PlayThen(sequence, () => visible[barrel] = false); 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<IRenderable> IRender.Render(Actor self, WorldRenderer wr) IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
{ {

View File

@@ -64,13 +64,13 @@ namespace OpenRA.Mods.Common.Traits.Render
PlayAttackAnimation(self); 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) if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
NotifyAttack(self); 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) if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
NotifyAttack(self); NotifyAttack(self);

View File

@@ -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") if (order.OrderID == "Repair")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -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") if (order.OrderID == "RepairNear")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
get { yield return new RepairBridgeOrderTargeter(info); } 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") if (order.OrderID == "RepairBridge")
return new Order(order.OrderID, self, target, queued); return new Order(order.OrderID, self, target, queued);

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info; 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) if (IsTraitDisabled)
return; return;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
Player GetTargetPlayer(Target target) Player GetTargetPlayer(in Target target)
{ {
if (target.Type == TargetType.Actor) if (target.Type == TargetType.Actor)
return target.Actor.Owner; return target.Actor.Owner;
@@ -74,6 +74,6 @@ namespace OpenRA.Mods.Common.Traits
return null; 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) { }
} }
} }

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
Game.Sound.Play(SoundType.World, info.Sounds, self.World, self.CenterPosition); 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) 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) if (info.DelayRelativeTo == AttackDelayType.Preparation)
{ {

View File

@@ -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") if (order.OrderID == "DeployTransform")
return new Order(order.OrderID, self, queued); return new Order(order.OrderID, self, queued);

View File

@@ -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) if (IsTraitDisabled || IsTraitPaused || attack == null || attack.IsTraitDisabled || attack.IsTraitPaused)
return false; return false;

View File

@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyAttack public interface INotifyAttack
{ {
void Attacking(Actor self, Target target, Armament a, Barrel barrel); void Attacking(Actor self, in Target target, Armament a, Barrel barrel);
void PreparingAttack(Actor self, Target target, Armament a, Barrel barrel); void PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel);
} }
[RequireExplicitImplementation] [RequireExplicitImplementation]
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); } public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); }
public interface INotifyBuildingPlaced { void BuildingPlaced(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 INotifyChat { bool OnChat(string from, string message); }
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); } 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); } 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, Activity MoveTo(CPos cell, int nearEnough = 0, Actor ignoreActor = null,
bool evaluateNearestMovableCell = false, Color? targetLineColor = 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); 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); 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); 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); WPos? initialTargetPosition = null, Color? targetLineColor = null);
Activity ReturnToCell(Actor self); 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); Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos); int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
CPos NearestMoveableCell(CPos target); CPos NearestMoveableCell(CPos target);
MovementType CurrentMovementTypes { get; set; } MovementType CurrentMovementTypes { get; set; }
bool CanEnterTargetNow(Actor self, Target target); bool CanEnterTargetNow(Actor self, in Target target);
} }
public interface IWrapMove public interface IWrapMove

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common
return cells.SelectMany(c => Neighbours(c, allowDiagonal)).Distinct(); return cells.SelectMany(c => Neighbours(c, allowDiagonal)).Distinct();
} }
public static IEnumerable<CPos> AdjacentCells(World w, Target target) public static IEnumerable<CPos> AdjacentCells(World w, in Target target)
{ {
var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct(); var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct();
return ExpandFootprint(cells, true); return ExpandFootprint(cells, true);

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Warheads
public readonly WDist Range = WDist.FromCells(1); 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 firedBy = args.SourceActor;
var actors = target.Type == TargetType.Actor ? new[] { target.Actor } : var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :

Some files were not shown because too many files have changed in this diff Show More