Use in parameter for Target
This commit is contained in:
@@ -875,20 +875,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return new Fly(self, Target.FromCell(self.World, cell), WDist.FromCells(nearEnough), targetLineColor: targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist range,
|
||||
public Activity MoveWithinRange(in Target target, WDist range,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return new Fly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||
public Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return new Fly(self, target, minRange, maxRange,
|
||||
initialTargetPosition, targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return new FlyFollow(self, target, minRange, maxRange,
|
||||
@@ -934,13 +934,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Activity MoveToTarget(Actor self, Target target,
|
||||
public Activity MoveToTarget(Actor self, in Target target,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return new Fly(self, target, initialTargetPosition, targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveIntoTarget(Actor self, Target target)
|
||||
public Activity MoveIntoTarget(Actor self, in Target target)
|
||||
{
|
||||
return new Land(self, target);
|
||||
}
|
||||
@@ -978,9 +978,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanEnterTargetNow(Actor self, Target target)
|
||||
public bool CanEnterTargetNow(Actor self, in Target target)
|
||||
{
|
||||
if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != target.Actor)))
|
||||
// Lambdas can't use 'in' variables, so capture a copy for later
|
||||
var targetActor = target;
|
||||
if (target.Positions.Any(p => self.World.ActorMap.GetActorsAt(self.World.Map.CellContaining(p)).Any(a => a != self && a != targetActor.Actor)))
|
||||
return false;
|
||||
|
||||
MakeReservation(target.Actor);
|
||||
@@ -1015,7 +1017,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (!IsTraitDisabled &&
|
||||
(order.OrderID == "Enter" || order.OrderID == "Move" || order.OrderID == "Land" || order.OrderID == "ForceEnter"))
|
||||
@@ -1250,7 +1252,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
OrderID = "Move";
|
||||
}
|
||||
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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
|
||||
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
|
||||
@@ -1259,7 +1261,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||
}
|
||||
|
||||
public virtual bool CanTarget(Actor self, Target target, List<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)))
|
||||
return false;
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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);
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
protected override bool CanAttack(Actor self, in Target target)
|
||||
{
|
||||
// Don't fire while landed or when outside the map.
|
||||
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
OnRemovedFromWorld(self);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
|
||||
{
|
||||
throw new NotImplementedException("AttackBomber requires a scripted target");
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
RemainingTicks = Info.ReloadDelay;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (a != null && Info.Armaments.Contains(a.Info.Name))
|
||||
TakeAmmo(self, 1);
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
void UpdateCondition(Actor self)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
a();
|
||||
}
|
||||
|
||||
protected virtual bool CanFire(Actor self, Target target)
|
||||
protected virtual bool CanFire(Actor self, in Target target)
|
||||
{
|
||||
if (IsReloading || IsTraitPaused)
|
||||
return false;
|
||||
@@ -249,7 +249,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Note: facing is only used by the legacy positioning code
|
||||
// The world coordinate model uses Actor.Orientation
|
||||
public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
|
||||
public virtual Barrel CheckFire(Actor self, IFacing facing, in Target target)
|
||||
{
|
||||
if (!CanFire(self, target))
|
||||
return null;
|
||||
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return barrel;
|
||||
}
|
||||
|
||||
protected virtual void FireBarrel(Actor self, IFacing facing, Target target, Barrel barrel)
|
||||
protected virtual void FireBarrel(Actor self, IFacing facing, in Target target, Barrel barrel)
|
||||
{
|
||||
foreach (var na in notifyAttacks)
|
||||
na.PreparingAttack(self, target, this, barrel);
|
||||
@@ -316,6 +316,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
GuidedTarget = target
|
||||
};
|
||||
|
||||
// Lambdas can't use 'in' variables, so capture a copy for later
|
||||
var delayedTarget = target;
|
||||
ScheduleDelayedAction(Info.FireDelay, () =>
|
||||
{
|
||||
if (args.Weapon.Projectile != null)
|
||||
@@ -331,14 +333,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
|
||||
|
||||
foreach (var na in notifyAttacks)
|
||||
na.Attacking(self, target, this, barrel);
|
||||
na.Attacking(self, delayedTarget, this, barrel);
|
||||
|
||||
Recoil = Info.Recoil;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual void UpdateBurst(Actor self, Target target)
|
||||
protected virtual void UpdateBurst(Actor self, in Target target)
|
||||
{
|
||||
if (--Burst > 0)
|
||||
{
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return () => armaments;
|
||||
}
|
||||
|
||||
public bool TargetInFiringArc(Actor self, Target target, int facingTolerance)
|
||||
public bool TargetInFiringArc(Actor self, in Target target, int facingTolerance)
|
||||
{
|
||||
if (facing == null)
|
||||
return true;
|
||||
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw, facingTolerance);
|
||||
}
|
||||
|
||||
protected virtual bool CanAttack(Actor self, Target target)
|
||||
protected virtual bool CanAttack(Actor self, in Target target)
|
||||
{
|
||||
if (!self.IsInWorld || IsTraitDisabled || IsTraitPaused)
|
||||
return false;
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void DoAttack(Actor self, Target target)
|
||||
public virtual void DoAttack(Actor self, in Target target)
|
||||
{
|
||||
if (!CanAttack(self, target))
|
||||
return;
|
||||
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order is AttackOrderTargeter)
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
@@ -226,9 +226,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return order.OrderString == attackOrderName || order.OrderString == forceAttackOrderName ? Info.Voice : null;
|
||||
}
|
||||
|
||||
public abstract Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
|
||||
public abstract Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
|
||||
|
||||
public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
|
||||
public bool HasAnyValidWeapons(in Target t, bool checkForCenterTargetingWeapons = false)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return false;
|
||||
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual WPos GetTargetPosition(WPos pos, Target target)
|
||||
public virtual WPos GetTargetPosition(WPos pos, in Target target)
|
||||
{
|
||||
return HasAnyValidWeapons(target, true) ? target.CenterPosition : target.Positions.PositionClosestTo(pos);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return max;
|
||||
}
|
||||
|
||||
public WDist GetMinimumRangeVersusTarget(Target target)
|
||||
public WDist GetMinimumRangeVersusTarget(in Target target)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return WDist.Zero;
|
||||
@@ -324,7 +324,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return min != WDist.MaxValue ? min : WDist.Zero;
|
||||
}
|
||||
|
||||
public WDist GetMaximumRangeVersusTarget(Target target)
|
||||
public WDist GetMaximumRangeVersusTarget(in Target target)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return WDist.Zero;
|
||||
@@ -382,7 +382,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
&& a.Weapon.IsValidAgainst(t, self.World, self));
|
||||
}
|
||||
|
||||
public void AttackTarget(Target target, AttackSource source, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
|
||||
public void AttackTarget(in Target target, AttackSource source, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
@@ -395,9 +395,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
OnResolveAttackOrder(self, activity, target, queued, forceAttack);
|
||||
}
|
||||
|
||||
public virtual void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack) { }
|
||||
public virtual void OnResolveAttackOrder(Actor self, Activity activity, in Target target, bool queued, bool forceAttack) { }
|
||||
|
||||
public bool IsReachableTarget(Target target, bool allowMove)
|
||||
public bool IsReachableTarget(in Target target, bool allowMove)
|
||||
{
|
||||
return HasAnyValidWeapons(target)
|
||||
&& (target.IsInRange(self.CenterPosition, GetMaximumRangeVersusTarget(target)) || (allowMove && self.Info.HasTraitInfo<IMoveInfo>()));
|
||||
@@ -427,9 +427,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public string OrderID { get; private set; }
|
||||
public int OrderPriority { get; private set; }
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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);
|
||||
|
||||
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -63,14 +63,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Tick(self);
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
protected override bool CanAttack(Actor self, in Target target)
|
||||
{
|
||||
charging = base.CanAttack(self, target) && IsReachableTarget(target, true);
|
||||
return ChargeLevel >= info.ChargeLevel && charging;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
void INotifySold.Selling(Actor self) { ChargeLevel = 0; }
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool opportunityForceAttack;
|
||||
bool opportunityTargetIsPersistentTarget;
|
||||
|
||||
public void SetRequestedTarget(Actor self, Target target, bool isForceAttack = false)
|
||||
public void SetRequestedTarget(Actor self, in Target target, bool isForceAttack = false)
|
||||
{
|
||||
RequestedTarget = target;
|
||||
requestedForceAttack = isForceAttack;
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
protected bool CanAimAtTarget(Actor self, Target target, bool forceAttack)
|
||||
protected bool CanAimAtTarget(Actor self, in Target target, bool forceAttack)
|
||||
{
|
||||
if (target.Type == TargetType.Actor && !target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
return false;
|
||||
@@ -154,12 +154,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Tick(self);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
return new AttackActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||
}
|
||||
|
||||
public override void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack)
|
||||
public override void OnResolveAttackOrder(Actor self, Activity activity, in Target target, bool queued, bool forceAttack)
|
||||
{
|
||||
// We can improve responsiveness for turreted actors by preempting
|
||||
// the last order (usually a move) and setting the target immediately
|
||||
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool wasMovingWithinRange;
|
||||
bool hasTicked;
|
||||
|
||||
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public AttackActivity(Actor self, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
attack = self.Trait<AttackFollow>();
|
||||
move = allowMove ? self.TraitOrDefault<IMove>() : null;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info = info;
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
protected override bool CanAttack(Actor self, in Target target)
|
||||
{
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return TargetInFiringArc(self, target, 4 * Info.FacingTolerance);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
return new Activities.Attack(self, newTarget, allowMove, forceAttack, targetLineColor);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
|
||||
}
|
||||
|
||||
public override void DoAttack(Actor self, Target target)
|
||||
public override void DoAttack(Actor self, in Target target)
|
||||
{
|
||||
if (!CanAttack(self, target))
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public AttackOmni(Actor self, AttackOmniInfo info)
|
||||
: base(self, info) { }
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
return new SetTarget(this, newTarget, allowMove, forceAttack, targetLineColor);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Color? targetLineColor;
|
||||
Target target;
|
||||
|
||||
public SetTarget(AttackOmni attack, Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
public SetTarget(AttackOmni attack, in Target target, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
{
|
||||
this.target = target;
|
||||
this.targetLineColor = targetLineColor;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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)
|
||||
return false;
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Attack(self, target, allowMove);
|
||||
}
|
||||
|
||||
void Attack(Actor self, Target target, bool allowMove)
|
||||
void Attack(Actor self, in Target target, bool allowMove)
|
||||
{
|
||||
foreach (var ab in ActiveAttackBases)
|
||||
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == OrderID)
|
||||
return new Order(order.OrderID, self, false);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { yield return new RallyPointOrderTargeter(Info.Cursor); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == OrderID)
|
||||
{
|
||||
@@ -140,11 +140,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public string OrderID { get { return "SetRallyPoint"; } }
|
||||
public int OrderPriority { get { return 0; } }
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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 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)
|
||||
return false;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
// Note: Returns a valid order even if the unit can't move to the target
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "Enter" || order.OrderID == "Move")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly TransformsIntoAircraft aircraft;
|
||||
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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
|
||||
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
|
||||
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority { get { return 4; } }
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<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)))
|
||||
return false;
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return self.CurrentActivity is Transform || transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused);
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "EnterTunnel")
|
||||
return new Order(order.OrderID, self, target, queued) { SuppressVisualFeedback = true };
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
// Note: Returns a valid order even if the unit can't move to the target
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order is MoveOrderTargeter)
|
||||
return new Order("Move", self, target, queued);
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly TransformsIntoMobile mobile;
|
||||
readonly bool rejectMove;
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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
|
||||
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority { get { return 4; } }
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<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)))
|
||||
return false;
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "EnterTransport")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return Info.RepairActors.Contains(target.Info.Name);
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "Repair")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "CaptureActor")
|
||||
return null;
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "Unload")
|
||||
return new Order(order.OrderID, self, queued);
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "PickupUnit" || order.OrderID == "DeliverUnit" || order.OrderID == "Unload")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
@@ -383,7 +383,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public string OrderID { get { return "DeliverUnit"; } }
|
||||
public int OrderPriority { get { return 6; } }
|
||||
public bool IsQueued { get; protected set; }
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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)
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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))
|
||||
return false;
|
||||
|
||||
@@ -108,9 +108,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Uncloak(int time) { remainingTime = Math.Max(remainingTime, time); }
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { if (Info.UncloakOn.HasFlag(UncloakType.Attack)) Uncloak(); }
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { if (Info.UncloakOn.HasFlag(UncloakType.Attack)) Uncloak(); }
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
void INotifyDamage.Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
bool TargetChanged(Target lastTarget, Target target)
|
||||
bool TargetChanged(in Target lastTarget, in Target target)
|
||||
{
|
||||
// Invalidate reveal changing the target.
|
||||
if (lastTarget.Type == TargetType.FrozenActor && target.Type == TargetType.Actor)
|
||||
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (IsTraitDisabled || IsTraitPaused)
|
||||
return;
|
||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
protected override void TraitDisabled(Actor self)
|
||||
{
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "GrantConditionOnDeploy")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { yield return new DeliversCashOrderTargeter(info); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "DeliverCash")
|
||||
return null;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "DeliverExperience")
|
||||
return null;
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { yield return new DemolitionOrderTargeter(info); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "C4")
|
||||
return null;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "EngineerRepair")
|
||||
return null;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return !requireForceMove || modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID != "EnterTunnel")
|
||||
return null;
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "Deliver" || order.OrderID == "Harvest")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
@@ -364,9 +364,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public string OrderID { get { return "Harvest"; } }
|
||||
public int OrderPriority { get { return 10; } }
|
||||
public bool IsQueued { get; protected set; }
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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)
|
||||
return false;
|
||||
|
||||
@@ -88,13 +88,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Panic();
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (self.World.SharedRandom.Next(100) < info.AttackPanicChance)
|
||||
Panic();
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
int ISpeedModifier.GetSpeedModifier()
|
||||
{
|
||||
|
||||
@@ -602,19 +602,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return WrapMove(new Move(self, cell, WDist.FromCells(nearEnough), ignoreActor, evaluateNearestMovableCell, targetLineColor));
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist range,
|
||||
public Activity MoveWithinRange(in Target target, WDist range,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return WrapMove(new MoveWithinRange(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor));
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||
public Activity MoveWithinRange(in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return WrapMove(new MoveWithinRange(self, target, minRange, maxRange, initialTargetPosition, targetLineColor));
|
||||
}
|
||||
|
||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
return WrapMove(new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor));
|
||||
@@ -675,7 +675,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Activity MoveToTarget(Actor self, Target target,
|
||||
public Activity MoveToTarget(Actor self, in Target target,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
if (target.Type == TargetType.Invalid)
|
||||
@@ -684,7 +684,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return WrapMove(new MoveAdjacentTo(self, target, initialTargetPosition, targetLineColor));
|
||||
}
|
||||
|
||||
public Activity MoveIntoTarget(Actor self, Target target)
|
||||
public Activity MoveIntoTarget(Actor self, in Target target)
|
||||
{
|
||||
if (target.Type == TargetType.Invalid)
|
||||
return null;
|
||||
@@ -711,7 +711,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return NearestMoveableCell(target, 1, 10);
|
||||
}
|
||||
|
||||
public bool CanEnterTargetNow(Actor self, Target target)
|
||||
public bool CanEnterTargetNow(Actor self, in Target target)
|
||||
{
|
||||
if (target.Type == TargetType.FrozenActor && !target.FrozenActor.IsValid)
|
||||
return false;
|
||||
@@ -904,7 +904,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
// Note: Returns a valid order even if the unit can't move to the target
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order is MoveOrderTargeter)
|
||||
return new Order("Move", self, target, queued);
|
||||
@@ -968,7 +968,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Mobile mobile;
|
||||
readonly LocomotorInfo locomotorInfo;
|
||||
readonly bool rejectMove;
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<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
|
||||
if (target.Type == TargetType.Actor && (target.Actor.Owner != self.Owner || self.World.Selection.Contains(target.Actor)))
|
||||
@@ -988,7 +988,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority { get { return 4; } }
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<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)))
|
||||
return false;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "EnterTransport")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -66,13 +66,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (Info.ResetOnFire)
|
||||
remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier()));
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
wsb.PlayCustomAnimation(self, Info.Sequence);
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
overlay.PlayThen(info.Sequence, () => attacking = false);
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (info.DelayRelativeTo == AttackDelayType.Attack)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (info.DelayRelativeTo == AttackDelayType.Preparation)
|
||||
{
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
public void Attacking(Actor self, Target target, Armament a)
|
||||
public void Attacking(Actor self, in Target target, Armament a)
|
||||
{
|
||||
var info = GetDisplayInfo();
|
||||
if (!info.AttackSequences.TryGetValue(a.Info.Name, out var sequence))
|
||||
@@ -146,12 +146,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
Attacking(self, target, a);
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (a == null || barrel == null || !armaments.Contains(a))
|
||||
return;
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
anims[barrel].Animation.PlayThen(sequence, () => visible[barrel] = false);
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
|
||||
IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
|
||||
{
|
||||
|
||||
@@ -64,13 +64,13 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
PlayAttackAnimation(self);
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Attack)
|
||||
NotifyAttack(self);
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (!IsTraitDisabled && a == armament && Info.DelayRelativeTo == AttackDelayType.Preparation)
|
||||
NotifyAttack(self);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "Repair")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "RepairNear")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { yield return new RepairBridgeOrderTargeter(info); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "RepairBridge")
|
||||
return new Order(order.OrderID, self, target, queued);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
Player GetTargetPlayer(Target target)
|
||||
Player GetTargetPlayer(in Target target)
|
||||
{
|
||||
if (target.Type == TargetType.Actor)
|
||||
return target.Actor.Owner;
|
||||
@@ -74,6 +74,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return null;
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, OpenRA.Traits.Target target, Armament a, Barrel barrel) { }
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
Game.Sound.Play(SoundType.World, info.Sounds, self.World, self.CenterPosition);
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (info.DelayRelativeTo == AttackDelayType.Attack)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
}
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
|
||||
void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (info.DelayRelativeTo == AttackDelayType.Preparation)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "DeployTransform")
|
||||
return new Order(order.OrderID, self, queued);
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public bool FaceTarget(Actor self, Target target)
|
||||
public bool FaceTarget(Actor self, in Target target)
|
||||
{
|
||||
if (IsTraitDisabled || IsTraitPaused || attack == null || attack.IsTraitDisabled || attack.IsTraitPaused)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user