using System;
using System.Collections;
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 Microsoft.CodeAnalysis;
using TMPro;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("QNCNXW8R")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+560b79dc77bf9296c585b6b835339d822c4f821a")]
[assembly: AssemblyProduct("FindRemainingValuables")]
[assembly: AssemblyTitle("FindRemainingValuables")]
[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 FindRemainingValuables
{
[BepInPlugin("QNCNXW8R.FindRemainingValuables", "FindRemainingValuables", "1.0")]
public class FindRemainingValuables : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <EnableHaulUIAfterDelay>d__27 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public HaulUI ui;
public float delay;
public FindRemainingValuables <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnableHaulUIAfterDelay>d__27(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Behaviour)ui).enabled = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PeriodicValueCheck>d__23 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FindRemainingValuables <>4__this;
private RoundDirector <director>5__1;
private float <currentHaul>5__2;
private int <goal>5__3;
private float <threshold>5__4;
private ValuableObject[] <valuables>5__5;
private float <totalValue>5__6;
private float <unhauledValue>5__7;
private float <thresholdValue>5__8;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PeriodicValueCheck>d__23(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<director>5__1 = null;
<valuables>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<director>5__1 = Object.FindObjectOfType<RoundDirector>();
if (!((Object)(object)<director>5__1 == (Object)null))
{
<currentHaul>5__2 = <director>5__1.currentHaul;
if (GoalType.Value == "Level")
{
<goal>5__3 = <director>5__1.haulGoal;
}
else
{
<goal>5__3 = <director>5__1.extractionHaulGoal;
}
<threshold>5__4 = RevealThreshold.Value;
<valuables>5__5 = Object.FindObjectsOfType<ValuableObject>();
<totalValue>5__6 = <valuables>5__5.Sum((ValuableObject v) => v.dollarValueCurrent);
<unhauledValue>5__7 = <totalValue>5__6 - <currentHaul>5__2;
<thresholdValue>5__8 = (float)<goal>5__3 * <threshold>5__4;
if (<unhauledValue>5__7 <= <thresholdValue>5__8 && <goal>5__3 > 0)
{
<>4__this.ForceReveal();
}
if ((EnableLogging?.Value).Value)
{
Logger.LogInfo((object)$"Current Haul: {<currentHaul>5__2}, Goal: {<goal>5__3}");
Logger.LogInfo((object)$"Unhauled Value: {<unhauledValue>5__7}, Threshold: {<thresholdValue>5__8}");
}
<director>5__1 = null;
<valuables>5__5 = null;
}
break;
}
<>2__current = (object)new WaitForSeconds(5f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private bool sceneReady = false;
private bool hasRevealedThisScene = false;
public static ConfigEntry<float>? RevealThreshold;
public static ConfigEntry<string>? GoalType;
public static ConfigEntry<KeyboardShortcut>? RevealKeybind;
public static ConfigEntry<bool>? EnableLogging;
internal static FindRemainingValuables Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
Instance = this;
RevealThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RevealThreshold", 0.5f, new ConfigDescription("Proportion of goal remaining before revealing all valuables: 0 is never, 4 is (probably) always", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), Array.Empty<object>()));
GoalType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GoalType", "Level", new ConfigDescription("Which goal to use when calculating reveal threshold: Extraction or Level", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Extraction", "Level" }), Array.Empty<object>()));
RevealKeybind = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "RevealKeybind", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), new ConfigDescription("Key to press to reveal all remaining valuables", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
EnableLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableLogging", false, "If true, prints debug data to console");
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
SceneManager.sceneLoaded += OnSceneLoaded;
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: 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_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
((MonoBehaviour)this).StartCoroutine(PeriodicValueCheck());
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
sceneReady = true;
hasRevealedThisScene = false;
}
internal void Update()
{
//IL_001d: 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)
if (sceneReady && !hasRevealedThisScene)
{
KeyboardShortcut value = RevealKeybind.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
Logger.LogInfo((object)"Force reveal triggered by keybind");
ForceReveal();
}
}
}
[IteratorStateMachine(typeof(<PeriodicValueCheck>d__23))]
private IEnumerator PeriodicValueCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PeriodicValueCheck>d__23(0)
{
<>4__this = this
};
}
internal void ForceReveal()
{
if (hasRevealedThisScene)
{
return;
}
hasRevealedThisScene = true;
ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
ValuableObject[] array2 = array;
foreach (ValuableObject val in array2)
{
if (!val.discovered)
{
val.Discover((State)0);
}
}
float num = array.Where((ValuableObject v) => !v.discovered).Sum((ValuableObject v) => v.dollarValueCurrent);
PlayNotificationSound();
ShowHaulMessage($"Valuables Revealed! ${Mathf.RoundToInt(num)} Left!");
Logger.LogInfo((object)"Revealed valuables.");
}
public void PlayNotificationSound()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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)
AudioClip val = ((IEnumerable<AudioClip>)Resources.FindObjectsOfTypeAll<AudioClip>()).FirstOrDefault((Func<AudioClip, bool>)((AudioClip c) => ((Object)c).name.Equals("valuable tracker target found")));
if ((Object)(object)val != (Object)null)
{
Vector3 val2 = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero);
Logger.LogInfo((object)("Playing Audio: " + ((Object)val).name));
AudioSource.PlayClipAtPoint(val, val2);
}
else
{
Logger.LogWarning((object)"AudioClip 'valuable tracker target found' not found.");
}
}
private void ShowHaulMessage(string message, float duration = 2f)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)HaulUI.instance == (Object)null)
{
Logger.LogWarning((object)"HaulUI.instance not found.");
return;
}
HaulUI instance = HaulUI.instance;
((Behaviour)instance).enabled = false;
object? value = AccessTools.Field(typeof(HaulUI), "Text").GetValue(instance);
TextMeshProUGUI val = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null);
if ((Object)(object)val != (Object)null)
{
((TMP_Text)val).text = message;
}
((SemiUI)instance).SemiUITextFlashColor(Color.yellow, duration);
((SemiUI)instance).SemiUISpringShakeY(2f, 4f, 1f);
((MonoBehaviour)instance).StartCoroutine(EnableHaulUIAfterDelay(instance, duration));
}
[IteratorStateMachine(typeof(<EnableHaulUIAfterDelay>d__27))]
private IEnumerator EnableHaulUIAfterDelay(HaulUI ui, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnableHaulUIAfterDelay>d__27(0)
{
<>4__this = this,
ui = ui,
delay = delay
};
}
}
}