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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MapValueTracker.Config;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[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("MapValueTracker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+487376b9015d76a9cb2dcb327d3146692bcd3575")]
[assembly: AssemblyProduct("MapValueTracker")]
[assembly: AssemblyTitle("MapValueTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.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 MapValueTracker
{
[BepInPlugin("MapValueTracker", "MapValueTracker", "1.2.2")]
public class MapValueTracker : BaseUnityPlugin
{
public const string PLUGIN_GUID = "MapValueTracker";
public const string PLUGIN_NAME = "MapValueTracker";
public const string PLUGIN_VERSION = "1.2.2";
public static ManualLogSource Logger;
private readonly Harmony harmony = new Harmony("Tansinator.REPO.MapValueTracker");
public static MapValueTracker instance;
public static GameObject textInstance;
public static TextMeshProUGUI valueText;
public static float totalValue;
public static float totalValueInit;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin MapValueTracker is loaded!");
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
Configuration.Init(((BaseUnityPlugin)this).Config);
harmony.PatchAll();
}
public static void ResetValues()
{
if (!SemiFunc.RunIsLevel())
{
totalValue = 0f;
}
Logger.LogDebug((object)"In ResetValues()");
Logger.LogDebug((object)("Total Map Value: " + totalValue));
}
public static void CheckForItems(ValuableObject ignoreThis = null)
{
if (!Traverse.Create((object)RoundDirector.instance).Field("allExtractionPointsCompleted").GetValue<bool>())
{
totalValue = 0f;
List<ValuableObject> list = Object.FindObjectsOfType<ValuableObject>().ToList();
if ((Object)(object)ignoreThis != (Object)null)
{
list.Remove(ignoreThis);
}
for (int i = 0; i < list.Count; i++)
{
totalValue += list[i].dollarValueCurrent;
}
Logger.LogDebug((object)("After CheckForItems Total Val: " + totalValue));
}
}
}
public class MyOnDestroy : MonoBehaviour
{
private void OnDestroy()
{
MapValueTracker.Logger.LogDebug((object)"Destroying!");
ValuableObject component = ((Component)this).GetComponent<ValuableObject>();
MapValueTracker.Logger.LogDebug((object)("Destroyed Valuable Object! " + ((Object)component).name + " Val: " + component.dollarValueCurrent));
MapValueTracker.totalValue -= component.dollarValueCurrent;
MapValueTracker.Logger.LogDebug((object)("Total Val: " + MapValueTracker.totalValue));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MapValueTracker";
public const string PLUGIN_NAME = "MapValueTracker";
public const string PLUGIN_VERSION = "1.2.2";
}
}
namespace MapValueTracker.Patches
{
[HarmonyPatch(typeof(LevelGenerator))]
internal static class LevelGeneratorPatches
{
[HarmonyPatch("StartRoomGeneration")]
[HarmonyPrefix]
public static void StartRoomGeneration()
{
MapValueTracker.Logger.LogDebug((object)"Generating Started. Resetting to zero.");
MapValueTracker.ResetValues();
MapValueTracker.Logger.LogDebug((object)("Room generation started. Now val is " + MapValueTracker.totalValue));
}
[HarmonyPatch("GenerateDone")]
[HarmonyPrefix]
public static void GenerateDonePostfix()
{
MapValueTracker.Logger.LogDebug((object)"Generating Started. Resetting to zero.");
MapValueTracker.CheckForItems();
MapValueTracker.totalValueInit = MapValueTracker.totalValue;
MapValueTracker.Logger.LogDebug((object)("Generation done. Now val is " + MapValueTracker.totalValue + ". Init Value: " + MapValueTracker.totalValueInit));
}
}
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
public static class PhysGrabObjectImpactDetectorPatches
{
[HarmonyPatch("BreakRPC")]
[HarmonyPostfix]
private static void StartPostFix(float valueLost, PhysGrabObjectImpactDetector? __instance, bool _loseValue)
{
if (_loseValue)
{
MapValueTracker.Logger.LogDebug((object)("BreakRPC - Current Value: " + MapValueTracker.totalValue));
ValuableObject obj = ((__instance != null) ? ((Component)__instance).GetComponent<ValuableObject>() : null);
MapValueTracker.Logger.LogDebug((object)("BreakRPC - Valuable Object current value: " + obj?.dollarValueCurrent));
MapValueTracker.Logger.LogDebug((object)("BreakRPC - Value lost: " + valueLost));
MapValueTracker.totalValue -= valueLost;
MapValueTracker.Logger.LogDebug((object)("BreakRPC - After Break Value: " + MapValueTracker.totalValue));
}
}
[HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObjectRPC")]
[HarmonyPostfix]
public static void DestroyPhysGrabObjectPostfix(PhysGrabObject __instance)
{
if (!SemiFunc.RunIsLevel())
{
return;
}
ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
if (!((Object)(object)component == (Object)null))
{
MapValueTracker.Logger.LogDebug((object)"Destroying (DPGO)!");
MapValueTracker.Logger.LogDebug((object)("Destroyed Valuable Object! " + ((Object)component).name + " Val: " + component.dollarValueCurrent));
if (component.dollarValueCurrent < component.dollarValueOriginal * 0.15f)
{
MapValueTracker.totalValue -= 0f;
}
else
{
MapValueTracker.totalValue -= component.dollarValueCurrent;
}
MapValueTracker.Logger.LogDebug((object)("After DPGO Map Remaining Val: " + MapValueTracker.totalValue));
}
}
}
[HarmonyPatch(typeof(RoundDirector))]
public static class RoundDirectorPatches
{
[HarmonyPatch("ExtractionCompleted")]
[HarmonyPostfix]
public static void ExtractionComplete()
{
if (SemiFunc.RunIsLevel())
{
MapValueTracker.Logger.LogDebug((object)"Extraction Completed!");
MapValueTracker.CheckForItems();
MapValueTracker.Logger.LogDebug((object)("Checked after Extraction. Val is " + MapValueTracker.totalValue));
}
}
[HarmonyPatch(typeof(RoundDirector), "Update")]
[HarmonyPostfix]
public static void UpdateUI()
{
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
int? num = Traverse.Create((object)RoundDirector.instance).Field("extractionHaulGoal").GetValue<int>();
bool value = Traverse.Create((object)RoundDirector.instance).Field("extractionPointActive").GetValue<bool>();
bool value2 = Traverse.Create((object)RoundDirector.instance).Field("allExtractionPointsCompleted").GetValue<bool>();
if (!SemiFunc.RunIsLevel())
{
return;
}
if ((Object)(object)MapValueTracker.textInstance == (Object)null)
{
GameObject val = GameObject.Find("Game Hud");
GameObject val2 = GameObject.Find("Tax Haul");
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
TMP_FontAsset font = val2.GetComponent<TMP_Text>().font;
MapValueTracker.textInstance = new GameObject();
MapValueTracker.textInstance.SetActive(false);
((Object)MapValueTracker.textInstance).name = "Value HUD";
MapValueTracker.textInstance.AddComponent<TextMeshProUGUI>();
MapValueTracker.valueText = MapValueTracker.textInstance.GetComponent<TextMeshProUGUI>();
((TMP_Text)MapValueTracker.valueText).font = font;
((Graphic)MapValueTracker.valueText).color = Color.op_Implicit(new Vector4(0.7882f, 0.9137f, 0.902f, 1f));
((TMP_Text)MapValueTracker.valueText).fontSize = 24f;
((TMP_Text)MapValueTracker.valueText).enableWordWrapping = false;
((TMP_Text)MapValueTracker.valueText).alignment = (TextAlignmentOptions)2052;
((TMP_Text)MapValueTracker.valueText).horizontalAlignment = (HorizontalAlignmentOptions)4;
((TMP_Text)MapValueTracker.valueText).verticalAlignment = (VerticalAlignmentOptions)2048;
MapValueTracker.textInstance.transform.SetParent(val.transform, false);
RectTransform component = MapValueTracker.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);
}
}
else if ((Object)(object)MapValueTracker.valueText != (Object)null && ((num.HasValue && num != 0) || !value2))
{
bool value3 = Traverse.Create((object)MapToolController.instance).Field("mapToggled").GetValue<bool>();
RectTransform component2 = MapValueTracker.textInstance.GetComponent<RectTransform>();
component2.pivot = new Vector2(1f, 1f);
component2.anchoredPosition = new Vector2(1f, -1f);
component2.anchorMin = new Vector2(0f, 0f);
component2.anchorMax = new Vector2(1f, 0f);
component2.sizeDelta = new Vector2(0f, 0f);
component2.offsetMax = new Vector2(0f, 225f);
component2.offsetMin = new Vector2(0f, 225f);
if (Configuration.StartingValueOnly.Value)
{
((TMP_Text)MapValueTracker.valueText).SetText("Map: $" + MapValueTracker.totalValueInit.ToString("N0"), true);
}
else
{
((TMP_Text)MapValueTracker.valueText).SetText("Map: $" + MapValueTracker.totalValue.ToString("N0"), true);
}
if (Configuration.AlwaysOn.Value)
{
MapValueTracker.textInstance.SetActive(true);
}
else if (Configuration.UseValueRatio.Value)
{
if (MapValueTracker.totalValue / (float)num.Value <= Configuration.ValueRatio.Value)
{
MapValueTracker.textInstance.SetActive(true);
}
else
{
MapValueTracker.textInstance.SetActive(false);
}
}
else if (SemiFunc.InputHold((InputKey)8) || value3)
{
MapValueTracker.textInstance.SetActive(true);
}
else
{
MapValueTracker.textInstance.SetActive(false);
}
}
else
{
MapValueTracker.textInstance.SetActive(false);
}
}
}
[HarmonyPatch(typeof(ValuableObject))]
internal static class ValuableObjectPatches
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start(ValuableObject __instance)
{
}
[HarmonyPatch("DollarValueSetRPC")]
[HarmonyPostfix]
private static void DollarValueSet(ValuableObject __instance, float value)
{
MapValueTracker.Logger.LogDebug((object)("Created Valuable Object! " + ((Object)__instance).name + " Val: " + value));
MapValueTracker.totalValue += value;
MapValueTracker.Logger.LogDebug((object)("After dollar value set Total Val: " + MapValueTracker.totalValue));
}
[HarmonyPatch("DollarValueSetLogic")]
[HarmonyPostfix]
private static void DollarValueSetLogic(ValuableObject __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
MapValueTracker.Logger.LogDebug((object)("Created Valuable Object! " + ((Object)__instance).name + " Val: " + __instance.dollarValueCurrent));
MapValueTracker.totalValue += __instance.dollarValueCurrent;
MapValueTracker.Logger.LogDebug((object)("After dollar value set Total Val: " + MapValueTracker.totalValue));
}
}
}
}
namespace MapValueTracker.Config
{
internal class Configuration
{
public static ConfigEntry<bool> AlwaysOn;
public static ConfigEntry<bool> StartingValueOnly;
public static ConfigEntry<bool> UseValueRatio;
public static ConfigEntry<float> ValueRatio;
public static void Init(ConfigFile config)
{
config.SaveOnConfigSet = false;
AlwaysOn = config.Bind<bool>("Default", "AlwaysOn", true, "Toggle to always display map value when an extraction goal is active. If false, use the menu key to pull up the tracker (Tab by default).");
StartingValueOnly = config.Bind<bool>("Default", "StartingValueOnly", false, "Toggle to keep the Map Value fixed to the level's initially generated value. Will not update value in real time from breaking items, killing enemies, or extracting loot. Should not be used with UseValueRatio set to true.");
UseValueRatio = config.Bind<bool>("Default", "UseValueRatio", false, "Toggle to use value ratio to display Map Valuables. AlwaysOn must be false and this must be true to take effect.");
ValueRatio = config.Bind<float>("Default", "ValueRatio", 2f, "Ratio of Map Value to Extraction Goal. UseValueRatio must be true to take effect. Ex: 20k map value to 10k goal is 2.0 ");
ClearOrphanedEntries(config);
config.Save();
config.SaveOnConfigSet = true;
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}