using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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+ffc9bb2936afd626e06fa2cfe94cc0ab2be59343")]
[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 = new LevelValues();
private static bool _ingame = false;
private static bool _inshop = false;
public static bool InMenu = false;
public static GameObject TextInstance;
public static TextMeshProUGUI ValueText;
internal static PostLevelSummary Instance { get; private set; } = null;
public static bool InGame
{
get
{
return _ingame;
}
set
{
if (value)
{
ResetValues();
}
_ingame = value;
}
}
public static bool InShop
{
get
{
return _inshop;
}
set
{
Logger.LogDebug((object)$"In shop: {value}");
if (value)
{
UI.Update();
TextInstance.SetActive(true);
}
else
{
TextInstance.SetActive(false);
}
_inshop = value;
}
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
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("StateComplete")]
[HarmonyPostfix]
public static void StateCompletePostfix()
{
if (PostLevelSummary.InGame)
{
PostLevelSummary.Level.Extracted();
}
}
}
[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("StartRoomGeneration")]
[HarmonyPrefix]
public static void StartRoomGenerationPrefix()
{
if (!((Object)(object)Instance == (Object)null))
{
PostLevelSummary.Logger.LogDebug((object)("Generating new level: " + ((Object)Instance.Level).name));
if (Instance.Level.NarrativeName == "Main Menu")
{
PostLevelSummary.InMenu = true;
}
else
{
PostLevelSummary.InMenu = false;
}
if (Instance.Level.HasEnemies)
{
PostLevelSummary.InGame = true;
}
else
{
PostLevelSummary.InGame = false;
}
if (((Object)Instance.Level).name.ToLower().Contains("shop"))
{
PostLevelSummary.InShop = true;
}
else
{
PostLevelSummary.InShop = false;
}
}
}
[HarmonyPatch("GenerateDone")]
[HarmonyPostfix]
public static void GenerateDonePostfix()
{
PostLevelSummary.Logger.LogDebug((object)"Done generating new level");
PostLevelSummary.Logger.LogDebug((object)$"Total value: {PostLevelSummary.Level.TotalValue}");
}
}
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
internal class PhysGrabObjectImpactDetectorPatches
{
[HarmonyPatch("BreakRPC")]
[HarmonyPostfix]
private static void StartPostFix(PhysGrabObjectImpactDetector? __instance)
{
ValuableObject val = ((__instance != null) ? ((Component)__instance).GetComponent<ValuableObject>() : null);
if (!((Object)(object)val == (Object)null))
{
PostLevelSummary.Level.CheckValueChange(val);
}
}
[HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObjectRPC")]
[HarmonyPrefix]
public static void DestroyPhysGrabObjectPrefix(PhysGrabObject __instance)
{
if (PostLevelSummary.InGame)
{
ValuableObject val = ((__instance != null) ? ((Component)__instance).GetComponent<ValuableObject>() : null);
if (!((Object)(object)val == (Object)null))
{
PostLevelSummary.Level.ItemBroken(val);
}
}
}
}
[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(ValuableObject))]
internal class ValuableObjectPatches
{
[HarmonyPatch("DollarValueSetLogic")]
[HarmonyPostfix]
private static void DollarValueSetLogicPostfix(ValuableObject __instance)
{
if (!((Object)__instance).name.ToLower().Contains("surplus"))
{
PostLevelSummary.AddValuable(__instance);
}
}
}
}
namespace PostLevelSummary.Models
{
public class LevelValues
{
public int TotalItems;
public float TotalValue;
public List<ValuableObject> Valuables = new List<ValuableObject>();
public List<ValuableValue> ValuableValues = new List<ValuableValue>();
public int ItemsHit;
public float TotalValueLost;
public int ItemsBroken;
public float ExtractedValue;
public int ExtractedItems;
public int ItemCount => Valuables.Count;
public void Clear()
{
PostLevelSummary.Logger.LogDebug((object)"Clearing level values!");
TotalItems = 0;
TotalValue = 0f;
Valuables.Clear();
ValuableValues.Clear();
ItemsHit = 0;
TotalValueLost = 0f;
ItemsBroken = 0;
}
public void AddValuable(ValuableObject val)
{
TotalItems++;
TotalValue += val.dollarValueOriginal;
Valuables.Add(val);
ValuableValues.Add(new ValuableValue
{
InstanceId = ((Object)val).GetInstanceID(),
Value = val.dollarValueOriginal
});
PostLevelSummary.Logger.LogDebug((object)$"Created Valuable Object! {((Object)val).name} Val: {val.dollarValueOriginal}");
}
public void CheckValueChange(ValuableObject val)
{
ValuableObject val2 = val;
ValuableValue valuableValue = ValuableValues.Find((ValuableValue v) => v.InstanceId == ((Object)val2).GetInstanceID());
if (valuableValue.Value != val2.dollarValueCurrent)
{
float num = valuableValue.Value - val2.dollarValueCurrent;
PostLevelSummary.Logger.LogDebug((object)$"{((Object)val2).name} lost {num} value!");
ItemsHit++;
TotalValueLost += num;
valuableValue.Value = val2.dollarValueCurrent;
}
}
public void ItemBroken(ValuableObject val)
{
ValuableObject val2 = val;
if (val2.dollarValueCurrent == 0f)
{
ValuableValue valuableValue = ValuableValues.Find((ValuableValue v) => v.InstanceId == ((Object)val2).GetInstanceID());
float num = valuableValue.Value - val2.dollarValueCurrent;
PostLevelSummary.Logger.LogDebug((object)("Broken " + ((Object)val2).name + "!"));
ItemsHit++;
TotalValueLost += num;
ItemsBroken++;
ValuableValues.Remove(valuableValue);
}
}
public void Extracted()
{
if (!Valuables.Any((ValuableObject v) => UnityObjectUtility.IsDestroyed((Object)(object)v)))
{
return;
}
IEnumerable<int> existing = from v in Valuables.FindAll((ValuableObject v) => ((Object)v).GetInstanceID() != 0)
select ((Object)v).GetInstanceID();
List<ValuableValue> list = ValuableValues.FindAll(delegate(ValuableValue v)
{
ValuableValue v3 = v;
return !existing.Any((int id) => id == v3.InstanceId);
});
ExtractedValue += list.Select((ValuableValue v) => v.Value).Sum();
ExtractedItems += list.Count;
Valuables.RemoveAll((ValuableObject v) => ((Object)v).GetInstanceID() == 0);
ValuableValues.RemoveAll(delegate(ValuableValue v)
{
ValuableValue v2 = v;
return !existing.Any((int id) => id == v2.InstanceId);
});
}
}
public class ValuableValue
{
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");
}
}
}