using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;
[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("ScoutmasterMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScoutmasterMod")]
[assembly: AssemblyTitle("ScoutmasterMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
}
namespace ScoutmasterMod
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ScoutmasterMod";
public const string PLUGIN_NAME = "ScoutmasterMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace NadirScoutmasterPursuit
{
[HarmonyPatch(typeof(GlobalEvents), "TriggerSoulFreed")]
public static class SoulFreedPatch
{
public static bool SpawnedThisRun;
private static bool _spawnCoroutineRunning;
[HarmonyPostfix]
public static void Postfix(int phase)
{
if (phase != 0 || !PhotonNetwork.IsConnected || !PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient || SpawnedThisRun || _spawnCoroutineRunning)
{
return;
}
Scoutmaster val = default(Scoutmaster);
if (Scoutmaster.GetPrimaryScoutmaster(ref val) && (Object)(object)val != (Object)null)
{
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogWarning((object)"[NadirSpawner] Scoutmaster is already active in the game world. Skipping duplicate spawn.");
}
SpawnedThisRun = true;
return;
}
_spawnCoroutineRunning = true;
SpawnedThisRun = true;
ManualLogSource? log2 = NadirScoutmasterPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"[NadirSpawner] Soul freed in Nadir! Spawning ONE Scoutmaster...");
}
if ((Object)(object)NadirScoutmasterPlugin.Instance != (Object)null)
{
((MonoBehaviour)NadirScoutmasterPlugin.Instance).StartCoroutine(SpawnRoutine());
}
}
private static IEnumerator SpawnRoutine()
{
yield return (object)new WaitForSeconds(3.5f);
Scoutmaster existingSm = default(Scoutmaster);
if (Scoutmaster.GetPrimaryScoutmaster(ref existingSm) && (Object)(object)existingSm != (Object)null)
{
_spawnCoroutineRunning = false;
yield break;
}
Character closest = GetClosestLivingPlayer(Vector3.zero);
if ((Object)(object)closest == (Object)null)
{
_spawnCoroutineRunning = false;
yield break;
}
Vector3 spawnPos = FindSpawnPlatformNear(closest);
GameObject smObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", spawnPos, Quaternion.identity, (byte)0, (object[])null);
if ((Object)(object)smObj == (Object)null)
{
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogError((object)"[NadirSpawner] Failed to instantiate Character_Scoutmaster room object.");
}
_spawnCoroutineRunning = false;
yield break;
}
Character smChar = smObj.GetComponent<Character>();
if ((Object)(object)smChar != (Object)null && (Object)(object)smChar.data != (Object)null)
{
smChar.data.spawnPoint = smObj.transform;
}
_spawnCoroutineRunning = false;
ManualLogSource? log2 = NadirScoutmasterPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)"[NadirSpawner] Exactly ONE Scoutmaster successfully spawned on Nadir platform!");
}
}
public static Vector3 FindSpawnPlatformNear(Character anchor)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
Vector3 center = anchor.Center;
Vector3 val = anchor.data.lookDirection_Flat;
if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
{
val = -((Component)anchor).transform.forward;
}
val.y = 0f;
((Vector3)(ref val)).Normalize();
Vector3 val2 = center - val * 16f + Vector3.up * 10f;
RaycastHit val3 = HelperFunctions.LineCheck(val2, val2 + Vector3.down * 40f, (LayerType)1, 0f, (QueryTriggerInteraction)1);
if ((Object)(object)((RaycastHit)(ref val3)).transform != (Object)null)
{
return ((RaycastHit)(ref val3)).point + Vector3.up * 1.2f;
}
return center + Vector3.up * 2f;
}
public static Character? GetClosestLivingPlayer(Vector3 origin)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
Character val = null;
float num = float.MaxValue;
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null) && !allCharacter.isBot && !((Object)(object)allCharacter.data == (Object)null) && !allCharacter.data.dead && !allCharacter.data.fullyPassedOut)
{
float num2 = ((origin == Vector3.zero) ? 0f : Vector3.Distance(origin, allCharacter.Center));
if (num2 < num)
{
num = num2;
val = allCharacter;
}
}
}
return val ?? Character.localCharacter;
}
}
[HarmonyPatch(typeof(MapHandler), "InitializeMap")]
public static class MapInitResetPatch
{
[HarmonyPostfix]
public static void Postfix()
{
SoulFreedPatch.SpawnedThisRun = false;
}
}
[BepInPlugin("com.custom.peak.nadirscoutmaster", "Nadir Scoutmaster Pursuit", "2.0.0")]
public class NadirScoutmasterPlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.custom.peak.nadirscoutmaster";
public const string PluginName = "Nadir Scoutmaster Pursuit";
public const string PluginVersion = "2.0.0";
internal static ManualLogSource? Log;
internal static NadirScoutmasterPlugin? Instance;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
Harmony val = new Harmony("com.custom.peak.nadirscoutmaster");
val.PatchAll();
Log.LogInfo((object)"Nadir Scoutmaster Pursuit v2.0.0 (Host-Only) loaded successfully!");
}
}
[HarmonyPatch(typeof(Scoutmaster), "Start")]
public static class ScoutmasterInitPatch
{
[HarmonyPostfix]
public static void Postfix(Scoutmaster __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<NadirFloatingPlatformHunter>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<NadirFloatingPlatformHunter>();
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogInfo((object)"[NadirAI] Attached Nadir Navigator component to Scoutmaster.");
}
}
}
}
public static class ScoutmasterHelper
{
private static readonly MethodInfo? SetCurrentTargetMethod = typeof(Scoutmaster).GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo? TpCounterField = typeof(Scoutmaster).GetField("tpCounter", BindingFlags.Instance | BindingFlags.NonPublic);
public static void SetTarget(Scoutmaster scoutmaster, Character? target, float forceForTime)
{
SetCurrentTargetMethod?.Invoke(scoutmaster, new object[2] { target, forceForTime });
}
public static void ResetTpCounter(Scoutmaster scoutmaster)
{
TpCounterField?.SetValue(scoutmaster, 0f);
}
}
public class NadirFloatingPlatformHunter : MonoBehaviour
{
private enum HunterState
{
Chasing,
Resting
}
private Scoutmaster? _scoutmaster;
private Character? _character;
private HunterState _state = HunterState.Chasing;
private float _cycleTimer = 60f;
private float _stuckTimer = 0f;
private float _warpCooldown = 6f;
private Vector3 _lastPosition;
private const float CHASE_DURATION = 60f;
private const float REST_DURATION = 15f;
private static readonly float[] SearchRings = new float[4] { 14f, 18f, 22f, 26f };
private void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
_scoutmaster = ((Component)this).GetComponent<Scoutmaster>();
_character = ((Component)this).GetComponent<Character>();
_lastPosition = ((Component)this).transform.position;
if ((Object)(object)_scoutmaster != (Object)null)
{
AccessTools.Field(typeof(Scoutmaster), "maxAggroHeight")?.SetValue(_scoutmaster, 2000f);
}
}
private void Update()
{
if (PhotonNetwork.IsMasterClient && !((Object)(object)_scoutmaster == (Object)null) && !((Object)(object)_character == (Object)null) && IsActiveNadirHunt())
{
_cycleTimer -= Time.deltaTime;
_warpCooldown -= Time.deltaTime;
if (_state == HunterState.Chasing)
{
UpdateChasing();
}
else
{
UpdateResting();
}
}
}
private void UpdateChasing()
{
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_scoutmaster == (Object)null || (Object)(object)_character == (Object)null || (Object)(object)_character.data.grabJoint != (Object)null || _character.data.isReaching)
{
return;
}
if (_cycleTimer <= 0f)
{
_state = HunterState.Resting;
_cycleTimer = 15f;
ScoutmasterHelper.SetTarget(_scoutmaster, null, 0f);
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogInfo((object)"[NadirAI] 30s chase over. Scoutmaster resting for 30s...");
}
return;
}
Character currentTarget = _scoutmaster.currentTarget;
if ((Object)(object)currentTarget == (Object)null || currentTarget.data.dead || currentTarget.data.fullyPassedOut)
{
Character val = PickNextLivingTarget(currentTarget);
if ((Object)(object)val != (Object)null)
{
ScoutmasterHelper.SetTarget(_scoutmaster, val, _cycleTimer);
ManualLogSource? log2 = NadirScoutmasterPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[NadirAI] Target down. Chasing: " + val.characterName));
}
}
return;
}
if (_character.Center.y < currentTarget.Center.y - 35f)
{
WarpToPlatformSafely(currentTarget, "Fell into void");
return;
}
float num = Vector3.Distance(_character.Center, currentTarget.Center);
Vector3 val2 = new Vector3(((Component)this).transform.position.x - _lastPosition.x, 0f, ((Component)this).transform.position.z - _lastPosition.z);
float num2 = ((Vector3)(ref val2)).magnitude / Time.deltaTime;
_lastPosition = ((Component)this).transform.position;
if (num > 12f && num2 < 0.35f && !_character.data.isClimbing)
{
_stuckTimer += Time.deltaTime;
if (_stuckTimer >= 5.5f && _warpCooldown <= 0f)
{
_stuckTimer = 0f;
WarpToPlatformSafely(currentTarget, "Stuck across platform gap");
return;
}
}
else
{
_stuckTimer = Mathf.Max(0f, _stuckTimer - Time.deltaTime);
}
if (num > 80f && _warpCooldown <= 0f)
{
WarpToPlatformSafely(currentTarget, "Target far ahead");
}
}
private void UpdateResting()
{
if ((Object)(object)_scoutmaster == (Object)null || (Object)(object)_character == (Object)null)
{
return;
}
if ((Object)(object)_scoutmaster.currentTarget != (Object)null)
{
ScoutmasterHelper.SetTarget(_scoutmaster, null, 0f);
}
if (!(_cycleTimer <= 0f))
{
return;
}
_state = HunterState.Chasing;
_cycleTimer = 60f;
Character val = PickNextLivingTarget(null);
if ((Object)(object)val != (Object)null)
{
ScoutmasterHelper.SetTarget(_scoutmaster, val, 60f);
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[NadirAI] Rest period over! Beginning 30s hunt on: " + val.characterName));
}
}
}
private Character? PickNextLivingTarget(Character? previousTarget)
{
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_character == (Object)null)
{
return null;
}
List<Character> list = new List<Character>();
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null) && !allCharacter.isBot && !((Object)(object)allCharacter.data == (Object)null) && !allCharacter.data.dead && !allCharacter.data.fullyPassedOut)
{
list.Add(allCharacter);
}
}
if (list.Count == 0)
{
return null;
}
if (list.Count > 1 && (Object)(object)previousTarget != (Object)null)
{
list.Remove(previousTarget);
}
Character val = null;
float num = float.MaxValue;
foreach (Character item in list)
{
float num2 = Vector3.Distance(_character.Center, item.Center);
if (num2 < num)
{
num = num2;
val = item;
}
}
return val ?? Character.localCharacter;
}
private void WarpToPlatformSafely(Character target, string reason)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_scoutmaster == (Object)null) && !((Object)(object)_character == (Object)null) && !(_warpCooldown > 0f))
{
_warpCooldown = 12f;
Vector3 val = SampleStandablePlatform(target);
ManualLogSource? log = NadirScoutmasterPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[NadirAI] Warping Scoutmaster ({reason}) -> {val}");
}
((MonoBehaviourPun)_character).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, false });
((MonoBehaviourPun)_character).photonView.RPC("StopClimbingRpc", (RpcTarget)0, new object[1] { 0f });
ScoutmasterHelper.ResetTpCounter(_scoutmaster);
_scoutmaster.discovered = null;
}
}
private Vector3 SampleStandablePlatform(Character anchor)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0247: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
Vector3 center = anchor.Center;
Vector3 val = anchor.data.lookDirection_Flat;
if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
{
val = -((Component)anchor).transform.forward;
}
val.y = 0f;
((Vector3)(ref val)).Normalize();
Vector3 result = center - val * 16f + Vector3.up * 1f;
float num = float.MinValue;
for (int i = 0; i < SearchRings.Length; i++)
{
float num2 = SearchRings[i];
int num3 = 8;
for (int j = 0; j < num3; j++)
{
float num4 = 360f / (float)num3 * (float)j * (MathF.PI / 180f);
Vector3 val2 = new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * num2;
Vector3 val3 = center + val2 + Vector3.up * 12f;
RaycastHit val4 = HelperFunctions.LineCheck(val3, val3 + Vector3.down * 35f, (LayerType)1, 0f, (QueryTriggerInteraction)1);
if (!((Object)(object)((RaycastHit)(ref val4)).transform != (Object)null) || !(Vector3.Angle(((RaycastHit)(ref val4)).normal, Vector3.up) <= 50f))
{
continue;
}
float num5 = Vector2.Distance(new Vector2(((RaycastHit)(ref val4)).point.x, ((RaycastHit)(ref val4)).point.z), new Vector2(center.x, center.z));
if (num5 >= 12f)
{
Vector3 val5 = ((RaycastHit)(ref val4)).point - center;
Vector3 normalized = ((Vector3)(ref val5)).normalized;
float num6 = Vector3.Dot(normalized, -val) * 10f - Mathf.Abs(num5 - 16f);
if (num6 > num)
{
num = num6;
result = ((RaycastHit)(ref val4)).point + Vector3.up * 1f;
}
}
}
if (num > float.MinValue && i >= 1)
{
break;
}
}
return result;
}
public static bool IsActiveNadirHunt()
{
if ((Object)(object)Singleton<MapHandler>.Instance != (Object)null && Singleton<MapHandler>.Instance.inNadir)
{
return SoulFreedPatch.SpawnedThisRun;
}
return false;
}
}
[HarmonyPatch(typeof(Scoutmaster))]
public static class ScoutmasterNadirSafetyPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
public static bool CheckPreventSpawning(ref bool __result)
{
if (NadirFloatingPlatformHunter.IsActiveNadirHunt())
{
__result = false;
return false;
}
return true;
}
[HarmonyPatch("VerifyTarget")]
[HarmonyPrefix]
public static bool OverrideVerifyTarget(Scoutmaster __instance)
{
if (NadirFloatingPlatformHunter.IsActiveNadirHunt())
{
if ((Object)(object)__instance.currentTarget != (Object)null && (__instance.currentTarget.data.dead || __instance.currentTarget.data.fullyPassedOut))
{
ScoutmasterHelper.SetTarget(__instance, null, 0f);
}
return false;
}
return true;
}
[HarmonyPatch("EvasiveBehaviour")]
[HarmonyPrefix]
public static bool PreventEvasionInNadir(Scoutmaster __instance)
{
if (NadirFloatingPlatformHunter.IsActiveNadirHunt())
{
return false;
}
return true;
}
}
}