Decompiled source of SaoriBandit v1.0.3

BanditSaoriSkin.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using MonoMod.RuntimeDetour.HookGen;
using RoR2;
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 BanditSaoriSkin;

[BepInPlugin("com.Bread.BanditSaoriSkin", "BanditSaoriSkin", "1.0.0")]
public class BanditSaoriSkinPlugin : 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 BanditSaoriSkinPlugin Instance { get; private set; }

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

	private void Start()
	{
		Instance = this;
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BanditSaoriSkin.breadbanditsaoriskin"))
		{
			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/Saori.mat", "Assets/Rifle.mat", "Assets/Gun.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("BREAD_SKIN_SAORISKIN_NAME", "Saori");
	}

	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));
		AddBandit2BodySaoriSkinSkin();
		HookEndpointManager.Remove((MethodBase)method, (Delegate)new Action<Action<SkinDef>, SkinDef>(Nothing));
	}

	private static void AddBandit2BodySaoriSkinSkin()
	{
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		string text = "Bandit2Body";
		string text2 = "SaoriSkin";
		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\\BanditSaoriSkin\\Icons\\SaoriSkinIcon.png");
			});
			((Object)skin).name = text2;
			skin.nameToken = "BREAD_SKIN_SAORISKIN_NAME";
			skin.rootObject = gameObject;
			TryCatchThrow("Base Skins", delegate
			{
				skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			});
			TryCatchThrow("Unlockable Name", delegate
			{
				skin.unlockableDef = null;
			});
			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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0161: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[6]
				{
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Saori.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers[3]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Saori.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)2,
						ignoreOverlays = false,
						renderer = renderers[2]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Saori.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)2,
						ignoreOverlays = false,
						renderer = renderers[6]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Saori.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)2,
						ignoreOverlays = false,
						renderer = renderers[1]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Rifle.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)2,
						ignoreOverlays = false,
						renderer = renderers[4]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Gun.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)2,
						ignoreOverlays = false,
						renderer = renderers[7]
					}
				};
			});
			TryCatchThrow("Mesh Replacements", delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[7]
				{
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\BanditSaoriSkin\\Meshes\\BodyNew.mesh"),
						renderer = renderers[2]
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers[0]
					},
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\BanditSaoriSkin\\Meshes\\HandsNew.mesh"),
						renderer = renderers[1]
					},
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\BanditSaoriSkin\\Meshes\\JacketNew.mesh"),
						renderer = renderers[3]
					},
					new MeshReplacement
					{
						mesh = null,
						renderer = renderers[6]
					},
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\BanditSaoriSkin\\Meshes\\Gun.mesh"),
						renderer = renderers[4]
					},
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\BanditSaoriSkin\\Meshes\\Pistol.mesh"),
						renderer = renderers[7]
					}
				};
			});
			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);
		}
	}
}

BanditSaoriVoiceover.dll

Decompiled 3 months 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 BanditSaoriVoiceover.Components;
using BanditSaoriVoiceoverPlugin.Modules;
using BaseVoiceoverLib;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BanditSaoriVoiceover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+498ff9b06b80c6d9a741b0d1679b998e5b6a5ca2")]
[assembly: AssemblyProduct("BanditSaoriVoiceover")]
[assembly: AssemblyTitle("BanditSaoriVoiceover")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BanditSaoriVoiceoverPlugin.Modules
{
	public class Content : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

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

		public string identifier => "com.Schale.BanditSaoriVoiceover";

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

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

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	public static class Files
	{
		public static PluginInfo PluginInfo;

		internal static string assemblyDir => Path.GetDirectoryName(PluginInfo.Location);

		internal static void Init(PluginInfo info)
		{
			PluginInfo = info;
		}

		internal static string GetPathToFile(string folderName, string fileName)
		{
			return Path.Combine(assemblyDir, folderName, fileName);
		}
	}
	public static class SoundBanks
	{
		private static bool initialized;

		public static string SoundBankDirectory => Files.assemblyDir;

		public static void Init()
		{
			if (initialized)
			{
				return;
			}
			initialized = true;
			using Stream stream = new FileStream(SoundBankDirectory + "\\BanditSaoriSoundbank.bnk", FileMode.Open);
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			SoundBanks.Add(array);
		}
	}
}
namespace BanditSaoriVoiceover
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Schale.BanditSaoriVoiceover", "BanditSaoriVoiceover", "1.0.2")]
	public class BanditSaoriVoiceoverPlugin : BaseUnityPlugin
	{
		public class NSEInfo
		{
			public NetworkSoundEventDef nse;

			public uint akId = 0u;

			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<KeyboardShortcut> buttonVanitas;

		public static ConfigEntry<KeyboardShortcut> buttonVanitasFull;

		public static ConfigEntry<KeyboardShortcut> buttonMuda;

		public static ConfigEntry<KeyboardShortcut> buttonHurt;

		public static ConfigEntry<KeyboardShortcut> buttonOmoshiroi;

		public static ConfigEntry<KeyboardShortcut> buttonMunashii;

		public static ConfigEntry<KeyboardShortcut> buttonThanks;

		public static ConfigEntry<KeyboardShortcut> buttonTitle;

		public static ConfigEntry<KeyboardShortcut> buttonIntro;

		public static ConfigEntry<KeyboardShortcut> buttonFormation;

		public static ConfigEntry<KeyboardShortcut> buttonCafe5;

		public static ConfigEntry<KeyboardShortcut> buttonExLevel1;

		public static ConfigEntry<KeyboardShortcut> buttonExLevel2;

		public static ConfigEntry<KeyboardShortcut> buttonExLevel3;

		public static ConfigEntry<bool> enableVoicelines;

		public static bool playedSeasonalVoiceline = false;

		public static AssetBundle assetBundle;

		public static SurvivorDef survivorDef = Addressables.LoadAssetAsync<SurvivorDef>((object)"RoR2/Base/Bandit2/Bandit2.asset").WaitForCompletion();

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

		public void Awake()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0099: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			Files.PluginInfo = ((BaseUnityPlugin)this).Info;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
			new Content().Initialize();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BanditSaoriVoiceover.banditsaorivoiceoverbundle"))
			{
				assetBundle = AssetBundle.LoadFromStream(stream);
			}
			SoundBanks.Init();
			InitNSE();
			enableVoicelines = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Settings", "Enable Voicelines"), true, new ConfigDescription("Enable voicelines when using the BanditSaori Skin.", (AcceptableValueBase)null, Array.Empty<object>()));
			enableVoicelines.SettingChanged += EnableVoicelines_SettingChanged;
			buttonVanitas = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Vanitas Vanitatum"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonVanitasFull = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Vanitas Vanitatum, et Omnia Vanitas"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonMuda = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Muda da"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonOmoshiroi = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Omoshiroi"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonHurt = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Hurt"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonMunashii = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Munashii"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonThanks = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Thanks"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonTitle = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Blue Archive"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonIntro = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Introduction"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonFormation = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Formation Select"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonCafe5 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Naruhodo"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonExLevel1 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "EX 1"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonExLevel2 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "EX 2"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonExLevel3 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "EX 3"), KeyboardShortcut.Empty, (ConfigDescription)null);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat();
			}
		}

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

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void RiskOfOptionsCompat()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableVoicelines));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonTitle));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonIntro));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonFormation));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonVanitas));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonVanitasFull));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonMunashii));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonExLevel1));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonExLevel2));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonExLevel3));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonCafe5));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonMuda));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonOmoshiroi));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonThanks));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonHurt));
			ModSettingsManager.SetModIcon(assetBundle.LoadAsset<Sprite>("texIconSaori"));
		}

		private void OnLoad()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			SkinDef val = null;
			SkinDef[] array = SkinCatalog.FindSkinsForBody(BodyCatalog.FindBodyIndex("Bandit2Body"));
			SkinDef[] array2 = array;
			foreach (SkinDef val2 in array2)
			{
				if (((Object)val2).name == "SaoriSkin")
				{
					val = val2;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				Debug.LogError((object)"BanditSaoriVoiceover: Bandit Saori SkinDef not found. Voicelines will not work!");
			}
			else
			{
				VoiceoverInfo val3 = new VoiceoverInfo(typeof(BanditSaoriVoiceoverComponent), val, "Bandit2Body");
				val3.selectActions = (LobbySelectActions)Delegate.Combine((Delegate?)(object)val3.selectActions, (Delegate?)new LobbySelectActions(SaoriSelect));
			}
			RefreshNSE();
		}

		private void SaoriSelect(GameObject mannequinObject)
		{
			if (!enableVoicelines.Value)
			{
				return;
			}
			bool flag = false;
			if (!playedSeasonalVoiceline)
			{
				if (DateTime.Today.Month == 1 && DateTime.Today.Day == 1)
				{
					Util.PlaySound("Play_BanditSaori_Lobby_Newyear", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 9 && DateTime.Today.Day == 3)
				{
					Util.PlaySound("Play_BanditSaori_Lobby_bday", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 10 && DateTime.Today.Day == 31)
				{
					Util.PlaySound("Play_BanditSaori_Lobby_Halloween", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 12 && DateTime.Today.Day == 25)
				{
					Util.PlaySound("Play_BanditSaori_Lobby_xmas", mannequinObject);
					flag = true;
				}
				if (flag)
				{
					playedSeasonalVoiceline = true;
				}
			}
			if (!flag)
			{
				if (Util.CheckRoll(5f, 0f, (CharacterMaster)null))
				{
					Util.PlaySound("Play_BanditSaori_TitleDrop", mannequinObject);
				}
				else
				{
					Util.PlaySound("Play_BanditSaori_Lobby", mannequinObject);
				}
			}
		}

		private void InitNSE()
		{
			BanditSaoriVoiceoverComponent.nseShout = RegisterNSE("Play_BanditSaori_Shout");
			BanditSaoriVoiceoverComponent.nseStealth = RegisterNSE("Play_BanditSaori_Stealth");
			BanditSaoriVoiceoverComponent.nseBlock = RegisterNSE("Play_BanditSaori_Block");
			BanditSaoriVoiceoverComponent.nseEx = RegisterNSE("Play_BanditSaori_Ex");
			BanditSaoriVoiceoverComponent.nseExLevel = RegisterNSE("Play_BanditSaori_ExLevel");
			BanditSaoriVoiceoverComponent.nseVanitas = RegisterNSE("Play_BanditSaori_Vanitas");
			BanditSaoriVoiceoverComponent.nseVanitasFull = RegisterNSE("Play_BanditSaori_VanitasFull");
			BanditSaoriVoiceoverComponent.nseMuda = RegisterNSE("Play_BanditSaori_Muda");
			BanditSaoriVoiceoverComponent.nseHurt = RegisterNSE("Play_BanditSaori_TakeDamage");
			BanditSaoriVoiceoverComponent.nseOmoshiroi = RegisterNSE("Play_BanditSaori_Omoshiroi");
			BanditSaoriVoiceoverComponent.nseMunashii = RegisterNSE("Play_BanditSaori_Munashii");
			BanditSaoriVoiceoverComponent.nseThanks = RegisterNSE("Play_BanditSaori_Thanks");
			BanditSaoriVoiceoverComponent.nseTitle = RegisterNSE("Play_BanditSaori_TitleDrop");
			BanditSaoriVoiceoverComponent.nseIntro = RegisterNSE("Play_BanditSaori_Intro");
			BanditSaoriVoiceoverComponent.nseFormation = RegisterNSE("Play_BanditSaori_Formation_Select");
			BanditSaoriVoiceoverComponent.nseCafe5 = RegisterNSE("Play_BanditSaori_Cafe5");
			BanditSaoriVoiceoverComponent.nseExLevel1 = RegisterNSE("Play_BanditSaori_ExLevel1");
			BanditSaoriVoiceoverComponent.nseExLevel2 = RegisterNSE("Play_BanditSaori_ExLevel2");
			BanditSaoriVoiceoverComponent.nseExLevel3 = RegisterNSE("Play_BanditSaori_ExLevel3");
		}

		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 BanditSaoriVoiceover.Components
{
	public class BanditSaoriVoiceoverComponent : BaseVoiceoverComponent
	{
		public static NetworkSoundEventDef nseShout;

		public static NetworkSoundEventDef nseStealth;

		public static NetworkSoundEventDef nseBlock;

		public static NetworkSoundEventDef nseExLevel;

		public static NetworkSoundEventDef nseEx;

		public static NetworkSoundEventDef nseVanitas;

		public static NetworkSoundEventDef nseVanitasFull;

		public static NetworkSoundEventDef nseMuda;

		public static NetworkSoundEventDef nseHurt;

		public static NetworkSoundEventDef nseOmoshiroi;

		public static NetworkSoundEventDef nseMunashii;

		public static NetworkSoundEventDef nseThanks;

		public static NetworkSoundEventDef nseTitle;

		public static NetworkSoundEventDef nseIntro;

		public static NetworkSoundEventDef nseFormation;

		public static NetworkSoundEventDef nseCafe5;

		public static NetworkSoundEventDef nseExLevel1;

		public static NetworkSoundEventDef nseExLevel2;

		public static NetworkSoundEventDef nseExLevel3;

		private float levelCooldown = 0f;

		private float blockedCooldown = 0f;

		private float lowHealthCooldown = 0f;

		private float specialCooldown = 0f;

		private float shrineFailCooldown = 0f;

		private bool acquiredScepter = false;

		protected override void Start()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			((BaseVoiceoverComponent)this).Start();
			if (Object.op_Implicit((Object)(object)base.inventory) && base.inventory.GetItemCount(BaseVoiceoverComponent.scepterIndex) > 0)
			{
				acquiredScepter = true;
			}
		}

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

		public override void PlayDamageBlockedServer()
		{
			if (NetworkServer.active && !(blockedCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseBlock, 0.55f, false))
			{
				blockedCooldown = 30f;
			}
		}

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

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

		public override void PlayLevelUp()
		{
			if (!(levelCooldown > 0f) && ((!Util.CheckRoll(50f, 0f, (CharacterMaster)null)) ? ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_LevelUp_Long", 6.6f, false) : ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_LevelUp_Short", 1.35f, false)))
			{
				levelCooldown = 60f;
			}
		}

		public override void PlayLowHealth()
		{
			if (!(lowHealthCooldown > 0f) && (Util.CheckRoll(60f, 0f, (CharacterMaster)null) ? ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_LowHealth", 0f, false) : (Util.CheckRoll(90f, 0f, (CharacterMaster)null) ? ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Lobby5", 3.8f, false) : ((!Util.CheckRoll(50f, 0f, (CharacterMaster)null)) ? ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Memorial4", 12.8f, false) : ((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Memorial2", 7.35f, false)))))
			{
				lowHealthCooldown = 60f;
			}
		}

		public override void PlaySecondaryAuthority(GenericSkill skill)
		{
			((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseShout, 0f, false);
		}

		public override void PlaySpawn()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Spawn", 2.4f, true);
		}

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

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

		public override void PlayTeleporterStart()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Ex", 4.4f, true);
		}

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

		protected override void Inventory_onItemAddedClient(ItemIndex itemIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			((BaseVoiceoverComponent)this).Inventory_onItemAddedClient(itemIndex);
			if ((int)BaseVoiceoverComponent.scepterIndex != -1 && itemIndex == BaseVoiceoverComponent.scepterIndex)
			{
				PlayAcquireScepter();
				return;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
			if ((Object)(object)itemDef == (Object)(object)Items.Squid || (Object)(object)itemDef == (Object)(object)Items.Plant || (Object)(object)itemDef == (Object)(object)Items.SlowOnHit)
			{
				PlayBadItem();
			}
			else if (Object.op_Implicit((Object)(object)itemDef) && (int)itemDef.deprecatedTier == 2)
			{
				PlayAcquireLegendary();
			}
		}

		public void PlayAcquireScepter()
		{
			if (!acquiredScepter)
			{
				((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_AcquireScepter", 22.75f, true);
				acquiredScepter = true;
			}
		}

		public void PlayBadItem()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Cafe3", 0.75f, false);
		}

		public void PlayAcquireLegendary()
		{
			if (Util.CheckRoll(75f, 0f, (CharacterMaster)null))
			{
				((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Relationship", 3.7f, false);
			}
			else
			{
				((BaseVoiceoverComponent)this).TryPlaySound("Play_BanditSaori_Relationship_Long", 12.25f, false);
			}
		}

		public override void PlayShrineOfChanceFailServer()
		{
			if (!(shrineFailCooldown > 0f) && Util.CheckRoll(15f, 0f, (CharacterMaster)null) && ((!Util.CheckRoll(50f, 0f, (CharacterMaster)null)) ? ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseVanitasFull, 2.9f, false) : ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseVanitas, 1.2f, false)))
			{
				shrineFailCooldown = 60f;
			}
		}

		protected override void CheckInputs()
		{
			if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonVanitas))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseVanitas, 1.2f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonVanitasFull))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseVanitasFull, 2.9f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonHurt))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseHurt, 0.1f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonMuda))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseMuda, 0.6f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonOmoshiroi))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseOmoshiroi, 0.75f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonMunashii))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseMunashii, 4.5f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonThanks))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseThanks, 1.5f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonTitle))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseTitle, 1f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonIntro))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseIntro, 12.3f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonFormation))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseFormation, 1f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonCafe5))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseCafe5, 3.55f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonExLevel1))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseExLevel1, 1.85f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonExLevel2))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseExLevel2, 0.1f, false);
			}
			else if (Utils.GetKeyPressed(BanditSaoriVoiceoverPlugin.buttonExLevel3))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseExLevel3, 1.45f, false);
			}
		}

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