Skip to content

Commit

Permalink
Add Misc SFX/Polish
Browse files Browse the repository at this point in the history
+Transport sfx
+Casing added to HMMV,JEEP,BGGY,IFV
+Add Heli/Jet SFX
  • Loading branch information
Inq8 committed Feb 25, 2024
1 parent 6228a42 commit e820105
Show file tree
Hide file tree
Showing 23 changed files with 238 additions and 33 deletions.
60 changes: 60 additions & 0 deletions OpenRA.Mods.CA/Traits/Sound/SoundOnDamageTransitionCA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#region Copyright & License Information
/*
* Copyright (c) The CA Developers and Contributors
* This file is part of CA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion

using System;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;

namespace OpenRA.Mods.CA.Traits.Sound
{
public class SoundOnDamageTransitionCAInfo : ConditionalTraitInfo
{
[Desc("Play a random sound from this list when damaged.")]
public readonly string[] DamagedSounds = Array.Empty<string>();

[Desc("Play a random sound from this list when destroyed.")]
public readonly string[] DestroyedSounds = Array.Empty<string>();

[Desc("DamageType(s) that trigger the sounds. Leave empty to always trigger a sound.")]
public readonly BitSet<DamageType> DamageTypes = default;

public override object Create(ActorInitializer init) { return new SoundOnDamageTransitionCA(init.Self, this); }
}

public class SoundOnDamageTransitionCA : ConditionalTrait<SoundOnDamageTransitionCAInfo>, INotifyDamageStateChanged
{
public SoundOnDamageTransitionCA(Actor self, SoundOnDamageTransitionCAInfo info)
: base(info) { }

void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
{
if (IsTraitDisabled)
return;

if (!Info.DamageTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DamageTypes))
return;

var rand = Game.CosmeticRandom;

if (e.DamageState == DamageState.Dead)
{
var sound = Info.DestroyedSounds.RandomOrDefault(rand);
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(SoundType.World, sound, self.CenterPosition);
}
}
}
}
6 changes: 6 additions & 0 deletions OpenRA.Mods.CA/Traits/Sound/WithCargoSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public WithCargoSounds(Actor self, WithCargoSoundsInfo info)

void INotifyPassengerEntered.OnPassengerEntered(Actor self, Actor passenger)
{
if (IsTraitDisabled)
return;

if (Info.EnterSounds.Length > 0)
{
var pos = self.CenterPosition;
Expand All @@ -55,6 +58,9 @@ void INotifyPassengerEntered.OnPassengerEntered(Actor self, Actor passenger)

void INotifyPassengerExited.OnPassengerExited(Actor self, Actor passenger)
{
if (IsTraitDisabled)
return;

if (Info.ExitSounds.Length > 0)
{
var pos = self.CenterPosition;
Expand Down
Binary file added mods/ca/bits/audio/cjetbanb.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/cjetbanc.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/genter1a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/gexit1a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vcomdi1a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vcomdi2a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vhelidi1a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vhelidi2a.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vhelilana.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vhelistaa.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vrapdiea.aud
Binary file not shown.
Binary file added mods/ca/bits/audio/vrapdieb.aud
Binary file not shown.
Loading

0 comments on commit e820105

Please sign in to comment.