using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 UnityEngine;
[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("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[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 REPOJP.AllExtractionPointOpen
{
[BepInPlugin("AllExtractionPointOpen", "AllExtractionPointOpen", "1.0.0")]
public sealed class AllExtractionPointOpenPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(RoundDirector), "ExtractionPointsLock")]
private static class Patch_RoundDirector_ExtractionPointsLock
{
private static bool Prefix()
{
if (!IsEnabled())
{
return true;
}
return false;
}
}
[HarmonyPatch(typeof(RoundDirector), "ExtractionCompleted")]
private static class Patch_RoundDirector_ExtractionCompleted_CallAllCheck
{
private static void Postfix(RoundDirector __instance)
{
if (IsEnabled() && !((Object)(object)__instance == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer())
{
RdExtractionPointSurplus.Invoke(__instance) = 0;
__instance.ExtractionCompletedAllCheck();
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "HaulGoalSet")]
private static class Patch_ExtractionPoint_HaulGoalSet_SendScaled
{
private static void Prefix(ExtractionPoint __instance, ref int value)
{
if (!IsEnabled() || (Object)(object)__instance == (Object)null || EpIsShop.Invoke(__instance) || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
RoundDirector instance = RoundDirector.instance;
if (!((Object)(object)instance == (Object)null))
{
EnsureScaledGoal(instance);
if (GoalScaled && GoalScaledValue > 0)
{
value = GoalScaledValue;
}
RdExtractionPointSurplus.Invoke(instance) = 0;
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "StateSetRPC")]
private static class Patch_ExtractionPoint_StateSetRPC_ForceComplete
{
private static void Prefix(ExtractionPoint __instance, ref State state, PhotonMessageInfo _info)
{
if (IsEnabled() && !((Object)(object)__instance == (Object)null) && !EpIsShop.Invoke(__instance))
{
if ((int)state == 8)
{
state = (State)7;
}
if ((int)state == 9)
{
state = (State)7;
}
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "StateSurplus")]
private static class Patch_ExtractionPoint_StateSurplus_TaxReturnOff
{
private static void Prefix(ExtractionPoint __instance)
{
if (IsEnabled() && !((Object)(object)__instance == (Object)null) && !EpIsShop.Invoke(__instance))
{
EpTaxReturn.Invoke(__instance) = false;
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "StateTaxReturn")]
private static class Patch_ExtractionPoint_StateTaxReturn_SkipToComplete
{
private static bool Prefix(ExtractionPoint __instance)
{
if (!IsEnabled())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (EpIsShop.Invoke(__instance))
{
return true;
}
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
EpTaxReturn.Invoke(__instance) = false;
PhotonView val = EpPhotonView.Invoke(__instance);
if ((Object)(object)val != (Object)null && val.ViewID > 0)
{
val.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (object)(State)7 });
}
return false;
}
}
[HarmonyPatch(typeof(ExtractionPoint), "ExtractionPointSurplusRPC")]
private static class Patch_ExtractionPoint_ExtractionPointSurplusRPC_ForceZero
{
private static bool Prefix(ExtractionPoint __instance, ref int surplus, PhotonMessageInfo _info)
{
if (!IsEnabled())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (EpIsShop.Invoke(__instance))
{
return true;
}
surplus = 0;
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
return false;
}
}
[HarmonyPatch(typeof(ExtractionPoint), "SpawnTaxReturn")]
private static class Patch_ExtractionPoint_SpawnTaxReturn_Block
{
private static bool Prefix(ExtractionPoint __instance)
{
if (!IsEnabled())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (EpIsShop.Invoke(__instance))
{
return true;
}
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
return false;
}
}
[HarmonyPatch(typeof(ExtractionPoint), "HaulChecker")]
private static class Patch_ExtractionPoint_HaulChecker
{
private static void Postfix(ExtractionPoint __instance)
{
if (IsEnabled() && IsSkipCountdown() && !((Object)(object)__instance == (Object)null) && !EpIsShop.Invoke(__instance) && EpHaulGoalFetched.Invoke(__instance) && EpHaulGoal.Invoke(__instance) - EpHaulCurrent.Invoke(__instance) <= 0)
{
EpSuccessDelay.Invoke(__instance) = 0f;
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "StateExtracting")]
private static class Patch_ExtractionPoint_StateExtracting_SplitInit
{
private static void Postfix(ExtractionPoint __instance)
{
if (!IsEnabled() || !IsSimultaneousSuctionDestroy() || (Object)(object)__instance == (Object)null || EpIsShop.Invoke(__instance) || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
int extractionId = GetExtractionId(__instance);
if (EpTubeHit.Invoke(__instance) && !TubeHitInitializedIds.Contains(extractionId))
{
BuildHaulSnapshotIfNeeded();
if (!HaulQueueByExtractionId.TryGetValue(extractionId, out Queue<GameObject> value))
{
value = new Queue<GameObject>();
HaulQueueByExtractionId[extractionId] = value;
}
EpAmountOfValuables.Invoke(__instance) = value.Count;
float num = EpStateTimer.Invoke(__instance);
EpSuckUpTimeLeft.Invoke(__instance) = num;
if (value.Count > 0)
{
EpSuckUpVariableTimer.Invoke(__instance) = num / (float)value.Count;
}
else
{
EpSuckUpVariableTimer.Invoke(__instance) = float.PositiveInfinity;
}
TubeHitInitializedIds.Add(extractionId);
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "DestroyTheFirstPhysObjectsInHaulList")]
private static class Patch_ExtractionPoint_DestroyTheFirstPhysObjectsInHaulList
{
private static bool Prefix(ExtractionPoint __instance)
{
if (!IsEnabled() || !IsSimultaneousSuctionDestroy())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (EpIsShop.Invoke(__instance))
{
return true;
}
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return true;
}
BuildHaulSnapshotIfNeeded();
int extractionId = GetExtractionId(__instance);
if (!HaulQueueByExtractionId.TryGetValue(extractionId, out Queue<GameObject> value))
{
return false;
}
while (value.Count > 0 && (Object)(object)value.Peek() == (Object)null)
{
value.Dequeue();
}
if (value.Count == 0)
{
return false;
}
GameObject val = value.Dequeue();
if ((Object)(object)val == (Object)null)
{
return false;
}
PhysGrabObject component = val.GetComponent<PhysGrabObject>();
ValuableObject component2 = val.GetComponent<ValuableObject>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
RoundDirector.instance.dollarHaulList.Remove(val);
return false;
}
RoundDirector instance = RoundDirector.instance;
instance.totalHaul += (int)component2.dollarValueCurrent;
component.DestroyPhysGrabObject();
RoundDirector.instance.dollarHaulList.Remove(val);
return false;
}
}
[HarmonyPatch(typeof(ExtractionPoint), "DestroyAllPhysObjectsInHaulList")]
private static class Patch_ExtractionPoint_DestroyAllPhysObjectsInHaulList
{
private static bool Prefix(ExtractionPoint __instance)
{
if (!IsEnabled() || !IsSimultaneousSuctionDestroy())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (EpIsShop.Invoke(__instance))
{
return true;
}
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return true;
}
BuildHaulSnapshotIfNeeded();
int extractionId = GetExtractionId(__instance);
if (!HaulQueueByExtractionId.TryGetValue(extractionId, out Queue<GameObject> value))
{
return false;
}
while (value.Count > 0)
{
GameObject val = value.Dequeue();
if (!((Object)(object)val == (Object)null))
{
PhysGrabObject component = val.GetComponent<PhysGrabObject>();
ValuableObject component2 = val.GetComponent<ValuableObject>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
RoundDirector.instance.dollarHaulList.Remove(val);
continue;
}
RoundDirector instance = RoundDirector.instance;
instance.totalHaul += (int)component2.dollarValueCurrent;
component.DestroyPhysGrabObject();
RoundDirector.instance.dollarHaulList.Remove(val);
}
}
return false;
}
}
private struct CompletePayoutState
{
public bool modified;
public int oldHaulGoal;
public int oldHaulSurplus;
public int oldExtractionPointSurplus;
public bool oldTaxReturn;
}
[HarmonyPatch(typeof(ExtractionPoint), "StateComplete")]
private static class Patch_ExtractionPoint_StateComplete_BankAll_NoChangeBags
{
private static void Prefix(ExtractionPoint __instance, ref CompletePayoutState __state)
{
__state = default(CompletePayoutState);
if (!IsEnabled() || (Object)(object)__instance == (Object)null || EpIsShop.Invoke(__instance) || !SemiFunc.IsMasterClientOrSingleplayer() || !EpStateStart.Invoke(__instance))
{
return;
}
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
__state.modified = true;
__state.oldHaulGoal = EpHaulGoal.Invoke(__instance);
__state.oldHaulSurplus = EpHaulSurplus.Invoke(__instance);
__state.oldExtractionPointSurplus = RdExtractionPointSurplus.Invoke(instance);
__state.oldTaxReturn = EpTaxReturn.Invoke(__instance);
EpTaxReturn.Invoke(__instance) = false;
int num = Mathf.Max(0, __state.oldExtractionPointSurplus);
int num2 = EpHaulSurplus.Invoke(__instance);
if (num > num2)
{
EpHaulSurplus.Invoke(__instance) = num;
}
RdExtractionPointSurplus.Invoke(instance) = 0;
if (GoalScaled && GoalPoints > 0 && GoalOriginal > 0)
{
if (IsPayoutDriver(__instance))
{
EpHaulGoal.Invoke(__instance) = GoalOriginal;
}
else
{
EpHaulGoal.Invoke(__instance) = 0;
}
}
}
private static void Postfix(ExtractionPoint __instance, ref CompletePayoutState __state)
{
if (__state.modified && !((Object)(object)__instance == (Object)null))
{
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance != (Object)null)
{
RdExtractionPointSurplus.Invoke(instance) = 0;
}
EpHaulGoal.Invoke(__instance) = __state.oldHaulGoal;
EpHaulSurplus.Invoke(__instance) = __state.oldHaulSurplus;
EpTaxReturn.Invoke(__instance) = __state.oldTaxReturn;
}
}
}
[CompilerGenerated]
private sealed class <LevelWatchRoutine>d__54 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AllExtractionPointOpenPlugin <>4__this;
private float <waitSec>5__1;
private RoundDirector <rd>5__2;
private int <instanceId>5__3;
private Exception <e>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LevelWatchRoutine>d__54(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rd>5__2 = null;
<e>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
<waitSec>5__1 = 1f;
try
{
if (!IsConfigEnabled())
{
<waitSec>5__1 = 1f;
}
else if (!IsLevelSafe())
{
<>4__this._activatedForThisRound = false;
ResetRoundState();
<waitSec>5__1 = 1f;
}
else if (!SemiFunc.IsMasterClientOrSingleplayer())
{
<waitSec>5__1 = 0.5f;
}
else
{
<rd>5__2 = RoundDirector.instance;
<instanceId>5__3 = ((Object)<rd>5__2).GetInstanceID();
if (<instanceId>5__3 != <>4__this._lastRoundDirectorInstanceId)
{
<>4__this._lastRoundDirectorInstanceId = <instanceId>5__3;
<>4__this._activatedForThisRound = false;
ResetRoundState();
}
if (AutoArmRoundDirectorInstanceId != <instanceId>5__3)
{
AutoArmRoundDirectorInstanceId = <instanceId>5__3;
AutoArmed = false;
}
if (!AutoArmed)
{
if (CheckAutoArmReady(<rd>5__2))
{
AutoArmed = true;
<>4__this._activatedForThisRound = false;
<waitSec>5__1 = 0.2f;
}
else
{
<waitSec>5__1 = 0.2f;
}
}
else if (!<>4__this._activatedForThisRound)
{
<>4__this.ActivateAllExtractionPointsIfReady(<rd>5__2);
<>4__this._activatedForThisRound = true;
<waitSec>5__1 = 1f;
}
else
{
RdExtractionPointSurplus.Invoke(<rd>5__2) = 0;
<waitSec>5__1 = 1f;
}
<rd>5__2 = null;
}
}
catch (Exception ex)
{
<e>5__4 = ex;
Log.LogError((object)<e>5__4);
<waitSec>5__1 = 1f;
}
<>2__current = (object)new WaitForSeconds(<waitSec>5__1);
<>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();
}
}
public const string PluginGuid = "AllExtractionPointOpen";
public const string PluginName = "AllExtractionPointOpen";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Log;
private static Harmony _harmony;
internal static ConfigEntry<bool> CfgEnabled;
private static readonly FieldRef<RoundDirector, int> RdExtractionPoints = AccessTools.FieldRefAccess<RoundDirector, int>("extractionPoints");
private static readonly FieldRef<RoundDirector, List<GameObject>> RdExtractionPointList = AccessTools.FieldRefAccess<RoundDirector, List<GameObject>>("extractionPointList");
private static readonly FieldRef<RoundDirector, bool> RdExtractionPointActive = AccessTools.FieldRefAccess<RoundDirector, bool>("extractionPointActive");
private static readonly FieldRef<RoundDirector, ExtractionPoint> RdExtractionPointCurrent = AccessTools.FieldRefAccess<RoundDirector, ExtractionPoint>("extractionPointCurrent");
private static readonly FieldRef<RoundDirector, int> RdHaulGoal = AccessTools.FieldRefAccess<RoundDirector, int>("haulGoal");
private static readonly FieldRef<RoundDirector, int> RdExtractionPointSurplus = AccessTools.FieldRefAccess<RoundDirector, int>("extractionPointSurplus");
private static readonly FieldRef<ExtractionPoint, bool> EpIsShop = AccessTools.FieldRefAccess<ExtractionPoint, bool>("isShop");
private static readonly FieldRef<ExtractionPoint, bool> EpStateStart = AccessTools.FieldRefAccess<ExtractionPoint, bool>("stateStart");
private static readonly FieldRef<ExtractionPoint, int> EpHaulGoal = AccessTools.FieldRefAccess<ExtractionPoint, int>("haulGoal");
private static readonly FieldRef<ExtractionPoint, int> EpHaulSurplus = AccessTools.FieldRefAccess<ExtractionPoint, int>("haulSurplus");
private static readonly FieldRef<ExtractionPoint, bool> EpHaulGoalFetched = AccessTools.FieldRefAccess<ExtractionPoint, bool>("haulGoalFetched");
private static readonly FieldRef<ExtractionPoint, int> EpHaulCurrent = AccessTools.FieldRefAccess<ExtractionPoint, int>("haulCurrent");
private static readonly FieldRef<ExtractionPoint, float> EpSuccessDelay = AccessTools.FieldRefAccess<ExtractionPoint, float>("successDelay");
private static readonly FieldRef<ExtractionPoint, bool> EpTubeHit = AccessTools.FieldRefAccess<ExtractionPoint, bool>("tubeHit");
private static readonly FieldRef<ExtractionPoint, int> EpAmountOfValuables = AccessTools.FieldRefAccess<ExtractionPoint, int>("amountOfValuables");
private static readonly FieldRef<ExtractionPoint, float> EpSuckUpVariableTimer = AccessTools.FieldRefAccess<ExtractionPoint, float>("suckUpVariableTimer");
private static readonly FieldRef<ExtractionPoint, float> EpSuckUpTimeLeft = AccessTools.FieldRefAccess<ExtractionPoint, float>("suckUpTimeLeft");
private static readonly FieldRef<ExtractionPoint, float> EpStateTimer = AccessTools.FieldRefAccess<ExtractionPoint, float>("stateTimer");
private static readonly FieldRef<ExtractionPoint, bool> EpTaxReturn = AccessTools.FieldRefAccess<ExtractionPoint, bool>("taxReturn");
private static readonly FieldRef<ExtractionPoint, PhotonView> EpPhotonView = AccessTools.FieldRefAccess<ExtractionPoint, PhotonView>("photonView");
private int _lastRoundDirectorInstanceId = 0;
private bool _activatedForThisRound = false;
private static int AutoArmRoundDirectorInstanceId = 0;
private static bool AutoArmed = false;
private static int GoalRoundDirectorInstanceId = 0;
private static bool GoalScaled = false;
private static int GoalOriginal = 0;
private static int GoalScaledValue = 0;
private static int GoalPoints = 0;
private static readonly Dictionary<int, Queue<GameObject>> HaulQueueByExtractionId = new Dictionary<int, Queue<GameObject>>();
private static readonly HashSet<int> TubeHitInitializedIds = new HashSet<int>();
private static int SnapshotRoundDirectorInstanceId = 0;
private static bool SnapshotBuilt = false;
private static int PayoutDriverId = 0;
private static bool PayoutDriverReady = false;
private void Awake()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable plugin.プラグイン有効化");
_harmony = new Harmony("AllExtractionPointOpen");
_harmony.PatchAll(typeof(AllExtractionPointOpenPlugin));
((MonoBehaviour)this).StartCoroutine(LevelWatchRoutine());
}
private void OnDestroy()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
}
}
internal static bool IsConfigEnabled()
{
return CfgEnabled != null && CfgEnabled.Value;
}
internal static bool IsEnabled()
{
return IsConfigEnabled() && AutoArmed;
}
internal static bool IsSkipCountdown()
{
return true;
}
internal static bool IsSimultaneousSuctionDestroy()
{
return true;
}
private static bool IsLevelSafe()
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return false;
}
if ((Object)(object)LevelGenerator.Instance == (Object)null)
{
return false;
}
if (!LevelGenerator.Instance.Generated)
{
return false;
}
if (!PhotonNetwork.InRoom)
{
return false;
}
return true;
}
private static void ResetRoundState()
{
HaulQueueByExtractionId.Clear();
TubeHitInitializedIds.Clear();
SnapshotBuilt = false;
SnapshotRoundDirectorInstanceId = 0;
PayoutDriverId = 0;
PayoutDriverReady = false;
GoalRoundDirectorInstanceId = 0;
GoalScaled = false;
GoalOriginal = 0;
GoalScaledValue = 0;
GoalPoints = 0;
AutoArmRoundDirectorInstanceId = 0;
AutoArmed = false;
}
private static int GetExtractionId(ExtractionPoint ep)
{
if ((Object)(object)ep == (Object)null)
{
return 0;
}
PhotonView component = ((Component)ep).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null && component.ViewID > 0)
{
return component.ViewID;
}
return ((Object)((Component)ep).gameObject).GetInstanceID();
}
private static bool IsPayoutDriver(ExtractionPoint ep)
{
if (!PayoutDriverReady)
{
return true;
}
int extractionId = GetExtractionId(ep);
return extractionId == PayoutDriverId;
}
private static void EnsureScaledGoal(RoundDirector rd)
{
if ((Object)(object)rd == (Object)null)
{
return;
}
int instanceID = ((Object)rd).GetInstanceID();
if (GoalRoundDirectorInstanceId != instanceID)
{
GoalRoundDirectorInstanceId = instanceID;
GoalScaled = false;
GoalOriginal = 0;
GoalScaledValue = 0;
GoalPoints = 0;
}
if (GoalScaled)
{
return;
}
int num = RdExtractionPoints.Invoke(rd);
if (num <= 0)
{
return;
}
int num2 = RdHaulGoal.Invoke(rd);
if (num2 > 0)
{
long num3 = (long)num2 * (long)num;
if (num3 > int.MaxValue)
{
num3 = 2147483647L;
}
GoalOriginal = num2;
GoalScaledValue = (int)num3;
GoalPoints = num;
RdHaulGoal.Invoke(rd) = GoalScaledValue;
RdExtractionPointSurplus.Invoke(rd) = 0;
GoalScaled = true;
}
}
private static bool CheckAutoArmReady(RoundDirector rd)
{
if ((Object)(object)rd == (Object)null)
{
return false;
}
if (!RdExtractionPointActive.Invoke(rd))
{
return false;
}
ExtractionPoint val = RdExtractionPointCurrent.Invoke(rd);
if ((Object)(object)val == (Object)null)
{
return false;
}
if (EpIsShop.Invoke(val))
{
return false;
}
if (!EpHaulGoalFetched.Invoke(val))
{
return false;
}
if (EpHaulGoal.Invoke(val) <= 0)
{
return false;
}
PhotonView component = ((Component)val).GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null || component.ViewID <= 0)
{
return false;
}
return true;
}
private void ActivateAllExtractionPointsIfReady(RoundDirector rd)
{
if ((Object)(object)rd == (Object)null)
{
return;
}
int num = RdExtractionPoints.Invoke(rd);
List<GameObject> list = RdExtractionPointList.Invoke(rd);
if (num <= 0 || list == null || list.Count < num)
{
return;
}
EnsureScaledGoal(rd);
rd.ExtractionPointsUnlock();
int num2 = int.MaxValue;
ExtractionPoint val = null;
for (int i = 0; i < list.Count; i++)
{
GameObject val2 = list[i];
if ((Object)(object)val2 == (Object)null)
{
continue;
}
ExtractionPoint component = val2.GetComponent<ExtractionPoint>();
if (!((Object)(object)component == (Object)null) && !EpIsShop.Invoke(component))
{
if ((Object)(object)val == (Object)null)
{
val = component;
}
int extractionId = GetExtractionId(component);
if (extractionId > 0 && extractionId < num2)
{
num2 = extractionId;
}
}
}
if (num2 != int.MaxValue)
{
PayoutDriverId = num2;
PayoutDriverReady = true;
}
else
{
PayoutDriverId = 0;
PayoutDriverReady = false;
}
for (int j = 0; j < list.Count; j++)
{
GameObject val3 = list[j];
if ((Object)(object)val3 == (Object)null)
{
continue;
}
ExtractionPoint component2 = val3.GetComponent<ExtractionPoint>();
if (!((Object)(object)component2 == (Object)null) && !EpIsShop.Invoke(component2))
{
PhotonView component3 = val3.GetComponent<PhotonView>();
if ((Object)(object)component3 != (Object)null && component3.ViewID > 0)
{
component3.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (object)(State)2 });
}
}
}
RdExtractionPointActive.Invoke(rd) = true;
RdExtractionPointCurrent.Invoke(rd) = val;
RdExtractionPointSurplus.Invoke(rd) = 0;
}
[IteratorStateMachine(typeof(<LevelWatchRoutine>d__54))]
private IEnumerator LevelWatchRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LevelWatchRoutine>d__54(0)
{
<>4__this = this
};
}
private static void BuildHaulSnapshotIfNeeded()
{
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
if (!IsSimultaneousSuctionDestroy())
{
return;
}
RoundDirector instance = RoundDirector.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
int instanceID = ((Object)instance).GetInstanceID();
if (SnapshotBuilt && SnapshotRoundDirectorInstanceId == instanceID)
{
return;
}
SnapshotRoundDirectorInstanceId = instanceID;
SnapshotBuilt = true;
HaulQueueByExtractionId.Clear();
List<GameObject> list = RdExtractionPointList.Invoke(instance);
if (list == null)
{
return;
}
Dictionary<RoomVolume, int> dictionary = new Dictionary<RoomVolume, int>();
List<ExtractionPoint> list2 = new List<ExtractionPoint>();
List<int> list3 = new List<int>();
for (int i = 0; i < list.Count; i++)
{
GameObject val = list[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
ExtractionPoint component = val.GetComponent<ExtractionPoint>();
if ((Object)(object)component == (Object)null || EpIsShop.Invoke(component))
{
continue;
}
int extractionId = GetExtractionId(component);
RoomVolume val2 = null;
if ((Object)(object)component.roomVolume != (Object)null)
{
val2 = component.roomVolume.GetComponent<RoomVolume>();
if ((Object)(object)val2 == (Object)null)
{
val2 = component.roomVolume.GetComponentInChildren<RoomVolume>(true);
}
if ((Object)(object)val2 == (Object)null)
{
val2 = component.roomVolume.GetComponentInParent<RoomVolume>();
}
}
if ((Object)(object)val2 != (Object)null && val2.Extraction && !dictionary.ContainsKey(val2))
{
dictionary.Add(val2, extractionId);
}
if (!HaulQueueByExtractionId.ContainsKey(extractionId))
{
HaulQueueByExtractionId.Add(extractionId, new Queue<GameObject>());
}
list2.Add(component);
list3.Add(extractionId);
}
List<GameObject> dollarHaulList = instance.dollarHaulList;
for (int j = 0; j < dollarHaulList.Count; j++)
{
GameObject val3 = dollarHaulList[j];
if ((Object)(object)val3 == (Object)null)
{
continue;
}
ValuableObject component2 = val3.GetComponent<ValuableObject>();
if ((Object)(object)component2 == (Object)null || (Object)(object)component2.roomVolumeCheck == (Object)null)
{
continue;
}
component2.roomVolumeCheck.CheckSet();
RoomVolume val4 = null;
List<RoomVolume> currentRooms = component2.roomVolumeCheck.CurrentRooms;
if (currentRooms != null)
{
for (int k = 0; k < currentRooms.Count; k++)
{
RoomVolume val5 = currentRooms[k];
if ((Object)(object)val5 != (Object)null && val5.Extraction)
{
val4 = val5;
if (dictionary.ContainsKey(val5))
{
break;
}
}
}
}
int value = 0;
if ((Object)(object)val4 != (Object)null && dictionary.TryGetValue(val4, out value))
{
if (HaulQueueByExtractionId.TryGetValue(value, out Queue<GameObject> value2))
{
value2.Enqueue(val3);
}
continue;
}
float num = float.MaxValue;
int num2 = 0;
for (int l = 0; l < list2.Count; l++)
{
ExtractionPoint val6 = list2[l];
int num3 = list3[l];
if (!((Object)(object)val6 == (Object)null))
{
float num4 = Vector3.SqrMagnitude(((Component)val6).transform.position - val3.transform.position);
if (num4 < num)
{
num = num4;
num2 = num3;
}
}
}
if (num2 != 0 && HaulQueueByExtractionId.TryGetValue(num2, out Queue<GameObject> value3))
{
value3.Enqueue(val3);
}
}
}
}
}