Corrected StartBurstReport sound synchronisation when used with FireDelay.
This commit is contained in:
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int currentBarrel;
|
||||
readonly int barrelCount;
|
||||
|
||||
readonly List<(int Ticks, Action Func)> delayedActions = new List<(int, Action)>();
|
||||
readonly List<(int Ticks, int Burst, Action<int> Func)> delayedActions = new List<(int, int, Action<int>)>();
|
||||
|
||||
public WDist Recoil;
|
||||
public int FireDelay { get; protected set; }
|
||||
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var x = delayedActions[i];
|
||||
if (--x.Ticks <= 0)
|
||||
x.Func();
|
||||
x.Func(x.Burst);
|
||||
delayedActions[i] = x;
|
||||
}
|
||||
|
||||
@@ -225,12 +225,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Tick(self);
|
||||
}
|
||||
|
||||
protected void ScheduleDelayedAction(int t, Action a)
|
||||
protected void ScheduleDelayedAction(int t, int b, Action<int> a)
|
||||
{
|
||||
if (t > 0)
|
||||
delayedActions.Add((t, a));
|
||||
delayedActions.Add((t, b, a));
|
||||
else
|
||||
a();
|
||||
a(b);
|
||||
}
|
||||
|
||||
protected virtual bool CanFire(Actor self, in Target target)
|
||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Lambdas can't use 'in' variables, so capture a copy for later
|
||||
var delayedTarget = target;
|
||||
ScheduleDelayedAction(Info.FireDelay, () =>
|
||||
ScheduleDelayedAction(Info.FireDelay, Burst, (burst) =>
|
||||
{
|
||||
if (args.Weapon.Projectile != null)
|
||||
{
|
||||
@@ -333,7 +333,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (args.Weapon.Report != null && args.Weapon.Report.Any())
|
||||
Game.Sound.Play(SoundType.World, args.Weapon.Report, self.World, self.CenterPosition);
|
||||
|
||||
if (Burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Any())
|
||||
if (burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Any())
|
||||
Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
|
||||
|
||||
foreach (var na in notifyAttacks)
|
||||
@@ -360,7 +360,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Burst = Weapon.Burst;
|
||||
|
||||
if (Weapon.AfterFireSound != null && Weapon.AfterFireSound.Any())
|
||||
ScheduleDelayedAction(Weapon.AfterFireSoundDelay, () => Game.Sound.Play(SoundType.World, Weapon.AfterFireSound, self.World, self.CenterPosition));
|
||||
ScheduleDelayedAction(Weapon.AfterFireSoundDelay, Burst, (burst) => Game.Sound.Play(SoundType.World, Weapon.AfterFireSound, self.World, self.CenterPosition));
|
||||
|
||||
foreach (var nbc in notifyBurstComplete)
|
||||
nbc.FiredBurst(self, target, this);
|
||||
|
||||
Reference in New Issue
Block a user