using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using LobbyNetworking;
using Microsoft.CodeAnalysis;
using Mirror;
using Rewired;
using UnityEngine;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TIDY")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TIDY")]
[assembly: AssemblyTitle("TIDY")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TidyLostAndFound
{
[BepInPlugin("gogogadgetjustice.tidy.lostandfound", "Tidy Lost and Found", "1.0.0")]
public sealed class Plugin : BasePlugin
{
public const string PluginGuid = "gogogadgetjustice.tidy.lostandfound";
public const string PluginName = "Tidy Lost and Found";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource L;
public override void Load()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
L = ((BasePlugin)this).Log;
TidyConfig.Bind(((BasePlugin)this).Config);
new Harmony("gogogadgetjustice.tidy.lostandfound").PatchAll(typeof(Plugin).Assembly);
ClassInjector.RegisterTypeInIl2Cpp<TidyManager>();
((BasePlugin)this).AddComponent<TidyManager>();
ManualLogSource l = L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Tidy Lost and Found");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Press ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(TidyConfig.TidyKey.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" in game to re-tidy.");
}
l.LogInfo(val);
}
internal static void Verbose(string message)
{
if (TidyConfig.Verbose.Value)
{
L.LogInfo((object)message);
}
}
}
internal static class TidyConfig
{
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<bool> UseAnchorYaw;
public static ConfigEntry<bool> Verbose;
public static ConfigEntry<KeyCode> TidyKey;
public static ConfigEntry<KeyCode> ReleaseKey;
public static ConfigEntry<KeyCode> Modifier;
public static ConfigEntry<string> AnchorName;
public static ConfigEntry<string> SkipNames;
public static ConfigEntry<int> Pockets;
public static ConfigEntry<int> Columns;
public static ConfigEntry<int> TicketBase;
public static ConfigEntry<int> GroupId;
public static ConfigEntry<float> Radius;
public static ConfigEntry<float> Spacing;
public static ConfigEntry<float> OffsetX;
public static ConfigEntry<float> OffsetY;
public static ConfigEntry<float> OffsetZ;
public static ConfigEntry<float> Yaw;
public static ConfigEntry<float> GiveUpSeconds;
public static void Bind(ConfigFile cfg)
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Expected O, but got Unknown
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Expected O, but got Unknown
Verbose = cfg.Bind<bool>("TidyLostAndFound", "VerboseLogging", false, "Extra log lines.");
Enabled = cfg.Bind<bool>("TidyLostAndFound", "Enabled", true, "Rack the lost & found items on pocket mounts when the map loads.");
TidyKey = cfg.Bind<KeyCode>("TidyLostAndFound", "TidyKey", (KeyCode)288, "Rebuild the rack and tidy again now. If the lost & found can't be found by name, stand in it first.");
Modifier = cfg.Bind<KeyCode>("TidyLostAndFound", "ModifierKey", (KeyCode)304, "Hold this with the tidy/release keys. None = no modifier needed.");
ReleaseKey = cfg.Bind<KeyCode>("TidyLostAndFound", "ReleaseKey", (KeyCode)289, "Take everything off the rack at once (items drop where they hang).");
SkipNames = cfg.Bind<string>("TidyLostAndFound", "SkipNames", "backpack", "Comma-separated name parts of items that are never racked (e.g. backpack,buoy). Empty = rack everything.");
AnchorName = cfg.Bind<string>("TidyLostAndFound", "AnchorName", "", "Optional: part of the lost & found object's name, if auto-detection picks the wrong one (see the log).");
Radius = cfg.Bind<float>("TidyLostAndFound", "Radius", 12f, "Loose items within this many metres of the lost & found get racked.");
Pockets = cfg.Bind<int>("TidyLostAndFound", "Pockets", 100, new ConfigDescription("Number of pocket mounts. Must match between players.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 500), Array.Empty<object>()));
Columns = cfg.Bind<int>("TidyLostAndFound", "Columns", 10, new ConfigDescription("Pockets per row.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>()));
Spacing = cfg.Bind<float>("TidyLostAndFound", "Spacing", 0.455f, "Distance between pockets in metres.");
OffsetX = cfg.Bind<float>("TidyLostAndFound", "OffsetX", 0f, "Rack centre, right of the lost & found (its own axes).");
OffsetY = cfg.Bind<float>("TidyLostAndFound", "RackHeight", 0f, "Bottom row height above the lost & found.");
OffsetZ = cfg.Bind<float>("TidyLostAndFound", "OffsetZ", -1.65f, "Rack centre, forward of the lost & found.");
Yaw = cfg.Bind<float>("TidyLostAndFound", "RackYaw", 90f, "Extra rotation of the rack in degrees (use -90 if it faces the wrong way).");
UseAnchorYaw = cfg.Bind<bool>("TidyLostAndFound", "UseAnchorYaw", true, "Face the way the lost & found object faces (otherwise world north + Yaw).");
GiveUpSeconds = cfg.Bind<float>("TidyLostAndFound", "GiveUpSeconds", 90f, "Stop waiting for the lost & found after this long (the key still works).");
GroupId = cfg.Bind<int>("TidyLostAndFound", "GroupId", -1, "Item group the rack accepts. -1 = a new group every item is given, so anything fits (buoys included). Set 25 to reuse the backpack group.");
TicketBase = cfg.Bind<int>("TidyLostAndFound", "TicketBase", 58000, new ConfigDescription("First game ticket used by the rack. Below the choppa's 60000 block.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1000, 64000), Array.Empty<object>()));
}
}
internal static class TidyFinder
{
private static string skipRaw;
private static string[] skip = Array.Empty<string>();
private static bool Skipped(string name)
{
string text = TidyConfig.SkipNames.Value ?? "";
if ((object)text != skipRaw && text != skipRaw)
{
skipRaw = text;
skip = text.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
}
string[] array = skip;
foreach (string value in array)
{
if (name.Contains(value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
private static string Norm(string s)
{
StringBuilder stringBuilder = new StringBuilder(s.Length);
foreach (char c in s)
{
if (char.IsLetter(c))
{
stringBuilder.Append(char.ToLowerInvariant(c));
}
}
return stringBuilder.ToString();
}
private static string PathOf(Transform t)
{
string text = ((Object)t).name;
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
text = ((Object)parent).name + "/" + text;
parent = parent.parent;
}
return text;
}
private static int Depth(Transform t)
{
int num = 0;
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
num++;
parent = parent.parent;
}
return num;
}
public static Transform FindAnchor()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
string text = Norm(TidyConfig.AnchorName.Value ?? "");
Transform val = null;
int num = int.MaxValue;
int num2 = 0;
bool flag = default(bool);
foreach (Transform item in Resources.FindObjectsOfTypeAll<Transform>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
Scene scene = ((Component)item).gameObject.scene;
if (!((Scene)(ref scene)).IsValid())
{
continue;
}
string text2 = Norm(((Object)item).name);
bool num3;
if (text.Length <= 0)
{
if (text2.Contains("lostandfound") || text2.Contains("lostfound"))
{
goto IL_00df;
}
if (!text2.Contains("lost"))
{
continue;
}
num3 = text2.Contains("found");
}
else
{
num3 = text2.Contains(text);
}
if (!num3)
{
continue;
}
goto IL_00df;
IL_00df:
if (++num2 <= 8)
{
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(30, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: anchor candidate '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(PathOf(item));
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' at ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(item.position);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
l.LogInfo(val2);
}
int num4 = Depth(item);
if (num4 < num)
{
num = num4;
val = item;
}
}
if ((Object)(object)val != (Object)null)
{
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(48, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: using '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(PathOf(val));
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' as the lost & found (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" match(es)).");
}
l2.LogInfo(val2);
}
return val;
}
public static void Candidates(Vector3 centre, Transform anchor, HashSet<IntPtr> skip, List<Prop> into, out int alreadyHomed)
{
//IL_0007: 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_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)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
into.Clear();
alreadyHomed = 0;
List<Prop> allProps = Prop.allProps;
if (allProps == null)
{
return;
}
float num = TidyConfig.Radius.Value * TidyConfig.Radius.Value;
for (int i = 0; i < allProps.Count; i++)
{
Prop val = allProps[i];
if ((Object)(object)val == (Object)null || skip.Contains(((Il2CppObjectBase)val).Pointer))
{
continue;
}
Vector3 val2 = ((Component)val).transform.position - centre;
if ((((Vector3)(ref val2)).sqrMagnitude <= num || ((Object)(object)anchor != (Object)null && ((Component)val).transform.IsChildOf(anchor))) && !((Object)(object)val.rb == (Object)null) && !val.isInInventory && !Skipped(((Object)val).name))
{
if ((Object)(object)val.currentHome != (Object)null)
{
alreadyHomed++;
}
else
{
into.Add(val);
}
}
}
into.Sort(delegate(Prop a, Prop b)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_002c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
int num2 = string.CompareOrdinal(((Object)a).name, ((Object)b).name);
int result;
if (num2 == 0)
{
Vector3 val3 = ((Component)a).transform.position - centre;
float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
val3 = ((Component)b).transform.position - centre;
result = sqrMagnitude.CompareTo(((Vector3)(ref val3)).sqrMagnitude);
}
else
{
result = num2;
}
return result;
});
}
}
[HarmonyPatch]
internal static class TidyGroups
{
private static PropGroup? group;
public static PropGroup Group
{
get
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
if (!group.HasValue)
{
int num = TidyConfig.GroupId.Value;
if (num < 0)
{
int num2 = 0;
foreach (object value in Enum.GetValues(typeof(PropGroup)))
{
num2 = Math.Max(num2, Convert.ToInt32(value));
}
num = num2 + 1;
}
group = (PropGroup)num;
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tidy: rack item group is ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
}
l.LogInfo(val);
}
return group.Value;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Prop), "Start")]
private static void Start_Postfix(Prop __instance)
{
if (TidyConfig.Enabled.Value)
{
Tag(__instance);
}
}
public static void TagAll()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
try
{
List<Prop> allProps = Prop.allProps;
if (allProps == null)
{
return;
}
for (int i = 0; i < allProps.Count; i++)
{
Prop val = allProps[i];
if ((Object)(object)val != (Object)null)
{
Tag(val);
}
}
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: tagging items failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val2);
}
}
private static void Tag(Prop prop)
{
//IL_0013: 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_001f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
try
{
List<PropGroup> propGroups = prop.propGroups;
if (propGroups == null)
{
return;
}
PropGroup val = Group;
for (int i = 0; i < propGroups.Count; i++)
{
if (propGroups[i] == val)
{
return;
}
}
propGroups.Add(val);
}
catch
{
}
}
}
internal static class TidyInput
{
private static bool rewiredBroken;
private static bool unityBroken;
private static readonly Dictionary<KeyCode, bool> prev = new Dictionary<KeyCode, bool>();
public static bool Pressed(KeyCode k)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if ((int)k == 0)
{
return false;
}
bool flag = Raw(k);
prev.TryGetValue(k, out var value);
prev[k] = flag;
return flag && !value;
}
public static bool Held(KeyCode k)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return (int)k != 0 && Raw(k);
}
private static bool Raw(KeyCode k)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
bool flag = default(bool);
if (!rewiredBroken)
{
try
{
if (ReInput.isReady && ReInput.controllers.keyboardEnabled)
{
return ReInput.controllers.Keyboard.GetKey(k);
}
}
catch (Exception ex)
{
rewiredBroken = true;
ManualLogSource l = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tidy: Rewired input failed, using Unity Input: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val);
}
}
if (!unityBroken)
{
try
{
return Input.GetKey(k);
}
catch (Exception ex2)
{
unityBroken = true;
ManualLogSource l2 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tidy: Unity Input failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
}
l2.LogWarning(val);
}
}
return false;
}
}
public class TidyManager : MonoBehaviour
{
private enum State
{
Waiting,
Done,
Idle,
GaveUp
}
private State state = State.Waiting;
private int sceneHandle = int.MinValue;
private float startedAt;
private float nextTick;
private float builtAt;
private float boxTick;
private int lastCount = -1;
private int stableTicks;
private TidyRack rack;
private Transform anchor;
private readonly HashSet<IntPtr> tried = new HashSet<IntPtr>();
private readonly HashSet<IntPtr> seated = new HashSet<IntPtr>();
private readonly List<Prop> items = new List<Prop>();
public TidyManager(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
try
{
Tick();
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("TidyManager.Update: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
l.LogError(val);
}
}
private void Tick()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
if (!TidyConfig.Enabled.Value)
{
return;
}
Scene activeScene = SceneManager.GetActiveScene();
int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
if (num != sceneHandle)
{
sceneHandle = num;
Reset();
}
bool flag = TidyInput.Pressed(TidyConfig.TidyKey.Value);
bool flag2 = TidyInput.Pressed(TidyConfig.ReleaseKey.Value);
KeyCode value = TidyConfig.Modifier.Value;
bool flag3 = (int)value == 0 || TidyInput.Held(value);
if (flag && flag3)
{
TidyNow(manual: true);
return;
}
if (flag2 && flag3)
{
rack?.ReleaseAll();
Plugin.L.LogInfo((object)"Tidy: released everything.");
return;
}
float unscaledTime = Time.unscaledTime;
if (rack != null && unscaledTime >= boxTick)
{
boxTick = unscaledTime + 0.2f;
rack.SyncBoxes();
}
if (unscaledTime < nextTick)
{
return;
}
switch (state)
{
case State.Waiting:
nextTick = unscaledTime + 2f;
Poll(unscaledTime);
break;
case State.Done:
nextTick = unscaledTime + 1f;
if (TidyPinner.Authority || unscaledTime > builtAt + 60f)
{
state = State.Idle;
}
else
{
Rebind();
}
break;
}
}
private void Reset()
{
rack?.Destroy();
rack = null;
anchor = null;
tried.Clear();
seated.Clear();
state = State.Waiting;
startedAt = Time.unscaledTime;
nextTick = startedAt + 3f;
lastCount = -1;
stableTicks = 0;
}
private void Poll(float t)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
if (t - startedAt > TidyConfig.GiveUpSeconds.Value)
{
state = State.GaveUp;
Plugin.L.LogWarning((object)"Tidy: gave up waiting for the lost & found. Stand in it and press the tidy key.");
return;
}
if ((Object)(object)anchor == (Object)null)
{
anchor = TidyFinder.FindAnchor();
if ((Object)(object)anchor == (Object)null)
{
return;
}
}
TidyFinder.Candidates(anchor.position, anchor, tried, items, out var _);
if (items.Count > 0 && items.Count == lastCount)
{
stableTicks++;
}
else
{
stableTicks = 0;
}
lastCount = items.Count;
if (stableTicks >= 2)
{
Tidy(anchor.position, anchor.rotation, anchor);
}
}
private void TidyNow(bool manual)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0077: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
Transform val = (((Object)(object)anchor != (Object)null) ? anchor : TidyFinder.FindAnchor());
Vector3 anchorPos;
Quaternion anchorRot;
if ((Object)(object)val != (Object)null)
{
anchor = val;
anchorPos = val.position;
anchorRot = val.rotation;
}
else
{
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
Plugin.L.LogWarning((object)"Tidy: no lost & found and no camera to anchor on.");
return;
}
anchorPos = ((Component)main).transform.position - Vector3.up * 1.5f;
anchorRot = Quaternion.Euler(0f, ((Component)main).transform.eulerAngles.y + 180f, 0f);
Plugin.L.LogWarning((object)"Tidy: anchoring on your position; other players only match if they do the same.");
}
rack?.Destroy();
rack = null;
tried.Clear();
seated.Clear();
Tidy(anchorPos, anchorRot, val);
}
private void Tidy(Vector3 anchorPos, Quaternion anchorRot, Transform a)
{
//IL_0028: 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)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
rack?.Destroy();
float num = (TidyConfig.UseAnchorYaw.Value ? ((Quaternion)(ref anchorRot)).eulerAngles.y : 0f);
Quaternion val = Quaternion.Euler(0f, num + TidyConfig.Yaw.Value, 0f);
Vector3 pos = anchorPos + val * new Vector3(TidyConfig.OffsetX.Value, TidyConfig.OffsetY.Value, TidyConfig.OffsetZ.Value);
TidyFinder.Candidates(anchorPos, a, tried, items, out var alreadyHomed);
TidyGroups.TagAll();
rack = TidyRack.Build(pos, val);
rack.Activate();
state = State.Done;
builtAt = Time.unscaledTime;
nextTick = builtAt + 1f;
int num2 = 0;
int i = 0;
if (TidyPinner.Authority)
{
foreach (Prop item in items)
{
if (!((Object)(object)item == (Object)null))
{
for (; i < rack.Homes.Length && (Object)(object)rack.Homes[i] == (Object)null; i++)
{
}
if (i >= rack.Homes.Length)
{
break;
}
tried.Add(((Il2CppObjectBase)item).Pointer);
if (TidyPinner.Pin(item, rack.Homes[i]))
{
num2++;
i++;
}
}
}
}
Plugin.L.LogInfo((object)($"Tidy: racked {num2} of {items.Count} items ({alreadyHomed} near the lost & found already had a home and were left alone)" + ((items.Count > num2 && TidyPinner.Authority) ? "; raise [TidyLostAndFound] Pockets for the rest." : ".")));
}
private void Rebind()
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
if (rack == null)
{
return;
}
List<Prop> allProps = Prop.allProps;
if (allProps == null)
{
return;
}
ushort firstTicket = rack.FirstTicket;
bool flag = default(bool);
for (int i = 0; i < allProps.Count; i++)
{
Prop val = allProps[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
int num = val.propHomeShellReference.ticket - firstTicket;
if (num < 0 || num >= rack.Homes.Length || (Object)(object)rack.Homes[num] == (Object)null || !seated.Add(((Il2CppObjectBase)val).Pointer) || (Object)(object)val.currentHome != (Object)null)
{
continue;
}
try
{
val.LocallySetPinned(rack.Homes[num], false);
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(19, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: re-seating ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val2);
}
}
}
}
internal static class TidyMaterials
{
private static readonly Dictionary<Color, Material> cache = new Dictionary<Color, Material>();
private static Shader shader;
private static Material template;
private static bool resolved;
public static Material Get(Color color)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
if (cache.TryGetValue(color, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
Resolve();
Material val;
if ((Object)(object)shader != (Object)null)
{
val = new Material(shader);
}
else
{
if (!((Object)(object)template != (Object)null))
{
return null;
}
val = new Material(template);
}
((Object)val).name = "Tidy_" + ColorUtility.ToHtmlStringRGB(color);
if (val.HasProperty("_BaseMap"))
{
val.SetTexture("_BaseMap", (Texture)null);
}
if (val.HasProperty("_MainTex"))
{
val.SetTexture("_MainTex", (Texture)null);
}
if (val.HasProperty("_BaseColor"))
{
val.SetColor("_BaseColor", color);
}
if (val.HasProperty("_Color"))
{
val.SetColor("_Color", color);
}
if (val.HasProperty("_Smoothness"))
{
val.SetFloat("_Smoothness", 0.35f);
}
val.color = color;
cache[color] = val;
return val;
}
public static Transform Part(Transform parent, PrimitiveType type, string name, Vector3 pos, Vector3 euler, Vector3 scale, Color color, bool solid)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0078: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive(type);
((Object)val).name = name;
Transform transform = val.transform;
transform.SetParent(parent, false);
transform.localPosition = pos;
transform.localEulerAngles = euler;
transform.localScale = scale;
if (!solid)
{
Collider component = val.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
}
MeshRenderer component2 = val.GetComponent<MeshRenderer>();
if ((Object)(object)component2 != (Object)null)
{
((Renderer)component2).sharedMaterial = Get(color);
}
return transform;
}
private static void Resolve()
{
if (resolved)
{
return;
}
resolved = true;
string[] array = new string[3] { "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit", "Universal Render Pipeline/Unlit" };
foreach (string text in array)
{
shader = Shader.Find(text);
if ((Object)(object)shader != (Object)null)
{
return;
}
}
foreach (MeshRenderer item in Object.FindObjectsByType<MeshRenderer>((FindObjectsSortMode)0))
{
Material sharedMaterial = ((Renderer)item).sharedMaterial;
if ((Object)(object)sharedMaterial == (Object)null || (Object)(object)sharedMaterial.shader == (Object)null || (!sharedMaterial.HasProperty("_BaseColor") && !sharedMaterial.HasProperty("_Color")))
{
continue;
}
template = sharedMaterial;
return;
}
Plugin.L.LogWarning((object)"Tidy: no usable shader or material found; the rack may render magenta.");
}
}
internal static class TidyPinner
{
private static bool resolved;
private static MethodInfo serverPin;
private static ParameterInfo[] pinParams;
public static bool Authority => NetworkServer.active || !NetworkClient.active;
private static void Resolve()
{
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
if (resolved)
{
return;
}
resolved = true;
try
{
MethodInfo[] methods = typeof(Prop).GetMethods(BindingFlags.Instance | BindingFlags.Public);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name.StartsWith("ServerSet") && methodInfo.Name.Contains("Pinned") && !methodInfo.Name.Contains("Unpinned"))
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length != 0 && !(parameters[0].ParameterType != typeof(PropHome)))
{
serverPin = methodInfo;
pinParams = parameters;
break;
}
}
}
Plugin.L.LogInfo((object)((serverPin != null) ? $"Tidy: using Prop.{serverPin.Name}({string.Join(", ", Array.ConvertAll(pinParams, (ParameterInfo p) => p.ParameterType.Name))}) to pin on the host." : "Tidy: no server pin method found on Prop; pinning locally only (other players may not see it)."));
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tidy: pin method lookup failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val);
}
}
public static bool Pin(Prop prop, PropHome home)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
Resolve();
try
{
if (serverPin != null && NetworkServer.active)
{
object[] array = new object[pinParams.Length];
array[0] = home;
for (int i = 1; i < array.Length; i++)
{
array[i] = (pinParams[i].ParameterType.IsValueType ? Activator.CreateInstance(pinParams[i].ParameterType) : null);
}
serverPin.Invoke(prop, array);
}
else
{
prop.LocallySetPinned(home, false);
}
return true;
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tidy: pinning ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)prop).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((ex.InnerException ?? ex).Message);
}
l.LogWarning(val);
return false;
}
}
}
internal sealed class TidyRack
{
public readonly PropHome[] Homes;
private readonly BoxCollider[] boxes;
private GameObject root;
public ushort FirstTicket { get; private set; }
private TidyRack(int count)
{
Homes = (PropHome[])(object)new PropHome[count];
boxes = (BoxCollider[])(object)new BoxCollider[count];
}
public static TidyRack Build(Vector3 pos, Quaternion rot)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Expected O, but got Unknown
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
int value = TidyConfig.Pockets.Value;
int num = Mathf.Min(TidyConfig.Columns.Value, value);
int num2 = (value + num - 1) / num;
float value2 = TidyConfig.Spacing.Value;
TidyRack tidyRack = new TidyRack(value);
tidyRack.root = new GameObject("TidyRack");
tidyRack.root.transform.SetPositionAndRotation(pos, rot);
Transform transform = tidyRack.root.transform;
TidyMaterials.Part(transform, (PrimitiveType)3, "TidyBoard", new Vector3(0f, (float)(num2 - 1) * value2 * 0.5f, -0.12f), Vector3.zero, new Vector3((float)num * value2 + 0.2f, (float)num2 * value2 + 0.2f, 0.05f), new Color(0.15f, 0.2f, 0.3f), solid: false);
Vector3 val = default(Vector3);
for (int i = 0; i < value; i++)
{
((Vector3)(ref val))..ctor(((float)(i % num) - (float)(num - 1) * 0.5f) * value2, (float)(i / num) * value2, 0f);
TidyMaterials.Part(transform, (PrimitiveType)3, "TidyPouch", val + new Vector3(0f, -0.05f, -0.02f), Vector3.zero, new Vector3(0.34f, 0.26f, 0.1f), Color.HSVToRGB((float)(i % num) / (float)num, 0.75f, 0.95f), solid: false);
GameObject val2 = new GameObject($"TidyHome{i}");
val2.SetActive(false);
val2.transform.SetParent(transform, false);
val2.transform.localPosition = val + new Vector3(0f, 0f, 0.2f);
BoxCollider val3 = val2.AddComponent<BoxCollider>();
val3.center = new Vector3(0f, 0f, -0.12f);
val3.size = new Vector3(0.4f, 0.4f, 0.4f);
tidyRack.boxes[i] = val3;
tidyRack.Homes[i] = val2.AddComponent<PropHome>();
}
return tidyRack;
}
public void Activate()
{
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Expected O, but got Unknown
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Expected O, but got Unknown
TidyTemplate.Find();
TicketOffice instance = TicketOffice.instance;
FirstTicket = (ushort)TidyConfig.TicketBase.Value;
int num = 0;
bool flag = default(bool);
for (int i = 0; i < Homes.Length; i++)
{
PropHome val = Homes[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
ushort num2 = (ushort)(FirstTicket + i);
try
{
if (!TidyTickets.Free(instance, num2))
{
Plugin.Verbose($"Tidy: ticket {num2} is used by the game; mount {i} skipped.");
Object.Destroy((Object)(object)((Component)val).gameObject);
Homes[i] = null;
continue;
}
GameObject gameObject = ((Component)val).gameObject;
if (TidyTemplate.CastLayer >= 0)
{
gameObject.layer = TidyTemplate.CastLayer;
}
((Collider)gameObject.GetComponent<BoxCollider>()).isTrigger = TidyTemplate.CastTrigger;
val.pinGroup = TidyGroups.Group;
val.isInventory = true;
val.saveableHomeName = (SaveableHomeName)0;
if ((Object)(object)TidyTemplate.PlaceSound != (Object)null)
{
val.propPlaceSoundOverride = TidyTemplate.PlaceSound;
}
if ((Object)(object)TidyTemplate.RemoveSound != (Object)null)
{
val.propRemoveSoundOverride = TidyTemplate.RemoveSound;
}
val._ticket_k__BackingField = num2;
val.shellReference = new ShellReference(num2);
CastableTarget val2 = gameObject.AddComponent<CastableTarget>();
Il2CppReferenceArray<CastableOutcome> val3 = new Il2CppReferenceArray<CastableOutcome>(1L);
((Il2CppArrayBase<CastableOutcome>)(object)val3)[0] = new CastableOutcome
{
propHome = val
};
val2.outcomes = val3;
gameObject.SetActive(true);
if (val.ticket != num2)
{
val._ticket_k__BackingField = num2;
}
if (!instance.tickets.ContainsKey(num2))
{
TicketOffice.AddTicket(new ITicketed(((Il2CppObjectBase)val).Pointer));
}
num++;
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Tidy: mount ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(i);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" setup failed: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
}
l.LogError(val4);
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
Homes[i] = null;
}
}
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(43, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Tidy: rack built with ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(Homes.Length);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" mounts, tickets ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<ushort>(FirstTicket);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("..");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(FirstTicket + Homes.Length - 1);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(".");
}
l2.LogInfo(val5);
}
public void SyncBoxes()
{
for (int i = 0; i < Homes.Length; i++)
{
PropHome val = Homes[i];
BoxCollider val2 = boxes[i];
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
bool flag = (Object)(object)val.pinnedProp != (Object)null;
if (((Collider)val2).enabled == flag)
{
((Collider)val2).enabled = !flag;
}
}
}
}
public void ReleaseAll()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
PropHome[] homes = Homes;
bool flag = default(bool);
foreach (PropHome val in homes)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
try
{
Prop pinnedProp = val.pinnedProp;
if (!((Object)(object)pinnedProp == (Object)null))
{
if (NetworkServer.active)
{
pinnedProp.ServerSetUnpinned();
}
else
{
pinnedProp.LocalUnpin(val);
}
}
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: emptying mount: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val2);
}
}
SyncBoxes();
}
public void Destroy()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
ReleaseAll();
TicketOffice instance = TicketOffice.instance;
PropHome[] homes = Homes;
bool flag = default(bool);
foreach (PropHome val in homes)
{
try
{
if ((Object)(object)val != (Object)null && (Object)(object)instance != (Object)null && instance.tickets.ContainsKey(val.ticket))
{
instance.tickets.Remove(val.ticket);
}
}
catch (Exception ex)
{
ManualLogSource l = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Tidy: removing ticket: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val2);
}
}
if ((Object)(object)root != (Object)null)
{
Object.Destroy((Object)(object)root);
}
root = null;
}
}
internal static class TidyTemplate
{
private static bool searched;
public static PropGroup AcceptGroup = (PropGroup)25;
public static int CastLayer = -1;
public static bool CastTrigger;
public static AudioAsset PlaceSound;
public static AudioAsset RemoveSound;
public static void Find()
{
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Expected O, but got Unknown
//IL_0110: 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_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
if (searched)
{
return;
}
searched = true;
bool flag = default(bool);
try
{
CastableTarget val = null;
PropHome val2 = null;
foreach (CastableTarget item in Resources.FindObjectsOfTypeAll<CastableTarget>())
{
Il2CppReferenceArray<CastableOutcome> outcomes = item.outcomes;
if (outcomes == null)
{
continue;
}
for (int i = 0; i < ((Il2CppArrayBase<CastableOutcome>)(object)outcomes).Length; i++)
{
if (!((Object)(object)val2 == (Object)null))
{
break;
}
CastableOutcome obj = ((Il2CppArrayBase<CastableOutcome>)(object)outcomes)[i];
PropHome val3 = ((obj != null) ? obj.propHome : null);
if ((Object)(object)val3 != (Object)null && (int)val3.pinGroup == 25 && (Object)(object)val3.parentCharacter == (Object)null)
{
val2 = val3;
val = item;
}
}
if (!((Object)(object)val2 != (Object)null))
{
continue;
}
break;
}
if ((Object)(object)val2 == (Object)null)
{
Plugin.L.LogWarning((object)"Tidy: no backpack pocket found to copy; using defaults (mounts may not be targetable).");
return;
}
AcceptGroup = val2.pinGroup;
PlaceSound = val2.propPlaceSoundOverride;
RemoveSound = val2.propRemoveSoundOverride;
Collider val4 = ((Component)val).GetComponent<Collider>() ?? ((Component)val).GetComponentInChildren<Collider>(true);
CastLayer = (((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject.layer : ((Component)val).gameObject.layer);
CastTrigger = (Object)(object)val4 != (Object)null && val4.isTrigger;
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(66, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Tidy: copied backpack pocket (group ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<PropGroup>(AcceptGroup);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("), crosshair layer ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(CastLayer);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(", trigger ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<bool>(CastTrigger);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(".");
}
l.LogInfo(val5);
}
catch (Exception ex)
{
ManualLogSource l2 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Tidy: template search failed: ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
}
l2.LogWarning(val6);
}
}
}
internal static class TidyTickets
{
public static bool Free(TicketOffice office, ushort ticket)
{
if ((Object)(object)office == (Object)null || !office.tickets.ContainsKey(ticket))
{
return true;
}
ITicketed val = office.tickets[ticket];
if (val != null && ((Object)(object)((Il2CppObjectBase)val).TryCast<PropHome>() != (Object)null || (Object)(object)((Il2CppObjectBase)val).TryCast<PlayerPose>() != (Object)null))
{
return false;
}
office.tickets.Remove(ticket);
return true;
}
}
}