using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("VermisOppidum-C")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VermisOppidum-C")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5a7bfc68-5895-472f-8045-9116e3817c4b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VermisOppidum_C
{
[BepInPlugin("TheWhiteCode.VermisOppidum_C", "VermisOppidum Code", "0.2.0")]
public class VermisOppidumCodeBase : BaseUnityPlugin
{
private const string modGUID = "TheWhiteCode.VermisOppidum_C";
private const string modName = "VermisOppidum Code";
private const string modVersion = "0.2.0";
private readonly Harmony harmony = new Harmony("TheWhiteCode.VermisOppidum_C");
internal static VermisOppidumCodeBase instance;
internal ManualLogSource logSource = null;
private void Awake()
{
logSource = Logger.CreateLogSource("TheWhiteCode.VermisOppidum_C");
if ((Object)(object)instance != (Object)null)
{
logSource.LogFatal((object)"Trying to register VermisOppdiumCodeBase instance when there is already one present");
return;
}
instance = this;
harmony.PatchAll();
}
}
}
namespace VermisOppidum_C.Patches
{
[HarmonyPatch(typeof(SandWormAI))]
internal class WormAIPatch : SandWormAI
{
[HarmonyPatch("DoAIInterval")]
[HarmonyPrefix]
private static bool CustomAI(SandWormAI __instance)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
if (((Object)StartOfRound.Instance.currentLevel).name != "39 Vermis Oppidum")
{
return true;
}
if (((EnemyAI)__instance).moveTowardsDestination)
{
((EnemyAI)__instance).agent.SetDestination(((EnemyAI)__instance).destination);
}
((EnemyAI)__instance).SyncPositionToClients();
if (StartOfRound.Instance.livingPlayers == 0 || ((EnemyAI)__instance).isEnemyDead)
{
return false;
}
switch (((EnemyAI)__instance).currentBehaviourStateIndex)
{
default:
return false;
case 1:
if (__instance.roamMap.inProgress)
{
((EnemyAI)__instance).StopSearch(__instance.roamMap, true);
}
((EnemyAI)__instance).targetPlayer = ((EnemyAI)__instance).GetClosestPlayer(false, true, false);
if ((Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
{
((EnemyAI)__instance).SwitchToBehaviourState(0);
return false;
}
((EnemyAI)__instance).agent.speed = 10f;
((EnemyAI)__instance).SetMovingTowardsTargetPlayer(((EnemyAI)__instance).targetPlayer);
if (__instance.chaseTimer < 1.5f && Vector3.Distance(((Component)__instance).transform.position, ((Component)((EnemyAI)__instance).targetPlayer).transform.position) < 4f && Vector3.Distance(StartOfRound.Instance.shipInnerRoomBounds.ClosestPoint(((Component)__instance).transform.position), ((Component)__instance).transform.position) >= 9f && Random.Range(0, 100) < 17)
{
__instance.StartEmergeAnimation();
}
break;
case 0:
{
if (__instance.emerged || __instance.inEmergingState)
{
return false;
}
if (!__instance.roamMap.inProgress)
{
((EnemyAI)__instance).StartSearch(((Component)__instance).transform.position, __instance.roamMap);
}
((EnemyAI)__instance).agent.speed = 4f;
PlayerControllerB closestPlayer = ((EnemyAI)__instance).GetClosestPlayer(false, true, true);
if ((Object)(object)closestPlayer != (Object)null)
{
((EnemyAI)__instance).SetMovingTowardsTargetPlayer(closestPlayer);
((EnemyAI)__instance).SwitchToBehaviourState(1);
__instance.chaseTimer = 0f;
return false;
}
break;
}
}
return false;
}
}
}