diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 6760ff7c7b..78281f8d22 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -79,7 +79,7 @@ namespace OpenRA public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); } - static ISound Play(Player player, string name, bool headRelative, PPos pos, float volumeModifier) + static ISound Play(Player player, string name, bool headRelative, WPos pos, float volumeModifier) { if (String.IsNullOrEmpty(name)) return null; @@ -87,16 +87,16 @@ namespace OpenRA return null; return soundEngine.Play2D(sounds[name], - false, headRelative, pos.ToFloat2(), + false, headRelative, PPos.FromWPosHackZ(pos).ToFloat2(), InternalSoundVolume * volumeModifier, true); } - public static ISound Play(string name) { return Play(null, name, true, PPos.Zero, 1); } - public static ISound Play(string name, PPos pos) { return Play(null, name, false, pos, 1); } - public static ISound Play(string name, float volumeModifier) { return Play(null, name, true, PPos.Zero, volumeModifier); } - public static ISound Play(string name, PPos pos, float volumeModifier) { return Play(null, name, false, pos, volumeModifier); } - public static ISound PlayToPlayer(Player player, string name) { return Play(player, name, true, PPos.Zero, 1); } - public static ISound PlayToPlayer(Player player, string name, PPos pos) { return Play(player, name, false, pos, 1); } + public static ISound Play(string name) { return Play(null, name, true, WPos.Zero, 1); } + public static ISound Play(string name, WPos pos) { return Play(null, name, false, pos, 1); } + public static ISound Play(string name, float volumeModifier) { return Play(null, name, true, WPos.Zero, volumeModifier); } + public static ISound Play(string name, WPos pos, float volumeModifier) { return Play(null, name, false, pos, volumeModifier); } + public static ISound PlayToPlayer(Player player, string name) { return Play(player, name, true, WPos.Zero, 1); } + public static ISound PlayToPlayer(Player player, string name, WPos pos) { return Play(player, name, false, pos, 1); } public static void PlayVideo(byte[] raw) { diff --git a/OpenRA.Mods.Cnc/IonCannonPower.cs b/OpenRA.Mods.Cnc/IonCannonPower.cs index 03b0eee3b9..3a96806c10 100644 --- a/OpenRA.Mods.Cnc/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/IonCannonPower.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc { self.World.AddFrameEndTask(w => { - Sound.Play(Info.LaunchSound, order.TargetLocation.ToPPos()); + Sound.Play(Info.LaunchSound, order.TargetLocation.CenterPosition); w.Add(new IonCannon(self, w, order.TargetLocation)); }); } diff --git a/OpenRA.Mods.RA/Activities/Leap.cs b/OpenRA.Mods.RA/Activities/Leap.cs index 289e87e379..7be3de70d2 100644 --- a/OpenRA.Mods.RA/Activities/Leap.cs +++ b/OpenRA.Mods.RA/Activities/Leap.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Activities self.Trait().Attacking(self, Target.FromActor(target)); if (weapon.Report != null && weapon.Report.Any()) - Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterLocation); + Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } public override Activity Tick(Actor self) diff --git a/OpenRA.Mods.RA/Activities/MakeAnimation.cs b/OpenRA.Mods.RA/Activities/MakeAnimation.cs index 1eb0c0bd18..8444f34f8e 100644 --- a/OpenRA.Mods.RA/Activities/MakeAnimation.cs +++ b/OpenRA.Mods.RA/Activities/MakeAnimation.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Activities var bi = self.Info.Traits.GetOrDefault(); if (bi != null) foreach (var s in bi.SellSounds) - Sound.PlayToPlayer(self.Owner, s, self.CenterLocation); + Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); rb.PlayCustomAnimBackwards(self, "make", () => { OnComplete(); complete = true;}); } diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index f9809d9f83..cd54a55119 100755 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -29,8 +29,8 @@ namespace OpenRA.Mods.RA.Activities public override Activity Tick(Actor self) { - Sound.Play("chrono2.aud", self.Location.ToPPos()); - Sound.Play("chrono2.aud", destination.ToPPos()); + Sound.Play("chrono2.aud", self.CenterPosition); + Sound.Play("chrono2.aud", destination.CenterPosition); self.Trait().SetPosition(self, destination); self.Generation++; diff --git a/OpenRA.Mods.RA/Activities/Transform.cs b/OpenRA.Mods.RA/Activities/Transform.cs index be5cee0329..77d9656bff 100644 --- a/OpenRA.Mods.RA/Activities/Transform.cs +++ b/OpenRA.Mods.RA/Activities/Transform.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Activities self.Destroy(); foreach (var s in Sounds) - Sound.PlayToPlayer(self.Owner, s, self.CenterLocation); + Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); var init = new TypeDictionary { diff --git a/OpenRA.Mods.RA/Air/EjectOnDeath.cs b/OpenRA.Mods.RA/Air/EjectOnDeath.cs index d3824b9c2b..74cf19de12 100644 --- a/OpenRA.Mods.RA/Air/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/Air/EjectOnDeath.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA && self.Owner.WinState != WinState.Lost) { self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, self.CenterPosition))); - Sound.Play(info.ChuteSound, self.CenterLocation); + Sound.Play(info.ChuteSound, self.CenterPosition); } else pilot.Destroy(); diff --git a/OpenRA.Mods.RA/Armament.cs b/OpenRA.Mods.RA/Armament.cs index 7ec683ac00..e1b09e3e79 100755 --- a/OpenRA.Mods.RA/Armament.cs +++ b/OpenRA.Mods.RA/Armament.cs @@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA self.World.Add(projectile); if (args.weapon.Report != null && args.weapon.Report.Any()) - Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterLocation); + Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } }); diff --git a/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs b/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs index e9e3762538..dd7acc987b 100644 --- a/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs +++ b/OpenRA.Mods.RA/Buildings/SoundOnDamageTransition.cs @@ -32,9 +32,9 @@ namespace OpenRA.Mods.RA.Buildings public void DamageStateChanged(Actor self, AttackInfo e) { if (e.DamageState == DamageState.Dead) - Sound.Play(Info.DestroyedSound, self.CenterLocation); + Sound.Play(Info.DestroyedSound, self.CenterPosition); else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy) - Sound.Play(Info.DamagedSound, self.CenterLocation); + Sound.Play(Info.DamagedSound, self.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/Buildings/Wall.cs b/OpenRA.Mods.RA/Buildings/Wall.cs index 727aa0bd59..7213ce6946 100755 --- a/OpenRA.Mods.RA/Buildings/Wall.cs +++ b/OpenRA.Mods.RA/Buildings/Wall.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Buildings public void OnCrush(Actor crusher) { self.Kill(crusher); - Sound.Play(info.CrushSound, self.CenterLocation); + Sound.Play(info.CrushSound, self.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs index 03e612d3fe..80148646a6 100644 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ b/OpenRA.Mods.RA/CarpetBomb.cs @@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA self.World.Add(args.weapon.Projectile.Create(args)); if (args.weapon.Report != null && args.weapon.Report.Any()) - Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterLocation); + Sound.Play(args.weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/Cloak.cs b/OpenRA.Mods.RA/Cloak.cs index 81fa26ede3..aef6315148 100644 --- a/OpenRA.Mods.RA/Cloak.cs +++ b/OpenRA.Mods.RA/Cloak.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA public void Uncloak(int time) { if (Cloaked) - Sound.Play(info.UncloakSound, self.CenterLocation); + Sound.Play(info.UncloakSound, self.CenterPosition); remainingTime = Math.Max(remainingTime, time); } @@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA { if (remainingTime > 0 && canCloak) if (--remainingTime <= 0) - Sound.Play(info.CloakSound, self.CenterLocation); + Sound.Play(info.CloakSound, self.CenterPosition); if (self.IsDisabled()) Uncloak(); diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index c65c21837a..956badf6b0 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -43,11 +43,12 @@ namespace OpenRA.Mods.RA var isWater = args.destAltitude == 0 && world.GetTerrainInfo(targetTile).IsWater; var explosionType = isWater ? warhead.WaterExplosion : warhead.Explosion; + var dest = args.dest.ToWPos(args.destAltitude); if (explosionType != null) world.AddFrameEndTask( - w => w.Add(new Explosion(w, args.dest.ToWPos(args.destAltitude), explosionType))); + w => w.Add(new Explosion(w, dest, explosionType))); - Sound.Play(GetImpactSound(warhead, isWater), args.dest); + Sound.Play(GetImpactSound(warhead, isWater), dest); var smudgeLayers = world.WorldActor.TraitsImplementing().ToDictionary(x => x.Info.Type); @@ -156,7 +157,7 @@ namespace OpenRA.Mods.RA }; if (args.weapon.Report != null && args.weapon.Report.Any()) - Sound.Play(args.weapon.Report.Random(attacker.World.SharedRandom), pxPos); + Sound.Play(args.weapon.Report.Random(attacker.World.SharedRandom), pos); DoImpacts(args); } diff --git a/OpenRA.Mods.RA/CrushableInfantry.cs b/OpenRA.Mods.RA/CrushableInfantry.cs index 3b625c056f..c5f9c1f167 100644 --- a/OpenRA.Mods.RA/CrushableInfantry.cs +++ b/OpenRA.Mods.RA/CrushableInfantry.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA public void OnCrush(Actor crusher) { - Sound.Play(Info.CrushSound, crusher.CenterLocation); + Sound.Play(Info.CrushSound, crusher.CenterPosition); ri.SpawnCorpse(self, Info.CorpseSequence); self.Kill(crusher); } diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index 9ea27934dc..9adc524ad7 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA var a = cargo.Unload(self); self.World.AddFrameEndTask(w => w.Add(new Parachute(a, self.CenterPosition))); - Sound.Play(info.ChuteSound, self.CenterLocation); + Sound.Play(info.ChuteSound, self.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/Player/PlaceBuilding.cs b/OpenRA.Mods.RA/Player/PlaceBuilding.cs index cfa783579b..acc8bf2019 100755 --- a/OpenRA.Mods.RA/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.RA/Player/PlaceBuilding.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA if (playSounds) foreach (var s in buildingInfo.BuildSounds) - Sound.PlayToPlayer(order.Player, s, building.CenterLocation); + Sound.PlayToPlayer(order.Player, s, building.CenterPosition); playSounds = false; } } @@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA new OwnerInit( order.Player ), }); foreach (var s in buildingInfo.BuildSounds) - Sound.PlayToPlayer(order.Player, s, building.CenterLocation); + Sound.PlayToPlayer(order.Player, s, building.CenterPosition); } PlayBuildAnim( self, unit ); diff --git a/OpenRA.Mods.RA/Render/RenderBuildingCharge.cs b/OpenRA.Mods.RA/Render/RenderBuildingCharge.cs index 5e2ec1d079..1abbffcfb0 100755 --- a/OpenRA.Mods.RA/Render/RenderBuildingCharge.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingCharge.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Render public void PlayCharge(Actor self) { - Sound.Play(info.ChargeAudio, self.CenterLocation); + Sound.Play(info.ChargeAudio, self.CenterPosition); anim.PlayThen(NormalizeSequence(self, "active"), () => anim.PlayRepeating(NormalizeSequence(self, "idle"))); } diff --git a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs index 0890649e9b..50e5a47d17 100755 --- a/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/IronCurtainPower.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA { self.Trait().PlayCustomAnim(self, "active"); - Sound.Play("ironcur9.aud", order.TargetLocation.ToPPos()); + Sound.Play("ironcur9.aud", order.TargetLocation.CenterPosition); foreach (var target in UnitsInRange(order.TargetLocation) .Where(a => a.Owner.Stances[self.Owner] == Stance.Ally))