using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BasedDecorPlacement.API;
using BasedDecorPlacement.Compatibility;
using BasedDecorPlacement.Patches;
using BasedDecorPlacement.PatchesAPI;
using BasedDecorPlacement.Tweaks;
using BasedDecorPlacement.Utils;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.BindingPathEnums;
using Microsoft.CodeAnalysis;
using ReservedItemSlotCore;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BasedDecorPlacement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.7.0")]
[assembly: AssemblyInformationalVersion("0.0.7")]
[assembly: AssemblyProduct("BasedDecorPlacement")]
[assembly: AssemblyTitle("BasedDecorPlacement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
internal static class AddNetworkPrefab
{
[HarmonyPatch(typeof(NetworkManager), "SetSingleton")]
[HarmonyPostfix]
private static void RegisterPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("MrHat.BasedDecorPlacement.Network");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Object.DontDestroyOnLoad((Object)(object)val);
NetworkObject obj = val.AddComponent<NetworkObject>();
FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(obj, GetHash("MrHat.BasedDecorPlacement"));
NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
static uint GetHash(string value)
{
return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
}
}
}
namespace BasedDecorPlacement
{
internal enum RotationSnap
{
Zero = 0,
Five = 5,
Fifteen = 15,
Thirty = 30,
FortyFive = 45
}
internal enum RotationControlMode
{
Mouse,
Keys
}
internal static class ConfigManager
{
private const string UnlockableItemReparentingSection = "Unlockable Item Reparenting";
private const string BuildModeSection = "Build Mode";
internal static ConfigEntry<bool> ReparentItemsToUnlockableSurfaces;
internal static ConfigEntry<float> ReparentItemsToUnlockableSurfaceOffset;
internal static ConfigEntry<string> ReparentItemsToUnlockableSurfaceBlacklist;
internal static ConfigEntry<bool> FixBrokenPrefabs;
internal static ConfigEntry<bool> BuildModeOverhaul;
internal static ConfigEntry<bool> ExtendBuildBounds;
internal static ConfigEntry<RotationControlMode> RotationMode;
internal static ConfigEntry<RotationSnap> DefaultRotationSnap;
internal static ConfigEntry<float> SelectionRange;
internal static ConfigEntry<float> PlacementRange;
internal static ConfigEntry<bool> ShowCurrentRotation;
internal static ConfigEntry<string> PlaceableGhostColour;
internal static ConfigEntry<string> BlockedGhostColour;
internal static void Bind(ConfigFile config)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Expected O, but got Unknown
ReparentItemsToUnlockableSurfaces = config.Bind<bool>("Unlockable Item Reparenting", "Reparent Items To Unlockables", true, "If true, reparent items back onto unlockable surfaces after load");
ReparentItemsToUnlockableSurfaceOffset = config.Bind<float>("Unlockable Item Reparenting", "Unlockable Surface Offset", 0.05f, new ConfigDescription("Max distance allowed when matching an item back to a unlockable surface", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.5f), Array.Empty<object>()));
ReparentItemsToUnlockableSurfaceBlacklist = config.Bind<string>("Unlockable Item Reparenting", "Unlockable Blacklist", "HouseTeleporter, StockRoom0, BedRoom0, BedRoom1, Basement, House, Poolroom, Garden", "Unlockable names that item reparenting should ignore entirely");
FixBrokenPrefabs = config.Bind<bool>("Unlockable Item Reparenting", "Fix broken unlockable prefabs", true, "If true, diagnoses issues in unlockable prefabs and tries to repair them. This can resolve items falling through some modded unlockables. Only valid for unlockables that store items");
BuildModeOverhaul = config.Bind<bool>("Build Mode", "Build mode overhaul", true, "If true, enables build mode overhaul");
ExtendBuildBounds = config.Bind<bool>("Build Mode", "Full ship coverage", false, "NOT CLIENTSIDE | If true, extends build mode bounds to the rails outside of the ship");
RotationMode = config.Bind<RotationControlMode>("Build Mode", "Rotation mode", RotationControlMode.Mouse, "Mouse = hold left click and move mouse, Keys = Q/E rotate by snap");
DefaultRotationSnap = config.Bind<RotationSnap>("Build Mode", "Default rotation snap", RotationSnap.Zero, "Default rotation snap");
SelectionRange = config.Bind<float>("Build Mode", "Selection range", 5f, new ConfigDescription("How far away ship decor can be selected", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 10f), Array.Empty<object>()));
PlacementRange = config.Bind<float>("Build Mode", "Placement range", 5f, new ConfigDescription("How far away ship decor can be positioned", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 10f), Array.Empty<object>()));
ShowCurrentRotation = config.Bind<bool>("Build Mode", "Show current rotation", false, "Show the current unlockable rotation in the build mode tooltip");
PlaceableGhostColour = config.Bind<string>("Build Mode", "Placeable ghost colour", "#00FF00", "Hex colour for the valid placement ghost");
BlockedGhostColour = config.Bind<string>("Build Mode", "Blocked ghost colour", "#FF0000", "Hex colour for the blocked placement ghost");
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("MrHat.BasedDecorPlacement", "BasedDecorPlacement", "0.0.7")]
internal class Plugin : BaseUnityPlugin
{
private const string GeneralImprovementsGUID = "ShaosilGaming.GeneralImprovements";
private const string BetterDecorPlacementGUID = "viviko.BetterDecorPlacement";
private const string SnapRotateFurnitureGUID = "SleeplessKyru.SnapRotateFurniture";
private const string LethalCompanyInputUtilsGUID = "com.rune580.LethalCompanyInputUtils";
private const string ReservedItemSlotCoreGUID = "FlipMods.ReservedItemSlotCore";
internal const string modGUID = "MrHat.BasedDecorPlacement";
internal const string modName = "BasedDecorPlacement";
internal const string modVersion = "0.0.7";
internal static Harmony _harmony;
internal static ManualLogSource mls;
internal static Plugin Instance;
private static bool HasGeneralImprovements => Chainloader.PluginInfos.ContainsKey("ShaosilGaming.GeneralImprovements");
private static bool HasBetterDecorPlacement => Chainloader.PluginInfos.ContainsKey("viviko.BetterDecorPlacement");
private static bool HasSnapRotateFurniture => Chainloader.PluginInfos.ContainsKey("SleeplessKyru.SnapRotateFurniture");
private static bool HasReservedItemSlotCore => Chainloader.PluginInfos.ContainsKey("FlipMods.ReservedItemSlotCore");
private void Awake()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
Instance = this;
mls = Logger.CreateLogSource("MrHat.BasedDecorPlacement");
_harmony = new Harmony("MrHat.BasedDecorPlacement");
ConfigManager.Bind(((BaseUnityPlugin)this).Config);
_harmony.PatchAll(typeof(ShipBuildModeManagerAPIPatches));
if (ConfigManager.ReparentItemsToUnlockableSurfaces.Value)
{
_harmony.PatchAll(typeof(StartOfRoundUnlockableReparentPatches));
}
if (ConfigManager.FixBrokenPrefabs.Value)
{
_harmony.PatchAll(typeof(GameNetworkManagerPatches));
}
if (ConfigManager.BuildModeOverhaul.Value)
{
BuildModeInputActions.Initialise();
RunCompatibilityUnpatches();
if (HasReservedItemSlotCore)
{
_harmony.PatchAll(typeof(ReservedItemSlotCorePatches));
mls.LogInfo((object)"ReservedItemSlotCore compatibility patches ran");
}
_harmony.PatchAll(typeof(PlayerControllerBPatches));
_harmony.PatchAll(typeof(ShipBuildModeManagerPatches));
_harmony.PatchAll(typeof(StartMatchLeverPatches));
_harmony.PatchAll(typeof(StartOfRoundPatches));
_harmony.PatchAll(typeof(RoundManagerPatches));
if (ConfigManager.ExtendBuildBounds.Value)
{
_harmony.PatchAll(typeof(AddNetworkPrefab));
mls.LogWarning((object)$"Networking enabled because extend build bounds returned {ConfigManager.ExtendBuildBounds.Value}");
}
if (ConfigManager.RotationMode.Value == RotationControlMode.Mouse)
{
_harmony.PatchAll(typeof(ShipBuildModeManagerMouseRotationPatches));
}
if (ConfigManager.RotationMode.Value == RotationControlMode.Keys)
{
_harmony.PatchAll(typeof(ShipBuildModeManagerKeyRotationPatches));
}
mls.LogInfo((object)"BasedDecorPlacement loaded!");
}
}
private static void RunCompatibilityUnpatches()
{
if (HasGeneralImprovements)
{
mls.LogDebug((object)"GeneralImprovements detected, unpatching methods for compatibility purposes...");
UnpatchMethod(typeof(ShipBuildModeManager), "Awake", (HarmonyPatchType)2, "ShaosilGaming.GeneralImprovements", "ShipBuildModeManager.Awake postfix");
UnpatchMethod(typeof(ShipBuildModeManager), "CreateGhostObjectAndHighlight", (HarmonyPatchType)2, "ShaosilGaming.GeneralImprovements", "ShipBuildModeManager.CreateGhostObjectAndHighlight postfix");
UnpatchMethod(typeof(ShipBuildModeManager), "Update", (HarmonyPatchType)2, "ShaosilGaming.GeneralImprovements", "ShipBuildModeManager.Update postfix");
UnpatchMethod(typeof(ShipBuildModeManager), "PlaceShipObject", (HarmonyPatchType)2, "ShaosilGaming.GeneralImprovements", "ShipBuildModeManager.PlaceShipObject postfix");
UnpatchMethod(typeof(AutoParentToShip), "Awake", (HarmonyPatchType)1, "ShaosilGaming.GeneralImprovements", "AutoParentToShip.Awake prefix");
mls.LogInfo((object)"GeneralImprovements compatibility patches ran");
}
if (HasBetterDecorPlacement)
{
mls.LogDebug((object)"BetterDecorPlacement detected, unpatching compatibility conflicts...");
Harmony.UnpatchID("viviko.BetterDecorPlacement");
mls.LogInfo((object)"Unpatched BetterDecorPlacement for compatibility purposes");
}
if (HasSnapRotateFurniture)
{
mls.LogDebug((object)"SnapRotateFurniture detected, unpatching compatibility conflicts...");
Harmony.UnpatchID("SleeplessKyru.SnapRotateFurniture");
mls.LogInfo((object)"Unpatched SnapRotateFurniture for compatibility purposes");
}
}
private static void UnpatchMethod(Type type, string methodName, HarmonyPatchType patchType, string owner, string label)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
_harmony.Unpatch((MethodBase)AccessTools.Method(type, methodName, (Type[])null, (Type[])null), patchType, owner);
mls.LogDebug((object)("Unpatched " + owner + " " + label));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BasedDecorPlacement";
public const string PLUGIN_NAME = "BasedDecorPlacement";
public const string PLUGIN_VERSION = "0.0.7";
}
}
namespace BasedDecorPlacement.Utils
{
internal class BuildModeInputActions : LcInputActions
{
private const string KeyboardAndMouseGroup = "KeyboardAndMouse";
internal static BuildModeInputActions Instance { get; private set; }
internal InputAction ConfirmPlacementAction => ((LcInputActions)this).Asset["confirmPlacement"];
internal InputAction CancelBuildModeAction => ((LcInputActions)this).Asset["cancelBuildMode"];
internal InputAction DecreaseAction => ((LcInputActions)this).Asset["decreaseBuildModeValue"];
internal InputAction IncreaseAction => ((LcInputActions)this).Asset["increaseBuildModeValue"];
internal static InputAction ReplaceFurniture => InputSystem.actions.FindAction("BuildMode", false);
internal static InputAction StoreFurniture => InputSystem.actions.FindAction("Delete", false);
internal static InputAction ConfirmPlacement => Instance.ConfirmPlacementAction;
internal static InputAction CancelBuildMode => Instance.CancelBuildModeAction;
internal static InputAction Decrease => Instance.DecreaseAction;
internal static InputAction Increase => Instance.IncreaseAction;
internal static void Initialise()
{
if (Instance == null)
{
Instance = new BuildModeInputActions();
}
}
internal static bool ConfirmConflictsWith(InputAction action)
{
return SharesKeyboardAndMouseBinding(ConfirmPlacement, action);
}
internal static bool ConfirmIsPressed()
{
return ConfirmPlacement.IsPressed();
}
internal static bool ConfirmWasPressedThisFrame()
{
return ConfirmPlacement.WasPressedThisFrame();
}
internal static bool ConfirmWasReleasedThisFrame()
{
return ConfirmPlacement.WasReleasedThisFrame();
}
internal static bool CancelWasPressedThisFrame()
{
return CancelBuildMode.WasPressedThisFrame();
}
internal static bool DecreaseWasPressedThisFrame()
{
return Decrease.WasPressedThisFrame();
}
internal static bool IncreaseWasPressedThisFrame()
{
return Increase.WasPressedThisFrame();
}
internal static bool DecreaseIsPressed()
{
return Decrease.IsPressed();
}
internal static bool IncreaseIsPressed()
{
return Increase.IsPressed();
}
internal static string GetReplaceFurnitureBindingText()
{
return GetVanillaBindingText(ReplaceFurniture);
}
internal static string GetStoreFurnitureBindingText()
{
return GetVanillaBindingText(StoreFurniture);
}
internal static string GetConfirmBindingText()
{
return GetBindingText(ConfirmPlacement);
}
internal static string GetCancelBindingText()
{
return GetBindingText(CancelBuildMode);
}
internal static string GetDecreaseBindingText()
{
return GetBindingText(Decrease);
}
internal static string GetIncreaseBindingText()
{
return GetBindingText(Increase);
}
public override void CreateInputActions(in InputActionMapBuilder builder)
{
builder.NewActionBinding().WithActionId("confirmPlacement").WithActionType((InputActionType)1)
.WithMouseControl((MouseControl)11)
.WithBindingName("Confirm Placement")
.Finish();
builder.NewActionBinding().WithActionId("cancelBuildMode").WithActionType((InputActionType)1)
.WithKeyboardControl((KeyboardControl)2)
.WithBindingName("Cancel Placement")
.Finish();
builder.NewActionBinding().WithActionId("decreaseBuildModeValue").WithActionType((InputActionType)1)
.WithKeyboardControl((KeyboardControl)37)
.WithBindingName("Decrease Snap / Rotate Left")
.Finish();
builder.NewActionBinding().WithActionId("increaseBuildModeValue").WithActionType((InputActionType)1)
.WithKeyboardControl((KeyboardControl)25)
.WithBindingName("Increase Snap / Rotate Right")
.Finish();
}
private static string FormatBindingText(string bindingText)
{
if (1 == 0)
{
}
string result = bindingText switch
{
"Left Button" => "L.Click",
"Right Button" => "R.Click",
"Middle Button" => "M.Click",
"Left Click" => "L.Click",
"Right Click" => "R.Click",
"Middle Click" => "M.Click",
"Left Arrow" => "L.Arrow",
"Right Arrow" => "R.Arrow",
"Up Arrow" => "U.Arrow",
"Down Arrow" => "D.Arrow",
"Left Shift" => "L.Shift",
"Right Shift" => "R.Shift",
"Left Ctrl" => "L.Ctrl",
"Right Ctrl" => "R.Ctrl",
"Left Control" => "L.Ctrl",
"Right Control" => "R.Ctrl",
"Left Alt" => "L.Alt",
"Right Alt" => "R.Alt",
"Escape" => "Esc",
_ => bindingText,
};
if (1 == 0)
{
}
return result;
}
private static string GetBindingText(InputAction action)
{
//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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (action == null)
{
return "Unbound";
}
Enumerator<InputBinding> enumerator = action.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (!((InputBinding)(ref current)).isComposite && !((InputBinding)(ref current)).isPartOfComposite && string.Equals(((InputBinding)(ref current)).groups, "KeyboardAndMouse", StringComparison.Ordinal) && !string.IsNullOrWhiteSpace(((InputBinding)(ref current)).effectivePath))
{
string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref current)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
if (!string.IsNullOrWhiteSpace(text))
{
return FormatBindingText(text);
}
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
return "Unbound";
}
private static string GetVanillaBindingText(InputAction action)
{
//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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (action == null)
{
return "Unbound";
}
Enumerator<InputBinding> enumerator = action.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (!((InputBinding)(ref current)).isComposite && !((InputBinding)(ref current)).isPartOfComposite && !string.IsNullOrWhiteSpace(((InputBinding)(ref current)).effectivePath) && IsKeyboardMousePath(((InputBinding)(ref current)).effectivePath))
{
string text = InputControlPath.ToHumanReadableString(((InputBinding)(ref current)).effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
if (!string.IsNullOrWhiteSpace(text))
{
return FormatBindingText(text);
}
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
return "Unbound";
}
private static bool IsKeyboardMousePath(string path)
{
return path.StartsWith("<Keyboard>", StringComparison.Ordinal) || path.StartsWith("<Mouse>", StringComparison.Ordinal);
}
private static bool SharesKeyboardAndMouseBinding(InputAction first, InputAction second)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
Enumerator<InputBinding> enumerator = first.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (((InputBinding)(ref current)).isComposite || ((InputBinding)(ref current)).isPartOfComposite || !string.Equals(((InputBinding)(ref current)).groups, "KeyboardAndMouse", StringComparison.Ordinal) || string.IsNullOrWhiteSpace(((InputBinding)(ref current)).effectivePath))
{
continue;
}
Enumerator<InputBinding> enumerator2 = second.bindings.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
InputBinding current2 = enumerator2.Current;
if (((InputBinding)(ref current2)).isComposite || ((InputBinding)(ref current2)).isPartOfComposite || !string.Equals(((InputBinding)(ref current2)).groups, "KeyboardAndMouse", StringComparison.Ordinal) || string.IsNullOrWhiteSpace(((InputBinding)(ref current2)).effectivePath) || !(((InputBinding)(ref current)).effectivePath == ((InputBinding)(ref current2)).effectivePath))
{
continue;
}
return true;
}
}
finally
{
((IDisposable)enumerator2).Dispose();
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
return false;
}
}
internal static class Helpers
{
private class ShipOutOfBounds : MonoBehaviour
{
private float lastHandledTime;
private void OnTriggerStay(Collider other)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (!(Time.realtimeSinceStartup - lastHandledTime < 0.25f) && ((Component)other).CompareTag("Player"))
{
PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)component) && !component.isPlayerDead && component.isInHangarShipRoom)
{
component.ResetFallGravity();
component.isInElevator = true;
component.isInHangarShipRoom = true;
component.TeleportPlayer(StartOfRound.Instance.GetPlayerSpawnPosition((int)component.playerClientId, false), false, 0f, false, true);
lastHandledTime = Time.realtimeSinceStartup;
Plugin.mls.LogDebug((object)"Out of bounds trigger hit, player returned to ship");
}
}
}
}
private static readonly HashSet<GameObject> cachedGameObjects = new HashSet<GameObject>();
internal static GameObject CacheGameObject(string objectName)
{
GameObject val = FindGameObject(objectName);
if ((Object)(object)val == (Object)null)
{
return null;
}
cachedGameObjects.Add(val);
return val;
}
internal static void ClearGameObjectCache()
{
cachedGameObjects.Clear();
}
internal static void ShipOutOfBoundsTrigger()
{
//IL_0021: 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_004e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Environment/HangarShip/OutOfBounds");
val.transform.localScale = new Vector3(800f, 25f, 800f);
Vector3 position = val.transform.position;
position.y -= 20f;
val.transform.position = position;
BoxCollider component = val.GetComponent<BoxCollider>();
((Collider)component).isTrigger = true;
if ((Object)(object)val.GetComponent<ShipOutOfBounds>() == (Object)null)
{
val.AddComponent<ShipOutOfBounds>();
}
Plugin.mls.LogDebug((object)"Updated Environment/HangarShip/OutOfBounds trigger to scale 800, 25, 800, moved it down 20 units, and added BDP trigger stay handling");
}
internal static bool RaycastPlacementSurface(Ray ray, out RaycastHit hit, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
//IL_0002: 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_000f: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
hit = default(RaycastHit);
bool result = false;
float num = maxDistance;
bool flag = (int)queryTriggerInteraction == 1 || ((int)queryTriggerInteraction == 0 && !Physics.queriesHitTriggers);
RaycastHit[] array = Physics.RaycastAll(ray, maxDistance, layerMask, queryTriggerInteraction);
for (int i = 0; i < array.Length; i++)
{
RaycastHit val = array[i];
if (!(((RaycastHit)(ref val)).distance >= num))
{
hit = val;
num = ((RaycastHit)(ref val)).distance;
result = true;
}
}
cachedGameObjects.RemoveWhere((GameObject gameObject) => (Object)(object)gameObject == (Object)null);
RaycastHit val3 = default(RaycastHit);
foreach (GameObject cachedGameObject in cachedGameObjects)
{
Collider[] componentsInChildren = cachedGameObject.GetComponentsInChildren<Collider>(true);
foreach (Collider val2 in componentsInChildren)
{
if (val2.enabled && (!flag || !val2.isTrigger) && val2.Raycast(ray, ref val3, num))
{
hit = val3;
num = ((RaycastHit)(ref val3)).distance;
result = true;
}
}
}
return result;
}
internal static bool RaycastPlacementSurface(Vector3 origin, Vector3 direction, out RaycastHit hit, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return RaycastPlacementSurface(new Ray(origin, direction), out hit, maxDistance, layerMask, queryTriggerInteraction);
}
private static GameObject FindGameObject(string objectName)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find(objectName);
if ((Object)(object)val != (Object)null)
{
return val;
}
int sceneCount = SceneManager.sceneCount;
for (int i = 0; i < sceneCount; i++)
{
Scene sceneAt = SceneManager.GetSceneAt(i);
if (!((Scene)(ref sceneAt)).isLoaded)
{
continue;
}
GameObject[] rootGameObjects = ((Scene)(ref sceneAt)).GetRootGameObjects();
for (int j = 0; j < rootGameObjects.Length; j++)
{
GameObject val2 = FindInChildren(rootGameObjects[j].transform, objectName);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
}
return null;
}
private static GameObject FindInChildren(Transform current, string objectName)
{
if (((Object)current).name == objectName)
{
return ((Component)current).gameObject;
}
int childCount = current.childCount;
for (int i = 0; i < childCount; i++)
{
GameObject val = FindInChildren(current.GetChild(i), objectName);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
}
}
namespace BasedDecorPlacement.Tweaks
{
internal static class ShipFurnitureSurfaceReparent
{
private readonly struct SurfaceInfo
{
public Transform Parent { get; }
public Collider Bounds { get; }
public SurfaceInfo(Transform parent, Collider bounds)
{
Parent = parent;
Bounds = bounds;
}
}
private static readonly List<SurfaceInfo> registeredSurfaces = new List<SurfaceInfo>();
private static readonly List<Collider> ignoredSurfaceBounds = new List<Collider>();
private static readonly HashSet<string> blacklistedUnlockableNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
internal static void Clear()
{
registeredSurfaces.Clear();
ignoredSurfaceBounds.Clear();
}
internal static void Rebuild()
{
registeredSurfaces.Clear();
ignoredSurfaceBounds.Clear();
RefreshUnlockableBlacklist();
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance?.unlockablesList == (Object)null)
{
return;
}
AutoParentToShip[] array = Object.FindObjectsOfType<AutoParentToShip>();
foreach (AutoParentToShip val in array)
{
val.MoveToOffset();
}
Physics.SyncTransforms();
PlaceableObjectsSurface[] array2 = Object.FindObjectsOfType<PlaceableObjectsSurface>();
foreach (PlaceableObjectsSurface val2 in array2)
{
PlaceableObjectsSurfaceRegistrationAPI registration;
bool flag = PlaceableObjectsSurfaceRegistry.TryGet(val2, out registration);
NetworkObject parentTo = val2.parentTo;
Transform val3 = ((parentTo != null) ? ((Component)parentTo).transform : null);
Collider placeableBounds = val2.placeableBounds;
if (flag && !registration.AllowAutomaticReparent)
{
if ((Object)(object)placeableBounds != (Object)null)
{
ignoredSurfaceBounds.Add(placeableBounds);
}
}
else
{
if ((Object)(object)val3 == (Object)null || (Object)(object)placeableBounds == (Object)null)
{
continue;
}
NetworkObject parentTo2 = val2.parentTo;
PlaceableShipObject val4 = ((parentTo2 != null) ? ((Component)parentTo2).GetComponentInChildren<PlaceableShipObject>() : null) ?? ((Component)val2).GetComponentInParent<PlaceableShipObject>();
if ((Object)(object)val4 == (Object)null)
{
continue;
}
int unlockableID = val4.unlockableID;
if (unlockableID < 0 || unlockableID >= instance.unlockablesList.unlockables.Count)
{
continue;
}
UnlockableItem val5 = instance.unlockablesList.unlockables[unlockableID];
if (val5 != null && !val5.inStorage)
{
if (blacklistedUnlockableNames.Contains(val5.unlockableName))
{
ignoredSurfaceBounds.Add(placeableBounds);
}
else
{
registeredSurfaces.Add(new SurfaceInfo(val3, placeableBounds));
}
}
}
}
}
internal static void RelinkAll(bool useGroundedOffset)
{
if (registeredSurfaces.Count == 0)
{
return;
}
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
foreach (GrabbableObject val in array)
{
if (val.isInShipRoom)
{
RelinkItem(val, useGroundedOffset);
}
}
Physics.SyncTransforms();
}
private static void RelinkItem(GrabbableObject item, bool useGroundedOffset)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_0079: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_00db: 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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: 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_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
if (PlaceableObjectsSurfaceRegistry.IsIgnored(item) || item is ClipboardItem || (item is PhysicsProp && item.itemProperties.itemName == "Sticky note"))
{
return;
}
float num = ((useGroundedOffset && item.hasHitGround) ? item.itemProperties.verticalOffset : 0f);
Vector3 val = ((Component)item).transform.position + Vector3.down * num;
float num2 = ConfigManager.ReparentItemsToUnlockableSurfaceOffset.Value * ConfigManager.ReparentItemsToUnlockableSurfaceOffset.Value;
Bounds bounds;
foreach (Collider ignoredSurfaceBound in ignoredSurfaceBounds)
{
if ((Object)(object)ignoredSurfaceBound == (Object)null)
{
continue;
}
bounds = ignoredSurfaceBound.bounds;
if (!(((Bounds)(ref bounds)).SqrDistance(val) > num2))
{
Vector3 val2 = ignoredSurfaceBound.ClosestPoint(val);
float num3 = Vector3.Dot(val - val2, ((Component)ignoredSurfaceBound).transform.up);
if (num3 >= -0.001f)
{
return;
}
}
}
float num4 = float.MaxValue;
int num5 = -1;
Vector3 val3 = default(Vector3);
for (int i = 0; i < registeredSurfaces.Count; i++)
{
Collider bounds2 = registeredSurfaces[i].Bounds;
if ((Object)(object)bounds2 == (Object)null)
{
continue;
}
bounds = bounds2.bounds;
if (!(((Bounds)(ref bounds)).SqrDistance(val) > num2))
{
Vector3 val4 = bounds2.ClosestPoint(val);
float num6 = Vector3.Dot(val - val4, ((Component)bounds2).transform.up);
if (!(num6 < -0.001f) && !(num6 >= num4))
{
num4 = num6;
num5 = i;
val3 = val4;
}
}
}
if (num5 >= 0)
{
SurfaceInfo surfaceInfo = registeredSurfaces[num5];
Vector3 position = val3 + ((Component)surfaceInfo.Bounds).transform.up * item.itemProperties.verticalOffset;
((Component)item).transform.SetParent(surfaceInfo.Parent, true);
((Component)item).transform.position = position;
item.parentObject = null;
item.startFallingPosition = (item.targetFloorPosition = ((Component)item).transform.localPosition) + Vector3.up * 0.0001f;
item.fallTime = 1f;
item.hasHitGround = true;
item.reachedFloorTarget = true;
}
}
private static void RefreshUnlockableBlacklist()
{
blacklistedUnlockableNames.Clear();
string value = ConfigManager.ReparentItemsToUnlockableSurfaceBlacklist.Value;
if (string.IsNullOrWhiteSpace(value))
{
return;
}
string[] array = value.Split(',');
foreach (string text in array)
{
string text2 = text.Trim();
if (!string.IsNullOrWhiteSpace(text2))
{
blacklistedUnlockableNames.Add(text2);
}
}
}
}
}
namespace BasedDecorPlacement.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal static class GameNetworkManagerPatches
{
private const string GeneratedRoomBoundsName = "GeneratedRoomBounds";
private static bool hasScanned;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix()
{
if (hasScanned)
{
return;
}
hasScanned = true;
int num = LayerMask.NameToLayer("InteractableObject");
int num2 = LayerMask.NameToLayer("Triggers");
int num3 = LayerMask.NameToLayer("PlaceableShipObjects");
int num4 = LayerMask.NameToLayer("Room");
int num5 = LayerMask.NameToLayer("Default");
HashSet<GameObject> hashSet = new HashSet<GameObject>();
int num6 = 0;
int num7 = 0;
int num8 = 0;
int num9 = 0;
int roomCloneFixes = 0;
UnlockablesList[] array = Resources.FindObjectsOfTypeAll<UnlockablesList>();
foreach (UnlockablesList val in array)
{
if (val?.unlockables == null)
{
continue;
}
foreach (UnlockableItem unlockable in val.unlockables)
{
if ((Object)(object)unlockable?.prefabObject == (Object)null || !hashSet.Add(unlockable.prefabObject))
{
continue;
}
num6++;
PlaceableObjectsSurface[] componentsInChildren = unlockable.prefabObject.GetComponentsInChildren<PlaceableObjectsSurface>(true);
if (componentsInChildren.Length == 0)
{
continue;
}
HashSet<Collider> hashSet2 = new HashSet<Collider>();
List<BoxCollider> list = new List<BoxCollider>();
HashSet<Collider> hashSet3 = new HashSet<Collider>();
HashSet<Collider> hashSet4 = new HashSet<Collider>();
List<string> list2 = new List<string>();
List<string> list3 = new List<string>();
PlaceableObjectsSurface[] array2 = componentsInChildren;
foreach (PlaceableObjectsSurface val2 in array2)
{
if ((Object)(object)val2 == (Object)null)
{
continue;
}
GameObject gameObject = ((Component)val2).gameObject;
if (gameObject.tag != "InteractTrigger")
{
list3.Add("PlaceableObjectsSurface object has wrong tag or has custom properties");
}
if (gameObject.layer != num)
{
list3.Add("PlaceableObjectsSurface object has wrong layer or has custom properties");
}
Collider[] components = gameObject.GetComponents<Collider>();
foreach (Collider val3 in components)
{
if (!((Object)(object)val3 == (Object)null))
{
hashSet2.Add(val3);
hashSet4.Add(val3);
}
}
if ((Object)(object)val2.placeableBounds == (Object)null)
{
list3.Add("PlaceableObjectsSurface is missing its PlaceableBounds reference");
continue;
}
hashSet3.Add(val2.placeableBounds);
GameObject gameObject2 = ((Component)val2.placeableBounds).gameObject;
if (gameObject2.layer != num2)
{
list3.Add("PlaceableBounds object has wrong layer or has custom properties");
}
Collider[] components2 = gameObject2.GetComponents<Collider>();
foreach (Collider val4 in components2)
{
if (!((Object)(object)val4 == (Object)null))
{
hashSet2.Add(val4);
hashSet3.Add(val4);
}
}
}
foreach (Collider item in hashSet2)
{
if ((Object)(object)item == (Object)null || ((Component)item).gameObject.layer == num3)
{
continue;
}
BoxCollider val5 = (BoxCollider)(object)((item is BoxCollider) ? item : null);
if (val5 != null && !hashSet3.Contains((Collider)(object)val5))
{
list.Add(val5);
}
if (!item.isTrigger)
{
item.isTrigger = true;
num9++;
if (hashSet3.Contains(item))
{
list2.Add("PlaceableBounds collider was not trigger and was changed");
}
else if (hashSet4.Contains(item))
{
list2.Add("PlaceableObjectsSurface collider was not trigger and was changed");
}
else
{
list3.Add("Collider was not trigger and was changed");
}
}
}
Collider[] componentsInChildren2 = unlockable.prefabObject.GetComponentsInChildren<Collider>(true);
bool flag = true;
bool flag2 = false;
Collider[] array3 = componentsInChildren2;
foreach (Collider val6 in array3)
{
if (!((Object)(object)val6 == (Object)null) && ((Component)val6).gameObject.layer != num3)
{
if (!val6.isTrigger)
{
flag = false;
}
int layer = ((Component)val6).gameObject.layer;
bool flag3 = layer == num4 || layer == num5;
if (!val6.isTrigger && flag3)
{
flag2 = true;
break;
}
}
}
if (flag && !flag2 && list.Count > 0)
{
TryCloneRoomBounds(unlockable.prefabObject, list, ref roomCloneFixes, list2);
}
if (list3.Count == 0 && list2.Count == 0)
{
continue;
}
if (list3.Count > 0)
{
num8++;
Plugin.mls.LogInfo((object)(unlockable.unlockableName + " prefab check"));
foreach (string item2 in list3)
{
Plugin.mls.LogError((object)(" " + item2));
}
}
if (list2.Count <= 0)
{
continue;
}
num7++;
if (list3.Count == 0)
{
Plugin.mls.LogInfo((object)(unlockable.unlockableName + " prefab check"));
}
foreach (string item3 in list2)
{
Plugin.mls.LogWarning((object)(" " + item3));
}
}
}
Plugin.mls.LogInfo((object)"Unlockables prefab scan finished");
Plugin.mls.LogInfo((object)$"Checked: {num6}");
if (num7 > 0)
{
Plugin.mls.LogWarning((object)$"Warnings: {num7}");
}
if (num8 > 0)
{
Plugin.mls.LogError((object)$"Errors: {num8}");
}
Plugin.mls.LogInfo((object)$"Colliders changed to trigger: {num9}");
Plugin.mls.LogInfo((object)$"Box colliders added: {roomCloneFixes}");
}
private static void TryCloneRoomBounds(GameObject prefabObject, List<BoxCollider> boxCollidersToClone, ref int roomCloneFixes, List<string> warnings)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
PlaceableShipObject componentInChildren = prefabObject.GetComponentInChildren<PlaceableShipObject>(true);
if ((Object)(object)componentInChildren?.mainMesh == (Object)null)
{
return;
}
Transform transform = ((Component)componentInChildren.mainMesh).transform;
Transform val = transform.Find("GeneratedRoomBounds");
if ((Object)(object)val == (Object)null)
{
GameObject val2 = new GameObject("GeneratedRoomBounds");
val = val2.transform;
val.SetParent(transform, false);
}
BoxCollider val3 = boxCollidersToClone[0];
val.position = ((Component)val3).transform.position;
val.rotation = ((Component)val3).transform.rotation;
val.localScale = ((Component)val3).transform.lossyScale;
Transform obj = val;
obj.localPosition += new Vector3(0f, 0f, -0.015f);
((Component)val).gameObject.layer = LayerMask.NameToLayer("Room");
BoxCollider[] components = ((Component)val).GetComponents<BoxCollider>();
for (int num = components.Length - 1; num >= 0; num--)
{
Object.DestroyImmediate((Object)(object)components[num]);
}
foreach (BoxCollider item in boxCollidersToClone)
{
if (!((Object)(object)item == (Object)null))
{
BoxCollider val4 = ((Component)val).gameObject.AddComponent<BoxCollider>();
val4.center = item.center;
val4.size = item.size;
((Collider)val4).isTrigger = false;
((Collider)val4).enabled = ((Collider)item).enabled;
((Collider)val4).sharedMaterial = ((Collider)item).sharedMaterial;
((Collider)val4).contactOffset = ((Collider)item).contactOffset;
roomCloneFixes++;
}
}
warnings.Add("Box collider components were cloned because no collision was detected");
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal static class PlayerControllerBPatches
{
[HarmonyPatch("PlayerLookInput")]
[HarmonyPrefix]
private static bool PlayerLookInputPrefix()
{
if (!ShipBuildModeManagerPatches.IsRotateHeld())
{
return true;
}
StartOfRound.Instance.playerLookMagnitudeThisFrame = 0f;
return false;
}
[HarmonyPatch("Interact_performed")]
[HarmonyPatch("ItemSecondaryUse_performed")]
[HarmonyPatch("ItemTertiaryUse_performed")]
[HarmonyPatch("QEItemInteract_performed")]
[HarmonyPatch("ActivateItem_performed")]
[HarmonyPatch("ActivateItem_canceled")]
[HarmonyPatch("Discard_performed")]
[HarmonyPatch("ScrollMouse_performed")]
[HarmonyPatch("UseUtilitySlot_performed")]
[HarmonyPatch("InspectItem_performed")]
[HarmonyPatch("OpenMenu_performed")]
[HarmonyPrefix]
private static bool BuildModeOwnsPlayerInputsPrefix()
{
return (Object)(object)ShipBuildModeManager.Instance == (Object)null || !ShipBuildModeManager.Instance.InBuildMode;
}
}
internal static class RoundManagerPatches
{
[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
[HarmonyPostfix]
private static void SyncScrapValuesClientRpcPostfix()
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = false;
}
}
[HarmonyPatch(typeof(ShipBuildModeManager))]
internal static class ShipBuildModeManagerKeyRotationPatches
{
private const float HoldRepeatDelay = 0.4f;
private const float RepeatInterval = 0.08f;
private const float FreeRotateSpeed = 155f;
private static bool qHeld;
private static bool eHeld;
private static float qHeldTime;
private static float eHeldTime;
private static float qRepeatTime;
private static float eRepeatTime;
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(ShipBuildModeManager __instance)
{
if (!__instance.InBuildMode || ConfigManager.RotationMode.Value != RotationControlMode.Keys)
{
ResetHeldState();
}
else if (BuildModeInputActions.ConfirmIsPressed())
{
ResetHeldState();
if (BuildModeInputActions.DecreaseWasPressedThisFrame() && !BuildModeInputActions.ConfirmConflictsWith(BuildModeInputActions.Decrease))
{
ShipBuildModeManagerPatches.ChangeSnap(-1);
}
else if (BuildModeInputActions.IncreaseWasPressedThisFrame() && !BuildModeInputActions.ConfirmConflictsWith(BuildModeInputActions.Increase))
{
ShipBuildModeManagerPatches.ChangeSnap(1);
}
}
else if (ShipBuildModeManagerPatches.CurrentSnapDegrees <= 0)
{
RotateWithoutSnap();
}
else
{
ProcessSnapRotation(BuildModeInputActions.Decrease, -1, ref qHeld, ref qHeldTime, ref qRepeatTime);
ProcessSnapRotation(BuildModeInputActions.Increase, 1, ref eHeld, ref eHeldTime, ref eRepeatTime);
}
}
private static void ResetHeldState()
{
ResetHeldState(ref qHeld, ref qHeldTime, ref qRepeatTime);
ResetHeldState(ref eHeld, ref eHeldTime, ref eRepeatTime);
}
private static void ResetHeldState(ref bool held, ref float heldTime, ref float repeatTime)
{
held = false;
heldTime = 0f;
repeatTime = 0f;
}
private static void RotateOnce(int direction)
{
ShipBuildModeManagerPatches.currentGhostYaw = ShipBuildModeManagerPatches.NormaliseYaw(ShipBuildModeManagerPatches.currentGhostYaw + (float)(ShipBuildModeManagerPatches.CurrentSnapDegrees * direction));
ShipBuildModeManagerPatches.rawGhostYawAccumulator = ShipBuildModeManagerPatches.currentGhostYaw;
ShipBuildModeManagerPatches.UpdateBuildModeTooltip();
}
private static void RotateWithoutSnap()
{
ResetHeldState();
bool flag = false;
if (BuildModeInputActions.DecreaseIsPressed())
{
ShipBuildModeManagerPatches.currentGhostYaw = ShipBuildModeManagerPatches.NormaliseYaw(ShipBuildModeManagerPatches.currentGhostYaw - Time.deltaTime * 155f);
flag = true;
}
if (BuildModeInputActions.IncreaseIsPressed())
{
ShipBuildModeManagerPatches.currentGhostYaw = ShipBuildModeManagerPatches.NormaliseYaw(ShipBuildModeManagerPatches.currentGhostYaw + Time.deltaTime * 155f);
flag = true;
}
if (flag)
{
ShipBuildModeManagerPatches.rawGhostYawAccumulator = ShipBuildModeManagerPatches.currentGhostYaw;
ShipBuildModeManagerPatches.UpdateBuildModeTooltip();
}
}
private static void ProcessSnapRotation(InputAction action, int direction, ref bool held, ref float heldTime, ref float repeatTime)
{
if (action.WasPressedThisFrame())
{
RotateOnce(direction);
held = true;
heldTime = 0f;
repeatTime = 0f;
return;
}
if (!action.IsPressed())
{
ResetHeldState(ref held, ref heldTime, ref repeatTime);
return;
}
if (!held)
{
held = true;
heldTime = 0f;
repeatTime = 0f;
}
heldTime += Time.deltaTime;
if (!(heldTime < 0.4f))
{
repeatTime += Time.deltaTime;
while (repeatTime >= 0.08f)
{
repeatTime -= 0.08f;
RotateOnce(direction);
}
}
}
}
[HarmonyPatch(typeof(ShipBuildModeManager))]
internal static class ShipBuildModeManagerMouseRotationPatches
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(ShipBuildModeManager __instance)
{
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.InBuildMode || ConfigManager.RotationMode.Value != 0)
{
return;
}
Mouse current = Mouse.current;
if (current == null)
{
return;
}
if (BuildModeInputActions.DecreaseWasPressedThisFrame() && (!BuildModeInputActions.ConfirmWasPressedThisFrame() || !BuildModeInputActions.ConfirmConflictsWith(BuildModeInputActions.Decrease)))
{
ShipBuildModeManagerPatches.ChangeSnap(-1);
}
else if (BuildModeInputActions.IncreaseWasPressedThisFrame() && (!BuildModeInputActions.ConfirmWasPressedThisFrame() || !BuildModeInputActions.ConfirmConflictsWith(BuildModeInputActions.Increase)))
{
ShipBuildModeManagerPatches.ChangeSnap(1);
}
else if (ShipBuildModeManagerPatches.IsRotateHeld())
{
int currentSnapDegrees = ShipBuildModeManagerPatches.CurrentSnapDegrees;
float currentGhostYaw = ShipBuildModeManagerPatches.currentGhostYaw;
ShipBuildModeManagerPatches.rawGhostYawAccumulator += ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue().x * GetRotationMultiplier();
ShipBuildModeManagerPatches.currentGhostYaw = (((float)currentSnapDegrees <= 0f) ? ShipBuildModeManagerPatches.NormaliseYaw(ShipBuildModeManagerPatches.rawGhostYawAccumulator) : ShipBuildModeManagerPatches.NormaliseYaw(Mathf.Round(ShipBuildModeManagerPatches.rawGhostYawAccumulator / (float)currentSnapDegrees) * (float)currentSnapDegrees));
if (!Mathf.Approximately(currentGhostYaw, ShipBuildModeManagerPatches.currentGhostYaw))
{
ShipBuildModeManagerPatches.consumedLeftClickAction = true;
ShipBuildModeManagerPatches.UpdateBuildModeTooltip();
}
}
}
private static float GetRotationMultiplier()
{
int currentSnapDegrees = ShipBuildModeManagerPatches.CurrentSnapDegrees;
if (1 == 0)
{
}
float result = currentSnapDegrees switch
{
0 => 0.2f,
5 => 0.2f,
15 => 0.16f,
30 => 0.13f,
45 => 0.11f,
_ => 0.2f,
};
if (1 == 0)
{
}
return result;
}
}
[HarmonyPatch(typeof(ShipBuildModeManager))]
internal static class ShipBuildModeManagerPatches
{
[CompilerGenerated]
private sealed class <EnterBuildModeTranspiler>d__37 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
private float <value>5__3;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnterBuildModeTranspiler>d__37(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 7u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
case 2:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)configValueGetter);
<>1__state = 3;
return true;
case 3:
<>1__state = -3;
break;
case 4:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)configValueGetter);
<>1__state = 5;
return true;
case 5:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Ldc_R4, (object)1f);
<>1__state = 6;
return true;
case 6:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Sub, (object)null);
<>1__state = 7;
return true;
case 7:
<>1__state = -3;
break;
case 8:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (!(<instruction>5__2.opcode != OpCodes.Ldc_R4))
{
object operand = <instruction>5__2.operand;
int num;
if (operand is float)
{
<value>5__3 = (float)operand;
num = 1;
}
else
{
num = 0;
}
if (num != 0)
{
if (<value>5__3 == 5f)
{
<>2__current = new CodeInstruction(OpCodes.Ldsfld, (object)selectionRangeField);
<>1__state = 2;
return true;
}
if (<value>5__3 == 4f)
{
<>2__current = new CodeInstruction(OpCodes.Ldsfld, (object)selectionRangeField);
<>1__state = 4;
return true;
}
<>2__current = <instruction>5__2;
<>1__state = 8;
return true;
}
}
<>2__current = <instruction>5__2;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<EnterBuildModeTranspiler>d__37 <EnterBuildModeTranspiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<EnterBuildModeTranspiler>d__ = this;
}
else
{
<EnterBuildModeTranspiler>d__ = new <EnterBuildModeTranspiler>d__37(0);
}
<EnterBuildModeTranspiler>d__.instructions = <>3__instructions;
return <EnterBuildModeTranspiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <UpdateTranspiler>d__38 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
private float <value>5__3;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UpdateTranspiler>d__38(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 2u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Callvirt, (object)configValueGetter);
<>1__state = 2;
return true;
case 2:
<>1__state = -3;
break;
case 3:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (<instruction>5__2.opcode == OpCodes.Ldc_R4)
{
object operand = <instruction>5__2.operand;
if (operand is float)
{
<value>5__3 = (float)operand;
if (<value>5__3 == 20f || <value>5__3 == 4f)
{
<>2__current = new CodeInstruction(OpCodes.Ldsfld, (object)placementRangeField);
<>1__state = 1;
return true;
}
}
}
if (CodeInstructionExtensions.Calls(<instruction>5__2, raycastRayMethod))
{
<instruction>5__2.operand = cachedRaycastRayMethod;
}
else if (CodeInstructionExtensions.Calls(<instruction>5__2, raycastVectorMethod))
{
<instruction>5__2.operand = cachedRaycastVectorMethod;
}
<>2__current = <instruction>5__2;
<>1__state = 3;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<UpdateTranspiler>d__38 <UpdateTranspiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<UpdateTranspiler>d__ = this;
}
else
{
<UpdateTranspiler>d__ = new <UpdateTranspiler>d__38(0);
}
<UpdateTranspiler>d__.instructions = <>3__instructions;
return <UpdateTranspiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
private static readonly FieldInfo selectionRangeField = AccessTools.Field(typeof(ConfigManager), "SelectionRange");
private static readonly FieldInfo placementRangeField = AccessTools.Field(typeof(ConfigManager), "PlacementRange");
private static readonly MethodInfo configValueGetter = AccessTools.PropertyGetter(typeof(ConfigEntry<float>), "Value");
private static readonly MethodInfo raycastRayMethod = AccessTools.Method(typeof(Physics), "Raycast", new Type[5]
{
typeof(Ray),
typeof(RaycastHit).MakeByRefType(),
typeof(float),
typeof(int),
typeof(QueryTriggerInteraction)
}, (Type[])null);
private static readonly MethodInfo raycastVectorMethod = AccessTools.Method(typeof(Physics), "Raycast", new Type[6]
{
typeof(Vector3),
typeof(Vector3),
typeof(RaycastHit).MakeByRefType(),
typeof(float),
typeof(int),
typeof(QueryTriggerInteraction)
}, (Type[])null);
private static readonly MethodInfo cachedRaycastRayMethod = AccessTools.Method(typeof(Helpers), "RaycastPlacementSurface", new Type[5]
{
typeof(Ray),
typeof(RaycastHit).MakeByRefType(),
typeof(float),
typeof(int),
typeof(QueryTriggerInteraction)
}, (Type[])null);
private static readonly MethodInfo cachedRaycastVectorMethod = AccessTools.Method(typeof(Helpers), "RaycastPlacementSurface", new Type[6]
{
typeof(Vector3),
typeof(Vector3),
typeof(RaycastHit).MakeByRefType(),
typeof(float),
typeof(int),
typeof(QueryTriggerInteraction)
}, (Type[])null);
private static readonly MethodInfo enterBuildModeMethod = AccessTools.Method(typeof(ShipBuildModeManager), "EnterBuildMode", new Type[1] { typeof(CallbackContext) }, (Type[])null);
internal static readonly int[] snapSteps = new int[5] { 0, 5, 15, 30, 45 };
internal const float MouseRotateHoldDelay = 0.04f;
internal static float currentGhostYaw;
internal static float rawGhostYawAccumulator;
internal static float defaultGhostYaw;
internal static float mouseLeftHeldTime;
internal static bool wasInBuildMode;
internal static bool consumedLeftClickAction;
internal static bool snapInitialised;
internal static int currentSnapIndex;
private static PlaceableShipObject currentPlacingObject;
private static ShipBuildModeManager currentShipBuildModeManager;
internal static int CurrentSnapDegrees => snapSteps[currentSnapIndex];
[MethodImpl(MethodImplOptions.NoInlining)]
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(ShipBuildModeManager), "PlayerMeetsConditionsToBuild", new Type[] { typeof(bool) })]
private static bool PlayerMeetsConditionsToBuild(ShipBuildModeManager instance, bool checkConditions)
{
throw new NotImplementedException();
}
[MethodImpl(MethodImplOptions.NoInlining)]
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(ShipBuildModeManager), "StoreObject_performed")]
private static void StoreObjectPerformedOriginal(ShipBuildModeManager instance, CallbackContext context)
{
throw new NotImplementedException();
}
[HarmonyPatch("OnEnable")]
[HarmonyPrefix]
private static bool OnEnablePrefix(ShipBuildModeManager __instance)
{
//IL_00a5: 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)
currentShipBuildModeManager = __instance;
BuildModeInputActions.ReplaceFurniture.performed -= OnEnterBuildModePerformed;
BuildModeInputActions.ReplaceFurniture.performed += OnEnterBuildModePerformed;
BuildModeInputActions.StoreFurniture.performed -= OnStoreObjectPerformed;
BuildModeInputActions.StoreFurniture.performed += OnStoreObjectPerformed;
MovementActions movement = __instance.playerActions.Movement;
((MovementActions)(ref movement)).Enable();
return false;
}
[HarmonyPatch("OnDisable")]
[HarmonyPrefix]
private static bool OnDisablePrefix(ShipBuildModeManager __instance)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
BuildModeInputActions.ReplaceFurniture.performed -= OnEnterBuildModePerformed;
BuildModeInputActions.StoreFurniture.performed -= OnStoreObjectPerformed;
MovementActions movement = __instance.playerActions.Movement;
((MovementActions)(ref movement)).Disable();
if ((Object)(object)currentShipBuildModeManager == (Object)(object)__instance)
{
currentShipBuildModeManager = null;
}
return false;
}
private static void OnEnterBuildModePerformed(CallbackContext context)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (((CallbackContext)(ref context)).performed && !((Object)(object)currentShipBuildModeManager == (Object)null) && !currentShipBuildModeManager.InBuildMode)
{
enterBuildModeMethod.Invoke(currentShipBuildModeManager, new object[1] { context });
}
}
private static void OnStoreObjectPerformed(CallbackContext context)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)currentShipBuildModeManager == (Object)null))
{
StoreObjectPerformedOriginal(currentShipBuildModeManager, context);
}
}
internal static bool IsRotateHeld()
{
return ConfigManager.RotationMode.Value == RotationControlMode.Mouse && (Object)(object)ShipBuildModeManager.Instance != (Object)null && ShipBuildModeManager.Instance.InBuildMode && BuildModeInputActions.ConfirmIsPressed() && mouseLeftHeldTime >= 0.04f;
}
internal static void ChangeSnap(int direction)
{
currentSnapIndex = Mathf.Clamp(currentSnapIndex + direction, 0, snapSteps.Length - 1);
if (CurrentSnapDegrees > 0)
{
currentGhostYaw = NormaliseYaw(Mathf.Round(currentGhostYaw / (float)CurrentSnapDegrees) * (float)CurrentSnapDegrees);
}
rawGhostYawAccumulator = currentGhostYaw;
consumedLeftClickAction = true;
UpdateBuildModeTooltip();
}
private static bool CanShowStoreTooltip(PlaceableShipObject placingObject)
{
return (Object)(object)placingObject != (Object)null && StartOfRound.Instance.unlockablesList.unlockables[placingObject.unlockableID].canBeStored;
}
internal static void UpdateBuildModeTooltip()
{
UpdateBuildModeTooltip(currentPlacingObject);
}
private static void UpdateBuildModeTooltip(PlaceableShipObject placingObject)
{
if (!((Object)(object)HUDManager.Instance == (Object)null))
{
string text = $"{CurrentSnapDegrees}°";
string text2 = $"{NormaliseYaw(currentGhostYaw):0.#}";
string confirmBindingText = BuildModeInputActions.GetConfirmBindingText();
string cancelBindingText = BuildModeInputActions.GetCancelBindingText();
string storeFurnitureBindingText = BuildModeInputActions.GetStoreFurnitureBindingText();
string decreaseBindingText = BuildModeInputActions.GetDecreaseBindingText();
string increaseBindingText = BuildModeInputActions.GetIncreaseBindingText();
string text3 = (CanShowStoreTooltip(placingObject) ? (" Store [" + storeFurnitureBindingText + "]") : "");
RotationControlMode value = ConfigManager.RotationMode.Value;
if (1 == 0)
{
}
string text4 = ((value != 0) ? ("Place [" + confirmBindingText + "]" + text3 + " Cancel [" + cancelBindingText + "]\r\nRotate Left [" + decreaseBindingText + "] Rotate Right [" + increaseBindingText + "]\r\nDecrease [Hold " + confirmBindingText + " + " + decreaseBindingText + "] Snap [" + text + "] Increase [Hold " + confirmBindingText + " + " + increaseBindingText + "]") : ("Place [" + confirmBindingText + "]" + text3 + " Cancel [" + cancelBindingText + "]\r\nRotate [Hold " + confirmBindingText + " + Move Mouse]\r\nDecrease [" + decreaseBindingText + "] Snap [" + text + "] Increase [" + increaseBindingText + "]"));
if (1 == 0)
{
}
string text5 = text4;
if (ConfigManager.ShowCurrentRotation.Value)
{
text5 = text5 + "\r\n[" + text2 + "° / 360°]";
}
((TMP_Text)HUDManager.Instance.buildModeControlTip).text = text5;
}
}
internal static float NormaliseYaw(float yaw)
{
return Mathf.Repeat(yaw, 360f);
}
internal static int GetSnapIndex(int snapDegrees)
{
int num = Array.IndexOf(snapSteps, snapDegrees);
return (num < 0) ? 1 : num;
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void AwakePostfix(ShipBuildModeManager __instance, ref int ___placementMask, ref int ___placementMaskAndBlockers)
{
Material val = CreateGhostMaterial(__instance.ghostObjectGreen, ConfigManager.PlaceableGhostColour.Value);
if ((Object)(object)val != (Object)null)
{
__instance.ghostObjectGreen = val;
}
Material val2 = CreateGhostMaterial(__instance.ghostObjectRed, ConfigManager.BlockedGhostColour.Value);
if ((Object)(object)val2 != (Object)null)
{
__instance.ghostObjectRed = val2;
}
if (!snapInitialised)
{
currentSnapIndex = GetSnapIndex((int)ConfigManager.DefaultRotationSnap.Value);
snapInitialised = true;
}
___placementMask = LayerMask.GetMask(new string[3] { "Room", "Colliders", "PlacementBlocker" });
___placementMaskAndBlockers = LayerMask.GetMask(new string[1] { "PlacementBlocker" });
}
[HarmonyPatch("EnterBuildMode")]
[HarmonyPrefix]
private static bool EnterBuildModePrefix(ShipBuildModeManager __instance)
{
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
return (val == null || !val.inTerminalMenu) && !__instance.InBuildMode && !BuildModeBoundsRegistry.ShouldBlockNewBuildModeEntry(__instance);
}
[IteratorStateMachine(typeof(<EnterBuildModeTranspiler>d__37))]
[HarmonyPatch("EnterBuildMode")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> EnterBuildModeTranspiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnterBuildModeTranspiler>d__37(-2)
{
<>3__instructions = instructions
};
}
[IteratorStateMachine(typeof(<UpdateTranspiler>d__38))]
[HarmonyPatch("Update")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdateTranspiler>d__38(-2)
{
<>3__instructions = instructions
};
}
[HarmonyPatch("CreateGhostObjectAndHighlight")]
[HarmonyPostfix]
private static void CreateGhostObjectAndHighlightPostfix(ShipBuildModeManager __instance, PlaceableShipObject ___placingObject)
{
if (__instance.InBuildMode)
{
if ((Object)(object)___placingObject != (Object)null)
{
___placingObject.AllowPlacementOnWalls = true;
___placingObject.AllowPlacementOnCounters = true;
}
InitialiseBuildModeState(__instance, ___placingObject);
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(ShipBuildModeManager __instance, ref bool ___CanConfirmPosition, PlaceableShipObject ___placingObject, ref float ___timeSincePlacingObject)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.InBuildMode)
{
ResetBuildModeState();
return;
}
if (!wasInBuildMode)
{
InitialiseBuildModeState(__instance, ___placingObject);
}
UpdateMouseState();
if (BuildModeInputActions.CancelWasPressedThisFrame())
{
__instance.CancelBuildMode(true);
return;
}
Vector3 eulerAngles = __instance.ghostObject.eulerAngles;
__instance.ghostObject.rotation = Quaternion.Euler(eulerAngles.x, currentGhostYaw, eulerAngles.z);
((Renderer)__instance.ghostObjectRenderer).sharedMaterial = (___CanConfirmPosition ? __instance.ghostObjectGreen : __instance.ghostObjectRed);
if (!BuildModeInputActions.ConfirmWasReleasedThisFrame())
{
return;
}
if (consumedLeftClickAction)
{
consumedLeftClickAction = false;
}
else if (!(___timeSincePlacingObject <= 1f))
{
if (!___CanConfirmPosition)
{
HUDManager.Instance.UIAudio.PlayOneShot(__instance.denyPlacementSFX);
return;
}
___timeSincePlacingObject = 0f;
__instance.PlaceShipObject(__instance.ghostObject.position, __instance.ghostObject.eulerAngles, ___placingObject, true);
__instance.CancelBuildMode(false);
__instance.PlaceShipObjectServerRpc(__instance.ghostObject.position, __instance.ghostObject.eulerAngles, NetworkObjectReference.op_Implicit(((Component)___placingObject.parentObject).GetComponent<NetworkObject>()), (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
ResetBuildModeState();
}
}
private static Material CreateGhostMaterial(Material source, string htmlColor)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Color val = default(Color);
if (!ColorUtility.TryParseHtmlString(htmlColor, ref val))
{
return null;
}
Material val2 = new Material(source);
Color color = val2.GetColor("_BaseColor");
val.a = color.a;
val2.SetColor("_BaseColor", val);
val2.SetColor("_EmissiveColor", val);
return val2;
}
private static void InitialiseBuildModeState(ShipBuildModeManager instance, PlaceableShipObject placingObject)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
currentPlacingObject = placingObject;
defaultGhostYaw = NormaliseYaw(instance.ghostObject.eulerAngles.y);
currentGhostYaw = defaultGhostYaw;
rawGhostYawAccumulator = defaultGhostYaw;
wasInBuildMode = true;
consumedLeftClickAction = false;
mouseLeftHeldTime = 0f;
UpdateBuildModeTooltip(placingObject);
}
private static void ResetBuildModeState()
{
wasInBuildMode = false;
consumedLeftClickAction = false;
mouseLeftHeldTime = 0f;
currentPlacingObject = null;
}
private static void UpdateMouseState()
{
if (!BuildModeInputActions.ConfirmIsPressed())
{
mouseLeftHeldTime = 0f;
}
else if (BuildModeInputActions.ConfirmWasPressedThisFrame())
{
consumedLeftClickAction = false;
mouseLeftHeldTime = 0f;
}
else
{
mouseLeftHeldTime += Time.deltaTime;
}
}
}
[HarmonyPatch(typeof(StartMatchLever))]
internal static class StartMatchLeverPatches
{
[CompilerGenerated]
private sealed class <ReleaseBuildBlockUntilShipLanded>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReleaseBuildBlockUntilShipLanded>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.mls.LogInfo((object)"Active build mode cancelled and now blocked");
break;
case 1:
<>1__state = -1;
break;
}
if (!StartOfRound.Instance.shipHasLanded)
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = false;
<>2__current = null;
<>1__state = 1;
return true;
}
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = false;
Plugin.mls.LogInfo((object)"Build mode can now be accessed");
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("StartGame")]
[HarmonyPrefix]
private static void StartGamePrefix()
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = true;
ShipBuildModeManager instance = ShipBuildModeManager.Instance;
if (instance != null && instance.InBuildMode)
{
ShipBuildModeManager.Instance.CancelBuildMode(true);
}
}
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
private static void StartGamePostfix()
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ReleaseBuildBlockUntilShipLanded());
}
[IteratorStateMachine(typeof(<ReleaseBuildBlockUntilShipLanded>d__2))]
private static IEnumerator ReleaseBuildBlockUntilShipLanded()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReleaseBuildBlockUntilShipLanded>d__2(0);
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatches
{
private const string ShipBoundsTriggerPath = "HangarShip/ShipBoundsTrigger";
private static BoxCollider shipBoundsTriggerCollider;
[HarmonyPatch("ShipHasLeft")]
[HarmonyPrefix]
private static void ShipHasLeftPrefix()
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = true;
ShipBuildModeManager instance = ShipBuildModeManager.Instance;
if (instance != null && instance.InBuildMode)
{
ShipBuildModeManager.Instance.CancelBuildMode(true);
}
}
[HarmonyPatch("EndOfGameClientRpc")]
[HarmonyPostfix]
private static void EndOfGameClientRpcPostfix()
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = false;
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPatch("OnDestroy")]
[HarmonyPostfix]
private static void ClearAndResetPostfix()
{
ShipBuildModeManagerAPIPatches.roundStateBuildBlocked = false;
ShipFurnitureSurfaceReparent.Clear();
Helpers.ClearGameObjectCache();
if (ConfigManager.ExtendBuildBounds.Value)
{
ClearShipBoundsTrigger();
}
}
[HarmonyPatch("LoadShipGrabbableItems")]
[HarmonyPostfix]
private static void LoadShipGrabbableItemsPostfix(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
Helpers.CacheGameObject("ShipModels2b/MonitorWall");
Helpers.CacheGameObject("ShipModels2b/ChargeStation");
Helpers.ShipOutOfBoundsTrigger();
if (ConfigManager.ExtendBuildBounds.Value)
{
RegisterShipBoundsTrigger();
SetCatwalkShipToRoomLayer();
}
}
}
[HarmonyPatch("SyncShipUnlockablesClientRpc")]
[HarmonyPostfix]
private static void AfterSyncShipUnlockablesClientRpcPostfix(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
return;
}
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (networkManager.IsClient || networkManager.IsHost))
{
Helpers.CacheGameObject("ShipModels2b/MonitorWall");
Helpers.CacheGameObject("ShipModels2b/ChargeStation");
Helpers.ShipOutOfBoundsTrigger();
if (ConfigManager.ExtendBuildBounds.Value)
{
RegisterShipBoundsTrigger();
SetCatwalkShipToRoomLayer();
}
}
}
private static void RegisterShipBoundsTrigger()
{
GameObject val = GameObject.Find("HangarShip/ShipBoundsTrigger");
if ((Object)(object)val == (Object)null)
{
return;
}
BoxCollider component = val.GetComponent<BoxCollider>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)shipBoundsTriggerCollider == (Object)(object)component))
{
if ((Object)(object)shipBoundsTriggerCollider != (Object)null)
{
BuildModeBoundsRegistry.UnregisterBuildModeBounds((Collider)(object)shipBoundsTriggerCollider);
}
shipBoundsTriggerCollider = component;
BuildModeBoundsRegistry.RegisterBuildModeBounds((Collider)(object)shipBoundsTriggerCollider);
}
}
private static void ClearShipBoundsTrigger()
{
if (!((Object)(object)shipBoundsTriggerCollider == (Object)null))
{
BuildModeBoundsRegistry.UnregisterBuildModeBounds((Collider)(object)shipBoundsTriggerCollider);
shipBoundsTriggerCollider = null;
}
}
private static void SetCatwalkShipToRoomLayer()
{
GameObject val = GameObject.Find("Environment/HangarShip/CatwalkShip");
if (val != null)
{
val.layer = LayerMask.NameToLayer("Room");
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundUnlockableReparentPatches
{
[HarmonyPatch("LoadShipGrabbableItems")]
[HarmonyPostfix]
private static void AfterLoadShipGrabbableItemsPostfix(StartOfRound __instance)
{
if (ConfigManager.ReparentItemsToUnlockableSurfaces.Value && ((NetworkBehaviour)__instance).IsServer)
{
ShipFurnitureSurfaceReparent.Rebuild();
ShipFurnitureSurfaceReparent.RelinkAll(useGroundedOffset: false);
}
}
[HarmonyPatch("SyncShipUnlockablesClientRpc")]
[HarmonyPostfix]
private static void AfterSyncShipUnlockablesClientRpcPostfix(StartOfRound __instance)
{
if (ConfigManager.ReparentItemsToUnlockableSurfaces.Value && !((NetworkBehaviour)__instance).IsServer)
{
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (networkManager.IsClient || networkManager.IsHost))
{
ShipFurnitureSurfaceReparent.Rebuild();
ShipFurnitureSurfaceReparent.RelinkAll(useGroundedOffset: true);
}
}
}
}
}
namespace BasedDecorPlacement.PatchesAPI
{
[HarmonyPatch(typeof(ShipBuildModeManager))]
internal static class ShipBuildModeManagerAPIPatches
{
[CompilerGenerated]
private sealed class <UpdateTranspiler>d__4 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UpdateTranspiler>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
case 2:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (CodeInstructionExtensions.Calls(<instruction>5__2, boundsContainsMethod))
{
<>2__current = new CodeInstruction(OpCodes.Call, (object)buildModeRoomMethod);
<>1__state = 1;
return true;
}
<>2__current = <instruction>5__2;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<UpdateTranspiler>d__4 <UpdateTranspiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<UpdateTranspiler>d__ = this;
}
else
{
<UpdateTranspiler>d__ = new <UpdateTranspiler>d__4(0);
}
<UpdateTranspiler>d__.instructions = <>3__instructions;
return <UpdateTranspiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
private static readonly MethodInfo boundsContainsMethod = AccessTools.Method(typeof(Bounds), "Contains", new Type[1] { typeof(Vector3) }, (Type[])null);
private static readonly MethodInfo buildModeRoomMethod = AccessTools.Method(typeof(BuildModeBoundsRegistry), "IsInBuildModeRoom", new Type[2]
{
typeof(Bounds).MakeByRefType(),
typeof(Vector3)
}, (Type[])null);
internal static bool roundStateBuildBlocked;
[HarmonyPatch("PlayerMeetsConditionsToBuild")]
[HarmonyPrefix]
private static bool PlayerMeetsConditionsToBuildPrefix(ShipBuildModeManager __instance, ref bool __result, PlaceableShipObject ___placingObject)
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
if (roundStateBuildBlocked)
{
__result = false;
return false;
}
if (__instance.InBuildMode && ((Object)(object)___placingObject == (Object)null || ___placingObject.inUse || StartOfRound.Instance.unlockablesList.unlockables[___placingObject.unlockableID].inStorage))
{
__result = false;
return false;
}
if (localPlayerController.isTypingChat || localPlayerController.isPlayerDead || localPlayerController.inSpecialInteractAnimation || localPlayerController.activatingItem || localPlayerController.disablingJetpackControls || localPlayerController.jetpackControls)
{
__result = false;
return false;
}
if (!localPlayerController.isInHangarShipRoom && !BuildModeBoundsRegistry.IsInBuildModeRoom(((Component)localPlayerController).transform.position) && !BuildModeBoundsRegistry.ShouldIgnoreBuildModeRoomCheck(__instance))
{
__result = false;
return false;
}
if (StartOfRound.Instance.fearLevel > 0.4f)
{
__result = false;
return false;
}
AnimatorStateInfo currentAnimatorStateInfo = StartOfRound.Instance.shipAnimator.GetCurrentAnimatorStateInfo(0);
if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).tagHash != Animator.StringToHash("ShipIdle"))
{
__result = false;
return false;
}
if (!StartOfRound.Instance.inShipPhase && !StartOfRound.Instance.shipHasLanded)
{
__result = false;
return false;
}
__result = true;
return false;
}
[IteratorStateMachine(typeof(<UpdateTranspiler>d__4))]
[HarmonyPatch("Update")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdateTranspiler>d__4(-2)
{
<>3__instructions = instructions
};
}
}
}
namespace BasedDecorPlacement.Compatibility
{
[HarmonyPatch]
internal class ReservedItemSlotCorePatches
{
[CompilerGenerated]
private sealed class <Transpiler>d__3 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
case 2:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (CodeInstructionExtensions.Calls(<instruction>5__2, cancelBuildModeMethod))
{
<>2__current = new CodeInstruction(OpCodes.Call, (object)cancelBuildModeDuringReservedSlotSwapMethod);
<>1__state = 1;
return true;
}
<>2__current = <instruction>5__2;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__3 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__3(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
private static readonly MethodInfo cancelBuildModeMethod = AccessTools.Method(typeof(ShipBuildModeManager), "CancelBuildMode", new Type[1] { typeof(bool) }, (Type[])null);
private static readonly MethodInfo cancelBuildModeDuringReservedSlotSwapMethod = AccessTools.Method(typeof(ReservedItemSlotCorePatches), "CancelBuildModeDuringReservedSlotSwap", (Type[])null, (Type[])null);
private static MethodBase TargetMethod()
{
Type type = typeof(PluginInfo).Assembly.GetType("ReservedItemSlotCore.Networking.SyncManager", throwOnError: true);
return AccessTools.Method(type, "CallSwitchToItemSlotMethod", new Type[2]
{
typeof(PlayerControllerB),
typeof(int)
}, (Type[])null);
}
[IteratorStateMachine(typeof(<Transpiler>d__3))]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__3(-2)
{
<>3__instructions = instructions
};
}
private static void CancelBuildModeDuringReservedSlotSwap(ShipBuildModeManager instance, bool cancelBeforePlacement)
{
if (!instance.InBuildMode)
{
instance.CancelBuildMode(cancelBeforePlacement);
}
}
}
}
namespace BasedDecorPlacement.API
{
public static class BuildModeBoundsRegistry
{
private const float GraceDuration = 0.35f;
private static readonly HashSet<Collider> buildModeBounds = new HashSet<Collider>();
private static float buildModeGraceUntil;
public static void RegisterBuildModeBounds(Collider collider)
{
if (!((Object)(object)collider == (Object)null))
{
buildModeBounds.Add(collider);
}
}
public static void UnregisterBuildModeBounds(Collider collider)
{
if (!((Object)(object)collider == (Object)null))
{
buildModeBounds.Remove(collider);
}
}
public static bool IsInBuildModeRoom(ref Bounds bounds, Vector3 position)
{
//IL_0002: 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_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)
if (((Bounds)(ref bounds)).Contains(position))
{
return true;
}
foreach (Collider buildModeBound in buildModeBounds)
{
if (!IsActiveBoundsCollider(buildModeBound) || !(buildModeBound.ClosestPoint(position) == position))
{
continue;
}
return true;
}
return false;
}
public static bool IsInBuildModeRoom(Vector3 position)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
if ((Object)(object)instance?.shipInnerRoomBounds != (Object)null)
{
Bounds bounds = instance.shipInnerRoomBounds.bounds;
if (((Bounds)(ref bounds)).Contains(position))
{
return true;
}
}
foreach (Collider buildModeBound in buildModeBounds)
{
if (!IsActiveBoundsCollider(buildModeBound) || !(buildModeBound.ClosestPoint(position) == position))
{
continue;
}
return true;
}
return false;
}
public static void BeginTeleportBuildModeGrace(PlayerControllerB player, Vector3 destination)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
ShipBuildModeManager instance = ShipBuildModeManager.Instance;
if (!((Object)(object)player != (Object)(object)val) && !((Object)(object)instance == (Object)null) && instance.InBuildMode && IsInBuildModeRoom(destination))
{
float num = Time.realtimeSinceStartup + 0.35f;
if (num > buildModeGraceUntil)
{
buildModeGraceUntil = num;
}
}
}
public static bool ShouldIgnoreBuildModeRoomCheck(ShipBuildModeManager buildModeManager)
{
PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
return (Object)(object)buildModeManager != (Object)null && (Object)(object)val != (Object)null && buildModeManager.InBuildMode && !val.isInHangarShipRoom && Time.realtimeSinceStartup < buildModeGraceUnti