Aircraft Takeoff & Landing Sounds (Fixed-Wing)

Added Takeoff & Landing sounds to planes.

Changed Aircraft Trait, TakeoffSounds & LandingSounds are now arrays & accept a list of sound files & it will randomly select one to play.

Changed/fixed take off & landing sounds to originate from the aircraft location, rather than play a global sound.
This commit is contained in:
Inq8
2018-09-18 06:54:09 +01:00
committed by reaperrr
parent 9cf8cba750
commit fec9fe1ad4
8 changed files with 81 additions and 24 deletions

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Target target;
readonly WDist maxRange;
readonly WDist minRange;
bool soundPlayed;
public Fly(Actor self, Target t)
{
@@ -67,6 +68,12 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
if (!soundPlayed && aircraft.Info.TakeoffSounds.Length > 0 && self.IsAtGroundLevel())
{
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSounds.Random(self.World.SharedRandom), aircraft.CenterPosition);
soundPlayed = true;
}
// Inside the target annulus, so we're done
var insideMaxRange = maxRange.Length > 0 && target.IsInRange(aircraft.CenterPosition, maxRange);
var insideMinRange = minRange.Length > 0 && target.IsInRange(aircraft.CenterPosition, minRange);

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Target target;
readonly WDist maxRange;
readonly WDist minRange;
bool playedSound;
bool soundPlayed;
public HeliFly(Actor self, Target t)
{
@@ -64,10 +64,10 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled || !target.IsValidFor(self))
return NextActivity;
if (!playedSound && aircraft.Info.TakeoffSound != null && self.IsAtGroundLevel())
if (!soundPlayed && aircraft.Info.TakeoffSounds.Length > 0 && self.IsAtGroundLevel())
{
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSound);
playedSound = true;
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSounds.Random(self.World.SharedRandom), aircraft.CenterPosition);
soundPlayed = true;
}
if (AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist landAltitude;
readonly bool requireSpace;
bool playedSound;
bool soundPlayed;
public HeliLand(Actor self, bool requireSpace)
: this(self, requireSpace, self.Info.TraitInfo<AircraftInfo>().LandAltitude) { }
@@ -40,10 +40,10 @@ namespace OpenRA.Mods.Common.Activities
if (requireSpace && !aircraft.CanLand(self.Location))
return this;
if (!playedSound && aircraft.Info.LandingSound != null && !self.IsAtGroundLevel())
if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel())
{
Game.Sound.Play(SoundType.World, aircraft.Info.LandingSound);
playedSound = true;
Game.Sound.Play(SoundType.World, aircraft.Info.LandingSounds.Random(self.World.SharedRandom), aircraft.CenterPosition);
soundPlayed = true;
}
if (HeliFly.AdjustAltitude(self, aircraft, landAltitude))

View File

@@ -20,6 +20,8 @@ namespace OpenRA.Mods.Common.Activities
readonly Target target;
readonly Aircraft aircraft;
bool soundPlayed;
public Land(Actor self, Target t)
{
target = t;
@@ -34,6 +36,12 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled)
return NextActivity;
if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel())
{
Game.Sound.Play(SoundType.World, aircraft.Info.LandingSounds.Random(self.World.SharedRandom), aircraft.CenterPosition);
soundPlayed = true;
}
var d = target.CenterPosition - self.CenterPosition;
// The next move would overshoot, so just set the final position