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 Photon.Pun;
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: AssemblyCompany("QNCNXW8R")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d0d59f8b85e99fdf63a7645c43621de0dce46fb6")]
[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", "2.5.0")]
public class FindRemainingValuables : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <EnableHaulUIAfterDelay>d__35 : 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__35(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__31 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FindRemainingValuables <>4__this;
private ValuableObject[] <valuables>5__1;
private float <totalValue>5__2;
private RoundDirector <director>5__3;
private float <undiscoveredValue>5__4;
private float <currentHaul>5__5;
private int <goal>5__6;
private float <threshold>5__7;
private float <remainingValue>5__8;
private float <thresholdValue>5__9;
private int <totalPoints>5__10;
private int <completedPoints>5__11;
private float <goalPerPoint>5__12;
private List<GameObject>.Enumerator <>s__13;
private GameObject <pointObj>5__14;
private ExtractionPoint <point>5__15;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PeriodicValueCheck>d__31(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<valuables>5__1 = null;
<director>5__3 = null;
<>s__13 = default(List<GameObject>.Enumerator);
<pointObj>5__14 = null;
<point>5__15 = 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
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Invalid comparison between Unknown and I4
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<valuables>5__1 = Object.FindObjectsOfType<ValuableObject>();
<totalValue>5__2 = <valuables>5__1.Sum((ValuableObject v) => v.dollarValueCurrent);
<director>5__3 = Object.FindObjectOfType<RoundDirector>();
if ((Object)(object)<director>5__3 == (Object)null || !SemiFunc.RunIsLevel())
{
break;
}
<>4__this.isHostOrSingleplayer = !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient;
if (<>4__this.awaitingActiveExtraction && <director>5__3.extractionPointActive && (Object)(object)<director>5__3.extractionPointCurrent != (Object)null)
{
<>4__this.awaitingActiveExtraction = false;
<>4__this.AlertEnemies();
}
<undiscoveredValue>5__4 = <valuables>5__1.Where((ValuableObject v) => !v.discovered).Sum((ValuableObject v) => v.dollarValueCurrent);
<>4__this.previousRemainingValue = <undiscoveredValue>5__4;
if (<undiscoveredValue>5__4 == 0f && <>4__this.previousRemainingValue > 0f)
{
<>4__this.ForceReveal();
}
<currentHaul>5__5 = <director>5__3.currentHaul;
if (GoalType.Value == "LevelGoal")
{
<goal>5__6 = <director>5__3.haulGoal;
<totalPoints>5__10 = <director>5__3.extractionPoints;
<completedPoints>5__11 = <director>5__3.extractionPointsCompleted;
if (<totalPoints>5__10 > 0 && <director>5__3.extractionPointList != null)
{
<goalPerPoint>5__12 = (float)<director>5__3.haulGoal / (float)<totalPoints>5__10;
<>s__13 = <director>5__3.extractionPointList.GetEnumerator();
try
{
while (<>s__13.MoveNext())
{
<pointObj>5__14 = <>s__13.Current;
<point>5__15 = <pointObj>5__14.GetComponent<ExtractionPoint>();
if ((Object)(object)<point>5__15 != (Object)null && (int)<point>5__15.currentState == 7)
{
<currentHaul>5__5 += <goalPerPoint>5__12;
}
<point>5__15 = null;
<pointObj>5__14 = null;
}
}
finally
{
((IDisposable)<>s__13).Dispose();
}
<>s__13 = default(List<GameObject>.Enumerator);
}
}
else if (GoalType.Value == "ExtractionGoal")
{
<goal>5__6 = <director>5__3.extractionHaulGoal;
}
else if (GoalType.Value == "LevelLoot")
{
<goal>5__6 = (int)<totalValue>5__2;
}
else
{
<goal>5__6 = 1;
}
<threshold>5__7 = RevealThreshold.Value;
if (GoalType.Value == "Extractions")
{
<remainingValue>5__8 = <director>5__3.extractionPoints - <director>5__3.extractionPointsCompleted;
}
else if (TrackingMethod.Value == "Haul")
{
<remainingValue>5__8 = <totalValue>5__2 - <currentHaul>5__5;
}
else
{
<remainingValue>5__8 = <undiscoveredValue>5__4;
}
<thresholdValue>5__9 = (float)<goal>5__6 * <threshold>5__7;
if (<remainingValue>5__8 <= <thresholdValue>5__9 && <goal>5__6 > 0 && (<director>5__3.extractionPointActive || <director>5__3.extractionPointsCompleted > 0) && <>4__this.isHostOrSingleplayer)
{
<>4__this.ForceReveal();
<>4__this.previousRemainingValue = 0f;
}
if ((EnableLogging?.Value).Value)
{
Logger.LogInfo((object)$"Current Haul: {<currentHaul>5__5}, Goal: {<goal>5__6}");
Logger.LogInfo((object)$"Missing Value: {<remainingValue>5__8}, Threshold: {<thresholdValue>5__9}");
}
<valuables>5__1 = null;
<director>5__3 = 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 isHostOrSingleplayer = false;
private bool sceneReady = false;
private bool hasRevealedThisScene = false;
private float previousRemainingValue = -1f;
private bool awaitingActiveExtraction = false;
public static ConfigEntry<float>? RevealThreshold;
public static ConfigEntry<string>? TrackingMethod;
public static ConfigEntry<string>? GoalType;
public static ConfigEntry<bool>? NotificationSound;
public static ConfigEntry<bool>? EnemiesRespond;
public static ConfigEntry<string>? AlertDifficulty;
public static ConfigEntry<bool>? EnableHotkeys;
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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Expected O, but got Unknown
Instance = this;
RevealThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RevealThreshold", 0.1f, new ConfigDescription("Proportion of goal remaining before revealing all valuables: 0 is never, 1 is always in LevelLoot mode, 4 is probably always in other modes", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), Array.Empty<object>()));
TrackingMethod = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TrackingMethod", "Haul", new ConfigDescription("Method to track progress towards the threshold", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Haul", "Discovery" }), Array.Empty<object>()));
GoalType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GoalType", "LevelLoot", new ConfigDescription("Which goal to use when calculating reveal threshold: ExtractionGoal, LevelGoal, LevelLoot, Extractions", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[4] { "ExtractionGoal", "LevelGoal", "LevelLoot", "Extractions" }), Array.Empty<object>()));
NotificationSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Notification", "NotificationSound", true, "If true, enables the notification sound when the reveal is triggered");
EnemiesRespond = ((BaseUnityPlugin)this).Config.Bind<bool>("Notification", "EnemiesRespond", false, "If true, causes enemies to investigate when the reveal is triggered");
AlertDifficulty = ((BaseUnityPlugin)this).Config.Bind<string>("Notification", "AlertDifficulty", "Investigate", new ConfigDescription("How strongly enemies respond when valuables are revealed", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[5] { "Investigate", "Sweep", "Purge", "Annihilation", "Dynamic" }), Array.Empty<object>()));
EnableHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "EnableHotkeys", true, "If true, enables hotkeys");
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;
awaitingActiveExtraction = false;
}
internal void Update()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (!sceneReady || hasRevealedThisScene || !isHostOrSingleplayer || !EnableHotkeys.Value)
{
return;
}
KeyboardShortcut value = RevealKeybind.Value;
if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
{
value = RevealKeybind.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
Logger.LogInfo((object)"Force reveal triggered by keybind");
ForceReveal();
}
}
}
[IteratorStateMachine(typeof(<PeriodicValueCheck>d__31))]
private IEnumerator PeriodicValueCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PeriodicValueCheck>d__31(0)
{
<>4__this = this
};
}
internal void ForceReveal()
{
if (hasRevealedThisScene)
{
return;
}
hasRevealedThisScene = true;
ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
float num = array.Where((ValuableObject v) => !v.discovered).Sum((ValuableObject v) => v.dollarValueCurrent);
if (num == 0f)
{
num = previousRemainingValue;
}
ValuableObject[] array2 = array;
foreach (ValuableObject val in array2)
{
if (!val.discovered)
{
val.Discover((State)0);
}
}
if (NotificationSound.Value)
{
PlayNotificationSound();
}
ShowHaulMessage($"${Mathf.RoundToInt(num)} of Valuables Revealed!");
if (EnemiesRespond.Value)
{
AlertEnemies();
}
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_0065: 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__35))]
private IEnumerator EnableHaulUIAfterDelay(HaulUI ui, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnableHaulUIAfterDelay>d__35(0)
{
<>4__this = this,
ui = ui,
delay = delay
};
}
private void AlertEnemies()
{
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: 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)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
string text;
if (AlertDifficulty?.Value == "Dynamic")
{
string[] array = new string[5] { "None", "Investigate", "Sweep", "Purge", "Annihilation" };
text = array[SemiFunc.MoonLevel()];
}
else
{
text = AlertDifficulty?.Value;
}
if (text == "None")
{
Logger.LogInfo((object)"Moon Phase 0: Not alerting enemies");
return;
}
RoundDirector val = Object.FindObjectOfType<RoundDirector>();
if ((Object)(object)val == (Object)null)
{
Logger.LogWarning((object)"RoundDirector not found.");
return;
}
if (!val.extractionPointActive || (Object)(object)val.extractionPointCurrent == (Object)null)
{
Logger.LogInfo((object)"No active extraction point to alert enemies to. Awaiting activation");
awaitingActiveExtraction = true;
return;
}
EnemyDirector val2 = Object.FindObjectOfType<EnemyDirector>();
if ((Object)(object)val2 == (Object)null || val2.enemiesSpawned == null)
{
Logger.LogWarning((object)"EnemyDirector or enemiesSpawned list not found.");
return;
}
if (text == "Purge" || text == "Annihilation")
{
foreach (EnemyParent item in val2.enemiesSpawned)
{
if ((Object)(object)item != (Object)null && !item.Spawned)
{
item.Spawn();
if ((EnableLogging?.Value).Value)
{
Logger.LogInfo((object)("Respawned enemy: " + ((Object)item).name));
}
}
}
}
Transform transform = ((Component)val.extractionPointCurrent).transform;
Vector3 forward = transform.forward;
Vector3 right = transform.right;
Vector3 val3 = transform.position;
if (text != "Annihilation")
{
val3 += forward * 5f;
}
if (1 == 0)
{
}
float num = text switch
{
"Investigate" => 40f,
"Sweep" => 80f,
"Purge" => 200f,
"Annihilation" => 200f,
_ => 80f,
};
if (1 == 0)
{
}
float num2 = num;
bool flag = text == "Investigate";
val2.SetInvestigate(val3, num2, flag);
Logger.LogInfo((object)$"Alerted all enemies to investigate {val3}");
}
}
}