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 GordionOverhaul v0.1.5
GordionOverhaul.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using GordionOverhaul.Core; using HarmonyLib; using HolidayShared; using Microsoft.CodeAnalysis; using ModMenu; using TMPro; using Unity.Collections; 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("GordionOverhaul")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4+50567b48833e7ac594e4acbd6232ad83b0e9dd15")] [assembly: AssemblyProduct("GordionOverhaul")] [assembly: AssemblyTitle("GordionOverhaul")] [assembly: AssemblyVersion("0.1.4.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 HolidayShared { internal enum ChristmasMode { Auto, On, Off } internal static class Season { internal static bool IsChristmas(DateTime day) { if (day.Month != 12) { if (day.Month == 1) { return day.Day <= 6; } return false; } return true; } internal static bool Decide(ChristmasMode mode, DateTime today) { return mode switch { ChristmasMode.Auto => IsChristmas(today), ChristmasMode.On => true, _ => false, }; } internal static DateTime Today(string testDate, DateTime now, out bool overridden) { overridden = TryParse(testDate, now, out var day); if (!overridden) { return now.Date; } return day; } internal static bool TryParse(string testDate, DateTime now, out DateTime day) { day = default(DateTime); string text = (testDate ?? "").Trim(); if (text.Length == 0) { return false; } if (DateTime.TryParseExact(text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out day)) { return true; } if (DateTime.TryParseExact(now.Year + "-" + text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out day)) { return true; } return false; } internal static string Why(ChristmasMode mode, DateTime today, bool overridden) { switch (mode) { case ChristmasMode.On: return "set to On"; case ChristmasMode.Off: return "set to Off"; default: { string text = today.ToString("d MMM", CultureInfo.InvariantCulture) + (overridden ? " (test date)" : ""); if (!IsChristmas(today)) { return "Auto, " + text + " is outside 1 Dec to 6 Jan"; } return "Auto, " + text + " is in 1 Dec to 6 Jan"; } } } } internal sealed class Holiday { internal readonly ConfigEntry<ChristmasMode> Mode; internal readonly ConfigEntry<string> TestDate; private readonly string _tag; private readonly ManualLogSource _log; private readonly Action _broadcast; private readonly string _msgAsk; private readonly string _msgState; private NetworkManager _nm; private bool _ownRegistered; private bool _decided; private bool _hostOn; private bool _hostKnown; private bool _hostWord; private bool _last; private string _why = "not in a lobby"; private float _nextDateCheck; private float _nextAsk; private int _asks; private bool _wasLanded; internal bool On { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { return false; } if (singleton.IsServer) { if (!_decided) { Decide("lobby opened"); } return _hostOn; } if (_hostKnown) { return _hostWord; } return false; } } internal string Why { get { if (!IsClient) { return _why; } if (!_hostKnown) { return "no word from the host"; } return "the host's word"; } } internal bool IsClient { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { return !singleton.IsServer; } return false; } } internal bool IsHost { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { return singleton.IsServer; } return false; } } internal byte Field => On ? ((byte)1) : ((byte)0); internal event Action<bool> Changed; internal Holiday(ConfigFile config, ManualLogSource log, string tag, Action broadcast = null) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown _tag = tag; _log = log; _broadcast = broadcast; _msgAsk = tag + ".Xmas.Ask"; _msgState = tag + ".Xmas"; Mode = config.Bind<ChristmasMode>("Holiday", "Christmas", ChristmasMode.Auto, "Christmas decorations. Auto: on from 1 December to 6 January by the host's date. On or Off: always. The host's setting counts for everyone; a client follows the host, and stays off when the host doesn't have it."); TestDate = config.Bind<string>("Holiday", "ChristmasTestDate", "", "Testing: the date Auto pretends it is, as 2026-12-24 or 12-24 (this year). Blank uses the real date."); Mode.SettingChanged += delegate { Decide("Christmas set to " + Mode.Value); }; TestDate.SettingChanged += delegate { Decide("test date " + (string.IsNullOrWhiteSpace(TestDate.Value) ? "cleared" : TestDate.Value)); }; GameObject val = new GameObject("HolidayRunner." + tag) { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); val.AddComponent<HolidayRunner>().Holiday = this; } internal void WriteField(FastBufferWriter w) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) byte field = Field; ((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref field, default(ForPrimitives)); } internal void ReadField(FastBufferReader r) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (((FastBufferReader)(ref r)).Position + 1 <= ((FastBufferReader)(ref r)).Length) { byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); FromHost((b & 1) != 0); } else { FromHost(null); } } internal void FromHost(bool? on) { if (IsClient) { bool num = _hostKnown != on.HasValue || _hostWord != (on == true); _hostKnown = on.HasValue; _hostWord = on == true; if (num) { _log.LogInfo((object)(_tag + ": Christmas " + ((on == true) ? "on" : "off") + ", " + (on.HasValue ? "the host's word" : "the host sends no Christmas field") + ".")); } Refresh(); } } internal void Decide(string reason) { if (!IsHost) { return; } bool overridden; DateTime today = Season.Today(TestDate.Value, DateTime.Now, out overridden); bool flag = Season.Decide(Mode.Value, today); _why = Season.Why(Mode.Value, today, overridden); bool flag2 = !_decided; bool num = flag2 || flag != _hostOn; _decided = true; _hostOn = flag; if (num) { _log.LogInfo((object)(_tag + ": Christmas " + (flag ? "on" : "off") + " (" + _why + "; " + reason + ").")); Refresh(); if (!flag2) { Broadcast(); } } } internal void Broadcast() { if (!IsHost) { return; } if (_broadcast != null) { try { _broadcast(); return; } catch (Exception ex) { _log.LogWarning((object)(_tag + ": Christmas broadcast: " + ex.Message)); return; } } foreach (ulong connectedClientsId in NetworkManager.Singleton.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendState(connectedClientsId); } } } internal void Tick() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { if ((Object)(object)_nm != (Object)null) { EndSession(); } Refresh(); return; } if ((Object)(object)singleton != (Object)(object)_nm) { if ((Object)(object)_nm != (Object)null) { EndSession(); } _nm = singleton; } if (_broadcast == null) { TickOwnMessage(singleton); } if (singleton.IsServer) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { bool shipHasLanded = instance.shipHasLanded; if (shipHasLanded && !_wasLanded) { Decide("landing"); } else if (instance.inShipPhase && Time.unscaledTime >= _nextDateCheck) { _nextDateCheck = Time.unscaledTime + 10f; Decide("in orbit"); } _wasLanded = shipHasLanded; } else if (!_decided) { Decide("lobby opened"); } } Refresh(); } private void EndSession() { if (_ownRegistered && (Object)(object)_nm != (Object)null && _nm.CustomMessagingManager != null) { try { _nm.CustomMessagingManager.UnregisterNamedMessageHandler(_msgAsk); } catch { } try { _nm.CustomMessagingManager.UnregisterNamedMessageHandler(_msgState); } catch { } } _nm = null; _ownRegistered = false; _decided = false; _hostOn = false; _hostKnown = false; _hostWord = false; _why = "not in a lobby"; _nextDateCheck = 0f; _nextAsk = 0f; _asks = 0; _wasLanded = false; } private void Refresh() { bool flag = On; if (flag == _last) { return; } _last = flag; Action<bool> action = this.Changed; if (action == null) { return; } Delegate[] invocationList = action.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action<bool> action2 = (Action<bool>)invocationList[i]; try { action2(flag); } catch (Exception arg) { _log.LogError((object)string.Format("{0}: Christmas {1} handler: {2}", _tag, flag ? "on" : "off", arg)); } } } private void TickOwnMessage(NetworkManager nm) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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 (!_ownRegistered) { CustomMessagingManager customMessagingManager = nm.CustomMessagingManager; if (nm.IsServer) { customMessagingManager.RegisterNamedMessageHandler(_msgAsk, (HandleNamedMessageDelegate)delegate(ulong sender, FastBufferReader r) { SendState(sender); }); } else { customMessagingManager.RegisterNamedMessageHandler(_msgState, (HandleNamedMessageDelegate)delegate(ulong sender, FastBufferReader r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReadField(r); }); } _ownRegistered = true; } if (!nm.IsServer && nm.IsConnectedClient && !_hostKnown && !(Time.unscaledTime < _nextAsk)) { _nextAsk = Time.unscaledTime + ((_asks < 10) ? 3f : 15f); _asks++; Send(_msgAsk, 0uL, null); } } private void SendState(ulong to) { Send(_msgState, to, WriteField); } private static void Send(string name, ulong to, Action<FastBufferWriter> write) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, 64); try { write?.Invoke(val); singleton.CustomMessagingManager.SendNamedMessage(name, to, val, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } } internal sealed class HolidayRunner : MonoBehaviour { internal Holiday Holiday; private float _next; private void Update() { if (Holiday == null || Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.25f; try { Holiday.Tick(); } catch (Exception ex) { Debug.LogWarning((object)("Holiday tick: " + ex.Message)); } } } internal static class HolidayMenu { private static readonly ChristmasMode[] Modes = new ChristmasMode[3] { ChristmasMode.Auto, ChristmasMode.On, ChristmasMode.Off }; private static readonly string[] ModeNames = new string[3] { "Auto", "On", "Off" }; private static readonly string[] DateNames = new string[3] { "real date", "24 Dec", "1 Feb" }; private static readonly string[] Dates = new string[3] { "", "12-24", "02-01" }; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register(string tab, Holiday holiday) { MenuApi.Choice(tab, "Christmas", ModeNames, (Func<int, string>)((int i) => SetMode(holiday, Modes[i])), true, false, (Func<string>)(() => NotHosting(holiday)), "Auto: 1 Dec to 6 Jan by your date. The host's pick counts for everyone and swaps the decorations now"); MenuApi.Choice(tab, "Christmas test date", DateNames, (Func<int, string>)((int i) => SetDate(holiday, i)), true, false, (Func<string>)(() => NotHosting(holiday)), "testing: the date Auto pretends it is (ChristmasTestDate), for everyone"); } private static string NotHosting(Holiday h) { if (!h.IsClient) { return null; } return "the host decides"; } private static string SetMode(Holiday h, ChristmasMode mode) { bool num = h.Mode.Value == mode; h.Mode.Value = mode; if (num) { h.Decide("F6 row"); } return Said(h, "Christmas " + mode); } private static string SetDate(Holiday h, int i) { bool num = h.TestDate.Value == Dates[i]; h.TestDate.Value = Dates[i]; if (num) { h.Decide("F6 row"); } return Said(h, (i == 0) ? "test date cleared" : ("test date " + DateNames[i])); } private static string Said(Holiday h, string what) { if (!h.IsHost) { return what + ": saved; it counts when you host"; } return what + ": " + (h.On ? "on" : "off") + " for everyone (" + h.Why + ")"; } } } namespace GordionOverhaul { internal static class Contract { public const string BundleFile = "gordion"; public const string Prefab = "GordionDressing"; public const string YardPrefab = "GordionYard"; public const string DeskAnchor = "DeskAnchor"; public const string Shared = "Shared"; public const string EyeBall = "EyeBall"; public const string RateText = "RateText"; public const string RateCell = "RateCell"; public const string BoardText = "BoardText"; public const string VanillaWall = "Map/CompanyPlanet/Cube.003"; public const string VanillaWallLights = "LightsContainer"; public const string VanillaWallLightPrefix = "LEDHangingLight"; public const string OutsideNodeTag = "OutsideAINode"; } internal static class Dressing { private class DestroyMeshWith : MonoBehaviour { internal Mesh Mesh; private void OnDestroy() { if ((Object)(object)Mesh != (Object)null) { Object.Destroy((Object)(object)Mesh); } } } private static AssetBundle _bundle; private static GameObject _prefab; private static bool _loadFailed; internal static int CurrentWall = -1; private static int _movedScene = -1; private static int _clearedScene = -1; internal static void Dress(Scene scene) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>(); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"No sell desk in CompanyBuilding; leaving the scene as it is."); return; } GameObject val2 = Prefab(); if ((Object)(object)val2 == (Object)null) { return; } MoveWallBack(scene); ClearContainers(scene); PlaceYard(scene); StartOfRound instance = StartOfRound.Instance; TimeOfDay instance2 = TimeOfDay.Instance; WallId wallId = Net.WallFor(((Object)(object)instance != (Object)null) ? instance.randomMapSeed : 0, ((Object)(object)instance2 != (Object)null) ? instance2.timesFulfilledQuota : 0); GameObject root = Object.Instantiate<GameObject>(val2); ((Object)root).name = "GordionDressing"; SceneManager.MoveGameObjectToScene(root, scene); string[] array = Walls.PrefabsToLoad(wallId, (string n) => (Object)(object)root.transform.Find(n) != (Object)null); foreach (string text in array) { GameObject val3 = _bundle.LoadAsset<GameObject>(text); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)("The bundle has no " + text + "; showing the shared parts only.")); } else { ((Object)Object.Instantiate<GameObject>(val3, root.transform, false)).name = text; } } foreach (WallId value in Enum.GetValues(typeof(WallId))) { Transform val4 = root.transform.Find(Walls.PrefabGroup(value)); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(value == wallId); } } if (!Anchor(root.transform, ((Component)val).transform)) { Object.Destroy((Object)(object)root); return; } HideVanilla(scene); Physics.SyncTransforms(); DropBuriedNodes(root.transform); root.AddComponent<Driver>().Init(val, wallId); CurrentWall = (int)wallId; Plugin.Log.LogInfo((object)($"Gordion dressed with the {wallId} wall (style {Net.Style}" + ((!Net.IsClient) ? "" : (Net.HostKnown ? ", the host's" : ", own config: no word from the host yet")) + ").")); if (Net.IsHost) { Net.Broadcast(); } } private static GameObject DressedRoot(out Scene scene) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) scene = SceneManager.GetSceneByName("CompanyBuilding"); if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded) { return null; } GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (((Object)val).name == "GordionDressing") { return val; } } return null; } internal static GameObject Root() { Scene scene; return DressedRoot(out scene); } internal static bool RedressIfNeeded() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Scene scene; GameObject val = DressedRoot(out scene); if ((Object)(object)val == (Object)null) { return false; } StartOfRound instance = StartOfRound.Instance; TimeOfDay instance2 = TimeOfDay.Instance; WallId wallId = Net.WallFor(((Object)(object)instance != (Object)null) ? instance.randomMapSeed : 0, ((Object)(object)instance2 != (Object)null) ? instance2.timesFulfilledQuota : 0); if (wallId == (WallId)CurrentWall) { if (Net.IsHost) { Net.Broadcast(); } return false; } Plugin.Log.LogInfo((object)$"Swapping the Gordion wall: {(WallId)CurrentWall} -> {wallId}."); ((Object)val).name = "GordionDressing_old"; val.SetActive(false); Object.Destroy((Object)(object)val); CurrentWall = -1; Dress(scene); return true; } internal static void Forget() { CurrentWall = -1; if (Net.IsHost) { Net.Broadcast(); } } private static GameObject Prefab() { if ((Object)(object)_prefab != (Object)null || _loadFailed) { return _prefab; } string text = Path.Combine(Plugin.Folder, "gordion"); if (!File.Exists(text)) { _loadFailed = true; Plugin.Log.LogError((object)("Bundle not found at " + text + "; Gordion stays vanilla.")); return null; } _bundle = AssetBundle.LoadFromFile(text); _prefab = (((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset<GameObject>("GordionDressing") : null); if ((Object)(object)_prefab == (Object)null) { _loadFailed = true; Plugin.Log.LogError((object)("Bundle " + text + " has no GordionDressing prefab; Gordion stays vanilla.")); } return _prefab; } private static void MoveWallBack(Scene scene) { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (_movedScene == ((Scene)(ref scene)).handle) { return; } _movedScene = ((Scene)(ref scene)).handle; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-12.5f, 0f, 0f); int num = 0; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val2 in rootGameObjects) { if (((Object)val2).name == "Environment") { string[] environmentAtWall = Yard.EnvironmentAtWall; foreach (string text in environmentAtWall) { Transform val3 = val2.transform.Find(text); if ((Object)(object)val3 == (Object)null) { if (text.EndsWith("Cube.003")) { Plugin.Log.LogWarning((object)("Didn't find " + text + " to move back (game update?).")); } } else { val3.position += val; num++; } } } else if (!(((Object)val2).name == "GordionDressing") && !(((Object)val2).name == "GordionYard") && Yard.MovesWithWall(((Object)val2).name, PlaceOf(val2.transform).x)) { Transform transform = val2.transform; transform.position += val; num++; } } Plugin.Log.LogInfo((object)($"Moved the Company wall {12.5f:F1} m back ({num} objects): " + $"{Yard.GapBefore:F1} m -> {Yard.GapAfter:F1} m of open floor in front of the ship.")); } private static Vector3 PlaceOf(Transform t) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Collider[] componentsInChildren = ((Component)t).GetComponentsInChildren<Collider>(true); if (componentsInChildren.Length == 0) { return t.position; } Bounds bounds = componentsInChildren[0].bounds; Collider[] array = componentsInChildren; foreach (Collider val in array) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } return ((Bounds)(ref bounds)).center; } private static void ClearContainers(Scene scene) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if (_clearedScene == ((Scene)(ref scene)).handle) { return; } _clearedScene = ((Scene)(ref scene)).handle; Transform val = null; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val2 in rootGameObjects) { if (((Object)val2).name == "Environment") { val = val2.transform.Find("Map/ShippingContainers"); } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Didn't find the shipping containers to clear (game update?)."); return; } List<Bounds> list = (from c in ((Component)val).GetComponentsInChildren<Collider>(true) where !c.isTrigger select c.bounds).ToList(); ((Component)val).gameObject.SetActive(false); HashSet<GameObject> hashSet = new HashSet<GameObject>(); rootGameObjects = GameObject.FindGameObjectsWithTag("OutsideAINode"); foreach (GameObject val3 in rootGameObjects) { Vector3 p = val3.transform.position; if (list.Any((Bounds b) => Yard.Floating(p.x, p.y, p.z, ((Bounds)(ref b)).min.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).min.z, ((Bounds)(ref b)).max.x, ((Bounds)(ref b)).max.z))) { hashSet.Add(val3); } } DropNodes(hashSet); Plugin.Log.LogInfo((object)$"Cleared the shipping containers ({list.Count} colliders) and {hashSet.Count} AI nodes on top of them."); } private static void PlaceYard(Scene scene) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!((Scene)(ref scene)).GetRootGameObjects().Any((GameObject g) => ((Object)g).name == "GordionYard")) { GameObject val = (((Object)(object)_bundle != (Object)null) ? _bundle.LoadAsset<GameObject>("GordionYard") : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"The bundle has no GordionYard; the yard has no props or floor behind the old wall line."); return; } GameObject obj = Object.Instantiate<GameObject>(val); ((Object)obj).name = "GordionYard"; SceneManager.MoveGameObjectToScene(obj, scene); ClearPad(obj.transform); } } private static void ClearPad(Transform yard) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(9.77f, -1.1f, -59.91f); Vector3 val2 = val; try { GameObject val3 = GameObject.FindGameObjectWithTag("ItemShipLandingNode"); if ((Object)(object)val3 != (Object)null) { val2 = val3.transform.position; } } catch (UnityException) { } if (Vector3.Distance(val2, val) > 0.5f) { Plugin.Log.LogWarning((object)$"The dropship lands at {val2}, not where it did when the yard was measured; clearing around the live spot."); } List<(Transform, Vector3, float, float)> list = new List<(Transform, Vector3, float, float)>(); List<string> list2 = new List<string>(); BoxCollider[] componentsInChildren = ((Component)yard).GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider val4 in componentsInChildren) { if (!Pad.Removable(PathOf(((Component)val4).transform, yard))) { continue; } Vector3 val5 = ((Component)val4).transform.InverseTransformPoint(val2) - val4.center; Vector3 val6 = Vector3.Scale(val4.size, ((Component)val4).transform.lossyScale); if (!(Pad.Distance(val5.x, val5.z, val6.x / 2f, val6.z / 2f) >= Pad.ClearRadius)) { Pad.CutHalf(val6.x, val6.z, out var hx, out var hz); list.Add((((Component)val4).transform, val4.center, hx, hz)); list2.Add(((Object)val4).name); ((Collider)val4).enabled = false; Transform val7 = (((Object)(object)((Component)val4).transform.parent != (Object)null) ? ((Component)val4).transform.parent.parent : null); Transform val8 = (((Object)(object)val7 != (Object)null) ? val7.Find("NavObstacles/" + ((Object)val4).name) : null); if ((Object)(object)val8 != (Object)null) { ((Component)val8).gameObject.SetActive(false); } } } if (list.Count == 0) { Plugin.Log.LogInfo((object)"The dropship pad was already clear."); return; } int num = 0; MeshFilter[] componentsInChildren2 = ((Component)yard).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val9 in componentsInChildren2) { Mesh sharedMesh = val9.sharedMesh; if ((Object)(object)sharedMesh == (Object)null) { continue; } if (!sharedMesh.isReadable) { Plugin.Log.LogWarning((object)(((Object)sharedMesh).name + " isn't readable; its props by the dropship pad stay visible.")); continue; } Vector3[] vertices = sharedMesh.vertices; bool[] array = new bool[vertices.Length]; bool flag = false; for (int j = 0; j < vertices.Length; j++) { Vector3 val10 = ((Component)val9).transform.TransformPoint(vertices[j]); foreach (var item in list) { Vector3 val11 = item.Item1.InverseTransformPoint(val10) - item.Item2; if (Mathf.Abs(val11.x) <= item.Item3 && Mathf.Abs(val11.z) <= item.Item4) { array[j] = true; flag = true; break; } } } if (!flag) { continue; } Mesh val12 = Object.Instantiate<Mesh>(sharedMesh); ((Object)val12).name = ((Object)sharedMesh).name + "_padclear"; for (int k = 0; k < val12.subMeshCount; k++) { int[] triangles = val12.GetTriangles(k); List<int> list3 = new List<int>(triangles.Length); for (int l = 0; l + 2 < triangles.Length; l += 3) { if (array[triangles[l]] && array[triangles[l + 1]] && array[triangles[l + 2]]) { num++; continue; } list3.Add(triangles[l]); list3.Add(triangles[l + 1]); list3.Add(triangles[l + 2]); } val12.SetTriangles(list3, k, false); } val9.sharedMesh = val12; ((Component)val9).gameObject.AddComponent<DestroyMeshWith>().Mesh = val12; } Plugin.Log.LogInfo((object)string.Format("Cleared the dropship pad ({0:F1} m around {1}): {2}; {3} triangles.", Pad.ClearRadius, val2, string.Join(", ", list2), num)); } internal static string PathOf(Transform t, Transform root) { string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root.parent) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private static void DropNodes(HashSet<GameObject> dropped) { foreach (GameObject item in dropped) { item.tag = "Untagged"; item.SetActive(false); } RoundManager instance = RoundManager.Instance; if (!((Object)(object)instance != (Object)null) || dropped.Count <= 0) { return; } if (instance.outsideAINodes != null) { instance.outsideAINodes = instance.outsideAINodes.Where((GameObject n) => !dropped.Contains(n)).ToArray(); } if (instance.outsideAINodesUnordered != null) { instance.outsideAINodesUnordered = instance.outsideAINodesUnordered.Where((GameObject n) => !dropped.Contains(n)).ToArray(); } } private static bool Anchor(Transform root, Transform desk) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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) Transform val = Find(root, "DeskAnchor"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"The prefab has no DeskAnchor; not placing it."); return false; } Quaternion val2 = desk.rotation * Quaternion.Inverse(val.rotation); if (Quaternion.Angle(Quaternion.identity, val2) > 1f) { Plugin.Log.LogWarning((object)$"The desk is turned {Quaternion.Angle(Quaternion.identity, val2):F1} degrees from where the wall was built; turning the wall with it."); } root.rotation = val2 * root.rotation; root.position += desk.position - val.position; Vector3 val3 = desk.position - val.position; if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f) { ManualLogSource log = Plugin.Log; val3 = desk.position - val.position; log.LogInfo((object)$"Desk is {((Vector3)(ref val3)).magnitude:F2} m from its authored spot (12.5 m is the wall moved back); wall moved to match."); } return true; } private static void HideVanilla(Scene scene) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown int num = 0; int num2 = 0; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (((Object)val).name == "DepositCounter") { foreach (Transform item in val.transform) { Transform val2 = item; if (Yard.IsDeskDressing(((Object)val2).name)) { Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; num++; } } } } else if (((Object)val).name == "Cube" && Yard.InWallBand(val.transform.position.x - -12.5f)) { Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; num++; } } else { if (((Object)val).name != "Environment") { continue; } Transform val3 = val.transform.Find("Map/CompanyPlanet/Cube.003"); if ((Object)(object)val3 != (Object)null) { Renderer[] componentsInChildren = ((Component)val3).GetComponents<Renderer>(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; num++; } } Transform val4 = val.transform.Find("LightsContainer"); if (!((Object)(object)val4 != (Object)null)) { continue; } foreach (Transform item2 in val4) { Transform val5 = item2; if (((Object)val5).name.StartsWith("LEDHangingLight")) { Renderer[] componentsInChildren = ((Component)val5).GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; num++; } Light[] componentsInChildren2 = ((Component)val5).GetComponentsInChildren<Light>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { ((Behaviour)componentsInChildren2[j]).enabled = false; num2++; } } } } } if (num == 0) { Plugin.Log.LogWarning((object)"Didn't find the vanilla Company wall to hide (game update?)."); } else { Plugin.Log.LogInfo((object)$"Hid {num} vanilla wall renderers and {num2} lights (colliders kept)."); } } private static void DropBuriedNodes(Transform root) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) Scene scene = ((Component)root).gameObject.scene; GameObject yard = ((IEnumerable<GameObject>)((Scene)(ref scene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == "GordionYard")); HashSet<GameObject> hashSet = new HashSet<GameObject>(); GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode"); foreach (GameObject val in array) { if (Physics.OverlapSphere(val.transform.position, 0.4f, -1, (QueryTriggerInteraction)1).Any((Collider h) => ((Component)h).transform.IsChildOf(root) || ((Object)(object)yard != (Object)null && ((Component)h).transform.IsChildOf(yard.transform)))) { hashSet.Add(val); } } DropNodes(hashSet); Plugin.Log.LogInfo((object)$"Dropped {hashSet.Count} outside AI nodes inside the new wall or the yard props."); } internal static Transform Find(Transform t, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)t).name == name) { return t; } foreach (Transform item in t) { Transform val = Find(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } internal class Driver : MonoBehaviour { private struct Posed { public Transform Part; public Transform P0; public Transform P1; public string Channel; } private struct Spinner { public Transform Part; public float Speed; } internal static Driver Instance; private DepositItemsDesk _desk; private readonly List<Transform> _eyes = new List<Transform>(); private readonly List<Quaternion> _eyeRest = new List<Quaternion>(); private readonly List<TMP_Text> _rate = new List<TMP_Text>(); private readonly List<TMP_Text>[] _cells = new List<TMP_Text>[4] { new List<TMP_Text>(), new List<TMP_Text>(), new List<TMP_Text>(), new List<TMP_Text>() }; private readonly List<TMP_Text> _board = new List<TMP_Text>(); private readonly Dictionary<string, List<GameObject>> _groups = new Dictionary<string, List<GameObject>>(); private readonly List<Posed> _posed = new List<Posed>(); private readonly List<Spinner> _spin = new List<Spinner>(); private Reaction _reaction; private float _reactionUntil; private float _nextRead; private Stage _stage; private MoodKind _mood; private string _moodName = ""; private readonly Dictionary<string, float> _chan = new Dictionary<string, float> { { "lid", 0.6f }, { "presence", 0f }, { "hatch", 0f }, { "alarm", 0f } }; internal void Init(DepositItemsDesk desk, WallId wall) { Instance = this; _desk = desk; Collect(((Component)this).transform); Read(first: true); Apply(1f); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal void React(Reaction r) { if (_reaction != Reaction.Attack || !(Time.time < _reactionUntil) || r == Reaction.Attack) { _reaction = r; _reactionUntil = Time.time + EyeRules.Hold(r); } } private void Collect(Transform t) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown if (!((Component)t).gameObject.activeSelf && ((Object)t).name.StartsWith("Wall_")) { return; } string name = ((Object)t).name; switch (name) { case "EyeBall": _eyes.Add(t); _eyeRest.Add(t.localRotation); break; case "RateText": Add(_rate, t); break; case "BoardText": Add(_board, t); break; default: { if (name.StartsWith("RateCell") && int.TryParse(name.Substring("RateCell".Length), out var result) && result >= 0 && result < 4) { Add(_cells[result], t); } else if (name.StartsWith("Stage_") || name.StartsWith("Mood_") || name.StartsWith("React_")) { if (!_groups.TryGetValue(name, out var value)) { value = (_groups[name] = new List<GameObject>()); } value.Add(((Component)t).gameObject); } else if (name.StartsWith("Drive.")) { string[] array = name.Split('.'); if (array.Length >= 3 && (Object)(object)t.parent != (Object)null) { string text = name.Substring("Drive.".Length); Transform val = t.parent.Find("Pose0." + text); Transform val2 = t.parent.Find("Pose1." + text); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { _posed.Add(new Posed { Part = t, P0 = val, P1 = val2, Channel = array[1] }); } else { Plugin.Log.LogWarning((object)(name + " has no Pose0/Pose1 siblings; left still.")); } } } else if (name.StartsWith("Spin.")) { string[] array2 = name.Split('.'); if (array2.Length >= 2 && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { _spin.Add(new Spinner { Part = t, Speed = result2 }); } } break; } } foreach (Transform item in t) { Transform t2 = item; Collect(t2); } } private static void Add(List<TMP_Text> list, Transform t) { TMP_Text component = ((Component)t).GetComponent<TMP_Text>(); if ((Object)(object)component != (Object)null) { list.Add(component); } } private void Update() { if (Time.time >= _nextRead) { Read(first: false); _nextRead = Time.time + 0.25f; } if (_reaction != Reaction.None && Time.time >= _reactionUntil) { _reaction = Reaction.None; } Apply(Mathf.Clamp01(Time.deltaTime * 3f)); Look(); } private void Read(bool first) { TimeOfDay instance = TimeOfDay.Instance; StartOfRound instance2 = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null) { return; } float companyBuyingRate = instance2.companyBuyingRate; int deadlineDaysAmount = ((instance.quotaVariables != null) ? instance.quotaVariables.deadlineDaysAmount : 3); _stage = Stages.Of(instance.daysUntilDeadline, deadlineDaysAmount, companyBuyingRate, instance.quotaFulfilled, instance.profitQuota); _moodName = (((Object)(object)instance.currentCompanyMood != (Object)null) ? ((Object)instance.currentCompanyMood).name : ""); _mood = Moods.Of(_moodName); string text = Readout.RateText(companyBuyingRate); foreach (TMP_Text item in _rate) { if (item.text != text) { item.text = text; } } char[] array = Readout.Cells(companyBuyingRate); for (int i = 0; i < 4; i++) { foreach (TMP_Text item2 in _cells[i]) { string text2 = array[i].ToString(); if (item2.text != text2) { item2.text = text2; } } } if (_board.Count > 0) { string text3 = string.Join("\n", Board.Lines(instance.daysUntilDeadline, Moods.Label(_mood, _moodName), instance.quotaFulfilled, instance.profitQuota, companyBuyingRate, (Plugin.Xmas != null && Plugin.Xmas.On) ? XmasRules.Want(instance2.randomMapSeed) : null, Net.Bonus)); foreach (TMP_Text item3 in _board) { if (item3.text != text3) { item3.text = text3; } } } foreach (KeyValuePair<string, List<GameObject>> group in _groups) { bool flag = (group.Key.StartsWith("Stage_") ? (group.Key == "Stage_" + _stage) : ((!group.Key.StartsWith("Mood_")) ? (group.Key == "React_" + _reaction) : (group.Key == "Mood_" + _mood))); foreach (GameObject item4 in group.Value) { if (item4.activeSelf != flag) { item4.SetActive(flag); } } } } private void Apply(float k) { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)_desk != (Object)null && _desk.doorOpen; bool flag2 = (Object)(object)_desk != (Object)null && _desk.attacking; Reaction reaction = (flag2 ? Reaction.Attack : _reaction); Ease("lid", EyeRules.Openness(_stage, _mood, reaction), k); Ease("presence", EyeRules.Presence(_stage), k * 0.3f); Ease("hatch", flag ? 1f : 0f, k); Ease("alarm", flag2 ? 1f : 0f, k * 2f); foreach (Posed item in _posed) { if (!((Object)(object)item.Part == (Object)null) && !((Object)(object)item.P0 == (Object)null) && !((Object)(object)item.P1 == (Object)null)) { float value; float num = (_chan.TryGetValue(item.Channel, out value) ? value : 0f); item.Part.localPosition = Vector3.LerpUnclamped(item.P0.localPosition, item.P1.localPosition, num); item.Part.localRotation = Quaternion.SlerpUnclamped(item.P0.localRotation, item.P1.localRotation, num); item.Part.localScale = Vector3.LerpUnclamped(item.P0.localScale, item.P1.localScale, num); } } float num2 = (flag2 ? 1.3f : ((_stage == Stage.Early) ? 0.4f : ((_stage == Stage.Mid) ? 0.7f : 1f))); foreach (Spinner item2 in _spin) { if ((Object)(object)item2.Part != (Object)null) { item2.Part.Rotate(0f, 0f, item2.Speed * num2 * Time.deltaTime, (Space)1); } } } private void Ease(string ch, float target, float k) { _chan[ch] = Mathf.Lerp(_chan[ch], target, k); } private void Look() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) if (_eyes.Count == 0) { return; } Vector3? val = null; if ((Object)(object)_desk != (Object)null && (_desk.doorOpen || _reaction == Reaction.HatchOpen)) { val = ((Component)_desk).transform.position; } else if (Net.EyeFollows && _mood != MoodKind.Asleep) { val = Nearest(); } for (int i = 0; i < _eyes.Count; i++) { Transform val2 = _eyes[i]; if (!((Object)(object)val2 == (Object)null)) { Quaternion val3 = _eyeRest[i]; if (val.HasValue && (Object)(object)val2.parent != (Object)null) { Vector3 val4 = val2.parent.InverseTransformPoint(val.Value) - val2.localPosition; Quaternion val5 = _eyeRest[i]; Vector3 val6 = Quaternion.Inverse(val5) * val4; float yaw = Mathf.Atan2(val6.x, val6.z) * 57.29578f; float y = val6.y; Vector2 val7 = new Vector2(val6.x, val6.z); float pitch = (0f - Mathf.Atan2(y, ((Vector2)(ref val7)).magnitude)) * 57.29578f; EyeRules.ClampLook(ref yaw, ref pitch); val3 = val5 * Quaternion.Euler(pitch, yaw, 0f); } float num = ((_reaction == Reaction.HatchOpen || _reaction == Reaction.Attack) ? 10f : 2.5f); val2.localRotation = Quaternion.Slerp(val2.localRotation, val3, Mathf.Clamp01(Time.deltaTime * num)); } } } private Vector3? Nearest() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null) { return null; } Vector3? result = null; float num = float.MaxValue; Vector3 position = _eyes[0].position; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead) { Vector3 val2 = (((Object)(object)val.gameplayCamera != (Object)null) ? ((Component)val.gameplayCamera).transform.position : (((Component)val).transform.position + Vector3.up * 1.6f)); Vector3 val3 = val2 - position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } } internal static class MenuHooks { internal const string ModMenuGuid = "daniel.lethalcompany.modmenu"; private const string Tab = "Gordion"; private static readonly WallStyle[] Styles = new WallStyle[5] { WallStyle.Random, WallStyle.PerQuota, WallStyle.Ribcage, WallStyle.Vault, WallStyle.Engine }; private static readonly string[] Names = new string[5] { "Random", "New each quota", "Ribcage", "Vault", "Engine" }; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { MenuApi.Choice("Gordion", "Wall style", Names, (Func<int, string>)((int i) => Pick(Styles[i])), true, false, (Func<string>)null, "the Company wall for everyone; swaps now if you're at the Company, otherwise on the next visit"); MenuApi.Toggle("Gordion", "Eye follows players", (Func<bool>)(() => Net.EyeFollows), (Func<bool, string>)delegate(bool on) { Plugin.EyeFollows.Value = on; return (!on) ? "the eye stays still, for everyone" : "the eye follows players, for everyone"; }, true, false, (Func<string>)null, (string)null); HolidayMenu.Register("Gordion", Plugin.Xmas); MenuApi.Toggle("Gordion", "Giant Christmas tree", (Func<bool>)(() => Net.GiantTree), (Func<bool, string>)delegate(bool on) { Plugin.GiantTree.Value = on; if (Plugin.Xmas == null || !Plugin.Xmas.On) { if (!on) { return "giant tree off, for everyone"; } return "giant tree on: it stands while Christmas is on, for everyone"; } return (!on) ? "giant tree down, the racks are back, for everyone" : "giant tree up in the yard, for everyone"; }, true, false, (Func<string>)null, "the 55 m tree in the yard on the ship's right while Christmas is on; its racks are cleared"); MenuApi.Toggle("Gordion", "Holiday bonus (+5%, 24-26 Dec)", (Func<bool>)(() => Plugin.HolidayBonus.Value), (Func<bool, string>)delegate(bool on) { Plugin.HolidayBonus.Value = on; if (!on) { return "holiday bonus off"; } return (!Net.BonusHere()) ? "holiday bonus on: it pays on 24 to 26 Dec while Christmas is on" : "holiday bonus on: sales pay 5% more today, for everyone"; }, true, false, (Func<string>)null, "sales pay 5% more on 24 to 26 Dec while Christmas is on; off by default"); } private static string Pick(WallStyle style) { bool num = Plugin.Style.Value == style; int currentWall = Dressing.CurrentWall; Plugin.Style.Value = style; if (num && !Dressing.RedressIfNeeded()) { Net.Broadcast(); } if (Dressing.CurrentWall == -1) { return $"wall style {style}: shows on the next visit to the Company, for everyone"; } if (Dressing.CurrentWall == currentWall) { return $"wall style {style}: already up"; } return $"wall style {style}: swapped now, for everyone"; } } internal static class Net { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnState; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__27_0; internal void <Tick>b__27_0(ulong sender, FastBufferReader r) { SendState(sender); } } private const string MsgRequest = "daniel.gordion.req"; private const string MsgState = "daniel.gordion.state"; private const byte Version = 1; private static NetworkManager _nm; private static bool _registered; private static float _nextAsk; private static int _asks; internal static bool HostKnown; private static WallStyle _hostStyle; private static bool _hostEye = true; private static int _hostWall = -1; private static bool _hostBonus; private static bool? _hostTree; internal static bool Bonus { get { if (!IsClient) { return BonusHere(); } if (HostKnown) { return _hostBonus; } return false; } } internal static bool IsClient { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { return !singleton.IsServer; } return false; } } internal static bool IsHost { get { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { return singleton.IsServer; } return false; } } internal static bool GiantTree => XmasRules.Tree(IsClient, HostKnown, _hostTree, Plugin.GiantTree.Value); internal static WallStyle Style => Sync.Style(IsClient, HostKnown, _hostStyle, Plugin.Style.Value); internal static bool EyeFollows => Sync.EyeFollows(IsClient, HostKnown, _hostEye, Plugin.EyeFollows.Value); internal static bool BonusHere() { Holiday xmas = Plugin.Xmas; if (xmas == null || !Plugin.HolidayBonus.Value || !xmas.On) { return false; } bool overridden; DateTime dateTime = Season.Today(xmas.TestDate.Value, DateTime.Now, out overridden); return XmasRules.BonusDay(dateTime.Month, dateTime.Day); } internal static WallId WallFor(int randomMapSeed, int timesFulfilledQuota) { return Sync.Wall(IsClient, HostKnown, _hostStyle, _hostWall, Plugin.Style.Value, randomMapSeed, timesFulfilledQuota); } internal static void Tick() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_0078: 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: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || singleton.CustomMessagingManager == null) { if (_registered) { Reset(); } return; } if (!_registered || (Object)(object)singleton != (Object)(object)_nm) { if (_registered) { Reset(); } CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; if (singleton.IsServer) { object obj = <>c.<>9__27_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader r) { SendState(sender); }; <>c.<>9__27_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("daniel.gordion.req", (HandleNamedMessageDelegate)obj); } else { object obj2 = <>O.<0>__OnState; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnState; <>O.<0>__OnState = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("daniel.gordion.state", (HandleNamedMessageDelegate)obj2); } _registered = true; _nm = singleton; _nextAsk = 0f; _asks = 0; } if (!singleton.IsServer && singleton.IsConnectedClient && !HostKnown && !(Time.unscaledTime < _nextAsk)) { _nextAsk = Time.unscaledTime + Sync.AskEvery(_asks); _asks++; if (_asks <= 10 || _asks % 20 == 0) { Plugin.Log.LogInfo((object)$"Asking the host for its Gordion settings (try {_asks})."); } Send("daniel.gordion.req", 0uL, null); } } private static void Reset() { if (_registered && (Object)(object)_nm != (Object)null && _nm.CustomMessagingManager != null) { try { _nm.CustomMessagingManager.UnregisterNamedMessageHandler("daniel.gordion.req"); } catch { } try { _nm.CustomMessagingManager.UnregisterNamedMessageHandler("daniel.gordion.state"); } catch { } } _registered = false; _nm = null; HostKnown = false; _hostWall = -1; _hostBonus = false; _hostTree = null; } internal static void Broadcast() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.IsServer) { return; } foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendState(connectedClientsId); } } } private static void SendState(ulong to) { WallStyle style = Plugin.Style.Value; bool eye = Plugin.EyeFollows.Value; int wall = Dressing.CurrentWall; StartOfRound instance = StartOfRound.Instance; int seed = (((Object)(object)instance != (Object)null) ? instance.randomMapSeed : 0); Send("daniel.gordion.state", to, delegate(FastBufferWriter w) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) byte b = 1; ((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref b, default(ForPrimitives)); int num = (int)style; ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref eye, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref wall, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<int>(ref seed, default(ForPrimitives)); bool flag = BonusHere(); ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); Plugin.Xmas?.WriteField(w); flag = Plugin.GiantTree.Value; ((FastBufferWriter)(ref w)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); }); } private static void OnState(ulong sender, FastBufferReader r) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); int num3 = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num3, default(ForPrimitives)); if (b >= 1) { if (((FastBufferReader)(ref r)).Position + 1 <= ((FastBufferReader)(ref r)).Length) { bool hostBonus = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref hostBonus, default(ForPrimitives)); _hostBonus = hostBonus; } else { _hostBonus = false; } Plugin.Xmas?.ReadField(r); if (((FastBufferReader)(ref r)).Position + 1 <= ((FastBufferReader)(ref r)).Length) { bool value = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref value, default(ForPrimitives)); _hostTree = value; } else { _hostTree = null; } bool flag2 = !HostKnown; WallStyle hostStyle = _hostStyle; HostKnown = true; _hostStyle = (Enum.IsDefined(typeof(WallStyle), num) ? ((WallStyle)num) : WallStyle.Random); _hostEye = flag; _hostWall = ((num2 >= 0 && num2 < 3) ? num2 : (-1)); ManualLogSource log = Plugin.Log; string text = string.Format("Host's Gordion: style {0}, eye {1}, ", _hostStyle, flag ? "follows" : "still"); object arg; if (_hostWall < 0) { arg = "not at the Company"; } else { WallId hostWall = (WallId)_hostWall; arg = "wall " + hostWall; } log.LogInfo((object)(text + string.Format("{0} (seed {1}){2}.", arg, num3, flag2 ? ", first word" : ""))); if (_hostWall >= 0 || flag2 || _hostStyle != hostStyle) { Dressing.RedressIfNeeded(); } } } internal static void ForgetVisit() { _hostWall = -1; } private static void Send(string name, ulong to, Action<FastBufferWriter> write) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, 256); try { write?.Invoke(val); singleton.CustomMessagingManager.SendNamedMessage(name, to, val, (NetworkDelivery)3); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } } internal class Runner : MonoBehaviour { private float _next; private void Update() { if (Time.unscaledTime < _next) { return; } _next = Time.unscaledTime + 0.25f; try { Net.Tick(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gordion sync: " + ex.Message)); } try { Xmas.Tick(); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Gordion Christmas: " + ex2.Message)); } } } internal static class Patches { internal static void Apply(Harmony h) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Hook(h, "OpenShutDoor", "OnDoor"); Hook(h, "MakeLoudNoise", "OnNoise"); Hook(h, "Attack", "OnAttack"); Hook(h, "SellAndDisplayItemProfits", "OnSale"); MethodInfo methodInfo = AccessTools.Method(typeof(DepositItemsDesk), "SellItemsOnServer", (Type[])null, (Type[])null); if (methodInfo == null) { Plugin.Log.LogWarning((object)"DepositItemsDesk.SellItemsOnServer not found; the holiday bonus is off."); } else { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), "SellBonus", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } private static IEnumerable<CodeInstruction> SellBonus(IEnumerable<CodeInstruction> code) { FieldInfo rate = AccessTools.Field(typeof(StartOfRound), "companyBuyingRate"); MethodInfo bonus = AccessTools.Method(typeof(Patches), "WithBonus", (Type[])null, (Type[])null); bool sawRate = false; bool done = false; foreach (CodeInstruction c in code) { yield return c; if (!done) { if (CodeInstructionExtensions.LoadsField(c, rate, false)) { sawRate = true; } else if (sawRate && c.opcode == OpCodes.Conv_I4) { yield return new CodeInstruction(OpCodes.Call, (object)bonus); done = true; } } } if (!done) { Plugin.Log.LogWarning((object)"SellItemsOnServer changed shape; the holiday bonus is off."); } } internal static int WithBonus(int profit) { if (!Net.BonusHere()) { return profit; } return XmasRules.WithBonus(profit); } private static void Hook(Harmony h, string target, string postfix) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(DepositItemsDesk), target, (Type[])null, (Type[])null); if (methodInfo == null) { Plugin.Log.LogWarning((object)("DepositItemsDesk." + target + " not found; that eye reaction is off.")); } else { h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Patches), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void OnDoor(bool open) { if (open) { Driver.Instance?.React(Reaction.HatchOpen); } } private static void OnNoise() { Driver.Instance?.React(Reaction.Warning); } private static void OnAttack() { Driver.Instance?.React(Reaction.Attack); } private static void OnSale() { Driver.Instance?.React(Reaction.Sale); } } public static class PluginInfo { public const string Guid = "daniel.lethalcompany.gordionoverhaul"; public const string Name = "GordionOverhaul"; public const string Version = "0.1.5"; } [BepInPlugin("daniel.lethalcompany.gordionoverhaul", "GordionOverhaul", "0.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<WallStyle> Style; internal static ConfigEntry<bool> EyeFollows; internal static ConfigEntry<bool> ForceWithOtherReskin; internal static ConfigEntry<bool> HolidayBonus; internal static ConfigEntry<bool> GiantTree; internal static Holiday Xmas; internal static string Folder; private readonly Harmony _harmony = new Harmony("daniel.lethalcompany.gordionoverhaul"); private void Awake() { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Style = ((BaseUnityPlugin)this).Config.Bind<WallStyle>("Wall", "WallStyle", WallStyle.Random, "Which Company wall shows. Random: a different wall each visit (the same for everyone with the mod). PerQuota: a new wall each quota, in the order Ribcage, Vault, Engine. Ribcage, Vault or Engine: always that wall."); EyeFollows = ((BaseUnityPlugin)this).Config.Bind<bool>("Eye", "EyeFollows", true, "The eye turns to follow the nearest player."); ForceWithOtherReskin = ((BaseUnityPlugin)this).Config.Bind<bool>("Compatibility", "ForceWithOtherReskin", false, "Dress the Company even when another Company reskin (such as WaffleHouseCompany) is installed."); HolidayBonus = ((BaseUnityPlugin)this).Config.Bind<bool>("Holiday", "HolidayBonus", false, "Host only: on 24 to 26 December (the host's date, or ChristmasTestDate) while Christmas is on, sales at the Company pay 5% more and the board says HOLIDAY BONUS +5%. Off by default."); GiantTree = ((BaseUnityPlugin)this).Config.Bind<bool>("Holiday", "GiantTree", true, "While Christmas is on: a giant lit tree (55 m, with a star on top) stands in the yard on the ship's right as you face the Company building, and the archive racks round its foot are cleared. The host's setting counts for everyone."); GiantTree.SettingChanged += delegate { if (!Net.IsClient) { Net.Broadcast(); } }; Xmas = new Holiday(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger, "GordionOverhaul", Net.Broadcast); Xmas.Changed += delegate(bool on) { Log.LogInfo((object)(on ? "Christmas on: decorating the Company" : "Christmas off: taking the Company's decorations down")); }; HolidayBonus.SettingChanged += delegate { if (!Net.IsClient) { Net.Broadcast(); } }; Patches.Apply(_harmony); if (Chainloader.PluginInfos.ContainsKey("daniel.lethalcompany.modmenu")) { MenuHooks.Register(); } SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!(((Scene)(ref scene)).name != "CompanyBuilding")) { if (OtherReskin() && !ForceWithOtherReskin.Value) { Log.LogWarning((object)"Another Company reskin is installed; leaving Gordion as it is (Compatibility > ForceWithOtherReskin)."); } else { Dressing.Dress(scene); } } }; SceneManager.sceneUnloaded += delegate(Scene scene) { if (!(((Scene)(ref scene)).name != "CompanyBuilding")) { Net.ForgetVisit(); Dressing.Forget(); } }; Style.SettingChanged += delegate { if (Net.IsClient) { Log.LogInfo((object)$"Wall style {Style.Value} saved; the host picks the wall in this lobby."); } else if (!Dressing.RedressIfNeeded()) { Net.Broadcast(); } }; EyeFollows.SettingChanged += delegate { if (!Net.IsClient) { Net.Broadcast(); } }; GameObject val = new GameObject("GordionOverhaulRunner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>(); Log.LogInfo((object)string.Format("{0} {1} loaded (wall style {2})", "GordionOverhaul", "0.1.5", Style.Value)); } private static bool OtherReskin() { return Chainloader.PluginInfos.Values.Any((PluginInfo p) => p.Metadata.GUID != "daniel.lethalcompany.gordionoverhaul" && (p.Metadata.Name ?? "").IndexOf("waffle", StringComparison.OrdinalIgnoreCase) >= 0); } } internal static class Xmas { internal const string BundleFile = "gordion_xmas"; private static readonly string[] Shared = new string[2] { "Hall", "Mouth" }; private static AssetBundle _bundle; private static bool _failed; private static GameObject _dressed; private static readonly List<GameObject> _up = new List<GameObject>(); private static AudioClip _bells; private static bool _treeUp; private static TreeCut _cut; internal static bool Up => _up.Count > 0; internal static void Tick() { GameObject val = Dressing.Root(); if (Plugin.Xmas == null || !Plugin.Xmas.On || !((Object)(object)val != (Object)null)) { if (Up || (Object)(object)_bundle != (Object)null) { TakeDown((Plugin.Xmas != null && Plugin.Xmas.On) ? "left the Company" : "Christmas off"); } _failed = false; } else if ((!Up || !((Object)(object)_dressed == (Object)(object)val) || !_up.All((GameObject g) => (Object)(object)g != (Object)null) || _treeUp != Net.GiantTree) && (!_failed || !((Object)(object)_dressed == (Object)(object)val))) { Clear(); _dressed = val; try { PutUp(val); _failed = !Up; } catch (Exception ex) { Plugin.Log.LogError((object)("Gordion Christmas decorations failed: " + ex)); Clear(); _failed = true; } } } internal static void TakeDown(string why) { if (Up) { Plugin.Log.LogInfo((object)("Gordion Christmas decorations down (" + why + ").")); } Clear(); _bells = null; if ((Object)(object)_bundle != (Object)null) { _bundle.Unload(true); _bundle = null; } } private static void Clear() { if (_cut != null) { _cut.Restore(); _cut = null; } foreach (GameObject item in _up) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } _up.Clear(); _dressed = null; _treeUp = false; } private static bool Load() { if ((Object)(object)_bundle != (Object)null) { return true; } string text = Path.Combine(Plugin.Folder, "gordion_xmas"); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)"No gordion_xmas next to GordionOverhaul.dll; no Christmas at the Company."); return false; } _bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { Plugin.Log.LogError((object)"gordion_xmas didn't load."); return false; } _bells = _bundle.LoadAsset<AudioClip>("sleigh_bells"); return true; } private static void PutUp(GameObject root) { //IL_0052: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (!Load()) { return; } WallId currentWall = (WallId)Dressing.CurrentWall; string text = Walls.PrefabGroup(currentWall); Transform val = root.transform.Find(text); int num = 0; int num2 = 0; string[] shared = Shared; for (int i = 0; i < shared.Length; i++) { Place(shared[i], root.transform); } Scene scene = root.scene; GameObject val2 = ((IEnumerable<GameObject>)((Scene)(ref scene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == "GordionYard")); if ((Object)(object)val2 != (Object)null) { Place("Yard", val2.transform); } if ((Object)(object)val2 != (Object)null && Net.GiantTree) { PutUpTree(val2.transform); } _treeUp = Net.GiantTree; if ((Object)(object)val != (Object)null) { Place(text, val); } else { Plugin.Log.LogWarning((object)("No " + text + " under the dressing; its Christmas group stays off.")); } GameObject val3 = _bundle.LoadAsset<GameObject>("XmasG_Snowfall"); if ((Object)(object)val3 != (Object)null) { GameObject val4 = Object.Instantiate<GameObject>(val3); ((Object)val4).name = "GordionXmas_Snowfall"; SceneManager.MoveGameObjectToScene(val4, root.scene); val4.AddComponent<XmasSnow>(); _up.Add(val4); } GameObject val5 = new GameObject("GordionXmas_Driver"); SceneManager.MoveGameObjectToScene(val5, root.scene); XmasDriver xmasDriver = val5.AddComponent<XmasDriver>(); foreach (GameObject item in _up) { if ((Object)(object)item == (Object)null) { continue; } MeshRenderer[] componentsInChildren = item.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val6 in componentsInChildren) { string name = ((Object)((Component)val6).gameObject).name; int result; if (name.StartsWith("Bulb.")) { xmasDriver.AddBulb((Renderer)(object)val6, name); num++; } else if (name.StartsWith("Overlay.") && int.TryParse(name.Substring(8), out result)) { xmasDriver.AddPhase(((Component)val6).gameObject, result); num2++; } } AudioSource[] componentsInChildren2 = item.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val7 in componentsInChildren2) { if ((Object)(object)val7.clip != (Object)null) { xmasDriver.AddPa(val7); } } } _up.Add(val5); Plugin.Log.LogInfo((object)$"Gordion Christmas decorations up ({currentWall} wall): {_up.Count - 1} groups, {num} bulbs, {num2} chasing lights."); } private static void PutUpTree(Transform yard) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) GameObject val = _bundle.LoadAsset<GameObject>("XmasG_Tree"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"gordion_xmas has no XmasG_Tree; no giant tree."); return; } GameObject val2 = Object.Instantiate<GameObject>(val, yard, false); ((Object)val2).name = "Xmas_Tree"; _up.Add(val2); Transform val3 = val2.transform.Find("Tree"); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)"XmasG_Tree has no Tree node; the yard round it stays as it is."); } else { _cut = TreeCut.Clear(yard, val2.transform, val3.position, 12f); } } private static void Place(string group, Transform parent) { GameObject val = _bundle.LoadAsset<GameObject>("XmasG_" + group); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("gordion_xmas has no XmasG_" + group + ".")); return; } GameObject val2 = Object.Instantiate<GameObject>(val, parent, false); ((Object)val2).name = "Xmas_" + group; foreach (Transform item in (from t in val2.GetComponentsInChildren<Transform>(true) where ((Object)t).name.StartsWith("@") select t).ToList()) { Transform val3 = parent.Find(((Object)item).name.Substring(1).Replace('|', '/')); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)("Christmas: no " + ((Object)item).name.Substring(1) + " in " + ((Object)parent).name + "; that piece stays put.")); } else { item.SetParent(val3, false); _up.Add(((Component)item).gameObject); } } _up.Add(val2); } internal static void OnBell(AnimatedObjectTrigger trigger) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown if (Up && !((Object)(object)_bells == (Object)null) && !((Object)(object)trigger == (Object)null) && IsBell(((Component)trigger).transform)) { Vector3 position = ((Component)trigger).transform.position; GameObject val = new GameObject("GordionXmas_Bells"); val.transform.position = position; AudioSource obj = val.AddComponent<AudioSource>(); obj.spatialBlend = 1f; obj.minDistance = 3f; obj.maxDistance = 30f; obj.rolloffMode = (AudioRolloffMode)0; obj.volume = 0.45f; obj.pitch = Random.Range(0.96f, 1.04f); obj.dopplerLevel = 0f; obj.clip = _bells; obj.Play(); Object.Destroy((Object)val, _bells.length + 0.2f); } } private static bool IsBell(Transform t) { while ((Object)(object)t != (Object)null) { if (((Object)t).name.StartsWith("BellDinger")) { return true; } t = t.parent; } return false; } } internal sealed class XmasDriver : MonoBehaviour { private struct Bulb { public Renderer R; public int Sub; public Color C; public float W; public float P; } private static readonly Color[] Colours = (Color[])(object)new Color[6] { new Color(1f, 0.08f, 0.05f), new Color(0.1f, 0.9f, 0.2f), new Color(0.15f, 0.35f, 1f), new Color(1f, 0.72f, 0.3f), new Color(0.9f, 0.2f, 0.8f), new Color(1f, 0.55f, 0.18f) }; private const float Nits = 260f; private const float Min = 0.35f; private readonly List<Bulb> _bulbs = new List<Bulb>(); private readonly List<(GameObject go, int phase)> _phases = new List<(GameObject, int)>(); private readonly List<AudioSource> _pa = new List<AudioSource>(); private MaterialPropertyBlock _mpb; private float _next; private float _nextCarol; private Random _r = new Random(); internal void AddBulb(Renderer r, string name) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) int result; int num = (int.TryParse(name.Substring(5), out result) ? result : 0); int num2 = Array.FindIndex(r.sharedMaterials, (Material m) => (Object)(object)m != (Object)null && ((Object)m).name.StartsWith("Xmas_Bulb")); if (num2 >= 0) { float num3 = 2.5f + (float)_r.NextDouble() * 3.5f; _bulbs.Add(new Bulb { R = r, Sub = num2, C = ((Color)(ref Colours[Mathf.Clamp(num, 0, Colours.Length - 1)])).linear, W = MathF.PI * 2f / num3, P = (float)_r.NextDouble() * 6.2832f }); } } internal void AddPhase(GameObject go, int phase) { _phases.Add((go, phase)); } internal void AddPa(AudioSource a) { _pa.Add(a); _nextCarol = Time.time + 10f + (float)_r.NextDouble() * 20f; } private void Update() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (_pa.Count > 0 && time >= _nextCarol) { _nextCarol = time + 75f + (float)_r.NextDouble() * 90f; foreach (AudioSource item in _pa) { if ((Object)(object)item != (Object)null && !item.isPlaying) { item.pitch = 0.98f + (float)_r.NextDouble() * 0.03f; item.Play(); } } } if (time < _next) { return; } _next = time + 1f / 15f; _mpb = (MaterialPropertyBlock)(((object)_mpb) ?? ((object)new MaterialPropertyBlock())); foreach (Bulb bulb in _bulbs) { if (!((Object)(object)bulb.R == (Object)null)) { float num = Mathf.Lerp(0.35f, 1f, 0.5f + 0.5f * Mathf.Sin(time * bulb.W + bulb.P)); _mpb.Clear(); _mpb.SetColor("_EmissiveColor", bulb.C * (260f * num)); bulb.R.SetPropertyBlock(_mpb, bulb.Sub); } } foreach (var (val, phase) in _phases) { if (!((Object)(object)val == (Object)null)) { bool flag = XmasRules.PhaseLit(phase, time); if (val.activeSelf != flag) { val.SetActive(flag); } } } } } internal sealed class XmasSnow : MonoBehaviour { private ParticleSystem _ps; private void Awake() { _ps = ((Component)this).GetComponent<ParticleSystem>(); } private void LateUpdate() { //IL_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; Camera val = (((Object)(object)instance != (Object)null) ? instance.activeCamera : Camera.main); if (!((Object)(object)val == (Object)null) && !((Object)(object)_ps == (Object)null)) { Vector3 position = ((Component)val).transform.position; ((Component)this).transform.position = new Vector3(position.x, position.y, position.z); PlayerControllerB val2 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); bool flag = (Object)(object)val2 != (Object)null && (val2.isInHangarShipRoom || val2.isInsideFactory); EmissionModule emission = _ps.emission; if (((EmissionModule)(ref emission)).enabled == flag) { ((EmissionModule)(ref emission)).enabled = !flag; } } } } internal sealed class TreeCut { private readonly List<Collider> _cols = new List<Collider>(); private readonly List<Light> _off = new List<Light>(); private readonly List<GameObject> _hidden = new List<GameObject>(); private readonly List<(MeshFilter mf, Mesh was, Mesh copy)> _meshes = new List<(MeshFilter, Mesh, Mesh)>(); internal static TreeCut Clear(Transform yard, Transform tree, Vector3 centre, float radius) { //IL_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) TreeCut treeCut = new TreeCut(); List<(Transform, Vector3, float, float)> list = new List<(Transform, Vector3, float, float)>(); List<string> list2 = new List<string>(); BoxCollider[] componentsInChildren = ((Component)yard).GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider val in componentsInChildren) { if (!((Collider)val).enabled || ((Component)val).transform.IsChildOf(tree) || !Pad.Removable(Dressing.PathOf(((Component)val).transform, yard))) { continue; } Vector3 val2 = ((Component)val).transform.InverseTransformPoint(centre) - val.center; Vector3 val3 = Vector3.Scale(val.size, ((Component)val).transform.lossyScale); if (!(Pad.Distance(val2.x, val2.z, val3.x / 2f, val3.z / 2f) >= radius)) { Pad.CutHalf(val3.x, val3.z, out var hx, out var hz); list.Add((((Component)val).transform, val.center, hx, hz)); list2.Add(((Object)val).name); ((Collider)val).enabled = false; treeCut._cols.Add((Collider)(object)val); Transform val4 = (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Component)val).transform.parent.parent : null); Transform val5 = (((Object)(object)val4 != (Object)null) ? val4.Find("NavObstacles/" + ((Object)val).name) : null); if ((Object)(object)val5 != (Object)null && ((Component)val5).gameObject.activeSelf) { ((Component)val5).gameObject.SetActive(false); treeCut._hidden.Add(((Component)val5).gameObject); } } } int num = 0; Light[] componentsInChildren2 = ((Component)yard).GetComponentsInChildren<Light>(false); foreach (Light val6 in componentsInChildren2) { if (((Behaviour)val6).enabled && !((Component)val6).transform.IsChildOf(tree)) { Vector3 position = ((Component)val6).transform.position; Vector2 val7 = new Vector2(position.x - centre.x, position.z - centre.z); if (!(((Vector2)(ref val7)).magnitude >= radius) && !(position.y > centre.y + 12f)) { ((Behaviour)val6).enabled = false; treeCut._off.Add(val6); num++; } } } int num2 = 0; if (list.Count > 0) { MeshFilter[] componentsInChildren3 = ((Component)yard).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val8 in componentsInChildren3) { Mesh sharedMesh = val8.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || ((Component)val8).transform.IsChildOf(tree)) { continue; } if (!sharedMesh.isReadable) { Plugin.Log.LogWarning((object)(((Object)sharedMesh).name + " isn't readable; its props by the giant tree stay.")); continue; } Vector3[] vertices = sharedMesh.vertices; bool[] array = new bool[vertices.Length]; bool flag = false; for (int j = 0; j < vertices.Length; j++) { Vector3 val9 = ((Component)val8).transform.TransformPoint(vertices[j]); foreach (var item in list) { Vector3 val10 = item.Item1.InverseTransformPoint(val9) - item.Item2; if (Mathf.Abs(val10.x) <= item.Item3 && Mathf.Abs(val10.z) <= item.Item4) { array[j] = true; flag = true; break; } } } if (!flag) { continue; } Mesh val11 = Object.Instantiate<Mesh>(sharedMesh); ((Object)val11).name = ((Object)sharedMesh).name + "_treeclear"; for (int k = 0; k < val11.subMeshCount; k++) { int[] triangles = val11.GetTriangles(k); List<int> list3 = new List<int>(triangles.Length); for (int l = 0; l + 2 < triangles.Length; l += 3) { if (array[triangles[l]] && array[triangles[l + 1]] && array[triangles[l + 2]]) { num2++; continue; } list3.Add(triangles[l]); list3.Add(triangles[l + 1]); list3.Add(triangles[l + 2]); } val11.SetTriangles(list3, k, false); } val8.sharedMesh = val11; treeCut._meshes.Add((val8, sharedMesh, val11)); } } Plugin.Log.LogInfo((object)string.Format("Giant tree up at {0}: cleared {1} props within {2:F0} m ({3}), {4} lights, {5} triangles.", centre, list2.Count, radius, string.Join(", ", list2), num, num2)); return treeCut; } internal void Restore() { foreach (Collider col in _cols) { if ((Object)(object)col != (Object)null) { col.enabled = true; } } foreach (Light item in _off) { if ((Object)(object)item != (Object)null) { ((Behaviour)item).enabled = true; } } foreach (GameObject item2 in _hidden) { if ((Object)(object)item2 != (Object)null) { item2.SetActive(true); } } foreach (var (val, sharedMesh, val2) in _meshes) { if ((Object)(object)val != (Object)null && (Object)(object)val.sharedMesh == (Object)(object)val2)