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.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PostLevelSummary.Helpers;
using PostLevelSummary.Models;
using PostLevelSummary.Patches;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Hattorius")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4cd0086d09953ee0dd9b0fdf7208ede8ca5a11e8")]
[assembly: AssemblyProduct("PostLevelSummary")]
[assembly: AssemblyTitle("PostLevelSummary")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PostLevelSummary
{
[BepInPlugin("Hattorius.PostLevelSummary", "PostLevelSummary", "1.0")]
public class PostLevelSummary : BaseUnityPlugin
{
public static ManualLogSource Logger;
private readonly Harmony harmony = new Harmony("Hattorius.PostLevelSummary");
public static LevelValues Level;
private static bool _inshop;
private static bool _inlobby;
private static bool _inmenu;
public static bool InGame;
public static GameObject TextInstance;
public static TextMeshProUGUI ValueText;
internal static PostLevelSummary Instance { get; private set; }
public static bool InShop
{
get
{
return _inshop;
}
set
{
Logger.LogDebug((object)$"In shop: {value}");
if (value)
{
UI.Update();
}
TextInstance.SetActive(value || _inlobby);
_inshop = value;
}
}
public static bool InLobby
{
get
{
return _inlobby;
}
set
{
Logger.LogDebug((object)$"In lobby: {value}");
if (value)
{
ResetValues();
}
_inlobby = value;
}
}
public static bool InMenu
{
get
{
return _inmenu;
}
set
{
Logger.LogDebug((object)$"In menu: {value}");
if (value)
{
ResetValues();
}
_inmenu = value;
}
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Level = new LevelValues();
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
harmony.PatchAll(typeof(SceneManagerPatches));
harmony.PatchAll(typeof(ValuableObjectPatches));
harmony.PatchAll(typeof(LevelGeneratorPatches));
harmony.PatchAll(typeof(PhysGrabObjectImpactDetectorPatches));
harmony.PatchAll(typeof(RoundDirectorPatches));
harmony.PatchAll(typeof(ExtractionPointPatches));
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Unpatch()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
public static void ResetValues()
{
Level.Clear();
}
public static void AddValuable(ValuableObject val)
{
Level.AddValuable(val);
}
}
public static class UI
{
public static void Init()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0084: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Game Hud");
GameObject val2 = GameObject.Find("Tax Haul");
TMP_FontAsset font = val2.GetComponent<TMP_Text>().font;
PostLevelSummary.TextInstance = new GameObject();
PostLevelSummary.TextInstance.SetActive(false);
((Object)PostLevelSummary.TextInstance).name = "Summary HUD";
PostLevelSummary.TextInstance.AddComponent<TextMeshProUGUI>();
PostLevelSummary.ValueText = PostLevelSummary.TextInstance.GetComponent<TextMeshProUGUI>();
((TMP_Text)PostLevelSummary.ValueText).font = font;
((Graphic)PostLevelSummary.ValueText).color = Color.op_Implicit(new Vector4(0.7882f, 0.9137f, 0.902f, 1f));
((TMP_Text)PostLevelSummary.ValueText).fontSize = 20f;
((TMP_Text)PostLevelSummary.ValueText).enableWordWrapping = false;
((TMP_Text)PostLevelSummary.ValueText).alignment = (TextAlignmentOptions)2052;
((TMP_Text)PostLevelSummary.ValueText).horizontalAlignment = (HorizontalAlignmentOptions)4;
((TMP_Text)PostLevelSummary.ValueText).verticalAlignment = (VerticalAlignmentOptions)2048;
PostLevelSummary.TextInstance.transform.SetParent(val.transform, false);
RectTransform component = PostLevelSummary.TextInstance.GetComponent<RectTransform>();
component.pivot = new Vector2(1f, 1f);
component.anchoredPosition = new Vector2(1f, -1f);
component.anchorMin = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1f, 0f);
component.sizeDelta = new Vector2(0f, 0f);
component.offsetMax = new Vector2(0f, 225f);
component.offsetMin = new Vector2(0f, 225f);
PostLevelSummary.Logger.LogDebug((object)"HUD generated");
}
public static void Update()
{
//IL_0016: 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_0040: 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_006a: 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_0094: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = PostLevelSummary.TextInstance.GetComponent<RectTransform>();
component.pivot = new Vector2(1f, 1f);
component.anchoredPosition = new Vector2(1f, -1f);
component.anchorMin = new Vector2(0f, 0f);
component.anchorMax = new Vector2(1f, 0f);
component.sizeDelta = new Vector2(0f, 0f);
component.offsetMax = new Vector2(0f, 225f);
component.offsetMin = new Vector2(0f, 225f);
((TMP_Text)PostLevelSummary.ValueText).lineSpacing = -50f;
((TMP_Text)PostLevelSummary.ValueText).SetText(string.Format("\r\n Extracted ${0} out of ${1}\r\n {2} items out of {3}\r\n\r\n Lost ${4} in value\r\n {5} {6} broken ({7} hits)\r\n ", NumberFormatter.FormatToK(PostLevelSummary.Level.ExtractedValue), NumberFormatter.FormatToK(PostLevelSummary.Level.TotalValue), PostLevelSummary.Level.ExtractedItems, PostLevelSummary.Level.TotalItems, NumberFormatter.FormatToK(PostLevelSummary.Level.TotalValueLost), PostLevelSummary.Level.ItemsBroken, string.Format("item{0}", (PostLevelSummary.Level.ItemsBroken == 1) ? "" : "s"), PostLevelSummary.Level.ItemsHit), true);
}
}
}
namespace PostLevelSummary.Patches
{
[HarmonyPatch(typeof(ExtractionPoint))]
internal class ExtractionPointPatches
{
[HarmonyPatch("StateSet")]
[HarmonyPrefix]
public static void StateSetPrefix(State newState)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (PostLevelSummary.InGame)
{
StateChangedPrefix(newState);
}
}
[HarmonyPatch("StateSetRPC")]
[HarmonyPrefix]
public static void StateSetRPCPrefix(State state)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (PostLevelSummary.InGame)
{
StateChangedPrefix(state);
}
}
[HarmonyPatch("StateSet")]
[HarmonyPostfix]
public static void StateSetPostfix(State newState)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (PostLevelSummary.InGame)
{
StateChangedPostfix(newState);
}
}
[HarmonyPatch("StateSetRPC")]
[HarmonyPostfix]
public static void StateSetRPCPostfix(State state)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (PostLevelSummary.InGame)
{
StateChangedPostfix(state);
}
}
private static void StateChangedPrefix(State state)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
PostLevelSummary.Logger.LogDebug((object)$"New state: {state}");
if ((int)state == 6)
{
PostLevelSummary.Level.Extracting = true;
PostLevelSummary.Level.ExtractedChecksLeft = 20;
}
}
private static void StateChangedPostfix(State state)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
PostLevelSummary.Logger.LogDebug((object)$"New state: {state}");
if ((int)state == 7)
{
PostLevelSummary.Level.Extracting = false;
PostLevelSummary.Level.ExtractedChecksLeft = 20;
}
}
}
[HarmonyPatch(typeof(LevelGenerator))]
internal class LevelGeneratorPatches
{
public static LevelGenerator? Instance;
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void CaptureInstance(LevelGenerator __instance)
{
Instance = __instance;
PostLevelSummary.Logger.LogDebug((object)"Captured LevelGenerator instance.");
}
[HarmonyPatch("GenerateDone")]
[HarmonyPrefix]
public static void GenerateDonePrefix()
{
if (!((Object)(object)Instance == (Object)null))
{
PostLevelSummary.Logger.LogDebug((object)("Done generating new level: " + ((Object)Instance.Level).name + " (" + Instance.Level.NarrativeName + ")"));
if (((Object)Instance.Level).name.ToLower().Contains("menu"))
{
PostLevelSummary.InMenu = true;
}
else if (((Object)Instance.Level).name.ToLower().Contains("lobby"))
{
PostLevelSummary.InLobby = true;
}
else if (((Object)Instance.Level).name.ToLower().Contains("shop"))
{
PostLevelSummary.InShop = true;
}
else if (Instance.Level.HasEnemies && !PostLevelSummary.InGame)
{
PostLevelSummary.InGame = true;
}
if (!((Object)Instance.Level).name.ToLower().Contains("menu"))
{
PostLevelSummary.InMenu = false;
}
if (!((Object)Instance.Level).name.ToLower().Contains("lobby"))
{
PostLevelSummary.InLobby = false;
}
if (!((Object)Instance.Level).name.ToLower().Contains("shop"))
{
PostLevelSummary.InShop = false;
}
if (!Instance.Level.HasEnemies)
{
PostLevelSummary.InGame = false;
}
}
}
}
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
internal class PhysGrabObjectImpactDetectorPatches
{
}
[HarmonyPatch(typeof(MenuManager))]
internal class RoundDirectorPatches
{
[HarmonyPatch(typeof(MenuManager), "Awake")]
[HarmonyPostfix]
public static void Awake()
{
if ((Object)(object)PostLevelSummary.TextInstance == (Object)null)
{
UI.Init();
}
UI.Update();
}
}
[HarmonyPatch(typeof(RunManager))]
internal class SceneManagerPatches
{
[HarmonyPatch("ChangeLevel")]
[HarmonyPrefix]
public static void ChangeLevelPrefix()
{
PostLevelSummary.Level.StopTask();
}
[HarmonyPatch("UpdateLevel")]
[HarmonyPrefix]
public static void UpdateLevelPrefix()
{
PostLevelSummary.Level.StopTask();
}
}
[HarmonyPatch(typeof(ValuableObject))]
internal class ValuableObjectPatches
{
[HarmonyPatch("DollarValueSet")]
[HarmonyPostfix]
private static void DollarValueSetPostfix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.AddValuable(__instance);
}
}
[HarmonyPatch("AddToDollarHaulList")]
[HarmonyPostfix]
private static void AddToDollarHaulListPostix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.Logger.LogDebug((object)("Added to dollar haul list: " + ((Object)__instance).name));
AddToDollarHaulList(((Object)__instance).GetInstanceID());
}
}
[HarmonyPatch("AddToDollarHaulListRPC")]
[HarmonyPostfix]
private static void AddToDollarHaulListRPCPostix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.Logger.LogDebug((object)("[RPC] Added to dollar haul list: " + ((Object)__instance).name));
AddToDollarHaulList(((Object)__instance).GetInstanceID());
}
}
[HarmonyPatch("RemoveFromDollarHaulList")]
[HarmonyPostfix]
private static void RemoveFromDollarHaulListPostix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.Logger.LogDebug((object)("Removed from dollar haul list: " + ((Object)__instance).name));
RemoveFromDollarHaulList(((Object)__instance).GetInstanceID());
}
}
[HarmonyPatch("RemoveFromDollarHaulListRPC")]
[HarmonyPostfix]
private static void RemoveFromDollarHaulListRPCPostix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.Logger.LogDebug((object)("[RPC] Removed from dollar haul list: " + ((Object)__instance).name));
RemoveFromDollarHaulList(((Object)__instance).GetInstanceID());
}
}
private static void AddToDollarHaulList(int id)
{
if (!PostLevelSummary.Level.DollarHaulList.Contains(id))
{
PostLevelSummary.Level.DollarHaulList.Add(id);
}
}
private static void RemoveFromDollarHaulList(int id)
{
PostLevelSummary.Level.DollarHaulList.Remove(id);
}
}
}
namespace PostLevelSummary.Models
{
public class LevelValues
{
public int TotalItems;
public float TotalValue;
public List<ValuableValue> ValuableValues = new List<ValuableValue>();
public List<int> DollarHaulList = new List<int>();
public int ItemsHit;
public float TotalValueLost;
public int ItemsBroken;
public float ExtractedValue;
public int ExtractedItems;
public bool Extracting;
public int ExtractedChecksLeft;
private bool _run;
private readonly object _locker = new object();
private Task? running;
public void Clear()
{
PostLevelSummary.Logger.LogDebug((object)"Clearing level values!");
TotalItems = 0;
TotalValue = 0f;
ValuableValues.Clear();
DollarHaulList.Clear();
ItemsHit = 0;
TotalValueLost = 0f;
ItemsBroken = 0;
ExtractedValue = 0f;
ExtractedItems = 0;
Extracting = false;
ExtractedChecksLeft = 0;
}
public async Task AddValuable(ValuableObject val)
{
while (!val.dollarValueSet)
{
await Task.Delay(50);
}
TotalItems++;
TotalValue += val.dollarValueOriginal;
ValuableValues.Add(new ValuableValue
{
Object = val,
InstanceId = ((Object)val).GetInstanceID(),
Value = val.dollarValueOriginal
});
PostLevelSummary.Logger.LogDebug((object)$"Created Valuable Object! {((Object)val).name} Val: {val.dollarValueOriginal}");
runTask();
}
private void runTask()
{
lock (_locker)
{
if (running == null || running.Status == TaskStatus.Canceled || running.Status == TaskStatus.Faulted || running.Status == TaskStatus.RanToCompletion)
{
if (running != null)
{
PostLevelSummary.Logger.LogWarning((object)$"Lost track of our runner / checker: {running} ({running.Status})");
}
_run = true;
running = run();
}
}
}
public void StopTask()
{
_run = false;
}
private async Task run()
{
while (_run)
{
await Task.Delay(100);
if (!PostLevelSummary.InGame || PostLevelSummary.InShop || PostLevelSummary.InLobby)
{
continue;
}
List<int> toBeRemoved = new List<int>();
ValuableValues.ForEach(delegate(ValuableValue val)
{
if (!Object.op_Implicit((Object)(object)val.Object))
{
if (DollarHaulList.Contains(val.InstanceId) && (ExtractedChecksLeft > 0 || Extracting))
{
ExtractedValue += val.Value;
ExtractedItems++;
if (!Extracting)
{
ExtractedChecksLeft--;
}
}
else
{
ItemsHit++;
TotalValueLost += val.Value;
ItemsBroken++;
}
toBeRemoved.Add(val.InstanceId);
PostLevelSummary.Logger.LogDebug((object)"An item has been destroyed");
}
else if (val.Value != val.Object.dollarValueCurrent)
{
PostLevelSummary.Logger.LogDebug((object)$"{((Object)val.Object).name} ({((Object)val.Object).GetInstanceID()}) {UnityObjectUtility.IsDestroyed((Object)(object)val.Object)} {val.Object.dollarValueCurrent} {val.Object.dollarValueOriginal} {val.Value}");
float num = val.Value - val.Object.dollarValueCurrent;
ItemsHit++;
TotalValueLost += num;
val.Value -= num;
UI.Update();
}
});
if (toBeRemoved.Count > 0)
{
ValuableValues = ValuableValues.FindAll((ValuableValue v) => !toBeRemoved.Contains(v.InstanceId));
UI.Update();
}
}
}
}
public class ValuableValue
{
public ValuableObject Object { get; set; }
public int InstanceId { get; set; }
public float Value { get; set; }
}
}
namespace PostLevelSummary.Helpers
{
public static class NumberFormatter
{
public static string FormatToK(float value)
{
if (value >= 1000f)
{
return $"{value / 1000f:0.#}k";
}
return value.ToString("0");
}
}
}