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 SelectableInteriors v1.3.0
NoteBoxz.SelectableInteriors.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalLevelLoader; using Microsoft.CodeAnalysis; using NoteBoxz.SelectableInteriors.NetcodePatcher; using SelectableInteriors.Patches; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: AssemblyCompany("NoteBoxz.SelectableInteriors")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0-dev")] [assembly: AssemblyProduct("SelectableInteriors")] [assembly: AssemblyTitle("NoteBoxz.SelectableInteriors")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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.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 SelectableInteriors { public class SelectableInteriorsSynchronizer : NetworkBehaviour { public NetworkVariable<int> SelectedIndex = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if (!((NetworkBehaviour)this).IsServer) { NetworkVariable<int> selectedIndex = SelectedIndex; selectedIndex.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)selectedIndex.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnSelectedIndexChanged)); } } private void OnSelectedIndexChanged(int oldValue, int newValue) { SelectableInteriors.LVidForceing = newValue; SelectableInteriors.Logger.LogMessage((object)string.Format("{0}Selected index changed from {1} to {2}", ((NetworkBehaviour)this).IsServer ? "" : "(Synced) ", oldValue, newValue)); } [ClientRpc] public void SyncMoonBlackListClientRpc(string newValue) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) 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(730136976u, val, (RpcDelivery)0); bool flag = newValue != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(newValue, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 730136976u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!((NetworkBehaviour)this).IsServer) { string moonBlackListString = SelectableInteriors.MoonBlackListString; SelectableInteriors.MoonBlackListString = newValue; SelectableInteriors.Logger.LogMessage((object)((((NetworkBehaviour)this).IsServer ? "" : "(Synced) ") + "Moon blacklist changed from '" + moonBlackListString + "' to '" + newValue + "'")); } } } private void Update() { if (((NetworkBehaviour)this).IsServer) { SelectedIndex.Value = SelectableInteriors.LVidForceing; } else { SelectableInteriors.LVidForceing = SelectedIndex.Value; } } protected override void __initializeVariables() { if (SelectedIndex == null) { throw new Exception("SelectableInteriorsSynchronizer.SelectedIndex cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)SelectedIndex).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SelectedIndex, "SelectedIndex"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)SelectedIndex); ((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(730136976u, new RpcReceiveHandler(__rpc_handler_730136976), "SyncMoonBlackListClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_730136976(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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); string newValue = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref newValue, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SelectableInteriorsSynchronizer)(object)target).SyncMoonBlackListClientRpc(newValue); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "SelectableInteriorsSynchronizer"; } } [BepInPlugin("NoteBoxz.SelectableInteriors", "SelectableInteriors", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SelectableInteriors : BaseUnityPlugin { internal static ConfigFile Config = null; public static TerminalKeyword InteriorViewKeyword = null; public static TerminalNode InteriorViewNode = null; public static List<TerminalKeyword> InteriorChangeKeywords = null; public static List<TerminalNode> InteriorChangeNodes = null; public static int LVidForceing = -1; public static bool FullRandom = false; public static string MoonBlackListString = string.Empty; public static SelectableInteriorsSynchronizer SelectableInteriorsSynchronizer = null; public static Dictionary<int, string> ValidDungens = new Dictionary<int, string>(); public static ConfigEntry<int> DefaultInteriorID = null; public static ConfigEntry<bool> DefaultFullRandom = null; public static ConfigEntry<string> SelectableInteriorsMoonBlacklist = null; public static ConfigEntry<string> FullRandomBlacklist = null; public static SelectableInteriors Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } public static bool IsDependencyLoaded(string pluginGUID) { return Chainloader.PluginInfos.ContainsKey(pluginGUID); } public static List<string> ParseStringList(string input) { List<string> list = new List<string>(); if (string.IsNullOrEmpty(input)) { return list; } string[] array = input.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim(); if (!string.IsNullOrEmpty(text2)) { list.Add(text2); } } return list; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Config = ((BaseUnityPlugin)this).Config; Instance = this; NetcodePatcher(); Patch(); RegisterNodes(); Logger.LogInfo((object)"NoteBoxz.SelectableInteriors v1.3.0 has loaded!"); } public void RegisterNodes() { InteriorViewNode = CreateBaseTerminalNode("Interior View", "cur level flows:", "SetLV -1"); InteriorViewKeyword = CreateTerminalKeyword("Interior ViewKW", "listinside", InteriorViewNode); } public static void AddNoneChangeNode() { TerminalNode resultNode = CreateBaseTerminalNode("forceNone", "No Interior will be forced!", "SetLV -1"); TerminalKeyword keyword = CreateTerminalKeyword("forcenonekw", "setinside none", resultNode); AddKeywordToTerminal(keyword); } public static void AddChangeNode(int ID, string name) { TerminalNode resultNode = CreateBaseTerminalNode($"force{ID}", $"Forcing Interior {name} ({ID}) to be loaded!", $"SetLV {ID}"); TerminalKeyword keyword = CreateTerminalKeyword($"force{ID}kw", $"setinside {ID}", resultNode); AddKeywordToTerminal(keyword); } public static void AddFullRandomNode() { TerminalNode resultNode = CreateBaseTerminalNode("forceFullRandom", "Fully Random Interiors will be chosen", "SetLV FullRandom"); TerminalKeyword keyword = CreateTerminalKeyword("forcefullrandomkw", "setinside fullrandom", resultNode); AddKeywordToTerminal(keyword); } private static TerminalNode CreateBaseTerminalNode(string name, string displayText, string terminalEvent = null) { TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val).name = name; val.displayText = displayText; val.clearPreviousText = true; val.maxCharactersToType = 35; val.buyItemIndex = -1; val.buyVehicleIndex = -1; val.isConfirmationNode = false; val.buyRerouteToMoon = -1; val.displayPlanetInfo = -1; val.shipUnlockableID = -1; val.buyUnlockable = true; val.returnFromStorage = false; val.itemCost = 0; val.creatureFileID = -1; val.creatureName = ""; val.storyLogFileID = -1; val.overrideOptions = false; val.acceptAnything = false; val.loadImageSlowly = false; val.persistentImage = false; if (terminalEvent != null) { val.terminalEvent = terminalEvent; } return val; } private static TerminalKeyword CreateTerminalKeyword(string name, string word, TerminalNode resultNode) { TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val).name = name; val.word = word; val.specialKeywordResult = resultNode; return val; } private static void AddKeywordToTerminal(TerminalKeyword keyword) { int num = TerminalPatch.nList.allKeywords.Length; Array.Resize(ref TerminalPatch.nList.allKeywords, num + 1); TerminalPatch.nList.allKeywords[num] = keyword; Logger.LogInfo((object)("Added " + keyword.word + " (" + ((Object)keyword).name + ") keyword to Terminal.allKeywords")); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("NoteBoxz.SelectableInteriors"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } private void NetcodePatcher() { Type[] types = Assembly.GetExecutingAssembly().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) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "NoteBoxz.SelectableInteriors"; public const string PLUGIN_NAME = "SelectableInteriors"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace SelectableInteriors.Patches { [HarmonyPatch(typeof(TVScript))] public class ExampleTVPatch { [HarmonyPatch("SwitchTVLocalClient")] [HarmonyPrefix] private static void SwitchTVPrefix(TVScript __instance) { StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn); } } [HarmonyPatch(typeof(RoundManager))] public class RoundManagerPatch { public static Dictionary<SelectableLevel, IntWithRarity[]> InitalRaries = new Dictionary<SelectableLevel, IntWithRarity[]>(); public static bool Newfloor; [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostFix(RoundManager __instance) { ((Component)__instance).gameObject.AddComponent<SelectableInteriorsSynchronizer>(); SelectableInteriors.SelectableInteriorsSynchronizer = ((Component)__instance).GetComponent<SelectableInteriorsSynchronizer>(); SelectableInteriors.Logger.LogDebug((object)"SelectableInteriorsSynchronizer added to RoundManager"); } [HarmonyPatch("GenerateNewFloor")] [HarmonyPrefix] public static void GenerateNewFloorPreFix() { Newfloor = true; } [HarmonyPatch("GenerateNewFloor")] [HarmonyPostfix] public static void GenerateNewFloorPostFix() { Newfloor = false; } [HarmonyPatch("GetRandomWeightedIndex")] [HarmonyPrefix] public static bool Prefix(int[] weights, Random randomSeed, ref int __result) { if (Newfloor) { string text = Regex.Replace(StartOfRound.Instance.currentLevel.PlanetName, "^\\d+", "").Trim().ToLower(); foreach (string item in SelectableInteriors.ParseStringList(SelectableInteriors.MoonBlackListString)) { if (item.ToLower().Contains(text.ToLower())) { SelectableInteriors.Logger.LogInfo((object)("SelectableInteriors: " + text + " is blacklisted, not forcing any level")); return true; } } SelectableInteriors.Logger.LogInfo((object)$"RandomWeightIndex called when loading new floor with {randomSeed} seed and {weights.Length} weights"); if (SelectableInteriors.ValidDungens.Keys.Contains(SelectableInteriors.LVidForceing)) { __result = SelectableInteriors.LVidForceing; SelectableInteriors.Logger.LogMessage((object)$"Forced ID: {SelectableInteriors.LVidForceing}"); if (RoundManager.Instance.currentLevel.dungeonFlowTypes.Length - 1 < __result) { SelectableInteriors.Logger.LogWarning((object)$"Current Level doesn't have {__result} as a flow type! Injecting flow..."); if (!InitalRaries.ContainsKey(RoundManager.Instance.currentLevel)) { InitalRaries.Add(RoundManager.Instance.currentLevel, RoundManager.Instance.currentLevel.dungeonFlowTypes); } Array.Resize(ref RoundManager.Instance.currentLevel.dungeonFlowTypes, __result + 1); } if (RoundManager.Instance.currentLevel.dungeonFlowTypes[__result] != StartOfRoundPatch.FlowTypes[__result]) { RoundManager.Instance.currentLevel.dungeonFlowTypes[__result] = StartOfRoundPatch.FlowTypes[__result]; SelectableInteriors.Logger.LogMessage((object)$"Injected flow at index {__result}"); } return false; } if (InitalRaries.ContainsKey(RoundManager.Instance.currentLevel)) { int num = RoundManager.Instance.currentLevel.dungeonFlowTypes.Length; int num2 = InitalRaries[RoundManager.Instance.currentLevel].Length; SelectableInteriors.Logger.LogMessage((object)("Resetting " + RoundManager.Instance.currentLevel.PlanetName + "'s flows back to default" + $" ({num} -> {num2})")); RoundManager.Instance.currentLevel.dungeonFlowTypes = InitalRaries[RoundManager.Instance.currentLevel]; } } return true; } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { public static List<IntWithRarity> FlowTypes = new List<IntWithRarity>(); [HarmonyPatch("StartGame")] [HarmonyPrefix] public static void StartGamePreFix(StartOfRound __instance) { if (!((NetworkBehaviour)__instance).IsServer) { return; } SelectableInteriors.MoonBlackListString = SelectableInteriors.SelectableInteriorsMoonBlacklist.Value; SelectableInteriors.SelectableInteriorsSynchronizer.SyncMoonBlackListClientRpc(SelectableInteriors.MoonBlackListString); if (!SelectableInteriors.FullRandom) { return; } Dictionary<int, string> dictionary = new Dictionary<int, string>(SelectableInteriors.ValidDungens); List<int> list = new List<int>(); foreach (KeyValuePair<int, string> item in dictionary) { foreach (string item2 in SelectableInteriors.ParseStringList(SelectableInteriors.FullRandomBlacklist.Value)) { if (item2.ToLower() == item.Value.ToLower()) { SelectableInteriors.Logger.LogDebug((object)$"SelectableInteriors: {item.Key} {item.Value} is blacklisted, removing from FullRandom options"); list.Add(item.Key); } } } foreach (int item3 in list) { dictionary.Remove(item3); } int index = Random.Range(0, dictionary.Count); SelectableInteriors.LVidForceing = dictionary.ElementAt(index).Key; SelectableInteriors.SelectableInteriorsSynchronizer.SelectedIndex.Value = SelectableInteriors.LVidForceing; SelectableInteriors.Logger.LogInfo((object)$"FullRandom is set to true, returning random LV id {SelectableInteriors.LVidForceing} ({dictionary.ElementAt(index).Value}) (possible ids: 0-{dictionary.Count - 1})"); } public static void SetFlows(StartOfRound __instance) { Dictionary<int, string> dictionary = new Dictionary<int, string>(); dictionary = LLL_GETMOONFLOWS(); SelectableInteriors.ValidDungens.Clear(); foreach (KeyValuePair<int, string> item in dictionary) { SelectableInteriors.ValidDungens.Add(item.Key, item.Value); SelectableInteriors.AddChangeNode(item.Key, item.Value); } PopulateFlowTypes(); SelectableInteriors.AddNoneChangeNode(); SelectableInteriors.AddFullRandomNode(); string text = string.Join("\n", dictionary.Select((KeyValuePair<int, string> kvp) => $"{kvp.Value} ({kvp.Key})")); SelectableInteriors.InteriorViewNode.displayText = "Possible Interiors: \n" + text + " \n \n Use the command 'SetInside ID' to force an interior to be loaded \n"; SelectableInteriors.DefaultInteriorID = SelectableInteriors.Config.Bind<int>("General", "Default Interior ID", -1, "Default Interior ID to be forced whenever the game is started. (Set to -1 to not use) Possible Flows: \n" + text); SelectableInteriors.DefaultFullRandom = SelectableInteriors.Config.Bind<bool>("General", "Full Random", false, "Sets Full Random mode on by default. (Default: false)"); SelectableInteriors.SelectableInteriorsMoonBlacklist = SelectableInteriors.Config.Bind<string>("General", "SelectableInteriors Moon Blacklist", "", "Comma-separated list of moon names to blacklist from SelectableInteriors. (Default: empty)"); SelectableInteriors.FullRandomBlacklist = SelectableInteriors.Config.Bind<string>("General", "Full Random Blacklist", "", "Comma-separated list of interiors names to blacklist from Full Random. (Default: empty)"); SelectableInteriors.FullRandom = SelectableInteriors.DefaultFullRandom.Value; SelectableInteriors.Logger.LogInfo((object)$"DefaultFullRandom is set to {SelectableInteriors.DefaultFullRandom.Value}"); SelectableInteriors.LVidForceing = SelectableInteriors.DefaultInteriorID.Value; SelectableInteriors.Logger.LogInfo((object)$"DefaultInteriorID is set to {SelectableInteriors.DefaultInteriorID.Value}"); if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { BindLCConfigs(); } } public static void BindLCConfigs() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown LethalConfigManager.SetModDescription("Allows you to select which interior will be loaded"); LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(SelectableInteriors.DefaultInteriorID)); LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(SelectableInteriors.DefaultFullRandom)); LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(SelectableInteriors.SelectableInteriorsMoonBlacklist)); LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(SelectableInteriors.FullRandomBlacklist)); } public static void PopulateFlowTypes() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown FlowTypes = new List<IntWithRarity>(); for (int i = 0; i < SelectableInteriors.ValidDungens.Count; i++) { FlowTypes.Add(new IntWithRarity(0, 0, (LevelAmbienceLibrary)null)); } foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { if (SelectableInteriors.ValidDungens.Keys.Contains(extendedDungeonFlow.DungeonID)) { SelectableInteriors.Logger.LogInfo((object)$"Adding {extendedDungeonFlow.DungeonName} ({extendedDungeonFlow.DungeonID}) to the flowTypes list"); IntWithRarity val = new IntWithRarity(0, 0, (LevelAmbienceLibrary)null); val.id = extendedDungeonFlow.DungeonID; val.overrideLevelAmbience = null; FlowTypes[extendedDungeonFlow.DungeonID] = val; } } } public static Dictionary<int, string> LLL_GETMOONFLOWS() { Dictionary<int, string> dictionary = new Dictionary<int, string>(); foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { dictionary.Add(extendedDungeonFlow.DungeonID, extendedDungeonFlow.DungeonName); } return dictionary; } } [HarmonyPatch(typeof(Terminal))] public class TerminalPatch { public static TerminalNodesList nList; [HarmonyPatch("Start")] [HarmonyPostfix] public static void Start(Terminal __instance) { if (__instance.terminalNodes.allKeywords != null) { nList = __instance.terminalNodes; int num = __instance.terminalNodes.allKeywords.Length; Array.Resize(ref __instance.terminalNodes.allKeywords, num + 1); __instance.terminalNodes.allKeywords[num] = SelectableInteriors.InteriorViewKeyword; SelectableInteriors.Logger.LogInfo((object)"Added SelectableInteriors keyword to Terminal.allKeywords"); StartOfRoundPatch.SetFlows(StartOfRound.Instance); } else { SelectableInteriors.Logger.LogWarning((object)"Unable to add SelectableInteriors keyword: allKeywords is null"); } } [HarmonyPatch("RunTerminalEvents")] [HarmonyPostfix] public static void RunTerminalEventsPatch(TerminalNode node) { try { if (node.terminalEvent.StartsWith("SetLV")) { string[] array = node.terminalEvent.Split(' '); if (array[1] == "FullRandom") { SelectableInteriors.FullRandom = true; SelectableInteriors.Logger.LogInfo((object)"Changed level to FullRandom"); } else { int num = (SelectableInteriors.LVidForceing = int.Parse(array[1])); SelectableInteriors.FullRandom = false; SelectableInteriors.Logger.LogInfo((object)$"Changed level to {num}"); } } } catch { } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace NoteBoxz.SelectableInteriors.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }