Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Tidewater v0.1.1
Tidewater.dll
Decompiled 31 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Jobs; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("TidewaterTest")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tidewater")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+3a7662d416e7388415de86ee41247d1cf20bc358")] [assembly: AssemblyProduct("Tidewater")] [assembly: AssemblyTitle("Tidewater")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Tidewater { internal class Channel : MonoBehaviour { public static Channel Current; public static bool Built; public static string Info = ""; public static Vector3 Centre; public static int Cells; public static float Deepest; public static float Span; public static float FromCulvert; public const float ChannelBed = -2.6f; public const float SwimDepth = 1.8f; private const float Step = 2f; private const int MouthRows = 4; private const float X0 = -135f; private const float X1 = 115f; private const float Y0 = -66f; private const float Y1 = 10f; private static int _nx; private static int _ny; private static float[] _bed; private static bool[] _chan; private float _wait; public static Vector3 Den; private static List<int> _cells = new List<int>(); private static int Mask { get { if (!((Object)(object)StartOfRound.Instance != (Object)null)) { return -1; } return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } } public static void Create(Transform host) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TidewaterChannel"); val.transform.SetParent(host, false); Current = val.AddComponent<Channel>(); } private void OnDestroy() { if (!((Object)(object)Current != (Object)(object)this)) { Current = null; Built = false; _bed = null; _chan = null; _cells = new List<int>(); Cells = 0; Info = ""; } } private void Update() { if (!Built && !((Object)(object)StartOfRound.Instance == (Object)null) && !((_wait += Time.deltaTime) < 3f)) { Build(); } } private static void Build() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: 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_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) float realtimeSinceStartup = Time.realtimeSinceStartup; _nx = Mathf.CeilToInt(125f); _ny = Mathf.CeilToInt(38f); _bed = new float[_nx * _ny]; _chan = new bool[_nx * _ny]; int mask = Mask; RaycastHit val = default(RaycastHit); for (int i = 0; i < _ny; i++) { for (int j = 0; j < _nx; j++) { float num = -135f + ((float)j + 0.5f) * 2f; float num2 = -66f + ((float)i + 0.5f) * 2f; float num3 = -77.3f - num; float num4 = 16f - num2; float num5 = float.NaN; if (Physics.Raycast(new Vector3(num3, 40f, num4), Vector3.down, ref val, 120f, mask, (QueryTriggerInteraction)1)) { Bounds bounds = ((RaycastHit)(ref val)).collider.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(size.x, size.z) >= 40f) { num5 = ((RaycastHit)(ref val)).point.y - -7f; } } _bed[i * _nx + j] = num5; } } int seaTop = -1; for (int k = 0; k < _ny; k++) { int num6 = 0; int num7 = 0; for (int l = 0; l < _nx; l++) { int num8 = k * _nx + l; if (!float.IsNaN(_bed[num8])) { num7++; if (Deep(num8)) { num6++; } } } if (num7 > 0 && num6 > num7 / 2) { seaTop = k; } else if (seaTop >= 0) { break; } } List<int> list = new List<int>(); int num9 = -1; Vector3? cul = Culvert(); if (cul.HasValue) { float num10 = float.MaxValue; for (int m = 0; m < _bed.Length; m++) { if (m / _nx > seaTop && Deep(m)) { Vector3 val2 = World(m) - cul.Value; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num10) { num10 = sqrMagnitude; num9 = m; } } } } bool[] seen; Queue<int> q; if (num9 >= 0) { seen = new bool[_nx * _ny]; q = new Queue<int>(); seen[num9] = true; q.Enqueue(num9); while (q.Count > 0) { int num11 = q.Dequeue(); list.Add(num11); int num12 = num11 % _nx; int num13 = num11 / _nx; Try(num12 + 1, num13); Try(num12 - 1, num13); Try(num12, num13 + 1); Try(num12, num13 - 1); } if (seaTop >= 0 && list.Count > 0) { int lowRow = list.Min((int c) => c / _nx); List<int> source = (from c in list where c / _nx == lowRow select c % _nx).ToList(); int num14 = source.Min() - 2; int num15 = source.Max() + 2; int num16 = seaTop; while (num16 > seaTop - 4 && num16 >= 0) { for (int num17 = Mathf.Max(0, num14); num17 <= Mathf.Min(_nx - 1, num15); num17++) { int num18 = num16 * _nx + num17; if (Deep(num18)) { list.Add(num18); } } num16--; } } } Vector3 val3 = Vector3.zero; float num19 = float.MaxValue; foreach (int item in list) { _chan[item] = true; val3 += World(item); num19 = Mathf.Min(num19, _bed[item]); } Cells = list.Count; Deepest = ((Cells > 0) ? num19 : float.NaN); _cells = list; Den = ((Cells > 0) ? World(list.OrderByDescending((int c) => _bed[c]).First()) : Vector3.zero); Span = ((Cells > 0) ? ((float)(list.Max((int c) => c % _nx) - list.Min((int c) => c % _nx) + 1) * 2f) : 0f); FromCulvert = ((Cells > 0 && cul.HasValue) ? list.Min((int c) => Vector2.Distance(new Vector2(World(c).x, World(c).z), new Vector2(cul.Value.x, cul.Value.z))) : float.NaN); Centre = ((Cells > 0) ? (val3 / (float)Cells) : Vector3.zero); Built = true; Info = ((Cells > 0) ? $"{Cells} cells ({(float)Cells * 2f * 2f:F0} m²) at or below {-2.6f:F1} m, deepest {num19:F1} m, {Span:F0} m across, {FromCulvert:F0} m from the culvert, centre {Centre}" : (Culvert().HasValue ? $"no ground at or below {-2.6f:F1} m by the culvert" : "culvert fire exit not found")); Plugin.Log.LogInfo((object)$"Tidewater: deep channel {Info}; {(Time.realtimeSinceStartup - realtimeSinceStartup) * 1000f:F0} ms"); void Try(int ni, int nj) { if (ni >= 0 && nj > seaTop && ni < _nx && nj < _ny) { int num20 = nj * _nx + ni; if (!seen[num20] && Deep(num20)) { seen[num20] = true; q.Enqueue(num20); } } } } internal static void Dump(string path) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (_bed == null) { return; } Vector3? val = Culvert(); int num = (val.HasValue ? CellAt(val.Value) : (-1)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"{_nx} {_ny} {2f} {-135f} {-66f} {((num >= 0) ? (num % _nx) : (-1))} {((num >= 0) ? (num / _nx) : (-1))}"); for (int i = 0; i < _ny; i++) { for (int j = 0; j < _nx; j++) { int num2 = i * _nx + j; stringBuilder.Append(float.IsNaN(_bed[num2]) ? "nan" : _bed[num2].ToString("F2", CultureInfo.InvariantCulture)); if (_chan[num2]) { stringBuilder.Append('*'); } stringBuilder.Append((j + 1 < _nx) ? ' ' : '\n'); } } File.WriteAllText(path, stringBuilder.ToString()); Plugin.Log.LogInfo((object)("Tidewater: channel dump " + path + "; culvert " + (val.HasValue ? ((object)val.Value/*cast due to .constrained prefix*/).ToString() : "not found"))); } internal static Vector3? Culvert() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); foreach (EntranceTeleport val in array) { if (val.isEntranceToBuilding && val.entranceId == 2) { return ((Component)val).transform.position; } } return null; } private static bool Deep(int k) { if (!float.IsNaN(_bed[k])) { return _bed[k] <= -2.6f; } return false; } private static Vector3 World(int k) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) int num = k % _nx; int num2 = k / _nx; float num3 = -135f + ((float)num + 0.5f) * 2f; float num4 = -66f + ((float)num2 + 0.5f) * 2f; return new Vector3(-77.3f - num3, _bed[k] + -7f, 16f - num4); } private static int CellAt(Vector3 world) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (_bed == null) { return -1; } float num = -77.3f - world.x; float num2 = 16f - world.z; int num3 = Mathf.FloorToInt((num - -135f) / 2f); int num4 = Mathf.FloorToInt((num2 - -66f) / 2f); if (num3 < 0 || num4 < 0 || num3 >= _nx || num4 >= _ny) { return -1; } return num4 * _nx + num3; } public static bool InWindow() { if (Tide.Today.Valid) { return Tide.HeightNow() >= -0.55f; } return false; } public static void Window(TideDay t, out float from, out float to) { from = Tide.Crossing(t, -0.55f, rising: true); to = Tide.Crossing(t, -0.55f, rising: false); } public static Vector3 RandomPoint(Random rnd) { //IL_002c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) if (_cells.Count == 0) { return Den; } return World(_cells[rnd.Next(_cells.Count)]) + new Vector3((float)rnd.NextDouble() - 0.5f, 0f, (float)rnd.NextDouble() - 0.5f) * 2f; } public static float BedAt(Vector3 world) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = CellAt(world); if (num >= 0 && !float.IsNaN(_bed[num])) { return _bed[num] + -7f; } return float.NaN; } public static bool InChannel(Vector3 world) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = CellAt(world); if (num >= 0) { return _chan[num]; } return false; } public static float DepthAt(Vector3 world) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = CellAt(world); if (num < 0 || float.IsNaN(_bed[num])) { return 0f; } float outsideSurface = Water.OutsideSurface; if (!float.IsNaN(outsideSurface)) { return Mathf.Max(0f, outsideSurface - (_bed[num] + -7f)); } return 0f; } public static bool Danger(Vector3 world) { //IL_001a: 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) if (Built && Plugin.ChannelThreat.Value && InWindow() && InChannel(world)) { return DepthAt(world) >= 1.8f; } return false; } } internal class DriftPile : MonoBehaviour { public static DriftPile Current; public static bool Built; public static Vector3 Centre; public static int Logs; public static string Info = ""; private const float Level = 0.4f; internal const float CatchRadius = 40f; private const float SnagReach = 1.1f; private readonly HashSet<Collider> cols = new HashSet<Collider>(); private static Texture2D _grain; private static Texture2D _weedTex; private int _seed = 101; private const bool AddWeed = false; private static int Mask { get { if (!((Object)(object)StartOfRound.Instance != (Object)null)) { return -1; } return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } } public static bool Owns(Collider c) { if ((Object)(object)c != (Object)null && (Object)(object)Current != (Object)null) { return Current.cols.Contains(c); } return false; } public static HashSet<int> ColliderIds() { return new HashSet<int>(((Object)(object)Current != (Object)null) ? (from c in Current.cols where (Object)(object)c != (Object)null select ((Object)c).GetInstanceID()) : Enumerable.Empty<int>()); } public static void Create(Transform host) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TidewaterDriftPile"); val.transform.SetParent(host, false); Current = val.AddComponent<DriftPile>(); } internal static bool Touching(Vector3 p) { //IL_0018: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) DriftPile current = Current; if (!Built || (Object)(object)current == (Object)null) { return false; } Vector3 val = new Vector3(p.x - Centre.x, 0f, p.z - Centre.z); if (((Vector3)(ref val)).sqrMagnitude > 144f) { return false; } Collider[] array = Physics.OverlapSphere(p + Vector3.up * 0.1f, 1.1f, -1, (QueryTriggerInteraction)1); foreach (Collider item in array) { if (current.cols.Contains(item)) { return true; } } return false; } private void OnDestroy() { if ((Object)(object)Current == (Object)(object)this) { Current = null; Built = false; Logs = 0; } } private IEnumerator Start() { for (int k = 0; k < 40; k++) { if (Built) { break; } yield return (object)new WaitForSeconds(0.25f); if (FindSpot(out var at)) { Build(at); } } if (!Built) { Info = "no spot found"; Plugin.Log.LogWarning((object)"Tidewater: no spot for the driftwood pile"); } } private static float GroundAt(float x, float z, float from = 60f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Vector3(x, from, z), Vector3.down, ref val, 200f, Mask, (QueryTriggerInteraction)1)) { return float.NaN; } return ((RaycastHit)(ref val)).point.y; } private static bool FindSpot(out Vector3 at) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) at = default(Vector3); float num = -6.6f; float[] array = new float[4] { -112f, -104f, -120f, -96f }; foreach (float num2 in array) { float num3 = -77.3f - num2; for (float num4 = 5f; num4 > -75f; num4 -= 0.5f) { float num5 = 16f - num4; float num6 = GroundAt(num3, num5); if (!float.IsNaN(num6) && !(num6 > num)) { float num7 = GroundAt(num3, num5 + 6f); if (float.IsNaN(num7) || num7 > num6 + 0.2f) { break; } at = new Vector3(num3, num6, num5); return true; } } } return false; } private void Build(Vector3 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_053e: 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_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: 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_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0168: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) Centre = c; ((Component)this).transform.position = c; int num = LayerMask.NameToLayer("Room"); if (num < 0) { num = 0; } Material val = WoodMat(); Random rnd = new Random(4711); Vector3 val5; for (int i = 0; i < 14; i++) { bool flag = i < 4; float num2 = (flag ? R(4.2f, 6.2f) : R(1.6f, 3.8f)); float num3 = (flag ? R(0.2f, 0.3f) : R(0.08f, 0.19f)); float num4 = ((rnd.NextDouble() < 0.7) ? 0f : 90f) + R(-28f, 28f); Vector3 val2 = new Vector3(R(-3.4f, 3.4f), 0f, R(-1.5f, 1.5f)) * (flag ? 0.55f : 1f); Vector3 val3 = Quaternion.Euler(0f, num4, 0f) * Vector3.right; Vector3 val4 = c + val2; float num5 = Rest(val4 - val3 * num2 * 0.4f, c.y); float num6 = Rest(val4 + val3 * num2 * 0.4f, c.y); float num7 = Rest(val4, c.y); float num8 = Mathf.Clamp(Mathf.Atan2(num6 - num5, num2 * 0.8f) * 57.29578f, -14f, 14f); float num9 = Mathf.Max(num7, (num5 + num6) * 0.5f) + num3 * 0.8f; val5 = val3 * Mathf.Cos(num8 * (MathF.PI / 180f)) + Vector3.up * Mathf.Sin(num8 * (MathF.PI / 180f)); Vector3 normalized = ((Vector3)(ref val5)).normalized; Piece("Log" + i, new Vector3(val4.x, num9, val4.z), normalized, num3, num2, val, num, R(0f, 360f), collide: true); Physics.SyncTransforms(); Logs++; } Vector3 val8 = default(Vector3); for (int j = 0; j < 2; j++) { float num10 = R(0f, 360f); Vector3 val6 = Quaternion.Euler(0f, num10, 0f) * Vector3.right; Vector3 val7 = c + new Vector3((j == 0) ? (-4.2f) : 3.9f, 0f, R(-1.8f, 1.8f)); float num11 = R(0.34f, 0.44f); float num12 = R(1.1f, 1.5f); float num13 = Rest(val7, c.y) + num11 * 0.85f; ((Vector3)(ref val8))..ctor(val7.x, num13, val7.z); Piece("Stump" + j, val8, val6, num11, num12, val, num, R(0f, 360f), collide: true); Vector3 val9 = val8 + val6 * num12 * 0.5f; for (int k = 0; k < 4; k++) { Quaternion val10 = Quaternion.AngleAxis((float)k * 90f + R(-25f, 25f), val6); val5 = Vector3.Cross(val6, Vector3.up); Vector3 val11 = val10 * ((Vector3)(ref val5)).normalized; val5 = val6 * R(0.9f, 1.4f) + val11 + Vector3.down * 0.35f; Vector3 normalized2 = ((Vector3)(ref val5)).normalized; float num14 = R(0.45f, 0.85f); Piece($"Root{j}{k}", val9 + normalized2 * num14 * 0.5f, normalized2, R(0.06f, 0.1f), num14, val, num, 0f, collide: false); } Physics.SyncTransforms(); } Material val12 = null; if ((Object)(object)val12 != (Object)null) { for (int l = 0; l < 9; l++) { float num15 = (float)l * 40f + R(-15f, 15f); Vector3 val13 = c + Quaternion.Euler(0f, num15, 0f) * new Vector3(R(2.2f, 4.6f), 0f, 0f) * 1f; val13.z = c.z + (val13.z - c.z) * 0.55f; Weed(val13, R(1.2f, 2.6f), R(0f, 360f), val12); } } Built = true; Info = $"at {c} (design y {16f - c.z:F0}, ground {c.y - -7f:+0.0;-0.0} m), {Logs} logs, {cols.Count} colliders, wood '{((val != null) ? ((Object)val).name : null)}'"; Plugin.Log.LogInfo((object)("Tidewater: driftwood pile " + Info)); float R(float a, float b) { return a + (float)rnd.NextDouble() * (b - a); } } private float Rest(Vector3 p, float near) { //IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Vector3(p.x, near + 6f, p.z), Vector3.down, ref val, 20f, Mask, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).point.y; } return near; } private GameObject Piece(string name, Vector3 at, Vector3 axis, float rad, float len, Material m, int layer, float roll, bool collide) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(((Component)this).transform, true); val.transform.position = at; val.transform.rotation = Quaternion.AngleAxis(roll, axis) * Quaternion.FromToRotation(Vector3.up, axis); val.layer = layer; try { val.tag = "Wood"; } catch { } val.AddComponent<MeshFilter>().sharedMesh = LogMesh(rad, len, collide ? 0.3f : 0.5f, _seed++); MeshRenderer val2 = val.AddComponent<MeshRenderer>(); if ((Object)(object)m != (Object)null) { ((Renderer)val2).sharedMaterial = m; } if (collide) { CapsuleCollider val3 = val.AddComponent<CapsuleCollider>(); val3.direction = 1; val3.radius = rad * 0.9f; val3.height = len; cols.Add((Collider)(object)val3); } return val; } internal static Mesh LogMesh(float rad, float len, float taper, int seed) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) Random rnd = new Random(seed); float num = Rn() * 6.2832f; float num2 = len * (0.015f + 0.03f * Rn()); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); float[] array = new float[110]; for (int i = 0; i < array.Length; i++) { array[i] = Rn(); } List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> tri = new List<int>(); for (int j = 0; j < 10; j++) { float num3 = (float)j / 9f; float num4 = ((Mathf.Min(num3, 1f - num3) < 0.06f) ? 0.8f : ((Mathf.Min(num3, 1f - num3) < 0.14f) ? 0.94f : 1f)); float num5 = rad * (1f - taper * num3) * (0.9f + 0.2f * array[j * 11]) * num4; Vector3 val2 = new Vector3(0f, (0f - len) * 0.5f + num3 * len, 0f) + val * num2 * Mathf.Sin(MathF.PI * num3); for (int k = 0; k <= 11; k++) { float num6 = (float)k * 6.2832f / 11f; float num7 = 1f + 0.08f * (array[j * 11 + k % 11] - 0.5f); list.Add(val2 + new Vector3(Mathf.Cos(num6), 0f, Mathf.Sin(num6)) * num5 * num7); list2.Add(new Vector2((float)k / 11f, num3 * len * 0.5f)); } } for (int l = 0; l < 9; l++) { for (int m = 0; m < 11; m++) { int num8 = l * 12 + m; int num9 = num8 + 1; int num10 = num8 + 11 + 1; int num11 = num10 + 1; tri.AddRange(new int[6] { num8, num10, num9, num9, num10, num11 }); } } int count = list.Count; list.Add(new Vector3(0f, (0f - len) * 0.5f - rad * 0.04f, 0f)); list2.Add(new Vector2(0.5f, 0f)); int count2 = list.Count; list.Add(new Vector3(0f, len * 0.5f + rad * 0.04f, 0f)); list2.Add(new Vector2(0.5f, len * 0.5f)); int num12 = 108; for (int n = 0; n < 11; n++) { tri.AddRange(new int[3] { count, n, n + 1 }); tri.AddRange(new int[3] { count2, num12 + n + 1, num12 + n }); } Mesh val3 = new Mesh { name = "TidewaterLog" }; val3.SetVertices(list); val3.SetUVs(0, list2); val3.SetTriangles(tri, 0); val3.RecalculateNormals(); val3.RecalculateBounds(); int num13 = 62; Vector3 val4 = new Vector3(0f, list[num13].y, 0f) + val * num2 * Mathf.Sin(MathF.PI * 5f / 9f); if (val3.normals.Length != 0 && Vector3.Dot(val3.normals[num13], list[num13] - val4) < 0f) { val3.SetTriangles(tri.Select((int x, int ix) => tri[ix - ix % 3 + 2 - ix % 3]).ToList(), 0); } val3.RecalculateNormals(); return val3; float Rn() { return (float)rnd.NextDouble(); } } private void Weed(Vector3 p, float size, float yaw, Material m) { //IL_0000: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Vector3(p.x, Centre.y + 6f, p.z), Vector3.down, ref val, 20f, Mask, (QueryTriggerInteraction)1) && !cols.Contains(((RaycastHit)(ref val)).collider)) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = "Weed"; Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.transform.SetParent(((Component)this).transform, true); obj.transform.position = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.03f; obj.transform.rotation = Quaternion.FromToRotation(Vector3.forward, -((RaycastHit)(ref val)).normal) * Quaternion.Euler(0f, 0f, yaw); obj.transform.localScale = new Vector3(size, size * 0.6f, 1f); MeshRenderer component = obj.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = m; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; } } private static Material WoodMat() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) string from; Material val = Sea.LiveLit(wantNormal: false, wantCutout: false, out from); if ((Object)(object)val == (Object)null) { return null; } ((Object)val).name = "TidewaterDriftwood"; Sea.Neutral(val); if ((Object)(object)_grain == (Object)null) { _grain = Grain(128); } val.SetTexture("_BaseColorMap", (Texture)(object)_grain); val.SetTextureScale("_BaseColorMap", Vector2.one); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.4f, 0.375f, 0.335f); val.SetColor("_BaseColor", val2); if (val.HasProperty("_Color")) { val.SetColor("_Color", val2); } Sea.SetF(val, "_Smoothness", 0.16f); Sea.SetF(val, "_SmoothnessRemapMin", 0.1f); Sea.SetF(val, "_SmoothnessRemapMax", 0.2f); return val; } private static Material WeedMat() { //IL_003e: 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) if ((Object)(object)_weedTex == (Object)null) { _weedTex = Sea.NoiseTex(128, 4, 4, 31, Color.white, 0.6f); } return Sea.CutoutMat("TidewaterPileWeed", new Color(0.11f, 0.1f, 0.05f), 0.35f, _weedTex, 0.5f); } internal static Texture2D Grain(int n) { //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_0155: 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) Color[] array = (Color[])(object)new Color[n * n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { float num = (float)j / (float)n; float num2 = (float)i / (float)n; float num3 = Mathf.PerlinNoise(num2 * 3f + 5f, Mathf.Sin(num * 6.2832f) * 0.6f + 3f) * 0.9f; float num4 = 0.5f + 0.5f * Mathf.Sin(6.2832f * (13f * num + 2f * num3)); float num5 = Mathf.SmoothStep(0f, 1f, (Mathf.Abs(Mathf.Sin(6.2832f * (3f * num + num3 * 0.7f))) - 0.94f) / 0.06f); float num6 = Mathf.PerlinNoise(num * 7f + 11f, num2 * 2f + 1f); float num7 = Mathf.PerlinNoise(num * 40f + 3f, num2 * 6f + 7f); float num8 = 0.82f + 0.05f * num4 + 0.07f * (num7 - 0.5f) + 0.12f * (num6 - 0.5f) - 0.3f * num5; array[i * n + j] = new Color(num8, num8 * 0.98f, num8 * 0.95f, 1f); } } Texture2D val = new Texture2D(n, n, (TextureFormat)4, true, false) { name = "TidewaterGrain", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; val.SetPixels(array); val.Apply(true, true); return val; } } [HarmonyPatch(typeof(RoundManager), "GetOutsideAINodes")] internal static class DryNodes { private static GameObject[] _doneFor; internal static int Dry; internal static int Wet; internal static float Line; internal static bool OnTidewater() { SelectableLevel val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.currentLevel : null); if ((Object)(object)val != (Object)null && val.sceneName != null) { return val.sceneName.StartsWith("Tidewater"); } return false; } [HarmonyPostfix] private static void Postfix(RoundManager __instance) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (OnTidewater() && __instance.outsideAINodes != null && __instance.outsideAINodes.Length != 0 && !((Object)(object)__instance.outsideAINodes[0] == (Object)null) && (_doneFor != __instance.outsideAINodes || __instance.outsideAIDryNodes == null || __instance.outsideAIDryNodes.Length != Dry)) { float num = Mathf.Max(2.1000001f, Tide.Today.Valid ? Tide.HighWater(Tide.Today) : 0f); Line = -7f + num + 0.3f; Vector3 ship = StartOfRound.Instance.shipLandingPosition.position; GameObject[] array = (from n in __instance.outsideAINodes where (Object)(object)n != (Object)null && n.transform.position.y >= Line orderby Vector3.Distance(n.transform.position, ship) select n).ToArray(); GameObject[] array2 = (from n in __instance.outsideAINodes where (Object)(object)n != (Object)null && n.transform.position.y < Line orderby Vector3.Distance(n.transform.position, ship) select n).ToArray(); _doneFor = __instance.outsideAINodes; if (array.Length == 0) { Plugin.Log.LogWarning((object)$"Tidewater: no outside AI node above the tide line (y {Line:F1}); leaving vanilla nodes"); GameObject[] outsideAIDryNodes = __instance.outsideAIDryNodes; Dry = ((outsideAIDryNodes != null) ? outsideAIDryNodes.Length : 0); return; } __instance.outsideAIDryNodes = array; __instance.outsideAIDryNodesUnordered = array.ToArray(); __instance.outsideAIWaterNodes = array2; __instance.outsideAIWaterNodesUnordered = array2.ToArray(); Dry = array.Length; Wet = array2.Length; Plugin.Log.LogInfo((object)$"Tidewater: outside AI nodes above the tide line (y {Line:F1}): {Dry} dry, {Wet} wet"); } } } internal class Eel : MonoBehaviour { public enum St : byte { Den, Patrol, Stalk, Warn, Bite, Retreat } public static Eel Current; public static string Info = ""; public static int Bites; public static int Warnings; public static int Bitten; public static float DragUntil; public static Vector3? TestBait; public const float Length = 3f; public const float WarnTime = 3f; public const float DragTime = 1f; public const float BackOff = 8f; public const float SeeRange = 30f; public const float PatrolSpeed = 1.3f; public const float StalkSpeed = 3.2f; public const float ReachToWarn = 7f; public const float BiteReach = 3.5f; public St State; public Vector3 Pos; public float Yaw; public ulong Target = ulong.MaxValue; private float stateSince; private Random rnd; private Vector3 goal; private float nextLook; private float nextSend; private float speed; private bool placed; private Vector3 netPos; private float netYaw; private bool haveNet; private Transform view; private Transform head; private Transform eyeL; private Transform eyeR; private Transform wake; private Mesh body; private Vector3[] verts; private float swimPhase; private float shownSpeed; private float nextBubble; private float pitch; private St lastShown; private const int Rings = 28; private const int Sides = 10; private static readonly float[] Slide = new float[6] { 35f, -35f, 70f, -70f, 105f, -105f }; internal bool WakeShown; public static int BiteDamage => Plugin.EelBite.Value; private float Surface => Water.OutsideSurface; public static void Create(Transform host) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TidewaterEel"); val.transform.SetParent(host, false); Current = val.AddComponent<Eel>(); } private void OnDestroy() { if (!((Object)(object)Current != (Object)(object)this)) { Current = null; Info = ""; DragUntil = 0f; TestBait = null; } } private void Start() { rnd = new Random((((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.randomMapSeed : 0) + 9161); Stopwatch stopwatch = Stopwatch.StartNew(); BuildView(); Plugin.Log.LogInfo((object)$"Tidewater: eel view {stopwatch.Elapsed.TotalMilliseconds:F0} ms"); } private void Update() { //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_0061: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (!Channel.Built || Channel.Cells == 0 || !Plugin.ChannelThreat.Value) { if ((Object)(object)view != (Object)null) { ((Component)view).gameObject.SetActive(false); } return; } if (!placed) { Pos = Channel.Den; Yaw = 0f; placed = true; netPos = Pos; } if (Net.IsHost) { Think(Time.deltaTime); } else if (haveNet) { Pos = Vector3.Lerp(Pos, netPos, 1f - Mathf.Exp((0f - Time.deltaTime) * 8f)); Yaw = Mathf.LerpAngle(Yaw, netYaw, 1f - Mathf.Exp((0f - Time.deltaTime) * 8f)); } Draw(Time.deltaTime); } private void Set(St s) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (State != s) { State = s; stateSince = Time.time; if (s == St.Warn) { Warnings++; } Plugin.Log.LogInfo((object)string.Format("Tidewater: eel {0}{1} at {2}", s, (Target != ulong.MaxValue) ? (" (player " + Target + ")") : "", Pos)); } } private static bool Prey(PlayerControllerB p, out Vector3 at) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) at = (((Object)(object)p != (Object)null) ? ((Component)p).transform.position : Vector3.zero); if ((Object)(object)p == (Object)null || !p.isPlayerControlled || p.isPlayerDead || p.isInsideFactory || p.isInHangarShipRoom || p.isInElevator) { return false; } float outsideSurface = Water.OutsideSurface; if (float.IsNaN(outsideSurface) || outsideSurface - at.y < 1.3f) { return false; } return Channel.Danger(at); } private bool TargetAt(out Vector3 at) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) at = Vector3.zero; if (Target == 18446744073709551614uL && TestBait.HasValue) { at = TestBait.Value; return Channel.Danger(at); } PlayerControllerB val = Player(Target); if ((Object)(object)val != (Object)null) { return Prey(val, out at); } return false; } private static PlayerControllerB Player(ulong clientId) { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || clientId == ulong.MaxValue) { return null; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && val.actualClientId == clientId) { return val; } } return null; } private void Think(float dt) { //IL_0074: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0153: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_0280: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) float num = Time.time - stateSince; bool flag = Channel.InWindow() && !float.IsNaN(Surface); if (!flag && State != St.Den && State != St.Bite) { Target = ulong.MaxValue; Set(St.Den); } switch (State) { case St.Den: goal = Channel.Den; Move(goal, 1.3f, dt, high: false); if (flag) { goal = Channel.RandomPoint(rnd); Set(St.Patrol); } break; case St.Patrol: if (Flat(Pos - goal) < 1.5f) { goal = Channel.RandomPoint(rnd); } Move(goal, 1.3f, dt, high: false); if (Time.time >= nextLook) { nextLook = Time.time + 0.25f; Look(); } break; case St.Stalk: { if (!TargetAt(out var at3)) { Target = ulong.MaxValue; Set(St.Patrol); break; } Move(at3, 3.2f, dt, high: false); if (Flat(Pos - at3) <= 7f) { Set(St.Warn); } break; } case St.Warn: { if (!TargetAt(out var at2)) { Target = ulong.MaxValue; Set(St.Patrol); break; } float num2 = Mathf.Max(0.2f, 3f - num); Move(at2, Mathf.Clamp(Mathf.Max(0f, Flat(Pos - at2) - 1.2f) / num2, 1.2f, 3.2f), dt, high: true); if (num >= 3f) { if (Flat(Pos - at2) <= 3.5f) { Bite(at2); break; } Target = ulong.MaxValue; Set(St.Patrol); } break; } case St.Bite: { if (TargetAt(out var at) || Target == 18446744073709551614uL) { Pos = Vector3.Lerp(Pos, at + Vector3.down * 0.7f, 1f - Mathf.Exp((0f - dt) * 10f)); Face(at - Pos, dt); } if (!(num >= 1f)) { break; } Vector3 pos = Pos; goal = Channel.RandomPoint(rnd); for (int i = 0; i < 6; i++) { if (!(Flat(goal - pos) < 12f)) { break; } goal = Channel.RandomPoint(rnd); } Target = ulong.MaxValue; Set(St.Retreat); break; } case St.Retreat: Move(goal, 3.2f, dt, high: false); if (num >= 8f) { goal = Channel.RandomPoint(rnd); Set(St.Patrol); } break; } if (Time.time >= nextSend) { nextSend = Time.time + 0.1f; Net.SendEel(this); } Info = $"{State}, {Bites} bites, {Warnings} warnings, at {Pos}"; } private void Look() { //IL_0077: 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_008e: 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_0038: Unknown result type (might be due to invalid IL or missing references) float num = 30f; ulong num2 = ulong.MaxValue; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null) { PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Prey(val, out var at)) { float num3 = Vector3.Distance(at, Pos); if (num3 < num) { num = num3; num2 = val.actualClientId; } } } } if (num2 == ulong.MaxValue && TestBait.HasValue && Channel.Danger(TestBait.Value) && Vector3.Distance(TestBait.Value, Pos) < 30f) { num2 = 18446744073709551614uL; } if (num2 != ulong.MaxValue) { Target = num2; Set(St.Stalk); } } private void Bite(Vector3 at) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) Bites++; Set(St.Bite); if (Target == 18446744073709551614uL) { Plugin.Log.LogInfo((object)$"Tidewater: eel bites the test bait at {at}"); } else if ((Object)(object)NetworkManager.Singleton != (Object)null && Target == 0L) { OnBitten(); } else { Net.SendBite(Target); } } internal static void OnBitten() { //IL_0054: 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) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val == (Object)null) && !val.isPlayerDead) { Bitten++; DragUntil = Time.time + 1f; val.DamagePlayer(BiteDamage, true, true, (CauseOfDeath)6, 0, false, Vector3.down * 4f); Plugin.Log.LogInfo((object)$"Tidewater: bitten by the eel, {BiteDamage} damage, health now {val.health}"); } } private static float Flat(Vector3 d) { d.y = 0f; return ((Vector3)(ref d)).magnitude; } private void Move(Vector3 to, float v, float dt, bool high) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0076: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) Vector3 d = to - Pos; d.y = 0f; float magnitude = ((Vector3)(ref d)).magnitude; speed = Mathf.MoveTowards(speed, (magnitude > 0.2f) ? v : 0f, dt * 3f); if (magnitude > 0.05f) { Face(d, dt); Vector3 val = Quaternion.Euler(0f, Yaw, 0f) * Vector3.forward; float num = Mathf.Min(speed * dt, magnitude); Vector3 val2 = Pos + val * num; if (Channel.InChannel(val2) || State == St.Den || !Channel.InChannel(Pos)) { Pos = val2; } else { float[] slide = Slide; foreach (float num2 in slide) { Vector3 val3 = Pos + Quaternion.Euler(0f, num2, 0f) * val * num; if (Channel.InChannel(val3)) { Pos = val3; break; } } } } float num3 = Channel.BedAt(Pos); float surface = Surface; float num4 = ((float.IsNaN(surface) || float.IsNaN(num3)) ? Pos.y : ((State != St.Den || Channel.InWindow()) ? Mathf.Clamp(high ? (surface - 0.12f) : (surface - 1.3f), num3 + 0.45f, Mathf.Max(num3 + 0.45f, surface - 0.1f)) : (num3 + 0.5f))); Pos.y = Mathf.MoveTowards(Pos.y, num4, dt * (high ? 2.6f : 1.2f)); } private void Face(Vector3 d, float dt) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) d.y = 0f; if (!(((Vector3)(ref d)).sqrMagnitude < 0.0001f)) { float num = Mathf.Atan2(d.x, d.z) * 57.29578f; Yaw = Mathf.MoveTowardsAngle(Yaw, num, dt * 140f); } } internal void Write(FastBufferWriter w) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) ((FastBufferWriter)(ref w)).WriteValueSafe(ref Pos); ((FastBufferWriter)(ref w)).WriteValueSafe<float>(ref Yaw, default(ForPrimitives)); byte state = (byte)State; ((FastBufferWriter)(ref w)).WriteValueSafe<byte>(ref state, default(ForPrimitives)); ((FastBufferWriter)(ref w)).WriteValueSafe<ulong>(ref Target, default(ForPrimitives)); } internal void Read(FastBufferReader r) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0028: 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_003b: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) Vector3 pos = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref pos); float yaw = default(float); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref yaw, default(ForPrimitives)); byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives)); ulong target = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref target, default(ForPrimitives)); netPos = pos; netYaw = yaw; Target = target; if (!haveNet) { Pos = pos; Yaw = yaw; haveNet = true; placed = true; } if ((uint)b != (uint)State) { State = (St)b; stateSince = Time.time; if (State == St.Warn) { Warnings++; } if (State == St.Bite) { Bites++; } } } private void BuildView() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("EelBody"); val.transform.SetParent(((Component)this).transform, false); view = val.transform; body = new Mesh { name = "TidewaterEel" }; body.MarkDynamic(); verts = (Vector3[])(object)new Vector3[282]; List<int> list = new List<int>(); for (int i = 0; i < 27; i++) { for (int j = 0; j < 10; j++) { int num = i * 10 + j; int num2 = i * 10 + (j + 1) % 10; int item = num + 10; int item2 = num2 + 10; list.Add(num); list.Add(item); list.Add(num2); list.Add(num2); list.Add(item); list.Add(item2); } } int num3 = 280; int item3 = num3 + 1; for (int k = 0; k < 10; k++) { list.Add(num3); list.Add(k); list.Add((k + 1) % 10); } int num4 = 270; for (int l = 0; l < 10; l++) { list.Add(item3); list.Add(num4 + (l + 1) % 10); list.Add(num4 + l); } body.vertices = verts; body.triangles = list.ToArray(); val.AddComponent<MeshFilter>().sharedMesh = body; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = Skin(new Color(0.12f, 0.115f, 0.075f), 0.78f, "TidewaterEelSkin"); head = new GameObject("EelHead").transform; head.SetParent(view, false); Material m = Skin(new Color(0.62f, 0.56f, 0.22f), 0.92f, "TidewaterEelEye"); eyeL = Eye(m, -1f); eyeR = Eye(m, 1f); GameObject val2 = new GameObject("EelWake"); val2.transform.SetParent(((Component)this).transform, false); wake = val2.transform; val2.AddComponent<MeshFilter>().sharedMesh = WakeMesh(); MeshRenderer obj = val2.AddComponent<MeshRenderer>(); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).sharedMaterial = Sea.CutoutMat("TidewaterEelWake", new Color(0.8f, 0.85f, 0.88f), 0.2f, Sea.NoiseTex(256, 8, 4, 31, Color.white, 0.5f), 0.5f); val2.SetActive(false); } private Transform Eye(Material m, float side) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val.GetComponent<Collider>()); ((Object)val).name = "EelEye"; val.transform.SetParent(head, false); val.transform.localPosition = new Vector3(0.075f * side, 0.045f, -0.1f); val.transform.localScale = Vector3.one * 0.032f; if ((Object)(object)m != (Object)null) { ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = m; } return val.transform; } private static Material Skin(Color c, float smooth, string name) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) string from; Material val = Sea.LiveLit(wantNormal: false, wantCutout: false, out from); if ((Object)(object)val == (Object)null) { return null; } ((Object)val).name = name; Sea.Neutral(val); val.SetColor("_BaseColor", c); if (val.HasProperty("_Color")) { val.SetColor("_Color", c); } Sea.SetF(val, "_Smoothness", smooth); Sea.SetF(val, "_SmoothnessRemapMin", smooth * 0.7f); Sea.SetF(val, "_SmoothnessRemapMax", smooth); return val; } private static Mesh WakeMesh() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00c4: 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_00e4: 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) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); for (int i = -1; i <= 1; i += 2) { int count = list.Count; Vector3 val = Quaternion.Euler(0f, 180f + 26f * (float)i, 0f) * Vector3.forward; Vector3 val2 = Vector3.Cross(Vector3.up, val); for (int j = 0; j <= 6; j++) { float num = (float)j / 6f; float num2 = Mathf.Lerp(0.14f, 0.5f, num) * (1f - num * num * 0.6f); Vector3 val3 = val * (0.3f + 5f * num); list.Add(val3 - val2 * num2); list.Add(val3 + val2 * num2); list2.Add(new Vector2(0f, num * 2f + (float)i)); list2.Add(new Vector2(0.35f, num * 2f + (float)i)); if (j > 0) { int num3 = count + (j - 1) * 2; list3.Add(num3); list3.Add(num3 + 2); list3.Add(num3 + 1); list3.Add(num3 + 1); list3.Add(num3 + 2); list3.Add(num3 + 3); list3.Add(num3); list3.Add(num3 + 1); list3.Add(num3 + 2); list3.Add(num3 + 1); list3.Add(num3 + 3); list3.Add(num3 + 2); } } } Mesh val4 = new Mesh { name = "TidewaterEelWake" }; val4.SetVertices(list); val4.SetUVs(0, list2); val4.SetTriangles(list3, 0); val4.RecalculateNormals(); val4.RecalculateBounds(); return val4; } private static float Radius(float s) { if (s < 0.06f) { return Mathf.Lerp(0.045f, 0.1f, Mathf.Sqrt(s / 0.06f)); } if (s < 0.2f) { return Mathf.Lerp(0.1f, 0.125f, (s - 0.06f) / 0.14f); } return Mathf.Lerp(0.125f, 0.012f, Mathf.Pow((s - 0.2f) / 0.8f, 1.3f)); } private void Draw(float dt) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_035c: 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_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0286: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)view == (Object)null) { return; } ((Component)view).gameObject.SetActive(true); bool flag = State == St.Den && !Channel.InWindow(); float num = (flag ? 0f : ((State == St.Bite) ? 3.5f : ((State == St.Warn || State == St.Stalk || State == St.Retreat) ? 2.4f : 1f))); shownSpeed = Mathf.MoveTowards(shownSpeed, num, dt * 2f); swimPhase += dt * (1.2f + 2.6f * shownSpeed); float num2 = (flag ? (-62f) : 0f); pitch = Mathf.MoveTowards(pitch, num2, dt * 40f); view.SetPositionAndRotation(Pos, Quaternion.Euler(pitch, Yaw, 0f)); float amp = (flag ? 0.015f : (0.05f + 0.06f * Mathf.Min(shownSpeed, 2f))); for (int i = 0; i < 28; i++) { float num3 = (float)i / 27f; Vector3 val = Spine(num3); Vector3 val2 = Spine(Mathf.Max(0f, num3 - 0.02f)); Vector3 val3 = Spine(Mathf.Min(1f, num3 + 0.02f)); Vector3 val4 = val2 - val3; Vector3 normalized = ((Vector3)(ref val4)).normalized; val4 = Vector3.Cross(Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; float num4 = Radius(num3); float num5 = num4 * 0.82f; float num6 = num4 * 1.12f + ((num3 > 0.55f) ? (0.05f * Mathf.Sin((num3 - 0.55f) / 0.45f * MathF.PI * 0.9f)) : 0f); for (int j = 0; j < 10; j++) { float num7 = (float)j / 10f * MathF.PI * 2f; float num8 = Mathf.Cos(num7); float num9 = Mathf.Sin(num7); float num10 = num6 * ((num8 > 0f) ? 1f : 0.85f); verts[i * 10 + j] = val + normalized2 * (num9 * ((num3 > 0.55f) ? Mathf.Lerp(num5, num5 * 0.45f, (num3 - 0.55f) / 0.45f) : num5)) + Vector3.up * (num8 * num10); } if (i == 1) { head.localPosition = val; } if (i == 1) { head.localRotation = Quaternion.LookRotation(-normalized, Vector3.up) * Quaternion.Euler(0f, 180f, 0f); } } verts[280] = Spine(0f) + new Vector3(0f, -0.01f, 0.03f); verts[281] = Spine(1f) + new Vector3(0f, 0f, -0.04f); body.vertices = verts; body.RecalculateNormals(); body.RecalculateBounds(); float surface = Surface; bool flag2 = !float.IsNaN(surface) && (State == St.Warn || (State == St.Bite && Time.time - stateSince < 0.4f)) && surface - Pos.y < 1.6f; if ((Object)(object)wake != (Object)null) { ((Component)wake).gameObject.SetActive(flag2); WakeShown = flag2; if (flag2) { wake.SetPositionAndRotation(new Vector3(Pos.x, surface + 0.03f, Pos.z), Quaternion.Euler(0f, Yaw, 0f)); } } Splashes current = Splashes.Current; if ((Object)(object)current != (Object)null && !float.IsNaN(surface)) { if (State == St.Warn && Time.time >= nextBubble) { nextBubble = Time.time + 0.1f + Random.value * 0.12f; Vector3 val5 = view.TransformPoint(new Vector3(0f, 0f, -0.4f)); val5.y = surface; current.Bubble(val5 + new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f))); } if (State == St.Bite && lastShown != St.Bite) { current.Splash(new Vector3(Pos.x, surface, Pos.z), 0.6f, hard: false); } } lastShown = State; Vector3 Spine(float s) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) float num11 = s * 3f; return new Vector3(Mathf.Sin(num11 / 1.5f * MathF.PI * 2f - swimPhase) * amp * (0.25f + 2.2f * s * s), 0f, 0f - num11); } } } [HarmonyPatch(typeof(RoundManager), "SetExitIDs")] internal static class ExitIds { [HarmonyPostfix] private static void Postfix(Vector3 mainEntrancePosition) { //IL_007f: 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) if (FlowName() != "PumpingWorksFlow") { return; } EntranceTeleport[] source = Object.FindObjectsOfType<EntranceTeleport>(); EntranceTeleport val = ((IEnumerable<EntranceTeleport>)source).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport t) => t.entranceId == 0 && !t.isEntranceToBuilding)); List<EntranceTeleport> list = source.Where((EntranceTeleport t) => t.entranceId != 0 && !t.isEntranceToBuilding).ToList(); if ((Object)(object)val == (Object)null || list.Count == 0) { return; } float y = ((Component)val).transform.position.y; foreach (EntranceTeleport item in list) { float num = ((Component)item).transform.position.y - y; int num2 = ((num > 4f) ? 3 : ((num > -8f) ? 1 : 2)); Plugin.Log.LogInfo((object)$"Pumping Works fire exit at {num:F1} m: id {item.entranceId} -> {num2}"); item.entranceId = num2; } List<int> list2 = (from t in list group t by t.entranceId into g where g.Count() > 1 select g.Key).ToList(); if (list2.Count > 0) { Plugin.Log.LogWarning((object)("Pumping Works: more than one inside fire exit for id " + string.Join(",", list2))); } } internal static string FlowName() { if ((Object)(object)RoundManager.Instance == (Object)null) { return null; } object value = Traverse.Create((object)RoundManager.Instance).Field("dungeonGenerator").GetValue(); if (value == null) { return null; } object value2 = Traverse.Create(value).Field("Generator").GetValue(); if (value2 == null) { return null; } object value3 = Traverse.Create(value2).Field("DungeonFlow").GetValue(); Object val = (Object)((value3 is Object) ? value3 : null); if (!(val != (Object)null)) { return null; } return val.name; } } internal class Flats : MonoBehaviour { internal struct Site { public byte Kind; public Vector3 At; public float Yaw; } public static Flats Current; public static readonly List<Site> Sites = new List<Site>(); public static bool Built; public static string Info = ""; internal static readonly HashSet<ulong> Anchored = new HashSet<ulong>(); internal static readonly List<(NetworkObject obj, int value)> Spawned = new List<(NetworkObject, int)>(); internal static readonly List<GrabbableObject> Items = new List<GrabbableObject>(); private static List<Site> _pending; private const float ValueBoost = 1.5f; private const float MinSpacing = 28f; private Material _wood; private Material _rock; private Material _pool; private static int Mask { get { if (!((Object)(object)StartOfRound.Instance != (Object)null)) { return -1; } return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } } public static void Create(Transform host) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TidewaterFlats"); val.transform.SetParent(host, false); Current = val.AddComponent<Flats>(); } private void OnDestroy() { if (!((Object)(object)Current != (Object)(object)this)) { Current = null; Built = false; Sites.Clear(); Anchored.Clear(); Spawned.Clear(); Items.Clear(); Info = ""; } } private void Update() { if (!Built && _pending != null) { List<Site> pending = _pending; _pending = null; BuildAll(pending); } if (!Net.IsHost || Anchored.Count <= 0) { return; } List<ulong> list = null; foreach (GrabbableObject item in Items) { if ((Object)(object)item != (Object)null && Anchored.Contains(((NetworkBehaviour)item).NetworkObjectId) && (item.isHeld || item.isHeldByEnemy || item.isPocketed || (Object)(object)item.parentObject != (Object)null)) { (list ?? (list = new List<ulong>())).Add(((NetworkBehaviour)item).NetworkObjectId); } } if (list == null) { return; } foreach (ulong item2 in list) { Anchored.Remove(item2); Plugin.Log.LogInfo((object)$"Tidewater: low-water scrap {item2} picked up, it floats from now on"); } } internal static void HostSpawn() { if ((Object)(object)Current == (Object)null || !Net.IsHost || Built || !Plugin.LowWaterScrap.Value) { return; } RoundManager instance = RoundManager.Instance; StartOfRound instance2 = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance2 == (Object)null) && !((Object)(object)instance.currentLevel == (Object)null)) { Random rnd = new Random(instance2.randomMapSeed + 5711); List<Site> list = PickSites(rnd, Plugin.LowWaterSites.Value); if (list.Count == 0) { Info = "no sites found"; Plugin.Log.LogWarning((object)"Tidewater: no low-water sites found on the flats"); } else { Current.BuildAll(list); Net.SendFlats(list); SpawnScrap(rnd, instance); } } } internal static void Band(out float lo, out float hi) { float num = Tide.LowWater(Tide.Today.Valid ? Tide.Today : new TideDay { Range = 1f }); lo = num + 0.5f; hi = Mathf.Min(num + 1.7f, -0.6f); if (hi < lo + 0.4f) { hi = lo + 0.4f; } } private static List<Site> PickSites(Random rnd, int count) { Band(out var lo, out var hi); string why; List<Site> list = PickSites(rnd, count, lo, hi, out why); Plugin.Log.LogInfo((object)$"Tidewater: low-water sites in band {lo:F1}..{hi:F1} m: {list.Count} ({why})"); if (list.Count < count) { List<Site> list2 = PickSites(rnd, count - list.Count, lo - 0.4f, Mathf.Max(hi + 0.8f, -0.6f), out why, list); Plugin.Log.LogInfo((object)$"Tidewater: widened band {lo - 0.4f:F1}..{Mathf.Max(hi + 0.8f, -0.6f):F1} m: {list2.Count} more ({why})"); list.AddRange(list2); } return list; } private static List<Site> PickSites(Random rnd, int count, float lo, float hi, out string why, List<Site> have = null) { //IL_0054: 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_0059: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; float num9 = float.MaxValue; float num10 = float.MinValue; Vector3 val = (Vector3)(((Object)(object)StartOfRound.Instance.elevatorTransform != (Object)null) ? StartOfRound.Instance.elevatorTransform.position : new Vector3(2.7f, 0f, -14f)); List<Site> list = new List<Site>(); List<Site> list2 = have ?? new List<Site>(); int mask = Mask; RaycastHit hit = default(RaycastHit); for (int i = 0; i < 1500 && list.Count < count; i++) { float num11 = -135f + (float)rnd.NextDouble() * 250f; float num12 = -66f + (float)rnd.NextDouble() * 60f; float x = -77.3f - num11; float z = 16f - num12; if (!Physics.Raycast(new Vector3(x, 40f, z), Vector3.down, ref hit, 120f, mask, (QueryTriggerInteraction)1)) { num++; continue; } Bounds bounds = ((RaycastHit)(ref hit)).collider.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(size.x, size.z) < 40f || ((RaycastHit)(ref hit)).normal.y < 0.94f) { num2++; continue; } float num13 = ((RaycastHit)(ref hit)).point.y - -7f; num9 = Mathf.Min(num9, num13); num10 = Mathf.Max(num10, num13); if (num13 < lo) { num3++; continue; } if (num13 > hi) { num4++; continue; } Vector2 val2 = new Vector2(x - val.x, z - val.z); if (((Vector2)(ref val2)).magnitude > 170f) { num5++; continue; } if (DriftPile.Built) { val2 = new Vector2(x - DriftPile.Centre.x, z - DriftPile.Centre.z); if (((Vector2)(ref val2)).magnitude < 20f) { num6++; continue; } } if (list2.Concat(list).Any(delegate(Site s) { //IL_0001: 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_0024: 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) Vector2 val3 = new Vector2(s.At.x - x, s.At.z - z); return ((Vector2)(ref val3)).magnitude < 28f; })) { num7++; continue; } if (Physics.OverlapBox(((RaycastHit)(ref hit)).point + Vector3.up * 1.8f, new Vector3(4f, 1.4f, 4f), Quaternion.identity, mask, (QueryTriggerInteraction)1).Any((Collider c) => (Object)(object)c != (Object)(object)((RaycastHit)(ref hit)).collider)) { num8++; continue; } byte kind = (byte)((list2.Count + list.Count) % 2); list.Add(new Site { Kind = kind, At = ((RaycastHit)(ref hit)).point, Yaw = (float)rnd.NextDouble() * 360f }); } why = $"no hit {num}, not ground {num2}, too low {num3}, too high {num4}, far {num5}, by the pile {num6}, too close {num7}, blocked {num8}; ground {num9:F1}..{num10:F1} m"; return list; } private static void SpawnScrap(Random rnd, RoundManager rm) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_0170: Unknown result type (might be due to invalid IL or missing references) List<SpawnableItemWithRarity> pool = rm.currentLevel.spawnableScrap.Where((SpawnableItemWithRarity s) => s != null && (Object)(object)s.spawnableItem != (Object)null && (Object)(object)s.spawnableItem.spawnPrefab != (Object)null && s.rarity > 0 && !s.spawnableItem.twoHanded).ToList(); if (pool.Count == 0) { pool = rm.currentLevel.spawnableScrap.Where((SpawnableItemWithRarity s) => s != null && (Object)(object)s.spawnableItem != (Object)null && (Object)(object)s.spawnableItem.spawnPrefab != (Object)null && s.rarity > 0).ToList(); } if (pool.Count == 0) { Plugin.Log.LogWarning((object)"Tidewater: no scrap to put on the flats"); return; } int total = pool.Sum((SpawnableItemWithRarity s) => s.rarity); int num = 0; foreach (Site site in Sites) { int num2 = ((site.Kind != 0) ? 1 : 2); for (int num3 = 0; num3 < num2; num3++) { Item val = Pick(); Vector3 val2 = Quaternion.Euler(0f, site.Yaw, 0f) * ((site.Kind == 0) ? new Vector3((num3 == 0) ? 0.25f : (-0.2f), 0f, (num3 == 0) ? 0.9f : (-1f)) : new Vector3(0.5f * (float)(num3 + 1), 0f, 0.3f)); Vector3 val3 = site.At + val2 + Vector3.up * 1.2f; GameObject val4 = Object.Instantiate<GameObject>(val.spawnPrefab, val3, Quaternion.identity, rm.spawnedScrapContainer); GrabbableObject component = val4.GetComponent<GrabbableObject>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val4); continue; } ((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation); component.fallTime = 0f; component.isInFactory = false; int num4 = (component.scrapValue = Mathf.Max(1, (int)((float)rnd.Next(val.minValue, Mathf.Max(val.minValue + 1, val.maxValue)) * rm.scrapValueMultiplier * 1.5f))); ((NetworkBehaviour)component).NetworkObject.Spawn(false); Spawned.Add((((NetworkBehaviour)component).NetworkObject, num4)); Items.Add(component); Anchored.Add(((NetworkBehaviour)component).NetworkObjectId); num += num4; } } Info += $", {Items.Count} items worth {num}"; Plugin.Log.LogInfo((object)string.Format("Tidewater: low-water scrap: {0} (total {1})", string.Join(", ", Items.Select((GrabbableObject i) => $"{i.itemProperties.itemName} ${i.scrapValue}")), num)); Item Pick() { int num5 = rnd.Next(total); foreach (SpawnableItemWithRarity item in pool) { num5 -= item.rarity; if (num5 < 0) { return item.spawnableItem; } } return pool[0].spawnableItem; } } internal static void OnSites(List<Site> sites) { if ((Object)(object)Current != (Object)null && !Built) { Current.BuildAll(sites); } else { _pending = sites; } } private void BuildAll(List<Site> sites) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00dd: Unknown result type (might be due to invalid IL or missing references) Sites.Clear(); Sites.AddRange(sites); int num = LayerMask.NameToLayer("Room"); if (num < 0) { num = 0; } _wood = WetWood(); _rock = RockMat(); _pool = PoolMat(); int num2 = 0; foreach (Site site in sites) { Transform transform = new GameObject((site.Kind == 0) ? ("LowWaterWreck" + num2) : ("TidePool" + num2)).transform; transform.SetParent(((Component)this).transform, false); transform.position = site.At; transform.rotation = Quaternion.Euler(0f, site.Yaw, 0f); Random rnd = new Random(1000 + num2 * 77 + Mathf.RoundToInt(site.At.x * 10f)); if (site.Kind == 0) { Wreck(transform, rnd, num); } else { Pool(transform, rnd, num); } Node(transform, (site.Kind == 0) ? "Wreck" : "Tide pool", (site.Kind == 0) ? 2.2f : 1f); num2++; } Built = true; Band(out var lo, out var hi); Info = string.Format("{0} wrecks, {1} tide pools on ground {2} m (band {3:F1}..{4:F1})", sites.Count((Site s) => s.Kind == 0), sites.Count((Site s) => s.Kind == 1), string.Join(" ", sites.Select((Site s) => (s.At.y - -7f).ToString("+0.0;-0.0"))), lo, hi); Plugin.Log.LogInfo((object)("Tidewater: low-water sites: " + Info)); } private static void Node(Transform root, string header, float up) { //IL_00