using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using LethalMin;
using Microsoft.CodeAnalysis;
using NoteBoxz.WaterWraith.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using WaterWraithMod;
using WaterWraithMod.Patches;
using WaterWraithMod.Scripts;
[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("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NoteBoxz.WaterWraith")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.5.1.0")]
[assembly: AssemblyInformationalVersion("1.5.1+4334d35157d220d0ece393d659c844fc1f933408")]
[assembly: AssemblyProduct("WaterWraithMod")]
[assembly: AssemblyTitle("NoteBoxz.WaterWraith")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
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;
}
}
}
public class PlayAudioOnAnimEvent : MonoBehaviour
{
public AudioSource audioSource = null;
public AudioClip[] audioClips = null;
public void PlayAudio(int index)
{
if (audioClips.Length - 1 < index)
{
Debug.LogWarning((object)$"Audio clip index out of range: {index}");
}
else
{
audioSource.PlayOneShot(audioClips[index], audioSource.volume);
}
}
}
public class PlayRandomAudioOnAnimEvent : MonoBehaviour
{
public AudioSource audioSource = null;
public AudioClip[] audioClips = null;
public void PlayRandom()
{
audioSource.PlayOneShot(audioClips[Random.Range(0, audioClips.Length - 1)], audioSource.volume);
}
}
public enum GameStle
{
Pikmin4,
Pikmin2
}
[Serializable]
public class WaterWraithMeshOverride
{
public Animator Anim = null;
public GameObject Object = null;
public MeshRenderer[] meshRenderers = Array.Empty<MeshRenderer>();
public SkinnedMeshRenderer[] skinnedMeshRenderers = Array.Empty<SkinnedMeshRenderer>();
public AudioSource MoveAudioSource = null;
}
public class WaterWraithMesh : MonoBehaviour
{
public List<WaterWraithMeshOverride> overrides = new List<WaterWraithMeshOverride>();
public WaterWraithMeshOverride curoverride = null;
public WaterWraithAI AI = null;
private int IndexBuffering = -1;
public void SetOverride(int index)
{
if (((EnemyAI)AI).inSpecialAnimation)
{
IndexBuffering = index;
((MonoBehaviour)this).StartCoroutine(WaitToSwitchOverride());
}
else
{
if (((EnemyAI)AI).isEnemyDead)
{
return;
}
for (int i = 0; i < overrides.Count; i++)
{
WaterWraithMeshOverride waterWraithMeshOverride = overrides[i];
if (i == index)
{
waterWraithMeshOverride.Object.SetActive(true);
((EnemyAI)AI).meshRenderers = waterWraithMeshOverride.meshRenderers;
((EnemyAI)AI).skinnedMeshRenderers = waterWraithMeshOverride.skinnedMeshRenderers;
((EnemyAI)AI).creatureAnimator = waterWraithMeshOverride.Anim;
AI.moveAud = waterWraithMeshOverride.MoveAudioSource;
string[] array = new string[4] { "Moving", "HasLostRollers", "IsRunning", "IsScared" };
if (curoverride != null && (Object)(object)curoverride.Anim != (Object)null)
{
string[] array2 = array;
foreach (string text in array2)
{
try
{
global::WaterWraithMod.WaterWraithMod.Logger.LogInfo((object)$"Setting {text} to {curoverride.Anim.GetBool(text)}");
waterWraithMeshOverride.Anim.SetBool(text, curoverride.Anim.GetBool(text));
}
catch (Exception arg)
{
global::WaterWraithMod.WaterWraithMod.Logger.LogError((object)$"Failed to set {text} to {curoverride.Anim.GetBool(text)} due to: {arg}");
}
}
}
curoverride = waterWraithMeshOverride;
}
else
{
waterWraithMeshOverride.Object.SetActive(false);
}
}
}
}
private IEnumerator WaitToSwitchOverride()
{
global::WaterWraithMod.WaterWraithMod.Logger.LogInfo((object)$"Buffing switch {IndexBuffering}");
yield return (object)new WaitUntil((Func<bool>)(() => !((EnemyAI)AI).inSpecialAnimation));
for (int i = 0; i < overrides.Count; i++)
{
WaterWraithMeshOverride waterWraithMeshOverride = overrides[i];
if (i == IndexBuffering)
{
waterWraithMeshOverride.Object.SetActive(true);
((EnemyAI)AI).meshRenderers = waterWraithMeshOverride.meshRenderers;
((EnemyAI)AI).skinnedMeshRenderers = waterWraithMeshOverride.skinnedMeshRenderers;
((EnemyAI)AI).creatureAnimator = waterWraithMeshOverride.Anim;
AI.moveAud = waterWraithMeshOverride.MoveAudioSource;
}
else
{
waterWraithMeshOverride.Object.SetActive(false);
}
}
}
[ContextMenu("AutoFind")]
public void FindMeshes()
{
foreach (WaterWraithMeshOverride @override in overrides)
{
List<MeshRenderer> list = new List<MeshRenderer>();
MeshRenderer[] componentsInChildren = @override.Object.GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer item in componentsInChildren)
{
list.Add(item);
}
@override.meshRenderers = list.ToArray();
}
foreach (WaterWraithMeshOverride override2 in overrides)
{
List<SkinnedMeshRenderer> list2 = new List<SkinnedMeshRenderer>();
SkinnedMeshRenderer[] componentsInChildren2 = override2.Object.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer item2 in componentsInChildren2)
{
list2.Add(item2);
}
override2.skinnedMeshRenderers = list2.ToArray();
}
}
}
[Serializable]
public class WraithProximityAnimEvent
{
public bool CamShake;
public ScreenShakeType screenShakeTypeNear;
public float DistanceThresholdDistanceNear = 10f;
public ScreenShakeType screenShakeTypeFar;
public float DistanceThresholdDistanceFar = 20f;
public float FearFactor = -1f;
}
public class WraithProximityAnimEventChecks : MonoBehaviour
{
public List<WraithProximityAnimEvent> animEvents = new List<WraithProximityAnimEvent>();
public void DoCheck(int index)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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)
WraithProximityAnimEvent wraithProximityAnimEvent = animEvents[index];
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
if (wraithProximityAnimEvent.CamShake)
{
if (Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < wraithProximityAnimEvent.DistanceThresholdDistanceNear)
{
HUDManager.Instance.ShakeCamera(wraithProximityAnimEvent.screenShakeTypeNear);
}
else if (Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < wraithProximityAnimEvent.DistanceThresholdDistanceFar)
{
HUDManager.Instance.ShakeCamera(wraithProximityAnimEvent.screenShakeTypeFar);
}
}
if (wraithProximityAnimEvent.FearFactor > 0f && Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < wraithProximityAnimEvent.DistanceThresholdDistanceFar)
{
localPlayerController.JumpToFearLevel(wraithProximityAnimEvent.FearFactor, true);
}
}
}
namespace WaterWraithMod
{
[BepInPlugin("NoteBoxz.WaterWraith", "WaterWraithMod", "1.5.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class WaterWraithMod : BaseUnityPlugin
{
public static ConfigEntry<float> SpawnChanceConfig = null;
public static ConfigEntry<float> SpawnTimerConfig = null;
public static ConfigEntry<bool> ChaseEnemyConfig = null;
public static ConfigEntry<int> DamageConfig = null;
public static ConfigEntry<int> EDamageConfig = null;
public static ConfigEntry<string> PerMoonSpawnChanceConfig = null;
public static ConfigEntry<float> PlayerCollisionBufferMultiplier = null;
public static ConfigEntry<WraithSpawnPosition> WraithSpawnPositionConfig = null;
public static ConfigEntry<GameStle> gameStleConfig = null;
public static List<Type> LibraryTypes = new List<Type>();
public static WaterWraithMod Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
internal static AssetBundle assetBundle { get; private set; } = null;
public static Dictionary<string, float> GetParsedMoonSpawn()
{
Dictionary<string, float> dictionary = new Dictionary<string, float>();
if (string.IsNullOrEmpty(PerMoonSpawnChanceConfig.Value))
{
return new Dictionary<string, float>();
}
foreach (string item in PerMoonSpawnChanceConfig.Value.Split(',').ToList())
{
if (string.IsNullOrEmpty(item))
{
Logger.LogWarning((object)"Empty item found in PerMoonSpawnChanceConfig. please do not have empty items in your config.");
continue;
}
string[] array = item.Split(':');
if (float.TryParse(array[1], out var result))
{
dictionary.Add(array[0], result);
}
else
{
Logger.LogWarning((object)("Failed to parse (" + item + ")!"));
}
}
return dictionary;
}
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
NetcodePatcher();
Patch();
BindConfigs();
LoadAssetBundle();
RegisterRockAssets();
Logger.LogInfo((object)"NoteBoxz.WaterWraith v1.5.1 has loaded!");
}
public void BindConfigs()
{
SpawnChanceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("WaterWraith", "Spawn Chance", 25f, "The chance for a Water Wraith to spawn. (0-100)");
PerMoonSpawnChanceConfig = ((BaseUnityPlugin)this).Config.Bind<string>("WaterWraith", "Per-Moon Spawn Chance", "7510 Zeranos:0,61 March:35", "The chance for a Water Wraith to spawn per moon these values will override the base spawn chance when spawning on a moon in the list. (Formatted just like Lethal Level Loader's configs) (sperate with commas no spaces inbetween sperate moonnames and spawn chances with colons) (moonname1:25,moonname2:35,moonname3:55...) (0-100)");
ChaseEnemyConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("WaterWraith", "Chase Enemys", true, "Makes the water wraith chase enemies as well as players.");
WraithSpawnPositionConfig = ((BaseUnityPlugin)this).Config.Bind<WraithSpawnPosition>("WaterWraith", "Wraith Spawn Position", WraithSpawnPosition.OnlyIndoors, "The position where the Water Wraith will spawn.");
SpawnTimerConfig = ((BaseUnityPlugin)this).Config.Bind<float>("WaterWraith", "Spawn Timer (Seconds)", 300f, "The amount of time it takes for the wraith to spawn.");
DamageConfig = ((BaseUnityPlugin)this).Config.Bind<int>("WaterWraith", "Damage", 50, "The ammount of damage the water wraith deals.(0-100)");
PlayerCollisionBufferMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("WaterWraith", "Collision Buffer", 1f, "Multiplies the timer that is used to buffer damage players, higher values = instant death");
EDamageConfig = ((BaseUnityPlugin)this).Config.Bind<int>("WaterWraith", "Enemy Damage", 1, "The ammount of damage the water wraith deals to Enemies. Recomended: (0-2)");
gameStleConfig = ((BaseUnityPlugin)this).Config.Bind<GameStle>("WaterWraith", "Game Stle", GameStle.Pikmin4, "The game stle of the water wraith.");
gameStleConfig.SettingChanged += delegate
{
UpdateAllOverrides();
};
}
public void UpdateAllOverrides()
{
try
{
WaterWraithMesh[] array = Object.FindObjectsOfType<WaterWraithMesh>();
foreach (WaterWraithMesh waterWraithMesh in array)
{
waterWraithMesh.SetOverride((int)gameStleConfig.Value);
}
}
catch (Exception ex)
{
Logger.LogError((object)("Error updating overrides: " + ex.Message));
}
}
internal static void LoadAssetBundle()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (directoryName == null)
{
throw new InvalidOperationException("Unable to determine assembly location.");
}
string text = Path.Combine(directoryName, "wraithassets");
assetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)assetBundle == (Object)null)
{
throw new InvalidOperationException("Failed to load AssetBundle.");
}
}
internal static void RegisterRockAssets()
{
EnemyType val = assetBundle.LoadAsset<EnemyType>("Assets/ModAsset/WaterType.asset");
TerminalNode val2 = assetBundle.LoadAsset<TerminalNode>("Assets/ModAsset/WaterNode.asset");
Enemies.RegisterEnemy(val, 0, (LevelTypes)(-1), val2, (TerminalKeyword)null);
}
public static bool IsDependencyLoaded(string pluginGUID)
{
return Chainloader.PluginInfos.ContainsKey(pluginGUID);
}
private void NetcodePatcher()
{
Type[] typesWithErrorHandling = GetTypesWithErrorHandling();
Type[] array = typesWithErrorHandling;
foreach (Type type in array)
{
try
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
try
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
catch (Exception ex)
{
Logger.LogWarning((object)("Error invoking method " + methodInfo.Name + " in type " + type.FullName + ": " + ex.Message));
if (ex.InnerException != null)
{
Logger.LogWarning((object)("Inner exception: " + ex.InnerException.Message));
}
}
}
}
catch (Exception ex2)
{
Logger.LogWarning((object)("Error processing type " + type.FullName + ": " + ex2.Message));
}
}
Logger.LogInfo((object)"NetcodePatcher completed.");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("NoteBoxz.WaterWraith");
}
Logger.LogDebug((object)"Patching...");
try
{
Type[] typesWithErrorHandling = GetTypesWithErrorHandling();
Type[] array = typesWithErrorHandling;
foreach (Type type in array)
{
if (!IsDependencyLoaded("NoteBoxz.LethalMin") && type == typeof(PurplePikminPatch))
{
continue;
}
try
{
Harmony.PatchAll(type);
}
catch (Exception ex)
{
Logger.LogError((object)("Error patching type " + type.FullName + ": " + ex.Message));
if (ex.InnerException != null)
{
Logger.LogError((object)("Inner exception: " + ex.InnerException.Message));
}
}
}
if (IsDependencyLoaded("NoteBoxz.LethalMin"))
{
Logger.LogInfo((object)"LethalMin detected. Patching Purple Pikmin.");
}
}
catch (Exception ex2)
{
Logger.LogError((object)("Error during patching process: " + ex2.Message));
if (ex2.InnerException != null)
{
Logger.LogError((object)("Inner exception: " + ex2.InnerException.Message));
}
}
Logger.LogDebug((object)"Finished patching!");
}
private static Type[] GetTypesWithErrorHandling()
{
try
{
return Assembly.GetExecutingAssembly().GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
Logger.LogWarning((object)"ReflectionTypeLoadException caught while getting types. Some types will be skipped.");
Exception[] loaderExceptions = ex.LoaderExceptions;
foreach (Exception ex2 in loaderExceptions)
{
Logger.LogWarning((object)("Loader Exception: " + ex2.Message));
if (ex2 is FileNotFoundException ex3)
{
Logger.LogWarning((object)("Could not load file: " + ex3.FileName));
}
}
return ex.Types.Where((Type t) => t != null).ToArray();
}
catch (Exception ex4)
{
Logger.LogError((object)("Unexpected error while getting types: " + ex4.Message));
return new Type[0];
}
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "NoteBoxz.WaterWraith";
public const string PLUGIN_NAME = "WaterWraithMod";
public const string PLUGIN_VERSION = "1.5.1";
}
}
namespace WaterWraithMod.Scripts
{
public class TireFragments : MonoBehaviour
{
public Rigidbody[] Fragments = Array.Empty<Rigidbody>();
public bool P2style = false;
public void Start()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (!P2style)
{
Fragments = ((Component)((Component)this).transform).GetComponentsInChildren<Rigidbody>();
Rigidbody[] fragments = Fragments;
foreach (Rigidbody val in fragments)
{
val.AddExplosionForce(15f, ((Component)this).transform.position, 7f);
}
}
((MonoBehaviour)this).StartCoroutine(RemoveFragments());
}
private IEnumerator RemoveFragments()
{
yield return (object)new WaitForSeconds(30f);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public class WaterWraithAI : EnemyAI
{
public AISearchRoutine roamFactory = null;
public EnemyAI TargetEnemy = null;
public List<EnemyAI> TargetedEnemies = null;
public WaterWraithMesh WMesh = null;
public AudioSource moveAud = null;
public AudioClip KillSFX = null;
public bool CanEnterState2 = false;
public bool IsChaseingEnemy = false;
public bool IsWandering = false;
public bool HasLostTires;
public Vector3 FleePos;
public NetworkVariable<bool> isVurable = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
public NetworkVariable<bool> isRunning = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private float timeSinceHitting;
private float timeInEnemyChase;
private float timeBeingScared;
public GameObject[] TireObjectsToDisable = Array.Empty<GameObject>();
public Collider[] ColidersToDisable = Array.Empty<Collider>();
private TireFragments[] TireObjectsToEnable = Array.Empty<TireFragments>();
public PlayerControllerB PlayerFleeingFrom = null;
public PlayerControllerB PlayerStunnedBy = null;
public AudioClip[] DethSounds = Array.Empty<AudioClip>();
public AudioClip[] HurtSounds = Array.Empty<AudioClip>();
private WraithTire[] Tires = Array.Empty<WraithTire>();
private Vector3 LastPosition;
private float LastPosCheck;
private bool lastIsScaredCheck;
public override void Start()
{
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
TireObjectsToEnable = ((Component)this).GetComponentsInChildren<TireFragments>(true);
Tires = ((Component)this).GetComponentsInChildren<WraithTire>(true);
WaterWraithMod.Logger.LogInfo((object)$"Tires: {Tires.Length}");
WaterWraithMod.Logger.LogInfo((object)$"DulyAbledTires: {TireObjectsToEnable.Length}");
WMesh.SetOverride((int)WaterWraithMod.gameStleConfig.Value);
base.creatureAnimator.SetTrigger("Spawn");
base.inSpecialAnimation = true;
moveAud.volume = 0f;
List<GameObject> list = new List<GameObject>();
GameObject[] collection = GameObject.FindGameObjectsWithTag("AINode");
GameObject[] collection2 = GameObject.FindGameObjectsWithTag("OutsideAINode");
list.AddRange(collection2);
list.AddRange(collection);
GameObject val = list.OrderBy((GameObject p) => Vector3.Distance(p.transform.position, ((Component)this).transform.position)).FirstOrDefault();
WaterWraithMod.Logger.LogInfo((object)("WaterWraith: Destemined " + ((Object)val).name + "(" + val.tag + ")" + $" is the position it spawned at: {val.transform.position} - {((Component)this).transform.position}"));
if (val.CompareTag("OutsideAINode"))
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: WaterWraith determined it spawned outside");
base.isOutside = true;
}
else
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: WaterWraith determined it spawned inside");
base.isOutside = false;
}
((MonoBehaviour)this).StartCoroutine(WaitForCrush());
}
private IEnumerator WaitForCrush()
{
yield return (object)new WaitForSeconds(8.5f);
base.inSpecialAnimation = false;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Should be able to move now");
yield return (object)new WaitForSeconds(2f);
CanEnterState2 = true;
}
public override void DoAIInterval()
{
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
//IL_04e7: Expected O, but got Unknown
//IL_0781: Unknown result type (might be due to invalid IL or missing references)
//IL_078b: Unknown result type (might be due to invalid IL or missing references)
//IL_0790: Unknown result type (might be due to invalid IL or missing references)
//IL_0606: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0503: Unknown result type (might be due to invalid IL or missing references)
//IL_0533: Unknown result type (might be due to invalid IL or missing references)
//IL_0538: Unknown result type (might be due to invalid IL or missing references)
//IL_0542: Expected O, but got Unknown
//IL_064e: Unknown result type (might be due to invalid IL or missing references)
//IL_0658: Unknown result type (might be due to invalid IL or missing references)
//IL_065d: Unknown result type (might be due to invalid IL or missing references)
//IL_0664: Unknown result type (might be due to invalid IL or missing references)
//IL_0568: Unknown result type (might be due to invalid IL or missing references)
//IL_0578: Unknown result type (might be due to invalid IL or missing references)
//IL_058e: Unknown result type (might be due to invalid IL or missing references)
//IL_0593: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (StartOfRound.Instance.livingPlayers == 0 || base.isEnemyDead || base.inSpecialAnimation)
{
moveAud.volume = 0f;
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
{
if (!IsWandering)
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Starting Search!");
((EnemyAI)this).StartSearch(((Component)this).transform.position, roamFactory);
IsWandering = true;
}
if (Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(360f, 15, -1)) && CanEnterState2)
{
((EnemyAI)this).StopSearch(roamFactory, true);
((EnemyAI)this).SetMovingTowardsTargetPlayer(((EnemyAI)this).CheckLineOfSightForPlayer(360f, 15, -1));
IsChaseingEnemy = false;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Chasing player");
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
break;
}
List<GameObject> list = (from enemy in RoundManager.Instance.SpawnedEnemies
where (Object)(object)enemy != (Object)null && (Object)(object)enemy.enemyType != (Object)(object)base.enemyType && !TargetedEnemies.Contains(enemy)
select ((Component)enemy).gameObject).ToList();
if (WaterWraithMod.ChaseEnemyConfig.Value && Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSight(list, 360f, 15, -1f, (Transform)null, (int[])null)) && CanEnterState2 && (Object)(object)((EnemyAI)this).CheckLineOfSight(list, 360f, 15, -1f, (Transform)null, (int[])null).GetComponentInChildren<EnemyAI>() != (Object)null)
{
((EnemyAI)this).StopSearch(roamFactory, true);
TargetEnemy = ((EnemyAI)this).CheckLineOfSight(list, 360f, 15, -1f, (Transform)null, (int[])null).GetComponentInChildren<EnemyAI>();
IsChaseingEnemy = true;
timeInEnemyChase = 0f;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Chasing enemy");
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
}
break;
}
case 1:
if (IsWandering)
{
((EnemyAI)this).StopSearch(roamFactory, true);
IsWandering = false;
}
if ((IsChaseingEnemy && ((Object)(object)TargetEnemy == (Object)null || TargetEnemy.isEnemyDead || TargetedEnemies.Contains(TargetEnemy) || Vector3.Distance(((Component)this).transform.position, ((Component)TargetEnemy).transform.position) > 20f)) || timeInEnemyChase > 25f)
{
if ((Object)(object)TargetEnemy != (Object)null)
{
TargetedEnemies.Add(TargetEnemy);
}
TargetEnemy = null;
IsChaseingEnemy = false;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: stopped Chasing enemy");
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
break;
}
if (IsChaseingEnemy)
{
((EnemyAI)this).SetDestinationToPosition(((Component)TargetEnemy).transform.position, false);
timeInEnemyChase += Time.deltaTime;
}
if (!IsChaseingEnemy && ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled || Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 30f))
{
base.targetPlayer = null;
base.movingTowardsTargetPlayer = false;
if (Vector3.Distance(((Component)this).transform.position, RoundManager.FindMainEntrancePosition(false, false)) < 10f)
{
roamFactory.currentTargetNode = ((Component)((EnemyAI)this).ChooseFarthestNodeFromPosition(RoundManager.FindMainEntrancePosition(false, false), false, 0, false, 50, false)).gameObject;
roamFactory.choseTargetNode = true;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Setting position away from main");
}
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: stopped Chasing player");
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
break;
case 2:
{
if (FleePos != Vector3.zero)
{
if (IsWandering)
{
((EnemyAI)this).StopSearch(roamFactory, true);
IsWandering = false;
}
base.agent.speed = 7f;
base.agent.acceleration = 999f;
base.agent.angularSpeed = 300f;
((EnemyAI)this).SetDestinationToPosition(FleePos, false);
if (Vector3.Distance(((Component)this).transform.position, FleePos) < 2f || !base.agent.CalculatePath(FleePos, new NavMeshPath()))
{
if (Vector3.Distance(((Component)this).transform.position, FleePos) < 2f)
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Exiting flee due to distance");
}
if (!base.agent.CalculatePath(FleePos, new NavMeshPath()))
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Exiting flee do to no pos");
}
WaterWraithMod.Logger.LogInfo((object)$"Flee pos: {FleePos}, Water pos: {((Component)this).transform.position}");
FleePos = Vector3.zero;
}
}
if (!IsWandering && FleePos == Vector3.zero)
{
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Starting Search 2!");
base.agent.speed = 3.5f;
base.agent.acceleration = 8f;
base.agent.angularSpeed = 120f;
((EnemyAI)this).StartSearch(((Component)this).transform.position, roamFactory);
IsWandering = true;
}
PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(360f, 15, -1);
if (IsWandering && Object.op_Implicit((Object)(object)val))
{
FleePos = ChooseFarthestPositionFromPosition(((Component)val).transform.position);
((EnemyAI)this).SetDestinationToPosition(FleePos, false);
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Fleeing from player!");
}
break;
}
case 3:
if (IsWandering)
{
((EnemyAI)this).StopSearch(roamFactory, true);
IsWandering = false;
}
((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
base.agent.speed = 0f;
base.agent.acceleration = 0f;
base.agent.angularSpeed = 0f;
if (timeBeingScared > 5f)
{
base.agent.speed = 3.5f;
base.agent.acceleration = 8f;
base.agent.angularSpeed = 120f;
timeBeingScared = 0f;
CanEnterState2 = true;
isVurable.Value = false;
WaterWraithMod.Logger.LogInfo((object)"WaterWraith: Resetting");
if (HasLostTires)
{
FleePos = ChooseFarthestPositionFromPosition(((Component)this).transform.position, 80f);
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
}
else
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
}
}
break;
}
}
public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
if (!isVurable.Value || base.isEnemyDead || base.inSpecialAnimation)
{
return;
}
base.enemyHP -= force;
timeBeingScared += Random.Range(0f, 1f);
if (base.enemyHP <= 0)
{
if (!HasLostTires)
{
RemoveTiresServerRpc();
}
else
{
KillWraithServerRpc();
}
}
}
public override void HitFromExplosion(float distance)
{
((EnemyAI)this).HitFromExplosion(distance);
WaterWraithMod.Logger.LogInfo((object)"Wraith kabboom!");
SetScaredServerRpc();
}
public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
{
((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer);
if (setToStunned)
{
WaterWraithMod.Logger.LogInfo((object)"Wraith cstuned!");
SetScaredServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
public void RemoveTiresServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(118134160u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 118134160u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
WaterWraithMod.Logger.LogInfo((object)"Removing On Serer");
if (!base.inSpecialAnimation && !HasLostTires)
{
RemoveTiresClientRpc();
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SetScaredServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2926869977u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2926869977u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
if (!isVurable.Value)
{
WaterWraithMod.Logger.LogInfo((object)"SetScared");
((EnemyAI)this).SwitchToBehaviourClientRpc(3);
timeBeingScared = 0f;
isVurable.Value = true;
}
else
{
WaterWraithMod.Logger.LogInfo((object)"Already scared");
}
}
}
public override void KillEnemy(bool destroy = false)
{
((EnemyAI)this).KillEnemy(destroy);
}
[ClientRpc]
public void RemoveTiresClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2232173676u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2232173676u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
if (HasLostTires)
{
WaterWraithMod.Logger.LogWarning((object)"The wraith has already removed it's tires");
return;
}
WaterWraithMod.Logger.LogInfo((object)"Removing Tires");
if (((NetworkBehaviour)this).IsServer && IsWandering)
{
((EnemyAI)this).StopSearch(roamFactory, true);
IsWandering = false;
}
base.targetPlayer = null;
base.enemyHP = 10;
base.inSpecialAnimation = true;
moveAud.volume = 0f;
HasLostTires = true;
base.creatureAnimator.SetTrigger("KnockedOff");
base.creatureAnimator.SetBool("HasLostRollers", true);
GameObject[] tireObjectsToDisable = TireObjectsToDisable;
foreach (GameObject val3 in tireObjectsToDisable)
{
val3.SetActive(false);
}
TireFragments[] tireObjectsToEnable = TireObjectsToEnable;
foreach (TireFragments tireFragments in tireObjectsToEnable)
{
GameObject gameObject = ((Component)tireFragments).gameObject;
if (((Component)gameObject.transform.parent).gameObject.activeSelf)
{
gameObject.SetActive(true);
}
gameObject.transform.SetParent((Transform)null, true);
}
Collider[] colidersToDisable = ColidersToDisable;
foreach (Collider val4 in colidersToDisable)
{
val4.enabled = false;
}
WraithTire[] tires = Tires;
foreach (WraithTire wraithTire in tires)
{
((Behaviour)wraithTire).enabled = false;
}
((MonoBehaviour)this).StartCoroutine(WaitToFlee());
}
private IEnumerator WaitToFlee()
{
yield return (object)new WaitForSeconds(2.6f);
FleePos = ChooseFarthestPositionFromPosition(((Component)this).transform.position);
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
base.inSpecialAnimation = false;
}
[ServerRpc(RequireOwnership = false)]
public void KillWraithServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3609201593u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3609201593u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !base.inSpecialAnimation && !base.isEnemyDead)
{
WaterWraithMod.Logger.LogInfo((object)"Killing Wraith");
KillWraithClientRpc();
}
}
}
[ClientRpc]
public void KillWraithClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1114460635u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1114460635u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureAnimator.SetTrigger("Die");
base.inSpecialAnimation = true;
base.creatureVoice.PlayOneShot(DethSounds[Random.Range(0, DethSounds.Length - 1)]);
if (((NetworkBehaviour)this).IsServer)
{
((MonoBehaviour)this).StartCoroutine(CallKillOnServer());
}
}
}
private IEnumerator CallKillOnServer()
{
yield return (object)new WaitForSeconds(2.5f);
((EnemyAI)this).KillEnemyOnOwnerClient(false);
}
public void DamagePlayer(PlayerControllerB player)
{
//IL_002b: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//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_0059: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
if (!isVurable.Value && (Object)(object)player != (Object)null)
{
Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
player.DamagePlayer(WaterWraithMod.DamageConfig.Value, true, true, (CauseOfDeath)8, 1, false, -normalized * 5f);
if (player.isPlayerDead)
{
base.creatureSFX.PlayOneShot(KillSFX);
}
else
{
player.externalForceAutoFade += normalized * 7f;
}
}
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).OnCollideWithPlayer(other);
PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && HasLostTires && !isVurable.Value && isRunning.Value)
{
Vector3 val = default(Vector3);
component.DamagePlayer(0, true, true, (CauseOfDeath)0, 0, false, val);
val = ((Component)component).transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
component.externalForceAutoFade += normalized * 2.5f;
}
}
public void DamageEnemy(EnemyAI enemy)
{
if (isVurable.Value || !((NetworkBehaviour)this).IsServer || !((Object)(object)enemy != (Object)null) || enemy.isEnemyDead)
{
return;
}
if (WaterWraithMod.IsDependencyLoaded("NoteBoxz.LethalMin") && LETHALMIN_ISRESISTANTTOCRUSH(enemy))
{
TargetedEnemies.Add(enemy);
WaterWraithMod.Logger.LogInfo((object)("Cannot Hit Pikmin: " + ((Object)enemy).name));
return;
}
WaterWraithMod.Logger.LogInfo((object)("Hitting enemy: " + ((Object)enemy).name));
int enemyHP = enemy.enemyHP;
enemy.HitEnemyServerRpc(WaterWraithMod.EDamageConfig.Value, -1, true, -1);
if (!enemy.isEnemyDead)
{
enemy.stunNormalizedTimer += Random.Range(0f, 1f);
}
if (enemyHP == enemy.enemyHP && (Object)(object)enemy == (Object)(object)TargetEnemy)
{
WaterWraithMod.Logger.LogInfo((object)("Water Wraith has determined that target enemy " + ((Object)enemy).name + " is unkillable"));
TargetedEnemies.Add(enemy);
}
}
public bool LETHALMIN_ISRESISTANTTOCRUSH(EnemyAI ai)
{
PikminAI component = ((Component)ai).GetComponent<PikminAI>();
if ((Object)(object)component != (Object)null)
{
return LethalMin.IsPikminResistantToHazard(component.PminType, (HazardType)7);
}
return false;
}
private void LateUpdate()
{
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0074: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if (base.isEnemyDead || base.inSpecialAnimation)
{
return;
}
if (((NetworkBehaviour)this).IsServer)
{
if (isVurable.Value)
{
timeBeingScared += Time.deltaTime;
}
Vector3 val;
if (!HasLostTires)
{
AudioSource obj = moveAud;
val = base.agent.velocity;
val = ((Vector3)(ref val)).normalized;
obj.volume = ((Vector3)(ref val)).magnitude;
}
Animator creatureAnimator = base.creatureAnimator;
val = base.agent.velocity;
val = ((Vector3)(ref val)).normalized;
creatureAnimator.SetBool("Moving", ((Vector3)(ref val)).magnitude > 0.1f);
base.creatureAnimator.SetBool("IsRunning", HasLostTires && FleePos != Vector3.zero);
isRunning.Value = HasLostTires && FleePos != Vector3.zero;
}
else
{
LastPosCheck += Time.deltaTime;
if (Vector3.Distance(LastPosition, ((Component)this).transform.position) > 0.1f)
{
LastPosition = ((Component)this).transform.position;
if (!HasLostTires)
{
moveAud.volume = 1f;
}
base.creatureAnimator.SetBool("Moving", true);
}
else if (LastPosCheck > 1f)
{
LastPosCheck = 0f;
if (!HasLostTires)
{
moveAud.volume = 0f;
}
base.creatureAnimator.SetBool("Moving", false);
}
base.creatureAnimator.SetBool("IsRunning", HasLostTires && isRunning.Value);
}
base.creatureAnimator.SetBool("IsScared", isVurable.Value);
if (lastIsScaredCheck != isVurable.Value)
{
lastIsScaredCheck = isVurable.Value;
if (isVurable.Value)
{
base.creatureAnimator.SetTrigger("Scared");
}
}
timeSinceHitting += Time.deltaTime;
}
public Vector3 ChooseFarthestPositionFromPosition(Vector3 pos, float MaxDistance = 25f)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_0070: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: 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_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)this).transform.position - pos;
Vector3 normalized = ((Vector3)(ref val)).normalized;
Vector3 val2 = ((Component)this).transform.position + normalized * MaxDistance;
Vector3 position = ((Component)this).transform.position;
float num = 0f;
NavMeshHit val5 = default(NavMeshHit);
for (int i = 0; i < 8; i++)
{
Vector3 val3 = Random.insideUnitSphere * (MaxDistance * 0.1f);
val3.y = 0f;
Vector3 val4 = val2 + val3;
if (NavMesh.SamplePosition(val4, ref val5, MaxDistance, -1))
{
float num2 = Vector3.Distance(((NavMeshHit)(ref val5)).position, pos);
if (num2 > num && !((EnemyAI)this).PathIsIntersectedByLineOfSight(((NavMeshHit)(ref val5)).position, false, false, false))
{
num = num2;
position = ((NavMeshHit)(ref val5)).position;
}
}
}
WaterWraithMod.Logger.LogInfo((object)$"Chosen flee position: {position}, Distance: {num}");
if (num == 0f)
{
WaterWraithMod.Logger.LogInfo((object)"Wraith cornnered!");
SetScaredServerRpc();
}
else if (isVurable.Value)
{
isVurable.Value = false;
}
return position;
}
protected override void __initializeVariables()
{
if (isVurable == null)
{
throw new Exception("WaterWraithAI.isVurable cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)isVurable).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isVurable, "isVurable");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isVurable);
if (isRunning == null)
{
throw new Exception("WaterWraithAI.isRunning cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)isRunning).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isRunning, "isRunning");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isRunning);
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_WaterWraithAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(118134160u, new RpcReceiveHandler(__rpc_handler_118134160));
NetworkManager.__rpc_func_table.Add(2926869977u, new RpcReceiveHandler(__rpc_handler_2926869977));
NetworkManager.__rpc_func_table.Add(2232173676u, new RpcReceiveHandler(__rpc_handler_2232173676));
NetworkManager.__rpc_func_table.Add(3609201593u, new RpcReceiveHandler(__rpc_handler_3609201593));
NetworkManager.__rpc_func_table.Add(1114460635u, new RpcReceiveHandler(__rpc_handler_1114460635));
}
private static void __rpc_handler_118134160(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((WaterWraithAI)(object)target).RemoveTiresServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2926869977(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((WaterWraithAI)(object)target).SetScaredServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2232173676(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((WaterWraithAI)(object)target).RemoveTiresClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3609201593(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((WaterWraithAI)(object)target).KillWraithServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1114460635(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((WaterWraithAI)(object)target).KillWraithClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "WaterWraithAI";
}
}
public class WraithTire : MonoBehaviour
{
public WaterWraithAI ai = null;
private Dictionary<Collider, float> objectsInTriggerWDelay = new Dictionary<Collider, float>();
private const float collisionDelay = 0.5f;
private void OnTriggerEnter(Collider other)
{
if (((Behaviour)this).enabled)
{
bool flag = false;
bool flag2 = false;
EnemyAICollisionDetect component = ((Component)other).GetComponent<EnemyAICollisionDetect>();
if ((Object)(object)component == (Object)null || (Object)(object)component.mainScript == (Object)null || (Object)(object)component.mainScript.enemyType == (Object)(object)((EnemyAI)ai).enemyType)
{
flag = true;
}
if ((Object)(object)((Component)other).GetComponent<PlayerControllerB>() == (Object)null)
{
flag2 = true;
}
if (!(flag && flag2) && !objectsInTriggerWDelay.ContainsKey(other))
{
objectsInTriggerWDelay.Add(other, 2f);
}
}
}
private void OnTriggerExit(Collider other)
{
}
private void OnTriggerStay(Collider other)
{
if (!((Behaviour)this).enabled)
{
return;
}
if (objectsInTriggerWDelay.ContainsKey(other))
{
if (((Component)other).CompareTag("Enemy"))
{
objectsInTriggerWDelay[other] += Time.deltaTime * 0.35f;
}
else
{
objectsInTriggerWDelay[other] += Time.deltaTime * WaterWraithMod.PlayerCollisionBufferMultiplier.Value;
}
if (objectsInTriggerWDelay[other] >= 0.5f)
{
HandleCollision(other);
objectsInTriggerWDelay[other] = 0f;
}
}
}
private void HandleCollision(Collider other)
{
if (!((Behaviour)this).enabled)
{
return;
}
PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && !component.isPlayerDead)
{
ai.DamagePlayer(component);
return;
}
EnemyAI val = ((Component)other).GetComponent<EnemyAICollisionDetect>()?.mainScript;
if ((Object)(object)val != (Object)null && !val.isEnemyDead)
{
ai.DamageEnemy(val);
return;
}
objectsInTriggerWDelay.Remove(other);
WaterWraithMod.Logger.LogInfo((object)("Remvoing null/dead component from trigger: " + ((other != null) ? ((Object)other).name : null)));
}
public List<Collider> GetobjectsInTriggerWDelay()
{
return new List<Collider>(objectsInTriggerWDelay.Keys);
}
public List<T> GetObjectsOfType<T>() where T : Component
{
return (from c in objectsInTriggerWDelay.Keys
select ((Component)c).GetComponent<T>() into component
where (Object)(object)component != (Object)null
select component).ToList();
}
}
}
namespace WaterWraithMod.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatch
{
public static bool HasInitalized;
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Init(GameNetworkManager __instance)
{
if (HasInitalized)
{
WaterWraithMod.Logger.LogWarning((object)"Already initalized WaterWraithMod");
return;
}
EnemyType val = WaterWraithMod.assetBundle.LoadAsset<EnemyType>("Assets/ModAsset/WaterType.asset");
NetworkManager.Singleton.AddNetworkPrefab(val.enemyPrefab);
WaterWraithMod.Logger.LogInfo((object)"WaterWraithMod initialized on network");
HasInitalized = true;
}
}
[HarmonyPatch(typeof(PurplePikmin))]
internal class PurplePikminPatch
{
[HarmonyPatch("PlaySlamSFXClientRpc")]
[HarmonyPostfix]
public static void Init(PurplePikmin __instance)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer)
{
return;
}
WaterWraithAI[] array = Object.FindObjectsOfType<WaterWraithAI>();
foreach (WaterWraithAI waterWraithAI in array)
{
if (Vector3.Distance(((Component)waterWraithAI).transform.position, ((Component)__instance).transform.position) < 10f && !waterWraithAI.isVurable.Value)
{
waterWraithAI.SetScaredServerRpc();
}
}
}
}
public enum WraithSpawnPosition
{
OnlyIndoors,
OnlyOutdoors,
IndoorsAndOutdoors
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
public static bool IsSpawningWaterWraithThisRound;
public static float WWTimer;
[HarmonyPatch("PredictAllOutsideEnemies")]
[HarmonyPostfix]
public static void PredictAllOutsideEnemiesPostFix(RoundManager __instance)
{
if (((NetworkBehaviour)__instance).IsServer && !(RoundManager.Instance.currentLevel.sceneName == "CompanyBuilding"))
{
IsSpawningWaterWraithThisRound = false;
float num = Random.Range(0f, 100f);
float value = WaterWraithMod.SpawnChanceConfig.Value;
if (WaterWraithMod.GetParsedMoonSpawn().ContainsKey(__instance.currentLevel.PlanetName))
{
WaterWraithMod.GetParsedMoonSpawn().TryGetValue(__instance.currentLevel.PlanetName, out value);
WaterWraithMod.Logger.LogInfo((object)$"override value: {value}");
}
WaterWraithMod.Logger.LogInfo((object)$"RNG: {num}, CHANCE: {value}");
if (num < value)
{
WWTimer = WaterWraithMod.SpawnTimerConfig.Value;
IsSpawningWaterWraithThisRound = true;
}
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void UpdatePostfix(RoundManager __instance)
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer || StartOfRound.Instance.inShipPhase || StartOfRound.Instance.livingPlayers == 0 || !IsSpawningWaterWraithThisRound)
{
return;
}
if (WWTimer > 0f)
{
WWTimer -= Time.deltaTime;
return;
}
IsSpawningWaterWraithThisRound = false;
GameObject[] array = GameObject.FindGameObjectsWithTag("AINode");
GameObject[] array2 = GameObject.FindGameObjectsWithTag("OutsideAINode");
EnemyType val = WaterWraithMod.assetBundle.LoadAsset<EnemyType>("Assets/ModAsset/WaterType.asset");
int num = -1;
for (int i = 0; i < __instance.currentLevel.Enemies.Count; i++)
{
EnemyType enemyType = __instance.currentLevel.Enemies[i].enemyType;
if ((Object)(object)enemyType == (Object)(object)val)
{
num = i;
WaterWraithMod.Logger.LogInfo((object)$"Found a WaterWraith at index {i} in the enemies list!");
break;
}
}
if (num == -1)
{
WaterWraithMod.Logger.LogWarning((object)"No WaterWraith found in the enemies list! Injecting...");
SpawnableEnemyWithRarity val2 = new SpawnableEnemyWithRarity();
val2.enemyType = val;
val2.rarity = 0;
__instance.currentLevel.Enemies.Add(val2);
num = __instance.currentLevel.Enemies.IndexOf(val2);
WaterWraithMod.Logger.LogInfo((object)$"WaterWraith added to the enemies list at index {num}");
}
int num2 = Random.Range(0, 100);
switch (WaterWraithMod.WraithSpawnPositionConfig.Value)
{
case WraithSpawnPosition.OnlyIndoors:
if (array.Length != 0)
{
__instance.SpawnEnemyOnServer(array[Random.Range(0, array.Length)].transform.position, val.enemyPrefab.transform.rotation.y, num);
}
break;
case WraithSpawnPosition.OnlyOutdoors:
if (array2.Length != 0)
{
__instance.SpawnEnemyOnServer(array2[Random.Range(0, array2.Length)].transform.position, val.enemyPrefab.transform.rotation.y, num);
}
break;
case WraithSpawnPosition.IndoorsAndOutdoors:
{
List<GameObject> list = new List<GameObject>();
list.AddRange(array2);
list.AddRange(array);
if (list.Count > 0)
{
__instance.SpawnEnemyOnServer(list[Random.Range(0, list.Count)].transform.position, val.enemyPrefab.transform.rotation.y, num);
}
break;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace NoteBoxz.WaterWraith.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}