diff --git a/Audio/ActiveSound.cs b/Audio/ActiveSound.cs deleted file mode 100644 index 4dacab7..0000000 --- a/Audio/ActiveSound.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.ActiveSound -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; - -namespace Terraria.Audio -{ - public class ActiveSound - { - public readonly bool IsGlobal; - public Vector2 Position; - public float Volume; - - public SoundEffectInstance Sound { get; private set; } - - public SoundStyle Style { get; private set; } - - public bool IsPlaying => this.Sound.State == SoundState.Playing; - - public ActiveSound(SoundStyle style, Vector2 position) - { - this.Position = position; - this.Volume = 1f; - this.IsGlobal = false; - this.Style = style; - this.Play(); - } - - public ActiveSound(SoundStyle style) - { - this.Position = Vector2.Zero; - this.Volume = 1f; - this.IsGlobal = true; - this.Style = style; - this.Play(); - } - - private void Play() - { - SoundEffectInstance instance = this.Style.GetRandomSound().CreateInstance(); - instance.Pitch += this.Style.GetRandomPitch(); - instance.Play(); - SoundInstanceGarbageCollector.Track(instance); - this.Sound = instance; - this.Update(); - } - - public void Stop() - { - if (this.Sound == null) - return; - this.Sound.Stop(); - } - - public void Pause() - { - if (this.Sound == null || this.Sound.State != SoundState.Playing) - return; - this.Sound.Pause(); - } - - public void Resume() - { - if (this.Sound == null || this.Sound.State != SoundState.Paused) - return; - this.Sound.Resume(); - } - - public void Update() - { - if (this.Sound == null) - return; - Vector2 vector2 = Main.screenPosition + new Vector2((float) (Main.screenWidth / 2), (float) (Main.screenHeight / 2)); - float num1 = 1f; - if (!this.IsGlobal) - { - this.Sound.Pan = MathHelper.Clamp((float) (((double) this.Position.X - (double) vector2.X) / ((double) Main.screenWidth * 0.5)), -1f, 1f); - num1 = (float) (1.0 - (double) Vector2.Distance(this.Position, vector2) / ((double) Main.screenWidth * 1.5)); - } - float num2 = num1 * (this.Style.Volume * this.Volume); - switch (this.Style.Type) - { - case SoundType.Sound: - num2 *= Main.soundVolume; - break; - case SoundType.Ambient: - num2 *= Main.ambientVolume; - break; - case SoundType.Music: - num2 *= Main.musicVolume; - break; - } - this.Sound.Volume = MathHelper.Clamp(num2, 0.0f, 1f); - } - } -} diff --git a/Audio/CustomSoundStyle.cs b/Audio/CustomSoundStyle.cs deleted file mode 100644 index fec2035..0000000 --- a/Audio/CustomSoundStyle.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.CustomSoundStyle -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework.Audio; -using Terraria.Utilities; - -namespace Terraria.Audio -{ - public class CustomSoundStyle : SoundStyle - { - private static readonly UnifiedRandom Random = new UnifiedRandom(); - private readonly SoundEffect[] _soundEffects; - - public override bool IsTrackable => true; - - public CustomSoundStyle( - SoundEffect soundEffect, - SoundType type = SoundType.Sound, - float volume = 1f, - float pitchVariance = 0.0f) - : base(volume, pitchVariance, type) - { - this._soundEffects = new SoundEffect[1]{ soundEffect }; - } - - public CustomSoundStyle( - SoundEffect[] soundEffects, - SoundType type = SoundType.Sound, - float volume = 1f, - float pitchVariance = 0.0f) - : base(volume, pitchVariance, type) - { - this._soundEffects = soundEffects; - } - - public override SoundEffect GetRandomSound() => this._soundEffects[CustomSoundStyle.Random.Next(this._soundEffects.Length)]; - } -} diff --git a/Audio/LegacySoundPlayer.cs b/Audio/LegacySoundPlayer.cs deleted file mode 100644 index e1175d9..0000000 --- a/Audio/LegacySoundPlayer.cs +++ /dev/null @@ -1,996 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.LegacySoundPlayer -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using ReLogic.Content; -using ReLogic.Utilities; -using System; -using System.IO; -using Terraria.ID; - -namespace Terraria.Audio -{ - public class LegacySoundPlayer - { - private Asset[] _soundDrip = new Asset[3]; - private SoundEffectInstance[] _soundInstanceDrip = new SoundEffectInstance[3]; - private Asset[] _soundLiquid = new Asset[2]; - private SoundEffectInstance[] _soundInstanceLiquid = new SoundEffectInstance[2]; - private Asset[] _soundMech = new Asset[1]; - private SoundEffectInstance[] _soundInstanceMech = new SoundEffectInstance[1]; - private Asset[] _soundDig = new Asset[3]; - private SoundEffectInstance[] _soundInstanceDig = new SoundEffectInstance[3]; - private Asset[] _soundThunder = new Asset[7]; - private SoundEffectInstance[] _soundInstanceThunder = new SoundEffectInstance[7]; - private Asset[] _soundResearch = new Asset[4]; - private SoundEffectInstance[] _soundInstanceResearch = new SoundEffectInstance[4]; - private Asset[] _soundTink = new Asset[3]; - private SoundEffectInstance[] _soundInstanceTink = new SoundEffectInstance[3]; - private Asset[] _soundCoin = new Asset[5]; - private SoundEffectInstance[] _soundInstanceCoin = new SoundEffectInstance[5]; - private Asset[] _soundPlayerHit = new Asset[3]; - private SoundEffectInstance[] _soundInstancePlayerHit = new SoundEffectInstance[3]; - private Asset[] _soundFemaleHit = new Asset[3]; - private SoundEffectInstance[] _soundInstanceFemaleHit = new SoundEffectInstance[3]; - private Asset _soundPlayerKilled; - private SoundEffectInstance _soundInstancePlayerKilled; - private Asset _soundGrass; - private SoundEffectInstance _soundInstanceGrass; - private Asset _soundGrab; - private SoundEffectInstance _soundInstanceGrab; - private Asset _soundPixie; - private SoundEffectInstance _soundInstancePixie; - private Asset[] _soundItem = new Asset[(int) SoundID.ItemSoundCount]; - private SoundEffectInstance[] _soundInstanceItem = new SoundEffectInstance[(int) SoundID.ItemSoundCount]; - private Asset[] _soundNpcHit = new Asset[58]; - private SoundEffectInstance[] _soundInstanceNpcHit = new SoundEffectInstance[58]; - private Asset[] _soundNpcKilled = new Asset[(int) SoundID.NPCDeathCount]; - private SoundEffectInstance[] _soundInstanceNpcKilled = new SoundEffectInstance[(int) SoundID.NPCDeathCount]; - private SoundEffectInstance _soundInstanceMoonlordCry; - private Asset _soundDoorOpen; - private SoundEffectInstance _soundInstanceDoorOpen; - private Asset _soundDoorClosed; - private SoundEffectInstance _soundInstanceDoorClosed; - private Asset _soundMenuOpen; - private SoundEffectInstance _soundInstanceMenuOpen; - private Asset _soundMenuClose; - private SoundEffectInstance _soundInstanceMenuClose; - private Asset _soundMenuTick; - private SoundEffectInstance _soundInstanceMenuTick; - private Asset _soundShatter; - private SoundEffectInstance _soundInstanceShatter; - private Asset _soundCamera; - private SoundEffectInstance _soundInstanceCamera; - private Asset[] _soundZombie = new Asset[118]; - private SoundEffectInstance[] _soundInstanceZombie = new SoundEffectInstance[118]; - private Asset[] _soundRoar = new Asset[3]; - private SoundEffectInstance[] _soundInstanceRoar = new SoundEffectInstance[3]; - private Asset[] _soundSplash = new Asset[2]; - private SoundEffectInstance[] _soundInstanceSplash = new SoundEffectInstance[2]; - private Asset _soundDoubleJump; - private SoundEffectInstance _soundInstanceDoubleJump; - private Asset _soundRun; - private SoundEffectInstance _soundInstanceRun; - private Asset _soundCoins; - private SoundEffectInstance _soundInstanceCoins; - private Asset _soundUnlock; - private SoundEffectInstance _soundInstanceUnlock; - private Asset _soundChat; - private SoundEffectInstance _soundInstanceChat; - private Asset _soundMaxMana; - private SoundEffectInstance _soundInstanceMaxMana; - private Asset _soundDrown; - private SoundEffectInstance _soundInstanceDrown; - private Asset[] _trackableSounds; - private SoundEffectInstance[] _trackableSoundInstances; - private readonly IServiceProvider _services; - - public LegacySoundPlayer(IServiceProvider services) - { - this._services = services; - this.LoadAll(); - } - - private void LoadAll() - { - this._soundMech[0] = this.Load("Sounds/Mech_0"); - this._soundGrab = this.Load("Sounds/Grab"); - this._soundPixie = this.Load("Sounds/Pixie"); - this._soundDig[0] = this.Load("Sounds/Dig_0"); - this._soundDig[1] = this.Load("Sounds/Dig_1"); - this._soundDig[2] = this.Load("Sounds/Dig_2"); - this._soundThunder[0] = this.Load("Sounds/Thunder_0"); - this._soundThunder[1] = this.Load("Sounds/Thunder_1"); - this._soundThunder[2] = this.Load("Sounds/Thunder_2"); - this._soundThunder[3] = this.Load("Sounds/Thunder_3"); - this._soundThunder[4] = this.Load("Sounds/Thunder_4"); - this._soundThunder[5] = this.Load("Sounds/Thunder_5"); - this._soundThunder[6] = this.Load("Sounds/Thunder_6"); - this._soundResearch[0] = this.Load("Sounds/Research_0"); - this._soundResearch[1] = this.Load("Sounds/Research_1"); - this._soundResearch[2] = this.Load("Sounds/Research_2"); - this._soundResearch[3] = this.Load("Sounds/Research_3"); - this._soundTink[0] = this.Load("Sounds/Tink_0"); - this._soundTink[1] = this.Load("Sounds/Tink_1"); - this._soundTink[2] = this.Load("Sounds/Tink_2"); - this._soundPlayerHit[0] = this.Load("Sounds/Player_Hit_0"); - this._soundPlayerHit[1] = this.Load("Sounds/Player_Hit_1"); - this._soundPlayerHit[2] = this.Load("Sounds/Player_Hit_2"); - this._soundFemaleHit[0] = this.Load("Sounds/Female_Hit_0"); - this._soundFemaleHit[1] = this.Load("Sounds/Female_Hit_1"); - this._soundFemaleHit[2] = this.Load("Sounds/Female_Hit_2"); - this._soundPlayerKilled = this.Load("Sounds/Player_Killed"); - this._soundChat = this.Load("Sounds/Chat"); - this._soundGrass = this.Load("Sounds/Grass"); - this._soundDoorOpen = this.Load("Sounds/Door_Opened"); - this._soundDoorClosed = this.Load("Sounds/Door_Closed"); - this._soundMenuTick = this.Load("Sounds/Menu_Tick"); - this._soundMenuOpen = this.Load("Sounds/Menu_Open"); - this._soundMenuClose = this.Load("Sounds/Menu_Close"); - this._soundShatter = this.Load("Sounds/Shatter"); - this._soundCamera = this.Load("Sounds/Camera"); - for (int index = 0; index < this._soundCoin.Length; ++index) - this._soundCoin[index] = this.Load("Sounds/Coin_" + (object) index); - for (int index = 0; index < this._soundDrip.Length; ++index) - this._soundDrip[index] = this.Load("Sounds/Drip_" + (object) index); - for (int index = 0; index < this._soundZombie.Length; ++index) - this._soundZombie[index] = this.Load("Sounds/Zombie_" + (object) index); - for (int index = 0; index < this._soundLiquid.Length; ++index) - this._soundLiquid[index] = this.Load("Sounds/Liquid_" + (object) index); - for (int index = 0; index < this._soundRoar.Length; ++index) - this._soundRoar[index] = this.Load("Sounds/Roar_" + (object) index); - this._soundSplash[0] = this.Load("Sounds/Splash_0"); - this._soundSplash[1] = this.Load("Sounds/Splash_1"); - this._soundDoubleJump = this.Load("Sounds/Double_Jump"); - this._soundRun = this.Load("Sounds/Run"); - this._soundCoins = this.Load("Sounds/Coins"); - this._soundUnlock = this.Load("Sounds/Unlock"); - this._soundMaxMana = this.Load("Sounds/MaxMana"); - this._soundDrown = this.Load("Sounds/Drown"); - for (int index = 1; index < this._soundItem.Length; ++index) - this._soundItem[index] = this.Load("Sounds/Item_" + (object) index); - for (int index = 1; index < this._soundNpcHit.Length; ++index) - this._soundNpcHit[index] = this.Load("Sounds/NPC_Hit_" + (object) index); - for (int index = 1; index < this._soundNpcKilled.Length; ++index) - this._soundNpcKilled[index] = this.Load("Sounds/NPC_Killed_" + (object) index); - this._trackableSounds = new Asset[SoundID.TrackableLegacySoundCount]; - this._trackableSoundInstances = new SoundEffectInstance[this._trackableSounds.Length]; - for (int id = 0; id < this._trackableSounds.Length; ++id) - this._trackableSounds[id] = this.Load("Sounds/Custom" + Path.DirectorySeparatorChar.ToString() + SoundID.GetTrackableLegacySoundPath(id)); - } - - public void CreateAllSoundInstances() - { - this._soundInstanceMech[0] = this._soundMech[0].Value.CreateInstance(); - this._soundInstanceGrab = this._soundGrab.Value.CreateInstance(); - this._soundInstancePixie = this._soundGrab.Value.CreateInstance(); - this._soundInstanceDig[0] = this._soundDig[0].Value.CreateInstance(); - this._soundInstanceDig[1] = this._soundDig[1].Value.CreateInstance(); - this._soundInstanceDig[2] = this._soundDig[2].Value.CreateInstance(); - this._soundInstanceTink[0] = this._soundTink[0].Value.CreateInstance(); - this._soundInstanceTink[1] = this._soundTink[1].Value.CreateInstance(); - this._soundInstanceTink[2] = this._soundTink[2].Value.CreateInstance(); - this._soundInstancePlayerHit[0] = this._soundPlayerHit[0].Value.CreateInstance(); - this._soundInstancePlayerHit[1] = this._soundPlayerHit[1].Value.CreateInstance(); - this._soundInstancePlayerHit[2] = this._soundPlayerHit[2].Value.CreateInstance(); - this._soundInstanceFemaleHit[0] = this._soundFemaleHit[0].Value.CreateInstance(); - this._soundInstanceFemaleHit[1] = this._soundFemaleHit[1].Value.CreateInstance(); - this._soundInstanceFemaleHit[2] = this._soundFemaleHit[2].Value.CreateInstance(); - this._soundInstancePlayerKilled = this._soundPlayerKilled.Value.CreateInstance(); - this._soundInstanceChat = this._soundChat.Value.CreateInstance(); - this._soundInstanceGrass = this._soundGrass.Value.CreateInstance(); - this._soundInstanceDoorOpen = this._soundDoorOpen.Value.CreateInstance(); - this._soundInstanceDoorClosed = this._soundDoorClosed.Value.CreateInstance(); - this._soundInstanceMenuTick = this._soundMenuTick.Value.CreateInstance(); - this._soundInstanceMenuOpen = this._soundMenuOpen.Value.CreateInstance(); - this._soundInstanceMenuClose = this._soundMenuClose.Value.CreateInstance(); - this._soundInstanceShatter = this._soundShatter.Value.CreateInstance(); - this._soundInstanceCamera = this._soundCamera.Value.CreateInstance(); - for (int index = 0; index < this._soundThunder.Length; ++index) - this._soundInstanceThunder[index] = this._soundThunder[index].Value.CreateInstance(); - for (int index = 0; index < this._soundResearch.Length; ++index) - this._soundInstanceResearch[index] = this._soundResearch[index].Value.CreateInstance(); - for (int index = 0; index < this._soundCoin.Length; ++index) - this._soundInstanceCoin[index] = this._soundCoin[index].Value.CreateInstance(); - for (int index = 0; index < this._soundDrip.Length; ++index) - this._soundInstanceDrip[index] = this._soundDrip[index].Value.CreateInstance(); - for (int index = 0; index < this._soundZombie.Length; ++index) - this._soundInstanceZombie[index] = this._soundZombie[index].Value.CreateInstance(); - for (int index = 0; index < this._soundLiquid.Length; ++index) - this._soundInstanceLiquid[index] = this._soundLiquid[index].Value.CreateInstance(); - for (int index = 0; index < this._soundRoar.Length; ++index) - this._soundInstanceRoar[index] = this._soundRoar[index].Value.CreateInstance(); - this._soundInstanceSplash[0] = this._soundRoar[0].Value.CreateInstance(); - this._soundInstanceSplash[1] = this._soundSplash[1].Value.CreateInstance(); - this._soundInstanceDoubleJump = this._soundRoar[0].Value.CreateInstance(); - this._soundInstanceRun = this._soundRun.Value.CreateInstance(); - this._soundInstanceCoins = this._soundCoins.Value.CreateInstance(); - this._soundInstanceUnlock = this._soundUnlock.Value.CreateInstance(); - this._soundInstanceMaxMana = this._soundMaxMana.Value.CreateInstance(); - this._soundInstanceDrown = this._soundDrown.Value.CreateInstance(); - for (int index = 1; index < this._soundItem.Length; ++index) - this._soundInstanceItem[index] = this._soundItem[index].Value.CreateInstance(); - for (int index = 1; index < this._soundNpcHit.Length; ++index) - this._soundInstanceNpcHit[index] = this._soundNpcHit[index].Value.CreateInstance(); - for (int index = 1; index < this._soundNpcKilled.Length; ++index) - this._soundInstanceNpcKilled[index] = this._soundNpcKilled[index].Value.CreateInstance(); - for (int index = 0; index < this._trackableSounds.Length; ++index) - this._trackableSoundInstances[index] = this._trackableSounds[index].Value.CreateInstance(); - this._soundInstanceMoonlordCry = this._soundNpcKilled[10].Value.CreateInstance(); - } - - private Asset Load(string assetName) => XnaExtensions.Get(this._services).Request(assetName, (AssetRequestMode) 2); - - public SoundEffectInstance PlaySound( - int type, - int x = -1, - int y = -1, - int Style = 1, - float volumeScale = 1f, - float pitchOffset = 0.0f) - { - int index1 = Style; - try - { - if (Main.dedServ || (double) Main.soundVolume == 0.0 && (type < 30 || type > 35)) - return (SoundEffectInstance) null; - bool flag = false; - float num1 = 1f; - float num2 = 0.0f; - if (x == -1 || y == -1) - { - flag = true; - } - else - { - if (WorldGen.gen || Main.netMode == 2) - return (SoundEffectInstance) null; - Vector2 vector2 = new Vector2(Main.screenPosition.X + (float) Main.screenWidth * 0.5f, Main.screenPosition.Y + (float) Main.screenHeight * 0.5f); - double num3 = (double) Math.Abs((float) x - vector2.X); - float num4 = Math.Abs((float) y - vector2.Y); - float num5 = (float) Math.Sqrt(num3 * num3 + (double) num4 * (double) num4); - int num6 = 2500; - if ((double) num5 < (double) num6) - { - flag = true; - num2 = type != 43 ? (float) (((double) x - (double) vector2.X) / ((double) Main.screenWidth * 0.5)) : (float) (((double) x - (double) vector2.X) / 900.0); - num1 = (float) (1.0 - (double) num5 / (double) num6); - } - } - if ((double) num2 < -1.0) - num2 = -1f; - if ((double) num2 > 1.0) - num2 = 1f; - if ((double) num1 > 1.0) - num1 = 1f; - if ((double) num1 <= 0.0 && (type < 34 || type > 35 || type > 39)) - return (SoundEffectInstance) null; - if (flag) - { - float num7; - if (type >= 30 && type <= 35 || type == 39) - { - num7 = num1 * (Main.ambientVolume * (Main.gameInactive ? 0.0f : 1f)); - if (Main.gameMenu) - num7 = 0.0f; - } - else - num7 = num1 * Main.soundVolume; - if ((double) num7 > 1.0) - num7 = 1f; - if ((double) num7 <= 0.0 && (type < 30 || type > 35) && type != 39) - return (SoundEffectInstance) null; - SoundEffectInstance sound = (SoundEffectInstance) null; - if (type == 0) - { - int index2 = Main.rand.Next(3); - if (this._soundInstanceDig[index2] != null) - this._soundInstanceDig[index2].Stop(); - this._soundInstanceDig[index2] = this._soundDig[index2].Value.CreateInstance(); - this._soundInstanceDig[index2].Volume = num7; - this._soundInstanceDig[index2].Pan = num2; - this._soundInstanceDig[index2].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceDig[index2]; - } - else if (type == 43) - { - int index3 = Main.rand.Next(this._soundThunder.Length); - for (int index4 = 0; index4 < this._soundThunder.Length && this._soundInstanceThunder[index3] != null && this._soundInstanceThunder[index3].State == SoundState.Playing; ++index4) - index3 = Main.rand.Next(this._soundThunder.Length); - if (this._soundInstanceThunder[index3] != null) - this._soundInstanceThunder[index3].Stop(); - this._soundInstanceThunder[index3] = this._soundThunder[index3].Value.CreateInstance(); - this._soundInstanceThunder[index3].Volume = num7; - this._soundInstanceThunder[index3].Pan = num2; - this._soundInstanceThunder[index3].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceThunder[index3]; - } - else if (type == 63) - { - int index5 = Main.rand.Next(1, 4); - if (this._soundInstanceResearch[index5] != null) - this._soundInstanceResearch[index5].Stop(); - this._soundInstanceResearch[index5] = this._soundResearch[index5].Value.CreateInstance(); - this._soundInstanceResearch[index5].Volume = num7; - this._soundInstanceResearch[index5].Pan = num2; - sound = this._soundInstanceResearch[index5]; - } - else if (type == 64) - { - if (this._soundInstanceResearch[0] != null) - this._soundInstanceResearch[0].Stop(); - this._soundInstanceResearch[0] = this._soundResearch[0].Value.CreateInstance(); - this._soundInstanceResearch[0].Volume = num7; - this._soundInstanceResearch[0].Pan = num2; - sound = this._soundInstanceResearch[0]; - } - else if (type == 1) - { - int index6 = Main.rand.Next(3); - if (this._soundInstancePlayerHit[index6] != null) - this._soundInstancePlayerHit[index6].Stop(); - this._soundInstancePlayerHit[index6] = this._soundPlayerHit[index6].Value.CreateInstance(); - this._soundInstancePlayerHit[index6].Volume = num7; - this._soundInstancePlayerHit[index6].Pan = num2; - sound = this._soundInstancePlayerHit[index6]; - } - else if (type == 2) - { - if (index1 == 129) - num7 *= 0.6f; - if (index1 == 123) - num7 *= 0.5f; - if (index1 == 124 || index1 == 125) - num7 *= 0.65f; - if (index1 == 116) - num7 *= 0.5f; - if (index1 == 1) - { - int num8 = Main.rand.Next(3); - if (num8 == 1) - index1 = 18; - if (num8 == 2) - index1 = 19; - } - else if (index1 == 55 || index1 == 53) - { - num7 *= 0.75f; - if (index1 == 55) - num7 *= 0.75f; - if (this._soundInstanceItem[index1] != null && this._soundInstanceItem[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - } - else if (index1 == 37) - num7 *= 0.5f; - else if (index1 == 52) - num7 *= 0.35f; - else if (index1 == 157) - num7 *= 0.7f; - else if (index1 == 158) - num7 *= 0.8f; - if (index1 == 159) - { - if (this._soundInstanceItem[index1] != null && this._soundInstanceItem[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - num7 *= 0.75f; - } - else if (index1 != 9 && index1 != 10 && index1 != 24 && index1 != 26 && index1 != 34 && index1 != 43 && index1 != 103 && index1 != 156 && index1 != 162 && this._soundInstanceItem[index1] != null) - this._soundInstanceItem[index1].Stop(); - this._soundInstanceItem[index1] = this._soundItem[index1].Value.CreateInstance(); - this._soundInstanceItem[index1].Volume = num7; - this._soundInstanceItem[index1].Pan = num2; - switch (index1) - { - case 53: - this._soundInstanceItem[index1].Pitch = (float) Main.rand.Next(-20, -11) * 0.02f; - break; - case 55: - this._soundInstanceItem[index1].Pitch = (float) -Main.rand.Next(-20, -11) * 0.02f; - break; - case 132: - this._soundInstanceItem[index1].Pitch = (float) Main.rand.Next(-20, 21) * (1f / 1000f); - break; - case 153: - this._soundInstanceItem[index1].Pitch = (float) Main.rand.Next(-50, 51) * (3f / 1000f); - break; - case 156: - this._soundInstanceItem[index1].Pitch = (float) Main.rand.Next(-50, 51) * (1f / 500f); - this._soundInstanceItem[index1].Volume *= 0.6f; - break; - default: - this._soundInstanceItem[index1].Pitch = (float) Main.rand.Next(-6, 7) * 0.01f; - break; - } - if (index1 == 26 || index1 == 35 || index1 == 47) - { - this._soundInstanceItem[index1].Volume = num7 * 0.75f; - this._soundInstanceItem[index1].Pitch = Main.musicPitch; - } - if (index1 == 169) - this._soundInstanceItem[index1].Pitch -= 0.8f; - sound = this._soundInstanceItem[index1]; - } - else if (type == 3) - { - if (index1 >= 20 && index1 <= 54) - num7 *= 0.5f; - if (index1 == 57 && this._soundInstanceNpcHit[index1] != null && this._soundInstanceNpcHit[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - if (index1 == 57) - num7 *= 0.6f; - if (index1 == 55 || index1 == 56) - num7 *= 0.5f; - if (this._soundInstanceNpcHit[index1] != null) - this._soundInstanceNpcHit[index1].Stop(); - this._soundInstanceNpcHit[index1] = this._soundNpcHit[index1].Value.CreateInstance(); - this._soundInstanceNpcHit[index1].Volume = num7; - this._soundInstanceNpcHit[index1].Pan = num2; - this._soundInstanceNpcHit[index1].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceNpcHit[index1]; - } - else if (type == 4) - { - if (index1 >= 23 && index1 <= 57) - num7 *= 0.5f; - if (index1 == 61) - num7 *= 0.6f; - if (index1 == 62) - num7 *= 0.6f; - if (index1 == 10 && this._soundInstanceNpcKilled[index1] != null && this._soundInstanceNpcKilled[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceNpcKilled[index1] = this._soundNpcKilled[index1].Value.CreateInstance(); - this._soundInstanceNpcKilled[index1].Volume = num7; - this._soundInstanceNpcKilled[index1].Pan = num2; - this._soundInstanceNpcKilled[index1].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceNpcKilled[index1]; - } - else if (type == 5) - { - if (this._soundInstancePlayerKilled != null) - this._soundInstancePlayerKilled.Stop(); - this._soundInstancePlayerKilled = this._soundPlayerKilled.Value.CreateInstance(); - this._soundInstancePlayerKilled.Volume = num7; - this._soundInstancePlayerKilled.Pan = num2; - sound = this._soundInstancePlayerKilled; - } - else if (type == 6) - { - if (this._soundInstanceGrass != null) - this._soundInstanceGrass.Stop(); - this._soundInstanceGrass = this._soundGrass.Value.CreateInstance(); - this._soundInstanceGrass.Volume = num7; - this._soundInstanceGrass.Pan = num2; - this._soundInstanceGrass.Pitch = (float) Main.rand.Next(-30, 31) * 0.01f; - sound = this._soundInstanceGrass; - } - else if (type == 7) - { - if (this._soundInstanceGrab != null) - this._soundInstanceGrab.Stop(); - this._soundInstanceGrab = this._soundGrab.Value.CreateInstance(); - this._soundInstanceGrab.Volume = num7; - this._soundInstanceGrab.Pan = num2; - this._soundInstanceGrab.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceGrab; - } - else if (type == 8) - { - if (this._soundInstanceDoorOpen != null) - this._soundInstanceDoorOpen.Stop(); - this._soundInstanceDoorOpen = this._soundDoorOpen.Value.CreateInstance(); - this._soundInstanceDoorOpen.Volume = num7; - this._soundInstanceDoorOpen.Pan = num2; - this._soundInstanceDoorOpen.Pitch = (float) Main.rand.Next(-20, 21) * 0.01f; - sound = this._soundInstanceDoorOpen; - } - else if (type == 9) - { - if (this._soundInstanceDoorClosed != null) - this._soundInstanceDoorClosed.Stop(); - this._soundInstanceDoorClosed = this._soundDoorClosed.Value.CreateInstance(); - this._soundInstanceDoorClosed.Volume = num7; - this._soundInstanceDoorClosed.Pan = num2; - this._soundInstanceDoorClosed.Pitch = (float) Main.rand.Next(-20, 21) * 0.01f; - sound = this._soundInstanceDoorClosed; - } - else if (type == 10) - { - if (this._soundInstanceMenuOpen != null) - this._soundInstanceMenuOpen.Stop(); - this._soundInstanceMenuOpen = this._soundMenuOpen.Value.CreateInstance(); - this._soundInstanceMenuOpen.Volume = num7; - this._soundInstanceMenuOpen.Pan = num2; - sound = this._soundInstanceMenuOpen; - } - else if (type == 11) - { - if (this._soundInstanceMenuClose != null) - this._soundInstanceMenuClose.Stop(); - this._soundInstanceMenuClose = this._soundMenuClose.Value.CreateInstance(); - this._soundInstanceMenuClose.Volume = num7; - this._soundInstanceMenuClose.Pan = num2; - sound = this._soundInstanceMenuClose; - } - else if (type == 12) - { - if (Main.hasFocus) - { - if (this._soundInstanceMenuTick != null) - this._soundInstanceMenuTick.Stop(); - this._soundInstanceMenuTick = this._soundMenuTick.Value.CreateInstance(); - this._soundInstanceMenuTick.Volume = num7; - this._soundInstanceMenuTick.Pan = num2; - sound = this._soundInstanceMenuTick; - } - } - else if (type == 13) - { - if (this._soundInstanceShatter != null) - this._soundInstanceShatter.Stop(); - this._soundInstanceShatter = this._soundShatter.Value.CreateInstance(); - this._soundInstanceShatter.Volume = num7; - this._soundInstanceShatter.Pan = num2; - sound = this._soundInstanceShatter; - } - else if (type == 14) - { - switch (Style) - { - case 489: - case 586: - int index7 = Main.rand.Next(21, 24); - this._soundInstanceZombie[index7] = this._soundZombie[index7].Value.CreateInstance(); - this._soundInstanceZombie[index7].Volume = num7 * 0.4f; - this._soundInstanceZombie[index7].Pan = num2; - sound = this._soundInstanceZombie[index7]; - break; - case 542: - int index8 = 7; - this._soundInstanceZombie[index8] = this._soundZombie[index8].Value.CreateInstance(); - this._soundInstanceZombie[index8].Volume = num7 * 0.4f; - this._soundInstanceZombie[index8].Pan = num2; - sound = this._soundInstanceZombie[index8]; - break; - default: - int index9 = Main.rand.Next(3); - this._soundInstanceZombie[index9] = this._soundZombie[index9].Value.CreateInstance(); - this._soundInstanceZombie[index9].Volume = num7 * 0.4f; - this._soundInstanceZombie[index9].Pan = num2; - sound = this._soundInstanceZombie[index9]; - break; - } - } - else if (type == 15) - { - float num9 = 1f; - if (index1 == 4) - { - index1 = 1; - num9 = 0.25f; - } - if (this._soundInstanceRoar[index1] == null || this._soundInstanceRoar[index1].State == SoundState.Stopped) - { - this._soundInstanceRoar[index1] = this._soundRoar[index1].Value.CreateInstance(); - this._soundInstanceRoar[index1].Volume = num7 * num9; - this._soundInstanceRoar[index1].Pan = num2; - sound = this._soundInstanceRoar[index1]; - } - } - else if (type == 16) - { - if (this._soundInstanceDoubleJump != null) - this._soundInstanceDoubleJump.Stop(); - this._soundInstanceDoubleJump = this._soundDoubleJump.Value.CreateInstance(); - this._soundInstanceDoubleJump.Volume = num7; - this._soundInstanceDoubleJump.Pan = num2; - this._soundInstanceDoubleJump.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceDoubleJump; - } - else if (type == 17) - { - if (this._soundInstanceRun != null) - this._soundInstanceRun.Stop(); - this._soundInstanceRun = this._soundRun.Value.CreateInstance(); - this._soundInstanceRun.Volume = num7; - this._soundInstanceRun.Pan = num2; - this._soundInstanceRun.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceRun; - } - else if (type == 18) - { - this._soundInstanceCoins = this._soundCoins.Value.CreateInstance(); - this._soundInstanceCoins.Volume = num7; - this._soundInstanceCoins.Pan = num2; - sound = this._soundInstanceCoins; - } - else if (type == 19) - { - if (this._soundInstanceSplash[index1] == null || this._soundInstanceSplash[index1].State == SoundState.Stopped) - { - this._soundInstanceSplash[index1] = this._soundSplash[index1].Value.CreateInstance(); - this._soundInstanceSplash[index1].Volume = num7; - this._soundInstanceSplash[index1].Pan = num2; - this._soundInstanceSplash[index1].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceSplash[index1]; - } - } - else if (type == 20) - { - int index10 = Main.rand.Next(3); - if (this._soundInstanceFemaleHit[index10] != null) - this._soundInstanceFemaleHit[index10].Stop(); - this._soundInstanceFemaleHit[index10] = this._soundFemaleHit[index10].Value.CreateInstance(); - this._soundInstanceFemaleHit[index10].Volume = num7; - this._soundInstanceFemaleHit[index10].Pan = num2; - sound = this._soundInstanceFemaleHit[index10]; - } - else if (type == 21) - { - int index11 = Main.rand.Next(3); - if (this._soundInstanceTink[index11] != null) - this._soundInstanceTink[index11].Stop(); - this._soundInstanceTink[index11] = this._soundTink[index11].Value.CreateInstance(); - this._soundInstanceTink[index11].Volume = num7; - this._soundInstanceTink[index11].Pan = num2; - sound = this._soundInstanceTink[index11]; - } - else if (type == 22) - { - if (this._soundInstanceUnlock != null) - this._soundInstanceUnlock.Stop(); - this._soundInstanceUnlock = this._soundUnlock.Value.CreateInstance(); - this._soundInstanceUnlock.Volume = num7; - this._soundInstanceUnlock.Pan = num2; - sound = this._soundInstanceUnlock; - } - else if (type == 23) - { - if (this._soundInstanceDrown != null) - this._soundInstanceDrown.Stop(); - this._soundInstanceDrown = this._soundDrown.Value.CreateInstance(); - this._soundInstanceDrown.Volume = num7; - this._soundInstanceDrown.Pan = num2; - sound = this._soundInstanceDrown; - } - else if (type == 24) - { - this._soundInstanceChat = this._soundChat.Value.CreateInstance(); - this._soundInstanceChat.Volume = num7; - this._soundInstanceChat.Pan = num2; - sound = this._soundInstanceChat; - } - else if (type == 25) - { - this._soundInstanceMaxMana = this._soundMaxMana.Value.CreateInstance(); - this._soundInstanceMaxMana.Volume = num7; - this._soundInstanceMaxMana.Pan = num2; - sound = this._soundInstanceMaxMana; - } - else if (type == 26) - { - int index12 = Main.rand.Next(3, 5); - this._soundInstanceZombie[index12] = this._soundZombie[index12].Value.CreateInstance(); - this._soundInstanceZombie[index12].Volume = num7 * 0.9f; - this._soundInstanceZombie[index12].Pan = num2; - this._soundInstanceZombie[index12].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceZombie[index12]; - } - else if (type == 27) - { - if (this._soundInstancePixie != null && this._soundInstancePixie.State == SoundState.Playing) - { - this._soundInstancePixie.Volume = num7; - this._soundInstancePixie.Pan = num2; - this._soundInstancePixie.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - return (SoundEffectInstance) null; - } - if (this._soundInstancePixie != null) - this._soundInstancePixie.Stop(); - this._soundInstancePixie = this._soundPixie.Value.CreateInstance(); - this._soundInstancePixie.Volume = num7; - this._soundInstancePixie.Pan = num2; - this._soundInstancePixie.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstancePixie; - } - else if (type == 28) - { - if (this._soundInstanceMech[index1] != null && this._soundInstanceMech[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceMech[index1] = this._soundMech[index1].Value.CreateInstance(); - this._soundInstanceMech[index1].Volume = num7; - this._soundInstanceMech[index1].Pan = num2; - this._soundInstanceMech[index1].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceMech[index1]; - } - else if (type == 29) - { - if (index1 >= 24 && index1 <= 87) - num7 *= 0.5f; - if (index1 >= 88 && index1 <= 91) - num7 *= 0.7f; - if (index1 >= 93 && index1 <= 99) - num7 *= 0.4f; - if (index1 == 92) - num7 *= 0.5f; - if (index1 == 103) - num7 *= 0.4f; - if (index1 == 104) - num7 *= 0.55f; - if (index1 == 100 || index1 == 101) - num7 *= 0.25f; - if (index1 == 102) - num7 *= 0.4f; - if (this._soundInstanceZombie[index1] != null && this._soundInstanceZombie[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceZombie[index1] = this._soundZombie[index1].Value.CreateInstance(); - this._soundInstanceZombie[index1].Volume = num7; - this._soundInstanceZombie[index1].Pan = num2; - this._soundInstanceZombie[index1].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceZombie[index1]; - } - else if (type == 44) - { - int index13 = Main.rand.Next(106, 109); - this._soundInstanceZombie[index13] = this._soundZombie[index13].Value.CreateInstance(); - this._soundInstanceZombie[index13].Volume = num7 * 0.2f; - this._soundInstanceZombie[index13].Pan = num2; - this._soundInstanceZombie[index13].Pitch = (float) Main.rand.Next(-70, 1) * 0.01f; - sound = this._soundInstanceZombie[index13]; - } - else if (type == 45) - { - int index14 = 109; - if (this._soundInstanceZombie[index14] != null && this._soundInstanceZombie[index14].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceZombie[index14] = this._soundZombie[index14].Value.CreateInstance(); - this._soundInstanceZombie[index14].Volume = num7 * 0.3f; - this._soundInstanceZombie[index14].Pan = num2; - this._soundInstanceZombie[index14].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceZombie[index14]; - } - else if (type == 46) - { - if (this._soundInstanceZombie[110] != null && this._soundInstanceZombie[110].State == SoundState.Playing || this._soundInstanceZombie[111] != null && this._soundInstanceZombie[111].State == SoundState.Playing) - return (SoundEffectInstance) null; - int index15 = Main.rand.Next(110, 112); - if (Main.rand.Next(300) == 0) - index15 = Main.rand.Next(3) != 0 ? (Main.rand.Next(2) != 0 ? 112 : 113) : 114; - this._soundInstanceZombie[index15] = this._soundZombie[index15].Value.CreateInstance(); - this._soundInstanceZombie[index15].Volume = num7 * 0.9f; - this._soundInstanceZombie[index15].Pan = num2; - this._soundInstanceZombie[index15].Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceZombie[index15]; - } - else if (type == 45) - { - int index16 = 109; - this._soundInstanceZombie[index16] = this._soundZombie[index16].Value.CreateInstance(); - this._soundInstanceZombie[index16].Volume = num7 * 0.2f; - this._soundInstanceZombie[index16].Pan = num2; - this._soundInstanceZombie[index16].Pitch = (float) Main.rand.Next(-70, 1) * 0.01f; - sound = this._soundInstanceZombie[index16]; - } - else if (type == 30) - { - int index17 = Main.rand.Next(10, 12); - if (Main.rand.Next(300) == 0) - { - index17 = 12; - if (this._soundInstanceZombie[index17] != null && this._soundInstanceZombie[index17].State == SoundState.Playing) - return (SoundEffectInstance) null; - } - this._soundInstanceZombie[index17] = this._soundZombie[index17].Value.CreateInstance(); - this._soundInstanceZombie[index17].Volume = num7 * 0.75f; - this._soundInstanceZombie[index17].Pan = num2; - this._soundInstanceZombie[index17].Pitch = index17 == 12 ? (float) Main.rand.Next(-40, 21) * 0.01f : (float) Main.rand.Next(-70, 1) * 0.01f; - sound = this._soundInstanceZombie[index17]; - } - else if (type == 31) - { - int index18 = 13; - this._soundInstanceZombie[index18] = this._soundZombie[index18].Value.CreateInstance(); - this._soundInstanceZombie[index18].Volume = num7 * 0.35f; - this._soundInstanceZombie[index18].Pan = num2; - this._soundInstanceZombie[index18].Pitch = (float) Main.rand.Next(-40, 21) * 0.01f; - sound = this._soundInstanceZombie[index18]; - } - else if (type == 32) - { - if (this._soundInstanceZombie[index1] != null && this._soundInstanceZombie[index1].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceZombie[index1] = this._soundZombie[index1].Value.CreateInstance(); - this._soundInstanceZombie[index1].Volume = num7 * 0.15f; - this._soundInstanceZombie[index1].Pan = num2; - this._soundInstanceZombie[index1].Pitch = (float) Main.rand.Next(-70, 26) * 0.01f; - sound = this._soundInstanceZombie[index1]; - } - else if (type == 33) - { - int index19 = 15; - if (this._soundInstanceZombie[index19] != null && this._soundInstanceZombie[index19].State == SoundState.Playing) - return (SoundEffectInstance) null; - this._soundInstanceZombie[index19] = this._soundZombie[index19].Value.CreateInstance(); - this._soundInstanceZombie[index19].Volume = num7 * 0.2f; - this._soundInstanceZombie[index19].Pan = num2; - this._soundInstanceZombie[index19].Pitch = (float) Main.rand.Next(-10, 31) * 0.01f; - sound = this._soundInstanceZombie[index19]; - } - else if (type >= 47 && type <= 52) - { - int index20 = 133 + type - 47; - for (int index21 = 133; index21 <= 138; ++index21) - { - if (this._soundInstanceItem[index21] != null && this._soundInstanceItem[index21].State == SoundState.Playing) - this._soundInstanceItem[index21].Stop(); - } - this._soundInstanceItem[index20] = this._soundItem[index20].Value.CreateInstance(); - this._soundInstanceItem[index20].Volume = num7 * 0.45f; - this._soundInstanceItem[index20].Pan = num2; - sound = this._soundInstanceItem[index20]; - } - else if (type >= 53 && type <= 62) - { - int index22 = 139 + type - 53; - if (this._soundInstanceItem[index22] != null && this._soundInstanceItem[index22].State == SoundState.Playing) - this._soundInstanceItem[index22].Stop(); - this._soundInstanceItem[index22] = this._soundItem[index22].Value.CreateInstance(); - this._soundInstanceItem[index22].Volume = num7 * 0.7f; - this._soundInstanceItem[index22].Pan = num2; - sound = this._soundInstanceItem[index22]; - } - else - { - switch (type) - { - case 34: - float num10 = (float) index1 / 50f; - if ((double) num10 > 1.0) - num10 = 1f; - float num11 = num7 * num10 * 0.2f; - if ((double) num11 <= 0.0 || x == -1 || y == -1) - { - if (this._soundInstanceLiquid[0] != null && this._soundInstanceLiquid[0].State == SoundState.Playing) - { - this._soundInstanceLiquid[0].Stop(); - break; - } - break; - } - if (this._soundInstanceLiquid[0] != null && this._soundInstanceLiquid[0].State == SoundState.Playing) - { - this._soundInstanceLiquid[0].Volume = num11; - this._soundInstanceLiquid[0].Pan = num2; - this._soundInstanceLiquid[0].Pitch = -0.2f; - break; - } - this._soundInstanceLiquid[0] = this._soundLiquid[0].Value.CreateInstance(); - this._soundInstanceLiquid[0].Volume = num11; - this._soundInstanceLiquid[0].Pan = num2; - sound = this._soundInstanceLiquid[0]; - break; - case 35: - float num12 = (float) index1 / 50f; - if ((double) num12 > 1.0) - num12 = 1f; - float num13 = num7 * num12 * 0.65f; - if ((double) num13 <= 0.0 || x == -1 || y == -1) - { - if (this._soundInstanceLiquid[1] != null && this._soundInstanceLiquid[1].State == SoundState.Playing) - { - this._soundInstanceLiquid[1].Stop(); - break; - } - break; - } - if (this._soundInstanceLiquid[1] != null && this._soundInstanceLiquid[1].State == SoundState.Playing) - { - this._soundInstanceLiquid[1].Volume = num13; - this._soundInstanceLiquid[1].Pan = num2; - this._soundInstanceLiquid[1].Pitch = -0.0f; - break; - } - this._soundInstanceLiquid[1] = this._soundLiquid[1].Value.CreateInstance(); - this._soundInstanceLiquid[1].Volume = num13; - this._soundInstanceLiquid[1].Pan = num2; - sound = this._soundInstanceLiquid[1]; - break; - case 36: - int index23 = Style; - if (Style == -1) - index23 = 0; - this._soundInstanceRoar[index23] = this._soundRoar[index23].Value.CreateInstance(); - this._soundInstanceRoar[index23].Volume = num7; - this._soundInstanceRoar[index23].Pan = num2; - if (Style == -1) - this._soundInstanceRoar[index23].Pitch += 0.6f; - sound = this._soundInstanceRoar[index23]; - break; - case 37: - int index24 = Main.rand.Next(57, 59); - float num14 = num7 * ((float) Style * 0.05f); - this._soundInstanceItem[index24] = this._soundItem[index24].Value.CreateInstance(); - this._soundInstanceItem[index24].Volume = num14; - this._soundInstanceItem[index24].Pan = num2; - this._soundInstanceItem[index24].Pitch = (float) Main.rand.Next(-40, 41) * 0.01f; - sound = this._soundInstanceItem[index24]; - break; - case 38: - int index25 = Main.rand.Next(5); - this._soundInstanceCoin[index25] = this._soundCoin[index25].Value.CreateInstance(); - this._soundInstanceCoin[index25].Volume = num7; - this._soundInstanceCoin[index25].Pan = num2; - this._soundInstanceCoin[index25].Pitch = (float) Main.rand.Next(-40, 41) * (1f / 500f); - sound = this._soundInstanceCoin[index25]; - break; - case 39: - int index26 = Style; - this._soundInstanceDrip[index26] = this._soundDrip[index26].Value.CreateInstance(); - this._soundInstanceDrip[index26].Volume = num7 * 0.5f; - this._soundInstanceDrip[index26].Pan = num2; - this._soundInstanceDrip[index26].Pitch = (float) Main.rand.Next(-30, 31) * 0.01f; - sound = this._soundInstanceDrip[index26]; - break; - case 40: - if (this._soundInstanceCamera != null) - this._soundInstanceCamera.Stop(); - this._soundInstanceCamera = this._soundCamera.Value.CreateInstance(); - this._soundInstanceCamera.Volume = num7; - this._soundInstanceCamera.Pan = num2; - sound = this._soundInstanceCamera; - break; - case 41: - this._soundInstanceMoonlordCry = this._soundNpcKilled[10].Value.CreateInstance(); - this._soundInstanceMoonlordCry.Volume = (float) (1.0 / (1.0 + (double) (new Vector2((float) x, (float) y) - Main.player[Main.myPlayer].position).Length())); - this._soundInstanceMoonlordCry.Pan = num2; - this._soundInstanceMoonlordCry.Pitch = (float) Main.rand.Next(-10, 11) * 0.01f; - sound = this._soundInstanceMoonlordCry; - break; - case 42: - sound = this._trackableSounds[index1].Value.CreateInstance(); - sound.Volume = num7; - sound.Pan = num2; - this._trackableSoundInstances[index1] = sound; - break; - case 65: - if (this._soundInstanceZombie[115] != null && this._soundInstanceZombie[115].State == SoundState.Playing || this._soundInstanceZombie[116] != null && this._soundInstanceZombie[116].State == SoundState.Playing || this._soundInstanceZombie[117] != null && this._soundInstanceZombie[117].State == SoundState.Playing) - return (SoundEffectInstance) null; - int index27 = Main.rand.Next(115, 118); - this._soundInstanceZombie[index27] = this._soundZombie[index27].Value.CreateInstance(); - this._soundInstanceZombie[index27].Volume = num7 * 0.5f; - this._soundInstanceZombie[index27].Pan = num2; - sound = this._soundInstanceZombie[index27]; - break; - } - } - if (sound != null) - { - sound.Pitch += pitchOffset; - sound.Volume *= volumeScale; - sound.Play(); - SoundInstanceGarbageCollector.Track(sound); - } - return sound; - } - } - catch - { - } - return (SoundEffectInstance) null; - } - - public SoundEffect GetTrackableSoundByStyleId(int id) => this._trackableSounds[id].Value; - - public void StopAmbientSounds() - { - for (int index = 0; index < this._soundInstanceLiquid.Length; ++index) - { - if (this._soundInstanceLiquid[index] != null) - this._soundInstanceLiquid[index].Stop(); - } - } - } -} diff --git a/Audio/LegacySoundStyle.cs b/Audio/LegacySoundStyle.cs deleted file mode 100644 index e304625..0000000 --- a/Audio/LegacySoundStyle.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.LegacySoundStyle -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework.Audio; -using Terraria.Utilities; - -namespace Terraria.Audio -{ - public class LegacySoundStyle : SoundStyle - { - private static readonly UnifiedRandom Random = new UnifiedRandom(); - private readonly int _style; - public readonly int Variations; - public readonly int SoundId; - - public int Style => this.Variations != 1 ? LegacySoundStyle.Random.Next(this._style, this._style + this.Variations) : this._style; - - public override bool IsTrackable => this.SoundId == 42; - - public LegacySoundStyle(int soundId, int style, SoundType type = SoundType.Sound) - : base(type) - { - this._style = style; - this.Variations = 1; - this.SoundId = soundId; - } - - public LegacySoundStyle(int soundId, int style, int variations, SoundType type = SoundType.Sound) - : base(type) - { - this._style = style; - this.Variations = variations; - this.SoundId = soundId; - } - - private LegacySoundStyle( - int soundId, - int style, - int variations, - SoundType type, - float volume, - float pitchVariance) - : base(volume, pitchVariance, type) - { - this._style = style; - this.Variations = variations; - this.SoundId = soundId; - } - - public LegacySoundStyle WithVolume(float volume) => new LegacySoundStyle(this.SoundId, this._style, this.Variations, this.Type, volume, this.PitchVariance); - - public LegacySoundStyle WithPitchVariance(float pitchVariance) => new LegacySoundStyle(this.SoundId, this._style, this.Variations, this.Type, this.Volume, pitchVariance); - - public LegacySoundStyle AsMusic() => new LegacySoundStyle(this.SoundId, this._style, this.Variations, SoundType.Music, this.Volume, this.PitchVariance); - - public LegacySoundStyle AsAmbient() => new LegacySoundStyle(this.SoundId, this._style, this.Variations, SoundType.Ambient, this.Volume, this.PitchVariance); - - public LegacySoundStyle AsSound() => new LegacySoundStyle(this.SoundId, this._style, this.Variations, SoundType.Sound, this.Volume, this.PitchVariance); - - public bool Includes(int soundId, int style) => this.SoundId == soundId && style >= this._style && style < this._style + this.Variations; - - public override SoundEffect GetRandomSound() => this.IsTrackable ? SoundEngine.GetTrackableSoundByStyleId(this.Style) : (SoundEffect) null; - } -} diff --git a/Audio/SoundEngine.cs b/Audio/SoundEngine.cs deleted file mode 100644 index 77c0e8b..0000000 --- a/Audio/SoundEngine.cs +++ /dev/null @@ -1,287 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.SoundEngine -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using ReLogic.Utilities; -using System; -using System.IO; - -namespace Terraria.Audio -{ - public static class SoundEngine - { - private static LegacySoundPlayer _legacyPlayer; - private static SoundPlayer _player; - private static bool _areSoundsPaused; - - public static bool IsAudioSupported { get; private set; } - - public static void Initialize() => SoundEngine.IsAudioSupported = SoundEngine.TestAudioSupport(); - - public static void Load(IServiceProvider services) - { - if (!SoundEngine.IsAudioSupported) - return; - SoundEngine._legacyPlayer = new LegacySoundPlayer(services); - SoundEngine._player = new SoundPlayer(); - } - - public static void Update() - { - if (!SoundEngine.IsAudioSupported) - return; - SoundInstanceGarbageCollector.Update(); - bool flag = (!Main.hasFocus || Main.gamePaused) && Main.netMode == 0; - if (!SoundEngine._areSoundsPaused & flag) - SoundEngine._player.PauseAll(); - else if (SoundEngine._areSoundsPaused && !flag) - SoundEngine._player.ResumeAll(); - SoundEngine._areSoundsPaused = flag; - SoundEngine._player.Update(); - } - - public static void PlaySound(int type, Vector2 position, int style = 1) => SoundEngine.PlaySound(type, (int) position.X, (int) position.Y, style); - - public static SoundEffectInstance PlaySound( - LegacySoundStyle type, - Vector2 position) - { - return SoundEngine.PlaySound(type, (int) position.X, (int) position.Y); - } - - public static SoundEffectInstance PlaySound( - LegacySoundStyle type, - int x = -1, - int y = -1) - { - return type == null ? (SoundEffectInstance) null : SoundEngine.PlaySound(type.SoundId, x, y, type.Style, type.Volume, type.GetRandomPitch()); - } - - public static SoundEffectInstance PlaySound( - int type, - int x = -1, - int y = -1, - int Style = 1, - float volumeScale = 1f, - float pitchOffset = 0.0f) - { - return !SoundEngine.IsAudioSupported ? (SoundEffectInstance) null : SoundEngine._legacyPlayer.PlaySound(type, x, y, Style, volumeScale, pitchOffset); - } - - public static ActiveSound GetActiveSound(SlotId id) => !SoundEngine.IsAudioSupported ? (ActiveSound) null : SoundEngine._player.GetActiveSound(id); - - public static SlotId PlayTrackedSound(SoundStyle style, Vector2 position) => !SoundEngine.IsAudioSupported ? (SlotId) SlotId.Invalid : SoundEngine._player.Play(style, position); - - public static SlotId PlayTrackedSound(SoundStyle style) => !SoundEngine.IsAudioSupported ? (SlotId) SlotId.Invalid : SoundEngine._player.Play(style); - - public static void StopTrackedSounds() - { - if (!SoundEngine.IsAudioSupported) - return; - SoundEngine._player.StopAll(); - } - - public static SoundEffect GetTrackableSoundByStyleId(int id) => !SoundEngine.IsAudioSupported ? (SoundEffect) null : SoundEngine._legacyPlayer.GetTrackableSoundByStyleId(id); - - public static void StopAmbientSounds() - { - if (!SoundEngine.IsAudioSupported || SoundEngine._legacyPlayer == null) - return; - SoundEngine._legacyPlayer.StopAmbientSounds(); - } - - public static ActiveSound FindActiveSound(SoundStyle style) => !SoundEngine.IsAudioSupported ? (ActiveSound) null : SoundEngine._player.FindActiveSound(style); - - private static bool TestAudioSupport() - { - byte[] buffer = new byte[166] - { - (byte) 82, - (byte) 73, - (byte) 70, - (byte) 70, - (byte) 158, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 87, - (byte) 65, - (byte) 86, - (byte) 69, - (byte) 102, - (byte) 109, - (byte) 116, - (byte) 32, - (byte) 16, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 1, - (byte) 0, - (byte) 1, - (byte) 0, - (byte) 68, - (byte) 172, - (byte) 0, - (byte) 0, - (byte) 136, - (byte) 88, - (byte) 1, - (byte) 0, - (byte) 2, - (byte) 0, - (byte) 16, - (byte) 0, - (byte) 76, - (byte) 73, - (byte) 83, - (byte) 84, - (byte) 26, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 73, - (byte) 78, - (byte) 70, - (byte) 79, - (byte) 73, - (byte) 83, - (byte) 70, - (byte) 84, - (byte) 14, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 76, - (byte) 97, - (byte) 118, - (byte) 102, - (byte) 53, - (byte) 54, - (byte) 46, - (byte) 52, - (byte) 48, - (byte) 46, - (byte) 49, - (byte) 48, - (byte) 49, - (byte) 0, - (byte) 100, - (byte) 97, - (byte) 116, - (byte) 97, - (byte) 88, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 0, - (byte) 126, - (byte) 4, - (byte) 240, - (byte) 8, - (byte) 64, - (byte) 13, - (byte) 95, - (byte) 17, - (byte) 67, - (byte) 21, - (byte) 217, - (byte) 24, - (byte) 23, - (byte) 28, - (byte) 240, - (byte) 30, - (byte) 94, - (byte) 33, - (byte) 84, - (byte) 35, - (byte) 208, - (byte) 36, - (byte) 204, - (byte) 37, - (byte) 71, - (byte) 38, - (byte) 64, - (byte) 38, - (byte) 183, - (byte) 37, - (byte) 180, - (byte) 36, - (byte) 58, - (byte) 35, - (byte) 79, - (byte) 33, - (byte) 1, - (byte) 31, - (byte) 86, - (byte) 28, - (byte) 92, - (byte) 25, - (byte) 37, - (byte) 22, - (byte) 185, - (byte) 18, - (byte) 42, - (byte) 15, - (byte) 134, - (byte) 11, - (byte) 222, - (byte) 7, - (byte) 68, - (byte) 4, - (byte) 196, - (byte) 0, - (byte) 112, - (byte) 253, - (byte) 86, - (byte) 250, - (byte) 132, - (byte) 247, - (byte) 6, - (byte) 245, - (byte) 230, - (byte) 242, - (byte) 47, - (byte) 241, - (byte) 232, - (byte) 239, - (byte) 25, - (byte) 239, - (byte) 194, - (byte) 238, - (byte) 231, - (byte) 238, - (byte) 139, - (byte) 239, - (byte) 169, - (byte) 240, - (byte) 61, - (byte) 242, - (byte) 67, - (byte) 244, - (byte) 180, - (byte) 246 - }; - try - { - using (MemoryStream memoryStream = new MemoryStream(buffer)) - SoundEffect.FromStream((Stream) memoryStream); - } - catch (NoAudioHardwareException ex) - { - Console.WriteLine("No audio hardware found. Disabling all audio."); - return false; - } - catch - { - return false; - } - return true; - } - } -} diff --git a/Audio/SoundInstanceGarbageCollector.cs b/Audio/SoundInstanceGarbageCollector.cs deleted file mode 100644 index 92d0efe..0000000 --- a/Audio/SoundInstanceGarbageCollector.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.SoundInstanceGarbageCollector -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework.Audio; -using System.Collections.Generic; - -namespace Terraria.Audio -{ - public static class SoundInstanceGarbageCollector - { - private static readonly List _activeSounds = new List(128); - - public static void Track(SoundEffectInstance sound) - { - } - - public static void Update() - { - for (int index = 0; index < SoundInstanceGarbageCollector._activeSounds.Count; ++index) - { - if (SoundInstanceGarbageCollector._activeSounds[index] == null) - { - SoundInstanceGarbageCollector._activeSounds.RemoveAt(index); - --index; - } - else if (SoundInstanceGarbageCollector._activeSounds[index].State == SoundState.Stopped) - { - SoundInstanceGarbageCollector._activeSounds[index].Dispose(); - SoundInstanceGarbageCollector._activeSounds.RemoveAt(index); - --index; - } - } - } - } -} diff --git a/Audio/SoundPlayer.cs b/Audio/SoundPlayer.cs deleted file mode 100644 index 0e79417..0000000 --- a/Audio/SoundPlayer.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.SoundPlayer -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework; -using ReLogic.Utilities; -using System.Collections.Generic; - -namespace Terraria.Audio -{ - public class SoundPlayer - { - private readonly SlotVector _trackedSounds = new SlotVector(4096); - - public SlotId Play(SoundStyle style, Vector2 position) - { - if (Main.dedServ || style == null || !style.IsTrackable) - return (SlotId) SlotId.Invalid; - return (double) Vector2.DistanceSquared(Main.screenPosition + new Vector2((float) (Main.screenWidth / 2), (float) (Main.screenHeight / 2)), position) > 100000000.0 ? (SlotId) SlotId.Invalid : this._trackedSounds.Add(new ActiveSound(style, position)); - } - - public SlotId Play(SoundStyle style) => Main.dedServ || style == null || !style.IsTrackable ? (SlotId) SlotId.Invalid : this._trackedSounds.Add(new ActiveSound(style)); - - public ActiveSound GetActiveSound(SlotId id) => !this._trackedSounds.Has(id) ? (ActiveSound) null : this._trackedSounds[id]; - - public void PauseAll() - { - foreach (SlotVector.ItemPair trackedSound in (IEnumerable.ItemPair>) this._trackedSounds) - ((ActiveSound) trackedSound.Value).Pause(); - } - - public void ResumeAll() - { - foreach (SlotVector.ItemPair trackedSound in (IEnumerable.ItemPair>) this._trackedSounds) - ((ActiveSound) trackedSound.Value).Resume(); - } - - public void StopAll() - { - foreach (SlotVector.ItemPair trackedSound in (IEnumerable.ItemPair>) this._trackedSounds) - ((ActiveSound) trackedSound.Value).Stop(); - this._trackedSounds.Clear(); - } - - public void Update() - { - foreach (SlotVector.ItemPair trackedSound in (IEnumerable.ItemPair>) this._trackedSounds) - { - try - { - ((ActiveSound) trackedSound.Value).Update(); - if (!((ActiveSound) trackedSound.Value).IsPlaying) - this._trackedSounds.Remove((SlotId) trackedSound.Id); - } - catch - { - this._trackedSounds.Remove((SlotId) trackedSound.Id); - } - } - } - - public ActiveSound FindActiveSound(SoundStyle style) - { - foreach (SlotVector.ItemPair trackedSound in (IEnumerable.ItemPair>) this._trackedSounds) - { - if (((ActiveSound) trackedSound.Value).Style == style) - return (ActiveSound) trackedSound.Value; - } - return (ActiveSound) null; - } - } -} diff --git a/Audio/SoundStyle.cs b/Audio/SoundStyle.cs deleted file mode 100644 index 06e08ac..0000000 --- a/Audio/SoundStyle.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.SoundStyle -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -using Microsoft.Xna.Framework.Audio; -using Terraria.Utilities; - -namespace Terraria.Audio -{ - public abstract class SoundStyle - { - private static UnifiedRandom _random = new UnifiedRandom(); - private float _volume; - private float _pitchVariance; - private SoundType _type; - - public float Volume => this._volume; - - public float PitchVariance => this._pitchVariance; - - public SoundType Type => this._type; - - public abstract bool IsTrackable { get; } - - public SoundStyle(float volume, float pitchVariance, SoundType type = SoundType.Sound) - { - this._volume = volume; - this._pitchVariance = pitchVariance; - this._type = type; - } - - public SoundStyle(SoundType type = SoundType.Sound) - { - this._volume = 1f; - this._pitchVariance = 0.0f; - this._type = type; - } - - public float GetRandomPitch() => (float) ((double) SoundStyle._random.NextFloat() * (double) this.PitchVariance - (double) this.PitchVariance * 0.5); - - public abstract SoundEffect GetRandomSound(); - } -} diff --git a/Audio/SoundType.cs b/Audio/SoundType.cs deleted file mode 100644 index 3b1107f..0000000 --- a/Audio/SoundType.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Decompiled with JetBrains decompiler -// Type: Terraria.Audio.SoundType -// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null -// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83 -// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe - -namespace Terraria.Audio -{ - public enum SoundType - { - Sound, - Ambient, - Music, - } -}