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 ColorRooms v1.0.0
ColorRooms.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; [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("ColorRooms")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ColorRooms")] [assembly: AssemblyTitle("ColorRooms")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ColorRooms { [BepInPlugin("josh.colorrooms", "ColorRooms", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string GUID = "josh.colorrooms"; public const string NAME = "ColorRooms"; public const string VERSION = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<int> ColorPrice; internal static ConfigEntry<int> HubPrice; internal static ConfigEntry<float> LightBrightness; internal static ConfigEntry<float> LightRange; internal static ConfigEntry<float> LightSpacing; private void Awake() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ColorPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "ColoredRoomPrice", 250, "Price of each colored room (StockRoom1 ... StockRoom6)."); HubPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "RoomHubPrice", 1250, "Price of RoomHub."); LightBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "Brightness", 3f, "Multiplier on the always-on ceiling lights. Raise it if rooms are still dim, lower it if too bright. Restart the game after changing."); LightRange = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "Range", 14f, "How far each ceiling light reaches (meters)."); LightSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Lighting", "Spacing", 8.5f, "Distance between ceiling lights (meters). Smaller = more lights, brighter and more even."); Rooms.Define(); new Harmony("josh.colorrooms").PatchAll(typeof(Patches)); Log.LogInfo((object)"ColorRooms 1.0.0 loaded."); } } internal class RoomDef { public string Name; public bool Hub; public bool Tint; public Color DoorColor; public Vector3 WorldPos; public int Price; public GameObject Prefab; public TerminalNode Node; public int UnlockableId = -1; } internal static class Patches { [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch(typeof(GameNetworkManager), "Start")] private static void AfterNetworkManagerStart() { Rooms.CreatePrefabs(); } [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch(typeof(StartOfRound), "Awake")] private static void AfterRoundAwake(StartOfRound __instance) { Rooms.RegisterUnlockables(__instance); } [HarmonyPrefix] [HarmonyPriority(0)] [HarmonyPatch(typeof(StartOfRound), "Start")] private static void BeforeRoundStart(StartOfRound __instance) { Rooms.RegisterUnlockables(__instance); } [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch(typeof(Terminal), "Awake")] private static void AfterTerminalAwake(Terminal __instance) { Rooms.RegisterTerminal(__instance); } } internal static class Rooms { private const string TemplateName = "MelMStockRoom0"; private const string TemplateUnlockable = "StockRoom0"; private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const float FloorZ = -1f; private const float CeilZ = 4.5f; private const float DoorWallY = -3.1f; private const float T = 0.2f; private const float DoorwayWidth = 3f; private const float DoorwayHeight = 3.5f; internal static readonly List<RoomDef> Defs = new List<RoomDef>(); private static bool prefabsCreated; private static GameObject holder; private static GameObject lampTemplate; internal static void Define() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) Defs.Clear(); (string, Color)[] array = new(string, Color)[6] { ("StockRoom1", new Color(0.75f, 0.1f, 0.1f)), ("StockRoom2", new Color(0.85f, 0.4f, 0.08f)), ("StockRoom3", new Color(0.85f, 0.75f, 0.12f)), ("StockRoom4", new Color(0.15f, 0.6f, 0.2f)), ("StockRoom5", new Color(0.12f, 0.32f, 0.8f)), ("StockRoom6", new Color(0.48f, 0.18f, 0.7f)) }; for (int i = 0; i < array.Length; i++) { Defs.Add(new RoomDef { Name = array[i].Item1, Tint = true, DoorColor = array[i].Item2, WorldPos = new Vector3(-300f + (float)i * 120f, 800f, 0f), Price = Plugin.ColorPrice.Value }); } Defs.Add(new RoomDef { Name = "RoomHub", Hub = true, Tint = false, WorldPos = new Vector3(0f, 800f, 400f), Price = Plugin.HubPrice.Value }); } internal static void CreatePrefabs() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (prefabsCreated) { return; } GameObject val = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)delegate(GameObject g) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)g != (Object)null && ((Object)g).name == "MelMStockRoom0") { Scene scene = g.scene; if (!((Scene)(ref scene)).IsValid()) { return (Object)(object)g.transform.parent == (Object)null; } } return false; }); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"Could not find MelMStockRoom0. Is Pocket Rooms MelanieMelicious installed and enabled?"); return; } holder = new GameObject("ColorRoomsPrefabs"); holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)holder); ((Object)holder).hideFlags = (HideFlags)61; lampTemplate = MakeLampTemplate(); foreach (RoomDef def in Defs) { try { GameObject val2 = Object.Instantiate<GameObject>(val, holder.transform); ((Object)val2).name = "ColorRoom_" + def.Name; Customize(val2, def); SetNetworkHash(val2, "josh.colorrooms." + def.Name); NetworkManager.Singleton.AddNetworkPrefab(val2); def.Prefab = val2; Plugin.Log.LogInfo((object)("Created room prefab " + def.Name)); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to create " + def.Name + ": " + ex)); } } prefabsCreated = true; } private static void Customize(GameObject go, RoomDef def) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) Transform transform = go.transform; Transform val = transform.Find("PocketRoomDoor0"); Transform val2 = transform.Find("StockRoom0.1"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { throw new Exception("StockRoom0 layout changed (door or room not found)."); } MonoBehaviour[] components = go.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val3 in components) { if ((Object)(object)val3 != (Object)null && ((object)val3).GetType().Name == "DuskUnlockable") { Object.DestroyImmediate((Object)(object)val3); } } MonoBehaviour val4 = ((IEnumerable<MonoBehaviour>)go.GetComponents<MonoBehaviour>()).FirstOrDefault((Func<MonoBehaviour, bool>)((MonoBehaviour m) => (Object)(object)m != (Object)null && ((object)m).GetType().Name == "PocketRoom")); if ((Object)(object)val4 == (Object)null) { throw new Exception("PocketRoom component not found."); } FieldInfo? field = ((object)val4).GetType().GetField("position", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { throw new Exception("PocketRoom.position field not found."); } field.SetValue(val4, def.WorldPos); Transform obj = val2.Find("Model0"); Transform val5 = val2.Find("Model1"); Material[] sharedMaterials = ((Renderer)((Component)obj).GetComponent<MeshRenderer>()).sharedMaterials; Material val6 = sharedMaterials[0]; Material mat = ((sharedMaterials.Length > 1) ? sharedMaterials[1] : sharedMaterials[0]); Mesh sharedMesh = ((Component)val5).GetComponent<MeshFilter>().sharedMesh; Material sharedMaterial = ((Renderer)((Component)val5).GetComponent<MeshRenderer>()).sharedMaterial; ((Component)obj).gameObject.SetActive(false); List<GameObject> list = new List<GameObject>(); for (int num = 0; num < val2.childCount; num++) { if (((Object)val2.GetChild(num)).name.StartsWith("FurnitureSpawn")) { list.Add(((Component)val2.GetChild(num)).gameObject); } } foreach (GameObject item in list) { Object.DestroyImmediate((Object)(object)item); } float num2 = -17f; float num3 = (def.Hub ? 51f : 17f); float num4 = -3.1f; float num5 = (def.Hub ? 32.9f : 14.9f); float num6 = (num2 + num3) / 2f; float num7 = (num4 + num5) / 2f; float num8 = num3 - num2; float num9 = num5 - num4; GameObject val7 = new GameObject("BoxShell") { layer = ((Component)val2).gameObject.layer }; val7.transform.SetParent(val2, false); Transform transform2 = val7.transform; Slab(transform2, "Floor", new Vector3(num2 - 0.2f, num4 - 0.2f, -1.2f), new Vector3(num3 + 0.2f, num5 + 0.2f, -1f), sharedMesh, mat); Slab(transform2, "Ceiling", new Vector3(num2 - 0.2f, num4 - 0.2f, 4.5f), new Vector3(num3 + 0.2f, num5 + 0.2f, 4.7f), sharedMesh, val6); Material mat2 = (def.Tint ? Tinted(val6, def.DoorColor, "ColorRoomWall_" + def.Name) : val6); Slab(transform2, "WallFront", new Vector3(num2 - 0.2f, num4 - 0.2f, -1f), new Vector3(num3 + 0.2f, num4, 4.5f), sharedMesh, mat2); Slab(transform2, "WallBack", new Vector3(num2 - 0.2f, num5, -1f), new Vector3(num3 + 0.2f, num5 + 0.2f, 4.5f), sharedMesh, mat2); Slab(transform2, "WallLeft", new Vector3(num2 - 0.2f, num4, -1f), new Vector3(num2, num5, 4.5f), sharedMesh, mat2); Slab(transform2, "WallRight", new Vector3(num3, num4, -1f), new Vector3(num3 + 0.2f, num5, 4.5f), sharedMesh, mat2); if (def.Hub) { float num10 = 17f; float num11 = 14.9f; WallWithDoorwayAlongY(transform2, "DividerX_Front", num10, num4, num11, sharedMesh, val6); WallWithDoorwayAlongY(transform2, "DividerX_Back", num10, num11, num5, sharedMesh, val6); WallWithDoorwayAlongX(transform2, "DividerY_Left", num11, num2, num10, sharedMesh, val6); WallWithDoorwayAlongX(transform2, "DividerY_Right", num11, num10, num3, sharedMesh, val6); } val5.localPosition = new Vector3(num6, num7, 1.75f); val5.localScale = new Vector3(num8 + 1f, num9 + 1f, 6f); BoxCollider component = ((Component)val2).GetComponent<BoxCollider>(); component.center = new Vector3(num6, num7, 1.75f); component.size = new Vector3(num8 + 1f, num9 + 1f, 6.5f); Transform val8 = val2.Find("Nav/Nav0"); if ((Object)(object)val8 != (Object)null) { val8.localPosition = new Vector3(num6, -1.52f, 0f - num7); val8.localScale = new Vector3(num8, 1f, num9); } Transform val9 = val2.Find("LightSwitch"); if ((Object)(object)val9 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val9).gameObject); } AddCeilingLights(val2, num2, num3, num4, num5); Transform val10 = val.Find("Model0"); Transform val11 = val2.Find("Model2"); if (def.Tint) { Material val12 = null; Transform[] array = (Transform[])(object)new Transform[2] { val10, val11 }; foreach (Transform val13 in array) { if ((Object)(object)val13 == (Object)null) { continue; } MeshRenderer component2 = ((Component)val13).GetComponent<MeshRenderer>(); Material[] sharedMaterials2 = ((Renderer)component2).sharedMaterials; for (int num12 = 0; num12 < sharedMaterials2.Length; num12++) { if (!((Object)(object)sharedMaterials2[num12] == (Object)null) && ((Object)sharedMaterials2[num12]).name.StartsWith("MetalFlat0")) { if ((Object)(object)val12 == (Object)null) { val12 = Tinted(sharedMaterials2[num12], def.DoorColor, "ColorRoomDoor_" + def.Name); } sharedMaterials2[num12] = val12; } } ((Renderer)component2).sharedMaterials = sharedMaterials2; } } if (def.Hub) { if ((Object)(object)val10 != (Object)null) { AddHubIcon(val10, sharedMesh, sharedMaterial); } if ((Object)(object)val11 != (Object)null) { AddHubIcon(val11, sharedMesh, sharedMaterial); } } Transform val14 = val2.Find("Nav"); if ((Object)(object)val14 != (Object)null) { MonoBehaviour val15 = ((IEnumerable<MonoBehaviour>)((Component)val14).GetComponents<MonoBehaviour>()).FirstOrDefault((Func<MonoBehaviour, bool>)((MonoBehaviour m) => (Object)(object)m != (Object)null && ((object)m).GetType().Name == "NavMeshSurface")); if ((Object)(object)val15 != (Object)null) { go.AddComponent<NavRebuilder>().surface = val15; } } } private static Material Tinted(Material src, Color color, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(src) { name = name }; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } else { val.color = color; } return val; } private static GameObject MakeLampTemplate() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) Light val = null; GameObject val2 = ((IEnumerable<GameObject>)Resources.FindObjectsOfTypeAll<GameObject>()).FirstOrDefault((Func<GameObject, bool>)delegate(GameObject g) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)g != (Object)null && ((Object)g).name == "StockRoom0Light") { Scene scene = g.scene; return !((Scene)(ref scene)).IsValid(); } return false; }); if ((Object)(object)val2 != (Object)null) { val = val2.GetComponentsInChildren<Light>(true).FirstOrDefault(); } if ((Object)(object)val == (Object)null) { val = ((IEnumerable<Light>)Resources.FindObjectsOfTypeAll<Light>()).FirstOrDefault((Func<Light, bool>)delegate(Light l) { //IL_000f: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if ((Object)(object)l != (Object)null) { Scene scene = ((Component)l).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { return (int)l.type == 2; } } return false; }); } if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"No light found to copy; rooms will only have the original light switch lights."); return null; } Plugin.Log.LogInfo((object)("Ceiling lights copied from '" + ((Object)val).name + "' (type " + ((object)val.type/*cast due to .constrained prefix*/).ToString() + ", intensity " + val.intensity + ", range " + val.range + ").")); GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, holder.transform); ((Object)val3).name = "ColorRoomLamp"; for (int num = val3.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val3.transform.GetChild(num)).gameObject); } Component[] components = val3.GetComponents<Component>(); foreach (Component val4 in components) { if (!((Object)(object)val4 == (Object)null) && !(val4 is Transform) && !(val4 is Light) && !IsHdrp(val4) && val4 is MonoBehaviour && !(val4 is NetworkObject)) { Object.DestroyImmediate((Object)(object)val4); } } components = val3.GetComponents<Component>(); foreach (Component val5 in components) { if (!((Object)(object)val5 == (Object)null) && !(val5 is Transform) && !(val5 is Light) && !IsHdrp(val5)) { Object.DestroyImmediate((Object)(object)val5); } } Light component = val3.GetComponent<Light>(); ((Behaviour)component).enabled = true; component.type = (LightType)2; component.shadows = (LightShadows)0; component.color = new Color(1f, 0.97f, 0.9f); return val3; } private static bool IsHdrp(Component c) { return (((object)c).GetType().Namespace ?? "").StartsWith("UnityEngine.Rendering"); } private static void AddCeilingLights(Transform room, float xmin, float xmax, float ymin, float ymax) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)lampTemplate == (Object)null) { return; } GameObject val = new GameObject("CeilingLights"); val.layer = ((Component)room).gameObject.layer; val.transform.SetParent(room, false); float num = Mathf.Max(3f, Plugin.LightSpacing.Value); int num2 = Mathf.Max(1, Mathf.RoundToInt((xmax - xmin) / num)); int num3 = Mathf.Max(1, Mathf.RoundToInt((ymax - ymin) / num)); float num4 = (xmax - xmin) / (float)num2; float num5 = (ymax - ymin) / (float)num3; float num6 = 4f; for (int i = 0; i < num2; i++) { for (int j = 0; j < num3; j++) { GameObject obj = Object.Instantiate<GameObject>(lampTemplate, val.transform); ((Object)obj).name = "Lamp_" + i + "_" + j; obj.transform.localPosition = new Vector3(xmin + num4 * ((float)i + 0.5f), ymin + num5 * ((float)j + 0.5f), num6); obj.transform.localRotation = Quaternion.identity; ConfigureLamp(obj); } } } private static void ConfigureLamp(GameObject lamp) { Light component = lamp.GetComponent<Light>(); float num = Mathf.Max(0f, Plugin.LightBrightness.Value); component.range = Plugin.LightRange.Value; Component val = ((IEnumerable<Component>)lamp.GetComponents<Component>()).FirstOrDefault((Func<Component, bool>)((Component c) => (Object)(object)c != (Object)null && ((object)c).GetType().Name == "HDAdditionalLightData")); bool flag = false; if ((Object)(object)val != (Object)null) { try { PropertyInfo property = ((object)val).GetType().GetProperty("intensity", BindingFlags.Instance | BindingFlags.Public); if (property != null && property.CanRead && property.CanWrite) { float num2 = Convert.ToSingle(property.GetValue(val)); if (num2 <= 0f) { num2 = 1000f; } property.SetValue(val, num2 * num); flag = true; } PropertyInfo property2 = ((object)val).GetType().GetProperty("range", BindingFlags.Instance | BindingFlags.Public); if (property2 != null && property2.CanWrite) { property2.SetValue(val, Plugin.LightRange.Value); } MethodInfo method = ((object)val).GetType().GetMethod("EnableShadows", BindingFlags.Instance | BindingFlags.Public); if (method != null && method.GetParameters().Length == 1) { method.Invoke(val, new object[1] { false }); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not set HDRP light values: " + ex.Message)); } } if (!flag) { component.intensity = ((component.intensity > 0f) ? component.intensity : 1f) * num; } } private static void WallWithDoorwayAlongY(Transform parent, string name, float x, float a, float b, Mesh cube, Material mat) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) float num = (a + b) / 2f; float num2 = 1.5f; float num3 = 0.1f; Slab(parent, name + "_A", new Vector3(x - num3, a, -1f), new Vector3(x + num3, num - num2, 4.5f), cube, mat); Slab(parent, name + "_B", new Vector3(x - num3, num + num2, -1f), new Vector3(x + num3, b, 4.5f), cube, mat); Slab(parent, name + "_Top", new Vector3(x - num3, num - num2, 2.5f), new Vector3(x + num3, num + num2, 4.5f), cube, mat); } private static void WallWithDoorwayAlongX(Transform parent, string name, float y, float a, float b, Mesh cube, Material mat) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) float num = (a + b) / 2f; float num2 = 1.5f; float num3 = 0.1f; Slab(parent, name + "_A", new Vector3(a, y - num3, -1f), new Vector3(num - num2, y + num3, 4.5f), cube, mat); Slab(parent, name + "_B", new Vector3(num + num2, y - num3, -1f), new Vector3(b, y + num3, 4.5f), cube, mat); Slab(parent, name + "_Top", new Vector3(num - num2, y - num3, 2.5f), new Vector3(num + num2, y + num3, 4.5f), cube, mat); } private static GameObject Slab(Transform parent, string name, Vector3 min, Vector3 max, Mesh cube, Material mat, bool collider = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.layer = ((Component)parent).gameObject.layer; try { val.tag = "Concrete"; } catch { } val.transform.SetParent(parent, false); val.transform.localPosition = (min + max) / 2f; val.transform.localRotation = Quaternion.identity; val.transform.localScale = max - min; val.AddComponent<MeshFilter>().sharedMesh = cube; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat; if (collider) { val.AddComponent<BoxCollider>(); } return val; } private static void AddHubIcon(Transform doorModel, Mesh cube, Material mat) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("HubIcon"); val.layer = ((Component)doorModel).gameObject.layer; val.transform.SetParent(doorModel, false); float[] array = new float[2] { 0.011f, -0.211f }; foreach (float num in array) { Piece(val.transform, new Vector3(0f, num, 2.2f), new Vector3(0.16f, 0.02f, 0.16f), 0f, cube, mat); (float, float)[] array2 = new(float, float)[4] { (-1f, -1f), (1f, -1f), (-1f, 1f), (1f, 1f) }; for (int j = 0; j < array2.Length; j++) { (float, float) tuple = array2[j]; float item = tuple.Item1; float item2 = tuple.Item2; float num2 = 1f / Mathf.Sqrt(2f); float yAngle = Mathf.Atan2(item, item2) * 57.29578f; float num3 = 0.32999998f; float num4 = 0.59999996f; Piece(val.transform, new Vector3(item * num3 * num2, num, 2.2f + item2 * num3 * num2), new Vector3(0.05f, 0.02f, 0.5f), yAngle, cube, mat); Piece(val.transform, new Vector3(item * num4 * num2, num, 2.2f + item2 * num4 * num2), new Vector3(0.1f, 0.02f, 0.1f), 45f, cube, mat); } } } private static void Piece(Transform parent, Vector3 pos, Vector3 scale, float yAngle, Mesh cube, Material mat) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("IconPiece") { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localRotation = Quaternion.Euler(0f, yAngle, 0f); val.transform.localScale = scale; val.AddComponent<MeshFilter>().sharedMesh = cube; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat; } private static void SetNetworkHash(GameObject go, string key) { uint num = 2166136261u; foreach (char c in key) { num ^= c; num *= 16777619; } NetworkObject component = go.GetComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if ((Object)(object)component == (Object)null || field == null) { throw new Exception("Could not set network id."); } field.SetValue(component, num); } internal static void RegisterUnlockables(StartOfRound sor) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_010b: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown if (!prefabsCreated || (Object)(object)sor == (Object)null || (Object)(object)sor.unlockablesList == (Object)null) { return; } List<UnlockableItem> unlockables = sor.unlockablesList.unlockables; UnlockableItem val = ((IEnumerable<UnlockableItem>)unlockables).FirstOrDefault((Func<UnlockableItem, bool>)((UnlockableItem u) => u != null && u.unlockableName == "StockRoom0")); if (val == null || (Object)(object)val.shopSelectionNode == (Object)null) { Plugin.Log.LogWarning((object)"StockRoom0 unlockable not found yet; will retry."); return; } foreach (RoomDef def in Defs) { if (!((Object)(object)def.Prefab == (Object)null)) { int num = unlockables.FindIndex((UnlockableItem u) => u != null && u.unlockableName == def.Name); UnlockableItem val2; if (num < 0) { val2 = new UnlockableItem { unlockableName = def.Name, prefabObject = def.Prefab, unlockableType = val.unlockableType, alwaysInStock = true, IsPlaceable = true, canBeStored = true, maxNumber = 1, spawnPrefab = true }; unlockables.Add(val2); num = unlockables.Count - 1; } else { val2 = unlockables[num]; val2.prefabObject = def.Prefab; } def.UnlockableId = num; AutoParentToShip component = def.Prefab.GetComponent<AutoParentToShip>(); if ((Object)(object)component != (Object)null) { component.unlockableID = num; } PlaceableShipObject[] componentsInChildren = def.Prefab.GetComponentsInChildren<PlaceableShipObject>(true); for (int num2 = 0; num2 < componentsInChildren.Length; num2++) { componentsInChildren[num2].unlockableID = num; } if ((Object)(object)val2.shopSelectionNode == (Object)null || val2.shopSelectionNode.shipUnlockableID != num) { val2.shopSelectionNode = MakeShopNode(val.shopSelectionNode, def, num); } val2.shopSelectionNode.itemCost = def.Price; def.Node = val2.shopSelectionNode; } } Terminal val3 = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val3 != (Object)null) { RegisterTerminal(val3); } } private static TerminalNode MakeShopNode(TerminalNode src, RoomDef def, int idx) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown TerminalNode val = Object.Instantiate<TerminalNode>(src); ((Object)val).name = def.Name + "ShopSelectionNode"; val.displayText = (val.displayText ?? "").Replace("StockRoom0", def.Name); val.creatureName = def.Name; val.itemCost = def.Price; val.shipUnlockableID = idx; if (val.terminalOptions != null) { CompatibleNoun[] array = (CompatibleNoun[])(object)new CompatibleNoun[val.terminalOptions.Length]; for (int i = 0; i < array.Length; i++) { CompatibleNoun val2 = val.terminalOptions[i]; CompatibleNoun val3 = new CompatibleNoun(val2?.noun, val2?.result); if (val2 != null && (Object)(object)val2.noun != (Object)null && val2.noun.word == "confirm" && (Object)(object)val2.result != (Object)null) { TerminalNode val4 = Object.Instantiate<TerminalNode>(val2.result); ((Object)val4).name = def.Name + "ConfirmNode"; val4.displayText = (val4.displayText ?? "").Replace("StockRoom0", def.Name); val4.creatureName = def.Name; val4.itemCost = def.Price; val4.shipUnlockableID = idx; val3.result = val4; } array[i] = val3; } val.terminalOptions = array; } return val; } internal static void RegisterTerminal(Terminal term) { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown if ((Object)(object)term == (Object)null || (Object)(object)term.terminalNodes == (Object)null || term.terminalNodes.allKeywords == null) { return; } List<TerminalKeyword> list = term.terminalNodes.allKeywords.ToList(); TerminalKeyword val = ((IEnumerable<TerminalKeyword>)list).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => (Object)(object)k != (Object)null && k.word == "buy")); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Terminal 'buy' keyword not found."); return; } List<CompatibleNoun> list2 = ((IEnumerable<CompatibleNoun>)(((object)val.compatibleNouns) ?? ((object)new CompatibleNoun[0]))).ToList(); bool flag = false; foreach (RoomDef def in Defs) { if (!((Object)(object)def.Node == (Object)null)) { string word = def.Name.ToLowerInvariant(); TerminalKeyword noun = ((IEnumerable<TerminalKeyword>)list).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => (Object)(object)k != (Object)null && k.word == word)); if ((Object)(object)noun == (Object)null) { noun = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)noun).name = def.Name + "Keyword"; noun.word = word; noun.isVerb = false; noun.defaultVerb = val; list.Add(noun); flag = true; } CompatibleNoun val2 = ((IEnumerable<CompatibleNoun>)list2).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun cn) => cn != null && (Object)(object)cn.noun == (Object)(object)noun)); if (val2 == null) { list2.Add(new CompatibleNoun(noun, def.Node)); flag = true; } else if ((Object)(object)val2.result != (Object)(object)def.Node) { val2.result = def.Node; } } } if (flag) { term.terminalNodes.allKeywords = list.ToArray(); val.compatibleNouns = list2.ToArray(); Plugin.Log.LogInfo((object)("Terminal: added buy entries for " + string.Join(", ", Defs.Select((RoomDef x) => x.Name)))); } } } public class NavRebuilder : MonoBehaviour { public MonoBehaviour surface; private IEnumerator Start() { yield return (object)new WaitForSeconds(3f); if ((Object)(object)surface == (Object)null) { yield break; } try { MethodInfo method = ((object)surface).GetType().GetMethod("BuildNavMesh", BindingFlags.Instance | BindingFlags.Public); if (method != null) { method.Invoke(surface, null); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Nav rebuild failed (enemies may not roam the whole room): " + ex.Message)); } } } }