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 JOJOPlush v1.2.0
com.github.zehsteam.JOJOPlush.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EasyTextEffects.Editor.MyBoxCopy.Extensions; using FNV; using FNV.NewFolder; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLevelLoader; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Steamworks; using Unity.Netcode; using UnityEngine; using com.github.zehsteam.JOJOPlush.Dependencies; using com.github.zehsteam.JOJOPlush.Dependencies.FalloutNewVegas; using com.github.zehsteam.JOJOPlush.Dependencies.FalloutNewVegas.Patches; using com.github.zehsteam.JOJOPlush.Dependencies.LethalLevelLoaderMod; using com.github.zehsteam.JOJOPlush.Dependencies.LethalLevelLoaderMod.Patches; using com.github.zehsteam.JOJOPlush.Extensions; using com.github.zehsteam.JOJOPlush.Helpers; using com.github.zehsteam.JOJOPlush.Managers; using com.github.zehsteam.JOJOPlush.MonoBehaviours; using com.github.zehsteam.JOJOPlush.NetcodePatcher; using com.github.zehsteam.JOJOPlush.Objects; using com.github.zehsteam.JOJOPlush.Patches; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("FNV")] [assembly: IgnoresAccessChecksTo("LethalLevelLoader")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("[v73+] Adds a JOJOsaysbreee plushie scrap item and other various things related to her channel.")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+0b785ded8f3e0271a33d9543f9d0a4a4bfcf9f0b")] [assembly: AssemblyProduct("JOJOPlush")] [assembly: AssemblyTitle("com.github.zehsteam.JOJOPlush")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace com.github.zehsteam.JOJOPlush { internal static class Assets { public static AssetBundle AssetBundle { get; private set; } public static GameObject PluginNetworkHandlerPrefab { get; private set; } public static Item JOJOPlush { get; private set; } public static AudioClip DrPhilOpenTheDoorSFX { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = "jojoplush_assets"; string text2 = Path.Combine(directoryName, text); if (!File.Exists(text2)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle val = AssetBundle.LoadFromFile(text2); if ((Object)(object)val == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); } else { OnAssetBundleLoaded(val); } } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { AssetBundle = assetBundle; PluginNetworkHandlerPrefab = LoadAsset<GameObject>("PluginNetworkHandler", assetBundle); PluginNetworkHandlerPrefab.AddComponent<PluginNetworkHandler>(); JOJOPlush = LoadAsset<Item>("JOJOPlush", assetBundle); DrPhilOpenTheDoorSFX = LoadAsset<AudioClip>("DrPhilOpenTheDoorSFX", assetBundle); } private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset<T>(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset<T>(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data, bool extended = false) { Log((LogLevel)32, data, extended); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled()) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } public static bool IsExtendedLoggingEnabled() { return ConfigManager.ExtendedLogging?.Value ?? false; } } [BepInPlugin("com.github.zehsteam.JOJOPlush", "JOJOPlush", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.JOJOPlush"); public static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.JOJOPlush")); Logger.LogInfo("JOJOPlush has awoken!"); _harmony.PatchAll(typeof(GameNetworkManager_Patches)); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(PlayerControllerB_Patches)); _harmony.PatchAll(typeof(GrabbableObject_Patches)); Assets.Load(); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); if (FalloutNewVegasProxy.IsModInstalled) { FalloutNewVegasProxy.PatchAll(_harmony); } if (LethalLevelLoaderProxy.IsModInstalled) { LethalLevelLoaderProxy.PatchAll(_harmony); } RegisterScrapItems(); NetcodePatcherAwake(); } private void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Type[] types = executingAssembly.GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message)); } } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message)); } } } } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message)); } } private void RegisterScrapItems() { ItemHelper.RegisterScrap(ConfigManager.JOJOPlush); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.JOJOPlush"; public const string PLUGIN_NAME = "JOJOPlush"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace com.github.zehsteam.JOJOPlush.Patches { [HarmonyPatch(typeof(AudioReverbTrigger))] internal static class AudioReverbTrigger_Patches { [HarmonyPatch("ChangeAudioReverbForPlayer")] [HarmonyPrefix] private static bool ChangeAudioReverbForPlayer_Patch(AudioReverbTrigger __instance, PlayerControllerB pScript) { FixAudioChanges(__instance); try { return ChangeAudioReverbForPlayer(__instance, pScript); } catch (Exception arg) { string hierarchyPath = ((Component)__instance).transform.GetHierarchyPath(); Logger.LogError($"[AudioReverbTrigger_Patches] ChangeAudioReverbForPlayer_Patch: AudioReverbTrigger \"{hierarchyPath}\": {arg}"); } return false; } private static bool ChangeAudioReverbForPlayer(AudioReverbTrigger __instance, PlayerControllerB pScript) { //IL_010d: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Invalid comparison between Unknown and I4 //IL_026c: Unknown result type (might be due to invalid IL or missing references) __instance.playerScript = pScript; if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)__instance.playerScript.currentAudioTrigger == (Object)(object)__instance || !__instance.playerScript.isPlayerControlled) { return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null) { Debug.Log((object)"Network manager is null"); } if (__instance.usePreset != -1) { AudioReverbPresets val = Object.FindObjectOfType<AudioReverbPresets>(); if ((Object)(object)val != (Object)null) { if (val.audioPresets.Length <= __instance.usePreset) { Debug.LogError((object)("The audio preset set by " + ((Object)((Component)__instance).gameObject).name + " is not one allowed by the audioreverbpresets in the scene.")); } else if (val.audioPresets[__instance.usePreset].usePreset != -1) { Debug.LogError((object)"Audio preset AudioReverbTrigger is set to call another audio preset which would crash!"); } else { val.audioPresets[__instance.usePreset].ChangeAudioReverbForPlayer(pScript); } return false; } } if ((Object)(object)__instance.reverbPreset != (Object)null) { __instance.playerScript.reverbPreset = __instance.reverbPreset; } if (__instance.elevatorTriggerForProps) { if (__instance.setInElevatorTrigger) { Bounds bounds = StartOfRound.Instance.shipBounds.bounds; if (!((Bounds)(ref bounds)).Contains(((Component)__instance.playerScript).transform.position)) { goto IL_01bd; } } if ((Object)(object)__instance.playerScript.currentlyHeldObjectServer != (Object)null && __instance.playerScript.isHoldingObject) { __instance.playerScript.SetItemInElevator(__instance.isShipRoom, __instance.setInElevatorTrigger, __instance.playerScript.currentlyHeldObjectServer); } if (__instance.playerScript.playersManager.shipDoorsEnabled || __instance.setInElevatorTrigger) { __instance.playerScript.isInElevator = __instance.setInElevatorTrigger; __instance.playerScript.isInHangarShipRoom = __instance.isShipRoom; } __instance.playerScript.playersManager.SetPlayerSafeInShip(); } goto IL_01bd; IL_01bd: if ((Object)(object)__instance.playerScript != (Object)(object)GameNetworkManager.Instance.localPlayerController) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)(object)__instance.playerScript) { __instance.playerScript.currentAudioTrigger = __instance; return false; } __instance.spectatedClientTriggered = true; } else { __instance.spectatedClientTriggered = false; } if (__instance.disableAllWeather) { TimeOfDay.Instance.DisableAllWeather(false); } else { if (__instance.weatherEffect != -1) { TimeOfDay.Instance.effects[__instance.weatherEffect].effectEnabled = __instance.effectEnabled; } if (__instance.enableCurrentLevelWeather && (int)TimeOfDay.Instance.currentLevelWeather != -1) { TimeOfDay.Instance.effects[TimeOfDay.Instance.currentLevelWeather].effectEnabled = true; } } if (__instance.setInsideAtmosphere) { TimeOfDay.Instance.insideLighting = __instance.insideLighting; } PlayerControllerB playerScript = __instance.playerScript; __instance.playerScript = GameNetworkManager.Instance.localPlayerController; for (int i = 0; i < __instance.audioChanges.Length; i++) { AudioSource audio = __instance.audioChanges[i].audio; if (__instance.audioChanges[i].stopAudio) { if (audio != null) { audio.Stop(); } continue; } if ((Object)(object)__instance.audioChanges[i].changeToClip != (Object)null && (Object)(object)((audio != null) ? audio.clip : null) != (Object)(object)__instance.audioChanges[i].changeToClip) { bool flag = false; if (audio != null && audio.isPlaying) { flag = true; } if (audio != null) { audio.clip = __instance.audioChanges[i].changeToClip; } if (flag && audio != null) { audio.Play(); } } else { if (__instance.audioChanges[i] == null) { Logger.LogError($"[AudioReverbTrigger_Patches] ChangeAudioReverbForPlayer: audioChanges[{i}] is null!"); } if ((Object)(object)audio == (Object)null) { Logger.LogError($"[AudioReverbTrigger_Patches] ChangeAudioReverbForPlayer: audioChanges[{i}].audio is null!"); } if ((Object)(object)__instance.audioChanges[i].changeToClip == (Object)null && audio != null && !audio.isPlaying && !__instance.audioChanges[i].changeAudioVolume && audio != null) { audio.Play(); } } if (__instance.audioChanges[i].changeAudioVolume && (Object)(object)__instance.playerScript.currentAudioTrigger != (Object)(object)__instance) { if (__instance.playerScript.audioCoroutines.TryGetValue(audio, out var value)) { value.StopAudioCoroutine(audio); IEnumerator enumerator = __instance.changeVolume(audio, __instance.audioChanges[i].audioVolume); ((MonoBehaviour)__instance).StartCoroutine(enumerator); } else { IEnumerator enumerator2 = __instance.changeVolume(audio, __instance.audioChanges[i].audioVolume); ((MonoBehaviour)__instance).StartCoroutine(enumerator2); __instance.playerScript.audioCoroutines.Add(audio, __instance); __instance.playerScript.audioCoroutines2.Add(audio, enumerator2); } } } if (__instance.spectatedClientTriggered) { playerScript.currentAudioTrigger = __instance; } __instance.playerScript.currentAudioTrigger = __instance; return false; } public static void FixAudioChanges(AudioReverbTrigger audioReverbTrigger) { if (FixAudioChangesForWindTrigger(audioReverbTrigger)) { return; } switchToAudio[] audioChanges = audioReverbTrigger.audioChanges; if (audioChanges == null || audioChanges.Length == 0) { return; } for (int i = 0; i < audioChanges.Length; i++) { switchToAudio val = audioChanges[i]; string hierarchyPath = ((Component)audioReverbTrigger).transform.GetHierarchyPath(); if (val == null) { Logger.LogWarning("[AudioReverbTrigger_Patches] ChangeAudioReverbForPlayer_Patch: AudioReverbTrigger \"" + hierarchyPath + "\" has a null AudioChange entry."); } else if ((Object)(object)val.audio == (Object)null) { Logger.LogWarning($"[AudioReverbTrigger_Patches] ChangeAudioReverbForPlayer_Patch: AudioReverbTrigger \"{hierarchyPath}\" audioChanges[{i}].audio is null."); } } for (int num = audioChanges.Length - 1; num >= 0; num--) { if (audioChanges[num] == null && !((Object)(object)audioChanges[num].audio != (Object)null)) { MyCollections.RemoveAt<switchToAudio>(audioReverbTrigger.audioChanges, num); } } } private static bool FixAudioChangesForWindTrigger(AudioReverbTrigger audioReverbTrigger) { if (!IsWindTrigger(audioReverbTrigger)) { return false; } if (audioReverbTrigger.audioChanges == null || audioReverbTrigger.audioChanges.Length != 2) { return false; } SetAudioIfNull(audioReverbTrigger.audioChanges[0], HighAndLowAltitudeAudio_Patches.HighAudio); SetAudioIfNull(audioReverbTrigger.audioChanges[1], HighAndLowAltitudeAudio_Patches.LowAudio); return true; } private static bool IsWindTrigger(AudioReverbTrigger audioReverbTrigger) { string hierarchyPath = ((Component)audioReverbTrigger).transform.GetHierarchyPath(); return hierarchyPath.Contains("/WindTriggers/", StringComparison.OrdinalIgnoreCase); } private static void SetAudioIfNull(switchToAudio audioChange, AudioSource audioSource) { if (audioChange != null && !((Object)(object)audioChange.audio != (Object)null)) { audioChange.audio = audioSource; } } } [HarmonyPatch(typeof(EntranceTeleport))] internal static class EntranceTeleport_Patches { [HarmonyPatch("SetAudioPreset")] [HarmonyPrefix] private static bool SetAudioPreset_Patch(EntranceTeleport __instance, int playerObj) { int audioReverbPreset = __instance.audioReverbPreset; if (audioReverbPreset < 0) { return false; } AudioReverbPresets val = Object.FindObjectOfType<AudioReverbPresets>(); if ((Object)(object)val == (Object)null) { return false; } AudioReverbTrigger[] audioPresets = val.audioPresets; if (audioPresets == null || audioPresets.Length == 0) { Logger.LogError($"[EntranceTeleport_Patches] SetAudioPreset_Patch: Has no valid audio presets. (audioReverbPreset: {audioReverbPreset}, playerObj: {playerObj})"); return false; } if (audioReverbPreset > audioPresets.Length - 1) { Logger.LogError($"[EntranceTeleport_Patches] SetAudioPreset_Patch: Tried to access invalid AudioReverbTrigger at index {audioReverbPreset} (Length: {audioPresets.Length})"); return false; } AudioReverbTrigger val2 = audioPresets[audioReverbPreset]; if ((Object)(object)val2 == (Object)null) { Logger.LogError("[EntranceTeleport_Patches] SetAudioPreset_Patch: Target AudioReverbTrigger is null!"); return false; } try { val2.ChangeAudioReverbForPlayer(StartOfRound.Instance.allPlayerScripts[playerObj]); if ((Object)(object)__instance.entrancePointAudio != (Object)null) { __instance.PlayAudioAtTeleportPositions(); } } catch (Exception arg) { Logger.LogError($"[EntranceTeleport_Patches] SetAudioPreset_Patch: {arg}"); } return false; } [HarmonyPatch("TeleportPlayer")] [HarmonyPostfix] private static void TeleportPlayer_Patch(EntranceTeleport __instance) { string hierarchyPath = ((Component)__instance).transform.GetHierarchyPath(); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: "); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: EntranceTeleport \"" + hierarchyPath + "\""); Logger.LogInfo($"[EntranceTeleport_Patches] TeleportPlayer_Patch: isEntranceToBuilding: {__instance.isEntranceToBuilding}"); Logger.LogInfo($"[EntranceTeleport_Patches] TeleportPlayer_Patch: entranceId: {__instance.entranceId}"); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: entrancePoint: \"" + __instance.entrancePoint.GetHierarchyPath() + "\""); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: exitPoint: \"" + __instance.exitPoint.GetHierarchyPath() + "\""); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: "); Logger.LogInfo($"[EntranceTeleport_Patches] TeleportPlayer_Patch: LOCAL PLAYER isInsideFactory: {PlayerUtils.LocalPlayerScript.isInsideFactory}, isInHangarShipRoom: {PlayerUtils.LocalPlayerScript.isInHangarShipRoom}, isInElevator: {PlayerUtils.LocalPlayerScript.isInElevator}"); Logger.LogInfo("[EntranceTeleport_Patches] TeleportPlayer_Patch: "); } } [HarmonyPatch(typeof(GameNetworkManager))] internal static class GameNetworkManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { AddNetworkPrefabs(); } private static void AddNetworkPrefabs() { AddNetworkPrefab(Assets.PluginNetworkHandlerPrefab); } private static void AddNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to register network prefab. GameObject is null."); return; } NetworkManager.Singleton.AddNetworkPrefab(prefab); Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab."); } } [HarmonyPatch(typeof(GrabbableObject))] internal static class GrabbableObject_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch(GrabbableObject __instance) { if (IsJarOfPickles(__instance.itemProperties) && ExtraFeaturesManager.IsTurtleDicksEnabled) { ScanNodeProperties componentInChildren = ((Component)__instance).GetComponentInChildren<ScanNodeProperties>(); if (!((Object)(object)componentInChildren == (Object)null)) { componentInChildren.headerText = "Turtle dicks"; } } } private static bool IsJarOfPickles(Item item) { if ((Object)(object)item == (Object)null) { return false; } return item.itemName.Equals("Jar of pickles", StringComparison.OrdinalIgnoreCase); } } [HarmonyPatch(typeof(HighAndLowAltitudeAudio))] internal static class HighAndLowAltitudeAudio_Patches { public static AudioSource HighAudio { get; private set; } public static AudioSource LowAudio { get; private set; } [HarmonyPatch("Start")] [HarmonyPrefix] private static void Start_Patch(HighAndLowAltitudeAudio __instance) { HighAudio = __instance.HighAudio; LowAudio = __instance.LowAudio; } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerB_Patches { [HarmonyPatch("Interact_performed")] [HarmonyPrefix] private static void OnInteract_Patch(PlayerControllerB __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!ExtraFeaturesManager.IsDrPhilLockedDoorsEnabled) { return; } InteractTrigger hoveringOverTrigger = __instance.hoveringOverTrigger; if (!((Object)(object)hoveringOverTrigger == (Object)null)) { DoorLock componentInParent = ((Component)hoveringOverTrigger).GetComponentInParent<DoorLock>(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.isLocked) { PluginNetworkHandler.Instance?.PlayDrPhilLockedDoorSFX_ServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)componentInParent)); } } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch() { SpawnNetworkHandler(); } private static void SpawnNetworkHandler() { //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) if (NetworkUtils.IsServer) { GameObject val = Object.Instantiate<GameObject>(Assets.PluginNetworkHandlerPrefab, Vector3.zero, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch("OnClientConnect")] [HarmonyPrefix] private static void OnClientConnect_Patch(ref ulong clientId) { if (NetworkUtils.IsServer) { SyncedConfigEntryBase.SendConfigsToClient(clientId); } } private static void LogLevel(SelectableLevel level) { int num = level.spawnableScrap.Sum((SpawnableItemWithRarity x) => x.rarity); string text = $"Level: {level.PlanetName}\n\nTotal Scrap: {level.spawnableScrap.Count}\nTotal Rarity: {num}"; Logger.LogInfo("\n\n" + text.Trim() + "\n", extended: true); if (!Logger.IsExtendedLoggingEnabled()) { return; } StringBuilder stringBuilder = new StringBuilder(); foreach (SpawnableItemWithRarity item in level.spawnableScrap) { stringBuilder.AppendLine("Item " + ("\"" + item.spawnableItem.itemName + "\"").PadRight(40) + $", Rarity: {item.rarity}"); } Logger.LogInfo("\n\n" + level.PlanetName + " Scrap:\n\n" + stringBuilder.ToString() + "\n", extended: true); } } } namespace com.github.zehsteam.JOJOPlush.Objects { [Serializable] public class AudioClipGroup { public AudioClip AudioClip; public AudioClip AudioClipFar; public float Length => AudioClip.length; public AudioClipGroup(AudioClip audioClip, AudioClip audioClipFar) { AudioClip = audioClip; AudioClipFar = audioClipFar; } } [Serializable] public class AudioClipGroupWithWeight : AudioClipGroup { [Range(0f, 100f)] public int Weight = 10; public AudioClipGroupWithWeight(AudioClip audioClip, AudioClip audioClipFar, int weight = 10) : base(audioClip, audioClipFar) { Weight = weight; } } [Serializable] public class AudioClipGroupWithData<T> : AudioClipGroup { public T Data; public AudioClipGroupWithData(AudioClip audioClip, AudioClip audioClipFar, T data) : base(audioClip, audioClipFar) { Data = data; } } [Serializable] public class AudioSourceGroup { public AudioSource AudioSource; public AudioSource AudioSourceFar; public bool IsPlaying => AudioSource.isPlaying; public float Volume { get { return AudioSource.volume; } set { AudioSource.volume = value; AudioSourceFar.volume = value; } } public float Pitch { get { return AudioSource.pitch; } set { AudioSource.pitch = value; AudioSourceFar.pitch = value; } } public AudioSourceGroup(AudioSource audioSource, AudioSource audioSourceFar) { AudioSource = audioSource; AudioSourceFar = audioSourceFar; } public void Play() { AudioSource.Play(); AudioSourceFar.Play(); } public float PlayOneShot(AudioClipGroup audioClipGroup, float volumeScale = 1f) { if (audioClipGroup == null) { return 0f; } float result = 0f; if ((Object)(object)audioClipGroup.AudioClip != (Object)null) { result = audioClipGroup.AudioClip.length; AudioSource.PlayOneShot(audioClipGroup.AudioClip, volumeScale); } if ((Object)(object)audioClipGroup.AudioClipFar != (Object)null) { AudioSourceFar.PlayOneShot(audioClipGroup.AudioClipFar, volumeScale); } return result; } public void Pause() { AudioSource.Pause(); AudioSourceFar.Pause(); } public void Stop() { AudioSource.Stop(); AudioSourceFar.Stop(); } } public class ItemConfigEntry { public static List<ItemConfigEntry> Instances { get; private set; } = new List<ItemConfigEntry>(); public ConfigEntry<int> SpawnWeight { get; private set; } public SyncedConfigEntry<bool> TwoHanded { get; private set; } public SyncedConfigEntry<int> CarryWeight { get; private set; } public ConfigEntry<int> MinValue { get; private set; } public ConfigEntry<int> MaxValue { get; private set; } public Item Item { get; private set; } public ItemConfigEntry(Item item, string section, int rarity, bool twoHanded, int carryWeight, int minValue, int maxValue) { Instances.Add(this); Item = item; Bind(section, rarity, twoHanded, carryWeight, minValue, maxValue); } private void Bind(string section, int rarity, bool twoHanded, int carryWeight, int minValue, int maxValue) { if (!((Object)(object)Item == (Object)null)) { SpawnWeight = ConfigHelper.Bind(section, "SpawnWeight", rarity, Item.itemName + " spawn chance weight."); TwoHanded = ConfigHelper.BindSynced(section, "TwoHanded", twoHanded, "If enabled, " + Item.itemName + " will be two-handed."); CarryWeight = ConfigHelper.BindSynced(section, "CarryWeight", carryWeight, Item.itemName + " carry weight in pounds."); MinValue = ConfigHelper.Bind(section, "MinValue", minValue, Item.itemName + " min scrap value."); MaxValue = ConfigHelper.Bind(section, "MaxValue", maxValue, Item.itemName + " max scrap value."); SpawnWeight.SettingChanged += delegate { SpawnWeight_SettingsChanged(); }; TwoHanded.SettingChanged += delegate { Properties_SettingsChanged(); }; CarryWeight.SettingChanged += delegate { Properties_SettingsChanged(); }; MinValue.SettingChanged += delegate { Properties_SettingsChanged(); }; MaxValue.SettingChanged += delegate { Properties_SettingsChanged(); }; } } private void SpawnWeight_SettingsChanged() { ItemHelper.UpdateScrapRarity(this); } private void Properties_SettingsChanged() { ItemHelper.UpdateItemProperties(this); } } public class SyncedConfigEntry<T> : SyncedConfigEntryBase { private ConfigEntry<T> _configEntry; private T _serverValue; public T Value { get { return GetValue(); } set { SetValue(value); } } public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue; public override ConfigDefinition Definition => ((ConfigEntryBase)_configEntry).Definition; public event Action<T> SettingChanged; public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null) { SyncedConfigEntryBase.AddInstance(this); base.SettingType = typeof(T); _configEntry = ConfigHelper.Bind(section, key, defaultValue, description, requiresRestart: false, acceptableValues, null, configFile); _configEntry.SettingChanged += SettingChangedInternal; Application.quitting += delegate { _configEntry.SettingChanged -= SettingChangedInternal; }; } public T GetValue() { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { return _serverValue; } return _configEntry.Value; } public void SetValue(T value) { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = value; } } public void ResetToDefault() { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = DefaultValue; } } private void SettingChangedInternal(object sender, EventArgs e) { if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { this.SettingChanged?.Invoke(Value); SendConfigToClients(); } } private void SendConfigToClients() { //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 (NetworkUtils.IsConnected && NetworkUtils.IsServer) { PluginNetworkHandler.Instance?.SetSyncedConfigValueClientRpc(base.Section, base.Key, Value.ToString()); } } public override void SendConfigToClient(ulong clientId) { //IL_0011: 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_002e: 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_0034: 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_0060: Unknown result type (might be due to invalid IL or missing references) if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { ClientRpcParams val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId) }; ClientRpcParams clientRpcParams = val; PluginNetworkHandler.Instance?.SetSyncedConfigValueClientRpc(base.Section, base.Key, Value.ToString(), clientRpcParams); } } public override void SetValueFromServer(string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { if (!Utils.TryParseValue<T>(value, out var result)) { throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}"); } _serverValue = result; Logger.LogInfo("Set synced config entry value from server. (Section: \"" + base.Section + "\", Key: \"" + base.Key + "\", Value: \"" + value + "\")", extended: true); this.SettingChanged?.Invoke(result); } } } public abstract class SyncedConfigEntryBase { private static readonly object _instancesLock = new object(); public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>(); public abstract ConfigDefinition Definition { get; } public string Section => Definition.Section; public string Key => Definition.Key; public Type SettingType { get; protected set; } public static void AddInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Add(instance); } } public static void RemoveInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Remove(instance); } } public abstract void SendConfigToClient(ulong clientId); public abstract void SetValueFromServer(string value); public static void SendConfigsToClient(ulong clientId) { if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId)) { return; } foreach (SyncedConfigEntryBase instance in Instances) { instance.SendConfigToClient(clientId); } } public static void SetValueFromServer(string section, string key, string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key); if (syncedConfigEntryBase == null) { Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\""); } else { syncedConfigEntryBase.SetValueFromServer(value); } } } } } namespace com.github.zehsteam.JOJOPlush.MonoBehaviours { public abstract class AdvancedGrabbableObject : GrabbableObject { public int UniqueId { get; private set; } public string SaveKey => string.Format("{0}_{1}", "AdvancedGrabbableObject", UniqueId); public virtual void Awake() { if (NetworkUtils.IsServer) { UniqueId = Random.Range(0, 1000000); } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if (NetworkUtils.IsServer) { NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected; } } public override void OnNetworkDespawn() { ((NetworkBehaviour)this).OnNetworkDespawn(); if (NetworkUtils.IsServer) { NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnected; } } protected virtual void OnClientConnected(ulong clientId) { } public override int GetItemDataToSave() { return UniqueId; } public override void LoadItemSaveData(int saveData) { ((GrabbableObject)this).LoadItemSaveData(saveData); UniqueId = saveData; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "AdvancedGrabbableObject"; } } public class AdvancedNoisemakerProp : AdvancedGrabbableObject { [Space(20f)] [Header("Advanced Noisemaker Prop")] [Space(5f)] public AudioSourceGroup NoiseAudio; public AudioClipGroupWithWeight[] NoiseSFX = Array.Empty<AudioClipGroupWithWeight>(); [Space(10f)] public float NoiseRange = 65f; public float MaxLoudness = 1f; public float MinLoudness = 0.95f; public float MinPitch = 1f; public float MaxPitch = 1f; [Space(10f)] public bool UseDynamicCooldown; public bool CancelActiveSFXOnItemActivate; public override void ItemActivate(bool used, bool buttonDown = true) { if (NoiseSFX.Length != 0) { int randomIndexFromWeightList = Utils.GetRandomIndexFromWeightList(NoiseSFX.Select((AudioClipGroupWithWeight x) => x.Weight).ToList()); PlaySound(randomIndexFromWeightList); } } public void PlaySound(int index) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (NoiseSFX.Length != 0) { PlaySoundServerRpc(index); PlaySoundOnLocalClient(index); } } [ServerRpc(RequireOwnership = false)] protected void PlaySoundServerRpc(int index, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: 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_0071: 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_00ce: 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_00d4: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(99839116u, serverRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, index); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 99839116u, serverRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; if (((NetworkBehaviour)this).NetworkManager.ConnectedClients.ContainsKey(senderClientId)) { PlaySoundClientRpc(index, senderClientId); } } } [ClientRpc] protected void PlaySoundClientRpc(int index, ulong senderClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: 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_0071: 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_0096: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3084224684u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, index); BytePacker.WriteValueBitPacked(val2, senderClientId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3084224684u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsLocalClientId(senderClientId)) { PlaySoundOnLocalClient(index); } } } public void PlaySoundOnLocalClient(int index) { AudioClipGroup audioClipGroup = ((index >= 0 && index < NoiseSFX.Length) ? NoiseSFX[index] : null); PlaySoundOnLocalClient(audioClipGroup); OnPlaySoundFromIndex(index); } protected virtual void OnPlaySoundFromIndex(int index) { } public float PlaySoundOnLocalClient(AudioClip audioClip, AudioClip audioClipFar, bool stopPreviousSFX = false) { return PlaySoundOnLocalClient(new AudioClipGroup(audioClip, audioClipFar), stopPreviousSFX); } public float PlaySoundOnLocalClient(AudioClipGroup audioClipGroup, bool stopPreviousSFX = false) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (audioClipGroup == null || (Object)(object)audioClipGroup.AudioClip == (Object)null) { return 0f; } float num = (float)Random.Range((int)(MinLoudness * 100f), (int)(MaxLoudness * 100f)) / 100f; float pitch = (float)Random.Range((int)(MinPitch * 100f), (int)(MaxPitch * 100f)) / 100f; if (CancelActiveSFXOnItemActivate || stopPreviousSFX) { NoiseAudio.Stop(); } if (UseDynamicCooldown && !CancelActiveSFXOnItemActivate) { ((GrabbableObject)this).currentUseCooldown = audioClipGroup.Length; } NoiseAudio.Pitch = pitch; NoiseAudio.PlayOneShot(audioClipGroup, num); WalkieTalkie.TransmitOneShotAudio(NoiseAudio.AudioSource, audioClipGroup.AudioClip, num); RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, NoiseRange, num, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0); if (MinLoudness >= 0.6f && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) { ((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f; } return audioClipGroup.Length; } protected override void __initializeVariables() { base.__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(99839116u, new RpcReceiveHandler(__rpc_handler_99839116), "PlaySoundServerRpc"); ((NetworkBehaviour)this).__registerRpc(3084224684u, new RpcReceiveHandler(__rpc_handler_3084224684), "PlaySoundClientRpc"); base.__initializeRpcs(); } private static void __rpc_handler_99839116(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_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_0040: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int index = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref index); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((AdvancedNoisemakerProp)(object)target).PlaySoundServerRpc(index, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3084224684(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0043: 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 networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int index = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref index); ulong senderClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref senderClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((AdvancedNoisemakerProp)(object)target).PlaySoundClientRpc(index, senderClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "AdvancedNoisemakerProp"; } } public class JOJOPlush : AdvancedNoisemakerProp { protected override void __initializeVariables() { base.__initializeVariables(); } protected override void __initializeRpcs() { base.__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "JOJOPlush"; } } public class PluginNetworkHandler : NetworkBehaviour { public static PluginNetworkHandler Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; ((Object)((Component)this).gameObject).name = "JOJOPlush PluginNetworkHandler"; } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { if (((NetworkBehaviour)this).IsServer) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } else { Instance = this; } } [ClientRpc] public void SetSyncedConfigValueClientRpc(string section, string key, string value, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: 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_017b: 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_00cc: 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_010a: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3024027376u, clientRpcParams, (RpcDelivery)0); bool flag = section != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(section, false); } bool flag2 = key != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val)).WriteValueSafe(key, false); } bool flag3 = value != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives)); if (flag3) { ((FastBufferWriter)(ref val)).WriteValueSafe(value, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3024027376u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { SyncedConfigEntryBase.SetValueFromServer(section, key, value); } } } [ServerRpc(RequireOwnership = false)] public void PlayDrPhilLockedDoorSFX_ServerRpc(NetworkBehaviourReference networkBehaviourReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: 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_007d: 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_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1781024345u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref networkBehaviourReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1781024345u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; PlayDrPhilLockedDoorSFX_ClientRpc(networkBehaviourReference); } } } [ClientRpc] private void PlayDrPhilLockedDoorSFX_ClientRpc(NetworkBehaviourReference networkBehaviourReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: 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_007d: 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_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3955199862u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref networkBehaviourReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3955199862u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; DoorLock val3 = default(DoorLock); if (((NetworkBehaviourReference)(ref networkBehaviourReference)).TryGet<DoorLock>(ref val3, (NetworkManager)null) && !((Object)(object)val3 == (Object)null)) { int value = ConfigManager.ExtraFeatures_DrPhilLockedDoorSFXVolume.Value; float num = (float)value * 0.01f; val3.doorLockSFX.PlayOneShot(Assets.DrPhilOpenTheDoorSFX, num); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3024027376u, new RpcReceiveHandler(__rpc_handler_3024027376), "SetSyncedConfigValueClientRpc"); ((NetworkBehaviour)this).__registerRpc(1781024345u, new RpcReceiveHandler(__rpc_handler_1781024345), "PlayDrPhilLockedDoorSFX_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(3955199862u, new RpcReceiveHandler(__rpc_handler_3955199862), "PlayDrPhilLockedDoorSFX_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_3024027376(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_009f: 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_00cb: 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) //IL_00db: 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_0101: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string section = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref section, false); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); string key = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref key, false); } bool flag3 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives)); string value = null; if (flag3) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, false); } ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).SetSyncedConfigValueClientRpc(section, key, value, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1781024345(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference networkBehaviourReference = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref networkBehaviourReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).PlayDrPhilLockedDoorSFX_ServerRpc(networkBehaviourReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3955199862(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference networkBehaviourReference = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref networkBehaviourReference, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).PlayDrPhilLockedDoorSFX_ClientRpc(networkBehaviourReference); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "PluginNetworkHandler"; } } } namespace com.github.zehsteam.JOJOPlush.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> ExtendedLogging { get; private set; } public static ConfigEntry<bool> ExtraFeatures_Enabled { get; private set; } public static ConfigEntry<bool> ExtraFeatures_TurtleDicks { get; private set; } public static ConfigEntry<bool> ExtraFeatures_DrPhilLockedDoors { get; private set; } public static ConfigEntry<int> ExtraFeatures_DrPhilLockedDoorSFXVolume { get; private set; } public static ConfigEntry<bool>? FNV_Enabled { get; private set; } public static ConfigEntry<bool>? FNV_FixCopyrightPrevention { get; private set; } public static ConfigEntry<bool>? DSP_Enabled { get; private set; } public static ConfigEntry<DafinisScrapPackRarityManipulation>? DSP_ScrapRarityManipulationMode { get; private set; } public static ConfigEntry<int>? DSP_DivideAllBy { get; private set; } public static ConfigEntry<int>? DSP_SetAllTo { get; private set; } public static ItemConfigEntry JOJOPlush { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ConfigHelper.SkipAutoGen(); ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, "Enable extended logging."); ExtraFeatures_Enabled = ConfigHelper.Bind("Extra Features", "Enabled", defaultValue: true, "Enable extra features related to JOJOsaysbreee and their channel."); ExtraFeatures_TurtleDicks = ConfigHelper.Bind("Extra Features", "TurtleDicks", defaultValue: true, "If enabled, will rename the scan node of Jar of pickles to Turtle dicks."); ExtraFeatures_DrPhilLockedDoors = ConfigHelper.Bind("Extra Features", "DrPhilLockedDoors", defaultValue: true, "If enabled, locked doors will play the Dr. Phil \"Open the door, or I'm gonna throw rocks through your window, you dumb whore\" SFX when trying to open them."); ExtraFeatures_DrPhilLockedDoorSFXVolume = ConfigHelper.Bind("Extra Features", "DrPhilLockedDoorSFXVolume", 100, "The volume of the Dr. Phil meme sound effect.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100)); if (FalloutNewVegasProxy.IsModInstalled) { FNV_Enabled = ConfigHelper.Bind("Fallout NewVegas Compat", "Enabled", defaultValue: true, "Would you like to enable this mod's compatibility features with the Fallout NewVegas mod?", requiresRestart: true); FNV_FixCopyrightPrevention = ConfigHelper.Bind("Fallout NewVegas Compat", "FixCopyrightPrevention", defaultValue: true, "If enabled, will disable all songs from the Fallout NewVegas mod if you have 'Enable copyrighted tracks' disabled in the mods config."); } if (DafinisScrapPackProxy.IsModInstalled) { DSP_Enabled = ConfigHelper.Bind("Dafinis Scrap Pack Compat", "Enabled", defaultValue: true, "Would you like to enable this mod's compatibility features with the Dafis Mega Scrap Pack Emporium mod?", requiresRestart: true); DSP_ScrapRarityManipulationMode = ConfigHelper.Bind("Dafinis Scrap Pack Compat", "ScrapRarityManipulationMode", DafinisScrapPackRarityManipulation.SetAllTo, "The method of which you would like to manipulate Dafini's scrap rarity by.", requiresRestart: true); DSP_DivideAllBy = ConfigHelper.Bind("Dafinis Scrap Pack Compat", "DivideAllBy", 20, "The value of which to divide Dafini's scrap rarity by.", requiresRestart: true); DSP_SetAllTo = ConfigHelper.Bind("Dafinis Scrap Pack Compat", "SetAllTo", 3, "The value of which to set Dafini's scrap rarity to.", requiresRestart: true); } JOJOPlush = new ItemConfigEntry(Assets.JOJOPlush, "JOJOsaysbreee", 20, twoHanded: false, 6, 80, 250); } } internal static class ExtraFeaturesManager { public static bool IsEnabled => ConfigManager.ExtraFeatures_Enabled?.Value ?? false; public static bool IsTurtleDicksEnabled { get { if (IsEnabled) { return ConfigManager.ExtraFeatures_TurtleDicks?.Value ?? false; } return false; } } public static bool IsDrPhilLockedDoorsEnabled { get { if (IsEnabled) { return ConfigManager.ExtraFeatures_DrPhilLockedDoors?.Value ?? false; } return false; } } } } namespace com.github.zehsteam.JOJOPlush.Helpers { internal static class ConfigHelper { public static void SkipAutoGen() { if (LethalConfigProxy.IsModInstalled) { LethalConfigProxy.SkipAutoGen(); } } public static void AddButton(string section, string name, string buttonText, string description, Action callback) { if (LethalConfigProxy.IsModInstalled) { LethalConfigProxy.AddButton(section, name, buttonText, description, callback); } } public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { if (configFile == null) { configFile = ((BaseUnityPlugin)Plugin.Instance).Config; } ConfigEntry<T> configEntry = configFile.Bind(section, key, defaultValue, description, acceptableValues); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.IsModInstalled) { LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart); } return configEntry; } public static SyncedConfigEntry<T> BindSynced<T>(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { SyncedConfigEntry<T> syncedConfigEntry = new SyncedConfigEntry<T>(section, key, defaultValue, description, acceptableValues, configFile); if (settingChanged != null) { syncedConfigEntry.SettingChanged += settingChanged; } return syncedConfigEntry; } } internal static class ItemHelper { public static void RegisterScrap(Item item, int rarity, bool twoHanded, int carryWeight, int minValue, int maxValue) { if ((Object)(object)item == (Object)null) { Logger.LogError("Failed to register scrap item. Item is null."); return; } item.twoHanded = twoHanded; item.weight = (float)carryWeight / 105f + 1f; item.minValue = minValue; item.maxValue = maxValue; Utilities.FixMixerGroups(item.spawnPrefab); NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab); Items.RegisterScrap(item, rarity, (LevelTypes)(-1)); Logger.LogInfo($"Registered \"{item.itemName}\" scrap item. (Rarity: {rarity}, TwoHanded: {twoHanded}, CarryWeight: {carryWeight}, MinValue: {minValue}, MaxValue: {maxValue})"); } public static void RegisterScrap(ItemConfigEntry ItemConfigEntry) { RegisterScrap(ItemConfigEntry.Item, ItemConfigEntry.SpawnWeight.Value, ItemConfigEntry.TwoHanded.Value, ItemConfigEntry.CarryWeight.Value, ItemConfigEntry.MinValue.Value, ItemConfigEntry.MaxValue.Value); } public static void UpdateScrapRarity(Item item, int rarity) { if ((Object)(object)item == (Object)null) { Logger.LogError("Failed to update scrap item rarity. Item is null."); return; } if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError("Failed to update scrap item rarity. StartOfRound instance is null."); return; } SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { foreach (SpawnableItemWithRarity item2 in val.spawnableScrap) { if (!((Object)(object)item2.spawnableItem != (Object)(object)item)) { item2.rarity = rarity; Logger.LogInfo($"Updated \"{item.itemName}\" scrap item rarity to {rarity} on \"{val.PlanetName}\"."); } } } } public static void UpdateScrapRarity(ItemConfigEntry ItemConfigEntry) { UpdateScrapRarity(ItemConfigEntry.Item, ItemConfigEntry.SpawnWeight.Value); } public static void UpdateItemProperties(Item item, bool twoHanded, int carryWeight, int minValue, int maxValue) { if ((Object)(object)item == (Object)null) { Logger.LogError("Failed to update item properties. Item is null."); return; } item.twoHanded = twoHanded; item.weight = (float)carryWeight / 105f + 1f; item.minValue = minValue; item.maxValue = maxValue; Logger.LogInfo($"Updated \"{item.itemName}\" item properties. (TwoHanded: {twoHanded}, CarryWeight: {carryWeight}, MinValue: {minValue}, MaxValue: {maxValue})"); } public static void UpdateItemProperties(string itemName, bool twoHanded, int carryWeight, int minValue, int maxValue) { if (!TryGetItem(itemName, out var item, matchCase: false)) { Logger.LogError("Failed to update item properties. Item is null. (ItemName: " + itemName + ")"); } else { UpdateItemProperties(item, twoHanded, carryWeight, minValue, maxValue); } } public static void UpdateItemProperties(ItemConfigEntry ItemConfigEntry) { UpdateItemProperties(ItemConfigEntry.Item, ItemConfigEntry.TwoHanded.Value, ItemConfigEntry.CarryWeight.Value, ItemConfigEntry.MinValue.Value, ItemConfigEntry.MaxValue.Value); } public static Item GetItem(string itemName, bool matchCase = true) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError("Failed to get item by name. StartOfRound instance is null."); return null; } StringComparison comparisonType = ((!matchCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.CurrentCulture); foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { if (items.itemName.Equals(itemName, comparisonType)) { return items; } } return null; } public static bool TryGetItem(string itemName, out Item item, bool matchCase = true) { item = GetItem(itemName, matchCase); return (Object)(object)item != (Object)null; } public static List<Item> GetItems(string[] itemNames, bool matchCase = true) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError("Failed to get items by names. StartOfRound instance is null."); return new List<Item>(); } List<Item> list = new List<Item>(); foreach (string itemName in itemNames) { if (TryGetItem(itemName, out var item, matchCase)) { list.Add(item); } } return list; } } internal static class NetworkUtils { public static bool IsConnected { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsConnectedClient; } } public static bool IsServer { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsServer; } } public static bool IsHost { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsHost; } } public static int ConnectedPlayerCount => GameNetworkManager.Instance?.connectedPlayers ?? 0; public static ulong GetLocalClientId() { return NetworkManager.Singleton.LocalClientId; } public static bool IsLocalClientId(ulong clientId) { return clientId == GetLocalClientId(); } } internal static class PlayerUtils { public static PlayerControllerB LocalPlayerScript => StartOfRound.Instance?.localPlayerController ?? null; public static PlayerControllerB[] PlayerScripts => StartOfRound.Instance?.allPlayerScripts ?? Array.Empty<PlayerControllerB>(); public static bool IsLocalPlayer(PlayerInfo playerInfo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (SteamClient.Name.Equals(playerInfo.Username, StringComparison.OrdinalIgnoreCase)) { return true; } if (SteamId.op_Implicit(SteamClient.SteamId) == playerInfo.SteamId) { return true; } return false; } public static bool IsPlayer(PlayerControllerB playerScript, PlayerInfo playerInfo) { if (playerScript.playerUsername.Equals(playerInfo.Username, StringComparison.OrdinalIgnoreCase)) { return true; } if (playerScript.playerSteamId == playerInfo.SteamId) { return true; } return false; } public static bool HasPlayer(PlayerInfo playerInfo) { return StartOfRound.Instance.allPlayerScripts.Any((PlayerControllerB x) => IsPlayer(x, playerInfo)); } public static bool IsHost(PlayerInfo playerInfo) { PlayerControllerB val = ((IEnumerable<PlayerControllerB>)PlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => x.isHostPlayerObject)); if ((Object)(object)val == (Object)null) { return false; } return IsPlayer(val, playerInfo); } public static PlayerInfo GetJOJOsaysbreeeInfo() { return new PlayerInfo("JOJOsaysbreee", 76561198060495494uL); } } internal struct PlayerInfo { public string Username { get; set; } public ulong SteamId { get; set; } public PlayerInfo(string username, ulong steamId) { Username = username; SteamId = steamId; } } internal static class Utils { public static string GetPluginDirectoryPath() { return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); } public static string GetConfigDirectoryPath() { return Paths.ConfigPath; } public static string GetGlobalConfigDirectoryPath() { return Path.Combine(Application.persistentDataPath, "JOJOPlush"); } public static string GetPluginPersistentDataPath() { return Path.Combine(Application.persistentDataPath, "JOJOPlush"); } public static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin); if (name == null) { name = metadata.GUID; } name += ".cfg"; return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata); } public static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { return CreateConfigFile(plugin, Paths.ConfigPath, name, saveOnInit); } public static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { string pluginPersistentDataPath = GetPluginPersistentDataPath(); if (name == null) { name = "global"; } return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit); } public static bool RollPercentChance(float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return Random.value * 100f <= percent; } public static int GetRandomIndexFromWeightList(List<int> weightList) { List<(int, int)> list = new List<(int, int)>(); for (int i = 0; i < weightList.Count; i++) { int num = weightList[i]; if (num > 0) { list.Add((i, num)); } } int num2 = 0; foreach (var item4 in list) { int item = item4.Item2; num2 += item; } if (num2 == 0) { return -1; } int num3 = Random.Range(0, num2); int num4 = 0; foreach (var item5 in list) { int item2 = item5.Item1; int item3 = item5.Item2; num4 += item3; if (num3 < num4) { return item2; } } throw new InvalidOperationException("Weights are not properly specified."); } public static bool TryParseValue<T>(string value, out T result) { try { if (typeof(T) == typeof(int) && int.TryParse(value, out var result2)) { result = (T)(object)result2; return true; } if (typeof(T) == typeof(float) && float.TryParse(value, out var result3)) { result = (T)(object)result3; return true; } if (typeof(T) == typeof(double) && double.TryParse(value, out var result4)) { result = (T)(object)result4; return true; } if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result5)) { result = (T)(object)result5; return true; } if (typeof(T) == typeof(string)) { result = (T)(object)value; return true; } } catch { } result = default(T); return false; } } } namespace com.github.zehsteam.JOJOPlush.Extensions { internal static class ConfigFileExtensions { public static ConfigEntry<T> Bind<T>(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (acceptableValues == null) { return configFile.Bind<T>(section, key, defaultValue, description); } return configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())); } } internal static class TransformExtensions { public static string GetHierarchyPath(this Transform transform) { if ((Object)(object)transform == (Object)null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(((Object)transform).name); Transform parent = transform.parent; while ((Object)(object)parent != (Object)null) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } } namespace com.github.zehsteam.JOJOPlush.Dependencies { public enum DafinisScrapPackRarityManipulation { None = -1, DivideAllBy, SetAllTo } internal static class DafinisScrapPackProxy { public const string PLUGIN_GUID = "com.dafini.consumables"; public static bool IsModInstalled => Chainloader.PluginInfos.ContainsKey("com.dafini.consumables"); public static bool IsEnabled { get { if (IsModInstalled) { return ConfigManager.DSP_Enabled?.Value ?? false; } return false; } } } internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; public static bool IsModInstalled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown if (typeof(T).IsEnum) { MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigProxy), "AddEnumDropdown", (Type[])null, (Type[])null); MethodInfo methodInfo2 = methodInfo.MakeGenericMethod(typeof(T)); methodInfo2.Invoke(null, new object[2] { configEntry, requiresRestart }); return; } AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>) { AddConfigSlider<T>(configEntry, requiresRestart); return; } if (acceptableValues is AcceptableValueList<string>) { AddConfigDropdown<T>(configEntry, requiresRestart); return; } } if (!(configEntry is ConfigEntry<string> val)) { if (!(configEntry is ConfigEntry<bool> val2)) { if (!(configEntry is ConfigEntry<float> val3)) { if (!(configEntry is ConfigEntry<int> val4)) { throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!(configEntry is ConfigEntry<float> val)) { if (!(configEntry is ConfigEntry<int> val2)) { throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry<string> val) { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); return; } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddEnumDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) where T : Enum { LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<T>(configEntry, requiresRestart)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string buttonText, string description, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); })); } } } namespace com.github.zehsteam.JOJOPlush.Dependencies.LethalLevelLoaderMod { internal static class LethalLevelLoaderProxy { public const string PLUGIN_GUID = "imabatby.lethallevelloader"; public static bool IsModInstalled => Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"); public static bool IsEnabled { get { if (IsModInstalled) { return DafinisScrapPackProxy.IsEnabled; } return false; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void PatchAll(Harmony harmony) { try { if (IsEnabled) { harmony.PatchAll(typeof(ExtendedMod_Patches)); harmony.PatchAll(typeof(ItemManager_Patches)); harmony.PatchAll(typeof(LevelMatchingProperties_Patches)); Logger.LogInfo("[LethalLevelLoaderProxy] Applied patches."); } } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to apply patches. {1}", "LethalLevelLoaderProxy", arg)); } } } } namespace com.github.zehsteam.JOJOPlush.Dependencies.LethalLevelLoaderMod.Patches { [HarmonyPatch(typeof(ExtendedMod))] internal static class ExtendedMod_Patches { public static readonly List<string> TargetMods = new List<string>(2) { "DafiScrapPack", "DafiScrapsMK2" }; public static readonly List<ExtendedItem> TargetExtendedItems = new List<ExtendedItem>(); [HarmonyPatch("RegisterExtendedContent", new Type[] { typeof(ExtendedItem) })] [HarmonyPrefix] private static void RegisterExtendedContent_Patch(ExtendedMod __instance, ExtendedItem extendedItem) { if (!LethalLevelLoaderProxy.IsEnabled || !TargetMods.Contains(__instance.ModName)) { return; } Item item = extendedItem.Item; if (!((Object)(object)item == (Object)null) && item.isScrap) { TargetExtendedItems.Add(extendedItem); Logger.LogInfo("[ExtendedMod_Patches] ModName: \"" + __instance.ModName + "\" ItemName: \"" + extendedItem.Item.itemName + "\"", extended: true); LevelMatchingProperties levelMatchingProperties = extendedItem.LevelMatchingProperties; if ((Object)(object)levelMatchingProperties != (Object)null) { LogStringWithRarity(item.itemName, "levelTags", levelMatchingProperties.levelTags); LogStringWithRarity(item.itemName, "currentWeather", levelMatchingProperties.currentWeather); LogStringWithRarity(item.itemName, "planetNames", levelMatchingProperties.planetNames); } DungeonMatchingProperties dungeonMatchingProperties = extendedItem.DungeonMatchingProperties; if ((Object)(object)dungeonMatchingProperties != (Object)null) { LogStringWithRarity(item.itemName, "dungeonTags", dungeonMatchingProperties.dungeonTags); LogStringWithRarity(item.itemName, "dungeonNames", dungeonMatchingProperties.dungeonNames); } } } public static void LogStringWithRarity(string itemName, string listName, List<StringWithRarity> list) { if (list == null) { return; } foreach (StringWithRarity item in list) { Logger.LogInfo($"ItemName: \"{itemName}\", ListName: \"{listName}\", Name: \"{item.Name}\", Rarity: \"{item.Rarity}\"", extended: true); } } } [HarmonyPatch(typeof(ItemManager))] internal static class ItemManager_Patches { [HarmonyPatch("InjectCustomItemsIntoLevelViaDynamicRarity")] [HarmonyPrefix] private static void InjectCustomItemsIntoLevelViaDynamicRarity_Patch(ExtendedLevel extendedLevel) { if (!LethalLevelLoaderProxy.IsEnabled) { return; } foreach (ExtendedItem customExtendedItem in PatchedContent.CustomExtendedItems) { if (ExtendedMod_Patches.TargetExtendedItems.Contains(customExtendedItem)) { Item item = customExtendedItem.Item; Logger.LogInfo($"Item \"{item.itemName}\" has a rarity of {customExtendedItem.LevelMatchingProperties.GetDynamicRarity(extendedLevel)} for Level \"{((ExtendedContent)extendedLevel).UniqueIdentificationName}\"", extended: true); LevelMatchingProperties levelMatchingProperties = customExtendedItem.LevelMatchingProperties; if ((Object)(object)levelMatchingProperties != (Object)null) { ExtendedMod_Patches.LogStringWithRarity(item.itemName, "levelTags", levelMatchingProperties.levelTags); ExtendedMod_Patches.LogStringWithRarity(item.itemName, "currentWeather", levelMatchingProperties.currentWeather); ExtendedMod_Patches.LogStringWithRarity(item.itemName, "planetNames", levelMatchingProperties.planetNames); } DungeonMatchingProperties dungeonMatchingProperties = customExtendedItem.DungeonMatchingProperties; if ((Object)(object)dungeonMatchingProperties != (Object)null) { ExtendedMod_Patches.LogStringWithRarity(item.itemName, "dungeonTags", dungeonMatchingProperties.dungeonTags); ExtendedMod_Patches.LogStringWithRarity(item.itemName, "dungeonNames", dungeonMatchingProperties.dungeonNames); } } } } } [HarmonyPatch(typeof(LevelMatchingProperties))] internal static class LevelMatchingProperties_Patches { [HarmonyPatch("GetDynamicRarity")] [HarmonyPostfix] private static void GetDynamicRarity_Patch(LevelMatchingProperties __instance, ref int __result) { if (!LethalLevelLoaderProxy.IsEnabled || ConfigManager.DSP_ScrapRarityManipulationMode == null || ConfigManager.DSP_ScrapRarityManipulationMode.Value == DafinisScrapPackRarityManipulation.None) { return; } ExtendedItem val = ((IEnumerable<ExtendedItem>)ExtendedMod_Patches.TargetExtendedItems).FirstOrDefault((Func<ExtendedItem, bool>)((ExtendedItem x) => (Object)(object)x.LevelMatchingProperties == (Object)(object)__instance)); if (!((Object)(object)val == (Object)null)) { int num = __result; int num2 = num; if (ConfigManager.DSP_ScrapRarityManipulationMode.Value == DafinisScrapPackRarityManipulation.DivideAllBy) { num2 = Mathf.Max((int)Mathf.Ceil((float)(num / ConfigManager.DSP_DivideAllBy.Value)), 1); } if (ConfigManager.DSP_ScrapRarityManipulationMode.Value == DafinisScrapPackRarityManipulation.SetAllTo) { num2 = ConfigManager.DSP_SetAllTo.Value; } Logger.LogInfo($"Converted item \"{val.Item.itemName}\" rarity from {num} to {num2}", extended: true); __result = num2; } } } } namespace com.github.zehsteam.JOJOPlush.Dependencies.FalloutNewVegas { internal static class FalloutNewVegasProxy { public const string PLUGIN_GUID = "lostpoet.NewVegasMod"; public static bool IsModInstalled => Chainloader.PluginInfos.ContainsKey("lostpoet.NewVegasMod"); public static bool IsEnabled { get { if (IsModInstalled) { return ConfigManager.FNV_Enabled?.Value ?? false; } return false; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void PatchAll(Harmony harmony) { try { if (IsEnabled) { harmony.PatchAll(typeof(IntercomsManagerPatch)); Logger.LogInfo("[FalloutNewVegasProxy] Applied patches."); } } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to apply patches. {1}", "FalloutNewVegasProxy", arg)); } } } } namespace com.github.zehsteam.JOJOPlush.Dependencies.FalloutNewVegas.Patches { [HarmonyPatch(typeof(IntercomsManager))] internal static class IntercomsManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch(IntercomsManager __instance) { if (FalloutNewVegasProxy.IsEnabled && !Plugin.VegasConfig.radio_UseCopyrightedAudio.Value && ConfigManager.FNV_FixCopyrightPrevention.Value) { __instance.Songs = Array.Empty<RadioTrack>(); Logger.LogInfo("[FalloutNewVegasProxy] Disabled all songs to prevent copyright."); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace com.github.zehsteam.JOJOPlush.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }
com.github.zehsteam.TenuousLight.dll
Decompiled 4 months agousing 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.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using TerminalFormatter; using Unity.Netcode; using UnityEngine; using com.github.zehsteam.TenuousLight.Dependencies; using com.github.zehsteam.TenuousLight.Extensions; using com.github.zehsteam.TenuousLight.Helpers; using com.github.zehsteam.TenuousLight.Managers; using com.github.zehsteam.TenuousLight.MonoBehaviours; using com.github.zehsteam.TenuousLight.NetcodePatcher; using com.github.zehsteam.TenuousLight.Objects; using com.github.zehsteam.TenuousLight.Patches; [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("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9640c89d60c4e4790888ea109987a5f21d134318")] [assembly: AssemblyProduct("TenuousLight")] [assembly: AssemblyTitle("com.github.zehsteam.TenuousLight")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace com.github.zehsteam.TenuousLight { internal static class Assets { public static AssetBundle AssetBundle { get; private set; } public static GameObject PluginNetworkHandlerPrefab { get; private set; } public static UnlockableItemDef TenuousLight { get; private set; } public static TerminalNode TenuousLightBuy { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = "tenuouslight_assets"; string text2 = Path.Combine(directoryName, text); if (!File.Exists(text2)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle val = AssetBundle.LoadFromFile(text2); if ((Object)(object)val == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); } else { OnAssetBundleLoaded(val); } } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { AssetBundle = assetBundle; PluginNetworkHandlerPrefab = LoadAsset<GameObject>("PluginNetworkHandler", assetBundle); PluginNetworkHandlerPrefab.AddComponent<PluginNetworkHandler>(); TenuousLight = LoadAsset<UnlockableItemDef>("TenuousLight", assetBundle); TenuousLightBuy = LoadAsset<TerminalNode>("TenuousLightBuy", assetBundle); } private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset<T>(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset<T>(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled()) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } public static bool IsExtendedLoggingEnabled() { return ConfigManager.General_ExtendedLogging?.Value ?? false; } } [BepInPlugin("com.github.zehsteam.TenuousLight", "TenuousLight", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.TenuousLight"); public static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.TenuousLight")); Logger.LogInfo("TenuousLight has awoken!"); _harmony.PatchAll(typeof(GameNetworkManager_Patches)); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(Terminal_Patches)); _harmony.PatchAll(typeof(PlayerControllerB_Patches)); if (TerminalFormatterProxy.Enabled) { TerminalFormatterProxy.PatchAll(_harmony); } Assets.Load(); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); RegisterUnlockableItems(); NetcodePatcherAwake(); } private void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Type[] types = executingAssembly.GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message)); } } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message)); } } } } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message)); } } private void RegisterUnlockableItems() { UnlockableItemHelper.RegisterUnlockable(ConfigManager.TenuousLight, Assets.TenuousLightBuy); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.TenuousLight"; public const string PLUGIN_NAME = "TenuousLight"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace com.github.zehsteam.TenuousLight.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal static class GameNetworkManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { AddNetworkPrefabs(); } private static void AddNetworkPrefabs() { AddNetworkPrefab(Assets.PluginNetworkHandlerPrefab); } private static void AddNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to register network prefab. GameObject is null."); return; } NetworkManager.Singleton.AddNetworkPrefab(prefab); Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab."); } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerB_Patches { [HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")] [HarmonyPostfix] private static void SetHoverTipAndCurrentInteractTrigger_Patch(PlayerControllerB __instance) { //IL_0043: 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_004a: 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) if (!PlayerUtils.IsLocalPlayer(__instance) || __instance.isGrabbingObjectAnimation || __instance.inSpecialMenu || __instance.quickMenuManager.isMenuOpen || __instance.isFreeCamera) { return; } LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Room" })); if (Physics.Raycast(__instance.interactRay, ref __instance.hit, 5f, LayerMask.op_Implicit(val))) { GameObject gameObject = ((Component)((RaycastHit)(ref __instance.hit)).collider).gameObject; NPCBodyPart nPCBodyPart = default(NPCBodyPart); if (gameObject.TryGetComponent<NPCBodyPart>(ref nPCBodyPart)) { nPCBodyPart.OnLocalHover(); } } } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch() { SpawnPluginNetworkHandler(); } private static void SpawnPluginNetworkHandler() { //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) if (NetworkUtils.IsServer) { GameObject val = Object.Instantiate<GameObject>(Assets.PluginNetworkHandlerPrefab, Vector3.zero, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } [HarmonyPatch("OnClientConnect")] [HarmonyPrefix] private static void OnClientConnect_Patch(ulong clientId) { if (NetworkUtils.IsServer) { SyncedConfigEntryBase.SendConfigsToClient(clientId); } } [HarmonyPatch("LoadUnlockables")] [HarmonyPostfix] private static void LoadUnlockablesPatch() { if (!NetworkUtils.IsServer) { return; } foreach (UnlockableItemConfigData instance in UnlockableItemConfigData.Instances) { UnlockableItem unlockableItem = instance.UnlockableItem; if (unlockableItem != null && !unlockableItem.inStorage && instance.UnlockAtStart.Value) { StartOfRound.Instance.UnlockShipObject(instance.UnlockableId); } } } } [HarmonyPatch(typeof(Terminal))] internal static class Terminal_Patches { public static readonly string TenuousLightHexColor = "#FF69B4"; [HarmonyPatch("TextPostProcess")] [HarmonyPostfix] private static void TextPostProcess_Patch(ref string __result) { __result = GetModifiedText(__result); } public static string GetModifiedText(string input) { string unlockableName = Assets.TenuousLight.unlockable.unlockableName; return input.Replace(unlockableName, "<color=" + TenuousLightHexColor + ">" + unlockableName + "</color>"); } } } namespace com.github.zehsteam.TenuousLight.Objects { public class SyncedConfigEntry<T> : SyncedConfigEntryBase { private ConfigEntry<T> _configEntry; private T _serverValue; public T Value { get { return GetValue(); } set { SetValue(value); } } public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue; public override ConfigDefinition Definition => ((ConfigEntryBase)_configEntry).Definition; public event Action<T> SettingChanged; public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null) { SyncedConfigEntryBase.AddInstance(this); base.SettingType = typeof(T); _configEntry = ConfigHelper.Bind(section, key, defaultValue, description, requiresRestart: false, acceptableValues, null, configFile); _configEntry.SettingChanged += SettingChangedInternal; Application.quitting += delegate { _configEntry.SettingChanged -= SettingChangedInternal; }; } public T GetValue() { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { return _serverValue; } return _configEntry.Value; } public void SetValue(T value) { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = value; } } public void ResetToDefault() { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = DefaultValue; } } private void SettingChangedInternal(object sender, EventArgs e) { if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { this.SettingChanged?.Invoke(Value); SendConfigToClients(); } } private void SendConfigToClients() { //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 (NetworkUtils.IsConnected && NetworkUtils.IsServer) { PluginNetworkHandler.Instance?.SetSyncedConfigValueClientRpc(base.Section, base.Key, Value.ToString()); } } public override void SendConfigToClient(ulong clientId) { //IL_0011: 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_002e: 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_0034: 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_0060: Unknown result type (might be due to invalid IL or missing references) if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { ClientRpcParams val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId) }; ClientRpcParams clientRpcParams = val; PluginNetworkHandler.Instance?.SetSyncedConfigValueClientRpc(base.Section, base.Key, Value.ToString(), clientRpcParams); } } public override void SetValueFromServer(string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { if (!value.TryConvertTo<T>(out var result)) { throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}"); } _serverValue = result; Logger.LogInfo("Set synced config entry value from server. (Section: \"" + base.Section + "\", Key: \"" + base.Key + "\", Value: \"" + value + "\")", extended: true); this.SettingChanged?.Invoke(result); } } } public abstract class SyncedConfigEntryBase { private static readonly object _instancesLock = new object(); public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>(); public abstract ConfigDefinition Definition { get; } public string Section => Definition.Section; public string Key => Definition.Key; public Type SettingType { get; protected set; } public static void AddInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Add(instance); } } public static void RemoveInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Remove(instance); } } public abstract void SendConfigToClient(ulong clientId); public abstract void SetValueFromServer(string value); public static void SendConfigsToClient(ulong clientId) { if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId)) { return; } foreach (SyncedConfigEntryBase instance in Instances) { instance.SendConfigToClient(clientId); } } public static void SetValueFromServer(string section, string key, string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key); if (syncedConfigEntryBase == null) { Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\""); } else { syncedConfigEntryBase.SetValueFromServer(value); } } } } public class UnlockableItemConfigData { public static List<UnlockableItemConfigData> Instances { get; private set; } = new List<UnlockableItemConfigData>(); public SyncedConfigEntry<int> Price { get; private set; } public ConfigEntry<bool> UnlockAtStart { get; private set; } public UnlockableItemDef UnlockableItemDef { get; private set; } public UnlockableItem UnlockableItem => UnlockableItemDef?.unlockable; public int UnlockableId => UnlockableItemHelper.GetUnlockableId(UnlockableItem); public UnlockableItemConfigData(UnlockableItemDef unlockableItemDef, string section, int price, bool unlockAtStart) { Instances.Add(this); UnlockableItemDef = unlockableItemDef; Bind(section, price, unlockAtStart); } private void Bind(string section, int price, bool unlockAtStart) { if (UnlockableItem != null) { Price = ConfigHelper.BindSynced(section, "Price", price, "The price of " + UnlockableItem.unlockableName + "."); UnlockAtStart = ConfigHelper.Bind(section, "UnlockAtStart", unlockAtStart, "If enabled, " + UnlockableItem.unlockableName + " will be unlocked at the start."); Price.SettingChanged += delegate { UnlockableItemHelper.UpdateUnlockablePrice(this); }; } } } } namespace com.github.zehsteam.TenuousLight.MonoBehaviours { public class NPC : NetworkBehaviour { [SerializeField] private Canvas _usernameCanvas; [SerializeField] private CanvasGroup _usernameCanvasGroup; private void LateUpdate() { BillboardUsernameCanvas(); } private void BillboardUsernameCanvas() { if (!((Object)(object)_usernameCanvas == (Object)null) && !((Object)(object)_usernameCanvasGroup == (Object)null) && !(_usernameCanvasGroup.alpha <= 0f)) { PlayerControllerB localPlayerScript = PlayerUtils.GetLocalPlayerScript(); if (!((Object)(object)localPlayerScript == (Object)null) && !((Object)(object)localPlayerScript.localVisorTargetPoint == (Object)null)) { ((Component)_usernameCanvas).transform.LookAt(localPlayerScript.localVisorTargetPoint); CanvasGroup usernameCanvasGroup = _usernameCanvasGroup; usernameCanvasGroup.alpha -= Time.deltaTime; } } } public void ShowUsername() { if (!((Object)(object)_usernameCanvas == (Object)null) && !((Object)(object)_usernameCanvasGroup == (Object)null)) { ((Component)_usernameCanvas).gameObject.SetActive(true); _usernameCanvasGroup.alpha = 1f; } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "NPC"; } } public class NPCBodyPart : MonoBehaviour { [SerializeField] private NPC _npc; public void OnLocalHover() { _npc?.ShowUsername(); } } internal class PluginNetworkHandler : NetworkBehaviour { public static PluginNetworkHandler Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { if (((NetworkBehaviour)this).IsServer) { Object.Destroy((Object)(object)((Component)this).gameObject); } } else { Instance = this; ((Object)((Component)this).gameObject).name = "TenuousLight PluginNetworkHandler"; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this && ((NetworkBehaviour)this).IsServer) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } [ClientRpc] public void SetSyncedConfigValueClientRpc(string section, string key, string value, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: 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_017b: 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_00cc: 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_010a: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(554537276u, clientRpcParams, (RpcDelivery)0); bool flag = section != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(section, false); } bool flag2 = key != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val)).WriteValueSafe(key, false); } bool flag3 = value != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives)); if (flag3) { ((FastBufferWriter)(ref val)).WriteValueSafe(value, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 554537276u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { SyncedConfigEntryBase.SetValueFromServer(section, key, value); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(554537276u, new RpcReceiveHandler(__rpc_handler_554537276), "SetSyncedConfigValueClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_554537276(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: 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_0067: 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_009f: 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_00cb: 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) //IL_00db: 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_0101: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string section = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref section, false); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); string key = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref key, false); } bool flag3 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives)); string value = null; if (flag3) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, false); } ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).SetSyncedConfigValueClientRpc(section, key, value, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "PluginNetworkHandler"; } } } namespace com.github.zehsteam.TenuousLight.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> General_ExtendedLogging { get; private set; } public static UnlockableItemConfigData TenuousLight { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ConfigHelper.SkipAutoGen(); General_ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, "Enable extended logging."); TenuousLight = new UnlockableItemConfigData(Assets.TenuousLight, "TenuousLight", 0, unlockAtStart: false); } } } namespace com.github.zehsteam.TenuousLight.Helpers { internal static class ConfigHelper { public static void SkipAutoGen() { if (LethalConfigProxy.Enabled) { LethalConfigProxy.SkipAutoGen(); } } public static void AddButton(string section, string name, string buttonText, string description, Action callback) { if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddButton(section, name, buttonText, description, callback); } } public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { if (configFile == null) { configFile = ((BaseUnityPlugin)Plugin.Instance).Config; } ConfigEntry<T> configEntry = configFile.Bind(section, key, defaultValue, description, acceptableValues); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart); } return configEntry; } public static SyncedConfigEntry<T> BindSynced<T>(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null) { SyncedConfigEntry<T> syncedConfigEntry = new SyncedConfigEntry<T>(section, key, defaultValue, description, acceptableValues, configFile); if (settingChanged != null) { syncedConfigEntry.SettingChanged += settingChanged; } return syncedConfigEntry; } } public static class NetworkUtils { public static bool IsConnected { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsConnectedClient; } } public static bool IsServer { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsServer; } } public static int ConnectedClientCount { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return 0; } return singleton.ConnectedClients.Count; } } public static ulong LocalClientId { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return 0uL; } return singleton.LocalClientId; } } public static bool IsLocalClientId(ulong clientId) { return clientId == LocalClientId; } public static bool IsNetworkPrefab(GameObject prefab) { IReadOnlyList<NetworkPrefab> prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs; return prefabs.Any((NetworkPrefab x) => (Object)(object)x.Prefab == (Object)(object)prefab); } } internal static class PlayerUtils { public static PlayerControllerB GetLocalPlayerScript() { return GameNetworkManager.Instance?.localPlayerController ?? null; } public static bool IsLocalPlayer(PlayerControllerB playerScript) { return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript(); } } internal static class UnlockableItemHelper { public static void RegisterUnlockable(UnlockableItemDef unlockableItemDef, int price, TerminalNode terminalNode) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unlockableItemDef == (Object)null) { Logger.LogError("Failed to register unlockable item. UnlockableItemDef is null."); return; } UnlockableItem unlockable = unlockableItemDef.unlockable; if (unlockable == null) { Logger.LogError("Failed to register unlockable item. UnlockableItem is null."); return; } if ((Object)(object)terminalNode == (Object)null) { Logger.LogError("Failed to register unlockable item. TerminalNode is null."); return; } try { unlockable.shopSelectionNode.itemCost = price; unlockable.shopSelectionNode.terminalOptions[0].result.itemCost = price; } catch { } Utilities.FixMixerGroups(unlockable.prefabObject); NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject); Unlockables.RegisterUnlockable(unlockableItemDef, unlockableItemDef.storeType, (TerminalNode)null, (TerminalNode)null, terminalNode, price); Logger.LogInfo($"Registered \"{unlockable.unlockableName}\" unlockable item with a price of ${price}."); } public static void RegisterUnlockable(UnlockableItemConfigData unlockableItemConfigData, TerminalNode terminalNode) { RegisterUnlockable(unlockableItemConfigData.UnlockableItemDef, unlockableItemConfigData.Price.Value, terminalNode); } public static void UpdateUnlockablePrice(UnlockableItem unlockableItem, int price) { if (unlockableItem == null) { Logger.LogError("Failed to update unlockable item price. UnlockableItem is null."); return; } try { unlockableItem.shopSelectionNode.itemCost = price; unlockableItem.shopSelectionNode.terminalOptions[0].result.itemCost = price; } catch { } Unlockables.UpdateUnlockablePrice(unlockableItem, price); Logger.LogInfo($"Updated \"{unlockableItem.unlockableName}\" unlockable item price to ${price}."); } public static void UpdateUnlockablePrice(int unlockableId, int price) { if (!TryGetUnlockableItem(unlockableId, out var unlockableItem)) { Logger.LogError($"Failed to update unlockable item price. UnlockableItem is null. (UnlockableId: {unlockableId})"); } else { UpdateUnlockablePrice(unlockableItem, price); } } public static void UpdateUnlockablePrice(UnlockableItemConfigData unlockableItemConfigData) { UpdateUnlockablePrice(unlockableItemConfigData.UnlockableItem, unlockableItemConfigData.Price.Value); } public static UnlockableItem GetUnlockableItem(int unlockableId) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError($"Failed to get unlockable item. StartOfRound instance is null. (UnlockableId: {unlockableId})"); return null; } List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; if (unlockableId < 0 || unlockableId > unlockables.Count - 1) { Logger.LogError($"Failed to get unlockable item. Unlockable id is invalid. (UnlockableId: {unlockableId})"); return null; } return unlockables[unlockableId]; } public static bool TryGetUnlockableItem(int unlockableId, out UnlockableItem unlockableItem) { unlockableItem = GetUnlockableItem(unlockableId); return unlockableItem != null; } public static int GetUnlockableId(UnlockableItem unlockableItem) { if ((Object)(object)StartOfRound.Instance == (Object)null) { Logger.LogError("Failed to get unlockable id. StartOfRound instance is null."); return -1; } if (unlockableItem == null) { Logger.LogError("Failed to get unlockable id. UnlockableItem is null."); return -1; } List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables; for (int i = 0; i < unlockables.Count; i++) { if (unlockables[i] == unlockableItem) { return i; } } return -1; } } } namespace com.github.zehsteam.TenuousLight.Extensions { internal static class ConfigFileExtensions { public static ConfigEntry<T> Bind<T>(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (acceptableValues == null) { return configFile.Bind<T>(section, key, defaultValue, description); } return configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())); } } public static class StringExtensions { public static T ConvertTo<T>(this string s) { Type typeFromHandle = typeof(T); if ((object)typeFromHandle != null) { Type type = typeFromHandle; object obj; if (type == typeof(int) && int.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { obj = result; } else { Type type2 = typeFromHandle; if (type2 == typeof(float) && float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { obj = result2; } else { Type type3 = typeFromHandle; if (type3 == typeof(double) && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { obj = result3; } else { Type type4 = typeFromHandle; if (type4 == typeof(bool) && bool.TryParse(s, out var result4)) { obj = result4; } else { Type type5 = typeFromHandle; if (type5 == typeof(string)) { obj = s; } else { Type type6 = typeFromHandle; if (!type6.IsEnum || !Enum.TryParse(type6, s, ignoreCase: true, out object result5)) { goto IL_0121; } obj = result5; } } } } } object obj2 = obj; return (T)obj2; } goto IL_0121; IL_0121: throw new NotSupportedException($"Unsupported value type: {typeof(T)}"); } public static bool TryConvertTo<T>(this string s, out T result) { try { result = s.ConvertTo<T>(); return true; } catch { result = default(T); return false; } } } } namespace com.github.zehsteam.TenuousLight.Dependencies { internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>) { AddConfigSlider<T>(configEntry, requiresRestart); return; } if (acceptableValues is AcceptableValueList<string>) { AddConfigDropdown<T>(configEntry, requiresRestart); return; } } if (!(configEntry is ConfigEntry<string> val)) { if (!(configEntry is ConfigEntry<bool> val2)) { if (!(configEntry is ConfigEntry<float> val3)) { if (!(configEntry is ConfigEntry<int> val4)) { throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!(configEntry is ConfigEntry<float> val)) { if (!(configEntry is ConfigEntry<int> val2)) { throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry<string> val) { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); return; } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string buttonText, string description, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); })); } } internal static class TerminalFormatterProxy { public const string PLUGIN_GUID = "TerminalFormatter"; private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("TerminalFormatter"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void PatchAll(Harmony harmony) { try { harmony.PatchAll(typeof(GetNodeText_Patches)); Logger.LogInfo("[TerminalFormatterProxy] Applied patches."); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to apply patches. {1}", "TerminalFormatterProxy", arg)); } } } [HarmonyPatch] public static class GetNodeText_Patches { private static IEnumerable<MethodBase> TargetMethods() { try { Type typeFromHandle = typeof(TerminalFormatterNode); Assembly assembly = typeFromHandle.Assembly; List<MethodBase> list = new List<MethodBase>(); Type[] types = assembly.GetTypes(); Type[] array = types; foreach (Type type in array) { try { if (!type.IsAbstract && typeFromHandle.IsAssignableFrom(type)) { MethodBase methodBase = AccessTools.Method(type, "GetNodeText", (Type[])null, (Type[])null); if (!(methodBase == null)) { list.Add(methodBase); } } } catch { } } return list.AsEnumerable(); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to apply patches. {1}", "TerminalFormatterProxy", arg)); return Array.Empty<MethodBase>(); } } [HarmonyPostfix] private static void Postfix(ref string __result) { __result = Terminal_Patches.GetModifiedText(__result); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T> { object IEnumerator.Current => _item; T IEnumerator<T>.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => 1; T IReadOnlyList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection<T>.Count => 1; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer<T>.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer<T>.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return new Enumerator(_item); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return EqualityComparer<T>.Default.Equals(_item, item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { if (!EqualityComparer<T>.Default.Equals(_item, item)) { return -1; } return 0; } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace com.github.zehsteam.TenuousLight.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }