using System;
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 Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("starktron.OutOfLoot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+4293697463fb54ff2602e88e8aa3285eb50ad1c5")]
[assembly: AssemblyProduct("starktron.OutOfLoot")]
[assembly: AssemblyTitle("starktron.OutOfLoot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace OutOfLoot
{
[BepInPlugin("starktron.OutOfLoot", "starktron.OutOfLoot", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static bool Active;
private readonly Harmony _harmony = new Harmony("starktron.OutOfLoot");
public static ConfigEntry<float> ConfigAlertTime;
private void Awake()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Active = false;
_harmony.PatchAll();
ConfigAlertTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AlertTime", 5f, new ConfigDescription("How long to show the alert for (in seconds)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
Logger.LogInfo((object)"Plugin starktron.OutOfLoot is loaded!");
}
}
internal static class Extensions
{
public static int GetInternalHaulGoal(this RoundDirector roundDirector)
{
return (int)typeof(RoundDirector).GetField("haulGoal", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(roundDirector);
}
public static int GetInternalExtractionPoints(this RoundDirector roundDirector)
{
return (int)typeof(RoundDirector).GetField("extractionPoints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(roundDirector);
}
public static int GetInternalExtractionPointsCompleted(this RoundDirector roundDirector)
{
return (int)typeof(RoundDirector).GetField("extractionPointsCompleted", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(roundDirector);
}
}
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
public static class PhysGrabObjectImpactDetectorPatches
{
[HarmonyPatch("BreakRPC")]
[HarmonyPostfix]
public static void BreakRPCPostfix()
{
if (SemiFunc.RunIsLevel())
{
OnValuableObjectDamaged();
}
}
private static void OnValuableObjectDamaged()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
int internalHaulGoal = RoundDirector.instance.GetInternalHaulGoal();
int num = internalHaulGoal / RoundDirector.instance.GetInternalExtractionPoints();
int num2 = RoundDirector.instance.GetInternalExtractionPointsCompleted() * num;
if (GetLevelValuablesValue() + (float)num2 >= (float)internalHaulGoal || Plugin.Active)
{
Plugin.Logger.LogDebug((object)"Round is still completable or plugin is already active");
return;
}
Plugin.Active = true;
Plugin.Logger.LogInfo((object)"Out of loot!");
SemiFunc.UIBigMessage("RUN IS DOOMED (?)", "{!}", 25f, Color.red, Color.red);
SemiFunc.UIFocusText("Not enough loot to complete the level! Good luck!", Color.red, Color.red, Plugin.ConfigAlertTime.Value);
}
private static float GetLevelValuablesValue()
{
return Object.FindObjectsOfType<ValuableObject>().Aggregate(0f, (float sum, ValuableObject valuable) => sum + valuable.dollarValueCurrent);
}
}
[HarmonyPatch(typeof(RoundDirector))]
public static class RoundDirectorPatches
{
[HarmonyPatch("StartRoundLogic")]
[HarmonyPrefix]
public static void StartRoundLogicPrefix(int value)
{
Plugin.Active = false;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "starktron.OutOfLoot";
public const string PLUGIN_NAME = "starktron.OutOfLoot";
public const string PLUGIN_VERSION = "1.3.0";
}
}