Add support for random sounds to AmbientSound
This commit is contained in:
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
|||||||
class AmbientSoundInfo : ConditionalTraitInfo
|
class AmbientSoundInfo : ConditionalTraitInfo
|
||||||
{
|
{
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
public readonly string SoundFile = null;
|
public readonly string[] SoundFiles = null;
|
||||||
|
|
||||||
[Desc("Initial delay (in ticks) before playing the sound for the first time.",
|
[Desc("Initial delay (in ticks) before playing the sound for the first time.",
|
||||||
"Two values indicate a random delay range.")]
|
"Two values indicate a random delay range.")]
|
||||||
@@ -74,16 +74,18 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
|||||||
|
|
||||||
void StartSound(Actor self)
|
void StartSound(Actor self)
|
||||||
{
|
{
|
||||||
|
var sound = Info.SoundFiles.RandomOrDefault(Game.CosmeticRandom);
|
||||||
|
|
||||||
ISound s;
|
ISound s;
|
||||||
if (self.OccupiesSpace != null)
|
if (self.OccupiesSpace != null)
|
||||||
{
|
{
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile, cachedPosition) :
|
s = loop ? Game.Sound.PlayLooped(SoundType.World, sound, cachedPosition) :
|
||||||
Game.Sound.Play(SoundType.World, Info.SoundFile, self.CenterPosition);
|
Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile) :
|
s = loop ? Game.Sound.PlayLooped(SoundType.World, sound) :
|
||||||
Game.Sound.Play(SoundType.World, Info.SoundFile);
|
Game.Sound.Play(SoundType.World, sound);
|
||||||
|
|
||||||
currentSounds.Add(s);
|
currentSounds.Add(s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -596,6 +596,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
RenameNodeKey(node, "-AcceptsDeliveredCash");
|
RenameNodeKey(node, "-AcceptsDeliveredCash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add random sound support to AmbientSound
|
||||||
|
if (engineVersion < 20170422)
|
||||||
|
if (node.Key == "SoundFile" && parent.Key.StartsWith("AmbientSound", StringComparison.Ordinal))
|
||||||
|
RenameNodeKey(node, "SoundFiles");
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -773,7 +773,7 @@ OBLI:
|
|||||||
ChargingCondition: charging
|
ChargingCondition: charging
|
||||||
AmbientSound:
|
AmbientSound:
|
||||||
RequiresCondition: charging
|
RequiresCondition: charging
|
||||||
SoundFile: obelpowr.aud
|
SoundFiles: obelpowr.aud
|
||||||
Interval: 30, 40
|
Interval: 30, 40
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ sandworm:
|
|||||||
Sequences: lightninga, lightningb, lightningc, lightningd, lightninge, lightningf
|
Sequences: lightninga, lightningb, lightningc, lightningd, lightninge, lightningf
|
||||||
RequiresCondition: !attacking
|
RequiresCondition: !attacking
|
||||||
AmbientSound:
|
AmbientSound:
|
||||||
SoundFile: WRMSIGN1.WAV
|
SoundFiles: WRMSIGN1.WAV
|
||||||
Interval: 160
|
Interval: 160
|
||||||
RequiresCondition: !attacking
|
RequiresCondition: !attacking
|
||||||
WithAttackOverlay@mouth:
|
WithAttackOverlay@mouth:
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ thumper:
|
|||||||
Sequence: thump-sand
|
Sequence: thump-sand
|
||||||
RequiresCondition: deployed
|
RequiresCondition: deployed
|
||||||
AmbientSound:
|
AmbientSound:
|
||||||
SoundFile: THUMPER1.WAV
|
SoundFiles: THUMPER1.WAV
|
||||||
Interval: 60
|
Interval: 60
|
||||||
RequiresCondition: deployed
|
RequiresCondition: deployed
|
||||||
AttractsWorms:
|
AttractsWorms:
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ NAOBEL:
|
|||||||
ChargingCondition: charging
|
ChargingCondition: charging
|
||||||
AmbientSound:
|
AmbientSound:
|
||||||
RequiresCondition: charging
|
RequiresCondition: charging
|
||||||
SoundFile: obelpowr.aud
|
SoundFiles: obelpowr.aud
|
||||||
Interval: 30, 40
|
Interval: 30, 40
|
||||||
WithChargeOverlay:
|
WithChargeOverlay:
|
||||||
Palette: player
|
Palette: player
|
||||||
|
|||||||
Reference in New Issue
Block a user