Introduce SoundType enum.

This commit is contained in:
Paul Chote
2016-12-10 17:38:44 +00:00
parent 28182ddc36
commit 9ddfdc45b3
48 changed files with 83 additions and 80 deletions

View File

@@ -32,6 +32,8 @@ namespace OpenRA
Stream GetPCMInputStream();
}
public enum SoundType { World, UI }
public sealed class Sound : IDisposable
{
readonly ISoundEngine soundEngine;
@@ -92,7 +94,7 @@ namespace OpenRA
soundEngine.SetListenerPosition(position);
}
ISound Play(Player player, string name, bool headRelative, WPos pos, float volumeModifier = 1f, bool loop = false)
ISound Play(SoundType type, Player player, string name, bool headRelative, WPos pos, float volumeModifier = 1f, bool loop = false)
{
if (string.IsNullOrEmpty(name))
return null;
@@ -119,14 +121,14 @@ namespace OpenRA
soundEngine.Volume = 1f;
}
public ISound Play(string name) { return Play(null, name, true, WPos.Zero, 1f); }
public ISound Play(string name, WPos pos) { return Play(null, name, false, pos, 1f); }
public ISound Play(string name, float volumeModifier) { return Play(null, name, true, WPos.Zero, volumeModifier); }
public ISound Play(string name, WPos pos, float volumeModifier) { return Play(null, name, false, pos, volumeModifier); }
public ISound PlayToPlayer(Player player, string name) { return Play(player, name, true, WPos.Zero, 1f); }
public ISound PlayToPlayer(Player player, string name, WPos pos) { return Play(player, name, false, pos, 1f); }
public ISound PlayLooped(string name) { return PlayLooped(name, WPos.Zero); }
public ISound PlayLooped(string name, WPos pos) { return Play(null, name, true, pos, 1f, true); }
public ISound Play(SoundType type, string name) { return Play(type, null, name, true, WPos.Zero, 1f); }
public ISound Play(SoundType type, string name, WPos pos) { return Play(type, null, name, false, pos, 1f); }
public ISound Play(SoundType type, string name, float volumeModifier) { return Play(type, null, name, true, WPos.Zero, volumeModifier); }
public ISound Play(SoundType type, string name, WPos pos, float volumeModifier) { return Play(type, null, name, false, pos, volumeModifier); }
public ISound PlayToPlayer(SoundType type, Player player, string name) { return Play(type, player, name, true, WPos.Zero, 1f); }
public ISound PlayToPlayer(SoundType type, Player player, string name, WPos pos) { return Play(type, player, name, false, pos, 1f); }
public ISound PlayLooped(SoundType type, string name) { return PlayLooped(type, name, WPos.Zero); }
public ISound PlayLooped(SoundType type, string name, WPos pos) { return Play(type, null, name, true, pos, 1f, true); }
public void PlayVideo(byte[] raw, int channels, int sampleBits, int sampleRate)
{
@@ -300,7 +302,7 @@ namespace OpenRA
}
// Returns true if played successfully
public bool PlayPredefined(Ruleset ruleset, Player p, Actor voicedActor, string type, string definition, string variant,
public bool PlayPredefined(SoundType soundType, Ruleset ruleset, Player p, Actor voicedActor, string type, string definition, string variant,
bool relative, WPos pos, float volumeModifier, bool attenuateVolume)
{
if (ruleset == null)
@@ -375,7 +377,7 @@ namespace OpenRA
if (type == null || notification == null)
return false;
return PlayPredefined(rules, player, null, type.ToLowerInvariant(), notification, variant, true, WPos.Zero, 1f, false);
return PlayPredefined(SoundType.UI, rules, player, null, type.ToLowerInvariant(), notification, variant, true, WPos.Zero, 1f, false);
}
public void Dispose()

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Effects
anim.PlayThen(sequence, () => Finish(world));
if (weapon.Report != null && weapon.Report.Any())
Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), launchPos);
Game.Sound.Play(SoundType.World, weapon.Report.Random(firedBy.World.SharedRandom), launchPos);
}
public void Tick(World world)

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Cnc.Traits
self.World.AddFrameEndTask(w =>
{
PlayLaunchSounds();
Game.Sound.Play(info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation));
Game.Sound.Play(SoundType.World, info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation));
w.Add(new IonCannon(self.Owner, info.WeaponInfo, w, self.CenterPosition, order.TargetLocation,
info.Effect, info.EffectSequence, info.EffectPalette, info.WeaponDelay));

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Activities
if (!playedSound && helicopter.Info.TakeoffSound != null && self.IsAtGroundLevel())
{
Game.Sound.Play(helicopter.Info.TakeoffSound);
Game.Sound.Play(SoundType.World, helicopter.Info.TakeoffSound);
playedSound = true;
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Activities
if (!playedSound && helicopter.Info.LandingSound != null && !self.IsAtGroundLevel())
{
Game.Sound.Play(helicopter.Info.LandingSound);
Game.Sound.Play(SoundType.World, helicopter.Info.LandingSound);
playedSound = true;
}

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Activities
var sound = pool.Info.RearmSound;
if (sound != null)
Game.Sound.PlayToPlayer(self.Owner, sound, self.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, sound, self.CenterPosition);
ammoPoolsReloadTimes[pool] = pool.Info.ReloadDelay;
}

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Activities
self.Dispose();
foreach (var s in Sounds)
Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, s, self.CenterPosition);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Notification, self.Owner.Faction.InternalName);

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Effects
pos = launchPos;
if (weapon.Report != null && weapon.Report.Any())
Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), pos);
Game.Sound.Play(SoundType.World, weapon.Report.Random(firedBy.World.SharedRandom), pos);
if (skipAscent)
ticks = turn;

View File

@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Play a sound file")]
public void PlaySound(string file)
{
Game.Sound.Play(file);
// TODO: Investigate how scripts use this function, and think about exposing the UI vs World distinction if needed
Game.Sound.Play(SoundType.World, file);
}
[Desc("Play track defined in music.yaml or map.yaml, or keep track empty for playing a random song.")]

View File

@@ -245,7 +245,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.Add(projectile);
if (args.Weapon.Report != null && args.Weapon.Report.Any())
Game.Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
foreach (var na in self.TraitsImplementing<INotifyAttack>())
na.Attacking(self, target, this, barrel);

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
notify.Charging(self, target);
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
Game.Sound.Play(attack.info.ChargeAudio, self.CenterPosition);
Game.Sound.Play(SoundType.World, attack.info.ChargeAudio, self.CenterPosition);
return ActivityUtils.SequenceActivities(new Wait(attack.info.InitialChargeDelay), new ChargeFire(attack, target), this);
}

View File

@@ -236,7 +236,7 @@ namespace OpenRA.Mods.Common.Traits
RemoveSmudges();
foreach (var s in Info.UndeploySounds)
Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, s, self.CenterPosition);
}
void INotifyTransform.OnTransform(Actor self) { }

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits
// Gate was fully open
if (Position == OpenPosition)
{
Game.Sound.Play(info.ClosingSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.ClosingSound, self.CenterPosition);
self.World.ActorMap.AddInfluence(self, this);
}
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
{
// Gate was fully closed
if (Position == 0)
Game.Sound.Play(info.OpeningSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.OpeningSound, self.CenterPosition);
Position++;

View File

@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Traits
cloakedToken = upgradeManager.GrantCondition(self, Info.CloakedCondition);
if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked))
Game.Sound.Play(Info.CloakSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, Info.CloakSound, self.CenterPosition);
}
else if (!isCloaked && wasCloaked)
{
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits
cloakedToken = upgradeManager.RevokeCondition(self, cloakedToken);
if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked))
Game.Sound.Play(Info.UncloakSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, Info.UncloakSound, self.CenterPosition);
}
wasCloaked = isCloaked;

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual void Activate(Actor collector)
{
Game.Sound.PlayToPlayer(collector.Owner, info.Notification);
Game.Sound.PlayToPlayer(SoundType.World, collector.Owner, info.Notification);
if (info.Effect != null)
collector.World.AddFrameEndTask(w => w.Add(new CrateEffect(collector, info.Effect, info.Palette)));

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
if (!CrushableInner(crushClasses, crusher.Owner))
return;
Game.Sound.Play(info.CrushSound, crusher.CenterPosition);
Game.Sound.Play(SoundType.World, info.CrushSound, crusher.CenterPosition);
self.Kill(crusher);
}

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
w.Add(pilot);
pilot.QueueActivity(new Parachute(pilot, cp));
});
Game.Sound.Play(info.ChuteSound, cp);
Game.Sound.Play(SoundType.World, info.ChuteSound, cp);
}
else
{

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
return;
if (weapon.Report != null && weapon.Report.Any())
Game.Sound.Play(weapon.Report.Random(e.Attacker.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, weapon.Report.Random(e.Attacker.World.SharedRandom), self.CenterPosition);
if (info.Type == ExplosionType.Footprint && buildingInfo != null)
{

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
w.Add(a);
a.QueueActivity(new Parachute(a, self.CenterPosition));
});
Game.Sound.Play(info.ChuteSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.ChuteSound, self.CenterPosition);
}
static bool IsSuitableCell(Actor actorToDrop, CPos p)

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
var onWater = info.WaterTerrainTypes.Contains(self.World.Map.GetTerrainInfo(cell).Type);
var sound = onWater ? info.WaterImpactSound : info.GroundImpactSound;
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
var sequence = onWater ? info.WaterCorpseSequence : info.GroundCorpseSequence;
var palette = onWater ? info.WaterCorpsePalette : info.GroundCorpsePalette;

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
if (playSounds)
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, building.CenterPosition);
playSounds = false;
}
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits
pluggable.EnablePlug(host, plugInfo.Type);
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(order.Player, s, host.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, host.CenterPosition);
}
else
{
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
});
foreach (var s in buildingInfo.BuildSounds)
Game.Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.World, order.Player, s, building.CenterPosition);
}
if (producer.Actor != null)

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
cargo.Delivered(self);
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit, factionVariant));
Game.Sound.Play(info.ChuteSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.ChuteSound, self.CenterPosition);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
}));

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
self.CancelActivity();
foreach (var s in info.SellSounds)
Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, s, self.CenterPosition);
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Selling(self);

View File

@@ -50,9 +50,9 @@ namespace OpenRA.Mods.Common.Traits.Sound
if (wasDisabled && Info.Interval <= 0)
{
if (self.OccupiesSpace != null)
currentSound = Game.Sound.PlayLooped(Info.SoundFile, self.CenterPosition);
currentSound = Game.Sound.PlayLooped(SoundType.World, Info.SoundFile, self.CenterPosition);
else
currentSound = Game.Sound.PlayLooped(Info.SoundFile);
currentSound = Game.Sound.PlayLooped(SoundType.World, Info.SoundFile);
}
wasDisabled = false;
@@ -66,9 +66,9 @@ namespace OpenRA.Mods.Common.Traits.Sound
interval = Info.Interval;
if (self.OccupiesSpace != null)
Game.Sound.Play(Info.SoundFile, self.CenterPosition);
Game.Sound.Play(SoundType.World, Info.SoundFile, self.CenterPosition);
else
Game.Sound.Play(Info.SoundFile);
Game.Sound.Play(SoundType.World, Info.SoundFile);
}
}
}

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
void PlaySound(Actor self)
{
if (info.Sounds.Any())
Game.Sound.Play(info.Sounds.Random(self.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, info.Sounds.Random(self.World.SharedRandom), self.CenterPosition);
}
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)

View File

@@ -40,12 +40,12 @@ namespace OpenRA.Mods.Common.Traits.Sound
if (e.DamageState == DamageState.Dead)
{
var sound = info.DestroyedSounds.RandomOrDefault(rand);
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
}
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
{
var sound = info.DamagedSounds.RandomOrDefault(rand);
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
}
}
}

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
{
Game.Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
Game.Sound.PlayToPlayer(SoundType.World, manager.Self.Owner, Info.SelectTargetSound);
self.World.OrderGenerator = new SelectUpgradeTarget(Self.World, order, manager, this);
}
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
if (wsb != null && wsb.DefaultAnimation.HasSequence(info.Sequence))
wsb.PlayCustomAnimation(self, info.Sequence, () => wsb.CancelCustomAnimation(self));
Game.Sound.Play(info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation));
Game.Sound.Play(SoundType.World, info.OnFireSound, self.World.Map.CenterOfCell(order.TargetLocation));
foreach (var a in UnitsInRange(order.TargetLocation))
{

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
{
var location = self.World.Map.CenterOfCell(order.TargetLocation);
Game.Sound.Play(info.DeploySound, location);
Game.Sound.Play(SoundType.World, info.DeploySound, location);
if (!string.IsNullOrEmpty(info.EffectSequence) && !string.IsNullOrEmpty(info.EffectPalette))
w.Add(new SpriteEffect(location, w, info.EffectImage, info.EffectSequence, info.EffectPalette));

View File

@@ -89,21 +89,21 @@ namespace OpenRA.Mods.Common.Traits
public virtual void Charging(Actor self, string key)
{
Game.Sound.PlayToPlayer(self.Owner, Info.BeginChargeSound);
Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, Info.BeginChargeSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.BeginChargeSpeechNotification, self.Owner.Faction.InternalName);
}
public virtual void Charged(Actor self, string key)
{
Game.Sound.PlayToPlayer(self.Owner, Info.EndChargeSound);
Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, Info.EndChargeSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.EndChargeSpeechNotification, self.Owner.Faction.InternalName);
}
public virtual void SelectTarget(Actor self, string order, SupportPowerManager manager)
{
Game.Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
self.World.OrderGenerator = new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left);
@@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Traits
{
var renderPlayer = Self.World.RenderPlayer;
var isAllied = Self.Owner.IsAlliedWith(renderPlayer);
Game.Sound.Play(isAllied ? Info.LaunchSound : Info.IncomingSound);
Game.Sound.Play(SoundType.UI, isAllied ? Info.LaunchSound : Info.IncomingSound);
// IsAlliedWith returns true if renderPlayer is null, so we are safe here.
var toPlayer = isAllied ? renderPlayer ?? Self.Owner : renderPlayer;

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.Add(projectile);
if (args.Weapon.Report != null && args.Weapon.Report.Any())
Game.Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
}
});
}

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
// Only play the "Cannot deploy here" audio
// for non-queued orders
foreach (var s in info.NoTransformSounds)
Game.Sound.PlayToPlayer(self.Owner, s);
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, s);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.NoTransformNotification, self.Owner.Faction.InternalName);

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
conditionToken = manager.GrantCondition(self, info.Condition);
var sound = info.EnabledSounds.RandomOrDefault(Game.CosmeticRandom);
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
}
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
conditionToken = manager.RevokeCondition(self, conditionToken);
var sound = info.DisabledSounds.RandomOrDefault(Game.CosmeticRandom);
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
}
}
}

View File

@@ -204,7 +204,7 @@ namespace OpenRA.Mods.Common.Traits
return;
if (!string.IsNullOrEmpty(info.DeploySound))
Game.Sound.Play(info.DeploySound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.DeploySound, self.CenterPosition);
// Revoke upgrades that are used while undeployed.
if (!init)
@@ -227,7 +227,7 @@ namespace OpenRA.Mods.Common.Traits
return;
if (!string.IsNullOrEmpty(info.UndeploySound))
Game.Sound.Play(info.UndeploySound, self.CenterPosition);
Game.Sound.Play(SoundType.World, info.UndeploySound, self.CenterPosition);
if (!init)
OnUndeployStarted();

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
if (cachedDisabled != disabled)
{
Game.Sound.Play(disabled ? info.DisableSound : info.EnableSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, disabled ? info.DisableSound : info.EnableSound, self.CenterPosition);
desiredRange = disabled ? WDist.Zero : info.Range;
desiredVRange = disabled ? WDist.Zero : info.MaximumVerticalOffset;
cachedDisabled = disabled;

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
var type = Info.VoiceSet.ToLowerInvariant();
var volume = Info.Volume;
return Game.Sound.PlayPredefined(self.World.Map.Rules, null, self, type, phrase, variant, true, WPos.Zero, volume, true);
return Game.Sound.PlayPredefined(SoundType.World, self.World.Map.Rules, null, self, type, phrase, variant, true, WPos.Zero, volume, true);
}
public bool PlayVoiceLocal(Actor self, string phrase, string variant, float volume)
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
return false;
var type = Info.VoiceSet.ToLowerInvariant();
return Game.Sound.PlayPredefined(self.World.Map.Rules, null, self, type, phrase, variant, false, self.CenterPosition, volume, true);
return Game.Sound.PlayPredefined(SoundType.World, self.World.Map.Rules, null, self, type, phrase, variant, false, self.CenterPosition, volume, true);
}
public bool HasVoice(Actor self, string voice)

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Warheads
var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
if (impactSound != null)
Game.Sound.Play(impactSound, pos);
Game.Sound.Play(SoundType.World, impactSound, pos);
}
public bool IsValidImpact(WPos pos, Actor firedBy)

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Widgets
recentLines.Add(new ChatLine(from, text, Game.LocalTick + RemoveTime, c));
if (Notification != null)
Game.Sound.Play(Notification);
Game.Sound.Play(SoundType.UI, Notification);
while (recentLines.Count > LogLength)
recentLines.RemoveAt(0);

View File

@@ -218,14 +218,14 @@ namespace OpenRA.Mods.Common.Widgets
{
if (PickUpCompletedBuildingIcon(icon, item))
{
Game.Sound.Play(TabClick);
Game.Sound.Play(SoundType.UI, TabClick);
return true;
}
if (item != null && item.Paused)
{
// Resume a paused item
Game.Sound.Play(TabClick);
Game.Sound.Play(SoundType.UI, TabClick);
World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
return true;
}
@@ -233,7 +233,7 @@ namespace OpenRA.Mods.Common.Widgets
if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
{
// Queue a new item
Game.Sound.Play(TabClick);
Game.Sound.Play(SoundType.UI, TabClick);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
return true;
@@ -247,7 +247,7 @@ namespace OpenRA.Mods.Common.Widgets
if (item == null)
return false;
Game.Sound.Play(TabClick);
Game.Sound.Play(SoundType.UI, TabClick);
if (item.Paused || item.Done || item.TotalCost == item.RemainingCost)
{
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Widgets
return false;
// Directly cancel, skipping "on-hold"
Game.Sound.Play(TabClick);
Game.Sound.Play(SoundType.UI, TabClick);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));
@@ -289,7 +289,7 @@ namespace OpenRA.Mods.Common.Widgets
: false;
if (!handled)
Game.Sound.Play(DisabledTabClick);
Game.Sound.Play(SoundType.UI, DisabledTabClick);
return true;
}

View File

@@ -333,7 +333,7 @@ namespace OpenRA.Mods.Common.Widgets
// Enable/Disable the radar
var enabled = IsEnabled();
if (enabled != cachedEnabled)
Game.Sound.Play(enabled ? RadarOnlineSound : RadarOfflineSound);
Game.Sound.Play(SoundType.UI, enabled ? RadarOnlineSound : RadarOfflineSound);
cachedEnabled = enabled;
if (enabled)

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Widgets
{
if (!clicked.Power.Active)
{
Game.Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound);
Game.Sound.PlayToPlayer(SoundType.UI, spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound);
Game.Sound.PlayNotification(spm.Self.World.Map.Rules, spm.Self.Owner, "Speech",
clicked.Power.Info.InsufficientPowerSpeechNotification, spm.Self.Owner.Faction.InternalName);
}

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.D2k.Activities
var attackPosition = self.CenterPosition;
var affectedPlayers = targets.Select(x => x.Owner).Distinct().ToList();
Game.Sound.Play(swallow.Info.WormAttackSound, self.CenterPosition);
Game.Sound.Play(SoundType.World, swallow.Info.WormAttackSound, self.CenterPosition);
Game.RunAfterDelay(1000, () =>
{

View File

@@ -152,7 +152,7 @@ namespace OpenRA.Mods.D2k.Traits
self.World.Add(projectile);
if (args.Weapon.Report != null && args.Weapon.Report.Any())
Game.Sound.Play(args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
}
});
}

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
self.Trait<WithInfantryBody>().Attacking(self, Target.FromActor(target), a);
if (weapon.Report != null && weapon.Report.Any())
Game.Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
Game.Sound.Play(SoundType.World, weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
}
public override Activity Tick(Actor self)

View File

@@ -60,8 +60,8 @@ namespace OpenRA.Mods.RA.Activities
destination = bestCell.Value;
Game.Sound.Play(sound, self.CenterPosition);
Game.Sound.Play(sound, self.World.Map.CenterOfCell(destination));
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
Game.Sound.Play(SoundType.World, sound, self.World.Map.CenterOfCell(destination));
self.Trait<IPositionable>().SetPosition(self, destination);
self.Generation++;

View File

@@ -159,9 +159,9 @@ namespace OpenRA.Mods.RA.Traits
wfsb.PlayCustomAnimationRepeating(self, info.ThumpSequence);
deployed = true;
self.QueueActivity(new Wait(info.ChargeDelay, false));
self.QueueActivity(new CallFunc(() => Game.Sound.Play(info.ChargeSound, self.CenterPosition)));
self.QueueActivity(new CallFunc(() => Game.Sound.Play(SoundType.World, info.ChargeSound, self.CenterPosition)));
self.QueueActivity(new Wait(info.DetonationDelay, false));
self.QueueActivity(new CallFunc(() => Game.Sound.Play(info.DetonationSound, self.CenterPosition)));
self.QueueActivity(new CallFunc(() => Game.Sound.Play(SoundType.World, info.DetonationSound, self.CenterPosition)));
self.QueueActivity(new CallFunc(Detonate));
}

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Traits
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
{
Game.Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
self.World.OrderGenerator = new SelectChronoshiftTarget(Self.World, order, manager, this);
}

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Traits
self.World.AddFrameEndTask(w =>
{
Game.Sound.PlayToPlayer(self.Owner, Info.LaunchSound);
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, Info.LaunchSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.LaunchSpeechNotification, self.Owner.Faction.InternalName);

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.TS.Traits
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
{
Game.Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound);
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
self.World.OrderGenerator = new SelectAttackPowerTarget(self, order, manager, info.Cursor, MouseButton.Left, attack);
}