Decompiled source of NishikiBracken v1.0.1

NishikiBracken.dll

Decompiled a month 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.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using NishikiBracken.Patches;
using UnityEngine;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NishikiBracken")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NishikiBracken")]
[assembly: AssemblyTitle("NishikiBracken")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 NishikiBracken
{
	internal class MajimaController : MonoBehaviour
	{
		private JesterAI JesterAI;

		private void Start()
		{
			JesterAI = ((Component)this).GetComponent<JesterAI>();
			JesterAI.screamingSFX = NishikiBracken.MajimaAssets.LoadAsset<AudioClip>("cinderellaVocals");
			JesterAI.popUpSFX = NishikiBracken.MajimaAssets.LoadAsset<AudioClip>("majimaLaugh");
			JesterAI.popGoesTheWeaselTheme = NishikiBracken.MajimaAssets.LoadAsset<AudioClip>("cinderellaVocalless");
		}

		private void UpdateScanNodeData()
		{
			((Component)JesterAI).GetComponentInChildren<ScanNodeProperties>().headerText = "Goro Majima";
		}
	}
	public class ModConfig
	{
		public ConfigEntry<bool> configEnableMajima;

		public ModConfig(ConfigFile cfg)
		{
			cfg.SaveOnConfigSet = false;
			configEnableMajima = cfg.Bind<bool>("General", "UseMajimaSong", true, "Replace Jester sounds with Majima's 24 Hour Cinderella");
			ClearOrphanedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
		}

		private static void ClearOrphanedEntries(ConfigFile cfg)
		{
			PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
			dictionary.Clear();
		}
	}
	[BepInPlugin("NishikiBracken", "NishikiBracken", "1.0.0")]
	public class NishikiBracken : BaseUnityPlugin
	{
		public static AssetBundle NishikiAssets;

		public static AssetBundle MajimaAssets;

		public static NishikiBracken Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		public static ModConfig ModConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			NishikiAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "nishikibracken"));
			if ((Object)(object)NishikiAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load nishiki");
				return;
			}
			ModConfig = new ModConfig(((BaseUnityPlugin)this).Config);
			if (ModConfig.configEnableMajima.Value)
			{
				MajimaAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "majimajester"));
				if ((Object)(object)NishikiAssets == (Object)null)
				{
					Logger.LogError((object)"Failed to load majima");
					return;
				}
			}
			Patch();
			Logger.LogInfo((object)"NishikiBracken v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: 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_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("NishikiBracken");
			}
			Logger.LogInfo((object)"What, you think you're better than me?");
			Harmony.PatchAll(typeof(EnemyPatches));
			Harmony.PatchAll(typeof(NishikiPatches));
			if (ModConfig.configEnableMajima.Value)
			{
				Harmony.PatchAll(typeof(MajimaController));
			}
			Logger.LogInfo((object)"Bring that shit Kazuma!");
		}

		internal static void Unpatch()
		{
			Logger.LogInfo((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogInfo((object)"Finished unpatching!");
		}
	}
	internal class NishikiController : MonoBehaviour
	{
		private FlowermanAI FlowermanAI { get; set; }

		private GameObject PS2NishikiObject { get; set; }

		private bool IsAttacking { get; set; }

		private bool IsDead { get; set; }

		private int ChaseSound { get; set; }

		private string ChaseThemes
		{
			get
			{
				int chaseSound = ChaseSound;
				if (1 == 0)
				{
				}
				string result = chaseSound switch
				{
					0 => "NishikiChase1", 
					1 => "NishikiChase2", 
					_ => "Unknown", 
				};
				if (1 == 0)
				{
				}
				return result;
			}
		}

		private int KillSound { get; set; }

		private string KillSounds
		{
			get
			{
				int killSound = KillSound;
				if (1 == 0)
				{
				}
				string result = killSound switch
				{
					0 => "TENYEARSINTHEJOINT", 
					1 => "EvilLaugh", 
					2 => "StayDown", 
					3 => "HowYouLikeThis", 
					_ => "Unknown", 
				};
				if (1 == 0)
				{
				}
				return result;
			}
		}

		private int EncounterSound { get; set; }

		private string EncounterSounds
		{
			get
			{
				int encounterSound = EncounterSound;
				if (1 == 0)
				{
				}
				string result = encounterSound switch
				{
					0 => "BetterThanMe", 
					1 => "PrisonBitch", 
					_ => "Unknown", 
				};
				if (1 == 0)
				{
				}
				return result;
			}
		}

		private int DieSound { get; set; }

		private string DieSounds
		{
			get
			{
				int dieSound = DieSound;
				if (1 == 0)
				{
				}
				string result = dieSound switch
				{
					0 => "NishikiHurt", 
					1 => "NishikiStun", 
					2 => "NotYet", 
					_ => "Unknown", 
				};
				if (1 == 0)
				{
				}
				return result;
			}
		}

		private void Start()
		{
			FlowermanAI = ((Component)this).GetComponent<FlowermanAI>();
			int seed = StartOfRound.Instance.randomMapSeed + Mathf.RoundToInt(StartOfRound.Instance.timeSinceRoundStarted / 10f) * 10;
			SelectNishikiVariant(seed);
			HideFlowermanModel();
			CreateModels();
			ReplaceFlowermanSFX();
			UpdateScanNodeData();
		}

		private void Update()
		{
			if (!((EnemyAI)FlowermanAI).movingTowardsTargetPlayer || !IsAttacking)
			{
			}
			if (((EnemyAI)FlowermanAI).movingTowardsTargetPlayer || IsAttacking)
			{
			}
			if (((EnemyAI)FlowermanAI).isEnemyDead && !IsDead)
			{
				KillGoku();
			}
		}

		private void CreateModels()
		{
			GameObject val = NishikiBracken.NishikiAssets.LoadAsset<GameObject>("ps2nishiki2");
			PS2NishikiObject = Object.Instantiate<GameObject>(val, ((Component)this).gameObject.transform);
			((Object)PS2NishikiObject).name = "PS2 Nishiki";
		}

		private void HideFlowermanModel()
		{
			Renderer[] componentsInChildren = ((Component)((Component)FlowermanAI).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
		}

		private void ReplaceFlowermanSFX()
		{
			SoundTool.ReplaceAudioClip("Found1", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("BetterThanMe"));
			SoundTool.ReplaceAudioClip("Found1", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("PrisonBitch"));
			SoundTool.ReplaceAudioClip("CrackNeck", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("TENYEARSINTHEJOINT"));
			SoundTool.ReplaceAudioClip("CrackNeck", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("EvilLaugh"));
			SoundTool.ReplaceAudioClip("CrackNeck", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("StayDown"));
			SoundTool.ReplaceAudioClip("CrackNeck", NishikiBracken.NishikiAssets.LoadAsset<AudioClip>("HowYouLikeThis"));
			FlowermanAI.creatureAngerVoice.clip = NishikiBracken.NishikiAssets.LoadAsset<AudioClip>(ChaseThemes);
			((EnemyAI)FlowermanAI).dieSFX = NishikiBracken.NishikiAssets.LoadAsset<AudioClip>(DieSounds);
		}

		private void UpdateScanNodeData()
		{
			((Component)FlowermanAI).GetComponentInChildren<ScanNodeProperties>().headerText = "Akira Nishikiyama";
		}

		private void KillGoku()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			PS2NishikiObject.SetActive(true);
			Transform transform = PS2NishikiObject.transform;
			Quaternion rotation = PS2NishikiObject.transform.rotation;
			Quaternion val = rotation;
			float y = ((Quaternion)(ref val)).eulerAngles.y;
			rotation = PS2NishikiObject.transform.rotation;
			val = rotation;
			transform.rotation = Quaternion.Euler(-90f, y, ((Quaternion)(ref val)).eulerAngles.z);
			IsDead = true;
		}

		private void SelectNishikiVariant(int seed)
		{
			Random random = new Random(seed);
			int chaseSound = random.Next(0, 2);
			ChaseSound = chaseSound;
			int killSound = random.Next(0, 3);
			KillSound = killSound;
			int encounterSound = random.Next(0, 2);
			EncounterSound = encounterSound;
			int dieSound = random.Next(0, 3);
			DieSound = dieSound;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NishikiBracken";

		public const string PLUGIN_NAME = "NishikiBracken";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace NishikiBracken.Patches
{
	[HarmonyPatch]
	internal class EnemyPatches
	{
		[HarmonyPatch(typeof(FlowermanAI), "Start")]
		[HarmonyPostfix]
		public static void CreateNishikiModel(FlowermanAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<NishikiController>();
		}

		[HarmonyPatch(typeof(JesterAI), "Start")]
		[HarmonyPostfix]
		public static void CreateMajimaModel(JesterAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<MajimaController>();
		}
	}
	internal class NishikiPatches
	{
		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPostfix]
		public static void EditTerminal(Terminal __instance)
		{
			int index = __instance.enemyFiles.FindIndex((TerminalNode e) => ((Object)e).name == "BrackenFile");
			int num = __instance.terminalNodes.allKeywords.ToList().FindIndex((TerminalKeyword e) => ((Object)e).name == "Bracken");
			__instance.enemyFiles[index].creatureName = "Akira Nishikiyama";
			__instance.enemyFiles[index].displayText = "Ten years in the joint\nmade you a fucking\nPUSSY!\n\n";
			__instance.enemyFiles[index].displayVideo = NishikiBracken.NishikiAssets.LoadAsset<VideoClip>("nishikismoke");
			__instance.terminalNodes.allKeywords[num].word = "nishiki";
			if (NishikiBracken.ModConfig.configEnableMajima.Value)
			{
				int index2 = __instance.enemyFiles.FindIndex((TerminalNode e) => ((Object)e).name == "JesterFile");
				int num2 = __instance.terminalNodes.allKeywords.ToList().FindIndex((TerminalKeyword e) => ((Object)e).name == "Jester");
				__instance.enemyFiles[index2].creatureName = "Goro Majima";
				__instance.enemyFiles[index2].displayText = "Sunao ni I LOVE YOU! todokeyou\nkitto YOU LOVE ME! tsutawaru sa\nKimi ni niau GLASS no kutsu wo sagasou\n\nFutari de STEP & GO! itsu made mo\nShin'ya juuni-ji wo sugitatte\nbokura no LOVE MAGIC wa\ntoke wa shinai\n\nOide meshimase ohime-sama\nDoku no ringo wo tabete nemucchai sou na\nSunao sugiru kimi ga totemo itoshii\n\nAtarimae = (iko) takaramono sa\nChikyuu wa mawari hi wa nobori\nKimi wa hohoemu\n\nSunao ni I LOVE YOU! todokeyou\nKitto YOU LOVE ME! tsutawaru sa\nKimi ni niau GLASS no kutsu wo sagasou\nThe in-game version of \"24-hour Cinderella\" omits the following lyrics. The following are the lyrics to the full version of the song. They are unofficial, but are written to match the established style.\n\nFutari de STEP & GO! itsu made mo\nShin'ya juuni-ji wo sugitatte\nBokura no LOVE MAGIC wa\nToke wa shinai\n\nIji no warui mama haha ni mo\nKyuu na ame ni mo samishii yoru ni mo\nHekotarenai kimi ga yahari itoshii\n\nTooku hanarete aenai hi wa\nHoshi ni negatte yume de aou\nAsu wa HALLELUJAH\n\nIsshou I LOVE YOU! kawaranai\nSou sa YOU LOVE ME! eien sa\nKimi ni niau daiya no RING watasou\n\nKore kara nanzenkai tsumazuite\nSara ni nanmankai koronde mo\nKimi no GLASS no kutsu wa nuge wa shinai\n\n\"Minna! notteru?\nkonkai no Goro, nanka aidoru!\nsou! GROUP de wa... Majima JINGI!!\"\n\nAtarimae = (iko) takaramono sa\nChikyuu wa mawari hi wa nobori\nKimi wa hohoemu\n\nSunao ni I LOVE YOU! todokeyou\nKitto YOU LOVE ME! tsutawaru sa\nKimi ni niau GLASS no kutsu wo sagasou\n\n";
				__instance.enemyFiles[index2].displayVideo = NishikiBracken.MajimaAssets.LoadAsset<VideoClip>("cinderellaVideo");
				__instance.terminalNodes.allKeywords[num2].word = "majima";
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}