Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KoishiGhost v1.1.3
qqrz997.KoishiGhostGirl.dll
Decompiled 2 years agousing System; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using KoishiGhostGirl.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("qqrz997.KoishiGhostGirl")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3")] [assembly: AssemblyProduct("KoishiGhostGirl")] [assembly: AssemblyTitle("qqrz997.KoishiGhostGirl")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.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 KoishiGhostGirl { internal class Koishi { public static bool Inited; public static GameObject Mesh { get; private set; } public static AudioClip HeartbeatAudio { get; private set; } public static Material OriginalGirlMaterial { get; private set; } public Koishi() { Init(); } private void Init() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown try { AssetLoader assetLoader = new AssetLoader("KoishiGhostGirl.Resources.koishi"); Mesh = (GameObject)assetLoader.GetAssetFromBundle<GameObject>("Assets/Bundles/Koishi2/koishi.prefab"); HeartbeatAudio = (AudioClip)assetLoader.GetAssetFromBundle<AudioClip>("Assets/Bundles/Koishi2/heartbeatMusic.wav"); OriginalGirlMaterial = (Material)assetLoader.GetAssetFromBundle<Material>("Assets/Bundles/Koishi2/Materials/koishiUnlit.mat"); assetLoader.Unload(); Inited = true; } catch (Exception ex) { PluginLog.Error("Problem encountered when initializing koishi"); PluginLog.Error(ex.ToString()); } } } internal class PluginLog { internal static ManualLogSource Log { get; private set; } public PluginLog(ManualLogSource log) { Log = log; } public static void Error(string message) { Log.LogError((object)message); } public static void Info(string message) { Log.LogInfo((object)message); } public static void Debug(string message) { Log.LogDebug((object)message); } } [BepInPlugin("qqrz997.KoishiGhostGirl", "KoishiGhostGirl", "1.1.3")] public class Plugin : BaseUnityPlugin { public static Plugin Instance { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown new PluginLog(((BaseUnityPlugin)this).Logger); Instance = this; Harmony = new Harmony("qqrz997.KoishiGhostGirl"); new PluginConfig(); new Koishi(); ApplyPatches(); PluginLog.Info("qqrz997.KoishiGhostGirl v1.1.3 has loaded!"); } private void ApplyPatches() { Harmony? harmony = Harmony; if (harmony != null) { harmony.PatchAll(); } PluginLog.Debug("Finished patching!"); } } internal class PluginConfig { private ConfigEntry<bool> useOriginalShader; private ConfigEntry<bool> useOriginalSound; public static PluginConfig Instance { get; private set; } public bool UseOriginalShader { get { return useOriginalShader.Value; } set { useOriginalShader.Value = value; } } public bool UseOriginalSound { get { return useOriginalSound.Value; } set { useOriginalSound.Value = value; } } public PluginConfig() { Instance = this; useOriginalShader = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Shaders", "Use Original Shaders", false, "Enable this to make Koishi use the original lit shaders to give her the same \"glow-in-the-dark\" appearance as the Ghost Girl."); useOriginalSound = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Audio", "Use Original Audio", false, "Enable this to make Koishi use the original sound effects of the Ghost Girl"); } } public static class PluginInfo { public const string GUID = "qqrz997.KoishiGhostGirl"; public const string Name = "KoishiGhostGirl"; public const string Version = "1.1.3"; } public static class MyPluginInfo { public const string PLUGIN_GUID = "qqrz997.KoishiGhostGirl"; public const string PLUGIN_NAME = "KoishiGhostGirl"; public const string PLUGIN_VERSION = "1.1.3"; } } namespace KoishiGhostGirl.Utils { internal class AssetLoader { private readonly string bundleResourcePath; private AssetBundle bundle; public AssetLoader(string bundleResourcePath) { this.bundleResourcePath = bundleResourcePath; LoadBundle(); } private void LoadBundle() { bundle = AssetBundle.LoadFromMemory(ResourceLoading.LoadFromResource(bundleResourcePath)); if ((Object)(object)bundle != (Object)null) { PluginLog.Debug("Successfully loaded assetbundle from " + bundleResourcePath); } else { PluginLog.Error("Failed to load assetbundle from " + bundleResourcePath); } } public Object GetAssetFromBundle<T>(string assetPath) { AssetBundle obj = bundle; Object val = ((obj != null) ? obj.LoadAsset<Object>(assetPath) : null); if (val != (Object)null) { PluginLog.Debug($"loaded {typeof(T)} from bundle: {assetPath}"); return val; } PluginLog.Error($"couldn't load {typeof(T)} from bundle: {assetPath}"); return null; } public void Unload() { AssetBundle obj = bundle; if (obj != null) { obj.Unload(false); } } } internal class ResourceLoading { public static byte[] LoadFromResource(string resourcePath) { return GetResource(Assembly.GetCallingAssembly(), resourcePath); } private static byte[] GetResource(Assembly assembly, string resourcePath) { Stream manifestResourceStream = assembly.GetManifestResourceStream(resourcePath); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, (int)manifestResourceStream.Length); return array; } } } namespace KoishiGhostGirl.Patches { [HarmonyPatch(typeof(DressGirlAI))] internal class DressGirlAIPatch { private static PluginConfig config => PluginConfig.Instance; [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix(DressGirlAI __instance) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (Koishi.Inited) { PluginLog.Debug("Ghost girl spawned, replacing model"); SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)__instance).skinnedMeshRenderers; foreach (SkinnedMeshRenderer val in skinnedMeshRenderers) { ((Renderer)val).enabled = false; } Transform val2 = ((Component)__instance).transform.Find("DressGirlModel"); Transform val3 = val2.Find("AnimContainer").Find("metarig"); ((Object)val3).name = "old_metarig"; Renderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Renderer>(); foreach (Renderer val4 in componentsInChildren) { val4.enabled = false; } GameObject val5 = Object.Instantiate<GameObject>(Koishi.Mesh); val5.transform.SetParent(val2); val5.transform.localPosition = Vector3.zero; val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = Vector3.one; Transform val6 = val5.transform.Find("metarig"); val6.SetParent(val3.parent, true); ((Component)val6).transform.localScale = ((Component)val3).transform.localScale; ((Component)val6).transform.localRotation = ((Component)val3).transform.localRotation; ((Component)val6).transform.localPosition = ((Component)val3).transform.localPosition; SkinnedMeshRenderer component = ((Component)val5.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>(); component.rootBone = val6; ((Component)component).gameObject.tag = "DoNotSet"; if (!config.UseOriginalSound) { __instance.heartbeatMusic.clip = Koishi.HeartbeatAudio; __instance.heartbeatMusic.pitch = 1f; __instance.heartbeatMusic.Play(); } if (config.UseOriginalShader) { ((Renderer)component).material = Koishi.OriginalGirlMaterial; } ((EnemyAI)__instance).skinnedMeshRenderers[0] = component; ((EnemyAI)__instance).EnableEnemyMesh(false, true); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }