Decompiled source of Shadow the Hedgehog v1.0.1

Shadow.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using MonoMod.RuntimeDetour.HookGen;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Shadow;

[BepInPlugin("com.Dannyduartemgs.Shadow", "Shadow", "1.0.0")]
public class ShadowPlugin : BaseUnityPlugin
{
	private class FieldException : Exception
	{
		public FieldException(string message, Exception innerException)
			: base(message, innerException)
		{
		}
	}

	private static AssetBundle assetBundle;

	private static readonly List<Material> materialsWithRoRShader = new List<Material>();

	internal static ShadowPlugin Instance { get; private set; }

	internal static ManualLogSource InstanceLogger
	{
		get
		{
			ShadowPlugin instance = Instance;
			return (instance != null) ? ((BaseUnityPlugin)instance).Logger : null;
		}
	}

	private void Start()
	{
		Instance = this;
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Shadow.dannyduartemgsshadow"))
		{
			assetBundle = AssetBundle.LoadFromStream(stream);
		}
		((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)BodyCatalogInit);
		HookEndpointManager.Add((MethodBase)typeof(Language).GetMethod("LoadStrings"), (Delegate)new Action<Action<Language>, Language>(LanguageLoadStrings));
		ReplaceShaders();
	}

	private static void ReplaceShaders()
	{
		LoadMaterialsWithReplacedShader("RoR2/Base/Shaders/HGStandard.shader", "Assets/Resources/shadow.mat");
	}

	private static void LoadMaterialsWithReplacedShader(string shaderPath, params string[] materialPaths)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		Shader shader = Addressables.LoadAssetAsync<Shader>((object)shaderPath).WaitForCompletion();
		foreach (string text in materialPaths)
		{
			Material val = assetBundle.LoadAsset<Material>(text);
			val.shader = shader;
			materialsWithRoRShader.Add(val);
		}
	}

	private static void LanguageLoadStrings(Action<Language> orig, Language self)
	{
		orig(self);
		self.SetStringByToken("DANNYDUARTEMGS_SKIN_SHADOWSKIN_NAME", "Shadow");
	}

	private static void Nothing(Action<SkinDef> orig, SkinDef self)
	{
	}

	private static void BodyCatalogInit()
	{
		MethodInfo method = typeof(SkinDef).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic);
		HookEndpointManager.Add((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
		AddSonicTheHedgehogShadowSkinSkin();
		HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
	}

	private static void AddSonicTheHedgehogShadowSkinSkin()
	{
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		string text = "SonicTheHedgehog";
		string text2 = "ShadowSkin";
		try
		{
			GameObject val = BodyCatalog.FindBodyPrefab(text);
			if (!Object.op_Implicit((Object)(object)val))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin because \"" + text + "\" doesn't exist"));
				return;
			}
			ModelLocator component = val.GetComponent<ModelLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelLocator\" component"));
				return;
			}
			GameObject gameObject = ((Component)component.modelTransform).gameObject;
			ModelSkinController skinController = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<ModelSkinController>() : null);
			if (!Object.op_Implicit((Object)(object)skinController))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"ModelSkinController\" component"));
				return;
			}
			Renderer[] renderers = gameObject.GetComponentsInChildren<Renderer>(true);
			SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
			TryCatchThrow("Icon", delegate
			{
				skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\Shadow\\Icons\\ShadowSkinIcon.png");
			});
			((Object)skin).name = text2;
			skin.nameToken = "DANNYDUARTEMGS_SKIN_SHADOWSKIN_NAME";
			skin.rootObject = gameObject;
			TryCatchThrow("Base Skins", delegate
			{
				skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			});
			TryCatchThrow("Unlockable Name", delegate
			{
				skin.unlockableDef = ((IEnumerable<UnlockableDef>)ContentManager.unlockableDefs).FirstOrDefault((Func<UnlockableDef, bool>)((UnlockableDef def) => def.cachedName == "Shadow"));
			});
			TryCatchThrow("Game Object Activations", delegate
			{
				skin.gameObjectActivations = Array.Empty<GameObjectActivation>();
			});
			TryCatchThrow("Renderer Infos", delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[1]
				{
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Resources/shadow.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers.First((Renderer r) => ((Object)r).name == "SonicMesh")
					}
				};
			});
			TryCatchThrow("Mesh Replacements", delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
				{
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\Shadow\\Meshes\\Shadow.mesh"),
						renderer = renderers.First((Renderer r) => ((Object)r).name == "SonicMesh")
					}
				};
			});
			TryCatchThrow("Minion Skin Replacements", delegate
			{
				skin.minionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			});
			TryCatchThrow("Projectile Ghost Replacements", delegate
			{
				skin.projectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			});
			Array.Resize(ref skinController.skins, skinController.skins.Length + 1);
			skinController.skins[skinController.skins.Length - 1] = skin;
			BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = skinController.skins;
		}
		catch (FieldException ex)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogWarning((object)("Field causing issue: " + ex.Message));
			InstanceLogger.LogError((object)ex.InnerException);
		}
		catch (Exception ex2)
		{
			InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\""));
			InstanceLogger.LogError((object)ex2);
		}
	}

	private static void TryCatchThrow(string message, Action action)
	{
		try
		{
			action?.Invoke();
		}
		catch (Exception innerException)
		{
			throw new FieldException(message, innerException);
		}
	}
}

ShadowVoiceMod.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BaseVoiceoverLib;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using ShadowVoiceMod.Components;
using ShadowVoiceMod.Modules;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShadowVoiceMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShadowVoiceMod")]
[assembly: AssemblyTitle("ShadowVoiceMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShadowVoiceMod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Dannyduartemgs.ShadowVoiceMod", "ShadowVoiceMod", "1.0.0")]
	public class ShadowVoiceMod : BaseUnityPlugin
	{
		public class NSEInfo
		{
			public NetworkSoundEventDef nse;

			public uint akId;

			public string eventName = string.Empty;

			public NSEInfo(NetworkSoundEventDef source)
			{
				nse = source;
				akId = source.akId;
				eventName = source.eventName;
			}

			private void DisableSound()
			{
				nse.akId = 0u;
				nse.eventName = string.Empty;
			}

			private void EnableSound()
			{
				nse.akId = akId;
				nse.eventName = eventName;
			}

			public void ValidateParams()
			{
				if (akId == 0)
				{
					akId = nse.akId;
				}
				if (eventName == string.Empty)
				{
					eventName = nse.eventName;
				}
				if (!enableVoicelines.Value)
				{
					DisableSound();
				}
				else
				{
					EnableSound();
				}
			}
		}

		public static ConfigEntry<bool> enableVoicelines;

		public static bool playedSeasonalVoiceline = false;

		public static AssetBundle assetBundle;

		public static List<NSEInfo> nseList = new List<NSEInfo>();

		public void Awake()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0066: Expected O, but got Unknown
			Files.PluginInfo = ((BaseUnityPlugin)this).Info;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
			new Content().Initialize();
			InitNSE();
			enableVoicelines = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Enable Voicelines"), true, new ConfigDescription("Enable Shadow voicelines when using the skin.", (AcceptableValueBase)null, Array.Empty<object>()));
			enableVoicelines.SettingChanged += EnableVoicelines_SettingChanged;
		}

		private void EnableVoicelines_SettingChanged(object sender, EventArgs e)
		{
			RefreshNSE();
		}

		private void OnLoad()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			BodyIndex val = BodyCatalog.FindBodyIndex("SonicTheHedgehog");
			SkinDef val2 = null;
			if ((int)val != -1)
			{
				SkinDef[] array = SkinCatalog.FindSkinsForBody(val);
				foreach (SkinDef val3 in array)
				{
					if (((Object)val3).name == "ShadowSkin")
					{
						val2 = val3;
						break;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val2))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"[ShadowVoiceMod] ❌ SkinDef not found. Voicelines will not work!");
				return;
			}
			VoiceoverInfo val4 = new VoiceoverInfo(typeof(ShadowVoiceoverComponent), val2, "SonicTheHedgehog");
			val4.selectActions = (LobbySelectActions)Delegate.Combine((Delegate?)(object)val4.selectActions, (Delegate?)new LobbySelectActions(OnSkinSelect));
			RefreshNSE();
		}

		private void OnSkinSelect(GameObject mannequinObject)
		{
			if (!enableVoicelines.Value)
			{
				return;
			}
			bool flag = false;
			if (!playedSeasonalVoiceline)
			{
				if (DateTime.Today.Month == 1 && DateTime.Today.Day == 1)
				{
					Util.PlaySound("Play_Shadow_NewYear", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 12 && (DateTime.Today.Day == 24 || DateTime.Today.Day == 25))
				{
					Util.PlaySound("Play_Shadow_Xmas", mannequinObject);
					flag = true;
				}
				if (flag)
				{
					playedSeasonalVoiceline = true;
				}
			}
			if (!flag)
			{
				if (Util.CheckRoll(10f, 0f, (CharacterMaster)null))
				{
					Util.PlaySound("Play_Shadow_select2", mannequinObject);
				}
				else
				{
					Util.PlaySound("Play_Shadow_select", mannequinObject);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[ShadowVoiceMod] Played skin select voiceline.");
			}
		}

		private void InitNSE()
		{
			ShadowVoiceoverComponent.nseSpecial = RegisterNSE("Play_Shadow_special");
			ShadowVoiceoverComponent.nseBlock = RegisterNSE("Play_Shadow_Blocked");
			ShadowVoiceoverComponent.nseShrineFail = RegisterNSE("Play_Shadow_fail");
			ShadowVoiceoverComponent.nseShout = RegisterNSE("Play_Shadow_secondary");
			ShadowVoiceoverComponent.nseTitle = RegisterNSE("Play_Shadow_TitleDrop");
			ShadowVoiceoverComponent.nseIntro = RegisterNSE("Play_Shadow_Intro");
			ShadowVoiceoverComponent.nseHurt = RegisterNSE("Play_Shadow_hurt");
			ShadowVoiceoverComponent.nseKanpeki = RegisterNSE("Play_Shadow_Kanpeki");
			ShadowVoiceoverComponent.nseSmart = RegisterNSE("Play_Shadow_Smart");
			ShadowVoiceoverComponent.nseLogic = RegisterNSE("Play_Shadow_Logic");
			ShadowVoiceoverComponent.nseFactor = RegisterNSE("Play_Shadow_Factor");
			ShadowVoiceoverComponent.nseThanks = RegisterNSE("Play_Shadow_Thanks");
			ShadowVoiceoverComponent.nseIku = RegisterNSE("Play_Shadow_jump");
			ShadowVoiceoverComponent.nseMathTruth = RegisterNSE("Play_Shadow_MathTruth");
		}

		private NetworkSoundEventDef RegisterNSE(string eventName)
		{
			NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>();
			val.eventName = eventName;
			Content.networkSoundEventDefs.Add(val);
			nseList.Add(new NSEInfo(val));
			return val;
		}

		public void RefreshNSE()
		{
			foreach (NSEInfo nse in nseList)
			{
				nse.ValidateParams();
			}
		}
	}
}
namespace ShadowVoiceMod.Modules
{
	public class Content : IContentPackProvider
	{
		[CompilerGenerated]
		private sealed class <FinalizeAsync>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public FinalizeAsyncArgs args;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FinalizeAsync>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				args.ReportProgress(1f);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <GenerateContentPackAsync>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Content <>4__this;

			public GetContentPackAsyncArgs args;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GenerateContentPackAsync>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				Content content = <>4__this;
				if (num != 0)
				{
					return false;
				}
				<>1__state = -1;
				ContentPack.Copy(content.contentPack, args.output);
				args.ReportProgress(1f);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadStaticContentAsync>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Content <>4__this;

			public LoadStaticContentAsyncArgs args;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadStaticContentAsync>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				Content content = <>4__this;
				if (num != 0)
				{
					return false;
				}
				<>1__state = -1;
				content.contentPack.identifier = content.identifier;
				content.contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray());
				args.ReportProgress(1f);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal ContentPack contentPack = new ContentPack();

		public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>();

		public string identifier => "com.Dannyduartemgs.ShadowVoiceMod";

		public void Initialize()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddContentPackProvider);
		}

		private void AddContentPackProvider(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		[IteratorStateMachine(typeof(<LoadStaticContentAsync>d__6))]
		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadStaticContentAsync>d__6(0)
			{
				<>4__this = this,
				args = args
			};
		}

		[IteratorStateMachine(typeof(<GenerateContentPackAsync>d__7))]
		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateContentPackAsync>d__7(0)
			{
				<>4__this = this,
				args = args
			};
		}

		[IteratorStateMachine(typeof(<FinalizeAsync>d__8))]
		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FinalizeAsync>d__8(0)
			{
				args = args
			};
		}

		internal static NetworkSoundEventDef CreateNetworkSoundEventDef(string eventName)
		{
			NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>();
			val.akId = AkSoundEngine.GetIDFromString(eventName);
			val.eventName = eventName;
			networkSoundEventDefs.Add(val);
			return val;
		}
	}
	public static class Files
	{
		public static PluginInfo PluginInfo;

		public static string assemblyDir => Path.GetDirectoryName(PluginInfo.Location);
	}
	public static class SoundBanks
	{
		private static bool initialized;

		public static string SoundBankDirectory => Files.assemblyDir;

		public static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				string text = Path.Combine(SoundBankDirectory, "ShadowSoundbank.sound");
				if (!File.Exists(text))
				{
					Debug.LogError((object)("[ShadowVoiceMod] ❌ Soundbank not found: " + text));
					return;
				}
				SoundBanks.Add(File.ReadAllBytes(text));
				Debug.Log((object)("[ShadowVoiceMod] ✅ Loaded soundbank: " + text));
			}
		}
	}
}
namespace ShadowVoiceMod.Components
{
	public class ShadowVoiceoverComponent : BaseVoiceoverComponent
	{
		public static NetworkSoundEventDef nseShout;

		public static NetworkSoundEventDef nseSpecial;

		public static NetworkSoundEventDef nseBlock;

		public static NetworkSoundEventDef nseShrineFail;

		public static NetworkSoundEventDef nseTitle;

		public static NetworkSoundEventDef nseIntro;

		public static NetworkSoundEventDef nseHurt;

		public static NetworkSoundEventDef nseKanpeki;

		public static NetworkSoundEventDef nseSmart;

		public static NetworkSoundEventDef nseLogic;

		public static NetworkSoundEventDef nseFactor;

		public static NetworkSoundEventDef nseThanks;

		public static NetworkSoundEventDef nseIku;

		public static NetworkSoundEventDef nseMathTruth;

		private float lowHealthCooldown;

		private float blockedCooldown;

		private float specialCooldown;

		private float levelCooldown;

		private float shrineOfChanceFailCooldown;

		private float secondaryCooldown;

		protected override void Start()
		{
			((BaseVoiceoverComponent)this).Start();
		}

		protected override void FixedUpdate()
		{
			((BaseVoiceoverComponent)this).FixedUpdate();
			if (lowHealthCooldown > 0f)
			{
				lowHealthCooldown -= Time.fixedDeltaTime;
			}
			if (blockedCooldown > 0f)
			{
				blockedCooldown -= Time.fixedDeltaTime;
			}
			if (specialCooldown > 0f)
			{
				specialCooldown -= Time.fixedDeltaTime;
			}
			if (levelCooldown > 0f)
			{
				levelCooldown -= Time.fixedDeltaTime;
			}
			if (shrineOfChanceFailCooldown > 0f)
			{
				levelCooldown -= Time.fixedDeltaTime;
			}
			if (secondaryCooldown > 0f)
			{
				secondaryCooldown -= Time.fixedDeltaTime;
			}
		}

		public override void PlaySpawn()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_spawn", 1f, false);
		}

		public override void PlayJump()
		{
			((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseIku, 0f, false);
		}

		public override void PlayDeath()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_death", 1.5f, true);
		}

		public override void PlayHurt(float percentHPLost)
		{
			if (percentHPLost >= 0.1f)
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseHurt, 0f, false);
			}
		}

		public override void PlaySecondaryAuthority(GenericSkill skill)
		{
			if (!(secondaryCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseShout, 0f, false))
			{
				secondaryCooldown = 6.5f;
			}
		}

		public override void PlayTeleporterStart()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_tpstart", 3f, false);
		}

		public override void PlayTeleporterFinish()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_tpend", 3.8f, false);
		}

		public override void PlayVictory()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_yay", 3.8f, true);
		}

		public override void PlayLevelUp()
		{
			if (!(levelCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_levelup", 3f, false))
			{
				levelCooldown = 60f;
			}
		}

		public override void PlayLowHealth()
		{
			if (!(lowHealthCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_lowhealth", 1f, false))
			{
				lowHealthCooldown = 45f;
			}
		}

		public override void PlaySpecialAuthority(GenericSkill skill)
		{
			if (!(specialCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseSpecial, 0f, false))
			{
				specialCooldown = 15f;
			}
		}

		public void PlayAcquireLegendary()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_yay", 5.75f, false);
		}

		public override void PlayShrineOfChanceFailServer()
		{
			if (NetworkServer.active && !(shrineOfChanceFailCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Shadow_fail", 1f, false))
			{
				shrineOfChanceFailCooldown = 60f;
			}
		}

		public override bool ComponentEnableVoicelines()
		{
			return ShadowVoiceMod.enableVoicelines.Value;
		}
	}
}