Decompiled source of MisakiRocket v1.2.3

RocketMisaki.dll

Decompiled 3 months ago
using System;
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 UnityEngine;
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 RocketMisaki;

[BepInPlugin("com.KrononConspirator.RocketMisaki", "RocketMisaki", "1.0.0")]
public class RocketMisakiPlugin : BaseUnityPlugin
{
	private class FieldException : Exception
	{
		public FieldException(string message, Exception innerException)
			: base(message, innerException)
		{
		}
	}

	private static AssetBundle assetBundle;

	internal static RocketMisakiPlugin Instance { get; private set; }

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

	private void Start()
	{
		Instance = this;
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RocketMisaki.krononconspiratorrocketmisaki"))
		{
			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));
	}

	private static void LanguageLoadStrings(Action<Language> orig, Language self)
	{
		orig(self);
		self.SetStringByToken("KRONONCONSPIRATOR_SKIN_ROCKETMISAKISKINDEF_NAME", "Imashino Misaki");
	}

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

	private static void AddRocketSurvivorBodyRocketMisakiSkinDefSkin()
	{
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		string text = "RocketSurvivorBody";
		string text2 = "RocketMisakiSkinDef";
		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;
			}
			CharacterModel component2 = gameObject.GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)component2))
			{
				InstanceLogger.LogWarning((object)("Failed to add \"" + text2 + "\" skin to \"" + text + "\" because it doesn't have \"CharacterModel\" component"));
				return;
			}
			Renderer[] renderers = component2.baseRendererInfos.Select((RendererInfo info) => info.renderer).ToArray();
			SkinDef skin = ScriptableObject.CreateInstance<SkinDef>();
			TryCatchThrow("Icon", delegate
			{
				skin.icon = assetBundle.LoadAsset<Sprite>("Assets\\SkinMods\\RocketMisaki\\Icons\\RocketMisakiSkinDefIcon.png");
			});
			((Object)skin).name = text2;
			skin.nameToken = "KRONONCONSPIRATOR_SKIN_ROCKETMISAKISKINDEF_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
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: 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_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				skin.gameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[3]
				{
					new GameObjectActivation
					{
						gameObject = ((Component)renderers[0]).gameObject,
						shouldActivate = false
					},
					new GameObjectActivation
					{
						gameObject = ((Component)renderers[6]).gameObject,
						shouldActivate = false
					},
					new GameObjectActivation
					{
						gameObject = ((Component)renderers[2]).gameObject,
						shouldActivate = false
					}
				};
			});
			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)
				skin.rendererInfos = (RendererInfo[])(object)new RendererInfo[2]
				{
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Skins/Modded/Rocket/ArknightMisaki/MisakiBaseMat.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers[4]
					},
					new RendererInfo
					{
						defaultMaterial = assetBundle.LoadAsset<Material>("Assets/Skins/Modded/Rocket/ArknightMisaki/MisakiCannonMat.mat"),
						defaultShadowCastingMode = (ShadowCastingMode)1,
						ignoreOverlays = false,
						renderer = renderers[3]
					}
				};
			});
			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_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				skin.meshReplacements = (MeshReplacement[])(object)new MeshReplacement[2]
				{
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\RocketMisaki\\Meshes\\MisakiMesh.mesh"),
						renderer = renderers[4]
					},
					new MeshReplacement
					{
						mesh = assetBundle.LoadAsset<Mesh>("Assets\\SkinMods\\RocketMisaki\\Meshes\\MisakiCannon.mesh"),
						renderer = renderers[3]
					}
				};
			});
			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);
		}
	}
}

RocketMisakiVoiceover.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 BaseVoiceoverLib;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RocketMisakiVoiceover.Components;
using RocketMisakiVoiceover.Modules;
using UnityEngine;
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("RocketMisakiVoiceover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d336d8d69482531efc1a6c2cbacdc5350bfa4127")]
[assembly: AssemblyProduct("RocketMisakiVoiceover")]
[assembly: AssemblyTitle("RocketMisakiVoiceover")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RocketMisakiVoiceover
{
	[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.RocketMisakiVoiceover", "RocketMisakiVoiceover", "1.2.3")]
	public class RocketMisakiVoiceoverPlugin : 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> buttonDust;

		public static ConfigEntry<KeyboardShortcut> buttonHurt;

		public static ConfigEntry<KeyboardShortcut> buttonTitle;

		public static ConfigEntry<KeyboardShortcut> buttonIntro;

		public static ConfigEntry<KeyboardShortcut> buttonThanks;

		public static ConfigEntry<KeyboardShortcut> buttonMuda;

		public static ConfigEntry<KeyboardShortcut> buttonNani;

		public static ConfigEntry<KeyboardShortcut> buttonCafe1;

		public static ConfigEntry<KeyboardShortcut> buttonCafe4;

		public static ConfigEntry<bool> enableVoicelines;

		public static bool playedSeasonalVoiceline = false;

		public static AssetBundle assetBundle;

		public static SurvivorDef rocketSurvivorDef;

		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
			Files.PluginInfo = ((BaseUnityPlugin)this).Info;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
			new Content().Initialize();
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RocketMisakiVoiceover.rocketmisakivoiceoverbundle"))
			{
				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 RocketMisaki Skin.", (AcceptableValueBase)null, Array.Empty<object>()));
			enableVoicelines.SettingChanged += EnableVoicelines_SettingChanged;
			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);
			buttonDust = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Dust to Dust"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonCafe1 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Noisy"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonCafe4 = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Not Interested"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonThanks = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Thanks"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonMuda = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Muda"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonNani = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Nani"), KeyboardShortcut.Empty, (ConfigDescription)null);
			buttonHurt = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition("Keybinds", "Hurt"), 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableVoicelines));
			ModSettingsManager.SetModIcon(assetBundle.LoadAsset<Sprite>("Misaki"));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonTitle));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonIntro));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonDust));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonThanks));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonMuda));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonNani));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(buttonHurt));
		}

		private void OnLoad()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0085: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			BodyIndex val = BodyCatalog.FindBodyIndex("RocketSurvivorBody");
			SkinDef val2 = null;
			SkinDef[] array = SkinCatalog.FindSkinsForBody(val);
			SkinDef[] array2 = array;
			foreach (SkinDef val3 in array2)
			{
				if (((Object)val3).name == "RocketMisakiSkinDef")
				{
					val2 = val3;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Debug.LogError((object)"RocketMisakiVoiceover: Rocket Misaki SkinDef not found. Voicelines will not work!");
			}
			else
			{
				VoiceoverInfo val4 = new VoiceoverInfo(typeof(RocketMisakiVoiceoverComponent), val2, "RocketSurvivorBody");
				val4.selectActions = (LobbySelectActions)Delegate.Combine((Delegate?)(object)val4.selectActions, (Delegate?)new LobbySelectActions(MisakiSelect));
			}
			RefreshNSE();
		}

		private void MisakiSelect(GameObject mannequinObject)
		{
			if (!enableVoicelines.Value)
			{
				return;
			}
			bool flag = false;
			if (!playedSeasonalVoiceline)
			{
				if (DateTime.Today.Month == 1 && DateTime.Today.Day == 1)
				{
					Util.PlaySound("Play_RocketMisaki_Lobby_Newyear", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 1 && DateTime.Today.Day == 13)
				{
					Util.PlaySound("Play_RocketMisaki_Lobby_bday", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 10 && DateTime.Today.Day == 31)
				{
					Util.PlaySound("Play_RocketMisaki_Lobby_Halloween", mannequinObject);
					flag = true;
				}
				else if (DateTime.Today.Month == 12 && DateTime.Today.Day == 25)
				{
					Util.PlaySound("Play_RocketMisaki_Lobby_xmas", mannequinObject);
					flag = true;
				}
				if (flag)
				{
					playedSeasonalVoiceline = true;
				}
			}
			if (!flag)
			{
				if (Util.CheckRoll(5f, 0f, (CharacterMaster)null))
				{
					Util.PlaySound("Play_RocketMisaki_TitleDrop", mannequinObject);
				}
				else
				{
					Util.PlaySound("Play_RocketMisaki_Lobby", mannequinObject);
				}
			}
		}

		private void InitNSE()
		{
			RocketMisakiVoiceoverComponent.nseBlock = RegisterNSE("Play_RocketMisaki_Blocked");
			RocketMisakiVoiceoverComponent.nseEx = RegisterNSE("Play_RocketMisaki_ExSkill");
			RocketMisakiVoiceoverComponent.nseExLevel = RegisterNSE("Play_RocketMisaki_ExSkill_Level");
			RocketMisakiVoiceoverComponent.nseShout = RegisterNSE("Play_RocketMisaki_Shout");
			RocketMisakiVoiceoverComponent.nseDust = RegisterNSE("Play_RocketMisaki_ExSkill_Level_1");
			RocketMisakiVoiceoverComponent.nseHurt = RegisterNSE("Play_RocketMisaki_TakeDamage");
			RocketMisakiVoiceoverComponent.nseTitle = RegisterNSE("Play_RocketMisaki_TitleDrop");
			RocketMisakiVoiceoverComponent.nseIntro = RegisterNSE("Play_RocketMisaki_Intro");
			RocketMisakiVoiceoverComponent.nseThanks = RegisterNSE("Play_RocketMisaki_Thanks");
			RocketMisakiVoiceoverComponent.nseNani = RegisterNSE("Play_RocketMisaki_nani");
			RocketMisakiVoiceoverComponent.nseCafe1 = RegisterNSE("Play_RocketMisaki_Cafe1");
			RocketMisakiVoiceoverComponent.nseCafe4 = RegisterNSE("Play_RocketMisaki_Cafe4");
		}

		public void RefreshNSE()
		{
			foreach (NSEInfo nse in nseList)
			{
				nse.ValidateParams();
			}
		}

		private NetworkSoundEventDef RegisterNSE(string eventName)
		{
			NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>();
			val.eventName = eventName;
			Content.networkSoundEventDefs.Add(val);
			nseList.Add(new NSEInfo(val));
			return val;
		}
	}
}
namespace RocketMisakiVoiceover.Modules
{
	public class Content : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

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

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

		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 + "\\RocketMisakiSoundbank.bnk", FileMode.Open);
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			SoundBanks.Add(array);
		}
	}
}
namespace RocketMisakiVoiceover.Components
{
	public class RocketMisakiVoiceoverComponent : BaseVoiceoverComponent
	{
		public static NetworkSoundEventDef nseBlock;

		public static NetworkSoundEventDef nseEx;

		public static NetworkSoundEventDef nseExLevel;

		public static NetworkSoundEventDef nseShout;

		public static NetworkSoundEventDef nseDust;

		public static NetworkSoundEventDef nseHurt;

		public static NetworkSoundEventDef nseTitle;

		public static NetworkSoundEventDef nseIntro;

		public static NetworkSoundEventDef nseThanks;

		public static NetworkSoundEventDef nseNani;

		public static NetworkSoundEventDef nseCafe4;

		public static NetworkSoundEventDef nseCafe1;

		private float levelCooldown = 0f;

		private float blockedCooldown = 0f;

		private float lowHealthCooldown = 0f;

		private float secondaryCooldown = 0f;

		private float specialCooldown = 0f;

		private float bearCooldown = 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 (secondaryCooldown > 0f)
			{
				secondaryCooldown -= Time.fixedDeltaTime;
			}
			if (levelCooldown > 0f)
			{
				levelCooldown -= Time.fixedDeltaTime;
			}
			if (blockedCooldown > 0f)
			{
				blockedCooldown -= Time.fixedDeltaTime;
			}
			if (lowHealthCooldown > 0f)
			{
				lowHealthCooldown -= Time.fixedDeltaTime;
			}
			if (bearCooldown > 0f)
			{
				bearCooldown -= Time.fixedDeltaTime;
			}
		}

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

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

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

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

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

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

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

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

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

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

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

		public override void PlayVictory()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_Memorial4", 12.5f, 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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.MoreMissile)
			{
				PlayAcquireICBM();
			}
			else if ((Object)(object)itemDef == (Object)(object)Items.Squid)
			{
				PlayBadItem();
			}
			else if ((Object)(object)itemDef == (Object)(object)Items.Bear)
			{
				PlayBear();
			}
			else if (Object.op_Implicit((Object)(object)itemDef) && (int)itemDef.deprecatedTier == 2)
			{
				PlayAcquireLegendary();
			}
		}

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

		public void PlayAcquireICBM()
		{
			((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_CommonSkill", 1.5f, false);
		}

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

		public void PlayAcquireLegendary()
		{
			if (Util.CheckRoll(50f, 0f, (CharacterMaster)null))
			{
				((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_Relationship_Short", 3f, false);
			}
			else
			{
				((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_Relationship", 7f, false);
			}
		}

		public void PlayBear()
		{
			if (!(bearCooldown > 0f) && ((!Util.CheckRoll(50f, 0f, (CharacterMaster)null)) ? ((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_Relationship", 7f, false) : ((BaseVoiceoverComponent)this).TryPlaySound("Play_RocketMisaki_Relationship_Short", 3f, false)))
			{
				bearCooldown = 60f;
			}
		}

		protected override void CheckInputs()
		{
			if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonTitle))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseTitle, 1.1f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonHurt))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseHurt, 0.1f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonDust))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseDust, 1.8f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonIntro))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseIntro, 12.5f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonThanks))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseThanks, 2.1f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonMuda))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseBlock, 0.75f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonNani))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseNani, 0.4f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonCafe1))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseCafe1, 1.5f, false);
			}
			else if (Utils.GetKeyPressed(RocketMisakiVoiceoverPlugin.buttonCafe4))
			{
				((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseCafe4, 1.35f, false);
			}
		}

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