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 UnderCompany v1.0.3
patchers/UnderCompany.Language.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } public static class UnderCompanyLanguage { private static readonly ManualLogSource Log = Logger.CreateLogSource("UnderCompany"); public static IEnumerable<string> TargetDLLs { get; } = new string[0]; public static void Patch(AssemblyDefinition assembly) { } public static void Initialize() { try { string configPath = Paths.ConfigPath; Directory.CreateDirectory(configPath); string text = ReadMaster(Path.Combine(configPath, "UnderCompany.cfg")); string text2 = ((text == "Korean" || (text == "Auto" && CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ko")) ? "Korean" : "English"); string value = ((text == "Auto") ? "Auto" : text2); Set(Path.Combine(configPath, "hihi.flowey.language.cfg"), "General", "Language", value); Set(Path.Combine(configPath, "hihi__h.Muffet.cfg"), "Language", "Language", value); Set(Path.Combine(configPath, "jin.sans.figurine.scrap.cfg"), "General", "Language", text2); Set(Path.Combine(configPath, "hihi__h.NapstablookMonster.cfg"), "General", "Language", text2); Log.LogInfo((object)("UnderCompany language = " + text + " -> " + text2 + " (Flowey, Muffet, Sans, Napstablook)")); } catch (Exception ex) { Log.LogError((object)("UnderCompany language switch failed: " + ex)); } } private static string ReadMaster(string path) { if (!File.Exists(path)) { return "Auto"; } string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { Match match = Regex.Match(array[i], "^\\s*Language\\s*=\\s*(\\S+)"); if (match.Success) { string text = match.Groups[1].Value.Trim(); if (text.Equals("Korean", StringComparison.OrdinalIgnoreCase) || text == "한국어") { return "Korean"; } if (text.Equals("English", StringComparison.OrdinalIgnoreCase) || text == "영어") { return "English"; } return "Auto"; } } return "Auto"; } private static void Set(string path, string section, string key, string value) { List<string> list = (File.Exists(path) ? new List<string>(File.ReadAllLines(path)) : new List<string>()); int num = -1; int num2 = list.Count; for (int i = 0; i < list.Count; i++) { string text = list[i].Trim(); if (text.StartsWith("[") && text.EndsWith("]")) { if (num >= 0) { num2 = i; break; } if (text == "[" + section + "]") { num = i; } } } Regex regex = new Regex("^\\s*" + Regex.Escape(key) + "\\s*="); if (num >= 0) { for (int j = num + 1; j < num2; j++) { if (regex.IsMatch(list[j])) { list[j] = key + " = " + value; Write(path, list); return; } } list.Insert(num2, key + " = " + value); } else { if (list.Count > 0) { list.Add(""); } list.Add("[" + section + "]"); list.Add(""); list.Add(key + " = " + value); } Write(path, list); } private static void Write(string path, List<string> lines) { File.WriteAllText(path, string.Join(Environment.NewLine, lines) + Environment.NewLine, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); } }
plugins/Flowey/FLOWEY.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using GyeongJi.Flowey; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FLOWEY")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.72.0")] [assembly: AssemblyInformationalVersion("1.0.72")] [assembly: AssemblyProduct("FLOWEY")] [assembly: AssemblyTitle("FLOWEY")] [assembly: AssemblyVersion("1.0.72.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 GyeongJi.Flowey { [BepInPlugin("gyeongji.flowey.item", "FLOWEY", "1.0.72")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FloweyPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static AudioClip Music; internal static AudioClip DialogueVoice; internal static AudioClip EvilDialogueVoice; internal static AudioClip EvilLaugh; internal static AudioClip OmegaHitA; internal static AudioClip OmegaHitB; internal static AudioClip OmegaDeath; internal static AudioClip FlowerSink; internal static AudioClip OmegaEmergence; internal static AudioClip OmegaCrawl; internal static AudioClip PickupCurseLaugh; internal static FloweyPlugin Instance; private NetworkManager _netMessageManager; private const string BloomSpawnMessage = "hihi.flowey.bloom.v1"; private const string DialogueClickMessage = "hihi.flowey.dialog.click.v1"; private const string DialogueStateMessage = "hihi.flowey.dialog.state.v1"; private const string DebugSpawnMessage = "hihi.flowey.testspawn.v1"; private const string DebugValueMessage = "hihi.flowey.testvalue.v1"; private ConfigEntry<bool> _enableTestF7; private float _nextLocalTestKey; private float _nextTestValueSync; private readonly Dictionary<ulong, float> _debugSpawnCooldown = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, int> _debugScrapValues = new Dictionary<ulong, int>(); private readonly Dictionary<ulong, int> _waitingScrapValues = new Dictionary<ulong, int>(); private const string OmegaVariantMessage = "hihi.flowey.omega.variant.v2"; private const string OmegaSoundMessage = "hihi.flowey.omega.sfx.v1"; private const string PickupCurseMessage = "hihi.flowey.pickup.curse.v1"; private readonly HashSet<ulong> _omegaVariantIds = new HashSet<ulong>(); private readonly HashSet<ulong> _omegaDeadIds = new HashSet<ulong>(); private readonly Dictionary<ulong, ulong> _omegaFlowerSourceIds = new Dictionary<ulong, ulong>(); private readonly Dictionary<ulong, float> _omegaMorphAge = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, float> _omegaMorphAgeReceivedAt = new Dictionary<ulong, float>(); private float _nextOmegaBroadcast; internal static string AssetDir; internal static Texture2D PixelGlyphAtlas; internal static GameObject FloweyPrefab; internal static Item FloweyData; private InputAction _dialogueClickAction; private int _lastClickFrame = -1; private bool _pendingDialogueClick; private bool _leftMouseWasDown; private float _nextBloomVisualScan; private const string BloomEvilStageMessage = "hihi.flowey.evilstage.v1"; private readonly Dictionary<ulong, ulong> _evilStageOwner = new Dictionary<ulong, ulong>(); private readonly Dictionary<ulong, float> _evilStageTime = new Dictionary<ulong, float>(); internal static bool IsDialogueAuthority { get { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsListening) { return singleton.IsServer; } return true; } } private void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Instance = this; _enableTestF7 = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "EnableF7Spawn", true, "Allow F7 test spawning at the aimed position. Set false after testing; natural scrap spawns are unchanged."); try { new Harmony("gyeongji.flowey.omega.cadaver.v1").PatchAll(typeof(FloweyOmegaCadaverDeathPatch).Assembly); } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega Harmony patch failed (death cleanup may be unsafe): " + ex)); } _dialogueClickAction = new InputAction("FLOWEY_Click", (InputActionType)1, "<Mouse>/leftButton", (string)null, (string)null, (string)null); _dialogueClickAction.performed += OnDialogueClick; _dialogueClickAction.Enable(); try { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets"); if (!Directory.Exists(text)) { throw new DirectoryNotFoundException(text); } AssetDir = text; Music = FloweyAssets.LoadPcmWav(Path.Combine(text, "YourBestFriend.wav")); DialogueVoice = FloweyAssets.LoadPcmWav(Path.Combine(text, "FloweyDialogueBlip.wav")); EvilDialogueVoice = FloweyAssets.LoadPcmWav(Path.Combine(text, "FloweyEvilVoice.wav")); EvilLaugh = FloweyAssets.LoadPcmWav(Path.Combine(text, "FLOWEY_UserEvilLaugh.wav")); OmegaHitA = TryLoadOmegaClip(text, "FLOWEY_OmegaHit_A.wav"); OmegaHitB = TryLoadOmegaClip(text, "FLOWEY_OmegaHit_B.wav"); OmegaDeath = TryLoadOmegaClip(text, "FLOWEY_OmegaDeath.wav"); FlowerSink = TryLoadOmegaClip(text, "FLOWEY_SinkGroan.wav"); OmegaEmergence = TryLoadOmegaClip(text, "FLOWEY_OmegaEmergence.wav"); OmegaCrawl = TryLoadOmegaClip(text, "FLOWEY_OmegaCrawl.wav"); PickupCurseLaugh = TryLoadOmegaClip(text, "FLOWEY_PickupCurseLaugh.wav"); PixelGlyphAtlas = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(PixelGlyphAtlas, File.ReadAllBytes(Path.Combine(text, "FloweyPixelGlyphs.png")))) { throw new InvalidDataException("FLOWEY pixel alphabet could not be loaded"); } ((Texture)PixelGlyphAtlas).filterMode = (FilterMode)0; ((Texture)PixelGlyphAtlas).wrapMode = (TextureWrapMode)1; FloweyPrefab = NetworkPrefabs.CreateNetworkPrefab("GyeongJi_FLOWEY_Item"); FloweyPrefab.layer = LayerMask.NameToLayer("Props"); if (FloweyPrefab.layer < 0) { FloweyPrefab.layer = 6; } try { FloweyPrefab.tag = "PhysicsProp"; } catch { } FloweyData = ScriptableObject.CreateInstance<Item>(); ((Object)FloweyData).name = "FLOWEY"; FloweyData.itemName = "FLOWEY"; FloweyData.itemId = 0; FloweyData.isScrap = true; FloweyData.minValue = 100; FloweyData.maxValue = 375; FloweyData.weight = 1f; FloweyData.twoHanded = false; FloweyData.twoHandedAnimation = false; FloweyData.itemSpawnsOnGround = true; FloweyData.canBeGrabbedBeforeGameStart = true; FloweyData.isConductiveMetal = false; FloweyData.requiresBattery = false; FloweyData.batteryUsage = 0f; FloweyData.toolTips = new string[1] { "Toggle FLOWEY music : [LMB]" }; FloweyData.verticalOffset = 0f; FloweyData.rotationOffset = new Vector3(0f, 180f, -85f); FloweyData.positionOffset = new Vector3(0.02f, -0.04f, 0.11f); FloweyData.restingRotation = Vector3.zero; FloweyData.allowDroppingAheadOfPlayer = true; FloweyData.itemIcon = FloweyAssets.LoadIcon(Path.Combine(text, "flowey_icon.png")); FloweyData.spawnPrefab = FloweyPrefab; FloweyItem floweyItem = FloweyPrefab.AddComponent<FloweyItem>(); ((GrabbableObject)floweyItem).itemProperties = FloweyData; ((GrabbableObject)floweyItem).insertedBattery = null; ((GrabbableObject)floweyItem).grabbable = true; ((GrabbableObject)floweyItem).grabbableToEnemies = true; ((GrabbableObject)floweyItem).isInFactory = true; BoxCollider obj2 = FloweyPrefab.AddComponent<BoxCollider>(); obj2.center = new Vector3(0f, 0.4f, 0f); obj2.size = new Vector3(0.75f, 0.8f, 0.48f); ((Collider)obj2).isTrigger = false; GameObject val = new GameObject("FLOWEY_ScanNode"); val.transform.SetParent(FloweyPrefab.transform, false); val.transform.localPosition = new Vector3(0f, 0.45f, 0f); int num = LayerMask.NameToLayer("ScanNode"); val.layer = ((num >= 0) ? num : 22); BoxCollider obj3 = val.AddComponent<BoxCollider>(); obj3.center = Vector3.zero; obj3.size = new Vector3(0.92f, 1.1f, 0.78f); ((Collider)obj3).isTrigger = true; ScanNodeProperties obj4 = val.AddComponent<ScanNodeProperties>(); obj4.headerText = "FLOWEY"; obj4.subText = "Value: "; obj4.nodeType = 2; obj4.minRange = 1; obj4.maxRange = 13; obj4.requiresLineOfSight = true; obj4.scrapValue = 0; obj4.creatureScanID = -1; AudioSource obj5 = FloweyPrefab.AddComponent<AudioSource>(); obj5.playOnAwake = false; obj5.spatialBlend = 1f; obj5.minDistance = 1.5f; obj5.maxDistance = 18f; obj5.rolloffMode = (AudioRolloffMode)1; obj5.loop = true; obj5.volume = 0.5f; obj5.clip = Music; GameObject val2 = FloweyAssets.LoadModel(Path.Combine(text, "FLOWEY.fm1"), text); val2.transform.SetParent(FloweyPrefab.transform, false); ((Object)val2).name = "FLOWEY_Model"; floweyItem.Visual = val2.transform.Find("FLOWEY_Flower"); floweyItem.GroundTemplate = val2.transform.Find("FLOWEY_Ground"); if ((Object)(object)floweyItem.Visual == (Object)null || (Object)(object)floweyItem.GroundTemplate == (Object)null) { throw new InvalidDataException("FLOWEY model is missing flower or ground meshes"); } floweyItem.GroundTemplate.localScale = new Vector3(1.33f, 1f, 1.38f); ((Component)floweyItem.GroundTemplate).gameObject.SetActive(false); GameObject val3 = FloweyAssets.LoadModel(Path.Combine(text, "FLOWEY_SpeechBubble.fm1"), text); ((Object)val3).name = "FLOWEY_SpeechBubble"; val3.transform.SetParent(FloweyPrefab.transform, false); floweyItem.SpeechBubble = val3.transform; GameObject val4 = new GameObject("FLOWEY_PixelDialogueText"); val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = new Vector3(0f, 0.012f, 0.071f); val4.transform.localRotation = Quaternion.identity; FloweyPixelDialogue floweyPixelDialogue = val4.AddComponent<FloweyPixelDialogue>(); floweyPixelDialogue.Initialize(PixelGlyphAtlas); floweyItem.PixelDialogue = floweyPixelDialogue; val3.SetActive(false); Items.RegisterScrap(FloweyData, 5, (LevelTypes)(-1)); Log.LogInfo((object)"FLOWEY v1.0.71: multiplayer dialogue rendered for every nearby local camera; reliable host click/state with diagnostics; battery-free unlimited music toggle. FLOWEY_62 combat/transform retained."); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("FLOWEY initialization failed: " + ex2)); } } private static AudioClip TryLoadOmegaClip(string dir, string name) { string path = Path.Combine(dir, name); if (!File.Exists(path)) { Log.LogWarning((object)("FLOWEY Omega SFX not supplied: " + name + " (audio event hook is ready)")); return null; } try { AudioClip val = FloweyAssets.LoadPcmWav(path); Log.LogInfo((object)("FLOWEY Omega SFX loaded " + name + " (" + val.length.ToString("F2") + "s)")); return val; } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega SFX invalid: " + name + " / " + ex.Message)); return null; } } private void OnDialogueClick(CallbackContext context) { if (((CallbackContext)(ref context)).performed) { _pendingDialogueClick = true; } } private void OnGUI() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current != null && (int)current.type == 0 && current.button == 0) { _pendingDialogueClick = true; } } private void OnDestroy() { if ((Object)(object)_netMessageManager != (Object)null && _netMessageManager.CustomMessagingManager != null) { try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.testspawn.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.testvalue.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.evilstage.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.dialog.click.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.dialog.state.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.bloom.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.omega.variant.v2"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.omega.sfx.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.pickup.curse.v1"); } catch { } _netMessageManager = null; _omegaVariantIds.Clear(); _omegaDeadIds.Clear(); } _evilStageOwner.Clear(); _evilStageTime.Clear(); if (_dialogueClickAction != null) { _dialogueClickAction.performed -= OnDialogueClick; _dialogueClickAction.Disable(); _dialogueClickAction.Dispose(); _dialogueClickAction = null; } } private void RegisterBloomNetworkMessages() { //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { _netMessageManager = null; } if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null || (Object)(object)_netMessageManager == (Object)(object)singleton) { return; } if ((Object)(object)_netMessageManager != (Object)null) { try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.testspawn.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.testvalue.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.evilstage.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.dialog.click.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.dialog.state.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.bloom.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.omega.variant.v2"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.omega.sfx.v1"); } catch { } try { _netMessageManager.CustomMessagingManager.UnregisterNamedMessageHandler("hihi.flowey.pickup.curse.v1"); } catch { } } _omegaVariantIds.Clear(); _omegaDeadIds.Clear(); _omegaMorphAge.Clear(); _omegaMorphAgeReceivedAt.Clear(); _waitingScrapValues.Clear(); _debugScrapValues.Clear(); _debugSpawnCooldown.Clear(); _evilStageOwner.Clear(); _evilStageTime.Clear(); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.evilstage.v1", new HandleNamedMessageDelegate(OnBloomEvilStage)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.dialog.click.v1", new HandleNamedMessageDelegate(OnDialogueClickRequest)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.dialog.state.v1", new HandleNamedMessageDelegate(OnDialogueStateMessage)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.bloom.v1", new HandleNamedMessageDelegate(OnBloomSpawnRequest)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.testspawn.v1", new HandleNamedMessageDelegate(OnDebugSpawnRequest)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.testvalue.v1", new HandleNamedMessageDelegate(OnDebugValueMessage)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.omega.variant.v2", new HandleNamedMessageDelegate(OnOmegaVariantMessage)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.omega.sfx.v1", new HandleNamedMessageDelegate(OnOmegaSoundMessage)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.pickup.curse.v1", new HandleNamedMessageDelegate(OnPickupCurseMessage)); _netMessageManager = singleton; _nextOmegaBroadcast = 0f; Log.LogInfo((object)"FLOWEY Omega: variant network handlers registered"); } private void OnOmegaVariantMessage(ulong senderId, FastBufferReader reader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || senderId != 0L) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); ulong num2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); _omegaMorphAge[num] = Mathf.Max(0f, num3); _omegaMorphAgeReceivedAt[num] = Time.time; _omegaVariantIds.Add(num); if (b != 0) { _omegaDeadIds.Add(num); } if (num2 != ulong.MaxValue) { _omegaFlowerSourceIds[num] = num2; } AttachOmegaVariant(num); } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega marker read error: " + ex.Message)); } } private void OnOmegaSoundMessage(ulong senderId, FastBufferReader reader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || senderId != 0L) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); if (b == 3) { _omegaDeadIds.Add(num); } PlayOmegaSoundOnThisClient(num, b); } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega SFX packet: " + ex.Message)); } } internal unsafe static void PlayNegativePickupLaugh(FloweyItem flower) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)flower == (Object)null) { return; } flower.PlayPickupCurseSoundLocal(); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)Instance == (Object)null || (Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null || (Object)(object)((NetworkBehaviour)flower).NetworkObject == (Object)null || !((NetworkBehaviour)flower).NetworkObject.IsSpawned) { return; } try { Instance.RegisterBloomNetworkMessages(); ulong networkObjectId = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; if (singleton.IsServer) { Instance.BroadcastPickupCurse(networkObjectId, singleton.LocalClientId); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.pickup.curse.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY pickup sound network send failed: " + ex.Message)); } } private void OnPickupCurseMessage(ulong senderId, FastBufferReader reader) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return; } try { ulong id = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); if (singleton.IsServer) { if (senderId != 0L && IsLiveFlower(id)) { PlayPickupCurseOnClient(id); BroadcastPickupCurse(id, senderId); } } else if (senderId == 0L) { PlayPickupCurseOnClient(id); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY pickup sound packet failed: " + ex.Message)); } } private static bool IsLiveFlower(ulong id) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.SpawnManager == null) { return false; } if (singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { return (Object)(object)((Component)value).GetComponent<FloweyItem>() != (Object)null; } return false; } private static void PlayPickupCurseOnClient(ulong id) { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.SpawnManager != null && singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) && !((Object)(object)value == (Object)null)) { FloweyItem component = ((Component)value).GetComponent<FloweyItem>(); if ((Object)(object)component != (Object)null) { component.PlayPickupCurseSoundLocal(); } } } private unsafe void BroadcastPickupCurse(ulong id, ulong originalPicker) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == originalPicker || connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.pickup.curse.v1", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY pickup sound broadcast failed: " + ex.Message)); } } } private void PlayOmegaSoundOnThisClient(ulong objectId, byte kind) { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.SpawnManager != null && singleton.SpawnManager.SpawnedObjects.TryGetValue(objectId, out var value) && !((Object)(object)value == (Object)null)) { FloweyOmegaCadaverVariant componentInChildren = ((Component)value).GetComponentInChildren<FloweyOmegaCadaverVariant>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.PlayOmegaSound(kind); } } } internal unsafe static void BroadcastOmegaSound(ulong objectId, byte kind) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || singleton.CustomMessagingManager == null) { return; } if (kind == 3) { Instance._omegaDeadIds.Add(objectId); } Instance.PlayOmegaSoundOnThisClient(objectId, kind); FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(9, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref objectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref kind, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.omega.sfx.v1", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega SFX broadcast: " + ex.Message)); } } } internal static void MarkOmegaVariant(NetworkObject networkObject, ulong flowerId) { if (!((Object)(object)Instance == (Object)null) && !((Object)(object)networkObject == (Object)null) && networkObject.IsSpawned) { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)null) && singleton.IsServer) { Instance._omegaVariantIds.Add(networkObject.NetworkObjectId); Instance._omegaFlowerSourceIds[networkObject.NetworkObjectId] = flowerId; Instance.AttachOmegaVariant(networkObject.NetworkObjectId); Instance.SendOmegaVariantMarker(networkObject.NetworkObjectId); } } } private unsafe void SendOmegaVariantMarker(ulong objectId) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.IsServer || singleton.CustomMessagingManager == null) { return; } if (!_omegaFlowerSourceIds.TryGetValue(objectId, out var value)) { value = ulong.MaxValue; } float num = 0f; if (singleton.SpawnManager != null && singleton.SpawnManager.SpawnedObjects.TryGetValue(objectId, out var value2) && (Object)(object)value2 != (Object)null) { FloweyOmegaCadaverVariant componentInChildren = ((Component)value2).GetComponentInChildren<FloweyOmegaCadaverVariant>(true); if ((Object)(object)componentInChildren != (Object)null) { num = componentInChildren.MorphElapsed; } } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref objectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref value, default(ForPrimitives)); byte b = (_omegaDeadIds.Contains(objectId) ? ((byte)1) : ((byte)0)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref num, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.omega.variant.v2", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Omega marker to client " + connectedClientsId + ": " + ex.Message)); } } } private void AttachOmegaVariant(ulong objectId) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.SpawnManager == null || !singleton.SpawnManager.SpawnedObjects.TryGetValue(objectId, out var value) || (Object)(object)value == (Object)null) { return; } CadaverBloomAI componentInChildren = ((Component)value).GetComponentInChildren<CadaverBloomAI>(true); if ((Object)(object)componentInChildren == (Object)null) { return; } FloweyOmegaCadaverVariant floweyOmegaCadaverVariant = ((Component)componentInChildren).GetComponent<FloweyOmegaCadaverVariant>(); if ((Object)(object)floweyOmegaCadaverVariant == (Object)null) { floweyOmegaCadaverVariant = ((Component)componentInChildren).gameObject.AddComponent<FloweyOmegaCadaverVariant>(); } floweyOmegaCadaverVariant.Initialize(componentInChildren, objectId); ulong value2; if (_omegaDeadIds.Contains(objectId)) { if (!floweyOmegaCadaverVariant.DeathSequenceStarted) { floweyOmegaCadaverVariant.RestoreCorpseFromNetwork(); } } else if (_omegaFlowerSourceIds.TryGetValue(objectId, out value2)) { float value3 = 0f; float value4 = Time.time; _omegaMorphAge.TryGetValue(objectId, out value3); if (!_omegaMorphAgeReceivedAt.TryGetValue(objectId, out value4)) { value4 = Time.time; } floweyOmegaCadaverVariant.BeginMetamorphosis(value2, Mathf.Min(6.85f, value3 + Mathf.Max(0f, Time.time - value4))); } } private void MaintainOmegaVariantNetwork() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.SpawnManager == null || Time.time < _nextBloomVisualScan) { return; } _nextBloomVisualScan = Time.time + 0.6f; List<ulong> list = new List<ulong>(); foreach (ulong omegaVariantId in _omegaVariantIds) { if (!singleton.SpawnManager.SpawnedObjects.TryGetValue(omegaVariantId, out var value) || (Object)(object)value == (Object)null) { if (singleton.IsServer) { list.Add(omegaVariantId); } } else { AttachOmegaVariant(omegaVariantId); } } foreach (ulong item in list) { _omegaVariantIds.Remove(item); _omegaFlowerSourceIds.Remove(item); _omegaDeadIds.Remove(item); _omegaMorphAge.Remove(item); _omegaMorphAgeReceivedAt.Remove(item); } if (!singleton.IsServer || !(Time.time >= _nextOmegaBroadcast)) { return; } _nextOmegaBroadcast = Time.time + 4f; foreach (ulong omegaVariantId2 in _omegaVariantIds) { SendOmegaVariantMarker(omegaVariantId2); } } private void OnDialogueClickRequest(ulong senderId, FastBufferReader reader) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { return; } try { ulong id = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); FloweyItem floweyItem = FloweyItem.FindFlowerByNetworkId(id); if ((Object)(object)floweyItem == (Object)null) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.actualClientId == senderId && val.isPlayerControlled && !val.isPlayerDead) { if (!floweyItem.ServerAdvanceDialogue(val)) { Log.LogInfo((object)("FLOWEY dialogue: host rejected click from " + senderId + " (out of range, held or in transformation)")); } break; } } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY synchronized dialogue click: " + ex.Message)); } } private void OnDialogueStateMessage(ulong senderId, FastBufferReader reader) { //IL_002a: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0063: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.IsServer || senderId != 0L) { return; } try { ulong id = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); uint serial = default(uint); ((FastBufferReader)(ref reader)).ReadValueSafe<uint>(ref serial, default(ForPrimitives)); int line = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref line, default(ForPrimitives)); int glyphs = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref glyphs, default(ForPrimitives)); byte flags = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref flags, default(ForPrimitives)); float threat = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref threat, default(ForPrimitives)); FloweyItem floweyItem = FloweyItem.FindFlowerByNetworkId(id); if ((Object)(object)floweyItem != (Object)null) { floweyItem.ApplyHostDialogueSnapshot(serial, line, glyphs, flags, threat); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY synchronized dialogue state: " + ex.Message)); } } internal unsafe static bool RequestDialogueClick(FloweyItem flower) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)flower == (Object)null || (Object)(object)((NetworkBehaviour)flower).NetworkObject == (Object)null || !((NetworkBehaviour)flower).NetworkObject.IsSpawned || (Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.IsServer || singleton.CustomMessagingManager == null) { return false; } try { Instance.RegisterBloomNetworkMessages(); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ulong networkObjectId = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.dialog.click.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } return true; } catch (Exception ex) { Log.LogWarning((object)("FLOWEY dialogue click network send: " + ex.Message)); return false; } } internal unsafe static void BroadcastDialogue(FloweyItem flower, uint sequence, int line, int glyphs, byte flags, float threat) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0107: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)flower == (Object)null || (Object)(object)((NetworkBehaviour)flower).NetworkObject == (Object)null || !((NetworkBehaviour)flower).NetworkObject.IsSpawned || (Object)(object)singleton == (Object)null || !singleton.IsServer || !singleton.IsListening || singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(48, (Allocator)2, -1); try { ulong networkObjectId = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<uint>(ref sequence, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref line, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref glyphs, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref flags, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref threat, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.dialog.state.v1", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY dialogue send: " + ex.Message)); } } } private void OnBloomEvilStage(ulong senderId, FastBufferReader reader) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer) { return; } try { ulong flowerId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref flowerId, default(ForPrimitives)); RegisterEvilStart(senderId, flowerId); } catch (Exception ex) { Log.LogWarning((object)("FLOWEY evil stage request: " + ex.Message)); } } private void RegisterEvilStart(ulong senderId, ulong flowerId) { if (FloweyItem.IsNearLivingPlayerAndFlower(senderId, flowerId, 7f)) { _evilStageOwner[flowerId] = senderId; _evilStageTime[flowerId] = Time.time; Log.LogInfo((object)("FLOWEY evil auto dialogue authorized on host for flower " + flowerId)); } } internal unsafe static void NotifyEvilAutoStarted(FloweyItem flower) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)flower == (Object)null || (Object)(object)((NetworkBehaviour)flower).NetworkObject == (Object)null) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || (Object)(object)Instance == (Object)null) { return; } ulong networkObjectId = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; if (singleton.IsServer) { Instance.RegisterEvilStart(flower.DialogueControllerId, networkObjectId); return; } try { if (singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.evilstage.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY evil-stage signal failed: " + ex.Message)); } } internal static bool IsEvilSpawnAuthorized(ulong senderId, ulong flowerId) { if ((Object)(object)Instance == (Object)null) { return false; } if (Instance._evilStageOwner.TryGetValue(flowerId, out var value) && Instance._evilStageTime.TryGetValue(flowerId, out var value2) && senderId == value && Time.time - value2 >= 5f) { return Time.time - value2 < 1800f; } return false; } private void OnBloomSpawnRequest(ulong senderId, FastBufferReader reader) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer) { return; } try { ulong networkId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref networkId, default(ForPrimitives)); FloweyItem.TryServerBloomFromRequest(senderId, networkId); } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Bloom request rejected: " + ex.Message)); } } internal unsafe static bool RequestBloomOnServer(FloweyItem flower) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || (Object)(object)flower == (Object)null || (Object)(object)((NetworkBehaviour)flower).NetworkObject == (Object)null) { return false; } if (singleton.IsServer) { ulong networkObjectId = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; if (!Instance._evilStageOwner.TryGetValue(networkObjectId, out var value) || !IsEvilSpawnAuthorized(value, networkObjectId)) { return false; } PlayerControllerB player = null; if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.allPlayerScripts != null) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.playerClientId == value && val.isPlayerControlled && !val.isPlayerDead) { player = val; break; } } } return flower.TrySpawnCadaverBloom(player); } try { if (singleton.CustomMessagingManager == null) { return false; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(8, (Allocator)2, -1); try { ulong networkObjectId2 = ((NetworkBehaviour)flower).NetworkObject.NetworkObjectId; ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId2, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.bloom.v1", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } return true; } catch (Exception ex) { Log.LogWarning((object)("FLOWEY Bloom network request failed: " + ex.Message)); return false; } } private void TryHandleF7TestSpawn(PlayerControllerB player) { //Discarded unreachable code: IL_00c7, IL_00d2, IL_0169 Keyboard current = Keyboard.current; } private static Vector3 ChooseTestSpawnPosition(PlayerControllerB player) { //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: 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_003f: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00d2: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018e: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)player.gameplayCamera != (Object)null) ? ((Component)player.gameplayCamera).transform : ((Component)player).transform); Vector3 val2 = val.position + val.forward * 4f; try { RaycastHit[] array = Physics.RaycastAll(val.position, val.forward, 120f, -1, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !(((RaycastHit)(ref val3)).distance < 0.45f) && !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null)) { val2 = ((RaycastHit)(ref val3)).point + ((RaycastHit)(ref val3)).normal * 0.27f; break; } } RaycastHit[] array3 = Physics.RaycastAll(val2 + Vector3.up * 1.5f, Vector3.down, 8f, -1, (QueryTriggerInteraction)1); Array.Sort(array3, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); array2 = array3; for (int num = 0; num < array2.Length; num++) { RaycastHit val4 = array2[num]; if (!((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null) && !(((RaycastHit)(ref val4)).normal.y < 0.55f) && !((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null)) { val2 = ((RaycastHit)(ref val4)).point + Vector3.up * 0.07f; break; } } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY F7 ground ray failed: " + ex.Message)); } return val2; } private static void ShowDebugTip(string text) { try { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("FLOWEY TEST", text, false, false, "LC_Tip1"); } } catch { } } private void OnDebugSpawnRequest(ulong senderId, FastBufferReader reader) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_005a: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || _enableTestF7 == null || !_enableTestF7.Value) { return; } try { float num = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num, default(ForPrimitives)); float num2 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num2, num3); PlayerControllerB val2 = null; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if ((Object)(object)val3 != (Object)null && val3.actualClientId == senderId && !val3.isPlayerDead) { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null || !IsFinite(val.x) || !IsFinite(val.y) || !IsFinite(val.z) || Vector3.Distance(((Component)val2).transform.position, val) > 125f) { Log.LogWarning((object)("FLOWEY F7: rejected out-of-range/unknown client " + senderId)); } else { SpawnTestFlowerOnServer(senderId, val); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY F7 packet rejected: " + ex.Message)); } } private static bool IsFinite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private unsafe bool SpawnTestFlowerOnServer(ulong senderId, Vector3 pos) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0115: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || !singleton.IsListening || (Object)(object)FloweyPrefab == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } if (_debugSpawnCooldown.TryGetValue(senderId, out var value) && Time.time < value) { return false; } _debugSpawnCooldown[senderId] = Time.time + 0.75f; GameObject val = null; try { val = Object.Instantiate<GameObject>(FloweyPrefab, pos, Quaternion.identity); ((Object)val).name = "FLOWEY_F7_TestScrap"; val.SetActive(true); FloweyItem component = val.GetComponent<FloweyItem>(); NetworkObject component2 = val.GetComponent<NetworkObject>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { throw new InvalidOperationException("FLOWEY prefab missing GrabbableObject / NetworkObject"); } int num = Random.Range(40, 150); ((GrabbableObject)component).SetScrapValue(num); component2.Spawn(false); _debugScrapValues[component2.NetworkObjectId] = num; SendDebugValue(singleton, component2.NetworkObjectId, num); ManualLogSource log = Log; string[] obj = new string[8] { "FLOWEY F7 spawned test scrap at ", null, null, null, null, null, null, null }; Vector3 val2 = pos; obj[1] = ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString(); obj[2] = " value="; obj[3] = num.ToString(); obj[4] = " sender="; obj[5] = senderId.ToString(); obj[6] = " object="; obj[7] = component2.NetworkObjectId.ToString(); log.LogInfo((object)string.Concat(obj)); return true; } catch (Exception ex) { Log.LogError((object)("FLOWEY F7 test spawn failed: " + ex)); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } return false; } } private void OnDebugValueMessage(ulong senderId, FastBufferReader reader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || senderId != 0L) { return; } try { ulong key = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (num >= 0 && num <= 9999) { _waitingScrapValues[key] = num; } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY test scrap sync: " + ex.Message)); } } private unsafe static void SendDebugValue(NetworkManager net, ulong id, int value) { //IL_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) if ((Object)(object)net == (Object)null || !net.IsServer || net.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in net.ConnectedClientsIds) { if (connectedClientsId == net.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(12, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref value, default(ForPrimitives)); net.CustomMessagingManager.SendNamedMessage("hihi.flowey.testvalue.v1", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { Log.LogWarning((object)("FLOWEY test value broadcast: " + ex.Message)); } } } private void MaintainDebugTestValues() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.SpawnManager == null) { return; } List<ulong> list = new List<ulong>(); foreach (KeyValuePair<ulong, int> waitingScrapValue in _waitingScrapValues) { if (singleton.SpawnManager.SpawnedObjects.TryGetValue(waitingScrapValue.Key, out var value) && !((Object)(object)value == (Object)null)) { FloweyItem component = ((Component)value).GetComponent<FloweyItem>(); if ((Object)(object)component != (Object)null) { ((GrabbableObject)component).SetScrapValue(waitingScrapValue.Value); } list.Add(waitingScrapValue.Key); } } foreach (ulong item in list) { _waitingScrapValues.Remove(item); } if (!singleton.IsServer || Time.time < _nextTestValueSync) { return; } _nextTestValueSync = Time.time + 4f; List<ulong> list2 = new List<ulong>(); foreach (KeyValuePair<ulong, int> debugScrapValue in _debugScrapValues) { if (!singleton.SpawnManager.SpawnedObjects.TryGetValue(debugScrapValue.Key, out var value2) || (Object)(object)value2 == (Object)null) { list2.Add(debugScrapValue.Key); } else { SendDebugValue(singleton, debugScrapValue.Key, debugScrapValue.Value); } } foreach (ulong item2 in list2) { _debugScrapValues.Remove(item2); } } private void Update() { RegisterBloomNetworkMessages(); MaintainOmegaVariantNetwork(); MaintainDebugTestValues(); PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); TryHandleF7TestSpawn(val); Mouse current = Mouse.current; bool flag = current != null && current.leftButton.isPressed; bool num = _pendingDialogueClick || (flag && !_leftMouseWasDown) || (current != null && current.leftButton.wasPressedThisFrame) || (_dialogueClickAction != null && _dialogueClickAction.WasPressedThisFrame()); _pendingDialogueClick = false; _leftMouseWasDown = flag; if (!num || !((Object)(object)val != (Object)null) || _lastClickFrame == Time.frameCount) { return; } _lastClickFrame = Time.frameCount; FloweyItem floweyItem = val.currentlyHeldObjectServer as FloweyItem; if ((Object)(object)floweyItem != (Object)null) { _ = ((GrabbableObject)floweyItem).isHeld; if (!((GrabbableObject)floweyItem).isPocketed) { floweyItem.TryToggleMusic(); return; } } bool flag2 = FloweyItem.TryAdvanceClosestConversation(val); Log.LogInfo((object)(flag2 ? "FLOWEY LMB: dialogue click handled" : "FLOWEY LMB: no eligible FLOWEY nearby (move within 3m)")); } } public sealed class FloweyPixelDialogue : MonoBehaviour { private const string Glyphs = "반가워.내이름은플라위노란꽃야!나를당장집으로데려줘헤뭐해?어서날e키봐친구,니까다시보자고알았지난치는거너무뇌아식인을눈채있던응그저괴롭히싶었뿐죽"; private const int GlyphPixelSize = 28; private const int AtlasPixelSize = 56; private Texture2D _glyphAtlas; private Mesh _mesh; private int _lastLine = -1; private int _lastLetters = -1; private bool _lastCorrected; private bool _ready; private bool _shakeEnabled; private readonly List<int> _shakeStarts = new List<int>(); private readonly List<int> _shakeEnds = new List<int>(); private Vector3[] _basePositions; private Vector3[] _shakenPositions; private float _nextShakeAt; public void Initialize(Texture2D atlas) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) _glyphAtlas = atlas; MeshFilter val = ((Component)this).GetComponent<MeshFilter>(); if ((Object)(object)val == (Object)null) { val = ((Component)this).gameObject.AddComponent<MeshFilter>(); } MeshRenderer val2 = ((Component)this).GetComponent<MeshRenderer>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)this).gameObject.AddComponent<MeshRenderer>(); } _mesh = new Mesh(); ((Object)_mesh).name = "FLOWEY_BlockPixelText"; val.sharedMesh = _mesh; Shader obj = Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Color") ?? Shader.Find("HDRP/Lit") ?? Shader.Find("Standard"); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("FLOWEY text shader missing"); } Material val3 = new Material(obj); ((Object)val3).name = "FLOWEY_PixelText_Black"; SetUnlitColor(val3, new Color(0.025f, 0.025f, 0.025f, 1f)); Material val4 = new Material(obj); ((Object)val4).name = "FLOWEY_PixelText_Yellow"; SetUnlitColor(val4, new Color(0.88f, 0.6f, 0f, 1f)); ((Renderer)val2).sharedMaterials = (Material[])(object)new Material[2] { val3, val4 }; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; _ready = true; _lastLine = -1; SetDialogue(0, 0); } private static void SetUnlitColor(Material mat, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) mat.color = color; if (mat.HasProperty("_BaseColor")) { mat.SetColor("_BaseColor", color); } if (mat.HasProperty("_UnlitColor")) { mat.SetColor("_UnlitColor", color); } if (mat.HasProperty("_CullMode")) { mat.SetFloat("_CullMode", 0f); } if (mat.HasProperty("_Cull")) { mat.SetFloat("_Cull", 0f); } } public void SetDialogue(int line, int visible, bool corrected = false) { if (!_ready || (Object)(object)_mesh == (Object)null || (_lastLine == line && _lastLetters == visible && _lastCorrected == corrected)) { return; } _lastLine = line; _lastLetters = visible; _lastCorrected = corrected; List<Vector3> list = new List<Vector3>(); _shakeStarts.Clear(); _shakeEnds.Clear(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); switch (line) { case 0: AddLine("반가워.", visible, 0, 0f, 0.077f, 0.091f, -1, 0, list, list2, list3); break; case 1: AddLine("내 이름은", visible, 0, 0.034f, 0.069f, 0.066f, -1, 0, list, list2, list3); AddLine("플라위.", visible, 6, -0.034f, 0.069f, 0.066f, 0, 3, list, list2, list3); break; case 2: AddLine("노란 꽃", visible, 0, 0.034f, 0.069f, 0.066f, 0, 2, list, list2, list3); AddLine("플라위야!!", visible, 5, -0.034f, 0.067f, 0.066f, 0, 3, list, list2, list3); break; case 3: AddLine("나를 당장", visible, 0, 0.034f, 0.067f, 0.064f, -1, 0, list, list2, list3); AddLine("집으로 데려가줘.", visible, 6, -0.034f, 0.05f, 0.064f, -1, 0, list, list2, list3); break; case 4: AddLine("헤 헤 헤 ...", visible, 0, 0f, 0.052f, 0.086f, -1, 0, list, list2, list3); break; case 5: case 8: case 12: case 16: AddLine(". . .", visible, 0, 0f, 0.078f, 0.086f, -1, 0, list, list2, list3); break; case 6: AddLine("뭐해 ?", visible, 0, 0f, 0.078f, 0.086f, -1, 0, list, list2, list3); break; case 7: AddLine("어서 날 집으로", visible, 0, 0.034f, 0.056f, 0.063f, -1, 0, list, list2, list3); AddLine("데려가줘.", visible, 8, -0.034f, 0.069f, 0.063f, -1, 0, list, list2, list3); break; case 9: AddLine("e 키로", visible, 0, 0.034f, 0.08f, 0.067f, -1, 0, list, list2, list3); AddLine("날 집어.", visible, 5, -0.034f, 0.073f, 0.067f, -1, 0, list, list2, list3); break; case 10: AddLine("이봐 친구,", visible, 0, 0.034f, 0.068f, 0.065f, -1, 0, list, list2, list3); AddLine("집으라니까?", visible, 7, -0.034f, 0.061f, 0.065f, -1, 0, list, list2, list3); break; case 11: AddLine("다시 해보자고", visible, 0, 0.034f, 0.058f, 0.065f, -1, 0, list, list2, list3); AddLine("알았지 ?", visible, 8, -0.034f, 0.073f, 0.065f, -1, 0, list, list2, list3); break; case 13: AddLine("장난치는거야?", visible, 0, 0f, 0.059f, 0.087f, -1, 0, list, list2, list3); break; case 14: AddLine("너 무뇌아니?", visible, 0, 0f, 0.066f, 0.087f, -1, 0, list, list2, list3); break; case 15: AddLine("날 집어. 집으라고.", visible, 0, 0.034f, 0.042f, 0.066f, -1, 0, list, list2, list3); AddLine(corrected ? "플라위를." : "식인꽃을.", visible, 12, -0.034f, 0.074f, 0.066f, -1, 0, list, list2, list3); break; case 17: AddLine("눈치채고", visible, 0, 0.034f, 0.067f, 0.065f, -1, 0, list, list2, list3); AddLine("있던거지?", visible, 5, -0.034f, 0.064f, 0.065f, -1, 0, list, list2, list3); break; case 18: AddLine("응?", visible, 0, 0f, 0.08f, 0.088f, -1, 0, list, list2, list3); break; case 19: AddLine("그저 날 괴롭히고", visible, 0, 0.034f, 0.05f, 0.063f, -1, 0, list, list2, list3); AddLine("싶었을 뿐이었어.", visible, 10, -0.034f, 0.055f, 0.063f, -1, 0, list, list2, list3); break; case 20: AddLine("죽 어.", visible, 0, 0f, 0.113f, 0.108f, -1, 0, list, list2, list3); break; } if (line >= 0 && line <= 16 && visible >= FloweyItem.DialogueLines[line].Length) { if (line == 0) { AddLine(" 좌클릭으로 계속", 999, 0, -0.08f, 0.042f, 0.042f, -1, 0, list, list2, list3); } else if (((int)(Time.time * 2.5f) & 1) == 0) { AddLine(" ▼", 999, 0, -0.086f, 0.08f, 0.08f, -1, 0, list, list2, list3); } } _mesh.Clear(); _mesh.SetVertices(list); _mesh.subMeshCount = 2; _mesh.SetTriangles(list2, 0); _mesh.SetTriangles(list3, 1); _mesh.RecalculateBounds(); _basePositions = list.ToArray(); _shakenPositions = list.ToArray(); _nextShakeAt = 0f; } public void SetShaking(bool active) { if (_shakeEnabled != active) { _shakeEnabled = active; _nextShakeAt = 0f; if (!active && (Object)(object)_mesh != (Object)null && _basePositions != null) { _mesh.vertices = _basePositions; _mesh.RecalculateBounds(); } } } private void Update() { //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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if (!_shakeEnabled && _ready && _lastLine >= 1 && _lastLine <= 16 && _lastLetters >= FloweyItem.DialogueLines[_lastLine].Length && (float)((int)(Time.time * 2.5f) & 1) != _nextShakeAt) { int lastLine = _lastLine; int lastLetters = _lastLetters; bool lastCorrected = _lastCorrected; _lastLine = -1; SetDialogue(lastLine, lastLetters, lastCorrected); _nextShakeAt = (int)(Time.time * 2.5f) & 1; } if (!_shakeEnabled || (Object)(object)_mesh == (Object)null || _basePositions == null || _shakenPositions == null || _basePositions.Length == 0 || Time.unscaledTime < _nextShakeAt) { return; } _nextShakeAt = Time.unscaledTime + 0.045f; float num = Mathf.Floor(Time.unscaledTime * 22f); Array.Copy(_basePositions, _shakenPositions, _basePositions.Length); Vector3 val = default(Vector3); for (int i = 0; i < _shakeStarts.Count; i++) { float num2 = 0.0036f * Mathf.Sin(num * 2.17f + (float)i * 6.41f); float num3 = 0.0038f * Mathf.Sin(num * 3.19f + (float)i * 3.13f); ((Vector3)(ref val))..ctor(num2, num3, 0f); for (int j = _shakeStarts[i]; j < _shakeEnds[i]; j++) { _shakenPositions[j] = _basePositions[j] + val; } } _mesh.vertices = _shakenPositions; _mesh.RecalculateBounds(); } private void AddLine(string content, int visible, int startInDialogue, float centerY, float charWidth, float charHeight, int yellowStart, int yellowCount, List<Vector3> vertices, List<int> triBlack, List<int> triYellow) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_glyphAtlas == (Object)null) { return; } int num = Mathf.Clamp(visible - startInDialogue, 0, content.Length); float num2 = (float)(-content.Length) * charWidth * 0.5f; for (int i = 0; i < num; i++) { char value = content[i]; int num3 = "반가워.내이름은플라위노란꽃야!나를당장집으로데려줘헤뭐해?어서날e키봐친구,니까다시보자고알았지난치는거너무뇌아식인을눈채있던응그저괴롭히싶었뿐죽좌클릭계속▼".IndexOf(value); if (num3 < 0) { continue; } List<int> list = ((i >= yellowStart && i < yellowStart + yellowCount) ? triYellow : triBlack); float num4 = num2 + (float)i * charWidth; float num5 = centerY - charHeight * 0.5f; int count = vertices.Count; for (int j = 0; j < 28; j++) { for (int k = 0; k < 28; k++) { if (!(_glyphAtlas.GetPixel(num3 * 56 + k * 2, j * 2).a < 0.5f)) { float num6 = num4 + (float)k * charWidth / 28f; float num7 = num4 + (float)(k + 1) * charWidth / 28f; float num8 = num5 + (float)j * charHeight / 28f; float num9 = num5 + (float)(j + 1) * charHeight / 28f; int count2 = vertices.Count; vertices.Add(new Vector3(0f - num6, num8, 0f)); vertices.Add(new Vector3(0f - num7, num8, 0f)); vertices.Add(new Vector3(0f - num7, num9, 0f)); vertices.Add(new Vector3(0f - num6, num9, 0f)); list.Add(count2); list.Add(count2 + 2); list.Add(count2 + 1); list.Add(count2); list.Add(count2 + 3); list.Add(count2 + 2); } } } if (vertices.Count > count) { _shakeStarts.Add(count); _shakeEnds.Add(vertices.Count); } } } } internal static class FloweyMetamorphTiming { internal const float SinkSeconds = 2.85f; internal const float RiseSeconds = 9f; internal const float OmegaBuriedYOffset = -4.2f; internal const float TotalSeconds = 11.85f; } public sealed class FloweyGroundLifetime : MonoBehaviour { public GameObject Owner; private void Update() { if ((Object)(object)Owner == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public sealed class FloweyItem : GrabbableObject { public Transform Visual; public Transform GroundTemplate; public Transform SpeechBubble; public FloweyPixelDialogue PixelDialogue; public static readonly string[] DialogueLines = new string[21] { "반가워.", "내 이름은 플라위.", "노란 꽃 플라위야!!", "나를 당장 집으로 데려가줘.", "헤 헤 헤 ...", ". . .", "뭐해 ?", "어서 날 집으로 데려가줘.", ". . .", "e 키로 날 집어.", "이봐 친구, 집으라니까?", "다시 해보자고 알았지 ?", ". . .", "장난치는거야?", "너 무뇌아니?", "날 집어. 집으라고. 식인꽃을.", ". . .", "눈치채고 있던거지?", "응?", "그저 날 괴롭히고 싶었을 뿐이었어.", "죽 어." }; private const int SlipLineIndex = 15; private const int LastNormalLineIndex = 16; private const int FirstEvilLineIndex = 17; private const int DeathLineIndex = 20; private const float DeathLineLinger = 0.42f; private const float ThreatFadeSeconds = 5f; private const float ThreatFinalSeconds = 10f; private const float OminousFinalPitch = 0.42f; private const float WhatToneSeconds = 1f; private const float WhatTonePitch = 0.891f; private const float CharacterInterval = 0.095f; private static readonly List<FloweyItem> ActiveFlowers = new List<FloweyItem>(); private PlayerControllerB _dialogueListener; private uint _dialogueSerial; private uint _latestHostSerial; private float _nextDialogueStateSend; private bool _hasHostSnapshot; private bool _hostDialogueActive; private bool _loggedRemoteDialogue; private const float DialogueClickDistance = 4.5f; private const float SharedDialogueViewDistance = 18f; private int _dialogueLine; private int _visibleLetters; private float _nextCharacterTime; public bool _conversationEnded; private bool _finalWordCorrected; public bool _dialogueFinished; private float _threatCountdownSince = -1f; public bool _sinisterActive; private float _sinisterBeganAt = -1f; private float _evilLineCompletedAt = -1f; private float _lineStartedAt = -1f; private readonly List<GameObject> _originalFlowerMeshes = new List<GameObject>(); private readonly List<GameObject> _evilFlowerMeshes = new List<GameObject>(); private GameObject _happyMouthOutline; private GameObject _happyMouthWhiteInset; private GameObject _sadMouthObject; private Mesh _sadMouthMesh; private Vector3[] _sadMouthVertices; private float _fearFaceAmount = -1f; private float _finalWordCorrectionAt = -1f; private AudioSource _dialogueAudio; private AudioSource _laughAudio; private bool _laughStarted; private bool _laughCompleted; private float _laughEndsAt; private float _deathLineCompletedAt = -1f; private bool _bloomSpawnInProgress; private bool _bloomSpawnSucceeded; private float _nextBloomRequestAt; private int _bloomRequestCount; private bool _nearPlayer; private bool _trackingPlayer; private float _bubbleProgress; private const float BubbleEnterDistance = 3f; private const float BubbleLeaveDistance = 3.45f; private const float LookEnterDistance = 5f; private const float LookLeaveDistance = 5.5f; private GameObject _groundInstance; private AudioSource _music; private Vector3 _initialVisualPosition; private Quaternion _initialVisualRotation; public bool _musicOn = true; private float _timeOffset; private int _lastToggleFrame = -1; private Vector3 _normalVisualScale; private bool _lastHeld; private bool _metamorphosisActive; private float _metamorphosisStartedAt; private AudioSource _metamorphAudio; private AudioSource _pickupCurseAudio; private readonly HashSet<ulong> _playersWhoTriedPickupEffect = new HashSet<ulong>(); internal ulong DialogueControllerId { get { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)_dialogueListener != (Object)null)) { if (!((Object)(object)singleton != (Object)null)) { return 0uL; } return singleton.LocalClientId; } return _dialogueListener.playerClientId; } } internal void PlayPickupCurseSoundLocal() { if (!((Object)(object)FloweyPlugin.PickupCurseLaugh == (Object)null) && !_metamorphosisActive) { if ((Object)(object)_pickupCurseAudio == (Object)null) { _pickupCurseAudio = ((Component)this).gameObject.AddComponent<AudioSource>(); _pickupCurseAudio.playOnAwake = false; _pickupCurseAudio.loop = false; _pickupCurseAudio.spatialBlend = 1f; _pickupCurseAudio.minDistance = 1.8f; _pickupCurseAudio.maxDistance = 23f; _pickupCurseAudio.rolloffMode = (AudioRolloffMode)1; _pickupCurseAudio.dopplerLevel = 0f; _pickupCurseAudio.volume = 0.92f; } _pickupCurseAudio.Stop(); _pickupCurseAudio.PlayOneShot(FloweyPlugin.PickupCurseLaugh, 1f); } } internal void BeginMetamorphosis() { if (!_metamorphosisActive) { _metamorphosisActive = true; _metamorphosisStartedAt = Time.time; base.grabbable = false; base.grabbableToEnemies = false; if ((Object)(object)SpeechBubble != (Object)null) { ((Component)SpeechBubble).gameObject.SetActive(false); } if ((Object)(object)_music != (Object)null) { _music.Stop(); } if ((Object)(object)_laughAudio != (Object)null) { _laughAudio.Stop(); } if ((Object)(object)_metamorphAudio == (Object)null) { _metamorphAudio = ((Component)this).gameObject.AddComponent<AudioSource>(); _metamorphAudio.playOnAwake = false; _metamorphAudio.loop = false; _metamorphAudio.spatialBlend = 1f; _metamorphAudio.minDistance = 2.2f; _metamorphAudio.maxDistance = 42f; _metamorphAudio.rolloffMode = (AudioRolloffMode)1; _metamorphAudio.volume = 0.77f; } if ((Object)(object)FloweyPlugin.FlowerSink != (Object)null) { _metamorphAudio.PlayOneShot(FloweyPlugin.FlowerSink); } } } private void UpdateMetamorphosis() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Visual == (Object)null)) { float num = Time.time - _metamorphosisStartedAt; float num2 = Mathf.Clamp01(num / 2.85f); float num3 = num2 * num2 * (3f - 2f * num2); float num4 = num * (17f + 15f * num2); float num5 = (0.27f + Mathf.Sin(MathF.PI * num2)) * (1f - num3); float num6 = 1f - 0.45f * Mathf.Sin(num2 * MathF.PI); float num7 = Mathf.Max(0.018f, (1f - num3) * num6); Visual.localScale = Vector3.Scale(_normalVisualScale, new Vector3(num7 * (1f + num5 * Mathf.Sin(num4 * 0.82f) * 0.24f), num7 * (1f + 0.65f * Mathf.Sin(num2 * MathF.PI)), num7 * (1f - 0.27f * num3))); float num8 = 1.7f * num3; Visual.localPosition = _initialVisualPosition + new Vector3(0.06f * (1f - num3) * Mathf.Sin(num4 * 1.1f), 0f - num8 + 0.045f * num5 * Mathf.Cos(num4 * 1.8f), 0.045f * (1f - num3) * Mathf.Sin(num4 * 0.9f)); Visual.localRotation = _initialVisualRotation * Quaternion.Euler((40f + 27f * num2) * num5 * Mathf.Sin(num4), 24f * num5 * Mathf.Sin(num4 * 0.75f) + 70f * num3, (45f + 15f * num2) * num5 * Mathf.Cos(num4 * 1.3f) + 127f * num3); } } public override void Start() { //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Start(); if (!ActiveFlowers.Contains(this)) { ActiveFlowers.Add(this); } if ((Object)(object)base.itemProperties != (Object)null) { base.itemProperties.requiresBattery = false; base.itemProperties.batteryUsage = 0f; } base.insertedBattery = null; Transform val = ((Component)this).transform.Find("FLOWEY_Model"); if ((Object)(object)Visual == (Object)null && (Object)(object)val != (Object)null) { Visual = val.Find("FLOWEY_Flower"); } if ((Object)(object)GroundTemplate == (Object)null && (Object)(object)val != (Object)null) { GroundTemplate = val.Find("FLOWEY_Ground"); } if ((Object)(object)SpeechBubble == (Object)null) { SpeechBubble = ((Component)this).transform.Find("FLOWEY_SpeechBubble"); } if ((Object)(object)SpeechBubble != (Object)null) { if ((Object)(object)PixelDialogue == (Object)null) { PixelDialogue = ((Component)SpeechBubble).GetComponentInChildren<FloweyPixelDialogue>(true); } if ((Object)(object)PixelDialogue != (Object)null) { PixelDialogue.Initialize(FloweyPlugin.PixelGlyphAtlas); } ((Component)SpeechBubble).gameObject.SetActive(false); } _dialogueAudio = ((Component)this).gameObject.AddComponent<AudioSource>(); _dialogueAudio.playOnAwake = false; _dialogueAudio.loop = false; _dialogueAudio.spatialBlend = 1f; _dialogueAudio.minDistance = 0.6f; _dialogueAudio.maxDistance = 8f; _dialogueAudio.rolloffMode = (AudioRolloffMode)1; _dialogueAudio.volume = 0.95f; _dialogueAudio.ignoreListenerPause = false; _laughAudio = ((Component)this).gameObject.AddComponent<AudioSource>(); _laughAudio.playOnAwake = false; _laughAudio.loop = false; _laughAudio.spatialBlend = 1f; _laughAudio.volume = 1f; _laughAudio.minDistance = 2f; _laughAudio.maxDistance = 30f; _laughAudio.rolloffMode = (AudioRolloffMode)1; _laughAudio.clip = FloweyPlugin.EvilLaugh; if ((Object)(object)Visual != (Object)null) { _initialVisualPosition = Visual.localPosition; _initialVisualRotation = Visual.localRotation; _normalVisualScale = Visual.localScale; } _timeOffset = ((Component)this).transform.position.x * 0.31f + ((Component)this).transform.position.z * 0.19f; SpawnStationaryGround(); CreateSinisterFlower(); _music = ((Component)this).GetComponent<AudioSource>(); if ((Object)(object)_music != (Object)null) { _music.clip = FloweyPlugin.Music; _music.loop = true; _music.playOnAwake = false; _music.spatialBlend = 1f; SetMusicState(_musicOn); } } private unsafe void SpawnStationaryGround() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0032: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0069: 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) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_groundInstance != (Object)null || (Object)(object)GroundTemplate == (Object)null) { return; } try { Vector3 position = ((Component)this).transform.position; Vector3 val = position; float num = float.PositiveInfinity; RaycastHit[] array = Physics.RaycastAll(position + Vector3.up * 0.15f, Vector3.down, 1.5f, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)this).transform) && !(((RaycastHit)(ref val2)).normal.y < 0.8f) && !(((RaycastHit)(ref val2)).point.y > position.y + 0.025f)) { float num2 = Mathf.Abs(position.y - ((RaycastHit)(ref val2)).point.y); if (num2 < num) { num = num2; val.y = ((RaycastHit)(ref val2)).point.y + 0.012f; } } } if (num == float.PositiveInfinity) { val.y = position.y - 0.03f; } _groundInstance = Object.Instantiate<GameObject>(((Component)GroundTemplate).gameObject, val, Quaternion.Euler(0f, 90f, 0f)); ((Object)_groundInstance).name = "FLOWEY_Stationary_Grass_Soil"; _groundInstance.transform.SetParent((Transform)null, true); _groundInstance.SetActive(true); _groundInstance.AddComponent<FloweyGroundLifetime>().Owner = ((Component)this).gameObject; ManualLogSource log = FloweyPlugin.Log; Vector3 val3 = val; log.LogInfo((object)("FLOWEY soil placed at original spawn: " + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString())); } catch (Exception ex) { FloweyPlugin.Log.LogWarning((object)("FLOWEY decorative ground failed: " + ex.Message)); } } private void SetMusicState(bool shouldPlay) { _musicOn = shouldPlay; if ((Object)(object)_music == (Object)null) { _music = ((Component)this).GetComponent<AudioSource>(); } if (!((Object)(object)_music == (Object)null) && !((Object)(object)FloweyPlugin.Music == (Object)null)) { if ((Object)(object)_music.clip != (Object)(object)FloweyPlugin.Music) { _music.clip = FloweyPlugin.Music; } _music.loop = true; _music.mute = !shouldPlay; _music.volume = (shouldPlay ? 0.5f : 0f); if (!_music.isPlaying) { _music.Play(); } } } private bool IsLocalHeld() { GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } if (base.isPocketed) { return false; } if (!((Object)(object)instance.localPlayerController == (Object)null)) { return (Object)(object)instance.localPlayerController.currentlyHeldObjectServer == (Object)(object)this; } return false; } internal void TryToggleMusic() { if (_lastToggleFrame != Time.frameCount && IsLocalHeld()) { _lastToggleFrame = Time.frameCount; SetMusicState(!_musicOn); FloweyPlugin.Log.LogInfo((object)("FLOWEY BGM " + (_musicOn ? "ON" : "OFF") + " (LMB)")); } } private PlayerControllerB GetNearbyPlayer(float radius) { //IL_0059: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return null; } float num = radius * radius; PlayerControllerB result = null; PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val2)).sqrMagnitude < num) { return val; } } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (!((Object)(object)val3 == (Object)null) && val3.isPlayerControlled && !val3.isPlayerDead) { Vector3 val4 = ((Component)val3).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val3; } } } return result; } internal static FloweyItem FindFlowerByNetworkId(ulong id) { foreach (FloweyItem activeFlower in ActiveFlowers) { if ((Object)(object)activeFlower != (Object)null && (Object)(object)((NetworkBehaviour)activeFlower).NetworkObject != (Object)null && ((NetworkBehaviour)activeFlower).NetworkObject.IsSpawned && ((NetworkBehaviour)activeFlower).NetworkObject.NetworkObjectId == id) { return activeFlower; } } return null; } internal bool ServerAdvanceDialogue(PlayerControllerB player) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0065: Unknown result type (might be due to invalid IL or missing references) if (!FloweyPlugin.IsDialogueAuthority || (Object)(object)player == (Object)null || player.isPlayerDead || !player.isPlayerControlled || base.isHeld || base.isPocketed || _metamorphosisActive || _sinisterActive || _conversationEnded) { return false; } Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 20.25f) { return false; } if ((Object)(object)_dialogueListener == (Object)null) { StartDialogue(player); } bool num = AdvanceDialogue(); if (num) { _nextDialogueStateSend = 0f; } return num; } private void PublishDialogueState() { if (FloweyPlugin.IsDialogueAuthority && !(Time.time < _nextDialogueStateSend)) { bool flag = (Object)(object)_dialogueListener == (Object)null && !_sinisterActive && !_dialogueFinished && !_conversationEnded && !_metamorphosisActive; _nextDialogueStateSend = Time.time + (flag ? 0.8f : 0.095f); byte b = 0; if ((Object)(object)_dialogueListener != (Object)null) { b |= 1; } if (_sinisterActive) { b |= 2; } if (_dialogueFinished) { b |= 4; } if (_finalWordCorrected) { b |= 8; } if (_conversationEnded) { b |= 0x10; } if (_laughStarted) { b |= 0x20; } if (_metamorphosisActive) { b |= 0x40; } float threat = ((_threatCountdownSince >= 0f) ? Mathf.Clamp01((Time.time - _threatCountdownSince) / 10f) : 0f); FloweyPlugin.BroadcastDialogue(this, ++_dialogueSerial, _dialogueLine, _visibleLetters, b, threat); } } internal void ApplyHostDialogueSnapshot(uint serial, int line, int glyphs, byte flags, float threat) { if (FloweyPlugin.IsDialogueAuthority || (_hasHostSnapshot && serial <= _latestHostSerial)) { return; } _hasHostSnapshot = true; _latestHostSerial = serial; int dialogueLine = _dialogueLine; int visibleLetters = _visibleLetters; bool sinisterActive = _sinisterActive; bool laughStarted = _laughStarted; _dialogueLine = Mathf.Clamp(line, 0, DialogueLines.Length - 1); _visibleLetters = Mathf.Clamp(glyphs, 0, DialogueLines[_dialogueLine].Length); bool flag = (_hostDialogueActive = (flags & 1) != 0); if (flag && !_loggedRemoteDialogue) { _loggedRemoteDialogue = true; FloweyPlugin.Log.LogInfo((object)("FLOWEY dialogue: client received host transcript for flower " + (((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null) ? ((NetworkBehaviour)this).NetworkObject.NetworkObjectId.ToString() : "not-spawned"))); } _sinisterActive = (flags & 2) != 0; _dialogueFinished = (flags & 4) != 0; _finalWordCorrected = (flags & 8) != 0; _conversationEnded = (flags & 0x10) != 0; _laughStarted = (flags & 0x20) != 0; if (sinisterActive != _sinisterActive) { EnableSinisterFlower(_sinisterActive); if ((Object)(object)PixelDialogu
plugins/Flowey/FloweyLanguage.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; 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: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } [BepInPlugin("hihi.flowey.language", "FLOWEY Language", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FloweyLanguagePlugin : BaseUnityPlugin { public enum FloweyLanguage { Auto, Korean, English } private sealed class Chunk { internal readonly int Offset; internal readonly int HlStart; internal readonly int HlCount; internal readonly float Y; internal readonly float W; internal readonly float H; internal Chunk(int offset, float y, float w, float h, int hlStart, int hlCount) { Offset = offset; Y = y; W = w; H = h; HlStart = hlStart; HlCount = hlCount; } } private static readonly Dictionary<string, string> Map = new Dictionary<string, string> { { "반가워.내이름은플라위노란꽃야!나를당장집으로데려줘헤뭐해?어서날e키봐친구,니까다시보자고알았지난치는거너무뇌아식인을눈채있던응그저괴롭히싶었뿐죽좌클릭계속▼", "Howdy!MnameisFLOWEY.Thlk,?CtPrgbpG'KAujc-IDB▼fqvxzJNQRSUVXZ0123456789:;()\"/+=*&%" }, { "반가워.", "Howdy!" }, { "내 이름은 플라위.", "My name is FLOWEY." }, { "노란 꽃 플라위야!!", "The yellow FLOWEY!!" }, { "나를 당장 집으로 데려가줘.", "Take me home, now." }, { "헤 헤 헤 ...", "Hee hee hee..." }, { "뭐해 ?", "Well?" }, { "어서 날 집으로 데려가줘.", "Come on, take me home." }, { "e 키로 날 집어.", "Press E to grab me." }, { "이봐 친구, 집으라니까?", "Hey, pal! Grab me!" }, { "다시 해보자고 알았지 ?", "Let's try again, OK?" }, { "장난치는거야?", "Are you joking?" }, { "너 무뇌아니?", "Are you dumb?" }, { "날 집어. 집으라고. 식인꽃을.", "Pick me up. The man-eater." }, { "눈치채고 있던거지?", "You knew, didn't you?" }, { "응?", "Huh?" }, { "그저 날 괴롭히고 싶었을 뿐이었어.", "You just want to hurt me." }, { "죽 어.", "DIE." }, { "내 이름은", "My name is" }, { "플라위.", "FLOWEY." }, { "노란 꽃", "The yellow" }, { "플라위야!!", "FLOWEY!!" }, { "나를 당장", "Take me" }, { "집으로 데려가줘.", "home, now." }, { "어서 날 집으로", "Come on," }, { "데려가줘.", "take me home." }, { "e 키로", "Press E" }, { "날 집어.", "to grab me." }, { "이봐 친구,", "Hey, pal!" }, { "집으라니까?", "Grab me!" }, { "다시 해보자고", "Let's try" }, { "알았지 ?", "again, OK?" }, { "날 집어. 집으라고.", "Pick me up." }, { "식인꽃을.", "The man-eater." }, { "플라위를.", "I mean, FLOWEY." }, { "눈치채고", "You knew," }, { "있던거지?", "didn't you?" }, { "그저 날 괴롭히고", "You just" }, { "싶었을 뿐이었어.", "want to hurt me." }, { " 좌클릭으로 계속", " LMB to continue" }, { "F7: 플라위 생성에 실패했습니다. CMD 로그를 확인하세요.", "F7: Flowey spawn failed. Check the console log." }, { "F7: 플라위가 조준 위치에 생성되었습니다.", "F7: Flowey spawned at the aimed position." }, { "F7: 호스트에게 플라위 소환 요청을 보냈습니다.", "F7: Sent a Flowey spawn request to the host." }, { "친절한 노란꽃입니다 !오메가 플라위", "A friendly yellow flower!Omega Flowey" }, { "친절한 노란꽃입니다 !", "A friendly yellow flower!" }, { "오메가 플라위", "Omega Flowey" } }; private static readonly Dictionary<string, Chunk> Chunks = new Dictionary<string, Chunk> { { "반가워.", new Chunk(0, 0f, 0.052f, 0.091f, -1, 0) }, { "내 이름은", new Chunk(0, 0.034f, 0.0377f, 0.066f, -1, 0) }, { "플라위.", new Chunk(11, -0.034f, 0.0377f, 0.066f, 0, 6) }, { "노란 꽃", new Chunk(0, 0.034f, 0.0377f, 0.066f, 4, 6) }, { "플라위야!!", new Chunk(11, -0.034f, 0.0377f, 0.066f, 0, 6) }, { "나를 당장", new Chunk(0, 0.034f, 0.0366f, 0.064f, -1, 0) }, { "집으로 데려가줘.", new Chunk(8, -0.034f, 0.0366f, 0.064f, -1, 0) }, { "헤 헤 헤 ...", new Chunk(0, 0f, 0.0343f, 0.06f, -1, 0) }, { "뭐해 ?", new Chunk(0, 0f, 0.0491f, 0.086f, -1, 0) }, { "어서 날 집으로", new Chunk(0, 0.034f, 0.036f, 0.063f, -1, 0) }, { "데려가줘.", new Chunk(9, -0.034f, 0.036f, 0.063f, -1, 0) }, { "e 키로", new Chunk(0, 0.034f, 0.0383f, 0.067f, -1, 0) }, { "날 집어.", new Chunk(8, -0.034f, 0.0383f, 0.067f, -1, 0) }, { "이봐 친구,", new Chunk(0, 0.034f, 0.0371f, 0.065f, -1, 0) }, { "집으라니까?", new Chunk(10, -0.034f, 0.0371f, 0.065f, -1, 0) }, { "다시 해보자고", new Chunk(0, 0.034f, 0.0371f, 0.065f, -1, 0) }, { "알았지 ?", new Chunk(10, -0.034f, 0.0371f, 0.065f, -1, 0) }, { "장난치는거야?", new Chunk(0, 0f, 0.032f, 0.056f, -1, 0) }, { "너 무뇌아니?", new Chunk(0, 0f, 0.0369f, 0.0646f, -1, 0) }, { "날 집어. 집으라고.", new Chunk(0, 0.034f, 0.0377f, 0.066f, -1, 0) }, { "식인꽃을.", new Chunk(12, -0.034f, 0.0343f, 0.06f, -1, 0) }, { "플라위를.", new Chunk(12, -0.034f, 0.032f, 0.056f, -1, 0) }, { "눈치채고", new Chunk(0, 0.034f, 0.0371f, 0.065f, -1, 0) }, { "있던거지?", new Chunk(10, -0.034f, 0.0371f, 0.065f, -1, 0) }, { "응?", new Chunk(0, 0f, 0.0503f, 0.088f, -1, 0) }, { "그저 날 괴롭히고", new Chunk(0, 0.034f, 0.036f, 0.063f, -1, 0) }, { "싶었을 뿐이었어.", new Chunk(9, -0.034f, 0.03f, 0.0525f, -1, 0) }, { "죽 어.", new Chunk(0, 0f, 0.0617f, 0.108f, -1, 0) }, { " 좌클릭으로 계속", new Chunk(0, -0.08f, 0.024f, 0.042f, -1, 0) }, { " ▼", new Chunk(0, -0.086f, 0.08f, 0.08f, -1, 0) } }; private static MethodInfo addLine; private static ManualLogSource Log; private Harmony harmony; private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigEntry<FloweyLanguage> val = ((BaseUnityPlugin)this).Config.Bind<FloweyLanguage>("General", "Language", FloweyLanguage.Auto, "Flowey dialogue and scan text language. Auto = Korean when the game/Windows language is Korean, otherwise English."); bool flag = val.Value == FloweyLanguage.English; if (val.Value == FloweyLanguage.Auto) { flag = (int)Application.systemLanguage != 23 && !(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "ko"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("FLOWEY language setting=" + val.Value.ToString() + " -> " + (flag ? "English" : "Korean"))); if (!flag) { return; } try { harmony = new Harmony("hihi.flowey.language"); Type type = AccessTools.TypeByName("GyeongJi.Flowey.FloweyPixelDialogue"); Type type2 = AccessTools.TypeByName("GyeongJi.Flowey.FloweyItem"); Type type3 = AccessTools.TypeByName("GyeongJi.Flowey.FloweyPlugin"); if (type == null || type2 == null || type3 == null) { throw new Exception("FLOWEY types not found"); } addLine = AccessTools.Method(type, "AddLine", (Type[])null, (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(FloweyLanguagePlugin).GetMethod("SwapStrings", BindingFlags.Static | BindingFlags.NonPublic)); HarmonyMethod val3 = new HarmonyMethod(typeof(FloweyLanguagePlugin).GetMethod("SwapDialogue", BindingFlags.Static | BindingFlags.NonPublic)); harmony.Patch((MethodBase)AccessTools.Method(type, "SetDialogue", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)addLine, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo[] array = new MethodInfo[4] { AccessTools.Method(type3, "TryHandleF7TestSpawn", (Type[])null, (Type[])null), AccessTools.Method(AccessTools.TypeByName("GyeongJi.Flowey.FloweyNativeScanCaptionPatch"), "CanRender", (Type[])null, (Type[])null), AccessTools.Method(AccessTools.TypeByName("GyeongJi.Flowey.FloweyNativeScanCaptionPatch"), "Postfix", (Type[])null, (Type[])null), AccessTools.Method(AccessTools.TypeByName("GyeongJi.Flowey.FloweyOmegaCadaverVariant"), "EnsureOmegaScanNode", (Type[])null, (Type[])null) }; foreach (MethodInfo methodInfo in array) { if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null); } } FieldInfo fieldInfo = AccessTools.Field(type2, "DialogueLines"); if (fieldInfo != null && fieldInfo.GetValue(null) is string[] array2) { for (int j = 0; j < array2.Length; j++) { if (array2[j] != null && Map.TryGetValue(array2[j], out var value)) { array2[j] = value; } } } string directoryName = Path.GetDirectoryName(typeof(FloweyLanguagePlugin).Assembly.Location); string path = Path.Combine(directoryName, "Assets", "FloweyPixelGlyphs_en.png"); if (!File.Exists(path)) { path = Path.Combine(directoryName, "FloweyPixelGlyphs_en.png"); } Texture2D val4 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val4, File.ReadAllBytes(path), false)) { throw new Exception("English glyph atlas could not be loaded"); } ((Texture)val4).filterMode = (FilterMode)0; ((Texture)val4).wrapMode = (TextureWrapMode)1; FieldInfo fieldInfo2 = AccessTools.Field(type3, "PixelGlyphAtlas"); if (fieldInfo2 == null) { throw new Exception("PixelGlyphAtlas field not found"); } fieldInfo2.SetValue(null, val4); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FLOWEY English dialogue, scan text and pixel font enabled."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("FLOWEY English could not be enabled; Korean stays: " + ex)); try { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } catch { } } } private static IEnumerable<CodeInstruction> SwapStrings(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldstr && instruction.operand is string key && Map.TryGetValue(key, out var value)) { instruction.operand = value; } yield return instruction; } } private static bool IsLdcI4(CodeInstruction c) { if (!(c.opcode == OpCodes.Ldc_I4) && !(c.opcode == OpCodes.Ldc_I4_S) && !(c.opcode == OpCodes.Ldc_I4_M1)) { if (c.opcode.Value >= OpCodes.Ldc_I4_0.Value) { return c.opcode.Value <= OpCodes.Ldc_I4_8.Value; } return false; } return true; } private static IEnumerable<CodeInstruction> SwapDialogue(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; int num2 = 0; for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && object.Equals(list[i].operand, addLine)) { Chunk value = null; for (int j = num; j < i && (!(list[j].opcode == OpCodes.Ldstr) || !(list[j].operand is string key) || !Chunks.TryGetValue(key, out value)); j++) { } if (value != null && i >= 10 && IsLdcI4(list[i - 9]) && list[i - 8].opcode == OpCodes.Ldc_R4 && list[i - 7].opcode == OpCodes.Ldc_R4 && list[i - 6].opcode == OpCodes.Ldc_R4 && IsLdcI4(list[i - 5]) && IsLdcI4(list[i - 4])) { list[i - 9].opcode = OpCodes.Ldc_I4; list[i - 9].operand = value.Offset; list[i - 8].operand = value.Y; list[i - 7].operand = value.W; list[i - 6].operand = value.H; list[i - 5].opcode = OpCodes.Ldc_I4; list[i - 5].operand = value.HlStart; list[i - 4].opcode = OpCodes.Ldc_I4; list[i - 4].operand = value.HlCount; num2++; } num = i + 1; } } foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldstr && item.operand is string key2 && Map.TryGetValue(key2, out var value2)) { item.operand = value2; } } ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("FLOWEY English: dialogue layout patched for " + num2 + " lines.")); } return list; } }
plugins/Flowey/FloweyStability73.dll
Decompiled 5 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } [BepInPlugin("hihi.flowey.stability73", "FLOWEY Rejoin and Ship Stability 73", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FloweyStability73 : BaseUnityPlugin { private sealed class ShipAnchor { internal Vector3 local; internal Vector3 world; internal bool ship; internal byte flags; } private sealed class OmegaAnchor { internal Vector3 pos; internal float nextKick; internal bool chaseMoving; internal bool releaseLogged; internal bool navWarning; } private sealed class SyncedOmega { internal double epochServerTime; internal Vector3 anchor; internal ulong sourceFlowerId; internal float receivedAt; } private sealed class GuestPresence { internal ulong sender; internal float expires; } private const string PositionMessage = "hihi.flowey.position73"; private const string MusicMessage = "hihi.flowey.music73"; private const string GuestPresenceMessage = "hihi.flowey.guest.proximity78"; private const string GuestClickMessage = "hihi.flowey.guest.click78"; private const string OmegaSyncMessage = "hihi.flowey.omega.clock77"; private const float SyncInterval = 0.45f; private Harmony harmony; private static FloweyStability73 Instance; private static Type itemType; private static Type pluginType; private static Type omegaType; private static Type poisonType; private static FieldInfo netManager; private static FieldInfo activeFlowers; private static FieldInfo bloomField; private static FieldInfo morphActive; private static FieldInfo morphAt; private static FieldInfo musicOn; private static FieldInfo toggleFrame; private static FieldInfo sinister; private static MethodInfo setMusic; private static MethodInfo startFlowerMorph; private static MethodInfo startOmegaMorph; private static MethodInfo startDialogue; private static MethodInfo advanceDialogue; private static MethodInfo toggleMusic; private static FieldInfo listenerField; private static FieldInfo endedField; private static FieldInfo dialogueAudioField; private static FieldInfo omegaSourceId; private static FieldInfo flowerMorphStarted; private static FieldInfo flowerMorphStartTime; private static NetworkManager oldNetwork; private static StartOfRound oldRound; private static readonly object anchorsLock = new object(); private static readonly Dictionary<ulong, ShipAnchor> hostAnchors = new Dictionary<ulong, ShipAnchor>(); private static readonly Dictionary<ulong, ShipAnchor> guestAnchors = new Dictionary<ulong, ShipAnchor>(); private static readonly ConditionalWeakTable<object, OmegaAnchor> omegaAnchors = new ConditionalWeakTable<object, OmegaAnchor>(); private static readonly Dictionary<ulong, SyncedOmega> guestOmegaSync = new Dictionary<ulong, SyncedOmega>(); private float nextOmegaSync; private float nextGuestPresence; private static readonly Dictionary<ulong, GuestPresence> liveGuestPresence = new Dictionary<ulong, GuestPresence>(); private bool omegaSyncWarned; private NetworkManager registered; private StartOfRound registeredRound; private float nextRegistration; private float nextBroadcast; private Vector3 lastShipWorld; private Quaternion lastShipRotation; private bool sawShipTransform; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; harmony = new Harmony("hihi.flowey.stability73"); try { itemType = AccessTools.TypeByName("GyeongJi.Flowey.FloweyItem"); pluginType = AccessTools.TypeByName("GyeongJi.Flowey.FloweyPlugin"); omegaType = AccessTools.TypeByName("GyeongJi.Flowey.FloweyOmegaCadaverVariant"); poisonType = AccessTools.TypeByName("GyeongJi.Flowey.FloweyPickupHazards"); if (itemType == null || pluginType == null || omegaType == null) { throw new Exception("FLOWEY code not loaded"); } netManager = AccessTools.Field(pluginType, "_netMessageManager"); activeFlowers = AccessTools.Field(itemType, "ActiveFlowers"); bloomField = AccessTools.Field(omegaType, "bloom"); morphActive = AccessTools.Field(omegaType, "metamorphosisStarted"); morphAt = AccessTools.Field(omegaType, "metamorphosisAt"); musicOn = AccessTools.Field(itemType, "_musicOn"); toggleFrame = AccessTools.Field(itemType, "_lastToggleFrame"); sinister = AccessTools.Field(itemType, "_sinisterActive"); setMusic = AccessTools.Method(itemType, "SetMusicState", (Type[])null, (Type[])null); omegaSourceId = AccessTools.Field(omegaType, "morphFlowerId"); flowerMorphStarted = AccessTools.Field(itemType, "_metamorphosisActive"); flowerMorphStartTime = AccessTools.Field(itemType, "_metamorphosisStartedAt"); startFlowerMorph = AccessTools.Method(itemType, "BeginMetamorphosis", (Type[])null, (Type[])null); startOmegaMorph = AccessTools.Method(omegaType, "BeginMetamorphosis", (Type[])null, (Type[])null); startDialogue = AccessTools.Method(itemType, "StartDialogue", (Type[])null, (Type[])null); advanceDialogue = AccessTools.Method(itemType, "AdvanceDialogue", (Type[])null, (Type[])null); toggleMusic = AccessTools.Method(itemType, "TryToggleMusic", (Type[])null, (Type[])null); listenerField = AccessTools.Field(itemType, "_dialogueListener"); endedField = AccessTools.Field(itemType, "_conversationEnded"); dialogueAudioField = AccessTools.Field(itemType, "_dialogueAudio"); if (netManager == null || activeFlowers == null || bloomField == null || morphActive == null || morphAt == null || musicOn == null || toggleFrame == null || setMusic == null || sinister == null || omegaSourceId == null || flowerMorphStarted == null || flowerMorphStartTime == null || startFlowerMorph == null || startOmegaMorph == null || startDialogue == null || advanceDialogue == null || toggleMusic == null || listenerField == null || endedField == null || dialogueAudioField == null) { throw new Exception("FLOWEY version mismatch: private fields changed"); } AddPatch(AccessTools.Method(pluginType, "RegisterBloomNetworkMessages", (Type[])null, (Type[])null), "RebindOnlyAfterNewLobby", null, null); AddPatch(AccessTools.Method(pluginType, "Update", (Type[])null, (Type[])null), null, null, "AllowGuestHeldInput"); AddPatch(AccessTools.Method(itemType, "IsLocalHeld", (Type[])null, (Type[])null), "DetectRealLocalHeldItem", null, null); AddPatch(AccessTools.Method(itemType, "TryAdvanceClosestConversation", (Type[])null, (Type[])null), "GuestDialogueClickIntercept", null, null); AddPatch(AccessTools.Method(itemType, "GetNearbyPlayer", (Type[])null, (Type[])null), null, "HostRecognizeGuestPresence", null); AddPatch(AccessTools.Method(itemType, "Start", (Type[])null, (Type[])null), null, "SetDialogueSpatialAudio", null); AddPatch(AccessTools.Method(typeof(PlayerControllerB), "GrabObjectClientRpc", (Type[])null, (Type[])null), null, null, "AvoidGuestFlowerReparent"); AddPatch(AccessTools.Method(itemType, "TryToggleMusic", (Type[])null, (Type[])null), "BeforeToggle", "AfterToggle", null); AddPatch(AccessTools.Method(omegaType, "BeginMetamorphosis", (Type[])null, (Type[])null), null, "CaptureOmegaBirth", null); AddPatch(AccessTools.Method(omegaType, "LateUpdate", (Type[])null, (Type[])null), "PreSyncOmegaVisual", "FreezeOmegaDuringGrowth", null); AddPatch(AccessTools.Method(omegaType, "RegisterWeaponHit", (Type[])null, (Type[])null), "BlockOmegaHitDuringGrowth", null, null); MethodInfo methodInfo = AccessTools.Method(typeof(EnemyAI), "HitEnemy", (Type[])null, (Type[])null); if (methodInfo != null) { AddPatch(methodInfo, "BlockNativeHitDuringGrowth", null, null); } MethodInfo methodInfo2 = AccessTools.DeclaredMethod(typeof(CadaverBloomAI), "HitEnemy", (Type[])null, (Type[])null); if (methodInfo2 != null && methodInfo2 != methodInfo) { AddPatch(methodInfo2, "BlockNativeHitDuringGrowth", null, null); } AddPatch(AccessTools.Method(typeof(StartOfRound), "LateUpdate", (Type[])null, (Type[])null), null, "ShipItemLateTick", null); if (poisonType != null) { AddPatch(AccessTools.Method(poisonType, "ApplyPoisonDamage", (Type[])null, (Type[])null), null, "ShowPoisonTick", null); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"FLOWEY73 loaded: lobby-scoped registrations (no six-second reset), synchronized BGM, ship-local item anchors, birth-position lock."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("FLOWEY73 load aborted: " + ex)); harmony.UnpatchSelf(); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } ClearAnchors(); } private void AddPatch(MethodBase original, string prefix, string postfix, string transpiler) { if (original == null) { throw new MissingMethodException("Required FLOWEY method absent."); } BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic; harmony.Patch(original, Get(prefix), Get(postfix), Get(transpiler), (HarmonyMethod)null, (HarmonyMethod)null); HarmonyMethod Get(string n) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (n != null) { return new HarmonyMethod(typeof(FloweyStability73).GetMethod(n, flags)); } return null; } } private static void ClearAnchors() { lock (anchorsLock) { hostAnchors.Clear(); guestAnchors.Clear(); guestOmegaSync.Clear(); liveGuestPresence.Clear(); } } private static void RebindOnlyAfterNewLobby(object __instance) { NetworkManager singleton = NetworkManager.Singleton; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || (Object)(object)instance == (Object)null) { if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { oldNetwork = null; oldRound = null; } } else if (oldNetwork != singleton || oldRound != instance) { netManager.SetValue(__instance, null); oldNetwork = singleton; oldRound = instance; ClearAnchors(); if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"FLOWEY73 lobby epoch: registering handlers ONCE for new lobby."); } } } private static IEnumerable<CodeInstruction> AllowGuestHeldInput(IEnumerable<CodeInstruction> stream) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(stream); int num = 0; for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode != OpCodes.Ldfld) && list[i].operand is FieldInfo fieldInfo && !(fieldInfo.Name != "isHeld") && typeof(GrabbableObject).IsAssignableFrom(fieldInfo.DeclaringType)) { list[i] = new CodeInstruction(OpCodes.Pop, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)); num++; i++; } } if (num != 1) { throw new Exception("Guest local held gate mismatch count=" + num); } return list; } private static bool DetectRealLocalHeldItem(object __instance, ref bool __result) { GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val = (((Object)(object)instance == (Object)null) ? null : instance.localPlayerController); GrabbableObject val2 = (GrabbableObject)((__instance is GrabbableObject) ? __instance : null); __result = (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && !val2.isPocketed && (val.currentlyHeldObjectServer == val2 || (val2.isHeld && val2.playerHeldBy == val) || (val.ItemSlots != null && val.currentItemSlot >= 0 && val.currentItemSlot < val.ItemSlots.Length && val.ItemSlots[val.currentItemSlot] == val2)); return false; } private static void BeforeToggle(object __instance, out bool __state) { __state = __instance != null && (bool)musicOn.GetValue(__instance); } private unsafe static void AfterToggle(object __instance, bool __state) { //IL_00b4: 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_00c7: 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_00e1: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || (Object)(object)Instance == (Object)null) { return; } bool flag = (bool)musicOn.GetValue(__instance); if (__state == flag || (int)toggleFrame.GetValue(__instance) != Time.frameCount) { return; } GrabbableObject val = (GrabbableObject)((__instance is GrabbableObject) ? __instance : null); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)val == (Object)null || (Object)(object)singleton == (Object)null || !singleton.IsListening || (Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null || !((NetworkBehaviour)val).NetworkObject.IsSpawned) { return; } ulong networkObjectId = ((NetworkBehaviour)val).NetworkObject.NetworkObjectId; if (singleton.IsServer) { Instance.SendMusicToClients(networkObjectId, flag); return; } try { FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.music73", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY73 guest music send: " + ex.Message)); } } private static GrabbableObject FlowerById(ulong id) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.SpawnManager == null) { return null; } if (!singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) || (Object)(object)value == (Object)null) { return null; } Component component = ((Component)value).GetComponent(itemType); return (GrabbableObject)(object)((component is GrabbableObject) ? component : null); } private void OnMusic(ulong sender, FastBufferReader reader) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_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_013e: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return; } try { ulong id = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); GrabbableObject val = FlowerById(id); if ((Object)(object)val == (Object)null) { return; } if (singleton.IsServer) { StartOfRound instance = StartOfRound.Instance; bool flag2 = false; if ((Object)(object)instance != (Object)null && instance.allPlayerScripts != null) { PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.actualClientId == sender && (val2.currentlyHeldObjectServer == val || val.playerHeldBy == val2)) { flag2 = true; } } } if (!flag2 && (Object)(object)instance != (Object)null && instance.allPlayerScripts != null) { PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if ((Object)(object)val3 != (Object)null && val3.actualClientId == sender && val3.isPlayerControlled && !val3.isPlayerDead) { Vector3 val4 = ((Component)val3).transform.position - ((Component)val).transform.position; if (((Vector3)(ref val4)).sqrMagnitude <= 20.25f) { flag2 = true; } } } } if (!flag2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY78 music rejected: not authorized client=" + sender)); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("FLOWEY78 music accepted: client=" + sender + " enabled=" + flag)); setMusic.Invoke(val, new object[1] { flag }); SendMusicToClients(id, flag); } else if (sender == 0L && (bool)musicOn.GetValue(val) != flag) { setMusic.Invoke(val, new object[1] { flag }); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY73 music receive: " + ex.Message)); } } private unsafe void SendMusicToClients(ulong id, bool enabled) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.IsServer || singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.music73", connectedClientsId, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY73 music broadcast: " + ex.Message)); } } } private unsafe void Update() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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 //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { registered = null; registeredRound = null; nextRegistration = (nextBroadcast = 0f); ClearAnchors(); sawShipTransform = false; return; } if ((Object)(object)registered != (Object)(object)singleton || (Object)(object)registeredRound != (Object)(object)instance || Time.unscaledTime >= nextRegistration) { singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.position73", new HandleNamedMessageDelegate(OnPosition)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.music73", new HandleNamedMessageDelegate(OnMusic)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.omega.clock77", new HandleNamedMessageDelegate(OnOmegaSync)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.guest.proximity78", new HandleNamedMessageDelegate(OnGuestPresence)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi.flowey.guest.click78", new HandleNamedMessageDelegate(OnGuestClick)); registered = singleton; registeredRound = instance; nextRegistration = Time.unscaledTime + 10f; } if (singleton.IsServer) { BroadcastOmegaClock(singleton); } else { SyncGuestFlowerVisuals(singleton); SendGuestPresence(singleton); HandleGuestHeldMusicClick(); } if (!singleton.IsServer || (Object)(object)instance == (Object)null || Time.unscaledTime < nextBroadcast) { return; } nextBroadcast = Time.unscaledTime + 0.45f; if (!(activeFlowers.GetValue(null) is IEnumerable enumerable)) { return; } FastBufferWriter val3 = default(FastBufferWriter); foreach (object item in enumerable) { GrabbableObject val = (GrabbableObject)((item is GrabbableObject) ? item : null); if ((Object)(object)val == (Object)null || val.isHeld || val.isPocketed || !((Behaviour)val).isActiveAndEnabled || (Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null || !((NetworkBehaviour)val).NetworkObject.IsSpawned) { continue; } ulong networkObjectId = ((NetworkBehaviour)val).NetworkObject.NetworkObjectId; ShipAnchor value = null; lock (anchorsLock) { hostAnchors.TryGetValue(networkObjectId, out value); } bool flag = value?.ship ?? false; Vector3 val2 = (flag ? value.local : Vector3.zero); if (!flag && (Object)(object)instance.elevatorTransform != (Object)null && (val.isInShipRoom || val.isInElevator || WithinShipVolume(instance.elevatorTransform, ((Component)val).transform.position))) { flag = true; val2 = instance.elevatorTransform.InverseTransformPoint(((Component)val).transform.position); } Vector3 position = ((Component)val).transform.position; byte b = (byte)((val.isInShipRoom ? 1u : 0u) | (uint)(val.isInElevator ? 2 : 0)); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val3))..ctor(72, (Allocator)2, -1); try { ((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); float num = (flag ? val2.x : position.x); ((FastBufferWriter)(ref val3)).WriteValueSafe<float>(ref num, default(ForPrimitives)); num = (flag ? val2.y : position.y); ((FastBufferWriter)(ref val3)).WriteValueSafe<float>(ref num, default(ForPrimitives)); num = (flag ? val2.z : position.z); ((FastBufferWriter)(ref val3)).WriteValueSafe<float>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val3)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); bool flag2 = (bool)musicOn.GetValue(val); ((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("hihi.flowey.position73", connectedClientsId, val3, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY73 position send: " + ex.Message)); } } } } private static bool WithinShipVolume(Transform ship, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ship.InverseTransformPoint(point); if (val.x >= -5.25f && val.x <= 5.25f && val.z >= -10f && val.z <= 9f && val.y >= -3f) { return val.y <= 5.5f; } return false; } private void OnPosition(ulong sender, FastBufferReader reader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.IsServer || sender != 0L) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); float num2 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); float num4 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num4, default(ForPrimitives)); byte flags = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref flags, default(ForPrimitives)); bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); GrabbableObject val = FlowerById(num); if ((Object)(object)val == (Object)null) { return; } if ((bool)musicOn.GetValue(val) != flag2) { setMusic.Invoke(val, new object[1] { flag2 }); } if (val.isHeld || val.isPocketed) { lock (anchorsLock) { guestAnchors.Remove(num); return; } } lock (anchorsLock) { guestAnchors[num] = new ShipAnchor { ship = flag, local = (Vector3)(flag ? new Vector3(num2, num3, num4) : Vector3.zero), world = (Vector3)(flag ? Vector3.zero : new Vector3(num2, num3, num4)), flags = flags }; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY73 position receive: " + ex.Message)); } } private static void ShipItemLateTick() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00bf: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null) { return; } NetworkManager singleton = NetworkManager.Singleton; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || (Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null) { return; } Transform elevatorTransform = instance.elevatorTransform; Vector3 val; if (singleton.IsServer) { int num; if (Instance.sawShipTransform) { val = elevatorTransform.position - Instance.lastShipWorld; num = ((((Vector3)(ref val)).sqrMagnitude > 2.5E-05f || Quaternion.Angle(elevatorTransform.rotation, Instance.lastShipRotation) > 0.04f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; Instance.sawShipTransform = true; Instance.lastShipWorld = elevatorTransform.position; Instance.lastShipRotation = elevatorTransform.rotation; if (!(activeFlowers.GetValue(null) is IEnumerable enumerable)) { return; } { foreach (object item in enumerable) { GrabbableObject val2 = (GrabbableObject)((item is GrabbableObject) ? item : null); if ((Object)(object)val2 == (Object)null || (Object)(object)((NetworkBehaviour)val2).NetworkObject == (Object)null || !((NetworkBehaviour)val2).NetworkObject.IsSpawned) { continue; } ulong networkObjectId = ((NetworkBehaviour)val2).NetworkObject.NetworkObjectId; if (val2.isHeld || val2.isPocketed) { lock (anchorsLock) { hostAnchors.Remove(networkObjectId); } continue; } ShipAnchor value; lock (anchorsLock) { hostAnchors.TryGetValue(networkObjectId, out value); } if (value == null) { if (!val2.isInShipRoom && !val2.isInElevator && !WithinShipVolume(elevatorTransform, ((Component)val2).transform.position)) { continue; } value = new ShipAnchor { ship = true, local = elevatorTransform.InverseTransformPoint(((Component)val2).transform.position) }; lock (anchorsLock) { hostAnchors[networkObjectId] = value; } } if (!flag) { if (!val2.isInShipRoom && !val2.isInElevator && !WithinShipVolume(elevatorTransform, ((Component)val2).transform.position)) { lock (anchorsLock) { hostAnchors.Remove(networkObjectId); } } else { value.local = elevatorTransform.InverseTransformPoint(((Component)val2).transform.position); } continue; } Vector3 val3 = elevatorTransform.TransformPoint(value.local); val = ((Component)val2).transform.position - val3; if (((Vector3)(ref val)).sqrMagnitude > 0.0009f) { ((Component)val2).transform.position = val3; } } return; } } KeyValuePair<ulong, ShipAnchor>[] array; lock (anchorsLock) { array = new List<KeyValuePair<ulong, ShipAnchor>>(guestAnchors).ToArray(); } KeyValuePair<ulong, ShipAnchor>[] array2 = array; for (int i = 0; i < array2.Length; i++) { KeyValuePair<ulong, ShipAnchor> keyValuePair = array2[i]; GrabbableObject val4 = FlowerById(keyValuePair.Key); if ((Object)(object)val4 == (Object)null || val4.isHeld || val4.isPocketed) { continue; } ShipAnchor value2 = keyValuePair.Value; if (value2.ship) { Vector3 val5 = elevatorTransform.TransformPoint(value2.local); val = ((Component)val4).transform.position - val5; if (((Vector3)(ref val)).sqrMagnitude > 0.04f) { ((Component)val4).transform.position = val5; } val4.isInShipRoom = true; val4.isInElevator = true; } else { val = ((Component)val4).transform.position - value2.world; if (((Vector3)(ref val)).sqrMagnitude > 0.5625f) { ((Component)val4).transform.position = value2.world; } lock (anchorsLock) { guestAnchors.Remove(keyValuePair.Key); } } } } private static void CaptureOmegaBirth(object __instance) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || __instance == null) { return; } object? value = bloomField.GetValue(__instance); CadaverBloomAI val = (CadaverBloomAI)((value is CadaverBloomAI) ? value : null); if (!((Object)(object)val == (Object)null)) { omegaAnchors.Remove(__instance); omegaAnchors.Add(__instance, new OmegaAnchor { pos = ((Component)val).transform.position }); ((EnemyAI)val).inSpecialAnimation = true; ((EnemyAI)val).movingTowardsTargetPlayer = false; if ((Object)(object)((EnemyAI)val).agent != (Object)null && ((Behaviour)((EnemyAI)val).agent).isActiveAndEnabled && ((EnemyAI)val).agent.isOnNavMesh) { ((EnemyAI)val).agent.ResetPath(); ((EnemyAI)val).agent.isStopped = true; ((EnemyAI)val).agent.velocity = Vector3.zero; } } } private static void FreezeOmegaDuringGrowth(object __instance) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; Vector3 val2; if ((Object)(object)singleton != (Object)null && !singleton.IsServer) { object? value = bloomField.GetValue(__instance); CadaverBloomAI val = (CadaverBloomAI)((value is CadaverBloomAI) ? value : null); if (!((Object)(object)val != (Object)null) || !((Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null) || !guestOmegaSync.TryGetValue(((NetworkBehaviour)val).NetworkObject.NetworkObjectId, out var value2)) { return; } NetworkTime serverTime = singleton.ServerTime; double num = ((NetworkTime)(ref serverTime)).Time - value2.epochServerTime; if (num >= 0.0 && num < 6.85) { ((EnemyAI)val).inSpecialAnimation = true; NavMeshAgent agent = ((EnemyAI)val).agent; if ((Object)(object)agent != (Object)null && ((Behaviour)agent).isActiveAndEnabled && agent.isOnNavMesh) { agent.isStopped = true; agent.velocity = Vector3.zero; val2 = ((Component)val).transform.position - value2.anchor; if (((Vector3)(ref val2)).sqrMagnitude > 0.0025f) { agent.Warp(value2.anchor); } } else { ((Component)val).transform.position = value2.anchor; } } else if (num >= 6.85) { ((EnemyAI)val).inSpecialAnimation = false; NavMeshAgent agent2 = ((EnemyAI)val).agent; if ((Object)(object)agent2 != (Object)null && ((Behaviour)agent2).isActiveAndEnabled && agent2.isOnNavMesh) { agent2.isStopped = false; } } } else { if ((Object)(object)singleton == (Object)null || !singleton.IsServer || __instance == null || !(bool)morphActive.GetValue(__instance)) { return; } float num2 = Time.time - (float)morphAt.GetValue(__instance); object? value3 = bloomField.GetValue(__instance); CadaverBloomAI val3 = (CadaverBloomAI)((value3 is CadaverBloomAI) ? value3 : null); if ((Object)(object)val3 == (Object)null || ((EnemyAI)val3).isEnemyDead || num2 < 0f) { return; } if (num2 >= 6.85f) { ((EnemyAI)val3).inSpecialAnimation = false; if (!omegaAnchors.TryGetValue(__instance, out var value4)) { value4 = new OmegaAnchor { pos = ((Component)val3).transform.position }; omegaAnchors.Add(__instance, value4); } NavMeshAgent agent3 = ((EnemyAI)val3).agent; if ((Object)(object)agent3 != (Object)null && ((Behaviour)agent3).isActiveAndEnabled && agent3.isOnNavMesh && !agent3.isStopped) { val2 = agent3.velocity; if (((Vector3)(ref val2)).sqrMagnitude > 0.12f) { value4.chaseMoving = true; } } if (!value4.chaseMoving && Time.time >= value4.nextKick) { value4.nextKick = Time.time + 0.35f; KickStartOmegaChase(val3, value4); } return; } ((EnemyAI)val3).inSpecialAnimation = true; if (!omegaAnchors.TryGetValue(__instance, out var value5)) { value5 = new OmegaAnchor { pos = ((Component)val3).transform.position }; omegaAnchors.Add(__instance, value5); } NavMeshAgent agent4 = ((EnemyAI)val3).agent; if ((Object)(object)agent4 != (Object)null && ((Behaviour)agent4).isActiveAndEnabled && agent4.isOnNavMesh) { agent4.isStopped = true; val2 = ((Component)val3).transform.position - value5.pos; if (((Vector3)(ref val2)).sqrMagnitude > 0.0025f) { agent4.Warp(value5.pos); } agent4.velocity = Vector3.zero; } else { val2 = ((Component)val3).transform.position - value5.pos; if (((Vector3)(ref val2)).sqrMagnitude > 0.0025f) { ((Component)val3).transform.position = value5.pos; } } ((EnemyAI)val3).movingTowardsTargetPlayer = false; } } private static void ShowPoisonTick(object __instance) { try { GameNetworkManager instance = GameNetworkManager.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.localPlayerController == (Object)null) && !instance.localPlayerController.isPlayerDead && (Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("FLOWEY", "POISON: -4 HP (active)", false, false, "LC_Tip1"); } } catch (Exception ex) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY73 poison HUD: " + ex.Message)); } } } private static void KickStartOmegaChase(CadaverBloomAI bloom, OmegaAnchor state) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bloom == (Object)null || ((EnemyAI)bloom).isEnemyDead) { return; } try { NavMeshAgent agent = ((EnemyAI)bloom).agent; if ((Object)(object)agent == (Object)null) { return; } if (!((Behaviour)agent).isActiveAndEnabled || !agent.isOnNavMesh) { NavMeshQueryFilter val = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref val)).agentTypeID = agent.agentTypeID; ((NavMeshQueryFilter)(ref val)).areaMask = -1; NavMeshQueryFilter val2 = val; NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)bloom).transform.position, ref val3, 2.5f, val2)) { if (((Behaviour)agent).enabled) { ((Behaviour)agent).enabled = false; } ((Component)bloom).transform.position = ((NavMeshHit)(ref val3)).position; ((Component)agent).transform.position = ((NavMeshHit)(ref val3)).position; ((Behaviour)agent).enabled = true; } if (!((Behaviour)agent).isActiveAndEnabled || !agent.isOnNavMesh) { if (!state.navWarning && (Object)(object)Instance != (Object)null) { state.navWarning = true; ((BaseUnityPlugin)Instance).Logger.LogWarning((object)"FLOWEY76: Omega cannot chase yet; agent not on NavMesh"); } return; } } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return; } PlayerControllerB val4 = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; Vector3 val6; foreach (PlayerControllerB val5 in allPlayerScripts) { if (!((Object)(object)val5 == (Object)null) && !val5.isPlayerDead && val5.isPlayerControlled && val5.isInsideFactory != ((EnemyAI)bloom).isOutside) { val6 = ((Component)val5).transform.position - ((Component)bloom).transform.position; float sqrMagnitude = ((Vector3)(ref val6)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val4 = val5; } } } if ((Object)(object)val4 == (Object)null) { return; } bloom.hasBurst = true; ((EnemyAI)bloom).inSpecialAnimation = false; ((EnemyAI)bloom).targetPlayer = val4; ((EnemyAI)bloom).movingTowardsTargetPlayer = true; if (((EnemyAI)bloom).currentBehaviourStateIndex != 1) { ((EnemyAI)bloom).SwitchToBehaviourState(1); } agent.isStopped = false; if (agent.hasPath && !(agent.remainingDistance < 0.05f)) { val6 = agent.velocity; if (!(((Vector3)(ref val6)).sqrMagnitude < 0.12f)) { goto IL_0217; } } agent.SetDestination(((Component)val4).transform.position); goto IL_0217; IL_0217: if (!state.releaseLogged && (Object)(object)Instance != (Object)null) { state.releaseLogged = true; ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("FLOWEY76: Omega chase resumed immediately after 4s rise; state=" + ((EnemyAI)bloom).currentBehaviourStateIndex + ", target=" + val4.playerClientId + ", onNavMesh=" + agent.isOnNavMesh)); } } catch (Exception ex) { if (!state.navWarning && (Object)(object)Instance != (Object)null) { state.navWarning = true; ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY76: chase setup retry: " + ex.Message)); } } } [HarmonyPriority(800)] private static bool BlockOmegaHitDuringGrowth(object __instance) { return HasCompletedOmegaEmergence(__instance); } [HarmonyPriority(800)] private static bool BlockNativeHitDuringGrowth(EnemyAI __instance) { CadaverBloomAI val = (CadaverBloomAI)(object)((__instance is CadaverBloomAI) ? __instance : null); if ((Object)(object)val == (Object)null) { return true; } Component component = ((Component)val).GetComponent(omegaType); if (!((Object)(object)component == (Object)null)) { return HasCompletedOmegaEmergence(component); } return true; } private static bool HasCompletedOmegaEmergence(object variant) { if (variant == null) { return true; } try { if (!(bool)morphActive.GetValue(variant)) { return false; } return Time.time - (float)morphAt.GetValue(variant) >= 7.6f; } catch (Exception ex) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY76: damage guard: " + ex.Message)); } return false; } } private unsafe void BroadcastOmegaClock(NetworkManager net) { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)net == (Object)null || net.SpawnManager == null || net.CustomMessagingManager == null || Time.unscaledTime < nextOmegaSync) { return; } nextOmegaSync = Time.unscaledTime + 0.125f; FastBufferWriter val = default(FastBufferWriter); foreach (KeyValuePair<ulong, NetworkObject> spawnedObject in net.SpawnManager.SpawnedObjects) { NetworkObject value = spawnedObject.Value; if ((Object)(object)value == (Object)null || !value.IsSpawned) { continue; } CadaverBloomAI componentInChildren = ((Component)value).GetComponentInChildren<CadaverBloomAI>(true); if ((Object)(object)componentInChildren == (Object)null || ((EnemyAI)componentInChildren).isEnemyDead) { continue; } Component component = ((Component)componentInChildren).GetComponent(omegaType); if ((Object)(object)component == (Object)null || !(bool)morphActive.GetValue(component)) { continue; } float num = Time.time - (float)morphAt.GetValue(component); if (num < 0f || num > 15f) { continue; } if (!omegaAnchors.TryGetValue(component, out var value2)) { value2 = new OmegaAnchor { pos = ((Component)componentInChildren).transform.position }; omegaAnchors.Add(component, value2); } ulong num2 = (ulong)omegaSourceId.GetValue(component); NetworkTime serverTime = net.ServerTime; double num3 = ((NetworkTime)(ref serverTime)).Time - (double)num; foreach (ulong connectedClientsId in net.ConnectedClientsIds) { if (connectedClientsId == net.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { ulong networkObjectId = value.NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num2, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref num3, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref value2.pos.x, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref value2.pos.y, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref value2.pos.z, default(ForPrimitives)); net.CustomMessagingManager.SendNamedMessage("hihi.flowey.omega.clock77", connectedClientsId, val, (NetworkDelivery)1); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { if (!omegaSyncWarned) { omegaSyncWarned = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY77 server emergence clock: " + ex.Message)); } } } } } private void OnOmegaSync(ulong sender, FastBufferReader reader) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.IsServer || sender != 0L) { return; } try { ulong key = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); ulong sourceFlowerId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref sourceFlowerId, default(ForPrimitives)); double num = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref num, default(ForPrimitives)); float num2 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); float num4 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num4, default(ForPrimitives)); if (!guestOmegaSync.TryGetValue(key, out var value) || !(num < value.epochServerTime - 0.5)) { guestOmegaSync[key] = new SyncedOmega { epochServerTime = num, anchor = new Vector3(num2, num3, num4), sourceFlowerId = sourceFlowerId, receivedAt = Time.unscaledTime }; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY77 emergence sync receive: " + ex.Message)); } } private void SyncGuestFlowerVisuals(NetworkManager net) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (net.SpawnManager == null) { return; } List<ulong> list = new List<ulong>(); foreach (KeyValuePair<ulong, SyncedOmega> item in guestOmegaSync) { SyncedOmega value = item.Value; if (Time.unscaledTime - value.receivedAt > 18f) { list.Add(item.Key); } else { if (value.sourceFlowerId == ulong.MaxValue || !net.SpawnManager.SpawnedObjects.TryGetValue(value.sourceFlowerId, out var value2) || (Object)(object)value2 == (Object)null) { continue; } Component component = ((Component)value2).GetComponent(itemType); if ((Object)(object)component == (Object)null) { continue; } NetworkTime serverTime = net.ServerTime; float num = (float)Math.Max(0.0, ((NetworkTime)(ref serverTime)).Time - value.epochServerTime); try { if (!(bool)flowerMorphStarted.GetValue(component)) { startFlowerMorph.Invoke(component, null); } flowerMorphStartTime.SetValue(component, Time.time - num); } catch (Exception ex) { if (!omegaSyncWarned) { omegaSyncWarned = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY77 flower clock: " + ex.Message)); } } } } foreach (ulong item2 in list) { guestOmegaSync.Remove(item2); } } private static void PreSyncOmegaVisual(object __instance) { //IL_0070: 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_00ed: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.IsServer || __instance == null) { return; } object? value = bloomField.GetValue(__instance); CadaverBloomAI val = (CadaverBloomAI)((value is CadaverBloomAI) ? value : null); if ((Object)(object)val == (Object)null || (Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null || ((EnemyAI)val).isEnemyDead || !guestOmegaSync.TryGetValue(((NetworkBehaviour)val).NetworkObject.NetworkObjectId, out var value2)) { return; } NetworkTime serverTime = singleton.ServerTime; float num = (float)Math.Max(0.0, ((NetworkTime)(ref serverTime)).Time - value2.epochServerTime); try { if (!(bool)morphActive.GetValue(__instance)) { startOmegaMorph.Invoke(__instance, new object[2] { value2.sourceFlowerId, num }); } morphAt.SetValue(__instance, Time.time - num); if (num < 6.85f) { ((Component)val).transform.position = value2.anchor; } } catch (Exception ex) { if ((Object)(object)Instance != (Object)null && !Instance.omegaSyncWarned) { Instance.omegaSyncWarned = true; ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY77 shared emergence visual: " + ex.Message)); } } } private static PlayerControllerB SenderPlayer(ulong sender) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return null; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && val.actualClientId == sender) { return val; } } return null; } private static bool ValidGuestFlower(ulong sender, ulong id, out GrabbableObject item, out PlayerControllerB player) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) item = FlowerById(id); player = SenderPlayer(sender); if ((Object)(object)item == (Object)null || (Object)(object)player == (Object)null || item.isHeld || item.isPocketed || (bool)endedField.GetValue(item)) { return false; } Vector3 val = ((Component)player).transform.position - ((Component)item).transform.position; return ((Vector3)(ref val)).sqrMagnitude <= 56.25f; } private void OnGuestPresence(ulong sender, FastBufferReader reader) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || sender == singleton.LocalClientId) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); if (ValidGuestFlower(sender, num, out var item, out var player)) { liveGuestPresence[num] = new GuestPresence { sender = sender, expires = Time.unscaledTime + 1.5f }; if (listenerField.GetValue(item) == null) { startDialogue.Invoke(item, new object[1] { player }); ((BaseUnityPlugin)this).Logger.LogInfo((object)("FLOWEY78 guest proximity started host dialogue; client=" + sender)); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY78 guest proximity: " + ex.Message)); } } private void OnGuestClick(ulong sender, FastBufferReader reader) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || sender == singleton.LocalClientId) { return; } try { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); if (ValidGuestFlower(sender, num, out var item, out var player)) { liveGuestPresence[num] = new GuestPresence { sender = sender, expires = Time.unscaledTime + 1.5f }; bool flag = listenerField.GetValue(item) == null; if (flag) { startDialogue.Invoke(item, new object[1] { player }); } bool flag2 = flag || (bool)advanceDialogue.Invoke(item, null); ((BaseUnityPlugin)this).Logger.LogInfo((object)("FLOWEY78 guest dialogue click: client=" + sender + " advanced=" + flag2)); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY78 guest dialogue click: " + ex.Message)); } } private static void HostRecognizeGuestPresence(object __instance, float radius, ref PlayerControllerB __result) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__result != (Object)null || radius > 6.5f) { return; } NetworkManager singleton = NetworkManager.Singleton; GrabbableObject val = (GrabbableObject)((__instance is GrabbableObject) ? __instance : null); if ((Object)(object)singleton == (Object)null || !singleton.IsServer || (Object)(object)val == (Object)null || (Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null || !liveGuestPresence.TryGetValue(((NetworkBehaviour)val).NetworkObject.NetworkObjectId, out var value)) { return; } if (Time.unscaledTime > value.expires) { liveGuestPresence.Remove(((NetworkBehaviour)val).NetworkObject.NetworkObjectId); return; } PlayerControllerB val2 = SenderPlayer(value.sender); if ((Object)(object)val2 != (Object)null) { Vector3 val3 = ((Component)val2).transform.position - ((Component)val).transform.position; if (((Vector3)(ref val3)).sqrMagnitude <= 56.25f) { __result = val2; } } } private static bool GuestDialogueClickIntercept(PlayerControllerB localPlayer, ref bool __result) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.IsServer) { return true; } if ((Object)(object)localPlayer == (Object)null || localPlayer.isPlayerDead) { __result = false; return false; } if ((Object)(object)GetHeldFlower(localPlayer) != (Object)null) { __result = true; return false; } GrabbableObject nearbyGuestFlower = GetNearbyGuestFlower(localPlayer); if ((Object)(object)nearbyGuestFlower == (Object)null) { __result = false; return false; } __result = (Object)(object)Instance != (Object)null && Instance.SendGuestPacket("hihi.flowey.guest.click78", ((NetworkBehaviour)nearbyGuestFlower).NetworkObject.NetworkObjectId); return false; } private static GrabbableObject GetNearbyGuestFlower(PlayerControllerB player) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (!(activeFlowers.GetValue(null) is IEnumerable enumerable) || (Object)(object)player == (Object)null) { return null; } GrabbableObject result = null; float num = 14.0625f; foreach (object item in enumerable) { GrabbableObject val = (GrabbableObject)((item is GrabbableObject) ? item : null); if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && !((Object)(object)((NetworkBehaviour)val).NetworkObject == (Object)null) && ((NetworkBehaviour)val).NetworkObject.IsSpawned && !val.isHeld && !val.isPocketed && !(bool)endedField.GetValue(val)) { Vector3 val2 = ((Component)val).transform.position - ((Component)player).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private static GrabbableObject GetHeldFlower(PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return null; } if ((Object)(object)player.currentlyHeldObjectServer != (Object)null && itemType.IsInstanceOfType(player.currentlyHeldObjectServer)) { return player.currentlyHeldObjectServer; } if (player.ItemSlots != null && player.currentItemSlot >= 0 && player.currentItemSlot < player.ItemSlots.Length && (Object)(object)player.ItemSlots[player.currentItemSlot] != (Object)null && itemType.IsInstanceOfType(player.ItemSlots[player.currentItemSlot])) { return player.ItemSlots[player.currentItemSlot]; } if (activeFlowers.GetValue(null) is IEnumerable enumerable) { foreach (object item in enumerable) { GrabbableObject val = (GrabbableObject)((item is GrabbableObject) ? item : null); if ((Object)(object)val != (Object)null && val.playerHeldBy == player && !val.isPocketed) { return val; } } } return null; } private void SendGuestPresence(NetworkManager net) { if (Time.unscaledTime < nextGuestPresence) { return; } nextGuestPresence = Time.unscaledTime + 0.33f; GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val = (((Object)(object)instance == (Object)null) ? null : instance.localPlayerController); if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !((Object)(object)GetHeldFlower(val) != (Object)null)) { GrabbableObject nearbyGuestFlower = GetNearbyGuestFlower(val); if ((Object)(object)nearbyGuestFlower != (Object)null) { SendGuestPacket("hihi.flowey.guest.proximity78", ((NetworkBehaviour)nearbyGuestFlower).NetworkObject.NetworkObjectId); } } } private unsafe bool SendGuestPacket(string message, ulong flowerId) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.IsServer || !singleton.IsListening || singleton.CustomMessagingManager == null) { return false; } try { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref flowerId, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage(message, 0uL, val, (NetworkDelivery)((message == "hihi.flowey.guest.proximity78") ? 1 : 3)); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FLOWEY78 guest send " + message + ": " + ex.Message)); return false; } } private void HandleGuestHeldMusicClick() { Mouse current = Mouse.current; if (current != null && current.leftButton.wasPressedThisFrame) { GameNetworkManager instance = GameNetworkManager.Instance; GrabbableObject heldFlower = GetHeldFlower(((Object)(object)instance == (Object)null) ? null : instance.localPlayerController); if ((Object)(object)heldFlower != (Object)null && !heldFlower.isPocketed && toggleMusic != null) { toggleMusic.Invoke(heldFlower, null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FLOWEY78 guest music LMB recognized."); } } } private static void SetDialogueSpatialAudio(object __instance) { if (__instance != null && !(dialogueAudioField == null)) { object? value = dialogueAudioField.GetValue(__instance); AudioSource val = (AudioSource)((value is AudioSource) ? value : null); if (!((Object)(object)val == (Object)null)) { val.spatialBlend = 1f; val.minDistance = 0.7f; val.maxDistance = 8f; val.rolloffMode = (AudioRolloffMode)1; } } } private static IEnumerable<CodeInstruction> AvoidGuestFlowerReparent(IEnumerable<CodeInstruction> stream) { List<CodeInstruction> list = new List<CodeInstruction>(stream); MethodInfo operand = AccessTools.Method(typeof(FloweyStability73), "SafeFlowerReparent", (Type[])null, (Type[])null); int num = 0; for (int i = 0; i < list.Count; i++) { if ((!(list[i].opcode != OpCodes.Callvirt) || !(list[i].opcode != OpCodes.Call)) && list[i].operand is MethodInfo methodInfo && !(methodInfo.Name != "SetParent") && !(methodInfo.DeclaringType != typeof(Transform)) && methodInfo.GetParameters().Length == 2 && !(methodInfo.GetParameters()[1].ParameterType != typeof(bool))) { num++; } } if (num != 2) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)("FLOWEY78 guest pickup parent patch skipped: unexpected SetParent count=" + num)); } return list; } for (int j = 0; j < list.Count; j++) { if ((!(list[j].opcode != OpCodes.Callvirt) || !(list[j].opcode != OpCodes.Call)) && list[j].operand is MethodInfo methodInfo2 && !(methodInfo2.Name != "SetParent") && !(methodInfo2.DeclaringType != typeof(Transform)) && methodInfo2.GetParameters().Length == 2 && !(methodInfo2.GetParameters()[1].ParameterType != typeof(bool))) { list[j].opcode = OpCodes.Call; list[j].operand = operand; } } return list; } private static void SafeFlowerReparent(Transform subject, Transform parent, bool keepWorld) { if (!((Object)(object)subject == (Object)null)) { NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton != (Object)null) || !singleton.IsListening || singleton.IsServer || !(itemType != null) || !((Object)(object)((Component)subject).GetComponentInParent(itemType) != (Object)null)) { subject.SetParent(parent, keepWorld); } } } }
plugins/Frisk/FriskBodyMod.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
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.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Frisk 3D Suit")] [assembly: AssemblyFileVersion("0.7.13.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.7.13.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 FriskBodyMod { internal sealed class FriskArmSurface { private readonly byte[][] _replaced; private readonly Mesh _mesh; private readonly Material[] _materials; private Mesh _sleeves; private bool _bound; private FriskArmSurface(byte[][] replaced, Mesh mesh, Material[] materials) { _replaced = replaced; _mesh = mesh; _materials = materials; } public bool Replaces(int source, int triangle) { return (_replaced[source][triangle >> 3] & (1 << (triangle & 7))) != 0; } public SkinnedMeshRenderer Attach(Transform parent, Transform[] bones, int layer, bool hideHands = false) { //IL_0051: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown if (!_bound) { Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[bones.Length]; for (int i = 0; i < bones.Length; i++) { array[i] = bones[i].worldToLocalMatrix * parent.localToWorldMatrix; } _mesh.bindposes = array; _bound = true; } GameObject val = new GameObject("Frisk_SleevesAndHands") { layer = layer }; val.transform.SetParent(parent, false); SkinnedMeshRenderer val2 = val.AddComponent<SkinnedMeshRenderer>(); val2.bones = bones; val2.rootBone = parent; if (hideHands && (Object)(object)_sleeves == (Object)null) { int[][] array2 = new int[_mesh.subMeshCount][]; for (int j = 0; j < array2.Length; j++) { array2[j] = _mesh.GetTriangles(j); } FriskSleeveClip friskSleeveClip = new FriskSleeveClip(_mesh.vertices, _mesh.normals, _mesh.uv, _mesh.boneWeights, array2); _sleeves = new Mesh { name = "Frisk_WeightedSleeves", indexFormat = (IndexFormat)1 }; _sleeves.vertices = friskSleeveClip.Positions.ToArray(); _sleeves.normals = friskSleeveClip.Normals.ToArray(); _sleeves.uv = friskSleeveClip.UV.ToArray(); _sleeves.boneWeights = friskSleeveClip.Weights.ToArray(); _sleeves.bindposes = _mesh.bindposes; _sleeves.subMeshCount = array2.Length; for (int k = 0; k < array2.Length; k++) { _sleeves.SetTriangles(friskSleeveClip.Submeshes[k], k); } _sleeves.RecalculateBounds(); } val2.sharedMesh = (hideHands ? _sleeves : _mesh); ((Renderer)val2).sharedMaterials = _materials; val2.quality = (SkinQuality)4; ((Renderer)val2).localBounds = new Bounds(new Vector3(0f, -0.12f, 0f), new Vector3(2.3f, 2.3f, 2.3f)); val2.updateWhenOffscreen = true; return val2; } public static FriskArmSurface Load(string path, Mesh[] source, Material cloth) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "FRSKARM1" || binaryReader.ReadInt32() != source.Length) { throw new InvalidDataException("Invalid Frisk arm asset."); } byte[][] array = new byte[source.Length][]; for (int i = 0; i < source.Length; i++) { int num = binaryReader.ReadInt32(); if (num != (int)source[i].GetIndexCount(0) / 3) { throw new InvalidDataException("Frisk arm data does not match the body."); } array[i] = binaryReader.ReadBytes((num + 7) / 8); if (array[i].Length != (num + 7) / 8) { throw new EndOfStreamException(); } } int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); if (num2 < 3 || num2 > 250000 || num3 < 3 || num4 < 3 || num3 > 2000000 || num4 > 2000000 || num3 % 3 != 0 || num4 % 3 != 0) { throw new InvalidDataException("Invalid Frisk arm mesh dimensions."); } Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector2[] array4 = (Vector2[])(object)new Vector2[num2]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num2]; for (int j = 0; j < num2; j++) { array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int num5 = j; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = binaryReader.ReadByte(); ((BoneWeight)(ref val)).boneIndex1 = binaryReader.ReadByte(); ((BoneWeight)(ref val)).boneIndex2 = binaryReader.ReadByte(); ((BoneWeight)(ref val)).boneIndex3 = binaryReader.ReadByte(); ((BoneWeight)(ref val)).weight0 = (float)(int)binaryReader.ReadByte() / 255f; ((BoneWeight)(ref val)).weight1 = (float)(int)binaryReader.ReadByte() / 255f; ((BoneWeight)(ref val)).weight2 = (float)(int)binaryReader.ReadByte() / 255f; ((BoneWeight)(ref val)).weight3 = (float)(int)binaryReader.ReadByte() / 255f; array5[num5] = val; } int[] array6 = new int[num3]; int[] array7 = new int[num4]; for (int k = 0; k < num3; k++) { array6[k] = binaryReader.ReadInt32(); } for (int l = 0; l < num4; l++) { array7[l] = binaryReader.ReadInt32(); } int num6 = binaryReader.ReadInt32(); if (num6 <= 0 || num6 != binaryReader.BaseStream.Length - binaryReader.BaseStream.Position) { throw new InvalidDataException("Invalid Frisk lining texture."); } Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val2, binaryReader.ReadBytes(num6))) { throw new InvalidDataException("Invalid Frisk lining image."); } ((Texture)val2).wrapMode = (TextureWrapMode)1; Material val3 = new Material(cloth); ((Object)val3).name = "Frisk_SleeveAndShirtInside"; if (val3.HasProperty("_BaseColorMap")) { val3.SetTexture("_BaseColorMap", (Texture)(object)val2); } if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val2); } Mesh val4 = new Mesh(); ((Object)val4).name = "Frisk_WeightedArms"; val4.indexFormat = (IndexFormat)(num2 > 65535); val4.vertices = array2; val4.normals = array3; val4.uv = array4; for (int m = 0; m < num2; m++) { array5[m] = FriskSurfaceMath.MatchTorso(array2[m], array5[m]); } val4.boneWeights = array5; val4.subMeshCount = 2; val4.SetTriangles(array6, 0); val4.SetTriangles(array7, 1); val4.RecalculateBounds(); return new FriskArmSurface(array, val4, (Material[])(object)new Material[2] { cloth, val3 }); } } public sealed class FriskAsset { public const float SourceMinY = -0.952042f; public const float SourceMaxY = 0.951955f; public float Height => 1.903997f; public Mesh[] Meshes { get; private set; } public Material Material { get; private set; } internal FriskArmSurface Arms { get; private set; } public static FriskAsset Load(string filePath) { //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown using FileStream input = File.OpenRead(filePath); using BinaryReader binaryReader = new BinaryReader(input); byte[] bytes = binaryReader.ReadBytes(8); if (Encoding.ASCII.GetString(bytes) != "FRSKM001") { throw new InvalidDataException("Invalid Frisk mesh file."); } int num = binaryReader.ReadInt32(); if (num < 1 || num > 32) { throw new InvalidDataException("Invalid mesh count."); } Mesh[] array = (Mesh[])(object)new Mesh[num]; for (int i = 0; i < num; i++) { int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num2 <= 0 || num2 > 250000 || num3 <= 0 || num3 > 2000000 || num3 % 3 != 0) { throw new InvalidDataException("Invalid mesh dimensions."); } Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector2[] array4 = (Vector2[])(object)new Vector2[num2]; int[] array5 = new int[num3]; for (int j = 0; j < num2; j++) { array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int k = 0; k < num2; k++) { array3[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int l = 0; l < num2; l++) { array4[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int m = 0; m < num3; m++) { array5[m] = binaryReader.ReadInt32(); } Mesh val = new Mesh(); ((Object)val).name = "FriskSourceMesh" + i; val.indexFormat = (IndexFormat)(num2 > 65535); val.vertices = array2; val.normals = array3; val.uv = array4; val.triangles = array5; val.RecalculateBounds(); array[i] = val; } int num4 = binaryReader.ReadInt32(); if (num4 <= 0 || num4 > 30000000) { throw new InvalidDataException("Invalid texture length."); } byte[] array6 = binaryReader.ReadBytes(num4); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, true); ((Object)val2).name = "FriskBaseColor"; if (!ImageConversion.LoadImage(val2, array6)) { throw new InvalidDataException("Texture could not be decoded."); } ((Texture)val2).wrapMode = (TextureWrapMode)0; ((Texture)val2).filterMode = (FilterMode)2; ((Texture)val2).anisoLevel = 4; Shader obj = Shader.Find("HDRP/Lit") ?? Shader.Find("High Definition Render Pipeline/Lit") ?? Shader.Find("Standard"); if ((Object)(object)obj == (Object)null) { throw new Exception("No suitable texture shader was found."); } Material val3 = new Material(obj); ((Object)val3).name = "FriskBodyMaterial"; if (val3.HasProperty("_BaseColorMap")) { val3.SetTexture("_BaseColorMap", (Texture)(object)val2); } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", Color.white); } if (val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)val2); } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", Color.white); } if (val3.HasProperty("_Smoothness")) { val3.SetFloat("_Smoothness", 0.15f); } if (val3.HasProperty("_CullMode")) { val3.SetFloat("_CullMode", 0f); } if (val3.HasProperty("_DoubleSidedEnable")) { val3.SetFloat("_DoubleSidedEnable", 1f); } FriskArmSurface arms = FriskArmSurface.Load(Path.Combine(Path.GetDirectoryName(filePath), "frisk.arms"), array, val3); FriskCrownRepair.Apply(array); return new FriskAsset { Meshes = array, Material = val3, Arms = arms }; } } [DefaultExecutionOrder(21001)] internal sealed class FriskCorpse : MonoBehaviour { private static readonly HashSet<int> Failed = new HashSet<int>(); private SkinnedMeshRenderer _source; private readonly List<SkinnedMeshRenderer> _hidden = new List<SkinnedMeshRenderer>(); private readonly List<bool> _hiddenForce = new List<bool>(); private readonly List<Mesh> _ownedMeshes = new List<Mesh>(); private readonly List<Material> _ownedMaterials = new List<Material>(); private GameObject _root; private Transform[] _rig; private Transform[] _native; private FriskJoint[] _joints; private Quaternion _basis; private float _scale; private bool _ready; internal bool Initialize(DeadBodyInfo body, FriskAsset asset, float ratio) { int instanceID = ((Object)body).GetInstanceID(); if (Failed.Contains(instanceID)) { return false; } try { if (!Build(body, asset, ratio)) { Failed.Add(instanceID); Cleanup(); return false; } return true; } catch (Exception ex) { Failed.Add(instanceID); FriskPlugin.Log.LogWarning((object)("FRISK_41 corpse setup failed; vanilla body kept: " + ex.Message)); Cleanup(); return false; } } private bool Build(DeadBodyInfo body, FriskAsset asset, float ratio) { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer val = null; int num = 0; SkinnedMeshRenderer[] componentsInChildren = ((Component)body).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null || val2.bones == null) { continue; } int num2 = 0; string[][] names = FriskVisual.Names; foreach (string[] names2 in names) { if ((Object)(object)FriskBones.Find(val2.bones, names2) != (Object)null) { num2++; } } if (num2 > num) { val = val2; num = num2; } } if ((Object)(object)val == (Object)null || num < FriskVisual.Names.Length - 2) { return false; } _source = val; int num3 = FriskVisual.Rest.Length; _native = (Transform[])(object)new Transform[num3]; for (int k = 0; k < num3; k++) { _native[k] = FriskBones.Find(_source.bones, FriskVisual.Names[k]); } if ((Object)(object)_native[0] == (Object)null || (Object)(object)_native[2] == (Object)null) { return false; } _basis = FriskBones.Basis(_source, ((Component)body).transform); float num4 = BindHeight(_source, _basis); _scale = num4 * ratio / asset.Height; _root = new GameObject("Frisk_Corpse"); _root.transform.localScale = Vector3.one * _scale; _rig = (Transform[])(object)new Transform[num3]; for (int l = 0; l < num3; l++) { _rig[l] = new GameObject("FriskCorpseBone_" + FriskVisual.Names[l][0]).transform; } for (int m = 0; m < num3; m++) { int num5 = FriskVisual.Parents[m]; _rig[m].SetParent((num5 < 0) ? _root.transform : _rig[num5], false); _rig[m].localPosition = FriskVisual.Rest[m] - ((num5 < 0) ? Vector3.zero : FriskVisual.Rest[num5]); _rig[m].localRotation = Quaternion.identity; } _joints = new FriskJoint[num3]; for (int n = 0; n < num3; n++) { bool flag = n == 5 || n == 8; int num6 = FriskVisual.Ends[n]; Vector3 restAxis = (Vector3)((num6 >= 0) ? (FriskVisual.Rest[num6] - FriskVisual.Rest[n]) : (flag ? new Vector3((n == 5) ? 0.006f : (-0.006f), -0.135f, 0.008f) : ((n == 11 || n == 14) ? Vector3.forward : Vector3.up))); Transform end = ((num6 >= 0) ? _native[num6] : null); if (n == 11) { end = FriskBones.Find(_source.bones, "toe.L", "toes.L"); } if (n == 14) { end = FriskBones.Find(_source.bones, "toe.R", "toes.R"); } _joints[n] = new FriskJoint(_source, _native[n], end, _rig[n], restAxis, _basis, flag); } int layer = ((Component)_source).gameObject.layer; SkinnedMeshRenderer[] array = FriskSkinning.BuildBody(asset, _root.transform, _rig, layer, _ownedMeshes); if (array == null || array.Length == 0) { return false; } asset.Arms.Attach(_root.transform, _rig, layer); componentsInChildren = ((Component)body).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null)) { _hidden.Add(val3); _hiddenForce.Add(((Renderer)val3).forceRenderingOff); ((Renderer)val3).forceRenderingOff = true; } } _ready = true; ApplyPose(); FriskPlugin.Log.LogInfo((object)("FRISK_41 corpse visual ready: bones=" + num + "/" + num3 + ", scale=" + _scale.ToString("F3"))); return true; } private static float BindHeight(SkinnedMeshRenderer source, Quaternion basis) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = source.sharedMesh.bounds; Vector3 val = basis * Vector3.up; float num = float.MaxValue; float num2 = float.MinValue; for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { float num3 = Vector3.Dot(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)i, (float)j, (float)k)), val); num = Mathf.Min(num, num3); num2 = Mathf.Max(num2, num3); } } } float num4 = (num2 - num) * Mathf.Abs(((Component)source).transform.lossyScale.y); if (num4 < 0.5f || num4 > 4f || float.IsNaN(num4)) { num4 = 2f; } return num4; } private void ApplyPose() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_source == (Object)null) && !((Object)(object)_root == (Object)null)) { _root.transform.rotation = ((Component)_source).transform.rotation * _basis; int[] order = FriskVisual.Order; foreach (int num in order) { _joints[num]?.Apply(Quaternion.identity); } Transform val = _native[0]; if ((Object)(object)val != (Object)null) { Transform transform = _root.transform; transform.position += val.position - _rig[0].position; } } } private void LateUpdate() { if (!_ready) { return; } try { ApplyPose(); } catch (Exception ex) { FriskPlugin.Log.LogWarning((object)("FRISK_41 corpse pose error; vanilla body restored: " + ex.Message)); _ready = false; Cleanup(); } } private void OnEnable() { if ((Object)(object)_root != (Object)null) { _root.SetActive(true); } } private void OnDisable() { if ((Object)(object)_root != (Object)null) { _root.SetActive(false); } } private void OnDestroy() { Cleanup(); } private void Cleanup() { for (int i = 0; i < _hidden.Count; i++) { if ((Object)(object)_hidden[i] != (Object)null) { ((Renderer)_hidden[i]).forceRenderingOff = _hiddenForce[i]; } } _hidden.Clear(); _hiddenForce.Clear(); if ((Object)(object)_root != (Object)null) { _root.SetActive(false); Object.Destroy((Object)(object)_root); _root = null; } foreach (Mesh ownedMesh in _ownedMeshes) { if ((Object)(object)ownedMesh != (Object)null) { Object.Destroy((Object)(object)ownedMesh); } } foreach (Material ownedMaterial in _ownedMaterials) { if ((Object)(object)ownedMaterial != (Object)null) { Object.Destroy((Object)(object)ownedMaterial); } } _ownedMeshes.Clear(); _ownedMaterials.Clear(); } } internal static class FriskCrosshairHider { private static Transform _crosshair; private static Vector3 _originalScale = Vector3.one; private static bool _hidden; private static float _searchAt; private static Transform Find() { //IL_004e: 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) if ((Object)(object)_crosshair != (Object)null) { return _crosshair; } if (Time.unscaledTime < _searchAt) { return null; } _searchAt = Time.unscaledTime + 2f; TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((Object)val).name.IndexOf("CrossHair", StringComparison.OrdinalIgnoreCase) >= 0) { _crosshair = ((TMP_Text)val).transform; ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK crosshair found: " + ((Object)val).name)); } break; } } return _crosshair; } internal static bool LookingThroughOwnEyes(PlayerControllerB player, bool emoteThirdPerson) { if ((Object)(object)player != (Object)null) { return !emoteThirdPerson; } return false; } internal static void Apply(bool hide) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Transform val = Find(); if ((Object)(object)val == (Object)null) { return; } if (hide) { if (!_hidden) { _originalScale = val.localScale; _hidden = true; } val.localScale = Vector3.zero; } else if (_hidden) { val.localScale = ((_originalScale == Vector3.zero) ? Vector3.one : _originalScale); _hidden = false; } } } internal static class FriskCrownRepair { private static readonly Vector2 HairUV = new Vector2(0.23095703f, 0.90185547f); internal static void Apply(Mesh[] meshes) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) if (meshes == null) { return; } int num = 0; foreach (Mesh val in meshes) { if ((Object)(object)val == (Object)null) { continue; } Vector3[] vertices = val.vertices; Vector3[] normals = val.normals; Vector2[] uv = val.uv; int[] triangles = val.triangles; if (vertices.Length != uv.Length || vertices.Length != normals.Length) { continue; } int num2 = triangles.Length / 3; bool[] array = new bool[num2]; bool[] array2 = new bool[vertices.Length]; int num3 = 0; for (int j = 0; j < num2; j++) { int num4 = triangles[j * 3]; int num5 = triangles[j * 3 + 1]; int num6 = triangles[j * 3 + 2]; Vector3 val2 = vertices[num4]; Vector3 val3 = vertices[num5]; Vector3 val4 = vertices[num6]; float num7 = (val2.y + val3.y + val4.y) / 3f; float num8 = Mathf.Min(val2.y, Mathf.Min(val3.y, val4.y)); float num9 = (val2.x + val3.x + val4.x) / 3f; float num10 = (val2.z + val3.z + val4.z) / 3f; if (array[j] = num7 > 0.62f && num8 > 0.56f && Mathf.Abs(num9) < 0.59f && Mathf.Abs(num10) < 0.59f) { num3++; continue; } array2[num4] = true; array2[num5] = true; array2[num6] = true; } if (num3 == 0) { continue; } List<Vector3> list = new List<Vector3>(vertices); List<Vector3> list2 = new List<Vector3>(normals); List<Vector2> list3 = new List<Vector2>(uv); Dictionary<int, int> dictionary = new Dictionary<int, int>(); for (int k = 0; k < num2; k++) { if (!array[k]) { continue; } for (int l = 0; l < 3; l++) { int num11 = k * 3 + l; int num12 = triangles[num11]; if (array2[num12]) { if (!dictionary.TryGetValue(num12, out var value)) { value = list.Count; list.Add(vertices[num12]); list2.Add(normals[num12]); list3.Add(HairUV); dictionary.Add(num12, value); } triangles[num11] = value; } else { list3[num12] = HairUV; } } } val.indexFormat = (IndexFormat)(list.Count > 65535); val.vertices = list.ToArray(); val.normals = list2.ToArray(); val.uv = list3.ToArray(); val.triangles = triangles; val.RecalculateBounds(); num += num3; } ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK_38 crown UV cleanup: " + num + " upper-hair triangles remapped to clean brown. Original geometry/rig preserved.")); } } } internal static class FriskEmoteBridge { private static bool _attempted; private static FieldInfo _mappers; private static FieldInfo _currentClip; private static FieldInfo _thirdPerson; private static FieldInfo _externalThirdPerson; private static MethodInfo _enableThirdPerson; private static Type _mapperType; private static Type _apiType; private static bool _failed; private static void Discover() { if (_attempted) { return; } _attempted = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name.IndexOf("EmotesAPI", StringComparison.OrdinalIgnoreCase) < 0) { continue; } try { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.Name == "BoneMapper") { _mapperType = type; } if (type.Name == "CustomEmotesAPI") { _apiType = type; } } } catch (ReflectionTypeLoadException ex) { Type[] types = ex.Types; foreach (Type type2 in types) { if (!(type2 == null)) { if (type2.Name == "BoneMapper") { _mapperType = type2; } if (type2.Name == "CustomEmotesAPI") { _apiType = type2; } } } } catch { } } if (!(_mapperType == null)) { _mappers = _mapperType.GetField("playersToMappers", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _currentClip = _mapperType.GetField("currentClip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _thirdPerson = _mapperType.GetField("isInThirdPerson", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _enableThirdPerson = _mapperType.GetMethod("TurnOnThirdPerson", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_apiType != null) { _externalThirdPerson = _apiType.GetField("LCThirdPersonPresent", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } } } internal static object MapperFor(GameObject player) { Discover(); if (_failed || _mappers == null || (Object)(object)player == (Object)null) { return null; } try { if (_mappers.GetValue(null) is IDictionary dictionary && dictionary.Contains(player)) { return dictionary[player]; } } catch { _failed = true; } return null; } internal static bool HasActiveClip(object mapper) { if (mapper == null || _currentClip == null) { return false; } try { return _currentClip.GetValue(mapper) != null; } catch { return false; } } internal static bool IsThirdPerson(object mapper) { if (mapper == null || _thirdPerson == null) { return false; } try { object value = _thirdPerson.GetValue(mapper); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } internal static void RequestThirdPerson(object mapper) { if (mapper == null || _enableThirdPerson == null || !HasActiveClip(mapper)) { return; } try { bool flag = default(bool); int num; if (_externalThirdPerson != null) { object value = _externalThirdPerson.GetValue(null); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return; } object value2 = _currentClip.GetValue(mapper); if (value2 == null) { return; } Type type = value2.GetType(); FieldInfo field = type.GetField("allowThirdPerson", BindingFlags.Instance | BindingFlags.Public); if (field != null) { object value = field.GetValue(value2); if (value is bool && !(bool)value) { return; } } FieldInfo field2 = type.GetField("forceCameraMode", BindingFlags.Instance | BindingFlags.Public); FieldInfo field3 = type.GetField("thirdPerson", BindingFlags.Instance | BindingFlags.Public); bool flag2 = default(bool); int num2; if (field2 != null) { object value = field2.GetValue(value2); if (value is bool) { flag2 = (bool)value; num2 = 1; } else { num2 = 0; } } else { num2 = 0; } if (((uint)num2 & (flag2 ? 1u : 0u)) != 0 && field3 != null) { object value = field3.GetValue(value2); if (value is bool && !(bool)value) { return; } } _enableThirdPerson.Invoke(mapper, null); } catch { } } } internal sealed class FriskItemProxy : IDisposable { private sealed class Part { internal Renderer Source; internal Renderer World; internal Renderer View; internal MeshFilter SourceMesh; internal MeshFilter WorldMesh; internal MeshFilter ViewMesh; internal FriskRadarSurface RadarSurface; internal bool OriginalForceOff; internal Transform[] SourceBones; internal Transform[] WorldBones; internal Transform[] ViewBones; internal MaterialPropertyBlock Properties = new MaterialPropertyBlock(); } private sealed class SourceMask { internal int Users; internal bool Original; internal GrabbableObject Owner; } private static readonly Dictionary<Renderer, SourceMask> SourceMasks = new Dictionary<Renderer, SourceMask>(); private static readonly List<Renderer> ExpiredMasks = new List<Renderer>(); private static int _lastMaskSweepFrame = -1; internal readonly GrabbableObject Item; private readonly GameObject _root; private readonly List<Part> _parts = new List<Part>(); private readonly List<Renderer> _scan = new List<Renderer>(); private readonly HashSet<Renderer> _hiddenHelpers = new HashSet<Renderer>(); private readonly Dictionary<Renderer, Part> _bySource = new Dictionary<Renderer, Part>(); private readonly bool _radar; private readonly bool _bag; private readonly bool _scopeCamera; private readonly Camera _camera; private bool _disposed; private int _refreshFrame = -1; private static bool Claim(Renderer source, GrabbableObject owner) { if (!SourceMasks.TryGetValue(source, out var value)) { value = new SourceMask { Original = source.forceRenderingOff, Owner = owner }; SourceMasks.Add(source, value); } value.Users++; source.forceRenderingOff = true; return value.Original; } private static void ReleaseMask(Renderer source) { if (source == null || !SourceMasks.TryGetValue(source, out var value)) { return; } value.Users--; if (value.Users <= 0) { if ((Object)(object)source != (Object)null) { source.forceRenderingOff = value.Original; } SourceMasks.Remove(source); } } internal static void RestoreDroppedSources() { if (_lastMaskSweepFrame == Time.frameCount || SourceMasks.Count == 0) { return; } _lastMaskSweepFrame = Time.frameCount; ExpiredMasks.Clear(); foreach (KeyValuePair<Renderer, SourceMask> sourceMask in SourceMasks) { GrabbableObject owner = sourceMask.Value.Owner; if (!((Object)(object)owner != (Object)null) || (!owner.isHeld && !((Object)(object)owner.playerHeldBy != (Object)null))) { if ((Object)(object)sourceMask.Key != (Object)null) { sourceMask.Key.forceRenderingOff = sourceMask.Value.Original; } ExpiredMasks.Add(sourceMask.Key); } } foreach (Renderer expiredMask in ExpiredMasks) { SourceMasks.Remove(expiredMask); } if (ExpiredMasks.Count != 0) { ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK_39 restored " + ExpiredMasks.Count + " dropped item renderer(s); no lingering inventory invisibility.")); } } ExpiredMasks.Clear(); } private FriskItemProxy(GrabbableObject item, Transform parent, Camera camera) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown Item = item; _camera = camera; _radar = item is RadarBoosterItem; _bag = FriskVisual.IsBeltBag(item); _scopeCamera = (Object)(object)camera != (Object)null && (_bag || _radar || item is Shovel); _root = new GameObject("Frisk_ItemVisuals_" + ((Object)item).name); _root.transform.SetParent(parent, false); } internal static FriskItemProxy Create(GrabbableObject item, Transform parent, Camera camera) { FriskItemProxy friskItemProxy = new FriskItemProxy(item, parent, camera); try { friskItemProxy.RefreshParts(); if (friskItemProxy._parts.Count > 0 || friskItemProxy._radar || friskItemProxy._bag) { return friskItemProxy; } friskItemProxy.Dispose(); return null; } catch { friskItemProxy.Dispose(); throw; } } private void RefreshParts() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown if (_refreshFrame == Time.frameCount) { return; } _refreshFrame = Time.frameCount; for (int num = _parts.Count - 1; num >= 0; num--) { Part part = _parts[num]; if (!((Object)(object)part.Source != (Object)null)) { _bySource.Remove(part.Source); ReleasePart(part); _parts.RemoveAt(num); } } ((Component)Item).GetComponentsInChildren<Renderer>(true, _scan); foreach (Renderer item in _scan) { if ((!(item is MeshRenderer) && !(item is SkinnedMeshRenderer)) || (Object)(object)item == (Object)null || ((_bag || _radar) && (Object)(object)((Component)item).GetComponentInParent<GrabbableObject>(true) != (Object)(object)Item)) { continue; } FriskRadarSurface friskRadarSurface = (_radar ? FriskRadar.Surface((RadarBoosterItem)Item, item) : null); bool flag = ((friskRadarSurface != null) ? (friskRadarSurface.Overall != FriskRadarSurface.Role.Body) : ((_bag || Item is Shovel) && FriskRadar.IsMarker(Item, item))); bool flag2 = !_radar && FriskScrapVisualFilter.IsAuxiliary(item, Item); if (flag2) { flag = true; if (_hiddenHelpers.Add(item)) { Claim(item, Item); ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK_39 filtered scrap helper: " + ((Object)Item).name + "/" + ((Object)item).name)); } } else if (SourceMasks.ContainsKey(item)) { item.forceRenderingOff = true; } } else if (_hiddenHelpers.Remove(item)) { ReleaseMask(item); } if (_bySource.TryGetValue(item, out var value)) { if (flag) { ReleasePart(value); _parts.Remove(value); _bySource.Remove(item); if (flag2 && SourceMasks.ContainsKey(item)) { item.forceRenderingOff = true; } } else { value.RadarSurface = friskRadarSurface; } } else { if (flag) { continue; } MeshFilter component = ((Component)item).GetComponent<MeshFilter>(); if (item is MeshRenderer && ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null)) { continue; } SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((item is SkinnedMeshRenderer) ? item : null); if (val == null || !((Object)(object)val.sharedMesh == (Object)null)) { value = new Part { Source = item, RadarSurface = friskRadarSurface, OriginalForceOff = (_radar ? item.forceRenderingOff : Claim(item, Item)) }; _parts.Add(value); _bySource.Add(item, value); value.World = Copy(item, "World", out value.WorldBones); if ((Object)(object)_camera != (Object)null && !_radar) { value.View = Copy(item, "View", out value.ViewBones); } SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((item is SkinnedMeshRenderer) ? item : null); if (val2 != null) { value.SourceBones = val2.bones; } if ((_radar || _bag) && (Object)(object)component != (Object)null) { value.SourceMesh = component; value.WorldMesh = ((Component)value.World).GetComponent<MeshFilter>(); value.ViewMesh = (((Object)(object)value.View != (Object)null) ? ((Component)value.View).GetComponent<MeshFilter>() : null); } if (_radar) { FriskItemCameras.Add(item, FriskItemCameras.Audience.RadarSource, _camera, value); FriskItemCameras.Add(value.World, FriskItemCameras.Audience.RadarWorld, _camera, value); } else if (_scopeCamera) { FriskItemCameras.Add(value.World, FriskItemCameras.Audience.World, _camera); FriskItemCameras.Add(value.View, FriskItemCameras.Audience.View, _camera); } if (!_radar) { item.forceRenderingOff = true; } } } } _scan.Clear(); } private void ReleasePart(Part part) { if (_radar) { FriskItemCameras.Remove(part.Source, part); } else { ReleaseMask(part.Source); } Renderer[] array = (Renderer[])(object)new Renderer[2] { part.World, part.View }; foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null)) { FriskItemCameras.Remove(val); val.enabled = false; Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static bool Live(Part part) { if ((Object)(object)part.Source != (Object)null && part.Source.enabled && ((Component)part.Source).gameObject.activeInHierarchy) { return !part.OriginalForceOff; } return false; } private Part BagFallback() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) Part result = null; float num = 0f; foreach (Part part in _parts) { if (Live(part)) { return null; } if (!((Object)(object)part.Source == (Object)null)) { Bounds localBounds = part.Source.localBounds; Vector3 size = ((Bounds)(ref localBounds)).size; float sqrMagnitude = ((Vector3)(ref size)).sqrMagnitude; if (sqrMagnitude > num) { result = part; num = sqrMagnitude; } } } return result; } internal bool TryGetWorldCenter(out Vector3 center) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) center = Vector3.zero; Bounds val = default(Bounds); bool flag = false; if (_bag) { RefreshParts(); } Part part = (_bag ? BagFallback() : null); foreach (Part part2 in _parts) { if ((!Live(part2) && part2 != part) || (Object)(object)part2.Source == (Object)null) { continue; } Bounds bounds = part2.Source.bounds; if (_bag && (part2.Source is MeshRenderer || part2 == part)) { Bounds localBounds = part2.Source.localBounds; ((Bounds)(ref bounds))..ctor(((Component)part2.Source).transform.TransformPoint(((Bounds)(ref localBounds)).center), Vector3.zero); for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { ((Bounds)(ref bounds)).Encapsulate(((Component)part2.Source).transform.TransformPoint(((Bounds)(ref localBounds)).center + Vector3.Scale(((Bounds)(ref localBounds)).extents, new Vector3((float)i, (float)j, (float)k)))); } } } } if (float.IsNaN(((Bounds)(ref bounds)).center.x) || float.IsInfinity(((Bounds)(ref bounds)).center.x)) { continue; } Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).sqrMagnitude < 1E-06f) { continue; } size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude > 100f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (flag) { center = ((Bounds)(ref val)).center; } return flag; } internal void CenterWorldCopyOn(Vector3 desiredCenter) { //IL_0018: 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_0069: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (_disposed || _parts.Count == 0) { return; } Bounds val = default(Bounds); bool flag = false; foreach (Part part in _parts) { if ((Object)(object)part.World == (Object)null || !part.World.enabled) { continue; } Bounds bounds = part.World.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!float.IsNaN(((Bounds)(ref bounds)).center.x) && !float.IsNaN(((Bounds)(ref bounds)).center.y) && !float.IsNaN(((Bounds)(ref bounds)).center.z) && !float.IsInfinity(((Bounds)(ref bounds)).center.x) && !float.IsInfinity(((Bounds)(ref bounds)).center.y) && !float.IsInfinity(((Bounds)(ref bounds)).center.z) && !(((Vector3)(ref size)).sqrMagnitude < 1E-07f) && !(((Vector3)(ref size)).sqrMagnitude > 36f)) { if (!flag) { val = bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(bounds); } } } if (!flag) { return; } Vector3 val2 = desiredCenter - ((Bounds)(ref val)).center; if (!_bag && ((Vector3)(ref val2)).sqrMagnitude > 1.44f) { return; } foreach (Part part2 in _parts) { if ((Object)(object)part2.World != (Object)null && part2.World.enabled) { Transform transform = ((Component)part2.World).transform; transform.position += val2; } } } private Renderer Copy(Renderer source, string suffix, out Transform[] bones) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0058: 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_009e: Unknown result type (might be due to invalid IL or missing references) bones = null; GameObject val = new GameObject("Frisk_" + suffix + "_" + ((Object)source).name); val.transform.SetParent(_root.transform, false); SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((source is SkinnedMeshRenderer) ? source : null); Renderer val4; if (val2 != null) { SkinnedMeshRenderer val3 = val.AddComponent<SkinnedMeshRenderer>(); val3.sharedMesh = val2.sharedMesh; val3.quality = val2.quality; ((Renderer)val3).localBounds = ((Renderer)val2).localBounds; val3.updateWhenOffscreen = true; bones = (Transform[])(object)new Transform[val2.bones.Length]; for (int i = 0; i < bones.Length; i++) { bones[i] = new GameObject("Frisk_PropBone_" + i).transform; bones[i].SetParent(val.transform, false); } val3.bones = bones; val3.rootBone = val.transform; val4 = (Renderer)(object)val3; } else { val.AddComponent<MeshFilter>().sharedMesh = ((Component)source).GetComponent<MeshFilter>().sharedMesh; val4 = (Renderer)(object)val.AddComponent<MeshRenderer>(); } val4.sharedMaterials = source.sharedMaterials; val4.enabled = false; val4.receiveShadows = source.receiveShadows; return val4; } internal void Follow(FriskMap world, FriskMap view, int worldLayer, int viewLayer, bool showView, bool holstered = false) { //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Invalid comparison between Unknown and I4 //IL_0293: Unknown result type (might be due to invalid IL or missing references) if (_disposed || (Object)(object)Item == (Object)null) { return; } if (_radar || _bag || _refreshFrame < 0 || Time.frameCount - _refreshFrame >= 20) { RefreshParts(); } Part part = (_bag ? BagFallback() : null); foreach (Part part2 in _parts) { if ((Object)(object)part2.Source == (Object)null) { if ((Object)(object)part2.World != (Object)null) { part2.World.enabled = false; } if ((Object)(object)part2.View != (Object)null) { part2.View.enabled = false; } continue; } bool flag = Live(part2) || part2 == part; if ((Object)(object)part2.SourceMesh != (Object)null) { Mesh sharedMesh = part2.SourceMesh.sharedMesh; if ((Object)(object)part2.WorldMesh != (Object)null && (Object)(object)part2.WorldMesh.sharedMesh != (Object)(object)sharedMesh) { part2.WorldMesh.sharedMesh = sharedMesh; } if ((Object)(object)part2.ViewMesh != (Object)null && (Object)(object)part2.ViewMesh.sharedMesh != (Object)(object)sharedMesh) { part2.ViewMesh.sharedMesh = sharedMesh; } } if (_radar) { Camera val = (showView ? _camera : null); FriskItemCameras.Add(part2.Source, FriskItemCameras.Audience.RadarSource, val, part2); FriskItemCameras.SetWorldOwner(part2.World, val); } else if (_scopeCamera) { FriskItemCameras.SetWorldOwner(part2.World, showView ? _camera : null); } world.Apply(((Component)part2.Source).transform, ((Component)part2.World).transform); if ((Object)(object)part2.View != (Object)null) { view.Apply(((Component)part2.Source).transform, ((Component)part2.View).transform); } if (part2.SourceBones != null) { for (int i = 0; i < part2.SourceBones.Length; i++) { if (!((Object)(object)part2.SourceBones[i] == (Object)null)) { world.Apply(part2.SourceBones[i], part2.WorldBones[i]); if (part2.ViewBones != null) { view.Apply(part2.SourceBones[i], part2.ViewBones[i]); } } } SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)part2.Source; int num = 0; while ((Object)(object)val2.sharedMesh != (Object)null && num < val2.sharedMesh.blendShapeCount) { float blendShapeWeight = val2.GetBlendShapeWeight(num); ((SkinnedMeshRenderer)part2.World).SetBlendShapeWeight(num, blendShapeWeight); if ((Object)(object)part2.View != (Object)null) { ((SkinnedMeshRenderer)part2.View).SetBlendShapeWeight(num, blendShapeWeight); } num++; } } part2.Source.GetPropertyBlock(part2.Properties); part2.World.SetPropertyBlock(part2.Properties); Material[] array = (_radar ? part2.RadarSurface.PhysicalMaterials(part2.Source) : part2.Source.sharedMaterials); part2.World.sharedMaterials = array; ((Component)part2.World).gameObject.layer = (_radar ? ((Component)part2.Source).gameObject.layer : worldLayer); if (_radar) { part2.World.renderingLayerMask = part2.Source.renderingLayerMask; for (int j = 0; j < array.Length; j++) { part2.Source.GetPropertyBlock(part2.Properties, j); part2.World.SetPropertyBlock(part2.Properties.isEmpty ? null : part2.Properties, j); } } part2.World.shadowCastingMode = (ShadowCastingMode)((_bag && (int)part2.Source.shadowCastingMode == 3) ? 1 : ((int)part2.Source.shadowCastingMode)); part2.World.enabled = flag; if ((Object)(object)part2.View != (Object)null) { part2.View.SetPropertyBlock(part2.Properties); part2.View.sharedMaterials = part2.Source.sharedMaterials; ((Component)part2.View).gameObject.layer = viewLayer; part2.View.shadowCastingMode = (ShadowCastingMode)0; part2.View.enabled = flag && showView && !holstered; } if (!_radar && SourceMasks.ContainsKey(part2.Source)) { part2.Source.forceRenderingOff = true; } } } private static void UnclaimHelper(Renderer source) { ReleaseMask(source); } public void Dispose() { if (_disposed) { return; } _disposed = true; foreach (Renderer hiddenHelper in _hiddenHelpers) { UnclaimHelper(hiddenHelper); } _hiddenHelpers.Clear(); foreach (Part part in _parts) { ReleasePart(part); } _parts.Clear(); _bySource.Clear(); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } } internal sealed class FriskNameplate { private readonly PlayerControllerB _player; private Canvas _canvas; private bool _canvasEnabled; private Transform _billboard; private bool _billboardActive; private TextMeshProUGUI _text; private bool _textEnabled; private CanvasGroup _alpha; private float _oldAlpha; private bool _reported; private readonly Dictionary<Renderer, bool> _badges = new Dictionary<Renderer, bool>(); private float _badgeScanAt; private bool _badgeReported; internal FriskNameplate(PlayerControllerB player) { _player = player; } private void Track() { if (!((Object)(object)_player == (Object)null)) { if ((Object)(object)_player.usernameCanvas != (Object)null && (Object)(object)_canvas != (Object)(object)_player.usernameCanvas) { RestoreCanvas(); _canvas = _player.usernameCanvas; _canvasEnabled = ((Behaviour)_canvas).enabled; } if ((Object)(object)_player.usernameBillboard != (Object)null && (Object)(object)_billboard != (Object)(object)_player.usernameBillboard) { RestoreBillboard(); _billboard = _player.usernameBillboard; _billboardActive = ((Component)_billboard).gameObject.activeSelf; } if ((Object)(object)_player.usernameBillboardText != (Object)null && (Object)(object)_text != (Object)(object)_player.usernameBillboardText) { RestoreText(); _text = _player.usernameBillboardText; _textEnabled = ((Behaviour)_text).enabled; } if ((Object)(object)_player.usernameAlpha != (Object)null && (Object)(object)_alpha != (Object)(object)_player.usernameAlpha) { RestoreAlpha(); _alpha = _player.usernameAlpha; _oldAlpha = _alpha.alpha; } } } private void TrackBadges() { if ((Object)(object)_player == (Object)null || Time.unscaledTime < _badgeScanAt) { return; } _badgeScanAt = Time.unscaledTime + 2f; if ((Object)(object)_player.playerBadgeMesh != (Object)null) { Add(((Component)_player.playerBadgeMesh).GetComponent<Renderer>()); } Add((Renderer)(object)_player.playerBetaBadgeMesh); Renderer[] componentsInChildren = ((Component)_player).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { string name = ((Object)val).name; if (name.IndexOf("Badge", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("LevelSticker", StringComparison.OrdinalIgnoreCase) >= 0) { Add(val); } } void Add(Renderer r) { if ((Object)(object)r != (Object)null && !_badges.ContainsKey(r)) { _badges[r] = r.enabled; } } } private void HideBadges() { TrackBadges(); foreach (Renderer key in _badges.Keys) { if ((Object)(object)key != (Object)null) { key.enabled = false; } } if (!_badgeReported && _badges.Count > 0) { _badgeReported = true; ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK v0.7.12 level badges hidden for " + _player.playerUsername + " (" + _badges.Count + " renderers)")); } } } private void RestoreBadges() { foreach (KeyValuePair<Renderer, bool> badge in _badges) { if ((Object)(object)badge.Key != (Object)null) { badge.Key.enabled = badge.Value; } } _badges.Clear(); _badgeReported = false; } internal void Hide() { HideBadges(); Track(); if ((Object)(object)_canvas != (Object)null) { ((Behaviour)_canvas).enabled = false; } if ((Object)(object)_text != (Object)null) { ((Behaviour)_text).enabled = false; } if ((Object)(object)_alpha != (Object)null) { _alpha.alpha = 0f; } if ((Object)(object)_billboard != (Object)null) { ((Component)_billboard).gameObject.SetActive(false); } if (!_reported && ((Object)(object)_canvas != (Object)null || (Object)(object)_text != (Object)null || (Object)(object)_billboard != (Object)null)) { _reported = true; ManualLogSource log = FriskPlugin.Log; if (log != null) { log.LogInfo((object)("FRISK_38 nameplate hidden for player " + _player.playerUsername + " (canvas=" + ((Object)(object)_canvas != (Object)null) + ", text=" + ((Object)(object)_text != (Object)null) + ", billboard=" + ((Object)(object)_billboard != (Object)null) + ")")); } } } private void RestoreCanvas() { if ((Object)(object)_canvas != (Object)null) { ((Behaviour)_canvas).enabled = _canvasEnabled; } _canvas = null; } private void RestoreBillboard() { if ((Object)(object)_billboard != (Object)null) { ((Component)_billboard).gameObject.SetActive(_billboardActive); } _billboard = null; } private void RestoreText() { if ((Object)(object)_text != (Object)null) { ((Behaviour)_text).enabled = _textEnabled; } _text = null; } private void RestoreAlpha() { if ((Object)(object)_alpha != (Object)null) { _alpha.alpha = _oldAlpha; } _alpha = null; } internal void Restore() { RestoreCanvas(); RestoreText(); RestoreAlpha(); RestoreBillboard(); RestoreBadges(); } } [DefaultExecutionOrder(21000)] [BepInPlugin("hihi__h.friskbody", "Frisk 3D Suit", "0.7.13")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FriskPlugin : BaseUnityPlugin { internal static ManualLogSource Log; private ConfigEntry<float> _height; private ConfigEntry<float> _itemScale; private ConfigEntry<float> _viewScale; private ConfigEntry<float> _viewForward; private ConfigEntry<float> _bodyCenterX; private FriskAsset _asset; private float _nextScan; private bool _loadFailed; private bool _reportedMissingSuit; private bool _anyFrisk; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; FriskItemCameras.Start(); _height = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "HeightRatio", 0.625f, "Visual height only. Collider, camera height, speed and interaction reach stay native."); _itemScale = ((BaseUnityPlugin)this).Config.Bind<float>("HeldItems", "WorldItemScaleV3", 1f, "Multiplies ORIGINAL item world scale and HeightRatio. 1 preserves the grip proportions. Old V2 keys are retired."); _viewScale = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPerson", "ArmsAndItemsScale", 0.9f, "Arms, fingers and held item are scaled together about the camera; 1 = original view size."); _bodyCenterX = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "MirrorBodyCenterX_V2", 0.04f, "Visual-only player-local body offset. Previous MirrorBodyCenterX (v0.7.3) is intentionally retired, because its sign made reflection alignment worse. Set to 0 to fully disable centering adjustment."); _viewForward = ((BaseUnityPlugin)this).Config.Bind<float>("FirstPerson", "ForwardOffset", 0.04f, "Moves the complete first-person arms AND item together, in metres. Does not move the gameplay camera."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FRISK_41 v0.7.13: dead body shows the Frisk model instead of the vanilla body. FRISK_39 v0.7.12: FRISK_38 features preserved; fixed item renderer mask lifetime on drop/swap and stale inventory invisibility. Astra rig unchanged."); } private void Update() { if (Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 0.25f; _anyFrisk = false; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null || (Object)(object)instance.unlockablesList == (Object)null || instance.unlockablesList.unlockables == null) { return; } int num = -1; for (int i = 0; i < instance.unlockablesList.unlockables.Count; i++) { UnlockableItem val = instance.unlockablesList.unlockables[i]; string a = ((val == null) ? "" : (val.unlockableName ?? "").Trim()); if (string.Equals(a, "Frisk 3D", StringComparison.OrdinalIgnoreCase) || string.Equals(a, "Frisk 3D suit", StringComparison.OrdinalIgnoreCase)) { num = i; break; } } if (num < 0 && !_reportedMissingSuit) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Frisk 3D is missing from the More Suits rack. Check the installed moresuits PNG."); } _reportedMissingSuit = num < 0; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 == (Object)null) { continue; } FriskVisual friskVisual = ((Component)val2).GetComponent<FriskVisual>(); if (num >= 0 && val2.isPlayerDead && val2.currentSuitID == num && (Object)(object)val2.deadBody != (Object)null && ((Component)val2.deadBody).gameObject.activeInHierarchy && (Object)(object)((Component)val2.deadBody).GetComponent<FriskCorpse>() == (Object)null && !_loadFailed) { try { if (_asset == null) { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _asset = FriskAsset.Load(Path.Combine(directoryName, "frisk.fmesh")); } FriskCorpse friskCorpse = ((Component)val2.deadBody).gameObject.AddComponent<FriskCorpse>(); if (!friskCorpse.Initialize(val2.deadBody, _asset, Mathf.Clamp(_height.Value, 0.35f, 1.2f))) { Object.Destroy((Object)(object)friskCorpse); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("FRISK_41 corpse visual skipped (vanilla body kept): " + ex.Message)); } } if (num < 0 || val2.currentSuitID != num || !val2.isPlayerControlled || val2.isPlayerDead || !((Component)val2).gameObject.activeInHierarchy) { if ((Object)(object)friskVisual != (Object)null) { friskVisual.Release(); Object.Destroy((Object)(object)friskVisual); } continue; } _anyFrisk = true; if ((Object)(object)friskVisual != (Object)null || _loadFailed) { continue; } if (_asset == null) { try { string directoryName2 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _asset = FriskAsset.Load(Path.Combine(directoryName2, "frisk.fmesh")); } catch (Exception ex2) { _loadFailed = true; ((BaseUnityPlugin)this).Logger.LogError((object)ex2); continue; } } try { friskVisual = ((Component)val2).gameObject.AddComponent<FriskVisual>(); friskVisual.Initialize(val2, _asset, Mathf.Clamp(_height.Value, 0.35f, 1.2f), Mathf.Clamp(_itemScale.Value, 0.65f, 1.35f), Mathf.Clamp(_viewScale.Value, 0.65f, 1.1f), Mathf.Clamp(_viewForward.Value, -0.05f, 0.15f), Mathf.Clamp(_bodyCenterX.Value, -0.3f, 0.3f)); } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("FRISK_38 setup failed; restoring native renderers: " + ex3)); if ((Object)(object)friskVisual != (Object)null) { friskVisual.Release(); Object.Destroy((Object)(object)friskVisual); } _loadFailed = true; } } } private void LateUpdate() { FriskRadar.Tick(_anyFrisk); FriskItemProxy.RestoreDroppedSources(); if (!_anyFrisk) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null)) { ((Component)val).GetComponent<FriskVisual>()?.EnforceNameplate(); } } } private void OnDestroy() { FriskVisual[] array = Object.FindObjectsOfType<FriskVisual>(); foreach (FriskVisual obj in array) { obj.Release(); Object.Destroy((Object)(object)obj); } FriskRadar.Clear(); FriskItemCameras.Stop(); } } internal static class FriskItemCameras { internal enum Audience { Map, World, View, Hidden, RadarSource, RadarWorld } private sealed class Rule { internal Audience Show; internal Camera Owner; internal bool Original; internal object Token; } [CompilerGenerated] private static class <>O { public static Action<ScriptableRenderContext, Camera> <0>__BeginPipeline; public static Action<ScriptableRenderContext, Camera> <1>__EndPipeline; public static CameraCallback <2>__BeginBuiltin; public static CameraCallback <3>__EndBuiltin; } private static readonly Dictionary<Renderer, Rule> Rules = new Dictionary<Renderer, Rule>(); private static readonly Stack<Camera> Cameras = new Stack<Camera>(); private static int _frame = -1; internal static void Start() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown RenderPipelineManager.beginCameraRendering += BeginPipeline; RenderPipelineManager.endCameraRendering += EndPipeline; CameraCallback onPreCull = Camera.onPreCull; object obj = <>O.<2>__BeginBuiltin; if (obj == null) { CameraCallback val = BeginBuiltin; <>O.<2>__BeginBuiltin = val; obj = (object)val; } Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreCull, (Delegate?)obj); CameraCallback onPostRender = Camera.onPostRender; object obj2 = <>O.<3>__EndBuiltin; if (obj2 == null) { CameraCallback val2 = EndBuiltin; <>O.<3>__EndBuiltin = val2; obj2 = (object)val2; } Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)onPostRender, (Delegate?)obj2); } internal static void Stop() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown RenderPipelineManager.beginCameraRendering -= BeginPipeline; RenderPipelineManager.endCameraRendering -= EndPipeline; CameraCallback onPreCull = Camera.onPreCull; object obj = <>O.<2>__BeginBuiltin; if (obj == null) { CameraCallback val = BeginBuiltin; <>O.<2>__BeginBuiltin = val; obj = (object)val; } Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)onPreCull, (Delegate?)obj); CameraCallback onPostRender = Camera.onPostRender; object obj2 = <>O.<3>__EndBuiltin; if (obj2 == null) { CameraCallback val2 = EndBuiltin; <>O.<3>__EndBuiltin = val2; obj2 = (object)val2; } Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)onPostRender, (Delegate?)obj2); Restore(); Cameras.Clear(); Rules.Clear(); } internal static void Add(Renderer renderer, Audience show, Camera owner = null, object token = null) { if (!((Object)(object)renderer == (Object)null)) { if (!Rules.TryGetValue(renderer, out var value)) { value = new Rule { Original = renderer.forceRenderingOff }; Rules.Add(renderer, value); } value.Show = show; value.Owner = owner; value.Token = token; } } internal static void SetWorldOwner(Renderer renderer, Camera camera) { if ((Object)(object)renderer != (Object)null && Rules.TryGetValue(renderer, out var value)) { value.Owner = camera; } } internal static void Remove(Renderer renderer, object token = null) { if (renderer != null && Rules.TryGetValue(renderer, out var value) && (token == null || value.Token == token)) { if ((Object)(object)renderer != (Object)null && Cameras.Count > 0) { renderer.forceRenderingOff = value.Original; } Rules.Remove(renderer); } } private static void BeginPipeline(ScriptableRenderContext context, Camera camera) { Begin(camera); } private static void EndPipeline(ScriptableRenderContext context, Camera camera) { End(camera); } private static void BeginBuiltin(Camera camera) { if ((Object)(object)GraphicsSettings.currentRenderPipeline == (Object)null) { Begin(camera); } } private static void EndBuiltin(Camera camera) { if ((Object)(object)GraphicsSettings.currentRenderPipeline == (Object)null) { End(camera); } } private static void Begin(Camera camera) { if ((Object)(object)camera == (Object)null) { return; } if (_frame != Time.frameCount) { if (Cameras.Count > 0) { Restore(); Cameras.Clear(); } _frame = Time.frameCount; } if (Cameras.Count == 0) { foreach (KeyValuePair<Renderer, Rule> rule in Rules) { if ((Object)(object)rule.Key != (Object)null) { rule.Value.Original = rule.Key.forceRenderingOff; } } } Cameras.Push(camera); Apply(camera); } private static void End(Camera camera) { if (Cameras.Count != 0 && !((Object)(object)Cameras.Peek() != (Object)(object)camera)) { Cameras.Pop(); if (Cameras.Count > 0) { Apply(Cameras.Peek()); } else { Restore(); } } } private static void Apply(Camera camera) { StartOfRound instance = StartOfRound.Instance; bool flag = (Object)(object)instance != (Object)null && (Object)(object)instance.mapScreen != (Object)null && (Object)(object)camera == (Object)(object)instance.mapScreen.mapCamera; foreach (KeyValuePair<Renderer, Rule> rule in Rules) { Renderer key = rule.Key; if (!((Object)(object)key == (Object)null)) { Rule value = rule.Value; bool flag2 = value.Show switch { Audience.Hidden => false, Audience.Map => flag, Audience.RadarSource => flag || (Object)(object)camera == (Object)(object)value.Owner, Audience.RadarWorld => !flag && (Object)(object)camera != (Object)(object)value.Owner, Audience.View => (Object)(object)camera == (Object)(object)value.Owner, _ => (Object)(object)camera != (Object)(object)value.Owner, }; key.forceRenderingOff = value.Original || !flag2; } } FriskRadar.ApplySlots(flag); } private static void Restore() { FriskRadar.RestoreSlots(); foreach (KeyValuePair<Renderer, Rule> rule in Rules) { if ((Object)(object)rule.Key != (Object)null) { rule.Key.forceRenderingOff = rule.Value.Original; } } } } internal static class FriskRadar { private static NetworkManager _manager; private static readonly Dictionary<ulong, NetworkObject> Seen = new Dictionary<ulong, NetworkObject>(); private static readonly List<RadarBoosterItem> Boosters = new List<RadarBoosterItem>(); private static readonly List<ulong> Gone = new List<ulong>(); private static readonly List<Renderer> Scratch = new List<Renderer>(); private static readonly Dictionary<Renderer, FriskRadarSurface> Surfaces = new Dictionary<Renderer, FriskRadarSurface>(); private static readonly HashSet<Renderer> Current = new HashSet<Renderer>(); private static readonly HashSet<Renderer> Mixed = new HashSet<Renderer>(); private static readonly List<Renderer> Retired = new List<Renderer>(); private static readonly object HelperToken = new object(); internal static bool IsMarker(GrabbableObject item, Renderer renderer) { Transform transform = ((Component)renderer).transform; if ((Object)(object)item.radarIcon != (Object)null && (Object)(object)item.radarIcon != (Object)(object)((Component)item).transform && ((Object)(object)transform == (Object)(object)item.radarIcon || transform.IsChildOf(item.radarIcon))) { return true; } Transform val = transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)item).transform) { string name = ((Object)val).name; if (name.IndexOf("RadarBoosterDot", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("MapDot", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RadarDot", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("MapIcon", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RadarMarker", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RadarIcon", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("MapLabel", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("MapRadar", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return LayerMask.LayerToName(((Component)renderer).gameObject.layer)?.StartsWith("MapRadar", StringComparison.OrdinalIgnoreCase) ?? false; } internal static FriskRadarSurface Surface(RadarBoosterItem item, Renderer renderer) { if (!Surfaces.TryGetValue(renderer, out var value)) { value = new FriskRadarSurface(); Surfaces.Add(renderer, value); } value.Refresh(item, renderer); return value; } private static void Collect(Transform root, RadarBoosterItem item, bool detachedIcon) { if ((Object)(object)root == (Object)null) { return; } ((Component)root).GetComponentsInChildren<Renderer>(true, Scratch); foreach (Renderer item2 in Scratch) { if ((Object)(object)item2 == (Object)null || !Current.Add(item2)) { continue; } if (!detachedIcon && (Object)(object)((Component)item2).GetComponentInParent<GrabbableObject>(true) != (Object)(object)item) { Current.Remove(item2); continue; } FriskRadarSurface friskRadarSurface = Surface(item, item2); FriskRadarSurface.Role role = (detachedIcon ? FriskRadarSurface.Role.Map : friskRadarSurface.Overall); friskRadarSurface.Report(item2, role); if (role == FriskRadarSurface.Role.Body) { FriskItemCameras.Remove(item2, HelperToken); } else { FriskItemCameras.Add(item2, (role != FriskRadarSurface.Role.Map) ? FriskItemCameras.Audience.Hidden : FriskItemCameras.Audience.Map, null, HelperToken); } if (friskRadarSurface.Mixed) { Mixed.Add(item2); } } Scratch.Clear(); } internal static void ApplySlots(bool map) { foreach (Renderer item in Mixed) { if ((Object)(object)item != (Object)null) { Surfaces[item].Apply(item, map); } } } internal static void RestoreSlots() { foreach (Renderer item in Mixed) { Surfaces[item].Restore(item); } } internal static void Tick(bool enabled) { NetworkManager singleton = NetworkManager.Singleton; if (!enabled || (Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.SpawnManager == null) { Clear(); return; } if ((Object)(object)_manager != (Object)(object)singleton) { Clear(); _manager = singleton; RadarBoosterItem[] array = Object.FindObjectsOfType<RadarBoosterItem>(true); foreach (RadarBoosterItem val in array) { if ((Object)(object)val != (Object)null && !Boosters.Contains(val)) { Boosters.Add(val); } } } foreach (KeyValuePair<ulong, NetworkObject> spawnedObject in singleton.SpawnManager.SpawnedObjects) { if (Seen.TryGetValue(spawnedObject.Key, out var value) && (Object)(object)value == (Object)(object)spawnedObject.Value) { continue; } Seen[spawnedObject.Key] = spawnedObject.Value; if (!((Object)(object)spawnedObject.Value == (Object)null)) { RadarBoosterItem componentInChildren = ((Component)spawnedObject.Value).GetComponentInChildren<RadarBoosterItem>(true); if ((Object)(object)componentInChildren != (Object)null && !Boosters.Contains(componentInChildren)) { Boosters.Add(componentInChildren); } } } foreach (KeyValuePair<ulong, NetworkObject> item in Seen) { if ((Object)(object)item.Value == (Object)null || !item.Value.IsSpawned) { Gone.Add(item.Key); } } foreach (ulong item2 in Gone) { Seen.Remove(item2); } Gone.Clear(); Current.Clear(); Mixed.Clear(); for (int num = Boosters.Count - 1; num >= 0; num--) { RadarBoosterItem val2 = Boosters[num]; if ((Object)(object)val2 == (Object)null) { Boosters.RemoveAt(num); } else if (((Behaviour)val2).isActiveAndEnabled) { Collect(((Component)val2).transform, val2, detachedIcon: false); if ((Object)(object)((GrabbableObject)val2).radarIcon != (Object)null && !((GrabbableObject)val2).radarIcon.IsChildOf(((Component)val2).transform)) { Collect(((GrabbableObject)val2).radarIcon, val2, detachedIcon: true); } } } foreach (KeyValuePair<Renderer, FriskRadarSurface> surface in Surfaces) { if (!Current.Contains(surface.Key)) { Retired.Add(surface.Key); } } foreach (Renderer item3 in Retired) { Surfaces[item3].Restore(item3); FriskItemCameras.Remove(item3, HelperToken); Surfaces.Remove(item3); } Retired.Clear(); } internal static void Clear() { foreach (KeyValuePair<Renderer, FriskRadarSurface> surface in Surfaces) { surface.Value.Restore(surface.Key); FriskItemCameras.Remove(surface.Key, HelperToken); } Surfaces.Clear(); Mixed.Clear(); Current.Clear(); Seen.Clear(); Boosters.Clear(); Gone.Clear(); Retired.Clear(); _manager = null; FriskRadarSurface.CleanUp(); } } internal sealed class FriskRadarSurface { internal enum Role { Body, Map, Helper } internal Role Overall; internal int Frame = -1; private Material[] _native; private Material[] _ordinary; private Material[] _ship; private Material[] _applied; private bool _reported; private bool _reportedMixed; private Role _reportedRole; private static readonly List<Material> Materials = new List<Material>(); private static readonly MaterialPropertyBlock SharedBlock = new MaterialPropertyBlock(); private static readonly MaterialPropertyBlock SlotBlock = new MaterialPropertyBlock(); private static readonly int[] Tints = new int[5] { Shader.PropertyToID("_BaseColor"), Shader.PropertyToID("_UnlitColor"), Shader.PropertyToID("_Color"), Shader.PropertyToID("_TintColor"), Shader.PropertyToID("_EmissiveColor") }; private static Material _noDraw; internal bool Mixed { get; private set; } private static bool Contains(string text, string token) { if (text != null) { return text.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static bool HelperName(string name) { if (!Contains(name, "ScanNode") && !Contains(name, "Scan Node") && !Contains(name, "ScanVolume") && !Contains(name, "Trigger") && !Contains(name, "Collider") && !Contains(name, "Collision") && !Contains(name, "Occlusion") && !Contains(name, "Debug") && !Contains(name, "Gizmo") && !Contains(name, "Placement") && !Contains(name, "Bounds") && !Contains(name, "BoundBox") && !Contains(name, "BoundingBox") && !Contains(name, "Volume") && !Contains(name, "Projector") && !Contains(name, "Projection") && !Contains(name, "Wireframe") && !Contains(name, "Preview")) { return Contains(name, "Helper"); } return true; } private static bool MapName(string name) { if (!Contains(name, "MapDot") && !Contains(name, "MapIcon") && !Contains(name, "RadarBoosterDot") && !Contains(name, "RadarMarker")) { return Contains(name, "MapRadar"); } return true; } internal void Refresh(RadarBoosterItem item, Renderer renderer) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) if (Frame == Time.frameCount) { return; } if (_applied != null) { Restore(renderer); } Frame = Time.frameCount; Mixed = false; if (FriskRadar.IsMarker((GrabbableObject)(object)item, renderer)) { Overall = Role.Map; return; } bool flag = false; Transform val = ((Component)renderer).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)item).transform) { string text = LayerMask.LayerToName(((Component)val).gameObject.layer); if ((Object)(object)((Component)val).GetComponent<ScanNodeProperties>() != (Object)null || HelperName(((Object)val).name) || Contains(text, "ScanNode") || Contains(text, "Trigger") || Contains(text, "NotRendered") || Contains(text, "Gizmo") || Contains(text, "Debug") || Contains(text, "Collider")) { Overall = Role.Helper; return; } Collider component = ((Component)val).GetComponent<Collider>(); flag |= (Object)(object)component != (Object)null && component.isTrigger; val = val.parent; } MeshFilter component2 = ((Component)renderer).GetComponent<MeshFilter>(); object obj2; if (!((Object)(object)component2 != (Object)null)) { Renderer obj = ((renderer is SkinnedMeshRenderer) ? renderer : null); obj2 = ((obj != null) ? ((SkinnedMeshRenderer)obj).sharedMesh : null); } else { obj2 = component2.sharedMesh; } Mesh val2 = (Mesh)obj2; bool flag2 = false; bool flag3 = false; bool flag4 = false; Bounds bounds; if ((Object)(object)val2 != (Object)null) { bounds = val2.bounds; Vector3 val3 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)renderer).transform.lossyScale); float num = Mathf.Abs(val3.x); float num2 = Mathf.Abs(val3.y); float num3 = Mathf.Abs(val3.z); float num4 = Mathf.Max(num, Mathf.Max(num2, num3)); float num5 = Mathf.Min(num, Mathf.Min(num2, num3)); flag3 = num4 >= 0.22f && num + num2 + num3 - num4 - num5 >= 0.15f; flag4 = flag3 && num5 < num4 * 0.16f; string text2 = ((Object)val2).name ?? ""; flag2 = val2.vertexCount <= 32 || text2.Equals("Cube", StringComparison.OrdinalIgnoreCase) || text2.Equals("Quad", StringComparison.OrdinalIgnoreCase) || text2.Equals("Cylinder", StringComparison.OrdinalIgnoreCase) || text2.Equals("Plane", StringComparison.OrdinalIgnoreCase) || text2.Equals("Sphere", StringComparison.OrdinalIgnoreCase); if (HelperName(text2)) { Overall = Role.Helper; return; } } Materials.Clear(); renderer.GetSharedMaterials(Materials); int count = Materials.Count; if (count == 0) { Overall = Role.Body; return; } if (_native == null || _native.Length != count) { _native = (Material[])(object)new Material[count]; _ordinary = (Material[])(object)new Material[count]; _ship = (Material[])(object)new Material[count]; } renderer.GetPropertyBlock(SharedBlock); bool flag5 = false; bool flag6 = false; bool flag7 = false; for (int i = 0; i < count; i++) { Material val4 = Materials[i]; renderer.GetPropertyBlock(SlotBlock, i); bool flag8 = flag3; bool flat = flag4; bool primitive = flag2; if ((Object)(object)val2 != (Object)null && val2.subMeshCount > 1 && i < val2.subMeshCount) { SubMeshDescriptor subMesh = val2.GetSubMesh(i); bounds = ((SubMeshDescriptor)(ref subMesh)).bounds; Vector3 val5 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)renderer).transform.lossyScale); if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f) { float num6 = Mathf.Abs(val5.x); float num7 = Mathf.Abs(val5.y); float num8 = Mathf.Abs(val5.z); float num9 = Mathf.Max(num6, Mathf.Max(num7, num8)); float num10 = Mathf.Min(num6, Mathf.Min(num7, num8)); flag8 = num9 >= 0.22f && num6 + num7 + num8 - num9 - num10 >= 0.15f; flat = flag8 && num10 < num9 * 0.16f; primitive = ((SubMeshDescriptor)(ref subMesh)).indexCount <= 36; } } Role role = Slot(val4, flag, flag8, flat, primitive); _native[i] = val4; flag5 = flag5 || role == Role.Body; flag6 = flag6 || role == Role.Map; flag7 = flag7 || role == Role.Helper; _ordinary[i] = ((role == Role.Body) ? val4 : null); _ship[i] = ((role != Role.Helper) ? val4 : null); } Overall = ((!flag5) ? (flag6 ? Role.Map : Role.Helper) : Role.Body); Mixed = (flag5 && flag6) || (flag5 && flag7) || (flag6 && flag7); if (!Mixed) { return; } Material val6 = NoDraw(); for (int j = 0; j < count; j++) { if ((Object)(object)_ordinary[j] == (Object)null && (Object)(object)_native[j] != (Object)null) { _ordinary[j] = val6; } if ((Object)(object)_ship[j] == (Object)null && (Object)(object)_native[j] != (Object)null) { _ship[j] = val6; } } } private static Role Slot(Material m, bool trigger, bool broad, bool flat, bool primitive) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m == (Object)null) { return Role.Body; } if (MapName(((Object)m).name)) { return Role.Map; } if (HelperName(((Object)m).name) || HelperName(((Object)m.shader).name)) { return Role.Helper; } bool flag = m.renderQueue >= 3000 || (m.HasProperty("_SurfaceType") && m.GetFloat("_SurfaceType") > 0.5f) || (m.HasProperty("_Surface") && m.GetFloat("_Surface") > 0.5f) || m.IsKeywordEnabled("_SURFACE_TYPE_TRANSPARENT") || m.IsKeywordEnabled("_ALPHABLEND_ON") || Contains(m.GetTag("RenderType", false, ""), "Transparent"); bool flag2 = false; bool flag3 = false; for (int i = 0; i < Tints.Length; i++) { int num = Tints[i]; Color val; if (SlotBlock.HasColor(num)) { val = SlotBlock.GetColor(num); } else if (SlotBlock.HasVector(num)) { val = Color.op_Implicit(SlotBlock.GetVector(num)); } else if (SharedBlock.HasColor(num)) { val = SharedBlock.GetColor(num); } else if (SharedBlock.HasVector(num)) { val = Color.op_Implicit(SharedBlock.GetVector(num)); } else { if (!m.HasProperty(num)) { continue; } val = m.GetColor(num); } if (i != Tints.Length - 1) { flag |= val.a < 0.97f; } flag2 |= val.r > 0.22f && val.r > val.g * 1.55f && val.r > val.b * 1.45f; flag3 |= val.b > 0.52f && val.g > 0.21f && val.r < val.b * 0.58f && val.r < val.g * 0.7f; } if (flat && flag3) { return Role.Map; } if (broad && trigger && primitive) { return Role.Helper; } if (broad && flag && (primitive || trigger || flag2)) { return Role.Helper; } if (broad && flag2 && (primitive || trigger)) { return Role.Helper; } return Role.Body; } private static Material NoDraw() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_noDraw != (Object)null) { return _noDraw; } Shader val = Shader.Find("HDRP/Unlit") ?? Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { foreach (Material material in Materials) { if ((Object)(object)material != (Object)null) { val = material.shader; break; } } } _noDraw = new Material(val) { name = "Frisk_Radar_OmittedSlot", hideFlags = (HideFlags)61 }; ShaderTagId val2 = default(ShaderTagId); ((ShaderTagId)(ref val2))..ctor("LightMode"); for (int i = 0; i < _noDraw.passCount; i++) { ShaderTagId val3 = val.FindPass
plugins/Muffet/hihi__h.Muffet.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using hihi__h.Muffet.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("hihi__h.Muffet")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.76.5.0")] [assembly: AssemblyInformationalVersion("0.76.5")] [assembly: AssemblyProduct("hihi__h.Muffet")] [assembly: AssemblyTitle("hihi__h.Muffet")] [assembly: AssemblyVersion("0.76.5.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MuffetMod { internal static class DonutModelLoader { internal static Sprite LoadIcon(string path) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadTexture(path); ((Object)val).name = "SpiderDonut_InventoryIcon"; ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } private static Texture2D LoadTexture(string path) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array, false)) { throw new InvalidDataException("Could not decode PNG: " + path); } ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)0; return val; } private static Material MakeMaterial(Color tint, Texture2D texture) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("HDRP/Lit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("High Definition Render Pipeline/Lit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("Cannot find any usable Unity shader"); } Material val2 = new Material(val); ((Object)val2).name = (((Object)(object)texture != (Object)null) ? "SpiderDonut_Frosting" : "SpiderDonut_Residue"); if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", tint); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", tint); } if (val2.HasProperty("_Smoothness")) { val2.SetFloat("_Smoothness", ((Object)(object)texture != (Object)null) ? 0.25f : 0.12f); } if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", 0f); } if ((Object)(object)texture != (Object)null) { if (val2.HasProperty("_BaseColorMap")) { val2.SetTexture("_BaseColorMap", (Texture)(object)texture); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)texture); } } val2.enableInstancing = true; return val2; } internal static MeshRenderer BuildModel(GameObject root, string meshPath, string texturePath) { //IL_00f9: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0138: Unknown result type (might be due to invalid IL or missing references) //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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadTexture(texturePath); using FileStream input = File.OpenRead(meshPath); using BinaryReader binaryReader = new BinaryReader(input); byte[] array = binaryReader.ReadBytes(4); if (array.Length != 4 || array[0] != 83 || array[1] != 68 || array[2] != 77 || array[3] != 49) { throw new InvalidDataException("Invalid Spider Donut mesh asset"); } uint num = binaryReader.ReadUInt32(); if (num < 1 || num > 64) { throw new InvalidDataException("Unexpected mesh count"); } MeshRenderer result = null; for (int i = 0; i < num; i++) { bool flag = binaryReader.ReadByte() != 0; int num2; int num3; Vector3[] array2; Vector3[] array3; Vector2[] array4; Color32[] array5; checked { num2 = (int)binaryReader.ReadUInt32(); num3 = (int)binaryReader.ReadUInt32(); if (num2 <= 0 || num2 > 250000 || num3 < 3 || num3 > 1200000) { throw new InvalidDataException("Invalid mesh sizes"); } array2 = (Vector3[])(object)new Vector3[num2]; array3 = (Vector3[])(object)new Vector3[num2]; array4 = (Vector2[])(object)new Vector2[num2]; array5 = (Color32[])(object)new Color32[num2]; } for (int j = 0; j < num2; j++) { array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); array5[j] = new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte()); } int[] array6 = new int[num3]; for (int k = 0; k < num3; k++) { array6[k] = checked((int)binaryReader.ReadUInt32()); } Mesh val2 = new Mesh(); ((Object)val2).name = (flag ? "SpiderDonut_Main" : ("SpiderDonut_Residue_" + i)); val2.indexFormat = (IndexFormat)1; val2.vertices = array2; val2.normals = array3; val2.uv = array4; val2.colors32 = array5; val2.triangles = array6; val2.RecalculateBounds(); GameObject val3; if (i == 0) { val3 = root; } else { val3 = new GameObject("SpiderRemains_" + i); val3.transform.SetParent(root.transform, false); val3.layer = root.layer; } MeshFilter val4 = val3.AddComponent<MeshFilter>(); MeshRenderer val5 = val3.AddComponent<MeshRenderer>(); val4.sharedMesh = val2; ((Renderer)val5).sharedMaterial = MakeMaterial(flag ? Color.white : Color32.op_Implicit(array5[0]), flag ? val : null); ((Renderer)val5).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val5).receiveShadows = true; if (i == 0) { result = val5; } } return result; } } internal sealed class GltfRuntime { private readonly Dictionary<string, object> root; private readonly byte[] bin; private readonly List<object> accessors; private readonly List<object> views; private readonly List<object> meshes; private readonly List<object> nodes; private readonly List<object> mats; private readonly List<object> images; private readonly List<object> textures; private readonly List<object> skins; private readonly Dictionary<string, Mesh> meshCache = new Dictionary<string, Mesh>(); private readonly Dictionary<int, Material> matCache = new Dictionary<int, Material>(); private readonly Dictionary<int, Texture2D> textureCache = new Dictionary<int, Texture2D>(); private Transform[] nodeTransforms; private SkinnedMeshRenderer[] morphRenderers; private GltfRuntime(Dictionary<string, object> json, byte[] body) { root = json; bin = body; accessors = J.L(root, "accessors"); views = J.L(root, "bufferViews"); meshes = J.L(root, "meshes"); nodes = J.L(root, "nodes"); mats = J.L(root, "materials"); images = J.L(root, "images"); textures = J.L(root, "textures"); skins = J.L(root, "skins"); } internal static GameObject Import(string path, out MuffetGltfAnimator animation) { using FileStream input = File.OpenRead(path); using BinaryReader binaryReader = new BinaryReader(input); if (binaryReader.ReadUInt32() != 1179937895 || binaryReader.ReadUInt32() != 2) { throw new InvalidDataException("File is not GLB 2.0: " + path); } binaryReader.ReadUInt32(); int count = binaryReader.ReadInt32(); if (binaryReader.ReadUInt32() != 1313821514) { throw new InvalidDataException("GLB JSON chunk missing"); } Dictionary<string, object> json = J.D(MiniJSON.Parse(Encoding.UTF8.GetString(binaryReader.ReadBytes(count)).TrimEnd(' ', '\0'))); int count2 = binaryReader.ReadInt32(); if (binaryReader.ReadUInt32() != 5130562) { throw new InvalidDataException("GLB binary chunk missing"); } return new GltfRuntime(json, binaryReader.ReadBytes(count2)).CreateScene(out animation, Path.GetFileName(path)); } private static Vector3 V3(List<object> a, Vector3 fallback, bool mirrored = true) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (a.Count < 3) { return fallback; } return new Vector3(J.N(a[0]), J.N(a[1]), J.N(a[2]) * (mirrored ? (-1f) : 1f)); } private static Quaternion Q4(List<object> a) { //IL_0041: 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) if (a.Count < 4) { return Quaternion.identity; } return new Quaternion(0f - J.N(a[0]), 0f - J.N(a[1]), J.N(a[2]), J.N(a[3])); } private Matrix4x4 Matrix(object matrix) { //IL_0009: 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) List<object> list = J.A(matrix); Matrix4x4 result = default(Matrix4x4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { float num = J.N(list[i * 4 + j]); if (j == 2) { num = 0f - num; } if (i == 2) { num = 0f - num; } ((Matrix4x4)(ref result))[j, i] = num; } } return result; } private static void SetTransform(Transform tr, Matrix4x4 m) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00bc: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(0)); Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(1)); Vector3 val3 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(2)); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Vector3)(ref val)).magnitude, ((Vector3)(ref val2)).magnitude, ((Vector3)(ref val3)).magnitude); if (Vector3.Dot(Vector3.Cross(val, val2), val3) < 0f) { val4.x = 0f - val4.x; } tr.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(3)); tr.localScale = val4; Vector3 normalized = ((Vector3)(ref val3)).normalized; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; tr.localRotation = ((((Vector3)(ref normalized)).sqrMagnitude > 0.001f && ((Vector3)(ref normalized2)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(normalized, normalized2) : Quaternion.identity); } private GameObject CreateScene(out MuffetGltfAnimator animation, string assetKey) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_019f: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Expected O, but got Unknown //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Expected O, but got Unknown //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GLB_MUFFET_07_Model"); nodeTransforms = (Transform[])(object)new Transform[nodes.Count]; morphRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[nodes.Count]; for (int i = 0; i < nodes.Count; i++) { GameObject val2 = new GameObject(J.S(nodes[i], "name", "Node_" + i)); nodeTransforms[i] = val2.transform; } bool[] array = new bool[nodes.Count]; for (int j = 0; j < nodes.Count; j++) { foreach (object item in J.L(nodes[j], "children")) { int num = Convert.ToInt32(item); nodeTransforms[num].SetParent(nodeTransforms[j], false); array[num] = true; } } for (int k = 0; k < nodes.Count; k++) { if (!array[k]) { nodeTransforms[k].SetParent(val.transform, false); } } for (int l = 0; l < nodes.Count; l++) { object o = nodes[l]; Transform val3 = nodeTransforms[l]; object obj = J.V(o, "matrix"); if (obj != null) { SetTransform(val3, Matrix(obj)); continue; } val3.localPosition = V3(J.L(o, "translation"), Vector3.zero); val3.localRotation = Q4(J.L(o, "rotation")); val3.localScale = V3(J.L(o, "scale"), Vector3.one, mirrored: false); } for (int m = 0; m < nodes.Count; m++) { object o2 = nodes[m]; int num2 = J.I(o2, "mesh", -1); if (num2 < 0 || (string.Equals(assetKey, "MUFFET_07.glb", StringComparison.OrdinalIgnoreCase) && num2 == 16 && J.S(o2, "name").StartsWith("FX_STEAM_FLOATING_PUFF_", StringComparison.Ordinal))) { continue; } int num3 = J.I(o2, "skin", -1); GameObject gameObject = ((Component)nodeTransforms[m]).gameObject; List<object> list = J.L(meshes[num2], "primitives"); for (int n = 0; n < list.Count; n++) { GameObject val4 = (GameObject)((list.Count == 1) ? ((object)gameObject) : ((object)new GameObject(((Object)gameObject).name + "_primitive_" + n))); if ((Object)(object)val4 != (Object)(object)gameObject) { val4.transform.SetParent(nodeTransforms[m], false); } Mesh mesh = GetMesh(num2, num3, n); if ((Object)(object)mesh == (Object)null) { continue; } object o3 = list[n]; Material val5 = GetMaterial(J.I(o3, "material", -1)); int num4 = J.I(J.V(o3, "attributes"), "COLOR_0", -1); if (string.Equals(assetKey, "SpiderDonut_Replacement.glb", StringComparison.OrdinalIgnoreCase) && num4 >= 0 && (Object)(object)mesh != (Object)null) { float[] array2 = AccessFloats(num4); int num5 = ((mesh.vertexCount > 0) ? (array2.Length / mesh.vertexCount) : 0); if (num5 >= 3 && array2.Length == mesh.vertexCount * num5) { Color[] array3 = (Color[])(object)new Color[mesh.vertexCount]; for (int num6 = 0; num6 < array3.Length; num6++) { int num7 = num6 * num5; array3[num6] = new Color(array2[num7], array2[num7 + 1], array2[num7 + 2], (num5 > 3) ? array2[num7 + 3] : 1f); } mesh.colors = array3; Shader val6 = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Standard"); if ((Object)(object)val6 != (Object)null) { val5 = new Material(val6); ((Object)val5).name = "MuffetDonut57_VertexColors"; val5.color = Color.white; if (val5.HasProperty("_BaseColor")) { val5.SetColor("_BaseColor", Color.white); } val5.SetInt("_Cull", 0); } } } else if (num4 >= 0 && J.I(o3, "material", -1) < 0) { float[] array4 = AccessFloats(num4); if (array4.Length >= 4) { val5 = new Material(val5); val5.color = new Color(array4[0], array4[1], array4[2], array4[3]); if (val5.HasProperty("_BaseColor")) { val5.SetColor("_BaseColor", val5.color); } if (array4[3] < 0.99f) { if (val5.HasProperty("_Mode")) { val5.SetFloat("_Mode", 3f); } if (val5.HasProperty("_SurfaceType")) { val5.SetFloat("_SurfaceType", 1f); } val5.SetInt("_SrcBlend", 5); val5.SetInt("_DstBlend", 10); val5.SetInt("_ZWrite", 0); val5.EnableKeyword("_ALPHABLEND_ON"); val5.renderQueue = 3000; } } } bool flag = num3 >= 0 || J.L(o3, "targets").Count > 0; if (num3 >= 0 && num2 == 0 && n == 0 && string.Equals(assetKey, "MUFFET_07.glb", StringComparison.OrdinalIgnoreCase)) { List<object> list2 = J.L(skins[num3], "joints"); Transform[] array5 = (Transform[])(object)new Transform[list2.Count]; for (int num8 = 0; num8 < array5.Length; num8++) { array5[num8] = nodeTransforms[Convert.ToInt32(list2[num8])]; } val4.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj2 = val4.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterial = val5; ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)1; val4.AddComponent<MuffetSourceSkin>().Configure(mesh, array5); MuffetPlugin.Log.LogInfo((object)("[MuffetGLB] Imported ORIGINAL body + 6 two-finger hands via single full-mesh CPU skin; vertices=" + mesh.vertexCount)); } else if (flag) { SkinnedMeshRenderer val7 = val4.AddComponent<SkinnedMeshRenderer>(); val7.sharedMesh = mesh; ((Renderer)val7).sharedMaterial = val5; val7.updateWhenOffscreen = true; if (num3 >= 0) { object o4 = skins[num3]; List<object> list3 = J.L(o4, "joints"); Transform[] array6 = (Transform[])(object)new Transform[list3.Count]; for (int num9 = 0; num9 < array6.Length; num9++) { array6[num9] = nodeTransforms[Convert.ToInt32(list3[num9])]; } val7.bones = array6; int num10 = J.I(o4, "skeleton", -1); val7.rootBone = ((num10 >= 0) ? nodeTransforms[num10] : array6[0]); } if (n == 0) { morphRenderers[m] = val7; } } else { val4.AddComponent<MeshFilter>().sharedMesh = mesh; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = val5; } } } if (string.Equals(assetKey, "MUFFET_07.glb", StringComparison.OrdinalIgnoreCase)) { MuffetPlugin.Log.LogInfo((object)"[MuffetGLB] Disabled 15 solid-square-prone steam billboard planes; original body/eyes/cups retained."); } animation = val.AddComponent<MuffetGltfAnimator>(); animation.Initialise(root, bin, AccessFloats, nodeTransforms, morphRenderers, assetKey); return val; } private byte[] ViewBytes(int viewId) { object o = views[viewId]; int srcOffset = J.I(o, "byteOffset"); int num = J.I(o, "byteLength"); byte[] array = new byte[num]; Buffer.BlockCopy(bin, srcOffset, array, 0, num); return array; } private int ComponentSize(int type) { switch (type) { case 5125: case 5126: return 4; case 5122: case 5123: return 2; case 5120: case 5121: return 1; default: throw new NotSupportedException("Unsupported glTF accessor type " + type); } } private int Components(string type) { return type switch { "SCALAR" => 1, "VEC2" => 2, "VEC3" => 3, "VEC4" => 4, "MAT4" => 16, _ => throw new NotSupportedException("Unsupported glTF accessor dimensions: " + type), }; } internal float[] AccessFloats(int accessorIndex) { object o = accessors[accessorIndex]; int num = J.I(o, "bufferView", -1); if (num < 0) { throw new InvalidDataException("Sparse accessors unsupported"); } object o2 = views[num]; int num2 = J.I(o, "componentType"); int num3 = ComponentSize(num2); int num4 = Components(J.S(o, "type")); int num5 = J.I(o, "count"); int num6 = J.I(o2, "byteOffset") + J.I(o, "byteOffset"); int num7 = J.I(o2, "byteStride", num3 * num4); bool flag = J.B(o, "normalized"); float[] array = new float[num5 * num4]; for (int i = 0; i < num5; i++) { for (int j = 0; j < num4; j++) { int num8 = num6 + i * num7 + j * num3; float num9 = num2 switch { 5126 => BitConverter.ToSingle(bin, num8), 5125 => BitConverter.ToUInt32(bin, num8), 5123 => (int)BitConverter.ToUInt16(bin, num8), 5122 => BitConverter.ToInt16(bin, num8), 5121 => (int)bin[num8], 5120 => (sbyte)bin[num8], _ => throw new NotSupportedException("GLB component " + num2), }; if (flag) { switch (num2) { case 5121: num9 /= 255f; break; case 5123: num9 /= 65535f; break; case 5120: num9 = Mathf.Max(num9 / 127f, -1f); break; case 5122: num9 = Mathf.Max(num9 / 32767f, -1f); break; } } array[i * num4 + j] = num9; } } return array; } private int[] AccessIndices(int idx) { float[] array = AccessFloats(idx); int[] array2 = new int[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = (int)array[i]; } return array2; } private Mesh GetMesh(int id, int skinId, int primitiveIndex) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) string key = id + ":" + skinId + ":" + primitiveIndex; if (meshCache.TryGetValue(key, out var value)) { return value; } List<object> list = J.L(meshes[id], "primitives"); if (list.Count == 0) { return null; } if (primitiveIndex < 0 || primitiveIndex >= list.Count) { throw new InvalidDataException("GLB primitive index out of range: " + id); } object o = list[primitiveIndex]; object o2 = J.V(o, "attributes"); int num = J.I(o2, "POSITION", -1); if (num < 0) { throw new InvalidDataException("Mesh has no vertex positions"); } float[] array = AccessFloats(num); int num2 = array.Length / 3; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; for (int i = 0; i < num2; i++) { array2[i] = new Vector3(array[i * 3], array[i * 3 + 1], 0f - array[i * 3 + 2]); } int[] array3 = AccessIndices(J.I(o, "indices")); for (int j = 0; j + 2 < array3.Length; j += 3) { int num3 = array3[j + 1]; array3[j + 1] = array3[j + 2]; array3[j + 2] = num3; } Mesh val = new Mesh(); ((Object)val).name = J.S(meshes[id], "name", "MuffetMesh_" + id); val.indexFormat = (IndexFormat)1; val.vertices = array2; val.triangles = array3; int num4 = J.I(o2, "NORMAL", -1); if (num4 >= 0) { float[] array4 = AccessFloats(num4); Vector3[] array5 = (Vector3[])(object)new Vector3[num2]; for (int k = 0; k < num2; k++) { array5[k] = new Vector3(array4[k * 3], array4[k * 3 + 1], 0f - array4[k * 3 + 2]); } val.normals = array5; } else { val.RecalculateNormals(); } int num5 = J.I(o2, "TEXCOORD_0", -1); if (num5 >= 0) { float[] array6 = AccessFloats(num5); Vector2[] array7 = (Vector2[])(object)new Vector2[num2]; for (int l = 0; l < num2; l++) { array7[l] = new Vector2(array6[l * 2], 1f - array6[l * 2 + 1]); } val.uv = array7; } if (skinId >= 0) { int num6 = J.I(o2, "JOINTS_0", -1); int num7 = J.I(o2, "WEIGHTS_0", -1); if (num6 < 0 || num7 < 0) { throw new InvalidDataException("Skinned mesh lacks JOINTS_0 / WEIGHTS_0"); } float[] array8 = AccessFloats(num6); float[] array9 = AccessFloats(num7); BoneWeight[] array10 = (BoneWeight[])(object)new BoneWeight[num2]; for (int m = 0; m < num2; m++) { ((BoneWeight)(ref array10[m])).boneIndex0 = (int)array8[m * 4]; ((BoneWeight)(ref array10[m])).boneIndex1 = (int)array8[m * 4 + 1]; ((BoneWeight)(ref array10[m])).boneIndex2 = (int)array8[m * 4 + 2]; ((BoneWeight)(ref array10[m])).boneIndex3 = (int)array8[m * 4 + 3]; float num8 = array9[m * 4] + array9[m * 4 + 1] + array9[m * 4 + 2] + array9[m * 4 + 3]; num8 = ((num8 > 0.001f) ? num8 : 1f); ((BoneWeight)(ref array10[m])).weight0 = array9[m * 4] / num8; ((BoneWeight)(ref array10[m])).weight1 = array9[m * 4 + 1] / num8; ((BoneWeight)(ref array10[m])).weight2 = array9[m * 4 + 2] / num8; ((BoneWeight)(ref array10[m])).weight3 = array9[m * 4 + 3] / num8; } val.boneWeights = array10; object o3 = skins[skinId]; int num9 = J.I(o3, "inverseBindMatrices", -1); Matrix4x4[] array11 = (Matrix4x4[])(object)new Matrix4x4[J.L(o3, "joints").Count]; if (num9 >= 0) { float[] array12 = AccessFloats(num9); for (int n = 0; n < array11.Length; n++) { Matrix4x4 val2 = default(Matrix4x4); for (int num10 = 0; num10 < 4; num10++) { for (int num11 = 0; num11 < 4; num11++) { float num12 = array12[n * 16 + num10 * 4 + num11]; if (num11 == 2) { num12 = 0f - num12; } if (num10 == 2) { num12 = 0f - num12; } ((Matrix4x4)(ref val2))[num11, num10] = num12; } } array11[n] = val2; } } else { for (int num13 = 0; num13 < array11.Length; num13++) { array11[num13] = Matrix4x4.identity; } } val.bindposes = array11; } List<object> list2 = J.L(o, "targets"); for (int num14 = 0; num14 < list2.Count; num14++) { int num15 = J.I(list2[num14], "POSITION", -1); if (num15 >= 0) { float[] array13 = AccessFloats(num15); Vector3[] array14 = (Vector3[])(object)new Vector3[num2]; for (int num16 = 0; num16 < num2; num16++) { array14[num16] = new Vector3(array13[num16 * 3], array13[num16 * 3 + 1], 0f - array13[num16 * 3 + 2]); } val.AddBlendShapeFrame("MuffetOrTeaMorph_" + num14, 100f, array14, (Vector3[])(object)new Vector3[num2], (Vector3[])(object)new Vector3[num2]); } } val.RecalculateBounds(); meshCache[key] = val; return val; } private Texture2D GetTexture(int id) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if (textureCache.TryGetValue(id, out var value)) { return value; } int num = J.I(textures[id], "source", -1); if (num < 0) { return null; } int num2 = J.I(images[num], "bufferView", -1); if (num2 < 0) { return null; } byte[] array = ViewBytes(num2); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val, array, false)) { throw new InvalidDataException("GLB embedded texture decode failed"); } ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)1; textureCache[id] = val; return val; } private Material GetMaterial(int id) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) if (matCache.TryGetValue(id, out var value)) { return value; } value = new Material(Shader.Find("HDRP/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default")); if (id >= 0 && id < mats.Count) { object o = mats[id]; object o2 = J.V(o, "pbrMetallicRoughness"); ((Object)value).name = J.S(o, "name", "GLB_" + id); List<object> list = J.L(o2, "baseColorFactor"); if (list.Count >= 4) { Color val = default(Color); ((Color)(ref val))..ctor(J.N(list[0]), J.N(list[1]), J.N(list[2]), J.N(list[3])); value.color = val; if (value.HasProperty("_BaseColor")) { value.SetColor("_BaseColor", val); } } int num = J.I(J.V(o2, "baseColorTexture"), "index", -1); if (num >= 0 && num < textures.Count) { Texture2D val2 = (Texture2D)(object)(value.mainTexture = (Texture)(object)GetTexture(num)); if (value.HasProperty("_BaseColorMap")) { value.SetTexture("_BaseColorMap", (Texture)(object)val2); } } value.SetFloat("_Metallic", J.F(o2, "metallicFactor")); value.SetFloat("_Glossiness", 1f - J.F(o2, "roughnessFactor", 1f)); if (J.S(o, "alphaMode") == "BLEND" || value.color.a < 0.99f) { if (value.HasProperty("_Mode")) { value.SetFloat("_Mode", 3f); } if (value.HasProperty("_SurfaceType")) { value.SetFloat("_SurfaceType", 1f); } value.SetInt("_SrcBlend", 5); value.SetInt("_DstBlend", 10); value.SetInt("_ZWrite", 0); value.DisableKeyword("_ALPHATEST_ON"); value.EnableKeyword("_ALPHABLEND_ON"); value.renderQueue = 3000; } if (J.B(o, "doubleSided")) { value.SetInt("_Cull", 0); if (value.HasProperty("_DoubleSidedEnable")) { value.SetFloat("_DoubleSidedEnable", 1f); } } List<object> list2 = J.L(o, "emissiveFactor"); if (list2.Count >= 3) { value.SetColor("_EmissionColor", new Color(J.N(list2[0]), J.N(list2[1]), J.N(list2[2]))); value.EnableKeyword("_EMISSION"); } } matCache[id] = value; return value; } } internal static class MiniJSON { private sealed class Parser { private readonly string s; private int i; private char Peek { get { White(); if (i >= s.Length) { return '\0'; } return s[i]; } } public Parser(string text) { s = text; } private void White() { while (i < s.Length && char.IsWhiteSpace(s[i])) { i++; } } private void Eat(char c) { White(); if (i >= s.Length || s[i] != c) { throw new FormatException("GLB JSON expected '" + c + "' at " + i); } i++; } public object ParseValue() { switch (Peek) { case '{': return Obj(); case '[': return Arr(); case '"': return Str(); case 't': ReadWord("true"); return true; case 'f': ReadWord("false"); return false; case 'n': ReadWord("null"); return null; default: return Num(); } } private void ReadWord(string word) { if (i + word.Length > s.Length || string.CompareOrdinal(s, i, word, 0, word.Length) != 0) { throw new FormatException("Invalid JSON literal"); } i += word.Length; } private Dictionary<string, object> Obj() { Eat('{'); Dictionary<string, object> dictionary = new Dictionary<string, object>(StringComparer.Ordinal); if (Peek == '}') { i++; return dictionary; } while (true) { string key = Str(); Eat(':'); dictionary[key] = ParseValue(); if (Peek == '}') { break; } Eat(','); } i++; return dictionary; } private List<object> Arr() { Eat('['); List<object> list = new List<object>(); if (Peek == ']') { i++; return list; } while (true) { list.Add(ParseValue()); if (Peek == ']') { break; } Eat(','); } i++; return list; } private string Str() { Eat('"'); StringBuilder stringBuilder = new StringBuilder(); while (i < s.Length) { char c = s[i++]; switch (c) { case '"': return stringBuilder.ToString(); default: stringBuilder.Append(c); break; case '\\': if (i >= s.Length) { throw new FormatException("Invalid escape"); } switch (s[i++]) { case '"': stringBuilder.Append('"'); break; case '\\': stringBuilder.Append('\\'); break; case '/': stringBuilder.Append('/'); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': stringBuilder.Append((char)int.Parse(s.Substring(i, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture)); i += 4; break; default: throw new FormatException("Unsupported JSON escape"); } break; } } throw new FormatException("Unterminated JSON string"); } private double Num() { White(); int num = i; while (i < s.Length && "-+.0123456789eE".IndexOf(s[i]) >= 0) { i++; } if (i == num) { throw new FormatException("JSON number expected at " + i); } return double.Parse(s.Substring(num, i - num), CultureInfo.InvariantCulture); } } internal static object Parse(string input) { return new Parser(input).ParseValue(); } } internal static class J { internal static Dictionary<string, object> D(object o) { return (Dictionary<string, object>)o; } internal static List<object> A(object o) { return (List<object>)o; } internal static object V(object o, string k) { if (o == null || !D(o).TryGetValue(k, out var value)) { return null; } return value; } internal static string S(object o, string k, string fallback = "") { object obj = V(o, k); if (obj != null) { return (string)obj; } return fallback; } internal static int I(object o, string k, int fallback = 0) { object obj = V(o, k); if (obj != null) { return Convert.ToInt32(obj); } return fallback; } internal static float F(object o, string k, float fallback = 0f) { object obj = V(o, k); if (obj != null) { return Convert.ToSingle(obj); } return fallback; } internal static bool B(object o, string k, bool fallback = false) { object obj = V(o, k); if (obj != null) { return (bool)obj; } return fallback; } internal static List<object> L(object o, string k) { object obj = V(o, k); if (obj != null) { return A(obj); } return new List<object>(); } internal static float N(object o) { return Convert.ToSingle(o, CultureInfo.InvariantCulture); } } public sealed class MuffetChaseAudio : MonoBehaviour { private MuffetEnemyAI owner; private AudioSource steps; private float nextCheck; private void Start() { owner = ((Component)this).GetComponent<MuffetEnemyAI>(); steps = ((Component)this).gameObject.AddComponent<AudioSource>(); steps.playOnAwake = false; steps.loop = true; steps.spatialBlend = 1f; steps.rolloffMode = (AudioRolloffMode)1; steps.minDistance = 1.5f; steps.maxDistance = 22f; steps.dopplerLevel = 0f; steps.volume = 0.68f; steps.spatialize = false; steps.clip = MuffetSound.GetSpiderChaseFootsteps(); } private void Update() { if (Time.time < nextCheck) { return; } nextCheck = Time.time + 0.12f; bool flag = (Object)(object)owner != (Object)null && owner.IsSpiderChasing; if (!((Object)(object)steps == (Object)null) && !((Object)(object)steps.clip == (Object)null)) { if (flag && !steps.isPlaying) { steps.Play(); MuffetPlugin.Log.LogInfo((object)"[MuffetAudio64] SPIDER_STEPS_STARTED syncedChase=True"); } else if (!flag && steps.isPlaying) { steps.Stop(); } } } private void OnDisable() { if ((Object)(object)steps != (Object)null) { steps.Stop(); } } private void OnDestroy() { if ((Object)(object)steps != (Object)null) { steps.Stop(); } } } internal static class MuffetDevMenuBridge { private static bool loggedMissingMethod; public static void Install(Harmony harmony) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown try { Type type = AccessTools.TypeByName("QuickMenuManager"); if (type == null) { MuffetPlugin.Log.LogWarning((object)"[MUFFET DEV] QuickMenuManager not found (Ctrl+F6 still available)."); return; } MethodInfo methodInfo = AccessTools.Method(type, "Debug_SetEnemyDropdownOptions", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(MuffetDevMenuBridge), "AddMuffetToTestLevel", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { MuffetPlugin.Log.LogWarning((object)"[MUFFET DEV] Debug dropdown method missing in this game version; late-registration fallback enabled."); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MuffetPlugin.Log.LogInfo((object)"[MUFFET DEV] QuickMenuManager dropdown patch installed."); } catch (Exception ex) { MuffetPlugin.Log.LogWarning((object)("[MUFFET DEV] Dropdown patch error; fallback enabled: " + ex.Message)); } } private static void AddMuffetToTestLevel(object __instance) { AddIfMissing(__instance); } internal static void EnsureLoadedMenu() { if ((Object)(object)MuffetPlugin.EnemyItem == (Object)null) { return; } try { Type type = AccessTools.TypeByName("QuickMenuManager"); if (!(type == null)) { Object val = Object.FindObjectOfType(type); if (val != (Object)null) { AddIfMissing(val); } } } catch (Exception ex) { if (!loggedMissingMethod) { loggedMissingMethod = true; MuffetPlugin.Log.LogWarning((object)("[MUFFET DEV] Late-menu check failed: " + ex.Message)); } } } private static void AddIfMissing(object menu) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown if (menu == null || (Object)(object)MuffetPlugin.EnemyItem == (Object)null) { return; } try { FieldInfo fieldInfo = AccessTools.Field(menu.GetType(), "testAllEnemiesLevel"); SelectableLevel val = (SelectableLevel)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null) && val.Enemies != null && !val.Enemies.Any((SpawnableEnemyWithRarity e) => e != null && (Object)(object)e.enemyType == (Object)(object)MuffetPlugin.EnemyItem)) { val.Enemies.Add(new SpawnableEnemyWithRarity(MuffetPlugin.EnemyItem, 25)); MuffetPlugin.Log.LogInfo((object)"[MUFFET DEV] Muffet added to indoor enemy test dropdown."); } } catch (Exception ex) { if (!loggedMissingMethod) { loggedMissingMethod = true; MuffetPlugin.Log.LogWarning((object)("[MUFFET DEV] Cannot add Muffet to test list: " + ex.Message)); } } } } public sealed class MuffetDebugTools : MonoBehaviour { private readonly List<NetworkObject> spawnedForTesting = new List<NetworkObject>(); private bool showOverlay; private string lastAction = "No test action yet."; private float lastActionTime; private float nextDevMenuCheck; private static GUIStyle overlayStyle; private void Update() { if (Time.unscaledTime >= nextDevMenuCheck) { nextDevMenuCheck = Time.unscaledTime + 4f; MuffetDevMenuBridge.EnsureLoadedMenu(); } if (MuffetPlugin.DebugHotkeys == null || !MuffetPlugin.DebugHotkeys.Value) { return; } Keyboard current = Keyboard.current; if (current != null && (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.rightCtrlKey).isPressed)) { if (((ButtonControl)current.f6Key).wasPressedThisFrame) { SpawnMuffet(); } else if (((ButtonControl)current.f7Key).wasPressedThisFrame) { Inform("The bundled Spider Donut spawns ONLY when Muffet appears. Use Ctrl+F6."); } else if (((ButtonControl)current.f8Key).wasPressedThisFrame) { SpawnItem(MuffetPlugin.TeaItem, "Tea", Random.Range(70, 101)); } else if (((ButtonControl)current.f9Key).wasPressedThisFrame) { ClearDebugObjects(); } else if (((ButtonControl)current.f10Key).wasPressedThisFrame) { showOverlay = !showOverlay; } } } private bool CheckHost(out PlayerControllerB player) { player = null; if ((Object)(object)MuffetPlugin.EnemyItem == (Object)null || (Object)(object)MuffetPlugin.EnemyItem.enemyPrefab == (Object)null) { Inform("Muffet EnemyType is not registered. Read the first [Muffet] error in BepInEx/LogOutput.log."); return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { Inform("Start or join a game first."); return false; } if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer) { Inform("Debug spawning is host-only. Host a private lobby to test."); return false; } if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)RoundManager.Instance == (Object)null || StartOfRound.Instance.inShipPhase) { Inform("Land on a moon before spawning Muffet."); return false; } player = (((Object)(object)GameNetworkManager.Instance == (Object)null) ? null : GameNetworkManager.Instance.localPlayerController); if ((Object)(object)player == (Object)null || player.isPlayerDead) { Inform("Local player is unavailable or dead."); return false; } return true; } private void SpawnMuffet() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!CheckHost(out var player)) { return; } bool flag = (Object)(object)GameObject.Find("TestRoom(Clone)") != (Object)null || (Object)(object)GameObject.Find("TestLevel") != (Object)null; if (!player.isInsideFactory && !flag) { Inform("Enter the facility (or dev TestRoom) to spawn Muffet."); return; } MuffetEnemyAI[] array = Object.FindObjectsOfType<MuffetEnemyAI>(); foreach (MuffetEnemyAI muffetEnemyAI in array) { if ((Object)(object)muffetEnemyAI != (Object)null && (Object)(object)((NetworkBehaviour)muffetEnemyAI).NetworkObject != (Object)null && ((NetworkBehaviour)muffetEnemyAI).NetworkObject.IsSpawned && !muffetEnemyAI.IsTradingOrSettled) { Inform("A Muffet is already active. Clear prior test spawns with Ctrl+F9 or reload the round first."); MuffetPlugin.Log.LogWarning((object)"[MuffetModel36] Prevented a second Muffet model (two overlapping six-arm rigs)."); return; } } try { NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(((Component)player).transform.position + ((Component)player).transform.forward * 4f, ref val, 5f, -1) && !NavMesh.SamplePosition(((Component)player).transform.position, ref val, 9f, -1)) { Inform("Ctrl+F6 received, but no valid indoor NavMesh was found near the player."); return; } NetworkObjectReference val2 = RoundManager.Instance.SpawnEnemyGameObject(((NavMeshHit)(ref val)).position, ((Component)player).transform.eulerAngles.y + 180f, -1, MuffetPlugin.EnemyItem); NetworkObject val3 = default(NetworkObject); if (((NetworkObjectReference)(ref val2)).TryGet(ref val3, (NetworkManager)null) && (Object)(object)val3 != (Object)null) { spawnedForTesting.Add(val3); Inform("Muffet spawned; web radius " + MuffetPlugin.WebRadius.Value.ToString("0") + "m."); } else { Inform("Muffet spawn request sent, but no NetworkObject was returned. Check game log."); } } catch (Exception ex) { Inform("Muffet spawn error: " + ex.Message); MuffetPlugin.Log.LogError((object)ex); } } private void SpawnItem(Item item, string label, int scrapValue) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (!CheckHost(out var player)) { return; } if ((Object)(object)item == (Object)null || (Object)(object)item.spawnPrefab == (Object)null) { Inform("Missing " + label + " registered runtime item prefab."); return; } try { Vector3 val = ((Component)player).transform.position + ((Component)player).transform.forward * 1.7f + Vector3.up * 0.4f; GameObject val2 = Object.Instantiate<GameObject>(item.spawnPrefab, val, Quaternion.identity); MuffetScrapVisibility63.NormalizeInstance(val2, "debug-test-instance"); GrabbableObject component = val2.GetComponent<GrabbableObject>(); NetworkObject component2 = val2.GetComponent<NetworkObject>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val2); Inform(label + " prefab requires GrabbableObject and NetworkObject."); return; } component.itemProperties = item; component.grabbable = true; component.isInFactory = true; component2.Spawn(true); if (component is MuffetTea muffetTea) { muffetTea.AssignValueOnServer(scrapValue); } else { component.SetScrapValue(scrapValue); } spawnedForTesting.Add(component2); Inform(label + " (" + scrapValue + " credits) spawned in front of the player."); } catch (Exception ex) { Inform(label + " spawn error: " + ex.Message); MuffetPlugin.Log.LogError((object)ex); } } private void ClearDebugObjects() { if (!CheckHost(out var _)) { return; } int num = 0; foreach (NetworkObject item in spawnedForTesting) { if (!((Object)(object)item == (Object)null) && item.IsSpawned) { try { item.Despawn(true); num++; } catch (Exception ex) { MuffetPlugin.Log.LogWarning((object)("Could not despawn a test object: " + ex.Message)); } } } spawnedForTesting.Clear(); Inform("Removed " + num + " hotkey-spawned objects."); } private void Inform(string message) { lastAction = message; lastActionTime = Time.unscaledTime; MuffetPlugin.Log.LogInfo((object)("[TEST] " + message)); if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("Muffet TEST", message, false, false, "LC_Tip1"); } } private void OnGUI() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (showOverlay && MuffetPlugin.DebugHotkeys != null && MuffetPlugin.DebugHotkeys.Value) { if (overlayStyle == null) { overlayStyle = new GUIStyle(GUI.skin.box); overlayStyle.alignment = (TextAnchor)0; overlayStyle.fontSize = 14; overlayStyle.wordWrap = true; } string text = (((Object)(object)MuffetPlugin.EnemyItem != (Object)null) ? ("Enemy: READY | Tea: " + (((Object)(object)MuffetPlugin.TeaItem != (Object)null) ? "READY" : "NOT READY")) : "Enemy: NOT READY (read BepInEx errors)"); string text2 = (((Object)(object)NetworkManager.Singleton != (Object)null && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)) ? "Host: yes" : "Host: no"); string text3 = ((Time.unscaledTime - lastActionTime < 15f) ? lastAction : "Press Ctrl+F6 to try a test spawn."); GUI.Box(new Rect(12f, 12f, 480f, 145f), "MUFFET TEST (MUFFET_07)\n" + text + " | " + text2 + "\nCtrl+F6 Muffet(+donut) | Ctrl+F7 spawn rule | Ctrl+F8 Tea\nCtrl+F9 Clear debug spawns | Ctrl+F10 Close\n" + text3, overlayStyle); } } } public sealed class MuffetDonutAnimation : MonoBehaviour { private MuffetGltfAnimator animator; internal void Initialise(MuffetGltfAnimator motion) { animator = motion; } private void Start() { if ((Object)(object)animator == (Object)null) { animator = ((Component)this).GetComponentInChildren<MuffetGltfAnimator>(true); } if ((Object)(object)animator == (Object)null) { return; } string[] array = new string[10] { "Flies_Buzz_Loop_6s", "Fly", "Flies", "FlyLoop", "Flying", "Buzz", "Idle", "idle", "fly", "fly_loop" }; foreach (string text in array) { if (animator.HasClip(text)) { animator.Play(text, loop: true); MuffetPlugin.Log.LogInfo((object)("[MuffetDonut56] Replaying ORIGINAL GLB animation: " + text)); return; } } if (animator.PlayFirstAvailableClip(loop: true)) { MuffetPlugin.Log.LogInfo((object)"[MuffetDonut56] Replaying first original GLB animation clip."); } } } public sealed class MuffetDonutDiagnostics : MonoBehaviour { private float nextCheck; private int reports; private void Update() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if (reports >= 4 || Time.time < nextCheck) { return; } nextCheck = Time.time + 2.5f; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.localPlayerController == (Object)null) { return; } PlayerControllerB localPlayerController = instance.localPlayerController; if ((Object)(object)localPlayerController.gameplayCamera == (Object)null) { return; } GrabbableObject component = ((Component)this).GetComponent<GrabbableObject>(); if ((Object)(object)component == (Object)null || !((NetworkBehaviour)component).NetworkObject.IsSpawned) { return; } Vector3 position = ((Component)localPlayerController.gameplayCamera).transform.position; float num = Vector3.Distance(position, ((Component)this).transform.position); if (num > 5.5f) { return; } ScanNodeProperties componentInChildren = ((Component)this).GetComponentInChildren<ScanNodeProperties>(true); Collider component2 = ((Component)this).GetComponent<Collider>(); RaycastHit[] array = Physics.RaycastAll(new Ray(position, ((Component)localPlayerController.gameplayCamera).transform.forward), 5.5f, -1, (QueryTriggerInteraction)2); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); string text = ""; bool flag = false; bool flag2 = false; int num2 = Math.Min(array.Length, 6); for (int num3 = 0; num3 < num2; num3++) { RaycastHit val = array[num3]; if (num3 > 0) { text += ", "; } text = text + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name + "(L" + ((Component)((RaycastHit)(ref val)).collider).gameObject.layer + ",d=" + ((RaycastHit)(ref val)).distance.ToString("F2") + ",trigger=" + ((RaycastHit)(ref val)).collider.isTrigger + ")"; if ((Object)(object)((RaycastHit)(ref val)).collider == (Object)(object)component2) { flag = true; } if ((Object)(object)componentInChildren != (Object)null && ((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(((Component)componentInChildren).transform)) { flag2 = true; } } reports++; MuffetPlugin.Log.LogInfo((object)("[MuffetDonut][NEAR32] cameraDist=" + num.ToString("F2") + "; root=" + ((Component)this).gameObject.tag + "/" + ((Component)this).gameObject.layer + "; collider=" + ((Object)(object)component2 != (Object)null && component2.enabled) + "; rootRayHit=" + flag + "; scanRayHit=" + flag2 + "; scan=" + (((Object)(object)componentInChildren != (Object)null) ? (((Component)componentInChildren).gameObject.layer + "/" + ((Behaviour)componentInChildren).enabled) : "missing") + "; grab=" + component.grabbable + "; held=" + component.isHeld + "; item=" + (((Object)(object)component.itemProperties != (Object)null) ? component.itemProperties.itemName : "null") + "; rayHits=[" + text + "]")); } } [DefaultExecutionOrder(30000)] public sealed class MuffetEffects : MonoBehaviour { private static MuffetEffects instance; private PlayerControllerB player; private bool effectActive; private TeaEffect activeEffect; private float appliedSpeedFactor = 1f; private float appliedJumpFactor = 1f; private float appliedWeightDelta; private float oldDrunkness; private float oldDrunknessInertia; private bool tzpWasForced; private bool hadRoundStarted; private bool hasSeenActiveRound; private float effectStartedAt; private const float EffectDuration = 90f; private float initialSpeed = 4.6f; private float initialJump = 13f; private CameraRollEffect cameraRoll; private readonly HashSet<MuffetWeb> soundedWebs = new HashSet<MuffetWeb>(); private AudioSource webWalkAudio; private Vector3 previousSilkPosition; private bool previousSilkPositionValid; private float lastConfirmedWebWalkAt = -100f; private float nextWeightUiRefreshAt; public static bool ShovelBuffActive { get { if ((Object)(object)instance != (Object)null && instance.effectActive) { return instance.activeEffect == TeaEffect.ShovelPlusOne; } return false; } } public static void Ensure() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)instance != (Object)null)) { GameObject val = new GameObject("Muffet_Tea_RoundEffectController"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent<MuffetEffects>(); } } public static void Apply(TeaEffect effect) { Ensure(); instance.Begin(effect); } private void Begin(TeaEffect effect) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) player = GameNetworkManager.Instance.localPlayerController; if (!((Object)(object)player == (Object)null) && !player.isPlayerDead) { RestoreModifiers(); activeEffect = effect; effectActive = true; hadRoundStarted = true; effectStartedAt = Time.time; initialSpeed = player.movementSpeed; initialJump = player.jumpForce; if (effect == TeaEffect.Heal30 && (Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.UpdateHealthUI(player.health, false); } if (effect == TeaEffect.Hurt30) { player.DamagePlayer(30, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); } if (effect == TeaEffect.Heal30 || effect == TeaEffect.Hurt30 || effect == TeaEffect.PriceUp || effect == TeaEffect.PriceDown) { effectActive = false; } if (effect == TeaEffect.TZPDizzy) { oldDrunkness = player.drunkness; oldDrunknessInertia = player.drunknessInertia; tzpWasForced = true; } if (effect == TeaEffect.TiltedView45 || effect == TeaEffect.TZPDizzy) { EnsureCameraRoll(); } MuffetPlugin.Log.LogInfo((object)("[MuffetTea66] EFFECT_START " + effect.ToString() + " duration=" + (effectActive ? "90" : "0") + " carryWeight=" + player.carryWeight.ToString("F2"))); ShowVanillaEffectTip(effect); } } private void EnsureCameraRoll() { if (!((Object)(object)player == (Object)null) && !((Object)(object)player.gameplayCamera == (Object)null)) { if ((Object)(object)cameraRoll != (Object)null && (Object)(object)((Component)cameraRoll).gameObject != (Object)(object)((Component)player.gameplayCamera).gameObject) { ((Behaviour)cameraRoll).enabled = false; } cameraRoll = ((Component)player.gameplayCamera).gameObject.GetComponent<CameraRollEffect>(); if ((Object)(object)cameraRoll == (Object)null) { cameraRoll = ((Component)player.gameplayCamera).gameObject.AddComponent<CameraRollEffect>(); } cameraRoll.dizzy = activeEffect == TeaEffect.TZPDizzy; ((Behaviour)cameraRoll).enabled = true; } } private static void ShowVanillaEffectTip(TeaEffect effect) { MuffetTeaEffectToast.Show(Explain(effect), effect <= TeaEffect.Heal30 || effect == TeaEffect.PriceUp); HUDManager val = HUDManager.Instance; if ((Object)(object)val != (Object)null && (Object)(object)val.UIAudio != (Object)null) { AudioClip val2 = null; AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>(); foreach (AudioClip val3 in array) { if ((Object)(object)val3 != (Object)null && (((Object)val3).name == "TipsHUD" || ((Object)val3).name == "TipsHUD2")) { val2 = val3; break; } } if ((Object)(object)val2 != (Object)null) { val.UIAudio.PlayOneShot(val2, 0.9f); } } MuffetPlugin.Log.LogInfo((object)("[MuffetTea50] KOREAN_YELLOW_TIP: " + Explain(effect))); } private static string Explain(TeaEffect effect) { return MuffetText.T(ExplainKorean(effect)); } private static string ExplainKorean(TeaEffect effect) { return effect switch { TeaEffect.SpeedUp => "행운! 90초간 이동속도 증가", TeaEffect.StaminaUp => "행운! 90초간 스태미나 증가", TeaEffect.ShovelPlusOne => "행운! 90초간 삽 공격력 +1", TeaEffect.ScrapLighter => "행운! 90초간 운반 무게 감소", TeaEffect.Heal30 => "행운! 체력 30 회복", TeaEffect.TZPDizzy => "불운! 90초간 어지러움", TeaEffect.ScrapHeavier => "불운! 90초간 운반 무게 증가", TeaEffect.TiltedView45 => "불운! 90초간 화면 기울어짐", TeaEffect.Hurt30 => "불운! 체력 30 감소", TeaEffect.PriceUp => "행운! 인벤토리 스크랩 가격 상승", TeaEffect.PriceDown => "불운! 인벤토리 스크랩 가격 하락", _ => "", }; } private void LateUpdate() { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) player = (((Object)(object)GameNetworkManager.Instance == (Object)null) ? null : GameNetworkManager.Instance.localPlayerController); if ((Object)(object)player == (Object)null || player.isPlayerDead) { StopWebWalkSound(); RestoreModifiers(); return; } if ((Object)(object)StartOfRound.Instance != (Object)null && !StartOfRound.Instance.inShipPhase) { hasSeenActiveRound = true; } if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.inShipPhase && hasSeenActiveRound && hadRoundStarted) { StopWebWalkSound(); RestoreModifiers(); effectActive = false; hadRoundStarted = false; hasSeenActiveRound = false; soundedWebs.Clear(); MuffetWebDialogue.ResetRound(); return; } if (Mathf.Abs(appliedSpeedFactor) > 0.01f) { PlayerControllerB obj = player; obj.movementSpeed /= appliedSpeedFactor; } if (Mathf.Abs(appliedJumpFactor) > 0.01f) { PlayerControllerB obj2 = player; obj2.jumpForce /= appliedJumpFactor; } if (Mathf.Abs(appliedWeightDelta) > 1E-06f) { PlayerControllerB obj3 = player; obj3.carryWeight -= appliedWeightDelta; } appliedSpeedFactor = (appliedJumpFactor = 1f); appliedWeightDelta = 0f; bool flag = MuffetWeb.Contains(((Component)player).transform.position); if (flag && MuffetSound.EncounterCuesAllowed) { foreach (MuffetWeb item in MuffetWeb.Active) { if ((Object)(object)item == (Object)null || !((Behaviour)item).isActiveAndEnabled || soundedWebs.Contains(item)) { continue; } Vector3 val = ((Component)player).transform.position - ((Component)item).transform.position; if (Mathf.Abs(val.y) <= 2.5f && val.x * val.x + val.z * val.z <= item.Radius * item.Radius) { soundedWebs.Add(item); MuffetSound.PlayFirstWeb(((Component)item).transform.position); MuffetEnemyAI muffetEnemyAI = ((Component)item).GetComponentInParent<MuffetEnemyAI>() ?? MuffetEnemyAI.NearestTo(((Component)item).transform.position); MuffetWebDialogue.Mood? mood = (((Object)(object)muffetEnemyAI == (Object)null) ? new MuffetWebDialogue.Mood?(MuffetWebDialogue.Mood.Normal) : muffetEnemyAI.EntryDialogueMood()); if (mood.HasValue) { MuffetWebDialogue.BeginForLocalPlayer(mood.Value); } } } } UpdateWebWalkSound(flag); if (flag) { appliedSpeedFactor *= Mathf.Clamp(MuffetPlugin.WebSpeedMultiplier.Value, 0.1f, 1f); } if (effectActive && Time.time - effectStartedAt >= 90f) { effectActive = false; RestoreModifiers(); if ((Object)(object)cameraRoll != (Object)null) { ((Behaviour)cameraRoll).enabled = false; } if ((Object)(object)HUDManager.Instance != (Object)null) { MuffetTeaEffectToast.Show(MuffetText.T("차의 효과가 사라졌습니다."), good: true); } } if (effectActive) { if ((activeEffect == TeaEffect.TiltedView45 || activeEffect == TeaEffect.TZPDizzy) && ((Object)(object)cameraRoll == (Object)null || !((Behaviour)cameraRoll).enabled || ((Object)(object)player.gameplayCamera != (Object)null && (Object)(object)((Component)cameraRoll).gameObject != (Object)(object)((Component)player.gameplayCamera).gameObject))) { EnsureCameraRoll(); } switch (activeEffect) { case TeaEffect.SpeedUp: appliedSpeedFactor *= MuffetPlugin.SpeedBuff.Value; break; case TeaEffect.StaminaUp: player.sprintMeter = Mathf.Clamp01(player.sprintMeter + Time.deltaTime * (player.isSprinting ? 0.018f : 0.025f)); break; case TeaEffect.ScrapLighter: appliedWeightDelta = -0.2f * Mathf.Max(0f, player.carryWeight - 1f); break; case TeaEffect.ScrapHeavier: appliedWeightDelta = 0.2f * Mathf.Max(0f, player.carryWeight - 1f); break; case TeaEffect.TZPDizzy: player.drunkness = Mathf.Max(player.drunkness, 1f); player.drunknessInertia = Mathf.Max(player.drunknessInertia, 2f); break; } } PlayerControllerB obj4 = player; obj4.movementSpeed *= appliedSpeedFactor; PlayerControllerB obj5 = player; obj5.jumpForce *= appliedJumpFactor; float carryWeight = player.carryWeight; player.carryWeight = Mathf.Max(1f, carryWeight + appliedWeightDelta); appliedWeightDelta = player.carryWeight - carryWeight; if (effectActive && (activeEffect == TeaEffect.ScrapHeavier || activeEffect == TeaEffect.ScrapLighter) && Time.unscaledTime >= nextWeightUiRefreshAt) { nextWeightUiRefreshAt = Time.unscaledTime + 0.2f; if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.UpdateWeightCounter(); } } } private void UpdateWebWalkSound(bool inWeb) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0047: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0054: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { StopWebWalkSound(); return; } Vector3 position = ((Component)player).transform.position; float num = Mathf.Max(0.005f, Time.deltaTime); Vector3 val = (previousSilkPositionValid ? (position - previousSilkPosition) : Vector3.zero); previousSilkPosition = position; previousSilkPositionValid = true; Vector2 val2 = new Vector2(val.x, val.z); float num2 = ((Vector2)(ref val2)).magnitude / num; int num3; if (inWeb && num2 > 0.3f && num2 < 12f && !player.isPlayerDead) { num3 = (MuffetSound.CanPlayWebWalking ? 1 : 0); if (num3 != 0) { lastConfirmedWebWalkAt = Time.unscaledTime; } } else { num3 = 0; } if (num3 == 0 && Time.unscaledTime - lastConfirmedWebWalkAt > 0.45f) { StopWebWalkSound(); return; } if ((Object)(object)webWalkAudio == (Object)null) { webWalkAudio = ((Component)this).gameObject.AddComponent<AudioSource>(); webWalkAudio.playOnAwake = false; webWalkAudio.loop = true; webWalkAudio.spatialBlend = 0f; webWalkAudio.volume = 0.36f; webWalkAudio.spatialize = false; webWalkAudio.clip = MuffetSound.GetWebWalk(); } if ((Object)(object)webWalkAudio.clip != (Object)null && !webWalkAudio.isPlaying) { webWalkAudio.Play(); } } private void StopWebWalkSound() { if ((Object)(object)webWalkAudio != (Object)null && webWalkAudio.isPlaying) { webWalkAudio.Stop(); } } private void RestoreModifiers() { if ((Object)(object)player != (Object)null) { if (Mathf.Abs(appliedSpeedFactor) > 0.01f) { PlayerControllerB obj = player; obj.movementSpeed /= appliedSpeedFactor; } if (Mathf.Abs(appliedJumpFactor) > 0.01f) { PlayerControllerB obj2 = player; obj2.jumpForce /= appliedJumpFactor; } if (Mathf.Abs(appliedWeightDelta) > 1E-06f) { PlayerControllerB obj3 = player; obj3.carryWeight -= appliedWeightDelta; } } appliedSpeedFactor = (appliedJumpFactor = 1f); appliedWeightDelta = 0f; if ((Object)(object)cameraRoll != (Object)null) { ((Behaviour)cameraRoll).enabled = false; } if (tzpWasForced && (Object)(object)player != (Object)null) { player.drunkness = oldDrunkness; player.drunknessInertia = oldDrunknessInertia; tzpWasForced = false; } } private void OnDestroy() { StopWebWalkSound(); RestoreModifiers(); if ((Object)(object)instance == (Object)(object)this) { instance = null; } } } [DefaultExecutionOrder(32000)] [RequireComponent(typeof(Camera))] public sealed class CameraRollEffect : MonoBehaviour { public bool dizzy; private Quaternion cameraBeforeEffect; private bool poseModified; private void OnEnable() { MuffetPlugin.Log.LogInfo((object)("[MuffetTea66] PLAYER_CAMERA_EFFECT_ENABLED " + ((Object)this).name)); } private void LateUpdate() { //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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) RestoreView(); cameraBeforeEffect = ((Component)this).transform.localRotation; float unscaledTime = Time.unscaledTime; float num = (dizzy ? (Mathf.Sin(unscaledTime * 2.4f) * 14f + Mathf.Sin(unscaledTime * 4.6f) * 5f) : 45f); float num2 = (dizzy ? (Mathf.Sin(unscaledTime * 2f) * 5f) : 0f); ((Component)this).transform.localRotation = cameraBeforeEffect * Quaternion.Euler(num2, 0f, num); poseModified = true; } internal void RestoreView() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (poseModified) { ((Component)this).transform.localRotation = cameraBeforeEffect; poseModified = false; } } private void OnDisable() { RestoreView(); } private void OnDestroy() { RestoreView(); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class CameraRollMouseLookPatch { private static void Prefix(PlayerControllerB __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.gameplayCamera == (Object)null) && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { CameraRollEffect component = ((Component)__instance.gameplayCamera).GetComponent<CameraRollEffect>(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled) { component.RestoreView(); } } } } [HarmonyPatch(typeof(Shovel), "HitShovel")] internal static class ShovelBonusPatch { private static readonly FieldInfo ForceField = AccessTools.Field(typeof(Shovel), "shovelHitForce"); private static readonly FieldInfo HolderField = AccessTools.Field(typeof(Shovel), "previousPlayerHeldBy"); private static void Prefix(Shovel __instance, out int __state) { __state = -1; if (!((Object)(object)__instance == (Object)null) && !(ForceField == null) && MuffetEffects.ShovelBuffActive) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance == (Object)null) ? null : GameNetworkManager.Instance.localPlayerController); if (!((Object)(object)val == (Object)null) && !(HolderField == null) && HolderField.GetValue(__instance) == val) { __state = (int)ForceField.GetValue(__instance); ForceField.SetValue(__instance, __state + 1); MuffetPlugin.Log.LogInfo((object)("[MuffetTea66] SHOVEL_FORCE " + __state + " -> " + (__state + 1))); } } } private static void Postfix(Shovel __instance, int __state) { if (__state >= 0 && ForceField != null && (Object)(object)__instance != (Object)null) { ForceField.SetValue(__instance, __state); } } private static Exception Finalizer(Shovel __instance, int __state, Exception __exception) { if (__state >= 0 && ForceField != null && (Object)(object)__instance != (Object)null) { ForceField.SetValue(__instance, __state); } return __exception; } } public sealed class MuffetEnemyAI : EnemyAI { public InteractTrigger tradeTrigger; public BoxCollider rageHitbox; public GameObject originalVisual; public GameObject transformedVisual; public MuffetGltfAnimator transformedAnimator; private readonly NetworkVariable<int> ragePhase = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<Vector3> silkOrigin = new NetworkVariable<Vector3>(Vector3.zero, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private const float NoBodyYaw = -1000f; private readonly NetworkVariable<float> bodyYaw = new NetworkVariable<float>(-1000f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private Quaternion webWorldRotation; private bool webRotationSaved; private int neutralShovelHits; private int spiderHealth = 5; private ulong firstAttacker = ulong.MaxValue; private Coroutine pursuitRoutine; private readonly Dictionary<ulong, float> lastHitPerPlayer = new Dictionary<ulong, float>(); private float nextSpiderAttack; private int spiderAttackVisualSequence; private const float SpiderContactHorizontalRange = 1.55f; private const float SpiderContactVerticalRange = 1.65f; private const float SpiderHitCooldownSeconds = 1f; private Coroutine horrorTransformServer; private Coroutine horrorTransformVisual; private bool originalVisualPoseSaved; private Vector3 originalVisualBasePosition; private Vector3 originalVisualBaseScale; private Quaternion originalVisualBaseRotation; private const float HorrorTransformationSeconds = 2.8f; private MuffetWeb web; private MuffetProgressLabel progressLabel; private bool settled; private bool busy; private int valuableDonations; private bool donutQueued; private MuffetTea pendingTeaReward; private bool startedFade; private int lastLocalOfferFrame = -1; private static Sprite cachedHandIcon; private static Sprite transparentHoverIcon; private const string AngryFirstHitLine = "지금 뭐하는거야?"; public bool IsSpiderChasing { get { if (((NetworkBehaviour)this).IsSpawned) { return ragePhase.Value == 2; } return false; } } internal bool HasTransformed { get { if (ragePhase.Value != 2) { return ragePhase.Value == 3; } return true; } } internal bool IsHostileOrDead => ragePhase.Value != 0; internal bool IsTradingOrSettled { get { if (!settled && !busy) { return ragePhase.Value > 1; } return true; } } internal bool InAngryPhase { get { if (((NetworkBehaviour)this).IsSpawned) { return ragePhase.Value == 1; } return false; } } internal bool GazeAllowed { get { if (!settled && !busy) { if (ragePhase.Value != 0) { return ragePhase.Value == 1; } return true; } return false; } } internal bool CanTurnBody { get { if (((NetworkBehaviour)this).IsSpawned) { return GazeAllowed; } return false; } } internal bool FollowsSyncedBodyYaw { get { if (((NetworkBehaviour)this).IsSpawned) { if (ragePhase.Value != 0) { return ragePhase.Value == 1; } return true; } return false; } } internal float SyncedBodyYaw => bodyYaw.Value; public override void OnNetworkSpawn() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) ((NetworkBehaviour)this).OnNetworkSpawn(); NetworkVariable<int> obj = ragePhase; obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnRagePhaseChanged)); if (((NetworkBehaviour)this).IsServer) { silkOrigin.Value = ((Component)this).transform.position; } if (((NetworkBehaviour)this).IsServer && ragePhase.Value == 0) { FaceOpenSpaceOnSpawn(); } if (ragePhase.Value > 0) { ApplyRageVisuals(ragePhase.Value); } MuffetSound.BeginNewEncounter(); ((MonoBehaviour)this).StartCoroutine(EnsureWebAfterNetworkSpawn()); EnsureFirstEncounterFear(); if (((NetworkBehaviour)this).IsServer && !donutQueued) { donutQueued = true; ((MonoBehaviour)this).StartCoroutine(SpawnBundledDonutIfUnique()); } } public override void OnNetworkDespawn() { NetworkVariable<int> obj = ragePhase; obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnRagePhaseChanged)); if (pursuitRoutine != null) { ((MonoBehaviour)this).StopCoroutine(pursuitRoutine); } if (horrorTransformServer != null) { ((MonoBehaviour)this).StopCoroutine(horrorTransformServer); } if (horrorTransformVisual != null) { ((MonoBehaviour)this).StopCoroutine(horrorTransformVisual); } RestoreOriginalVisualPose(); if ((Object)(object)web != (Object)null) { Object.Destroy((Object)(object)((Component)web).gameObject); } ((NetworkBehaviour)this).OnNetworkDespawn(); } private IEnumerator EnsureWebAfterNetworkSpawn() { yield return null; if (ragePhase.Value == 3) { yield break; } try { EnsureWeb(); } catch (Exception ex) { MuffetPlugin.Log.LogError((object)("[Muffet] OnNetworkSpawn web failure: " + ex)); } } private static Sprite FindVanillaHandIcon() { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown if ((Object)(object)cachedHandIcon != (Object)null) { return cachedHandIcon; } try { InteractTrigger[] array = Resources.FindObjectsOfTypeAll<InteractTrigger>(); foreach (InteractTrigger val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.hoverIcon == (Object)null)) { string name = ((Object)val.hoverIcon).name; if (name.IndexOf("Hand", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("Ladder", StringComparison.OrdinalIgnoreCase) < 0) { cachedHandIcon = val.hoverIcon; return cachedHandIcon; } } } Sprite[] array2 = Resources.FindObjectsOfTypeAll<Sprite>(); foreach (Sprite val2 in array2) { if ((Object)(object)val2 != (Object)null && (((Object)val2).name == "HandIcon" || ((Object)val2).name == "HandIconPoint")) { cachedHandIcon = val2; return cachedHandIcon; } } array = Resources.FindObjectsOfTypeAll<InteractTrigger>(); foreach (InteractTrigger val3 in array) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.hoverIcon != (Object)null) { cachedHandIcon = val3.hoverIcon; return cachedHandIcon; } } } catch (Exception ex) { MuffetPlugin.Log.LogWarning((object)("[MuffetHover71] Icon search failed: " + ex.Message)); } Texture2D val4 = new Texture2D(1, 1, (TextureFormat)4, false); val4.SetPixel(0, 0, new Color(0f, 0f, 0f, 0f)); val4.Apply(); cachedHandIcon = Sprite.Create(val4, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); ((Object)cachedHandIcon).name = "Muffet_TransparentHoverIcon"; return cachedHandIcon; } private static Sprite TransparentHoverIcon() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown if ((Object)(object)transparentHoverIcon != (Object)null) { return transparentHoverIcon; } Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, new Color(0f, 0f, 0f, 0f)); val.Apply(); transparentHoverIcon = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); ((Object)transparentHoverIcon).name = "Muffet_TransparentHoverIcon"; return transparentHoverIcon; } internal MuffetWebDialogue.Mood? EntryDialogueMood() { if (!((NetworkBehaviour)this).IsSpawned) { return MuffetWebDialogue.Mood.Normal; } int value = ragePhase.Value; if (value >= 2) { return null; } if (value == 1) { return MuffetWebDialogue.Mood.Angry; } if (valuableDonations >= 2) { return MuffetWebDialogue.Mood.Paid; } if (valuableDonations == 1) { return MuffetWebDialogue.Mood.HalfPaid; } return MuffetWebDialogue.Mood.Normal; } internal static MuffetEnemyAI NearestTo(Vector3 position) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) MuffetEnemyAI result = null; float num = float.MaxValue; MuffetEnemyAI[] array = Object.FindObjectsOfType<MuffetEnemyAI>(); foreach (MuffetEnemyAI muffetEnemyAI in array) { if (!((Object)(object)muffetEnemyAI == (Object)null) && ((NetworkBehaviour)muffetEnemyAI).IsSpawned) { Vector3 val = ((Component)muffetEnemyAI).transform.position - position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = muffetEnemyAI; } } } return result; } internal static bool HasBodyYaw(float yaw) { return yaw > -999f; } internal void ApplyBodyYaw(float yaw) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = ((Component)this).transform.eulerAngles; ((Component)this).transform.rotation = Quaternion.Euler(eulerAngles.x, yaw, eulerAngles.z); if (webRotationSaved && (Object)(object)web != (Object)null && (Object)(object)((Component)web).transform.parent == (Object)(object)((Component)this).transform) { ((Component)web).transform.rotation = webWorldRotation; } } internal void ServerPublishBodyYaw(float yaw) { if (((NetworkBehaviour)this).IsServer) { yaw = Mathf.Repeat(yaw, 360f); if (!HasBodyYaw(bodyYaw.Value) || Mathf.Abs(Mathf.DeltaAngle(bodyYaw.Value, yaw)) >= 1.5f) { bodyYaw.Value = yaw; } } } private void FaceOpenSpaceOnSpawn() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0058: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) try { float[] array = new float[16]; Vector3 val = ((Component)this).transform.position + Vector3.up * 1.2f; for (int i = 0; i < 16; i++) { Vector3 val2 = Quaternion.Euler(0f, (float)i * 360f / 16f, 0f) * Vector3.forward; array[i] = 15f; RaycastHit[] array2 = Physics.RaycastAll(val, val2, 15f, -5, (QueryTriggerInteraction)1); for (int j = 0; j < array2.Length; j++) { RaycastHit val3 = array2[j]; Collider collider = ((RaycastHit)(ref val3)).collider; if (!((Object)(object)collider == (Object)null) && !((Component)collider).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)collider).GetComponentInParent<PlayerControllerB>() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent<GrabbableObject>() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent<EnemyAI>() != (Object)null)) { array[i] = Mathf.Min(array[i], ((RaycastHit)(ref val3)).distance); } } } int num = 0; float num2 = -1f; for (int k = 0; k < 16; k++) { float num3 = array[k] * 2f + array[(k + 1) % 16] + array[(k + 16 - 1) % 16]; if (num3 > num2) { num2 = num3; num = k; } } float y = ((Component)this).transform.eulerAngles.y; int num4 = Mathf.RoundToInt(Mathf.Repeat(y, 360f) / 22.5f) % 16; float yaw = ((array[num4] * 2f + array[(num4 + 1) % 16] + array[(num4 + 16 - 1) % 16] >= num2 * 0.85f) ? y : ((float)num * 360f / 16f)); ApplyBodyYaw(yaw); ServerPublishBodyYaw(yaw); MuffetPlugin.Log.LogInfo((object)("[MuffetTurn71] Spawn facing: front clear " + array[num4].ToString("0.0") + "m -> yaw " + yaw.ToString("0") + " (best open " + array[num].ToString("0.0") + "m)")); } catch (Exception ex) { MuffetPlugin.Log.LogError((object)("[MuffetTurn71] Spawn facing failed: " + ex)); } } private void EnsureFirstEncounterFear() { MuffetFirstEncounterFear muffetFirstEncounterFear = ((Component)this).GetComponent<MuffetFirstEncounterFear>(); if ((Object)(object)muffetFirstEncounterFear == (Object)null) { muffetFirstEncounterFear = ((Component)this).gameObject.AddComponent<MuffetFirstEncounterFear>(); } muffetFirstEncounterFear.Initialise(this); } private void EnsureWeb() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (ragePhase.Value != 3 && !((Object)(object)web != (Object)null)) { GameObject val = new GameObject("Muffet_BunkerSpiderWeb_20m"); if (ragePhase.Value == 2 || ragePhase.Value == 4) { val.transform.position = ((silkOrigin.Value == Vector3.zero) ? ((Component)this).transform.position : silkOrigin.Value); } else { val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = Vector3.zero; webWorldRotation = val.transform.rotation; webRotationSaved = true; } MuffetWeb muffetWeb = val.AddComponent<MuffetWeb>(); muffetWeb.Initialise(MuffetPlugin.WebRadius.Value); web = muffetWeb; } } private IEnumerator SpawnBundledDonutIfUnique() { yield return (object)new WaitForSeconds(0.25f); if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned || (Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) { yield break; } MuffetEnemyAI[] array = Object.FindObjectsOfType<MuffetEnemyAI>(); foreach (MuffetEnemyAI muffetEnemyAI in array) { if (!((Object)(object)muffetEnemyAI == (Object)null) && !((Object)(object)muffetEnemyAI == (Object)(object)this) && !((Object)(object)((NetworkBehaviour)muffetEnemyAI).NetworkObject == (Object)null) && ((NetworkBehaviour)muffetEnemyAI).NetworkObject.IsSpawned && !(Vector3.Distance(((Component)this).transform.position, ((Component)muffetEnemyAI).transform.position) > 2f) && ((NetworkBehaviour)muffetEnemyAI).NetworkObject.NetworkObjectId < ((NetworkBehaviour)this).NetworkObject.NetworkObjectId) { MuffetPlugin.Log.LogWarning((object)("[MuffetModel36] Overlapping Muffet duplicate detected: " + ((NetworkBehaviour)this).NetworkObject.NetworkObjectId + " versus " + ((NetworkBehaviour)muffetEnemyAI).NetworkObject.NetworkObjectId + "; despawning newer actor BEFORE linked donut spawn.")); ((NetworkBehaviour)this).NetworkObject.Despawn(true); yield break; } } yield return SpawnBundledDonutForThisMuffet(); } private unsafe IEnumerator SpawnBundledDonutForThisMuffet() { yield return (object)new WaitForSeconds(0.6f); if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned) { yield break; } if ((Object)(object)MuffetPlugin.DonutItem == (Object)null || (Object)(object)MuffetPlugin.DonutItem.spawnPrefab == (Object)null) { MuffetPlugin.Log.LogError((object)"[Muffet] Bundled Spider Donut prefab missing; cannot spawn linked donut."); yield break; } Vector3 position = ((Component)this).transform.position; Vector3 val = position + ((Component)this).transform.forward * 5f; bool flag = false; try { RoundManager instance = RoundManager.Instance; FieldInfo fieldInfo = (((Object)(object)instance == (Object)null) ? null : AccessTools.Field(((object)instance).GetType(), "insideAINodes")); Array array = ((fieldInfo == null) ? null : (fieldInfo.GetValue(instance) as Array)); if (array != null && array.Length > 0) { List<Vector3> list = new List<Vector3>(); NavMeshHit val5 = default(NavMeshHit); foreach (object item in array) { GameObject val2 = (GameObject)((item is GameObject) ? item : null); Vector3 position2; if (val2 != null) { position2 = val2.transform.position; } else { Transform val3 = (Transform)((item is Transform) ? item : null); if (val3 != null) { position2 = val3.position; } else { Component val4 = (Component)((item is Component) ? item : null); if (val4 == null) { continue; } position2 = val4.transform.position; } } float num = Vector3.Distance(position2, position); if (!(num < 4.5f) && !(num > 110f) && NavMesh.SamplePosition(position2, ref val5, 2.5f, -1)) { list.Add(((NavMeshHit)(ref val5)).position); } } if (list.Count > 0) { val = list[Random.Range(0, list.Count)]; flag = true; } } } catch (Exception ex) { MuffetPlugin.Log.LogWarning((object)("[Muffet] Indoor spawn node lookup failed: " + ex.Message)); } Vector3 val8; if (!flag) { NavMeshHit val7 = default(NavMeshHit); for (int i = 0; i < 24; i++) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val6 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(4f, 10f); if (NavMesh.SamplePosition(position + new Vector3(val6.x, 0f, val6.y), ref val7, 3f, -1)) { val8 = ((NavMeshHit)(ref val7)).position - position; if (!(((Vector3)(ref val8)).sqrMagnitude < 12.25f)) { val = ((NavMeshHit)(ref val7)).position; flag = true; break; } } } } if (!flag) { MuffetPlugin.Log.LogWarning((object)"[Muffet] No valid indoor NavMesh for linked Spider Donut; one was not spawned."); yield break; } GameObject val9 = null; try { val9 = Object.Instantiate<GameObject>(MuffetPlugin.DonutItem.spawnPrefab, val + Vector3.up * 0.25f, Quaternion.identity); MuffetScrapVisibility63.NormalizeInstance(val9, "donut-instance"); val9.SetActive(true); GrabbableObject component = val9.GetComponent<GrabbableObject>(); NetworkObject component2 = val9.GetComponent<NetworkObject>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { throw new InvalidOperationException("Spider Donut instance lacks PhysicsProp or NetworkObject."); } component.itemProperties = MuffetPlugin.DonutItem; component.grabbable = true; component.isInFactory = true; component.SetScrapValue(50); component2.Spawn(true); ManualLogSource log = MuffetPlugin.Log; string[] obj = new string[16] { "[MuffetDonut] Spawned pickup at ", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; val8 = val; obj[1] = ((object)(*(Vector3*)(&val8))/*cast due to .constrained prefix*/).ToString(); obj[2] = "; network="; obj[3] = component2.IsSpawned.ToString(); obj[4] = "; grabbable="; obj[5] = component.grabbable.ToString(); obj[6] = "; isInFactory="; obj[7] = component.isInFactory.ToString(); obj[8] = "; propsLayer="; obj[9] = val9.layer.ToString(); obj[10] = "; collider="; obj[11] = ((Object)(object)val9.GetComponent<Collider>() != (Object)null).ToString(); obj[12] = "; item="; obj[13] = (((Object)(object)component.itemProperties != (Object)null) ? component.itemProperties.itemName : "NULL"); obj[14
plugins/NapstablookMonster/NapstablookMonster.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
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.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NapstablookMonster")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NapstablookMonster")] [assembly: AssemblyTitle("NapstablookMonster")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 NapstablookMonster { internal sealed class GlbScene { internal class Reader { public readonly JObject Json; private readonly byte[] _bytes; private readonly int _binary; public Reader(JObject json, byte[] b, int bin) { Json = json; _bytes = b; _binary = bin; } public float[] FloatJson(JToken arr) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (arr == null) { return new float[0]; } float[] array = new float[((JContainer)(JArray)arr).Count]; for (int i = 0; i < array.Length; i++) { array[i] = (float)arr[(object)i]; } return array; } public Vector3 Vec3Json(JToken t, bool coord) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) float[] array = FloatJson(t); return new Vector3(array[0], array[1], coord ? (0f - array[2]) : array[2]); } public Quaternion QuaternionJson(JToken t) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) float[] array = FloatJson(t); return new Quaternion(0f - array[0], 0f - array[1], array[2], array[3]); } public byte[] BufferViewBytes(int idx) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown JObject val = (JObject)((JArray)Json["bufferViews"])[idx]; int srcOffset = _binary + ((int?)val["byteOffset"]).GetValueOrDefault(); int num = (int)val["byteLength"]; byte[] array = new byte[num]; Buffer.BlockCopy(_bytes, srcOffset, array, 0, num); return array; } private void Accessor(int idx, out int start, out int stride, out int len, out int component, out int count, out int n) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown JObject val = (JObject)((JArray)Json["accessors"])[idx]; JObject val2 = (JObject)((JArray)Json["bufferViews"])[(int)val["bufferView"]]; component = (int)val["componentType"]; count = (int)val["count"]; n = (string)val["type"] switch { "MAT4" => 16, "VEC4" => 4, "VEC3" => 3, "VEC2" => 2, "SCALAR" => 1, _ => 1, }; int num = ((component == 5126 || component == 5125) ? 4 : ((component != 5123 && component != 5122) ? 1 : 2)); stride = ((int?)val2["byteStride"]) ?? (n * num); len = count * n; start = _binary + ((int?)val2["byteOffset"]).GetValueOrDefault() + ((int?)val["byteOffset"]).GetValueOrDefault(); } public float[] Floats(int idx) { Accessor(idx, out var start, out var stride, out var len, out var component, out var count, out var n); float[] array = new float[len]; for (int i = 0; i < count; i++) { for (int j = 0; j < n; j++) { int num = start + i * stride; int num2 = j; int num3; switch (component) { default: num3 = 1; break; case 5122: case 5123: num3 = 2; break; case 5125: case 5126: num3 = 4; break; } int num4 = num + num2 * num3; array[i * n + j] = ((component == 5126) ? BitConverter.ToSingle(_bytes, num4) : ((component == 5123) ? ((float)(int)BitConverter.ToUInt16(_bytes, num4)) : ((component == 5125) ? ((float)BitConverter.ToUInt32(_bytes, num4)) : ((float)(component switch { 5122 => BitConverter.ToInt16(_bytes, num4), 5121 => _bytes[num4], _ => 0, }))))); } } return array; } public int[] Indices(int idx) { float[] array = Floats(idx); int[] array2 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = (int)array[i]; } return array2; } public Vector3[] Vectors3(int idx, bool flipZ) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) float[] array = Floats(idx); Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length / 3]; for (int i = 0; i < array2.Length; i++) { array2[i] = new Vector3(array[i * 3], array[i * 3 + 1], flipZ ? (0f - array[i * 3 + 2]) : array[i * 3 + 2]); } return array2; } public Vector2[] Vectors2(int idx) { //IL_002b: 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) float[] array = Floats(idx); Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = new Vector2(array[i * 2], 1f - array[i * 2 + 1]); } return array2; } public Matrix4x4[] BindPoses(int idx) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) float[] array = Floats(idx); Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[array.Length / 16]; for (int i = 0; i < array2.Length; i++) { Matrix4x4 identity = Matrix4x4.identity; for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { ((Matrix4x4)(ref identity))[k, j] = array[i * 16 + j * 4 + k] * ((k == 2) ? (-1f) : 1f) * ((j == 2) ? (-1f) : 1f); } } array2[i] = identity; } return array2; } } public GameObject Root; public Transform[] Nodes; public Dictionary<string, GlbClip> Clips = new Dictionary<string, GlbClip>(); public Renderer[] Renderers; private List<Renderer> _renderers = new List<Renderer>(); private List<Renderer> _glints = new List<Renderer>(); private Material[][] _baseMats; private bool _isPuddle; public static GlbScene Open(string path, bool isPuddle = false) { byte[] array = File.ReadAllBytes(path); if (array.Length < 20 || BitConverter.ToUInt32(array, 0) != 1179937895 || BitConverter.ToUInt32(array, 4) != 2) { throw new InvalidDataException("GLB 2.0 required: " + path); } int num = BitConverter.ToInt32(array, 12); int num2 = 20; int num3 = num2 + (num + 3) / 4 * 4; if (num3 + 8 > array.Length || BitConverter.ToUInt32(array, num3 + 4) != 5130562) { throw new InvalidDataException("GLB binary chunk missing"); } JObject json = JObject.Parse(Encoding.UTF8.GetString(array, num2, num).TrimEnd('\0', ' ')); GlbScene glbScene = new GlbScene(); glbScene._isPuddle = isPuddle; Reader r = new Reader(json, array, num3 + 8); glbScene.Build(r); return glbScene; } private void Build(Reader r) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00d0: 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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Expected O, but got Unknown //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Expected O, but got Unknown //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Expected O, but got Unknown //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Expected O, but got Unknown //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Expected O, but got Unknown //IL_069b: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Expected O, but got Unknown //IL_072f: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) JArray val = (JArray)r.Json["nodes"]; Nodes = (Transform[])(object)new Transform[((JContainer)val).Count]; Root = new GameObject(_isPuddle ? "Napstablook_Water_GLTF" : "Napstablook_Character_GLTF"); Root.SetActive(false); Vector3 localPosition = default(Vector3); Vector3 val4 = default(Vector3); Vector3 val5 = default(Vector3); Vector3 val6 = default(Vector3); Vector3 val7 = default(Vector3); for (int i = 0; i < ((JContainer)val).Count; i++) { JObject val2 = (JObject)val[i]; GameObject val3 = new GameObject(((string)val2["name"]) ?? ("node_" + i)); Nodes[i] = val3.transform; if (val2["matrix"] is JArray) { float[] array = r.FloatJson(val2["matrix"]); Matrix4x4 identity = Matrix4x4.identity; for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { ((Matrix4x4)(ref identity))[k, j] = array[j * 4 + k] * (((k == 2) ? (-1f) : 1f) * ((j == 2) ? (-1f) : 1f)); } } ((Vector3)(ref localPosition))..ctor(identity.m03, identity.m13, identity.m23); ((Vector3)(ref val4))..ctor(identity.m00, identity.m10, identity.m20); ((Vector3)(ref val5))..ctor(identity.m01, identity.m11, identity.m21); ((Vector3)(ref val6))..ctor(identity.m02, identity.m12, identity.m22); ((Vector3)(ref val7))..ctor(((Vector3)(ref val4)).magnitude, ((Vector3)(ref val5)).magnitude, ((Vector3)(ref val6)).magnitude); if (val7.x > 1E-06f && val7.y > 1E-06f && val7.z > 1E-06f) { val3.transform.localPosition = localPosition; val3.transform.localRotation = Quaternion.LookRotation(val6 / val7.z, val5 / val7.y); val3.transform.localScale = val7; } } else { val3.transform.localPosition = r.Vec3Json((JToken)(((object)val2["translation"]) ?? ((object)new JArray(new object[3] { 0f, 0f, 0f }))), coord: true); val3.transform.localRotation = r.QuaternionJson((JToken)(((object)val2["rotation"]) ?? ((object)new JArray(new object[4] { 0f, 0f, 0f, 1f })))); val3.transform.localScale = r.Vec3Json((JToken)(((object)val2["scale"]) ?? ((object)new JArray(new object[3] { 1f, 1f, 1f }))), coord: false); } } bool[] array2 = new bool[Nodes.Length]; for (int l = 0; l < ((JContainer)val).Count; l++) { JToken obj = val[l][(object)"children"]; JArray val8 = (JArray)(object)((obj is JArray) ? obj : null); if (val8 == null) { continue; } foreach (JToken item in val8) { int num = (int)item; if (num >= 0 && num < Nodes.Length) { Nodes[num].SetParent(Nodes[l], false); array2[num] = true; } } } for (int m = 0; m < Nodes.Length; m++) { if (!array2[m]) { Nodes[m].SetParent(Root.transform, false); } } Material[] array3 = MakeMaterials(r, _isPuddle); JToken obj2 = r.Json["meshes"]; JArray val9 = (JArray)(object)((obj2 is JArray) ? obj2 : null); JToken obj3 = r.Json["skins"]; JArray val10 = (JArray)(object)((obj3 is JArray) ? obj3 : null); Dictionary<int, Mesh> dictionary = new Dictionary<int, Mesh>(); for (int n = 0; n < ((JContainer)val).Count; n++) { JObject val11 = (JObject)val[n]; if (val11["mesh"] == null) { continue; } string name = ((Object)Nodes[n]).name; if ((!_isPuddle && (name.Contains("Puddle") || name.Contains("Ripple") || name.Contains("Circle") || name.Contains("Unused_SparklePlaceholder"))) || name.Contains("EyeSolidFill") || name.Contains("DISABLED")) { continue; } JArray val12 = (JArray)((JObject)val9[(int)val11["mesh"]])["primitives"]; for (int num2 = 0; num2 < ((JContainer)val12).Count; num2++) { JObject val13 = (JObject)val12[num2]; int key = (int)val11["mesh"] * 1000 + num2; bool flag = val11["skin"] == null; if (!flag || !dictionary.TryGetValue(key, out var value)) { value = MakeMesh(r, val13); if (flag) { dictionary[key] = value; } } GameObject val14 = new GameObject("render_" + num2); val14.transform.SetParent(Nodes[n], false); Material val15 = ((val13["material"] != null && (int)val13["material"] < array3.Length) ? array3[(int)val13["material"]] : NapstaRuntimeMaterials.Make("Napstablook_Default", Color.white, null, transparent: false)); if ((Object)(object)val15 == (Object)null) { NapstablookPlugin.ModLogger.LogWarning((object)("Skipped mesh with no HDRP-supported material: " + name)); continue; } Renderer val18; if (val11["skin"] != null && val10 != null) { JObject val16 = (JObject)val10[(int)val11["skin"]]; JArray val17 = (JArray)val16["joints"]; Transform[] array4 = (Transform[])(object)new Transform[((JContainer)val17).Count]; for (int num3 = 0; num3 < ((JContainer)val17).Count; num3++) { array4[num3] = Nodes[(int)val17[num3]]; } value.bindposes = r.BindPoses((int)val16["inverseBindMatrices"]); SkinnedMeshRenderer obj4 = val14.AddComponent<SkinnedMeshRenderer>(); obj4.sharedMesh = value; obj4.bones = array4; obj4.rootBone = ((array4.Length != 0) ? array4[0] : null); obj4.updateWhenOffscreen = true; ((Renderer)obj4).localBounds = new Bounds(Vector3.zero, Vector3.one * 15f); val18 = (Renderer)(object)obj4; } else { val14.AddComponent<MeshFilter>().sharedMesh = value; val18 = (Renderer)(object)val14.AddComponent<MeshRenderer>(); } val18.sharedMaterial = new Material(val15); val18.shadowCastingMode = (ShadowCastingMode)0; val18.receiveShadows = false; _renderers.Add(val18); if (name.Contains("WanderOnly_Glint") || name.Contains("Sparkle")) { _glints.Add(val18); } } } Renderers = _renderers.ToArray(); _baseMats = new Material[Renderers.Length][]; for (int num4 = 0; num4 < Renderers.Length; num4++) { _baseMats[num4] = Renderers[num4].materials; } ReadClips(r); Root.SetActive(true); } public void SetMoodVisual(int state, float fade) { if (_isPuddle) { return; } bool flag = state == 0; float alpha = ((flag || state == 6) ? Mathf.Clamp01(0.54f * fade) : Mathf.Clamp01(fade)); for (int i = 0; i < Renderers.Length; i++) { Renderer val = Renderers[i]; if ((Object)(object)val == (Object)null) { continue; } bool flag2 = _glints.Contains(val); val.enabled = (!flag2 || flag) && fade > 0.005f; if (flag2) { continue; } for (int j = 0; j < _baseMats[i].Length; j++) { Material val2 = _baseMats[i][j]; if (!((Object)(object)val2 == (Object)null)) { NapstaRuntimeMaterials.SetOpacity(val2, alpha); } } } } internal bool TryGetNativeStarTemplate(out Mesh mesh, out Material material) { mesh = null; material = null; foreach (Renderer glint in _glints) { if (!((Object)(object)glint == (Object)null)) { MeshFilter component = ((Component)glint).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && !((Object)(object)glint.sharedMaterial == (Object)null)) { mesh = component.sharedMesh; material = glint.sharedMaterial; return true; } } } return false; } public void Dispose() { if ((Object)(object)Root != (Object)null) { Object.Destroy((Object)(object)Root); } } public void Animate(string name, float time, bool loop) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) if (!Clips.TryGetValue(name, out var value)) { return; } float num = ((loop && value.Duration > 0.001f) ? (time % value.Duration) : Mathf.Clamp(time, 0f, value.Duration)); Vector3 localPosition = default(Vector3); Quaternion val = default(Quaternion); Quaternion val2 = default(Quaternion); for (int i = 0; i < value.Channels.Count; i++) { GlbTrack glbTrack = value.Channels[i]; if (glbTrack.Node >= 0 && glbTrack.Node < Nodes.Length) { int num2 = glbTrack.Locate(num); int num3 = Mathf.Min(num2 + 1, glbTrack.Times.Length - 1); float num4 = glbTrack.Times[num3] - glbTrack.Times[num2]; float num5 = ((num4 < 1E-05f) ? 0f : Mathf.Clamp01((num - glbTrack.Times[num2]) / num4)); int arity = glbTrack.Arity; int num6 = num2 * arity; int num7 = num3 * arity; if (glbTrack.Path == "translation") { ((Vector3)(ref localPosition))..ctor(Mathf.Lerp(glbTrack.Values[num6], glbTrack.Values[num7], num5), Mathf.Lerp(glbTrack.Values[num6 + 1], glbTrack.Values[num7 + 1], num5), 0f - Mathf.Lerp(glbTrack.Values[num6 + 2], glbTrack.Values[num7 + 2], num5)); Nodes[glbTrack.Node].localPosition = localPosition; } else if (glbTrack.Path == "scale") { Nodes[glbTrack.Node].localScale = new Vector3(Mathf.Lerp(glbTrack.Values[num6], glbTrack.Values[num7], num5), Mathf.Lerp(glbTrack.Values[num6 + 1], glbTrack.Values[num7 + 1], num5), Mathf.Lerp(glbTrack.Values[num6 + 2], glbTrack.Values[num7 + 2], num5)); } else if (glbTrack.Path == "rotation") { ((Quaternion)(ref val))..ctor(0f - glbTrack.Values[num6], 0f - glbTrack.Values[num6 + 1], glbTrack.Values[num6 + 2], glbTrack.Values[num6 + 3]); ((Quaternion)(ref val2))..ctor(0f - glbTrack.Values[num7], 0f - glbTrack.Values[num7 + 1], glbTrack.Values[num7 + 2], glbTrack.Values[num7 + 3]); Nodes[glbTrack.Node].localRotation = Quaternion.Slerp(val, val2, num5); } } } } private void ReadClips(Reader r) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0074: 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_0093: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown JToken obj = r.Json["animations"]; JArray val = (JArray)(object)((obj is JArray) ? obj : null); if (val == null) { return; } foreach (JObject item in val) { JObject val2 = item; GlbClip glbClip = new GlbClip { Name = (((string)val2["name"]) ?? "Unnamed") }; JArray val3 = (JArray)val2["samplers"]; foreach (JObject item2 in (JArray)val2["channels"]) { JObject val4 = item2; JObject val5 = (JObject)val3[(int)val4["sampler"]]; string text = (string)val4["target"][(object)"path"]; if (text != "translation" && text != "scale" && text != "rotation") { continue; } float[] array = r.Floats((int)val5["input"]); if (array.Length != 0) { GlbTrack glbTrack = new GlbTrack { Node = (int)val4["target"][(object)"node"], Path = text, Times = array, Values = r.Floats((int)val5["output"]), Arity = ((text == "rotation") ? 4 : 3) }; if (glbTrack.Values.Length >= glbTrack.Times.Length * glbTrack.Arity) { glbClip.Duration = Mathf.Max(glbClip.Duration, array[^1]); glbClip.Channels.Add(glbTrack); } } } Clips[glbClip.Name] = glbClip; } } private static Material[] MakeMaterials(Reader r, bool isPuddle) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown JToken obj = r.Json["materials"]; JArray val = (JArray)(object)((obj is JArray) ? obj : null); Material[] array = (Material[])(object)new Material[(val != null) ? ((JContainer)val).Count : 0]; JToken obj2 = r.Json["textures"]; JArray val2 = (JArray)(object)((obj2 is JArray) ? obj2 : null); JToken obj3 = r.Json["images"]; JArray val3 = (JArray)(object)((obj3 is JArray) ? obj3 : null); Dictionary<int, Texture2D> dictionary = new Dictionary<int, Texture2D>(); for (int i = 0; i < array.Length; i++) { JObject val4 = (JObject)val[i]; JToken obj4 = val4["pbrMetallicRoughness"]; JObject val5 = (JObject)(object)((obj4 is JObject) ? obj4 : null); JToken obj5 = ((val5 != null) ? val5["baseColorFactor"] : null); JArray val6 = (JArray)(object)((obj5 is JArray) ? obj5 : null); Color color = (Color)((val6 == null) ? Color.white : new Color((float)val6[0], (float)val6[1], (float)val6[2], (float)val6[3])); bool transparent = !isPuddle || (string)val4["alphaMode"] == "BLEND"; string text = ((string)val4["name"]) ?? ("glb_mat_" + i); JToken obj6 = val4["extensions"]; bool num = ((obj6 != null) ? obj6[(object)"KHR_materials_unlit"] : null) != null; bool flag = text.Contains("Cloth"); float num2 = ((((val5 != null) ? val5["roughnessFactor"] : null) != null) ? ((float)val5["roughnessFactor"]) : 1f); JToken obj7 = val4["emissiveFactor"]; JArray val7 = (JArray)(object)((obj7 is JArray) ? obj7 : null); Color emissive = (Color)((val7 == null) ? Color.black : new Color((float)val7[0], (float)val7[1], (float)val7[2], 1f)); float num3 = ((NapstablookPlugin.GhostGlow == null) ? 0.18f : Mathf.Clamp01(NapstablookPlugin.GhostGlow.Value)); Material val8 = ((!num) ? NapstaRuntimeMaterials.MakeLit(text, color, null, transparent, 1f - num2, isPuddle ? 0f : (flag ? num3 : (num3 * 0.5f)), emissive, (!isPuddle) ? (flag ? (-10) : 10) : 0, flag) : NapstaRuntimeMaterials.Make(text, color, null, transparent)); if ((Object)(object)val8 == (Object)null) { continue; } object obj8; if (val5 == null) { obj8 = null; } else { JToken obj9 = val5["baseColorTexture"]; obj8 = ((obj9 != null) ? obj9[(object)"index"] : null); } JToken val9 = (JToken)obj8; if (val9 != null && val2 != null && val3 != null) { int num4 = (int)val2[(int)val9][(object)"source"]; if (!dictionary.TryGetValue(num4, out var value)) { JObject val10 = (JObject)val3[num4]; if (val10["bufferView"] != null) { byte[] array2 = r.BufferViewBytes((int)val10["bufferView"]); value = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(value, array2, false)) { Object.Destroy((Object)(object)value); } else { ((Texture)value).wrapMode = (TextureWrapMode)0; ((Texture)value).filterMode = (FilterMode)1; dictionary[num4] = value; } } } if ((Object)(object)value != (Object)null) { if (val8.HasProperty("_BaseColorMap")) { val8.SetTexture("_BaseColorMap", (Texture)(object)value); } if (val8.HasProperty("_UnlitColorMap")) { val8.SetTexture("_UnlitColorMap", (Texture)(object)value); } if (val8.HasProperty("_MainTex")) { val8.SetTexture("_MainTex", (Texture)(object)value); } } } array[i] = val8; } return array; } private static Mesh MakeMesh(Reader r, JObject p) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0079: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) JObject val = (JObject)p["attributes"]; int num = Extensions.Value<int>((IEnumerable<JToken>)((JObject)((JArray)r.Json["accessors"])[(int)val["POSITION"]])["count"]); Vector3[] vertices = r.Vectors3((int)val["POSITION"], flipZ: true); Mesh val2 = new Mesh { name = "GLB_NapstablookMesh" }; if (num > 65535) { val2.indexFormat = (IndexFormat)1; } val2.vertices = vertices; if (val["NORMAL"] != null) { val2.normals = r.Vectors3((int)val["NORMAL"], flipZ: true); } if (val["TEXCOORD_0"] != null) { val2.uv = r.Vectors2((int)val["TEXCOORD_0"]); } if (val["JOINTS_0"] != null && val["WEIGHTS_0"] != null) { float[] array = r.Floats((int)val["JOINTS_0"]); float[] array2 = r.Floats((int)val["WEIGHTS_0"]); BoneWeight[] array3 = (BoneWeight[])(object)new BoneWeight[num]; for (int i = 0; i < num; i++) { int num2 = i * 4; float num3 = array2[num2] + array2[num2 + 1] + array2[num2 + 2] + array2[num2 + 3]; if (num3 < 1E-06f) { num3 = 1f; } int num4 = i; BoneWeight val3 = default(BoneWeight); ((BoneWeight)(ref val3)).boneIndex0 = (int)array[num2]; ((BoneWeight)(ref val3)).boneIndex1 = (int)array[num2 + 1]; ((BoneWeight)(ref val3)).boneIndex2 = (int)array[num2 + 2]; ((BoneWeight)(ref val3)).boneIndex3 = (int)array[num2 + 3]; ((BoneWeight)(ref val3)).weight0 = array2[num2] / num3; ((BoneWeight)(ref val3)).weight1 = array2[num2 + 1] / num3; ((BoneWeight)(ref val3)).weight2 = array2[num2 + 2] / num3; ((BoneWeight)(ref val3)).weight3 = array2[num2 + 3] / num3; array3[num4] = val3; } val2.boneWeights = array3; } int[] array4 = r.Indices((int)p["indices"]); for (int j = 0; j + 2 < array4.Length; j += 3) { int num5 = array4[j + 1]; array4[j + 1] = array4[j + 2]; array4[j + 2] = num5; } val2.triangles = array4; if (val["NORMAL"] == null) { val2.RecalculateNormals(); } val2.RecalculateBounds(); return val2; } } internal sealed class GlbClip { public string Name; public float Duration; public readonly List<GlbTrack> Channels = new List<GlbTrack>(); } internal sealed class GlbTrack { public int Node; public int Arity; public string Path; public float[] Times; public float[] Values; public int Locate(float t) { int num = 0; int num2 = Times.Length - 1; while (num < num2) { int num3 = (num + num2 + 1) / 2; if (Times[num3] <= t) { num = num3; } else { num2 = num3 - 1; } } return num; } } [BepInPlugin("hihi__h.NapstablookMonster", "Napstablook Monster", "1.9.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class NapstablookPlugin : BaseUnityPlugin { internal static NapstablookPlugin Instance; internal static ManualLogSource ModLogger; internal static ConfigEntry<float> MoodGain; internal static ConfigEntry<float> NearbyMoodGain; internal static ConfigEntry<float> PlayerMoodRadius; internal static ConfigEntry<float> MusicReduction; internal static ConfigEntry<float> MusicRange; internal static ConfigEntry<float> WaterMultiplier; internal static ConfigEntry<float> PuddleSize; internal static ConfigEntry<int> MaxPuddles; internal static ConfigEntry<bool> EnableNaturalSpawn; internal static ConfigEntry<bool> EnableDebugHotkeys; internal static ConfigEntry<int> LandingSpawnChancePercent; internal static ConfigEntry<bool> LitShading; internal static ConfigEntry<float> GhostGlow; internal static ConfigEntry<string> Language; internal static EnemyType DevEnemyType; internal static string Folder; private Harmony harmony; internal static bool IsKorean { get { if (Language != null) { return !string.Equals(Language.Value, "English", StringComparison.OrdinalIgnoreCase); } return true; } } internal static string ScanName { get { if (!IsKorean) { return "Napstablook"; } return "냅스타블룩"; } } internal static string ScanDescription { get { if (!IsKorean) { return "Likes music."; } return "음악을 좋아합니다."; } } private void Awake() { //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown Instance = this; ModLogger = ((BaseUnityPlugin)this).Logger; Folder = ResolveAssetFolder(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); if (File.Exists(Path.Combine(Folder, "Napstablook_Animated.glb"))) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[NAP ASSETS20] Character model and sounds directory: " + Folder)); } else { ((BaseUnityPlugin)this).Logger.LogError((object)("[NAP ASSETS20] Napstablook_Animated.glb missing. Copy assets folder beside DLL or use READY_TO_INSTALL folder. Searched from: " + ((BaseUnityPlugin)this).Info.Location)); } MoodGain = ((BaseUnityPlugin)this).Config.Bind<float>("Mood", "BaselineGainPerSecond", 0.35f, "Sadness gain per second when wandering alone."); NearbyMoodGain = ((BaseUnityPlugin)this).Config.Bind<float>("Mood", "NearbyPlayerExtraPerSecond", 1.5f, "Extra sadness per second if a living player is nearby."); PlayerMoodRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Mood", "NearbyPlayerRadius", 8f, "Radius in metres for player-induced sadness."); MusicReduction = ((BaseUnityPlugin)this).Config.Bind<float>("Mood", "BoomboxRecoveryPerSecond", 14f, "Sadness decrease per second while nearby music plays."); MusicRange = ((BaseUnityPlugin)this).Config.Bind<float>("Mood", "BoomboxRadius", 9f, "Effective boombox music radius in metres."); WaterMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "SpeedMultiplier", 0.55f, "Player speed multiplier while standing in tears (0.55 = 45% slower)."); PuddleSize = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "PuddleScale", 1f, "Original uploaded GLB world scale (1.0 = original dimensions)."); MaxPuddles = ((BaseUnityPlugin)this).Config.Bind<int>("Water", "MaxActivePuddles", 20, "At limit, replace the oldest puddle (FIFO); clear everything on takeoff."); EnableNaturalSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "EnableNaturalSpawn", true, "Allow one natural Napstablook roll when the ship lands. DEV/F8 always remains available."); LandingSpawnChancePercent = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "LandingChancePercent", 15, "Percent chance (0-100) per ship landing. Exactly one roll each landing, all moons. Maximum one active Napstablook."); EnableDebugHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "DebugMoodKeys", false, "Host-only DEV testing: F6 mood +25, F7 mood -25, F8 spawn next to host."); LitShading = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "LitShading", true, "true = Napstablook, tears and puddles react to light (3D shading, glossy water). false = old flat unlit look."); GhostGlow = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "GhostGlow", 0.18f, "Faint self-glow so the ghost stays visible in dark rooms (0 = none, 1 = fully bright). Only used with LitShading."); Language = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "Korean", "Scan text language: Korean (냅스타블룩 / 음악을 좋아합니다.) or English (Napstablook / Likes music.)."); RegisterDevEnemy(); harmony = new Harmony("hihi__h.NapstablookMonster"); harmony.PatchAll(); MethodInfo methodInfo = AccessTools.Method(typeof(QuickMenuManager), "Debug_SetEnemyDropdownOptions", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(NapstablookDevDropdownPatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"DEV dropdown method absent; relying on LethalLib's list insertion."); } NapstablookDevRuntime18.EnsureWorld(); NapstablookDevRuntime18.Install(harmony); ((BaseUnityPlugin)this).Logger.LogInfo((object)("NAPSTABLOOK 1.9.7 loaded: lit shading=" + LitShading.Value + ", scan=" + ScanName + ", DevMode bridge, F8 manual spawn, 15% landing roll.")); } private static string ResolveAssetFolder(string dllDirectory) { string text = dllDirectory; for (int i = 0; i < 9; i++) { if (string.IsNullOrEmpty(text)) { break; } if (File.Exists(Path.Combine(text, "Napstablook_Animated.glb"))) { return text; } string text2 = Path.Combine(text, "assets"); if (File.Exists(Path.Combine(text2, "Napstablook_Animated.glb"))) { return text2; } string directoryName = Path.GetDirectoryName(text); if (string.IsNullOrEmpty(directoryName) || directoryName == text) { break; } text = directoryName; } return dllDirectory ?? string.Empty; } private void RegisterDevEnemy() { try { GameObject val = NetworkPrefabs.CreateNetworkPrefab("hihi__h_Napstablook_DEV_v03"); val.layer = 0; NavMeshAgent val2 = val.AddComponent<NavMeshAgent>(); val2.radius = 0.15f; val2.height = 1.5f; val2.speed = 0f; val2.obstacleAvoidanceType = (ObstacleAvoidanceType)0; Animator creatureAnimator = val.AddComponent<Animator>(); AudioSource creatureSFX = val.AddComponent<AudioSource>(); AudioSource creatureVoice = val.AddComponent<AudioSource>(); NapstablookDevEnemy napstablookDevEnemy = val.AddComponent<NapstablookDevEnemy>(); ((EnemyAI)napstablookDevEnemy).agent = val2; ((EnemyAI)napstablookDevEnemy).creatureAnimator = creatureAnimator; ((EnemyAI)napstablookDevEnemy).creatureSFX = creatureSFX; ((EnemyAI)napstablookDevEnemy).creatureVoice = creatureVoice; ((EnemyAI)napstablookDevEnemy).enemyHP = int.MaxValue; DevEnemyType = ScriptableObject.CreateInstance<EnemyType>(); ((Object)DevEnemyType).name = "Napstablook_DEV_Type"; DevEnemyType.enemyName = "Napstablook"; DevEnemyType.enemyPrefab = val; ((EnemyAI)napstablookDevEnemy).enemyType = DevEnemyType; SetOptionalField(DevEnemyType, "maxCount", 1); SetOptionalField(DevEnemyType, "PowerLevel", 0f); SetOptionalField(DevEnemyType, "powerLevel", 0f); SetOptionalField(DevEnemyType, "isOutsideEnemy", false); Enemies.RegisterEnemy(DevEnemyType, 0, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"NAPSTABLOOK DEV enemy registered: Napstablook / rarity 0; checking dropdown categories separately."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("DEV EnemyType registration failed: " + ex)); } } private static void SetOptionalField(object target, string field, object value) { try { FieldInfo field2 = target.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(target, Convert.ChangeType(value, field2.FieldType)); } } catch { } } private void OnApplicationQuit() { if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(StartOfRound), "LateUpdate")] internal static class NapstablookPersistentFrame16 { [HarmonyPostfix] private static void Postfix() { NapstablookDevRuntime18.Tick(); } } internal static class NapstablookDevRuntime18 { private static float nextListProbe; private static float nextWorldRetry; private static bool startupReport; internal static void EnsureWorld() { //IL_002f: 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_003a: Expected O, but got Unknown if ((Object)(object)NapstablookWorld.Active != (Object)null || Time.unscaledTime < nextWorldRetry) { return; } nextWorldRetry = Time.unscaledTime + 2f; try { GameObject val = new GameObject("Napstablook_PersistentWorld_v18"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<NapstablookWorld>(); ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)"[NAP DEV18] World runtime constructed/recovered."); } } catch (Exception ex) { ManualLogSource modLogger2 = NapstablookPlugin.ModLogger; if (modLogger2 != null) { modLogger2.LogError((object)("[NAP DEV18] World runtime recovery failed: " + ex)); } } } internal static void Tick() { EnsureWorld(); NapstablookWorld.Active?.NativeTick(); if (Time.unscaledTime < nextListProbe) { return; } nextListProbe = Time.unscaledTime + 1.5f; QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if ((Object)(object)val != (Object)null && NapstablookDevDropdownPatch.Ensure(val) && !startupReport) { startupReport = true; ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)"[NAP DEV18] Test room enemy list injected."); } } } internal static void Install(Harmony h) { TryPatch(h, typeof(QuickMenuManager), "Update", "Frame", prefix: false); TryPatch(h, typeof(QuickMenuManager), "Start", "MenuStart", prefix: false); TryPatch(h, typeof(GameNetworkManager), "Update", "Frame", prefix: false); TryPatch(h, typeof(RoundManager), "SpawnEnemyGameObject", "BeforeSpawn", prefix: true); } private static void TryPatch(Harmony h, Type type, string method, string callback, bool prefix) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null); MethodInfo method2 = typeof(NapstablookDevRuntime18).GetMethod(callback, BindingFlags.Static | BindingFlags.NonPublic); if (!(methodInfo == null) && !(method2 == null)) { HarmonyMethod val = new HarmonyMethod(method2); if (prefix) { h.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)("[NAP DEV18] Runtime hook: " + type.Name + "." + method)); } } } catch (Exception ex) { ManualLogSource modLogger2 = NapstablookPlugin.ModLogger; if (modLogger2 != null) { modLogger2.LogWarning((object)("[NAP DEV18] Optional hook unavailable " + type.Name + "." + method + ": " + ex.Message)); } } } private static void Frame() { Tick(); } private static void MenuStart(QuickMenuManager __instance) { EnsureWorld(); if ((Object)(object)__instance != (Object)null) { NapstablookDevDropdownPatch.Ensure(__instance); } Tick(); } private unsafe static void BeforeSpawn(object[] __args) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (__args == null || (Object)(object)NapstablookPlugin.DevEnemyType == (Object)null) { return; } bool flag = false; Vector3 val = Vector3.zero; bool flag2 = false; foreach (object obj in __args) { EnemyType val2 = (EnemyType)((obj is EnemyType) ? obj : null); if (val2 != null && val2 == NapstablookPlugin.DevEnemyType) { flag = true; } if (obj is Vector3 val3) { val = val3; flag2 = true; } } if (!flag) { return; } EnsureWorld(); if (!flag2) { GameNetworkManager instance = GameNetworkManager.Instance; PlayerControllerB val4 = (((Object)(object)instance != (Object)null) ? instance.localPlayerController : null); if ((Object)(object)val4 != (Object)null) { val = ((Component)val4).transform.position + ((Component)val4).transform.forward * 3f; } } ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { Vector3 val5 = val; modLogger.LogInfo((object)("[NAP DEV18] Vanilla test-room spawn request received at " + ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString())); } NapstablookWorld.Active?.SpawnFromDev(val); } } internal static class NapstablookDevDropdownPatch { private static void Prefix(QuickMenuManager __instance) { Ensure(__instance); } internal static bool Ensure(QuickMenuManager menu) { try { if ((Object)(object)NapstablookPlugin.DevEnemyType == (Object)null || (Object)(object)menu == (Object)null || (Object)(object)menu.testAllEnemiesLevel == (Object)null) { return false; } SelectableLevel testAllEnemiesLevel = menu.testAllEnemiesLevel; bool flag = false; flag = Insert(testAllEnemiesLevel.Enemies) || flag; flag = Insert(testAllEnemiesLevel.OutsideEnemies) || flag; flag = Insert(testAllEnemiesLevel.DaytimeEnemies) || flag; if (flag && (Object)(object)NapstablookPlugin.Instance != (Object)null) { NapstablookPlugin.ModLogger.LogInfo((object)"DEV list updated: Napstablook added to indoor / outdoor / daytime groups (where available)."); } return flag; } catch (Exception ex) { if ((Object)(object)NapstablookPlugin.Instance != (Object)null) { NapstablookPlugin.ModLogger.LogWarning((object)("Could not update DEV list: " + ex)); } return false; } } private static bool Insert(List<SpawnableEnemyWithRarity> entries) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (entries == null) { return false; } foreach (SpawnableEnemyWithRarity entry in entries) { if (entry != null && (Object)(object)entry.enemyType == (Object)(object)NapstablookPlugin.DevEnemyType) { return false; } } entries.Add(new SpawnableEnemyWithRarity(NapstablookPlugin.DevEnemyType, 10)); return true; } } internal sealed class NapstablookDevEnemy : EnemyAI { public override void Start() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) try { ((EnemyAI)this).Start(); } catch (Exception ex) { if ((Object)(object)NapstablookPlugin.Instance != (Object)null) { NapstablookPlugin.ModLogger.LogWarning((object)("EnemyAI base Start on runtime prefab: " + ex.Message)); } } ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)("[NAP DEV18] Dummy enemy Start entered; host=" + ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer))); } if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer) { NapstablookDevRuntime18.EnsureWorld(); NapstablookWorld.Active?.SpawnFromDev(((Component)this).transform.position); } } public override void Update() { } public override void DoAIInterval() { } public override void OnCollideWithPlayer(Collider other) { } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class SlowdownPatch { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { if ((Object)(object)NapstablookWorld.Active != (Object)null) { NapstablookWorld.Active.ApplySlowdown(__instance); } } } internal static class DevKeyReader { private static bool initialized; private static PropertyInfo current; private static PropertyInfo f6; private static PropertyInfo f7; private static PropertyInfo f8; private static readonly BindingFlags Props = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; private static void Init() { if (initialized) { return; } initialized = true; try { Type type = Type.GetType("UnityEngine.InputSystem.Keyboard, Unity.InputSystem", throwOnError: false); if (type == null) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("UnityEngine.InputSystem.Keyboard", throwOnError: false); if (type != null) { break; } } } if (type == null) { NapstablookPlugin.ModLogger.LogWarning((object)"Unity Input System keyboard unavailable; DEV shortcuts disabled."); return; } current = type.GetProperty("current", Props); f6 = type.GetProperty("f6Key", Props); f7 = type.GetProperty("f7Key", Props); f8 = type.GetProperty("f8Key", Props); if (current == null) { NapstablookPlugin.ModLogger.LogWarning((object)"Keyboard.current unavailable."); } } catch (Exception ex) { NapstablookPlugin.ModLogger.LogWarning((object)("Input System binding failed: " + ex.Message)); } } internal static bool Pressed(string key) { Init(); if (current == null) { return false; } try { object value = current.GetValue(null, null); if (value == null) { return false; } PropertyInfo propertyInfo = key switch { "f8Key" => f8, "f7Key" => f7, "f6Key" => f6, _ => null, }; if (propertyInfo == null) { return false; } object value2 = propertyInfo.GetValue(value, null); if (value2 == null) { return false; } PropertyInfo property = value2.GetType().GetProperty("wasPressedThisFrame", BindingFlags.Instance | BindingFlags.Public); return property != null && (bool)property.GetValue(value2, null); } catch (Exception ex) { NapstablookPlugin.ModLogger.LogWarning((object)("Input System DEV key failed once: " + ex.Message)); current = null; return false; } } } internal enum MoodState { Wander, Falling, Lying, Vanishing, Crying, Recovery, Spawning } internal sealed class PuddleStamp { public int Id; public Vector3 Position; public float Size; public float Born; public float FadeStarted = -1f; public GameObject WaterObject; public int PurificationOrder = -1; public Material[] Materials; public Renderer[] Renderers; } internal sealed class NativeStarPop { public GameObject Object; public Material Material; public Vector3 Start; public float Born; public float Life; public float Size; } internal sealed class EvaporationMote { public GameObject Object; public Material Material; public Vector3 Origin; public float Born; public float Duration; public float Size; } internal sealed class HeartPop { public GameObject Object; public Material Material; public Vector3 Start; public float Born; public float Duration; } internal sealed class NapstablookWorld : MonoBehaviour { public static NapstablookWorld Active; private const string NetState = "hihi__h.napsta.state.2"; private const string NetWater = "hihi__h.napsta.water.2"; private const string NetReset = "hihi__h.napsta.clear.1"; private const string NetPurify = "hihi__h.napsta.purify.1"; private NetworkManager network; private GameObject ghost; private GlbScene model; private GlbScene waterTemplate; private bool puddleLoadFailed; private Mesh heartShape; private Material heartMaterial; private readonly List<HeartPop> hearts = new List<HeartPop>(); private readonly List<NativeStarPop> worldStars = new List<NativeStarPop>(); private float lastStarSpawn; private bool warnedStarTemplate; private float lastHeartSpawn; private bool musicActive; private AudioSource ambientSource; private AudioSource accentSource; private readonly AudioClip[] soundClips = (AudioClip[])(object)new AudioClip[4]; private MoodState previousAudioState = MoodState.Spawning; private float nextHappySound; private bool lastHappyMusic; private float happyMusicTime; private bool purificationActive; private float purificationStarted; private const float PurificationPairInterval = 2.35f; private const float PurificationPairFadeDuration = 2.2f; private float lastEvapMote; private Material evaporationMaterial; private Mesh evaporationMesh; private readonly List<EvaporationMote> evaporationMotes = new List<EvaporationMote>(); private int waterSequence; private readonly List<PuddleStamp> fadingPuddles = new List<PuddleStamp>(); private NavMeshAgent nav; private BoxCollider obstruction; private Mesh lyingColliderBakeMesh; private float nextLyingColliderFit; private Vector3 localTarget; private Vector3 remoteTarget; private float mood; private float phaseTime; private float elapsed; private float lastSend; private float lastWater; private float lastTargetPick; private float remoteYaw; private float remoteMood; private float nextSyncAll; private float nextDevListScan; private MoodState state; private List<PuddleStamp> puddles = new List<PuddleStamp>(); private readonly Dictionary<int, float> speedBefore = new Dictionary<int, float>(); private readonly Dictionary<int, float> appliedSpeed = new Dictionary<int, float>(); private bool landedLast; private bool localSpawned; private bool devSpawned; private bool landingRollCompleted; private bool landingRollSucceeded; private float nextNaturalSpawnAttempt; private float nextNaturalSpawnWarn; private Random random = new Random(38211); private bool tickReported; private int lastFrame = -1; private bool IsHost { get { if ((Object)(object)network != (Object)null) { return network.IsServer; } return false; } } private bool IsInRound { get { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)RoundManager.Instance == (Object)null || instance.shipIsLeaving) { return false; } if (!instance.shipHasLanded || instance.inShipPhase) { return devSpawned; } return true; } } private void Awake() { Active = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void OnDestroy() { ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogWarning((object)"[NAP DEV18] World runtime destroyed; next game/UI frame will recreate it."); } if ((Object)(object)Active == (Object)(object)this) { Active = null; } Unbind(); Clear(); for (int i = 0; i < soundClips.Length; i++) { if ((Object)(object)soundClips[i] != (Object)null) { Object.Destroy((Object)(object)soundClips[i]); } } if ((Object)(object)evaporationMaterial != (Object)null) { Object.Destroy((Object)(object)evaporationMaterial); } if ((Object)(object)evaporationMesh != (Object)null) { Object.Destroy((Object)(object)evaporationMesh); } } private void Unbind() { if (!((Object)(object)network == (Object)null)) { try { network.CustomMessagingManager.UnregisterNamedMessageHandler("hihi__h.napsta.state.2"); } catch { } try { network.CustomMessagingManager.UnregisterNamedMessageHandler("hihi__h.napsta.water.2"); } catch { } try { network.CustomMessagingManager.UnregisterNamedMessageHandler("hihi__h.napsta.clear.1"); } catch { } try { network.CustomMessagingManager.UnregisterNamedMessageHandler("hihi__h.napsta.purify.1"); } catch { } try { network.OnClientConnectedCallback -= ClientConnected; } catch { } network = null; } } private void Bind() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)(object)network) || (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager == null)) { Unbind(); if (!((Object)(object)singleton == (Object)null) && singleton.CustomMessagingManager != null) { network = singleton; singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi__h.napsta.state.2", new HandleNamedMessageDelegate(ReceiveState)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi__h.napsta.water.2", new HandleNamedMessageDelegate(ReceiveWater)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi__h.napsta.clear.1", new HandleNamedMessageDelegate(ReceiveReset)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("hihi__h.napsta.purify.1", new HandleNamedMessageDelegate(ReceivePurify)); singleton.OnClientConnectedCallback += ClientConnected; } } } private void Update() { NativeTick(); } internal void NativeTick() { //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) if (lastFrame == Time.frameCount) { return; } lastFrame = Time.frameCount; if (!tickReported) { tickReported = true; ManualLogSource modLogger = NapstablookPlugin.ModLogger; if (modLogger != null) { modLogger.LogInfo((object)"[NAP v16] Persistent world frame running; landing chance rolls enabled."); } } Bind(); if (Time.unscaledTime > nextDevListScan) { nextDevListScan = Time.unscaledTime + 3f; QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>(); if ((Object)(object)val != (Object)null) { NapstablookDevDropdownPatch.Ensure(val); } } if (!IsInRound) { if (landedLast) { if (IsHost) { SendReset(); } Clear(); } landedLast = false; return; } landedLast = true; if (IsHost) { HandleLandingSpawn(); } if (IsHost && NapstablookPlugin.EnableDebugHotkeys.Value && (Object)(object)ghost != (Object)null) { if (DevKeyReader.Pressed("f6Key")) { mood = Mathf.Clamp(mood + 25f, 0f, 100f); SendState(); } if (DevKeyReader.Pressed("f7Key")) { mood = Mathf.Clamp(mood - 25f, 0f, 100f); SendState(); } } if ((Object)(object)ghost == (Object)null) { return; } float num = Mathf.Min(Time.deltaTime, 0.1f); elapsed += num; phaseTime += num; if (IsHost) { Think(num); if (Time.time - lastSend > 0.18f) { lastSend = Time.time; SendState(); } if (Time.time >= nextSyncAll) { nextSyncAll = Time.time + 18f; foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (connectedClientsId != network.LocalClientId) { ClientConnected(connectedClientsId); } } } } else { ghost.transform.position = Vector3.Lerp(ghost.transform.position, remoteTarget, Mathf.Min(1f, num * 7f)); ghost.transform.rotation = Quaternion.Slerp(ghost.transform.rotation, Quaternion.Euler(0f, remoteYaw, 0f), Mathf.Min(1f, num * 5f)); } UpdateVisual(num); UpdateHearts(); UpdateNativeStars(); UpdateAudio(); AnimateWater(); UpdateEvaporationMotes(); } public unsafe void SpawnFromDev(Vector3 location) { //IL_001b: 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) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Bind(); if (!IsHost) { return; } if (!localSpawned) { MakeGhost(location); localSpawned = true; devSpawned = true; mood = 0f; state = MoodState.Spawning; phaseTime = 0f; lastWater = Time.time; nextSyncAll = Time.time + 18f; ManualLogSource modLogger = NapstablookPlugin.ModLogger; Vector3 val = location; modLogger.LogInfo((object)("DEV spawn requested at: " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); SendState(); } else { if ((Object)(object)nav != (Object)null && ((Behaviour)nav).enabled && nav.isOnNavMesh) { nav.Warp(location); } else if ((Object)(object)ghost != (Object)null) { ghost.transform.position = location; } mood = 0f; ChangeState(MoodState.Spawning); phaseTime = 0f; StopAI(); NapstablookPlugin.ModLogger.LogInfo((object)"DEV spawn repositioned existing Napstablook; appearance restarted"); SendState(); } } private void HandleLandingSpawn() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || !instance.shipHasLanded || instance.inShipPhase || instance.shipIsLeaving) { return; } if (!landingRollCompleted) { landingRollCompleted = true; landingRollSucceeded = false; if (!NapstablookPlugin.EnableNaturalSpawn.Value) { NapstablookPlugin.ModLogger.LogInfo((object)"Natural Napstablook spawn disabled in config; DEV/F8 remains enabled."); return; } if (localSpawned) { NapstablookPlugin.ModLogger.LogInfo((object)"Natural spawn skipped: Napstablook already exists (max 1)."); return; } int num = Mathf.Clamp(NapstablookPlugin.LandingSpawnChancePercent.Value, 0, 100); float num2 = Random.value * 100f; landingRollSucceeded = num >= 100 || num2 < (float)num; nextNaturalSpawnAttempt = Time.time + 1f; nextNaturalSpawnWarn = Time.time + 25f; NapstablookPlugin.ModLogger.LogInfo((object)("Landing Napstablook roll: " + num2.ToString("F2") + " / " + num + "% => " + (landingRollSucceeded ? "selected; pending indoor spawn" : "no spawn this landing"))); } if (landingRollSucceeded && !localSpawned && !(Time.time < nextNaturalSpawnAttempt)) { nextNaturalSpawnAttempt = Time.time + 2f; if (TrySpawn()) { landingRollSucceeded = false; NapstablookPlugin.ModLogger.LogInfo((object)"Natural Napstablook spawn completed (1 of 1 this landing)."); } else if (Time.time >= nextNaturalSpawnWarn) { nextNaturalSpawnWarn = Time.time + 25f; NapstablookPlugin.ModLogger.LogWarning((object)"15% landing roll passed; waiting for a valid indoor NavMesh spawn node."); } } } private unsafe bool TrySpawn() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!FindInteriorPoint(out var pos)) { return false; } MakeGhost(pos); localSpawned = true; mood = 0f; state = MoodState.Spawning; phaseTime = 0f; lastWater = Time.time; nextSyncAll = Time.time + 18f; ManualLogSource modLogger = NapstablookPlugin.ModLogger; Vector3 val = pos; modLogger.LogInfo((object)("Napstablook spawned indoors at " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); SendState(); return true; } private bool FindInteriorPoint(out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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) pos = Vector3.zero; RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } List<Vector3> list = new List<Vector3>(); try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object obj = typeof(RoundManager).GetField("insideAINodes", bindingAttr)?.GetValue(instance) ?? typeof(RoundManager).GetField("allInsideAINodes", bindingAttr)?.GetValue(instance); if (obj is IEnumerable) { foreach (object item in (IEnumerable)obj) { GameObject val = (GameObject)((item is GameObject) ? item : null); if (val != null && (Object)(object)val != (Object)null) { list.Add(val.transform.position); continue; } Transform val2 = (Transform)((item is Transform) ? item : null); if (val2 != null && (Object)(object)val2 != (Object)null) { list.Add(val2.position); } } } } catch { } if (list.Count == 0) { try { GameObject[] array = GameObject.FindGameObjectsWithTag("AINode"); foreach (GameObject val3 in array) { if ((Object)(object)val3 != (Object)null && !((Object)val3).name.ToLowerInvariant().Contains("outside")) { list.Add(val3.transform.position); } } } catch { } } if (list.Count == 0) { return false; } NavMeshHit val4 = default(NavMeshHit); for (int j = 0; j < Mathf.Min(20, list.Count * 3); j++) { if (NavMesh.SamplePosition(list[random.Next(list.Count)], ref val4, 5f, -1)) { pos = ((NavMeshHit)(ref val4)).position; return true; } } return false; } private void MakeGhost(Vector3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) DestroyGhostOnly(); ghost = new GameObject("NAPSTABLOOK_MONSTER_AI"); ghost.transform.position = pos; remoteTarget = pos; NavMeshAgent val = ghost.AddComponent<NavMeshAgent>(); val.radius = 0.12f; val.height = 1.7f; val.speed = 1.18f; val.acceleration = 5f; val.angularSpeed = 240f; val.obstacleAvoidanceType = (ObstacleAvoidanceType)0; val.avoidancePriority = 99; nav = val; if (!IsHost) { ((Behaviour)nav).enabled = false; } BoxCollider val2 = ghost.AddComponent<BoxCollider>(); val2.size = new Vector3(2.2f, 8f, 3.2f); val2.center = new Vector3(0f, 3.85f, 0f); ((Collider)val2).enabled = false; obstruction = val2; InstallAudioSources(); AddScanNode(ghost); try { model = GlbScene.Open(Path.Combine(NapstablookPlugin.Folder, "Napstablook_Animated.glb")); model.Root.transform.SetParent(ghost.transform, false); model.Root.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); model.Animate("01_Wander_Loop", 0f, loop: true); model.SetMoodVisual(6, 0f); } catch (Exception ex) { NapstablookPlugin.ModLogger.LogError((object)("Could not load character GLB: " + ex)); } } private static void AddScanNode(GameObject owner) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("ScanNode"); val.transform.SetParent(owner.transform, false); val.transform.localPosition = new Vector3(0f, 1.05f, 0f); int num = LayerMask.NameToLayer("ScanNode"); if (num >= 0) { val.layer = num; } BoxCollider obj = val.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = new Vector3(0.9f, 1.8f, 0.9f); ScanNodeProperties obj2 = val.AddComponent<ScanNodeProperties>(); obj2.headerText = NapstablookPlugin.ScanName; obj2.subText = NapstablookPlugin.ScanDescription; obj2.nodeType = 1; obj2.minRange = 1; obj2.maxRange = 22; obj2.requiresLineOfSight = true; obj2.creatureScanID = -1; } catch (Exception ex) { NapstablookPlugin.ModLogger.LogWarning((object)("Napstablook scan node setup failed: " + ex.Message)); } } private void Think(float dt) { //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ghost == (Object)null) { return; } bool flag = (musicActive = MusicIsPlayingNearby()); if (flag && mood <= 20f && (state == MoodState.Wander || state == MoodState.Recovery)) { happyMusicTime += dt; if (happyMusicTime >= 5f && !purificationActive && puddles.Count > 0) { BeginPurification(); } if (purificationActive && Time.time - purificationStarted >= (float)(Mathf.CeilToInt((float)puddles.Count / 2f) - 1) * 2.35f + 2.2f + 0.1f) { FinishPurification(); } } else if (happyMusicTime > 0f || purificationActive) { happyMusicTime = 0f; if (purificationActive) { CancelPurification(); } } if (state == MoodState.Spawning) { StopAI(); if (phaseTime >= 2.2f) { ChangeState(MoodState.Wander); } return; } float num = NapstablookPlugin.MoodGain.Value + (HasNearbyPlayer() ? NapstablookPlugin.NearbyMoodGain.Value : 0f); mood = Mathf.Clamp(mood + (flag ? (0f - NapstablookPlugin.MusicReduction.Value) : num) * dt, 0f, 100f); if (flag && mood <= 20f && state != MoodState.Wander && state != MoodState.Recovery) { ChangeState(MoodState.Recovery); } switch (state) { case MoodState.Wander: MoveAI(1.18f); if (mood >= 70f) { ChangeState(MoodState.Crying); } else if (mood >= 40f) { ChangeState(MoodState.Falling); } break; case MoodState.Falling: StopAI(); if (phaseTime >= 2.8f) { ChangeState((mood >= 70f) ? MoodState.Crying : MoodState.Lying); } break; case MoodState.Lying: StopAI(); if (mood >= 70f) { ChangeState(MoodState.Crying); } else if (phaseTime >= 11.7f) { ChangeState(MoodState.Vanishing); } break; case MoodState.Vanishing: StopAI(); if (mood >= 70f) { ChangeState(MoodState.Crying); } else { if (!(phaseTime >= 1.5f)) { break; } if (FindInteriorPoint(out var pos)) { if ((Object)(object)nav != (Object)null && ((Behaviour)nav).enabled && nav.isOnNavMesh) { nav.Warp(pos); } else { ghost.transform.position = pos; } } ChangeState((mood >= 70f) ? MoodState.Crying : MoodState.Wander); } break; case MoodState.Crying: MoveAI(0.78f); if (!(Time.time - lastWater >= 5f)) { break; } if (puddles.Count != 0) { Vector3 val = puddles[puddles.Count - 1].Position - ghost.transform.position; if (!(((Vector3)(ref val)).sqrMagnitude >= 4f)) { break; } } lastWater = Time.time; AddWater(ghost.transform.position, NapstablookPlugin.PuddleSize.Value, broadcast: true); break; case MoodState.Recovery: StopAI(); if (phaseTime >= 2.6f) { ChangeState(MoodState.Wander); } break; } } private bool MusicIsPlayingNearby() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0052: Unknown result type (might be due to invalid IL or missing references) try { BoomboxItem[] array = Object.FindObjectsOfType<BoomboxItem>(); foreach (BoomboxItem val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.boomboxAudio != (Object)null && val.boomboxAudio.isPlaying) { Vector3 val2 = ((Component)val).transform.position - ghost.transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= NapstablookPlugin.MusicRange.Value * NapstablookPlugin.MusicRange.Value) { return true; } } } } catch (Exception ex) { if (Time.frameCount % 900 == 0) { NapstablookPlugin.ModLogger.LogWarning((object)("Boombox lookup: " + ex.Message)); } } return false; } private bool HasNearbyPlayer() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) try { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return false; } float value = NapstablookPlugin.PlayerMoodRadius.Value; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead) { Vector3 val2 = ((Component)val).transform.position - ghost.transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= value * value) { return true; } } } } catch (Exception ex) { if (Time.frameCount % 900 == 0) { NapstablookPlugin.ModLogger.LogWarning((object)("Nearby player scan: " + ex.Message)); } } return false; } private void ChangeState(MoodState next) { if (state == next) { return; } state = next; phaseTime = 0f; if (state == MoodState.Spawning && model != null) { model.Animate("01_Wander_Loop", 0f, loop: true); model.SetMoodVisual(6, 0f); } if (state == MoodState.Crying) { lastWater = Time.time - 2.6f; happyMusicTime = 0f; if (purificationActive) { CancelPurification(); } } if (state == MoodState.Wander) { lastTargetPick = 0f; } SendState(); } private void MoveAI(float speed) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) if ((Object)(object)nav == (Object)null || !((Behaviour)nav).enabled || !nav.isOnNavMesh) { return; } nav.speed = speed; nav.isStopped = false; if (Time.time - lastTargetPick > 7f || !nav.hasPath || nav.remainingDistance < 0.8f) { lastTargetPick = Time.time; if (FindInteriorPoint(out var pos)) { localTarget = pos; nav.SetDestination(pos); } } Vector3 velocity = nav.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.03f) { Quaternion val = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized, Vector3.up); ghost.transform.rotation = Quaternion.Slerp(ghost.transform.rotation, val, Time.deltaTime * 2f); } } private void StopAI() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)nav != (Object)null && ((Behaviour)nav).enabled && nav.isOnNavMesh) { nav.isStopped = true; nav.velocity = Vector3.zero; } } private void UpdateVisual(float dt) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) if (model != null) { float time = phaseTime; string name = "01_Wander_Loop"; bool loop = true; switch (state) { case MoodState.Spawning: name = "01_Wander_Loop"; break; case MoodState.Falling: name = "02_Sad_Fall_LieDown"; time = phaseTime * 5.2f / 2.8f; loop = false; break; case MoodState.Lying: name = "05_Sad_Lying_Loop"; break; case MoodState.Vanishing: name = "05_Sad_Lying_Loop"; break; case MoodState.Crying: name = ((phaseTime < 7f) ? "03_Cry_Create_Puddle" : "04_Cry_Loop"); time = ((phaseTime < 7f) ? phaseTime : (phaseTime - 7f)); loop = phaseTime >= 7f; break; case MoodState.Recovery: name = "06_Recovery"; loop = false; break; } model.Animate(name, time, loop); bool flag = state == MoodState.Spawning; float num = Mathf.Clamp01(phaseTime / 2.2f); float num2 = num * num * (3f - 2f * num); bool flag2 = !flag && musicActive && (state == MoodState.Wander || state == MoodState.Recovery); float num3 = (flag2 ? Mathf.Sin(elapsed * 9f) : 0f); model.Root.transform.localRotation = Quaternion.Euler(0f, 90f, 0f) * Quaternion.Euler(0f, 0f, flag2 ? (num3 * 7f) : 0f); model.Root.transform.localPosition = (flag ? new Vector3(0f, -0.45f * (1f - num2) + 0.12f * Mathf.Sin(num2 * MathF.PI), 0f) : new Vector3(0f, flag2 ? (Mathf.Abs(num3) * 0.105f) : 0f, 0f)); model.Root.transform.localScale = Vector3.one * (flag ? Mathf.Lerp(0.72f, 1f, num2) : 1f); float fade = (flag ? num2 : ((state == MoodState.Vanishing) ? Mathf.Clamp01(1f - phaseTime / 1.5f) : 1f)); model.SetMoodVisual((int)state, fade); } if ((Object)(object)obstruction != (Object)null) { bool flag3 = state == MoodState.Lying || (state == MoodState.Falling && phaseTime > 2.1f) || (state == MoodState.Vanishing && phaseTime < 1f); if (flag3 && (!((Collider)obstruction).enabled || Time.time >= nextLyingColliderFit)) { nextLyingColliderFit = Time.time + 0.2f; FitFullBodyLyingCollider(); } ((Collider)obstruction).enabled = flag3; } } private void FitFullBodyLyingCollider() { //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0120: 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_00f9: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01d2: Unknown result type (might be due to invalid IL or missing references) if (model == null || (Object)(object)model.Root == (Object)null || (Object)(object)obstruction == (Object)null || (Object)(object)ghost == (Object)null) { return; } try { SkinnedMeshRenderer val = null; SkinnedMeshRenderer[] componentsInChildren = model.Root.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || !((Renderer)val2).enabled) { continue; } Transform val3 = ((Component)val2).transform; while ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)model.Root.transform) { if (((Object)val3).name == "Ghost_Cloth_Skinned") { val = val2; break; } val3 = val3.parent; } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)lyingColliderBakeMesh == (Object)null) { lyingColliderBakeMesh = new Mesh(); } val.BakeMesh(lyingColliderBakeMesh); Bounds bounds = lyingColliderBakeMesh.bounds; Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); Vector3 val6 = default(Vector3); for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { ((Vector3)(ref val6))..ctor((j == 0) ? min.x : max.x, (k == 0) ? min.y : max.y, (l == 0) ? min.z : max.z); Vector3 val7 = ghost.transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val6)); val4 = Vector3.Min(val4, val7); val5 = Vector3.Max(val5, val7); } } } float num = Mathf.Clamp(val5.x - val4.x + 0.32f, 2.2f, 7f); float num2 = Mathf.Clamp(val5.z - val4.z + 0.32f, 3.2f, 8f); obstruction.size = new Vector3(num, 8f, num2); obstruction.center = new Vector3((val4.x + val5.x) * 0.5f, 3.85f, (val4.z + val5.z) * 0.5f); } catch (Exception ex) { NapstablookPlugin.ModLogger.LogWarning((object)("Could not fit lying wall to cloth skin; using tall fallback: " + ex.Message)); obstruction.size = new Vector3(2.2f, 8f, 3.2f); obstruction.center = new Vector3(0f, 3.85f, 0f); } } private void LoadAudioIfNeeded() { string[] array = new string[4] { "wander.wav", "lie_down.wav", "crying.wav", "happy.wav" }; for (int i = 0; i < array.Length; i++) { if ((Object)(object)soundClips[i] != (Object)null) { continue; } try { string text = Path.Combine(NapstablookPlugin.Folder, "sounds", array[i]); soundClips[i] = NapstaWavLoader.Load(text); if ((Object)(object)soundClips[i] != (Object)null) { NapstablookPlugin.ModLogger.LogInfo((object)("Audio ready: " + array[i] + " (" + soundClips[i].length.ToString("F2") + "s), " + text)); } } catch (Exception ex) { NapstablookPlugin.ModLogger.LogError((object)("Could not load sound " + array[i] + ": " + ex.Message)); } } } private AudioSource MakeSpatialSource(string sourceName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(sourceName); val.transform.SetParent(ghost.transform, false); val.transform.localPosition = Vector3.up * 0.9f; AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.8f; obj.maxDistance = 17f; obj.dopplerLevel = 0f; obj.volume = 0.65f; return obj; } private void InstallAudioSources() { LoadAudioIfNeeded(); ambientSource = MakeSpatialSource("Napstablook_Ambient_State_SFX"); ambientSource.loop = true; ambientSource.volume = 0.8f; ambientSource.minDistance = 3.2f; ambientSource.maxDistance = 24f; accentSource = MakeSpatialSource("Napstablook_Action_SFX"); accentSource.loop = false; accentSource.volume = 0.7f; previousAudioState = MoodState.Spawning; nextHappySound = 0f; lastHappyMusic = false; } private void UpdateAudio() { if ((Object)(object)ambientSource == (Object)null || (Object)(object)accentSource == (Object)null) { return; } AudioClip val = ((state == MoodState.Wander && !musicActive) ? soundClips[0] : ((state == MoodState.Crying) ? soundClips[2] : null)); if ((Object)(object)ambientSource.clip != (Object)(object)val) { ambientSource.Stop(); ambientSource.clip = val; if ((Object)(object)val != (Object)null) { ambientSource.Play(); } } else if ((Object)(object)val != (Object)null && !ambientSource.isPlaying) { ambientSource.Play(); } if (state == MoodState.Falling && previousAudioState != MoodState.Falling && (Object)(object)soundClips[1] != (Object)null) { accentSource.PlayOneShot(soundClips[1]); } bool flag = musicActive && (state == MoodState.Recovery || state == MoodState.Wander); if (flag && (!lastHappyMusic || Time.time >= nextHappySound) && (Object)(object)soundClips[3] != (Object)null) { accentSource.PlayOneShot(soundClips[3]); nextHappySound = Time.time + 4.2f; } lastHappyMusic = flag; previousAudioState = state; } private Mesh MakeHeartMesh() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[49]; array[0] = Vector3.zero; for (int i = 0; i < 48; i++) { float num = MathF.PI * 2f * (float)i / 48f; float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); float num4 = 16f * num2 * num2 * num2; float num5 = 13f * num3 - 5f * Mathf.Cos(2f * num) - 2f * Mathf.Cos(3f * num) - Mathf.Cos(4f * num); array[i + 1] = new Vector3(num4 * 0.035f, num5 * 0.035f, 0f); } int[] array2 = new int[288]; for (int j = 0; j < 48; j++) { int num6 = j + 1; int num7 = (j + 1) % 48 + 1; array2[j * 6] = 0; array2[j * 6 + 1] = num6; array2[j * 6 + 2] = num7; array2[j * 6 + 3] = 0; array2[j * 6 + 4] = num7; array2[j * 6 + 5] = num6; } Mesh val = new Mesh { name = "Napstablook_MusicHeart_3D" }; val.vertices = array; val.triangles = array2; Vector3[] array3 = (Vector3[])(object)new Vector3[array.Length]; for (int k = 0; k < array3.Length; k++) { array3[k] = Vector3.forward; } val.normals = array3; return val; } private void SpawnHeart() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ghost == (Object)null) { return; } if ((Object)(object)heartMaterial == (Object)null) { heartMaterial = NapstaRuntimeMaterials.Make("Napstablook_Pink_Music_Heart", new Color(1f, 0.46f, 0.7f, 0.96f), null, transparent: true); if ((Object)(object)heartMaterial == (Object)null) { return; } } if ((Object)(object)heartShape == (Object)null) { heartShape = MakeHeartMesh(); } GameObject val = new GameObject("Napstablook_Music_Heart"); val.AddComponent<MeshFilter>().sharedMesh = heartShape; MeshRenderer obj = val.AddComponent<MeshRenderer>(); Material material = (((Renderer)obj).sharedMaterial = new Material(heartMaterial)); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; HeartPop heartPop = new HeartPop { Object = val, Material = material, Born = Time.time, Duration = 1.45f }; heartPop.Start = ghost.transform.position + Vector3.up * (1.35f + (float)random.NextDouble() * 0.8f) + new Vector3((float)(random.NextDouble() - 0.5) * 1.2f, 0f, (float)(random.NextDouble() - 0.5) * 1.2f); val.transform.position = heartPop.Start; val.transform.localScale = Vector3.one * 0.01f; hearts.Add(heartPop); } private void UpdateHearts() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ghost != (Object)null && musicActive && Time.time - lastHeartSpawn >= 0.36f) { lastHeartSpawn = Time.time; SpawnHeart(); } for (int num = hearts.Count - 1; num >= 0; num--) { HeartPop heartPop = hearts[num]; if ((Object)(object)heartPop.Object == (Object)null) { hearts.RemoveAt(num); } else { float num2 = Mathf.Clamp01((Time.time - heartPop.Born) / heartPop.Duration); if (num2 >= 1f) { Object.Destroy((Object)(object)heartPop.Object); Object.Destroy((Object)(object)heartPop.Material); hearts.RemoveAt(num); } else { heartPop.Object.transform.position = heartPop.Start + Vector3.up * (num2 * 0.95f); if ((Object)(object)Camera.main != (Object)null) { heartPop.Object.transform.rotation = ((Component)Camera.main).transform.rotation; } float num3 = 0.28f * Mathf.Sin(MathF.PI * num2); heartPop.Object.transform.localScale = Vector3.one * Mathf.Max(0.001f, num3); NapstaRuntimeMaterials.SetOpacity(heartPop.Material, 0.96f * (1f - num2)); } } } } private void UpdateNativeStars() { //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0385: 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: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might
plugins/SansFigurine/SansFigurine.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
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.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 SansFigurineMod { internal static class GasterMeshLoader { internal sealed class Part { internal Mesh Mesh; internal Texture2D Texture; } internal static Part[] Load(string folder) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(File.OpenRead(Path.Combine(folder, "gaster_mesh.bin"))); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "GASTER02") { throw new InvalidDataException("Not a user original Gaster GLB mesh export"); } int num = binaryReader.ReadInt32(); if (num < 1 || num > 64) { throw new InvalidDataException("Invalid Gaster part count"); } Part[] array = new Part[num]; for (int i = 0; i < num; i++) { int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num2 < 3 || num2 > 65535 || num3 < 3 || num3 > 500000 || num3 % 3 != 0) { throw new InvalidDataException("Invalid mesh sizes"); } binaryReader.ReadBytes(4); Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector2[] array4 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array5 = new int[num3]; for (int k = 0; k < num3; k++) { uint num4 = binaryReader.ReadUInt32(); if (num4 >= num2) { throw new InvalidDataException("Gaster invalid index"); } array5[k] = (int)num4; } Mesh val = new Mesh(); ((Object)val).name = "Original supplied Gaster GLB part " + i; val.vertices = array2; val.normals = array3; val.uv = array4; val.triangles = array5; val.RecalculateBounds(); string path = Path.Combine(folder, "gaster_texture_" + i + ".png"); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val2, File.ReadAllBytes(path), false)) { throw new InvalidDataException("Could not load original GLB texture " + i); } ((Object)val2).name = "Original Gaster GLB texture " + i; ((Texture)val2).wrapMode = (TextureWrapMode)0; ((Texture)val2).filterMode = (FilterMode)1; array[i] = new Part { Mesh = val, Texture = val2 }; } return array; } } public enum SansLanguage { Korean, English } [BepInPlugin("jin.sans.figurine.scrap", "Sans Figurine", "0.4.11")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ErrorEventHandler <>9__122_0; internal void <EnsureScreen>b__122_0(VideoPlayer vp, string message) { Log.LogError((object)("Sans video error: " + message)); } } internal static ConfigEntry<SansLanguage> LanguageSetting; private readonly Dictionary<ulong, bool> fatalLockSawDeath = new Dictionary<ulong, bool>(); public const string ModGuid = "jin.sans.figurine.scrap"; private const string UseMessage = "jin.sans.figurine.scrap.use.v1"; private const string ResultMessage = "jin.sans.figurine.scrap.result.v1"; private const string FatalEndMessage = "jin.sans.figurine.scrap.fatal_end.v1"; private const string BlastStartMessage = "jin.sans.figurine.scrap.blast_start.v1"; internal static ManualLogSource Log; internal static AudioClip[] Sounds = (AudioClip[])(object)new AudioClip[3]; private NetworkManager registeredManager; private object registeredMessagingManager; private NetworkManager lastFailedManager; private static Plugin instance; private bool isReady; private const int ScrapRarity = 10; private const float NormalFatalChancePercent = 1f; private const float SpecialSequenceSeconds = 16.1f; private const int BlasterCount = 5; private const int BlastHitCount = 15; private const int BlastDamage = 6; private const float BlastChargeSeconds = 2f; private const float BlasterEntranceStep = 0.18f; private const float BlasterEntranceDuration = 0.48f; private const float BlastDurationSeconds = 2f; private const float BlastTotalSeconds = 4f; private const float FatalLockSeconds = 45f; private float blastWhiteout; private Texture2D whiteoutPixel; private AudioSource blastAudio; private readonly Dictionary<ulong, AudioSource> normalAudioByUser = new Dictionary<ulong, AudioSource>(); private GameObject[] blasterHeads = (GameObject[])(object)new GameObject[5]; private Transform[] blasterJaws = (Transform[])(object)new Transform[5]; private GameObject[] blasterChargeLights = (GameObject[])(object)new GameObject[5]; private GameObject[] blasterBeams = (GameObject[])(object)new GameObject[5]; private GameObject[] blasterOuterBeams = (GameObject[])(object)new GameObject[5]; private GameObject[] blasterInnerBeams = (GameObject[])(object)new GameObject[5]; private GameObject[] blasterBeamTips = (GameObject[])(object)new GameObject[5]; private readonly Dictionary<AudioSource, bool> mutedAmbience = new Dictionary<AudioSource, bool>(); private float nextMuteSweep; private bool showFatalScreen; private bool blackRoomVideoOverlay; private ConfigEntry<float> fatalChancePercent; private bool fatalSceneActive; private RenderTexture cutsceneTexture; private Texture2D cutsceneBlack; private GameObject cutsceneVideoObject; private AudioClip blastSound; private GasterMeshLoader.Part[] gasterModelParts; private AudioSource cutsceneAudio; private VideoPlayer cutscenePlayer; private readonly Dictionary<string, bool> previousInputFlags = new Dictionary<string, bool>(); private bool inputFreezeActive; private PlayerControllerB roomOccupant; private Vector3 cinematicAnchor; private bool hasCinematicAnchor; private Camera cinematicCamera; private PlayerControllerB thirdPersonTarget; private Vector3 cinematicForward; private readonly Dictionary<Renderer, bool> originalPlayerRendererStates = new Dictionary<Renderer, bool>(); private readonly Dictionary<Renderer, ShadowCastingMode> originalPlayerShadowStates = new Dictionary<Renderer, ShadowCastingMode>(); private readonly Dictionary<Renderer, bool> originalPlayerForceRenderingStates = new Dictionary<Renderer, bool>(); private readonly Dictionary<GameObject, bool> originalPlayerObjectStates = new Dictionary<GameObject, bool>(); private GameObject blastImpact; private GameObject isolatedBlasterCameraRig; private bool isolatedBlasterCamera; private RenderTexture blasterFrameTexture; private const int CinematicBlasterLayer = 30; private GameObject blastCurtainRoot; private Canvas blastCurtainCanvas; private RawImage blastCurtainImage; private bool keepPlayerInRoom; private SansFigurineScrap activeFatalFigure; private Coroutine activeFatalCoroutine; private PlayerControllerB lastFatalVictim; private PlayerControllerB deferredBodyRestorePlayer; private bool waitingForLocalRevive; private bool sawLocalFatalDeath; private bool warnedStillDead; private float fatalDeathStartedAt; private float fatalSceneStartedAt; private readonly Dictionary<ulong, float> fatalPendingUntil = new Dictionary<ulong, float>(); internal static SansRunner runnerInstance; internal static bool IsKorean { get { if (LanguageSetting != null) { return LanguageSetting.Value == SansLanguage.Korean; } return true; } } internal static string ItemDisplayName { get { if (!IsKorean) { return "Sans Figurine"; } return "샌즈 피규어"; } } internal static string UseTooltip { get { if (!IsKorean) { return "Use Sans : [LMB]"; } return "샌즈 사용 : [LMB]"; } } internal static string ScanWarning { get { if (!IsKorean) { return "DO NOT PRESS."; } return "누르지 마시오."; } } internal static MonoBehaviour Runner { get { EnsureRunner(); return (MonoBehaviour)(((object)runnerInstance) ?? ((object)instance)); } } internal static void TickInstance() { if (instance != null) { instance.Tick(); } } internal static void LateTickInstance() { if (instance != null) { instance.LateTick(); } } internal static void GuiInstance() { if (instance != null) { instance.Gui(); } } internal static void ShutdownInstance() { if (instance != null) { instance.Shutdown(); } } internal static void EnsureRunner() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (!((Object)(object)runnerInstance != (Object)null)) { GameObject val = new GameObject("SansFigurine_Runner") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); runnerInstance = val.AddComponent<SansRunner>(); } } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Expected O, but got Unknown //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) instance = this; Log = ((BaseUnityPlugin)this).Logger; try { if ((((Object)((Component)this).gameObject).hideFlags & 0x3D) != 61) { ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ((BaseUnityPlugin)this).Logger.LogInfo((object)"BepInEx manager object protected (HideAndDontSave) for UnderCompany plugins."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Manager protect failed: " + ex.Message)); } EnsureRunner(); fatalChancePercent = ((BaseUnityPlugin)this).Config.Bind<float>("Testing", "FatalChancePercent", 1f, "Third (special death) result chance when landed; reset from testing to 1% in SANS_11."); if (Mathf.Abs(fatalChancePercent.Value - 1f) > 0.001f) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sans special chance config migrated from {fatalChancePercent.Value:F1}% to {1f:F1}%."); fatalChancePercent.Value = 1f; } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sans special chance: landed={1f:F1}%, airborne=0%."); LanguageSetting = ((BaseUnityPlugin)this).Config.Bind<SansLanguage>("General", "Language", SansLanguage.Korean, "Korean = 샌즈 피규어 / 누르지 마시오. / Korean cutscene. English = Sans Figurine / DO NOT PRESS. / English cutscene. Restart the game after changing."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Sans language: " + LanguageSetting.Value)); string text = Path.Combine(Path.GetDirectoryName(((object)this).GetType().Assembly.Location), "assets"); try { for (int i = 0; i < 2; i++) { Sounds[i] = WaveLoader.Load(Path.Combine(text, "sans" + (i + 1) + ".wav")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sans sound {i + 1} loaded, duration={Sounds[i].length:F3}s"); } blastSound = WaveLoader.Load(Path.Combine(text, "sans_blast.wav")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sans blaster loaded, duration={blastSound.length:F3}s; death near sound end."); SansMeshLoader.Imported imported = SansMeshLoader.Import(text); gasterModelParts = GasterMeshLoader.Load(text); Log.LogInfo((object)("Loaded NEW supplied Gaster Blaster GLB original mesh parts WITH material textures: " + gasterModelParts.Length)); Item val = ScriptableObject.CreateInstance<Item>(); ((Object)val).name = "SansFigurineItem"; val.itemName = ItemDisplayName; val.isScrap = true; val.requiresBattery = false; val.itemIsTrigger = true; val.minValue = 150; val.maxValue = 300; val.weight = 1.04f; val.twoHanded = false; val.canBeGrabbedBeforeGameStart = true; val.isConductiveMetal = false; val.positionOffset = new Vector3(0f, 0.015f, 0.02f); val.rotationOffset = new Vector3(0f, 180f, 0f); val.verticalOffset = 0.03f; val.restingRotation = Vector3.zero; val.toolTips = new string[1] { UseTooltip }; Texture2D texture = LoadTexture(Path.Combine(text, "sans_icon.png")) ?? imported.Texture; val.itemIcon = MakeIcon(texture); GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("SansFigurineScrap"); val2.tag = "PhysicsProp"; int num = LayerMask.NameToLayer("Props"); if (num >= 0) { val2.layer = num; } SansFigurineScrap sansFigurineScrap = val2.AddComponent<SansFigurineScrap>(); val2.AddComponent<SansFigurineHeldVisual>(); ((GrabbableObject)sansFigurineScrap).itemProperties = val; ((GrabbableObject)sansFigurineScrap).grabbable = true; ((GrabbableObject)sansFigurineScrap).grabbableToEnemies = true; ((GrabbableObject)sansFigurineScrap).isInFactory = true; ((GrabbableObject)sansFigurineScrap).scrapValue = 0; BoxCollider obj = val2.AddComponent<BoxCollider>(); obj.center = new Vector3(0f, 0.17f, 0f); Bounds bounds = imported.Mesh.bounds; float num2 = Mathf.Max(0.12f, ((Bounds)(ref bounds)).size.x); bounds = imported.Mesh.bounds; obj.size = new Vector3(num2, 0.34f, Mathf.Max(0.12f, ((Bounds)(ref bounds)).size.z)); GameObject val3 = new GameObject("SansFigureModel"); val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = new Vector3(0f, 0.17f, 0f); val3.AddComponent<MeshFilter>().sharedMesh = imported.Mesh; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = imported.Material; GameObject val4 = new GameObject("ScanNode"); val4.transform.SetParent(val2.transform, false); val4.transform.localPosition = new Vector3(0f, 0.16f, 0f); int num3 = LayerMask.NameToLayer("ScanNode"); if (num3 >= 0) { val4.layer = num3; } BoxCollider obj2 = val4.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.size = new Vector3(0.48f, 0.48f, 0.48f); ScanNodeProperties obj3 = val4.AddComponent<ScanNodeProperties>(); obj3.headerText = ItemDisplayName; obj3.subText = "Value: "; GameObject val5 = new GameObject("ScanNode_Warning"); val5.transform.SetParent(val4.transform, false); val5.transform.localPosition = new Vector3(0f, 0.22f, 0f); if (num3 >= 0) { val5.layer = num3; } BoxCollider obj4 = val5.AddComponent<BoxCollider>(); ((Collider)obj4).isTrigger = true; obj4.size = new Vector3(0.3f, 0.3f, 0.3f); ScanNodeProperties obj5 = val5.AddComponent<ScanNodeProperties>(); obj5.headerText = ScanWarning; obj5.subText = ""; obj5.nodeType = 1; obj5.minRange = 1; obj5.maxRange = 13; obj5.requiresLineOfSight = true; obj5.creatureScanID = -1; obj3.nodeType = 2; obj3.minRange = 1; obj3.maxRange = 13; obj3.scrapValue = 0; obj3.creatureScanID = -1; AudioSource obj6 = val2.AddComponent<AudioSource>(); obj6.playOnAwake = false; obj6.spatialBlend = 0f; obj6.spatialize = false; obj6.dopplerLevel = 0f; val.spawnPrefab = val2; Items.RegisterScrap(val, 10, (LevelTypes)(-1)); isReady = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Sans Figurine v0.4.11 registered: heart/hall/angry, 2s jaws/charge, 2s firing, 15 impacts, Pieces finisher, normal special chance 1% after landing. Name=" + ItemDisplayName)); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Sans Figurine initialization failed: " + ex2)); } } private static Texture2D LoadTexture(string path) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0025: 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_0034: Expected O, but got Unknown try { if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array, false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("Icon load failed: " + ex.Message)); } return null; } } private static Sprite MakeIcon(Texture2D texture) { //IL_0024: 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) if ((Object)(object)texture == (Object)null) { return null; } return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f)); } internal void Tick() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown if (!isReady) { return; } WatchLocalReviveAndRecover(); if (fatalSceneActive && Time.realtimeSinceStartup - fatalSceneStartedAt > 35f) { Log.LogError((object)"Sans cinematic exceeded 35s; forcing recovery of Sans-owned input, camera and video."); PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if (activeFatalCoroutine != null) { Runner.StopCoroutine(activeFatalCoroutine); activeFatalCoroutine = null; } if ((Object)(object)val != (Object)null && inputFreezeActive) { SetInputFrozen(val, freeze: false, freezeLook: false); } CleanupFatalScene(); } if (keepPlayerInRoom) { MaintainRoomSilence(); } TrackFatalLockDeaths(); NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { registeredManager = null; registeredMessagingManager = null; return; } object customMessagingManager = singleton.CustomMessagingManager; if ((Object)(object)singleton == (Object)(object)registeredManager && customMessagingManager == registeredMessagingManager) { return; } try { singleton.CustomMessagingManager.RegisterNamedMessageHandler("jin.sans.figurine.scrap.use.v1", new HandleNamedMessageDelegate(HandleUseRequest)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("jin.sans.figurine.scrap.result.v1", new HandleNamedMessageDelegate(HandleUseResult)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("jin.sans.figurine.scrap.fatal_end.v1", new HandleNamedMessageDelegate(HandleFatalEnd)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("jin.sans.figurine.scrap.blast_start.v1", new HandleNamedMessageDelegate(HandleBlastStart)); registeredManager = singleton; registeredMessagingManager = customMessagingManager; lastFailedManager = null; Log.LogInfo((object)"Sans Figurine network handlers (re)registered for active lobby."); } catch (Exception ex) { if ((Object)(object)lastFailedManager != (Object)(object)singleton) { Log.LogWarning((object)("Network handler setup failed: " + ex)); lastFailedManager = singleton; } } } private void TrackFatalLockDeaths() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || fatalPendingUntil.Count == 0) { return; } foreach (ulong item in new List<ulong>(fatalPendingUntil.Keys)) { PlayerControllerB val = FindPlayerByClientId(item); if ((Object)(object)val != (Object)null && val.isPlayerDead) { fatalLockSawDeath[item] = true; } } } private void ClearFatalLockOnHost(ulong clientId, string reason) { bool num = fatalPendingUntil.Remove(clientId); fatalLockSawDeath.Remove(clientId); if (num) { Log.LogInfo((object)$"Sans fatal lock released for client={clientId} ({reason})."); } } internal static PlayerControllerB FindPlayerByClientId(ulong clientId) { StartOfRound val = StartOfRound.Instance; if ((Object)(object)val == (Object)null || val.allPlayerScripts == null) { return null; } try { if (val.ClientPlayerList != null && val.ClientPlayerList.TryGetValue(clientId, out var value) && value >= 0 && value < val.allPlayerScripts.Length && (Object)(object)val.allPlayerScripts[value] != (Object)null) { return val.allPlayerScripts[value]; } } catch (Exception) { } PlayerControllerB[] allPlayerScripts = val.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.actualClientId == clientId && (val2.isPlayerControlled || val2.isPlayerDead)) { return val2; } } return null; } private static void ClearAllLocalFatalPending() { SansFigurineScrap[] array = Object.FindObjectsOfType<SansFigurineScrap>(); foreach (SansFigurineScrap sansFigurineScrap in array) { if ((Object)(object)sansFigurineScrap != (Object)null) { sansFigurineScrap.ClearFatalPending(); } } } private void BeginFatalDeathRecovery(PlayerControllerB victim) { lastFatalVictim = victim; waitingForLocalRevive = true; sawLocalFatalDeath = (Object)(object)victim != (Object)null && victim.isPlayerDead; warnedStillDead = false; fatalDeathStartedAt = Time.realtimeSinceStartup; } private void WatchLocalReviveAndRecover() { if (!waitingForLocalRevive) { return; } StartOfRound val = StartOfRound.Instance; PlayerControllerB val2 = (((Object)(object)val != (Object)null) ? val.localPlayerController : null); if ((Object)(object)val2 == (Object)null) { return; } if ((Object)(object)lastFatalVictim != (Object)null && (Object)(object)val2 != (Object)(object)lastFatalVictim) { RecoverLocalCinematic(val2, revived: false); } else if (val2.isPlayerDead) { sawLocalFatalDeath = true; if (!warnedStillDead && Time.realtimeSinceStartup - fatalDeathStartedAt > 25f) { warnedStillDead = true; Log.LogWarning((object)"Sans revive monitor: local player is still marked dead after 25s. A revival mod/server must synchronize the actual revive; Sans will not fake it."); } } else if (sawLocalFatalDeath || !(Time.realtimeSinceStartup - fatalDeathStartedAt < 3f)) { RecoverLocalCinematic(val2, sawLocalFatalDeath); } } private void RecoverLocalCinematic(PlayerControllerB local, bool revived) { waitingForLocalRevive = false; sawLocalFatalDeath = false; warnedStillDead = false; lastFatalVictim = null; if (activeFatalCoroutine != null) { try { Runner.StopCoroutine(activeFatalCoroutine); } catch (Exception ex) { Log.LogWarning((object)("Sans stop old cinematic: " + ex.Message)); } activeFatalCoroutine = null; } try { if (inputFreezeActive) { SetInputFrozen(local, freeze: false, freezeLook: false); } } catch (Exception ex2) { Log.LogWarning((object)("Sans input recovery: " + ex2.Message)); } try { CleanupFatalScene(); } catch (Exception ex3) { Log.LogWarning((object)("Sans cinematic recovery: " + ex3.Message)); } try { if ((Object)(object)local != (Object)null) { ReleaseFatalLock(local.actualClientId); } } catch (Exception ex4) { Log.LogWarning((object)("Sans revive lock release: " + ex4.Message)); } try { ClearAllLocalFatalPending(); } catch (Exception ex5) { Log.LogWarning((object)("Sans revive item unlock: " + ex5.Message)); } activeFatalFigure = null; if (!revived || !((Object)(object)local != (Object)null) || local.isPlayerDead) { return; } try { if ((Object)(object)local.gameplayCamera != (Object)null && !((Behaviour)local.gameplayCamera).enabled) { ((Behaviour)local.gameplayCamera).enabled = true; } StartOfRound val = StartOfRound.Instance; if ((Object)(object)val != (Object)null) { FieldInfo field = typeof(StartOfRound).GetField("spectateCamera", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Camera val2 = (Camera)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 == (Object)null) { GameObject val3 = GameObject.Find("SpectateCamera"); if ((Object)(object)val3 != (Object)null) { val2 = val3.GetComponent<Camera>(); } } if ((Object)(object)val2 != (Object)null && ((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; } } Log.LogInfo((object)"Sans revive monitor: native alive state confirmed; cinematic input/render/camera restored."); } catch (Exception ex6) { Log.LogWarning((object)("Sans native camera revive recovery: " + ex6.Message)); } } internal void Shutdown() { try { foreach (AudioSource value in normalAudioByUser.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } normalAudioByUser.Clear(); if ((Object)(object)roomOccupant != (Object)null && inputFreezeActive) { SetInputFrozen(roomOccupant, freeze: false, freezeLook: false); } CleanupFatalScene(); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("Sans shutdown cleanup: " + ex.Message)); } } } internal void LateTick() { //IL_0037: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (keepPlayerInRoom && !((Object)(object)roomOccupant == (Object)null) && !roomOccupant.isPlayerDead && hasCinematicAnchor) { Vector3 val = ((Component)roomOccupant).transform.position - cinematicAnchor; if (((Vector3)(ref val)).sqrMagnitude > 0.25f) { Log.LogWarning((object)"Sans: unexpected movement during cinematic; leaving world position unchanged to avoid clipping/falling."); hasCinematicAnchor = false; } } } private void MaintainRoomSilence() { if (Time.realtimeSinceStartup < nextMuteSweep) { return; } nextMuteSweep = Time.realtimeSinceStartup + 0.2f; AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); foreach (AudioSource val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)cutsceneAudio) && !((Object)(object)val == (Object)(object)blastAudio)) { if (!mutedAmbience.ContainsKey(val)) { mutedAmbience[val] = val.mute; } val.mute = true; } } } private void RestoreRoomAudio() { foreach (KeyValuePair<AudioSource, bool> item in mutedAmbience) { if ((Object)(object)item.Key != (Object)null) { item.Key.mute = item.Value; } } mutedAmbience.Clear(); blastAudio = null; } internal unsafe static void RequestUse(SansFigurineScrap figure) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)instance == (Object)null || !instance.isReady || (Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null || (Object)(object)figure == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)"Sans click not sent: lobby messaging not ready (or item missing)."); } return; } ulong num = 0uL; try { if ((Object)(object)((NetworkBehaviour)figure).NetworkObject != (Object)null && ((NetworkBehaviour)figure).NetworkObject.IsSpawned) { num = ((NetworkBehaviour)figure).NetworkObject.NetworkObjectId; } } catch (Exception) { num = 0uL; } if (num == 0L) { Log.LogWarning((object)"Sans click: figure not network-spawned locally; using server-held-item fallback."); } Log.LogInfo((object)$"Sans click RequestedId={num}; requesting host result."); if (singleton.IsServer) { instance.ProcessRequest(singleton.LocalClientId, num); return; } try { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("jin.sans.figurine.scrap.use.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } Log.LogInfo((object)"Sans use request delivered to NGO messaging layer; awaiting host result."); } catch (Exception ex2) { Log.LogWarning((object)("Sans use message failed: " + ex2.Message)); } } private void HandleUseRequest(ulong sender, FastBufferReader reader) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) ulong id = default(ulong); try { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref id, default(ForPrimitives)); } catch (Exception ex) { Log.LogWarning((object)("Sans host could not read use request: " + ex.Message)); return; } ProcessRequest(sender, id); } private unsafe void ProcessRequest(ulong sender, ulong id) { //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || singleton.SpawnManager == null) { return; } PlayerControllerB val = FindPlayerByClientId(sender); SansFigurineScrap sansFigurineScrap = null; if (id != 0L && singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { sansFigurineScrap = ((Component)value).GetComponent<SansFigurineScrap>(); } if (!((Object)(object)sansFigurineScrap != (Object)null) || !((Object)(object)((GrabbableObject)sansFigurineScrap).playerHeldBy != (Object)null) || ((GrabbableObject)sansFigurineScrap).playerHeldBy.actualClientId != sender) { SansFigurineScrap sansFigurineScrap2 = (((Object)(object)val != (Object)null) ? (val.currentlyHeldObjectServer as SansFigurineScrap) : null); if ((Object)(object)sansFigurineScrap2 == (Object)null) { string arg = (((Object)(object)sansFigurineScrap != (Object)null && (Object)(object)((GrabbableObject)sansFigurineScrap).playerHeldBy != (Object)null) ? ((GrabbableObject)sansFigurineScrap).playerHeldBy.actualClientId.ToString() : "none"); Log.LogWarning((object)$"Sans host rejected use: client={sender} does not hold a validated Sans figurine. claimed={id}, holder={arg}"); return; } ulong num = 0uL; try { if ((Object)(object)((NetworkBehaviour)sansFigurineScrap2).NetworkObject != (Object)null && ((NetworkBehaviour)sansFigurineScrap2).NetworkObject.IsSpawned) { num = ((NetworkBehaviour)sansFigurineScrap2).NetworkObject.NetworkObjectId; } } catch (Exception) { num = 0uL; } Log.LogWarning((object)$"Sans client/server item ID mismatch: client={sender}, claimed={id}, hostHeld={num}. Using verified host-held item."); if (num == 0L) { Log.LogWarning((object)$"Sans host verified held figurine for client={sender}, but item itself is unspawned."); } sansFigurineScrap = sansFigurineScrap2; id = num; } if ((Object)(object)val == (Object)null) { val = ((GrabbableObject)sansFigurineScrap).playerHeldBy; } if ((Object)(object)val == (Object)null || val.isPlayerDead) { Log.LogWarning((object)$"Sans host rejected use: client={sender} is not alive on the host yet (revive not synchronized)."); return; } if (fatalPendingUntil.TryGetValue(sender, out var value2)) { fatalLockSawDeath.TryGetValue(sender, out var value3); if (Time.realtimeSinceStartup >= value2) { ClearFatalLockOnHost(sender, "timer expired"); } else { if (!value3 || val.isPlayerDead) { Log.LogInfo((object)$"Sans use ignored: fatal sequence still running for client={sender} ({value2 - Time.realtimeSinceStartup:F1}s lock left)."); return; } ClearFatalLockOnHost(sender, "player revived"); } } if (!sansFigurineScrap.ServerCanUse()) { return; } StartOfRound val2 = StartOfRound.Instance; bool flag = (Object)(object)val2 != (Object)null && val2.shipHasLanded && !val2.shipIsLeaving; float num2 = (flag ? 0.01f : 0f); float num3 = 1f - num2; float num4 = num3 - 0.6f; float value4 = Random.value; byte b = (byte)((!(value4 < 0.6f)) ? ((!flag || value4 < num3) ? 1u : 2u) : 0u); Log.LogInfo((object)$"Sans outcome rolled={value4:F4}, chosen={b + 1}, client={sender}, shipDown={flag}, probabilities=[{60.000004f:F1}%,{num4 * 100f:F1}%,{num2 * 100f:F1}%]"); ulong num5 = sender; if (b == 2) { fatalPendingUntil[num5] = Time.realtimeSinceStartup + 45f; fatalLockSawDeath.Remove(num5); } if (singleton.IsServer && singleton.IsClient) { ApplyOutcome(id, b, num5); } if (singleton.CustomMessagingManager == null) { return; } FastBufferWriter val3 = default(FastBufferWriter); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (singleton.IsServer && singleton.IsClient && connectedClientsId == singleton.LocalClientId) { continue; } try { ((FastBufferWriter)(ref val3))..ctor(32, (Allocator)2, -1); try { ((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(ref id, default(ForPrimitives)); ((FastBufferWriter)(ref val3)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(ref num5, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("jin.sans.figurine.scrap.result.v1", connectedClientsId, val3, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex2) { Log.LogWarning((object)$"Sans result send failed to client={connectedClientsId}: {ex2.Message}"); } } } private static int FindPiecesRagdollIndex() { StartOfRound val = StartOfRound.Instance; if ((Object)(object)val == (Object)null || val.playerRagdolls == null) { return 0; } List<GameObject> playerRagdolls = val.playerRagdolls; for (int i = 0; i < playerRagdolls.Count; i++) { GameObject val2 = playerRagdolls[i]; if (!((Object)(object)val2 == (Object)null)) { string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("sapsucker") || text.Contains("kiwi") || text.Contains("pieces") || text.Contains("dismember") || text.Contains("bodyparts")) { Log.LogInfo((object)$"Sans found dismembered player ragdoll: index={i} name={((Object)val2).name}"); return i; } } } if (playerRagdolls.Count > 9) { Log.LogInfo((object)$"Sans using vanilla Pieces ragdoll index 9 of {playerRagdolls.Count}; name={((Object)playerRagdolls[9]).name}"); return 9; } Log.LogWarning((object)$"Sans Pieces ragdoll unavailable (count={playerRagdolls.Count}); normal body fallback."); return 0; } private void HandleUseResult(ulong sender, FastBufferReader reader) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)NetworkManager.Singleton == (Object)null) && sender == 0L) { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); byte b = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); ulong num2 = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num2, default(ForPrimitives)); Log.LogInfo((object)$"Sans network result received: result={b + 1}, user={num2}, object={num}"); ApplyOutcome(num, b, num2); } } private void ApplyOutcome(ulong id, byte outcome, ulong victim) { if (outcome > 2) { return; } if (outcome < 2) { PlayNormalSound(outcome, victim); return; } StartOfRound val = StartOfRound.Instance; PlayerControllerB val2 = (((Object)(object)val != (Object)null) ? val.localPlayerController : null); bool num = (Object)(object)val2 != (Object)null && val2.actualClientId == victim; SansFigurineScrap sansFigurineScrap = null; NetworkManager singleton = NetworkManager.Singleton; if (id != 0L && (Object)(object)singleton != (Object)null && singleton.SpawnManager != null && singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { sansFigurineScrap = ((Component)value).GetComponent<SansFigurineScrap>(); } if (num) { if ((Object)(object)sansFigurineScrap != (Object)null) { sansFigurineScrap.PrepareFatalSound(45f); } else { Log.LogWarning((object)"Sans special result: local figurine missing, but host-confirmed cinematic will run."); } if (!val2.isPlayerDead && !fatalSceneActive) { activeFatalFigure = sansFigurineScrap; activeFatalCoroutine = Runner.StartCoroutine(PlayFatalSequence(val2)); } } } private void PlayNormalSound(byte outcome, ulong userId) { //IL_014b: 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_00ec: Unknown result type (might be due to invalid IL or missing references) AudioClip val = Sounds[outcome]; if ((Object)(object)val == (Object)null) { Log.LogWarning((object)("Sans sound missing for result " + (outcome + 1))); return; } StartOfRound val2 = StartOfRound.Instance; PlayerControllerB val3 = (((Object)(object)val2 != (Object)null) ? val2.localPlayerController : null); bool flag = (Object)(object)val3 != (Object)null && val3.actualClientId == userId; float num = 1f; if (!flag && (Object)(object)val3 != (Object)null && (Object)(object)val2 != (Object)null && val2.allPlayerScripts != null) { PlayerControllerB val4 = null; PlayerControllerB[] allPlayerScripts = val2.allPlayerScripts; foreach (PlayerControllerB val5 in allPlayerScripts) { if ((Object)(object)val5 != (Object)null && val5.actualClientId == userId) { val4 = val5; break; } } if ((Object)(object)val4 != (Object)null) { float num2 = Vector3.Distance(((Component)val3).transform.position, ((Component)val4).transform.position); if (num2 >= 28f) { return; } num = Mathf.Clamp01((28f - num2) / 16f); } else { num = 0.75f; } } if (!normalAudioByUser.TryGetValue(userId, out var value) || (Object)(object)value == (Object)null) { value = new GameObject("SansFigurineVoice_" + userId).AddComponent<AudioSource>(); normalAudioByUser[userId] = value; value.playOnAwake = false; value.loop = false; value.spatialBlend = 0f; value.spatialize = false; value.dopplerLevel = 0f; value.bypassReverbZones = true; value.ignoreListenerPause = true; } value.Stop(); value.clip = val; value.pitch = 1f; value.volume = num; value.Play(); Log.LogInfo((object)$"Sans sound {outcome + 1} playing (2D, gain={num:F2}, user={userId}, localHolder={flag}, length={val.length:F2}s)"); } private void HandleFatalEnd(ulong sender, FastBufferReader reader) { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer) { ClearFatalLockOnHost(sender, "client cinematic finished"); } } private unsafe void ReleaseFatalLock(ulong playerId) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } if (singleton.IsServer) { ClearFatalLockOnHost(playerId, "local cinematic finished"); } else if (singleton.IsListening && singleton.CustomMessagingManager != null) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1); try { singleton.CustomMessagingManager.SendNamedMessage("jin.sans.figurine.scrap.fatal_end.v1", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } } internal void Gui() { //IL_001b: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (!showFatalScreen && blastWhiteout <= 0.001f) { return; } int depth = GUI.depth; Color color = GUI.color; GUI.depth = -10000; GUI.color = Color.white; Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height); if (showFatalScreen) { GUI.DrawTexture(val, (Texture)(object)(((Object)(object)cutsceneBlack != (Object)null) ? cutsceneBlack : Texture2D.blackTexture), (ScaleMode)0); if (!isolatedBlasterCamera && (Object)(object)cutsceneTexture != (Object)null && (Object)(object)cutscenePlayer != (Object)null && cutscenePlayer.isPlaying) { if (blackRoomVideoOverlay) { float num = Mathf.Min((float)Screen.width * 0.57f, (float)Screen.height * 0.67f * 2.6815643f); float num2 = num / 2.6815643f; GUI.DrawTexture(new Rect(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2), (Texture)(object)cutsceneTexture, (ScaleMode)0); } else { GUI.DrawTexture(val, (Texture)(object)cutsceneTexture, (ScaleMode)2); } } } if (blastWhiteout > 0.001f) { if ((Object)(object)whiteoutPixel == (Object)null) { whiteoutPixel = new Texture2D(1, 1, (TextureFormat)4, false); whiteoutPixel.SetPixel(0, 0, Color.white); whiteoutPixel.Apply(); } GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(blastWhiteout)); GUI.DrawTexture(val, (Texture)(object)whiteoutPixel, (ScaleMode)0); } GUI.color = color; GUI.depth = depth; } private void EnsureScreen() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown if ((Object)(object)cutsceneBlack == (Object)null) { cutsceneBlack = new Texture2D(1, 1, (TextureFormat)4, false); cutsceneBlack.SetPixel(0, 0, Color.black); cutsceneBlack.Apply(); } if (!((Object)(object)cutsceneVideoObject == (Object)null)) { return; } cutsceneVideoObject = new GameObject("SansFatalVideoPlayer"); cutsceneAudio = cutsceneVideoObject.AddComponent<AudioSource>(); cutsceneAudio.playOnAwake = false; cutsceneAudio.spatialBlend = 0f; cutsceneAudio.volume = 1f; cutscenePlayer = cutsceneVideoObject.AddComponent<VideoPlayer>(); cutscenePlayer.playOnAwake = false; cutscenePlayer.isLooping = false; cutscenePlayer.source = (VideoSource)1; cutscenePlayer.renderMode = (VideoRenderMode)2; cutscenePlayer.audioOutputMode = (VideoAudioOutputMode)1; cutscenePlayer.controlledAudioTrackCount = 1; cutscenePlayer.waitForFirstFrame = true; cutscenePlayer.skipOnDrop = false; cutscenePlayer.aspectRatio = (VideoAspectRatio)3; VideoPlayer obj = cutscenePlayer; object obj2 = <>c.<>9__122_0; if (obj2 == null) { ErrorEventHandler val = delegate(VideoPlayer vp, string message) { Log.LogError((object)("Sans video error: " + message)); }; <>c.<>9__122_0 = val; obj2 = (object)val; } obj.errorReceived += (ErrorEventHandler)obj2; } private void ResizeVideoTarget(int width, int height) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown if (!((Object)(object)cutsceneTexture != (Object)null) || ((Texture)cutsceneTexture).width != width || ((Texture)cutsceneTexture).height != height) { if ((Object)(object)cutscenePlayer != (Object)null) { cutscenePlayer.targetTexture = null; } if ((Object)(object)cutsceneTexture != (Object)null) { cutsceneTexture.Release(); Object.Destroy((Object)(object)cutsceneTexture); } cutsceneTexture = new RenderTexture(width, height, 0, (RenderTextureFormat)0); ((Object)cutsceneTexture).name = "Sans video cinematic target"; cutsceneTexture.antiAliasing = 1; ((Texture)cutsceneTexture).filterMode = (FilterMode)1; cutsceneTexture.Create(); if ((Object)(object)cutscenePlayer != (Object)null) { cutscenePlayer.targetTexture = cutsceneTexture; } } } private IEnumerator PlayClip(string name, float duration) { EnsureScreen(); ResizeVideoTarget(1920, 716); string text = Path.Combine(Path.Combine(Path.GetDirectoryName(((object)this).GetType().Assembly.Location), "assets"), name); if (!File.Exists(text)) { Log.LogError((object)("Missing Sans cutscene clip: " + text)); yield return (object)new WaitForSecondsRealtime(duration); yield break; } cutscenePlayer.Stop(); cutscenePlayer.url = new Uri(text).AbsoluteUri; bool flag = false; try { cutscenePlayer.EnableAudioTrack((ushort)0, true); cutscenePlayer.SetTargetAudioSource((ushort)0, cutsceneAudio); cutscenePlayer.Prepare(); } catch (Exception ex) { Log.LogError((object)("Sans video preparation failed: " + ex)); flag = true; } if (flag) { yield return (object)new WaitForSecondsRealtime(duration); yield break; } float until = Time.realtimeSinceStartup + 6f; while (!cutscenePlayer.isPrepared && Time.realtimeSinceStartup < until) { yield return null; } if (!cutscenePlayer.isPrepared) { Log.LogError((object)("Sans video prepare timed out: " + name)); yield return (object)new WaitForSecondsRealtime(duration); yield break; } cutsceneAudio.volume = 1f; cutscenePlayer.Play(); Log.LogInfo((object)("Sans video playing: " + name)); float endAt = Time.realtimeSinceStartup + duration; while (Time.realtimeSinceStartup < endAt) { yield return null; } cutscenePlayer.Stop(); } private static void TintMaterial(Material material, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null) { return; } material.color = color; string[] array = new string[3] { "_BaseColor", "_UnlitColor", "_Color" }; foreach (string text in array) { if (material.HasProperty(text)) { material.SetColor(text, color); } } if (material.HasProperty("_EmissiveColor")) { material.SetColor("_EmissiveColor", color); } if (material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", color); } } private void SetInputFrozen(PlayerControllerB player, bool freeze, bool freezeLook) { if ((Object)(object)player == (Object)null) { return; } string[] array; if (freeze && !inputFreezeActive) { previousInputFlags.Clear(); array = new string[2] { "disableMoveInput", "disableLookInput" }; foreach (string text in array) { FieldInfo field = typeof(PlayerControllerB).GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(bool)) { previousInputFlags[text] = (bool)field.GetValue(player); } } inputFreezeActive = true; } array = new string[2] { "disableMoveInput", "disableLookInput" }; foreach (string text2 in array) { FieldInfo field2 = typeof(PlayerControllerB).GetField(text2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null || field2.FieldType != typeof(bool)) { continue; } try { bool value; if (freeze) { field2.SetValue(player, text2 == "disableMoveInput" || freezeLook); } else if (previousInputFlags.TryGetValue(text2, out value)) { field2.SetValue(player, value); } } catch (Exception ex) { Log.LogWarning((object)("Sans input flag error: " + ex.Message)); } } if (!freeze) { previousInputFlags.Clear(); inputFreezeActive = false; } } private void CreateBlastCurtain() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) DestroyBlastCurtain(); blastCurtainRoot = new GameObject("Sans BLACK cinematic overlay", new Type[2] { typeof(RectTransform), typeof(Canvas) }); ((Object)blastCurtainRoot).hideFlags = (HideFlags)52; blastCurtainCanvas = blastCurtainRoot.GetComponent<Canvas>(); blastCurtainCanvas.renderMode = (RenderMode)0; blastCurtainCanvas.overrideSorting = true; blastCurtainCanvas.sortingOrder = 30000; GameObject val = new GameObject("Full screen #000000", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage) }); val.transform.SetParent(blastCurtainRoot.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; RawImage component2 = val.GetComponent<RawImage>(); component2.texture = (Texture)(object)Texture2D.whiteTexture; ((Graphic)component2).color = Color.black; ((Graphic)component2).raycastTarget = false; GameObject val2 = new GameObject("Original blasters rendered over black", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(RawImage) }); val2.transform.SetParent(blastCurtainRoot.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; blastCurtainImage = val2.GetComponent<RawImage>(); blastCurtainImage.texture = (Texture)(object)blasterFrameTexture; ((Graphic)blastCurtainImage).color = Color.white; ((Graphic)blastCurtainImage).raycastTarget = false; ((Behaviour)blastCurtainImage).enabled = (Object)(object)blasterFrameTexture != (Object)null; } private void DestroyBlastCurtain() { blastCurtainImage = null; blastCurtainCanvas = null; if ((Object)(object)blastCurtainRoot != (Object)null) { Object.Destroy((Object)(object)blastCurtainRoot); } blastCurtainRoot = null; } private static void ConfigureHdrpBlackClear(GameObject cameraObject) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("UnityEngine.Rendering.HighDefinition.HDAdditionalCameraData", throwOnError: false); if (type == null) { continue; } Component component = cameraObject.GetComponent(type); if (!((Object)(object)component == (Object)null)) { PropertyInfo property = type.GetProperty("clearColorMode", BindingFlags.Instance | BindingFlags.Public); if (property != null && property.CanWrite && property.PropertyType.IsEnum) { object value = Enum.Parse(property.PropertyType, "Color"); property.SetValue(component, value, null); } PropertyInfo property2 = type.GetProperty("backgroundColorHDR", BindingFlags.Instance | BindingFlags.Public); if (property2 != null && property2.CanWrite) { property2.SetValue(component, Color.black, null); } PropertyInfo property3 = type.GetProperty("volumeLayerMask", BindingFlags.Instance | BindingFlags.Public); if (property3 != null && property3.CanWrite) { property3.SetValue(component, LayerMask.op_Implicit(0), null); } } break; } } catch (Exception ex) { Log.LogWarning((object)("Sans HDRP clear fallback: " + ex.Message)); } } private void StartBlasterBlackBackground(PlayerControllerB victim) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)victim == (Object)null || (Object)(object)victim.gameplayCamera == (Object)null) { return; } RestoreBlasterCamera(); Camera gameplayCamera = victim.gameplayCamera; try { CreateBlastCurtain(); } catch (Exception ex) { Log.LogError((object)("Sans black curtain creation failed: " + ex)); } try { int num = Mathf.Max(320, Screen.width); int num2 = Mathf.Max(240, Screen.height); blasterFrameTexture = new RenderTexture(num, num2, 24, (RenderTextureFormat)0); ((Object)blasterFrameTexture).name = "Sans original GLB and pure white blast only"; blasterFrameTexture.antiAliasing = 1; ((Texture)blasterFrameTexture).filterMode = (FilterMode)1; blasterFrameTexture.Create(); isolatedBlasterCameraRig = new GameObject("Sans independent blaster view"); isolatedBlasterCameraRig.transform.SetParent(((Component)gameplayCamera).transform, false); isolatedBlasterCameraRig.transform.localPosition = Vector3.zero; isolatedBlasterCameraRig.transform.localRotation = Quaternion.identity; Camera val = isolatedBlasterCameraRig.AddComponent<Camera>(); val.CopyFrom(gameplayCamera); val.cullingMask = 1073741824; val.clearFlags = (CameraClearFlags)2; val.backgroundColor = Color.black; val.nearClipPlane = 0.015f; val.farClipPlane = 60f; val.aspect = (float)num / (float)num2; val.allowHDR = false; val.allowMSAA = false; val.useOcclusionCulling = false; val.targetTexture = blasterFrameTexture; try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("UnityEngine.Rendering.HighDefinition.HDAdditionalCameraData", throwOnError: false); if (type != null) { break; } } if (type != null && (Object)(object)isolatedBlasterCameraRig.GetComponent(type) == (Object)null) { isolatedBlasterCameraRig.AddComponent(type); } } catch (Exception ex2) { Log.LogWarning((object)("Sans HDRP camera data fallback: " + ex2.Message)); } ConfigureHdrpBlackClear(isolatedBlasterCameraRig); ((Behaviour)val).enabled = true; cinematicCamera = val; isolatedBlasterCamera = true; if ((Object)(object)blastCurtainImage != (Object)null) { blastCurtainImage.texture = (Texture)(object)blasterFrameTexture; } blackRoomVideoOverlay = false; showFatalScreen = true; Log.LogInfo((object)$"Sans v24: independent blaster camera {num}x{num2}; fullscreen #000000 background remains throughout blast."); } catch (Exception ex3) { Log.LogError((object)("Sans independent blaster camera creation failed: " + ex3)); RestoreBlasterCamera(); try { CreateBlastCurtain(); } catch (Exception ex4) { Log.LogError((object)("Sans black-only fallback failed: " + ex4)); } } } private void RestoreBlasterCamera() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = (((Object)(object)thirdPersonTarget != (Object)null) ? thirdPersonTarget : deferredBodyRestorePlayer); if ((Object)(object)val != (Object)null && val.isPlayerDead) { deferredBodyRestorePlayer = val; } else { foreach (KeyValuePair<Renderer, ShadowCastingMode> originalPlayerShadowState in originalPlayerShadowStates) { if ((Object)(object)originalPlayerShadowState.Key != (Object)null) { originalPlayerShadowState.Key.shadowCastingMode = originalPlayerShadowState.Value; } } originalPlayerShadowStates.Clear(); foreach (KeyValuePair<Renderer, bool> originalPlayerForceRenderingState in originalPlayerForceRenderingStates) { if ((Object)(object)originalPlayerForceRenderingState.Key != (Object)null) { originalPlayerForceRenderingState.Key.forceRenderingOff = originalPlayerForceRenderingState.Value; } } originalPlayerForceRenderingStates.Clear(); foreach (KeyValuePair<Renderer, bool> originalPlayerRendererState in originalPlayerRendererStates) { if ((Object)(object)originalPlayerRendererState.Key != (Object)null) { originalPlayerRendererState.Key.enabled = originalPlayerRendererState.Value; } } originalPlayerRendererStates.Clear(); foreach (KeyValuePair<GameObject, bool> originalPlayerObjectState in originalPlayerObjectStates) { if ((Object)(object)originalPlayerObjectState.Key != (Object)null) { originalPlayerObjectState.Key.SetActive(originalPlayerObjectState.Value); } } originalPlayerObjectStates.Clear(); deferredBodyRestorePlayer = null; } thirdPersonTarget = null; if ((Object)(object)cinematicCamera != (Object)null) { cinematicCamera.targetTexture = null; ((Behaviour)cinematicCamera).enabled = false; } cinematicCamera = null; isolatedBlasterCamera = false; if ((Object)(object)isolatedBlasterCameraRig != (Object)null) { Object.Destroy((Object)(object)isolatedBlasterCameraRig); isolatedBlasterCameraRig = null; } DestroyBlastCurtain(); if ((Object)(object)blasterFrameTexture != (Object)null) { blasterFrameTexture.Release(); Object.Destroy((Object)(object)blasterFrameTexture); blasterFrameTexture = null; } } private void KeepThirdPersonBodyVisible(PlayerControllerB victim) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)victim == (Object)null || victim.isPlayerDead) { return; } string[] array = new string[4] { "thisPlayerModel", "thisPlayerModelLOD1", "thisPlayerModelLOD2", "thisPlayerModelArms" }; foreach (string text in array) { FieldInfo field = typeof(PlayerControllerB).GetField(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Renderer val = (Renderer)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { continue; } if (!originalPlayerRendererStates.ContainsKey(val)) { originalPlayerRendererStates.Add(val, val.enabled); } if (!originalPlayerShadowStates.ContainsKey(val)) { originalPlayerShadowStates.Add(val, val.shadowCastingMode); } if (!originalPlayerForceRenderingStates.ContainsKey(val)) { originalPlayerForceRenderingStates.Add(val, val.forceRenderingOff); } if (text == "thisPlayerModel") { GameObject gameObject = ((Component)val).gameObject; if (!originalPlayerObjectStates.ContainsKey(gameObject)) { originalPlayerObjectStates.Add(gameObject, gameObject.activeSelf); } if (!(originalPlayerForceRenderingStates.TryGetValue(val, out var value) && value)) { if (!gameObject.activeSelf) { gameObject.SetActive(true); } val.forceRenderingOff = false; val.shadowCastingMode = (ShadowCastingMode)1; val.enabled = true; } } else { val.enabled = false; } } HideForThirdPerson(((Object)(object)victim.gameplayCamera != (Object)null) ? ((Component)victim.gameplayCamera).transform : null); GameObject val2 = GameObject.Find("PlayerHUDHelmetModel"); if ((Object)(object)val2 != (Object)null) { HideForThirdPerson(val2.transform); } bool value2 = default(bool); if ((Object)(object)victim.thisPlayerModel != (Object)null && originalPlayerForceRenderingStates.TryGetValue((Renderer)(object)victim.thisPlayerModel, out value2) && value2) { array = new string[3] { "headCostumeContainer", "headCostumeContainerLocal", "lowerTorsoCostumeContainer" }; foreach (string name in array) { FieldInfo field2 = typeof(PlayerControllerB).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Transform root = (Transform)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null); HideForThirdPerson(root); } } } private void HideForThirdPerson(Transform root) { if ((Object)(object)root == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { if (!originalPlayerForceRenderingStates.ContainsKey(val)) { originalPlayerForceRenderingStates.Add(val, val.forceRenderingOff); } val.forceRenderingOff = true; } } } private void StartThirdPersonBlastCamera(PlayerControllerB victim) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) RestoreBlasterCamera(); if ((Object)(object)victim == (Object)null || (Object)(object)victim.gameplayCamera == (Object)null) { return; } try { int num = Mathf.Max(640, Screen.width); int num2 = Mathf.Max(360, Screen.height); blasterFrameTexture = new RenderTexture(num, num2, 24, (RenderTextureFormat)0); ((Object)blasterFrameTexture).name = "Sans third-person undistorted scene"; ((Texture)blasterFrameTexture).filterMode = (FilterMode)1; blasterFrameTexture.Create(); isolatedBlasterCameraRig = new GameObject("Sans temporary third person camera"); Camera val = isolatedBlasterCameraRig.AddComponent<Camera>(); val.CopyFrom(victim.gameplayCamera); val.targetTexture = blasterFrameTexture; val.nearClipPlane = 0.04f; val.farClipPlane = Mathf.Max(75f, victim.gameplayCamera.farClipPlane); val.orthographic = true; val.orthographicSize = 2.45f; val.usePhysicalProperties = false; val.lensShift = Vector2.zero; val.aspect = (float)num / (float)num2; val.ResetProjectionMatrix(); val.cullingMask |= 0x40000000; val.cullingMask |= 1 << ((Component)victim).gameObject.layer; val.useOcclusionCulling = false; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("UnityEngine.Rendering.HighDefinition.HDAdditionalCameraData", throwOnError: false); if (!(type == null)) { if ((Object)(object)isolatedBlasterCameraRig.GetComponent(type) == (Object)null) { isolatedBlasterCameraRig.AddComponent(type); } break; } } } catch (Exception ex) { Log.LogWarning((object)("Sans third-person HDRP setup: " + ex.Message)); } string[] array = new string[3] { "thisPlayerModel", "thisPlayerModelLOD1", "thisPlayerModelLOD2" }; foreach (string name in array) { FieldInfo field = typeof(PlayerControllerB).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Renderer val2 = (Renderer)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 != (Object)null) { val.cullingMask |= 1 << ((Component)val2).gameObject.layer; } } KeepThirdPersonBodyVisible(victim); FieldInfo field2 = typeof(PlayerControllerB).GetField("thisPlayerModel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Renderer val3 = (Renderer)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val3 != (Object)null) { Log.LogInfo((object)$"Sans third-person full body: active={((Component)val3).gameObject.activeInHierarchy}, enabled={val3.enabled}, shadows={val3.shadowCastingMode}, forceOff={val3.forceRenderingOff}, layer={((Component)val3).gameObject.layer}"); } else { Log.LogWarning((object)"Sans third-person body renderer not found; provide the BepInEx log if the character is invisible."); } SkinnedMeshRenderer[] componentsInChildren = ((Component)victim).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val4 in componentsInChildren) { val.cullingMask |= 1 << ((Component)val4).gameObject.layer; } if ((Object)(object)victim.thisPlayerModelArms != (Object)null) { int layer = ((Component)victim.thisPlayerModelArms).gameObject.layer; bool flag = false; array = new string[3] { "thisPlayerModel", "thisPlayerModelLOD1", "thisPlayerModelLOD2" }; foreach (string name2 in array) { FieldInfo field3 = typeof(PlayerControllerB).GetField(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Renderer val5 = (Renderer)((field3 != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val5 != (Object)null && ((Component)val5).gameObject.layer == layer) { flag = true; } } if (!flag) { val.cullingMask &= ~(1 << layer); } } thirdPersonTarget = victim; Vector3 val6 = Vector3.ProjectOnPlane(((Component)victim).transform.forward, Vector3.up); cinematicForward = ((Vector3)(ref val6)).normalized; if (((Vector3)(ref cinematicForward)).sqrMagnitude < 0.01f) { cinematicForward = Vector3.forward; } cinematicCamera = val; PositionThirdPersonCamera(); ((Behaviour)val).enabled = true; isolatedBlasterCamera = true; CreateBlastCurtain(); if ((Object)(object)blastCurtainImage != (Object)null) { blastCurtainImage.texture = (Texture)(object)blasterFrameTexture; } showFatalScreen = false; Log.LogInfo((object)"Sans v33 camera: local full body enabled with ShadowCastingMode.On, FPS arms and extra LODs hidden during blast."); } catch (Exception ex2) { Log.LogError((object)("Sans third-person camera failed, game view fallback: " + ex2)); RestoreBlasterCamera(); showFatalScreen = false; } } private void PositionThirdPersonCamera() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004e: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_012f: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)thirdPersonTarget == (Object)null || (Object)(object)cinematicCamera == (Object)null) { return; } Vector3 val = ((Component)thirdPersonTarget).transform.position + Vector3.up * 1.05f; Vector3 normalized = ((Vector3)(ref cinematicForward)).normalized; Vector3 val2 = Vector3.Cross(Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; Vector3[] array = (Vector3[])(object)new Vector3[8] { -normalized + normalized2 * 0.35f, -normalized - normalized2 * 0.35f, normalized2, -normalized2, normalized + normalized2 * 0.35f, normalized - normalized2 * 0.35f, -normalized, normalized }; Vector3 val3 = ((Vector3)(ref array[0])).normalized; float num = -999f; float num2 = 1f; for (int i = 0; i < array.Length; i++) { val2 = ((Vector3)(ref array[i])).normalized + Vector3.up * 0.12f; Vector3 normalized3 = ((Vector3)(ref val2)).normalized; float num3 = 3f; RaycastHit[] array2 = Physics.SphereCastAll(val, 0.2f, normalized3, num3, -1073741825, (QueryTriggerInteraction)1); for (int j = 0; j < array2.Length; j++) { RaycastHit val4 = array2[j]; if (!((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)thirdPersonTarget).transform) && !((Object)(object)((RaycastHit)(ref val4)).collider.attachedRigidbody != (Object)null) && ((RaycastHit)(ref val4)).distance >= 0.12f) { num3 = Mathf.Min(num3, ((RaycastHit)(ref val4)).distance - 0.14f); } } float num4 = num3 - (float)i * 0.045f; if (num4 > num) { num = num4; val3 = normalized3; num2 = num3; } } float num5 = Mathf.Clamp(num2, 0.65f, 2.5f); Vector3 val5 = val + val3 * num5; ((Component)cinematicCamera).transform.SetPositionAndRotation(val5, Quaternion.LookRotation(val - val5, Vector3.up)); } private void HideLiveVictimBodyForDeath(PlayerControllerB victim) { if ((Object)(object)victim == (Object)null) { return; } string[] array = new string[4] { "thisPlayerModel", "thisPlayerModelLOD1", "thisPlayerModelLOD2", "thisPlayerModelArms" }; foreach (string name in array) { FieldInfo field = typeof(PlayerControllerB).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Renderer val = (Renderer)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { val.enabled = false; } } } private GameObject MakeGasterBlaster(int index) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown GameObject val = new GameObject("Sans original Gaster Blaster " + (index + 1)); val.layer = 0; val.transform.localScale = Vector3.zero; if (gasterModelParts == null || gasterModelParts.Length == 0) { Log.LogError((object)"Sans: no converted source GLB parts available"); return val; } for (int i = 0; i < gasterModelParts.Length; i++) { GameObject val2 = new GameObject("Original GLB part " + i); val2.layer = 0; val2.transform.SetParent(val.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = gasterModelParts[i].Mesh; Shader val3 = Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Texture") ?? Shader.Find("Standard"); if (!((Object)(object)val3 == (Object)null)) { Material val4 = new Material(val3); Texture2D texture = gasterModelParts[i].Texture; if (val4.HasProperty("_UnlitColorMap")) { val4.SetTexture("_UnlitColorMap", (Texture)(object)texture); } if (val4.HasProperty("_BaseColorMap")) { val4.SetTexture("_BaseColorMap", (Texture)(object)texture); } if (val4.HasProperty("_MainTex")) { val4.SetTexture("_MainTex", (Texture)(object)texture); } val4.mainTexture = (Texture)(object)texture; val4.EnableKeyword("_UNLITCOLORMAP"); if (val4.HasProperty("_CullMode")) { val4.SetFloat("_CullMode", 0f); } if (val4.HasProperty("_Cull")) { val4.SetFloat("_Cull", 0f); } if (val4.HasProperty("_DoubleSidedEnable")) { val4.SetFloat("_DoubleSidedEnable", 1f); } ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = val4; if (i == 0 && index >= 0 && index < blasterJaws.Length) { blasterJaws[index] = val2.transform; } } } return val; } private GameObject NewBeamPart(string name, Color color, bool sphere = false) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)((!sphere) ? 2 : 0)); ((Object)val).name = name; val.layer = 0; Collider component = val.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Shader val2 = Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); if ((Object)(object)val2 != (Object)null) { Material val3 = new Material(val2); TintMaterial(val3, color); if (val3.HasProperty("_EmissiveColor")) { val3.SetColor("_EmissiveColor", color * 3f); } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", color * 3f); } ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = val3; } val.SetActive(false); return val; } private void SpawnBlasters(PlayerControllerB victim) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_013a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)victim == (Object)null)) { for (int i = 0; i < 5; i++) { blasterJaws[i] = null; blasterHeads[i] = MakeGasterBlaster(i); blasterChargeLights[i] = NewBeamPart("Sans Gaster charging orb " + i, Color.white, sphere: true); blasterChargeLights[i].transform.SetParent(blasterHeads[i].transform, false); blasterChargeLights[i].transform.localPosition = new Vector3(0f, -0.3f, -0.75f); blasterOuterBeams[i] = NewBeamPart("Sans beam outer " + i, Color.white); blasterBeams[i] = NewBeamPart("Sans beam white " + i, Color.white); blasterInnerBeams[i] = NewBeamPart("Sans beam hot core " + i, Color.white); blasterBeamTips[i] = NewBeamPart("Sans beam tip " + i, Color.white, sphere: true); } blastImpact = NewBeamPart("Sans five-beam impact fills target body", Color.white, sphere: true); blastImpact.SetActive(false); Log.LogInfo((object)"Sans spawned five Gaster Blasters in SKY/FLOOR/SKY/FLOOR/SKY formation; five lasers fire together after the 2s charge."); } } private static void ShapeBeam(GameObject beam, Vector3 start, Vector3 direction, float length, float diameter) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)beam == (Object)null)) { beam.SetActive(length > 0.01f); if (!(length <= 0.01f)) { beam.transform.position = start + direction * (length * 0.5f); beam.transform.rotation = Quaternion.FromToRotation(Vector3.up, direction); beam.transform.localScale = new Vector3(diameter, length * 0.5f, diameter); } } } private void AnimateBlasters(PlayerControllerB victim, float elapsed) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_005b: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_008d: 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_0093: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0515: 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) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)victim == (Object)null) { return; } Vector3 val = ((Component)victim).transform.position + Vector3.up * 1.25f; Vector3 val2 = (((Object)(object)cinematicCamera != (Object)null) ? Vector3.ProjectOnPlane(((Component)cinematicCamera).transform.position - val, Vector3.up) : (-cinematicForward)); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = -cinematicForward; } Vector3 val3 = -((Vector3)(ref val2)).normalized; Vector3 val4 = Vector3.Cross(Vector3.up, val3); Vector3 normalized = ((Vector3)(ref val4)).normalized; float num = elapsed - 2f; bool flag = num >= 0f && num <= 2.03f; float num2 = (flag ? Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num / 0.11f)) : 0f); for (int i = 0; i < 5; i++) { GameObject val5 = blasterHeads[i]; if ((Object)(object)val5 == (Object)null) { continue; } bool flag2 = i % 2 == 0; float num3 = (float)i * 0.18f; float num4 = Mathf.Clamp01((elapsed - num3) / 0.48f); float num5 = num4 * num4 * (3f - 2f * num4); Vector3 val6 = val + val3 * 3.85f + normalized * ((float)(i - 2) * 1.16f) + Vector3.up * (flag2 ? 1.12f : (-0.7f)); Vector3 val7 = Vector3.up * (flag2 ? 3.3f : (-2.55f)); Vector3 val8 = Vector3.Lerp(val6 + val7, val6, num5); val5.transform.position = val8; val4 = val - val8; Vector3 normalized2 = ((Vector3)(ref val4)).normalized; val5.transform.rotation = Quaternion.LookRotation(-normalized2, Vector3.up); val5.transform.localScale = Vector3.one * (0.94f * Mathf.SmoothStep(0f, 1f, num4)); float num6 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((elapsed - num3 - 0.48f) / 0.4f)); Transform val9 = blasterJaws[i]; if ((Object)(obje
plugins/UnderCompany/UnderCompany.dll
Decompiled 5 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; 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: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } [BepInPlugin("UnderCompany", "UnderCompany", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class UnderCompanyPlugin : BaseUnityPlugin { private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.Bind<string>("1. Language", "Language", "Auto", new ConfigDescription("Language for Flowey, Muffet, Sans and Napstablook (applied the next time the game starts). Auto = Korean when Windows is Korean.\n언어 설정: 플라위·머펫·샌즈·냅스타블룩 전체에 적용 (게임을 다시 켜면 적용). Auto = 윈도우가 한국어면 한국어.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Auto", "Korean", "English" }), Array.Empty<object>())); ConfigEntry<bool> floweyOn = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Flowey", "Enabled", true, "Flowey scrap can spawn on moons. / 플라위 스크랩 등장 켜기·끄기"); ConfigEntry<int> floweyW = ((BaseUnityPlugin)this).Config.Bind<int>("2. Flowey", "SpawnWeight", 5, new ConfigDescription("Scrap spawn weight (higher = more often, 0 = never). Default 5. / 스크랩 등장 가중치 (높을수록 자주, 0 = 안 나옴). 기본 5", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ConfigEntry<bool> sansOn = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Sans", "Enabled", true, "Sans Figurine scrap can spawn on moons. / 샌즈 피규어 스크랩 등장 켜기·끄기"); ConfigEntry<int> sansW = ((BaseUnityPlugin)this).Config.Bind<int>("3. Sans", "SpawnWeight", 10, new ConfigDescription("Scrap spawn weight (higher = more often, 0 = never). Default 10. / 스크랩 등장 가중치 (높을수록 자주, 0 = 안 나옴). 기본 10", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ConfigEntry<bool> muffetOn = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Muffet", "Enabled", true, "Muffet can appear when you land. / 머펫 등장 켜기·끄기"); ConfigEntry<int> muffetP = ((BaseUnityPlugin)this).Config.Bind<int>("4. Muffet", "SpawnChancePercent", 12, new ConfigDescription("Chance per landing that Muffet can appear (%). Default 12. / 착륙할 때마다 머펫이 나올 확률(%). 기본 12", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); ConfigEntry<bool> napOn = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Napstablook", "Enabled", true, "Napstablook can appear when you land. / 냅스타블룩 등장 켜기·끄기"); ConfigEntry<int> napP = ((BaseUnityPlugin)this).Config.Bind<int>("5. Napstablook", "SpawnChancePercent", 15, new ConfigDescription("Chance per landing that Napstablook appears (%). Default 15. / 착륙할 때마다 냅스타블룩이 나올 확률(%). 기본 15", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); Try("Flowey", delegate { SetScrapWeight("FLOWEY", floweyOn.Value ? floweyW.Value : 0); }); Try("Sans", delegate { SetScrapWeight("SansFigurine", sansOn.Value ? sansW.Value : 0); }); Try("Muffet", delegate { SetPluginConfig("hihi__h.Muffet", "Spawn", "RoundChancePercent", muffetOn.Value ? muffetP.Value : 0); }); Try("Napstablook", delegate { SetPluginConfig("hihi__h.NapstablookMonster", "Spawn", "EnableNaturalSpawn", napOn.Value); SetPluginConfig("hihi__h.NapstablookMonster", "Spawn", "LandingChancePercent", napP.Value); }); } private void Try(string what, Action a) { try { a(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)(what + " setting not applied: " + ex.Message)); } } private void SetScrapWeight(string modName, int weight) { Type? type = Type.GetType("LethalLib.Modules.Items, LethalLib"); if (type == null) { throw new Exception("LethalLib not found"); } IEnumerable obj = type.GetField("scrapItems", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(null) as IEnumerable; int num = 0; foreach (object item in obj) { Type type2 = item.GetType(); if (type2.GetField("modName")?.GetValue(item) as string != modName) { continue; } type2.GetField("rarity")?.SetValue(item, weight); string[] array = new string[2] { "levelRarities", "customLevelRarities" }; foreach (string name in array) { if (!(type2.GetField(name)?.GetValue(item) is IDictionary dictionary)) { continue; } foreach (object item2 in new List<object>(Keys(dictionary))) { dictionary[item2] = weight; } } num++; } ((BaseUnityPlugin)this).Logger.LogInfo((object)(modName + " scrap weight = " + weight + " (" + num + " item)")); } private static IEnumerable<object> Keys(IDictionary d) { foreach (object key in d.Keys) { yield return key; } } private void SetPluginConfig<T>(string guid, string section, string key, T value) { if (!Chainloader.PluginInfos.TryGetValue(guid, out var value2) || (Object)(object)value2.Instance == (Object)null) { throw new Exception(guid + " not loaded"); } ConfigEntry<T> val = default(ConfigEntry<T>); if (!value2.Instance.Config.TryGetEntry<T>(section, key, ref val)) { throw new Exception(section + "." + key + " not found"); } val.Value = value; ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[7] { guid, " ", section, ".", key, " = ", null }; T val2 = value; obj[6] = val2?.ToString(); logger.LogInfo((object)string.Concat(obj)); } }