Terraria 1.3.5.3 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-27 18:03:19 -04:00
commit 4b21dac4b6
503 changed files with 409032 additions and 0 deletions

101
Audio/ActiveSound.cs Normal file
View file

@ -0,0 +1,101 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Audio.ActiveSound
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// 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
{
private SoundEffectInstance _sound;
public readonly bool IsGlobal;
public Vector2 Position;
public float Volume;
private SoundStyle _style;
public SoundEffectInstance Sound => this._sound;
public SoundStyle Style => this._style;
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();
Main.PlaySoundInstance(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);
}
}
}

41
Audio/CustomSoundStyle.cs Normal file
View file

@ -0,0 +1,41 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Audio.CustomSoundStyle
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// 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 UnifiedRandom _random = new UnifiedRandom();
private 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)];
}
}

71
Audio/LegacySoundStyle.cs Normal file
View file

@ -0,0 +1,71 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Audio.LegacySoundStyle
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// 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 UnifiedRandom _random = new UnifiedRandom();
private int _style;
private int _styleVariations;
private int _soundId;
public int Style => this._styleVariations != 1 ? LegacySoundStyle._random.Next(this._style, this._style + this._styleVariations) : this._style;
public int Variations => this._styleVariations;
public int SoundId => this._soundId;
public override bool IsTrackable => this._soundId == 42;
public LegacySoundStyle(int soundId, int style, SoundType type = SoundType.Sound)
: base(type)
{
this._style = style;
this._styleVariations = 1;
this._soundId = soundId;
}
public LegacySoundStyle(int soundId, int style, int variations, SoundType type = SoundType.Sound)
: base(type)
{
this._style = style;
this._styleVariations = 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._styleVariations = variations;
this._soundId = soundId;
}
public LegacySoundStyle WithVolume(float volume) => new LegacySoundStyle(this._soundId, this._style, this._styleVariations, this.Type, volume, this.PitchVariance);
public LegacySoundStyle WithPitchVariance(float pitchVariance) => new LegacySoundStyle(this._soundId, this._style, this._styleVariations, this.Type, this.Volume, pitchVariance);
public LegacySoundStyle AsMusic() => new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Music, this.Volume, this.PitchVariance);
public LegacySoundStyle AsAmbient() => new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Ambient, this.Volume, this.PitchVariance);
public LegacySoundStyle AsSound() => new LegacySoundStyle(this._soundId, this._style, this._styleVariations, SoundType.Sound, this.Volume, this.PitchVariance);
public bool Includes(int soundId, int style) => this._soundId == soundId && style >= this._style && style < this._style + this._styleVariations;
public override SoundEffect GetRandomSound() => this.IsTrackable ? Main.trackableSounds[this.Style] : (SoundEffect) null;
}
}

45
Audio/SoundStyle.cs Normal file
View file

@ -0,0 +1,45 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Audio.SoundStyle
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// 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();
}
}

15
Audio/SoundType.cs Normal file
View file

@ -0,0 +1,15 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Audio.SoundType
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria.Audio
{
public enum SoundType
{
Sound,
Ambient,
Music,
}
}