Disable sound on the shell maps.

This commit is contained in:
Paul Chote
2016-12-10 17:50:46 +00:00
parent 9ddfdc45b3
commit 443c3ee72d
6 changed files with 16 additions and 2 deletions

View File

@@ -96,8 +96,9 @@ namespace OpenRA
ISound Play(SoundType type, Player player, string name, bool headRelative, WPos pos, float volumeModifier = 1f, bool loop = false)
{
if (string.IsNullOrEmpty(name))
if (string.IsNullOrEmpty(name) || (DisableWorldSounds && type == SoundType.World))
return null;
if (player != null && player != player.World.LocalPlayer)
return null;
@@ -121,6 +122,7 @@ namespace OpenRA
soundEngine.Volume = 1f;
}
public bool DisableWorldSounds { get; set; }
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); }
@@ -308,7 +310,7 @@ namespace OpenRA
if (ruleset == null)
throw new ArgumentNullException("ruleset");
if (definition == null)
if (definition == null || (DisableWorldSounds && soundType == SoundType.World))
return false;
if (ruleset.Voices == null || ruleset.Notifications == null)

View File

@@ -32,6 +32,9 @@ namespace OpenRA.Mods.Common.Traits
"It cannot be paused, but can be overridden by selecting a new track.")]
public readonly string BackgroundMusic = null;
[Desc("Disable all world sounds (combat etc).")]
public readonly bool DisableWorldSounds = false;
public object Create(ActorInitializer init) { return new MusicPlaylist(init.World, this); }
}
@@ -55,6 +58,9 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
this.world = world;
if (info.DisableWorldSounds)
Game.Sound.DisableWorldSounds = true;
IsMusicInstalled = world.Map.Rules.InstalledMusic.Any();
if (!IsMusicInstalled)
return;
@@ -220,6 +226,8 @@ namespace OpenRA.Mods.Common.Traits
{
if (currentSong != null)
Game.Sound.StopMusic();
Game.Sound.DisableWorldSounds = false;
}
}
}

View File

@@ -8,6 +8,7 @@ World:
Scripts: shellmap.lua
MusicPlaylist:
BackgroundMusic: map1
DisableWorldSounds: true
LST:
Mobile:

View File

@@ -13,6 +13,7 @@ World:
Maximum: 3
MusicPlaylist:
BackgroundMusic: options
DisableWorldSounds: true
LuaScript:
Scripts: d2k-shellmap.lua

View File

@@ -7,6 +7,7 @@ World:
-MPStartLocations:
MusicPlaylist:
BackgroundMusic: intro
DisableWorldSounds: true
ResourceType@ore:
ValuePerUnit: 0
LuaScript:

View File

@@ -1433,6 +1433,7 @@ Rules:
ValuePerUnit: 0
MusicPlaylist:
BackgroundMusic: intro
DisableWorldSounds: true
GlobalLightingPaletteEffect:
Blue: 0.7
Ambient: 0.7