Skip to content

Commit

Permalink
Make notifyAttacks more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
PunkPun committed Nov 16, 2023
1 parent f5eddf6 commit a39dcd7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Activities/Attack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected virtual void DoAttack(Actor self, AttackFrontal attack, IEnumerable<Ar
{
if (!attack.IsTraitPaused)
foreach (var a in armaments)
a.CheckFire(self, facing, target, false);
a.CheckFire(self, facing, target);
}

void IActivityNotifyStanceChanged.StanceChanged(Actor self, AutoTarget autoTarget, UnitStance oldStance, UnitStance newStance)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Traits/Air/AttackBomber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ITick.Tick(Actor self)
continue;

inAttackRange = true;
a.CheckFire(self, facing, target, false);
a.CheckFire(self, facing, target);
}

// Actors without armaments may want to trigger an action when it passes the target
Expand Down
12 changes: 4 additions & 8 deletions OpenRA.Mods.Common/Traits/Armament.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected virtual bool CanFire(Actor self, in Target target)

// Note: facing is only used by the legacy positioning code
// The world coordinate model uses Actor.Orientation
public virtual bool CheckFire(Actor self, IFacing facing, in Target target, bool notifyAttacking)
public virtual bool CheckFire(Actor self, IFacing facing, in Target target)
{
if (!CanFire(self, target))
return false;
Expand All @@ -282,10 +282,6 @@ public virtual bool CheckFire(Actor self, IFacing facing, in Target target, bool

FireBarrel(self, facing, target, barrel);
UpdateBurst(self, target);

if (notifyAttacking)
foreach (var notify in notifyAttacks)
notify.Attacking(self, target, this, barrel);
}
while (FireDelay == 0 && CanFire(self, target));

Expand Down Expand Up @@ -353,11 +349,11 @@ protected virtual void FireBarrel(Actor self, IFacing facing, in Target target,
if (burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Length > 0)
Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
foreach (var na in notifyAttacks)
na.Attacking(self, delayedTarget, this, barrel);
Recoil = Info.Recoil;
}
foreach (var na in notifyAttacks)
na.Attacking(self, delayedTarget, this, barrel);
});
}

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Traits/Attack/AttackBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public virtual void DoAttack(Actor self, in Target target)
return;

foreach (var a in Armaments)
a.CheckFire(self, facing, target, false);
a.CheckFire(self, facing, target);
}

IEnumerable<IOrderTargeter> IIssueOrder.Orders
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public override void DoAttack(Actor self, in Target target)
paxFacing[a.Actor].Facing = targetYaw;
paxPos[a.Actor].SetCenterPosition(a.Actor, pos + PortOffset(self, port));

if (!a.CheckFire(a.Actor, facing, target, true))
if (!a.CheckFire(a.Actor, facing, target))
continue;

if (a.Info.MuzzleSequence != null)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.D2k/Activities/SwallowActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool AttackTargets(Actor self, IReadOnlyCollection<Actor> targets)
if (affectedPlayers.Contains(self.World.LocalPlayer))
TextNotificationsManager.AddTransientLine(self.World.LocalPlayer, swallow.Info.WormAttackTextNotification);

return armament.CheckFire(self, facing, target, true);
return armament.CheckFire(self, facing, target);
}

public override bool Tick(Actor self)
Expand Down

0 comments on commit a39dcd7

Please sign in to comment.