using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("IsometricView")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+627c93de35fe4ea8fc7db780adf6d890daf2a24a")] [assembly: AssemblyProduct("IsometricView")] [assembly: AssemblyTitle("IsometricView")] [assembly: AssemblyVersion("0.2.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 IsometricView { internal static class BallisticAim { internal static bool Solve(Vector3 delta, float speed, float gravity, float drag, float dt, out Vector3 direction) { direction = ((delta.LengthSquared() > 1E-06f) ? Vector3.Normalize(delta) : Vector3.UnitZ); float num = (float)Math.Sqrt(delta.X * delta.X + delta.Z * delta.Z); if (num < 0.01f || speed < 0.1f) { return false; } float num2 = 0f; float num3 = 0f; bool flag = false; for (int i = 0; i <= 32; i++) { float num4 = -1.45f + (float)i * 0.090625f; if (!Height(num, delta.Y, num4, speed, gravity, drag, dt, out var height)) { flag = false; continue; } float num5 = height - delta.Y; if (flag && num3 <= 0f && num5 >= 0f) { float num6 = num2; float num7 = num4; for (int j = 0; j < 18; j++) { float num8 = (num6 + num7) * 0.5f; if (!Height(num, delta.Y, num8, speed, gravity, drag, dt, out height)) { return false; } if (height < delta.Y) { num6 = num8; } else { num7 = num8; } } float num9 = (num6 + num7) * 0.5f; direction = new Vector3(delta.X / num * (float)Math.Cos(num9), (float)Math.Sin(num9), delta.Z / num * (float)Math.Cos(num9)); return true; } flag = true; num2 = num4; num3 = num5; } return false; } private static bool Height(float range, float targetHeight, float angle, float speed, float gravity, float drag, float dt, out float height) { dt = Math.Max(0.005f, dt); Vector3 position = Vector3.Zero; Vector3 velocity = new Vector3((float)Math.Cos(angle) * speed, (float)Math.Sin(angle) * speed, 0f); for (int i = 0; (float)i < Math.Min(6000f, 30f / dt); i++) { Vector3 vector = position; CameraMath.StepProjectile(ref position, ref velocity, gravity, drag, dt); if (position.X >= range) { height = vector.Y + (position.Y - vector.Y) * (range - vector.X) / (position.X - vector.X); return true; } if (velocity.Y < 0f && position.Y < targetHeight) { height = position.Y; return true; } if (velocity.X <= 0.001f) { break; } } height = 0f; return false; } } internal readonly struct BuildingPart { internal readonly Vector3 Min; internal readonly Vector3 Max; internal BuildingPart(Vector3 min, Vector3 max) { Min = min; Max = max; } internal bool Touches(BuildingPart other, float gap) { return Min.X <= other.Max.X + gap && Max.X + gap >= other.Min.X && Min.Y <= other.Max.Y + gap && Max.Y + gap >= other.Min.Y && Min.Z <= other.Max.Z + gap && Max.Z + gap >= other.Min.Z; } } internal static class BuildingLayout { internal static HashSet Connected(IList parts, int seed) { HashSet hashSet = new HashSet(); if (seed < 0 || seed >= parts.Count) { return hashSet; } Dictionary<(int, int, int), List> dictionary = new Dictionary<(int, int, int), List>(); List list = new List(); for (int i = 0; i < parts.Count; i++) { BuildingPart buildingPart = parts[i]; int num = Bin(buildingPart.Min.X - 0.2f); int num2 = Bin(buildingPart.Min.Y - 0.2f); int num3 = Bin(buildingPart.Min.Z - 0.2f); int num4 = Bin(buildingPart.Max.X + 0.2f); int num5 = Bin(buildingPart.Max.Y + 0.2f); int num6 = Bin(buildingPart.Max.Z + 0.2f); if ((long)(num4 - num + 1) * (long)(num5 - num2 + 1) * (num6 - num3 + 1) > 4096) { list.Add(i); continue; } for (int j = num; j <= num4; j++) { for (int k = num2; k <= num5; k++) { for (int l = num3; l <= num6; l++) { (int, int, int) key = (j, k, l); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new List()); } value.Add(i); } } } } Queue queue = new Queue(); hashSet.Add(seed); queue.Enqueue(seed); while (queue.Count > 0) { int index = queue.Dequeue(); BuildingPart buildingPart2 = parts[index]; SortedSet sortedSet = new SortedSet(list); int num7 = Bin(buildingPart2.Min.X - 0.2f); int num8 = Bin(buildingPart2.Min.Y - 0.2f); int num9 = Bin(buildingPart2.Min.Z - 0.2f); int num10 = Bin(buildingPart2.Max.X + 0.2f); int num11 = Bin(buildingPart2.Max.Y + 0.2f); int num12 = Bin(buildingPart2.Max.Z + 0.2f); if ((long)(num10 - num7 + 1) * (long)(num11 - num8 + 1) * (num12 - num9 + 1) > 4096) { for (int m = 0; m < parts.Count; m++) { sortedSet.Add(m); } } else { for (int n = num7; n <= num10; n++) { for (int num13 = num8; num13 <= num11; num13++) { for (int num14 = num9; num14 <= num12; num14++) { if (!dictionary.TryGetValue((n, num13, num14), out var value2)) { continue; } foreach (int item in value2) { sortedSet.Add(item); } } } } } foreach (int item2 in sortedSet) { if (!hashSet.Contains(item2) && buildingPart2.Touches(parts[item2], 0.35f)) { hashSet.Add(item2); queue.Enqueue(item2); } } } return hashSet; } private static int Bin(float value) { return (int)Math.Floor(value / 2f); } internal static bool FrontSupport(Vector2 point, Vector2 anchor, Vector2 camera, IList boundaries) { float num = float.PositiveInfinity; bool flag = false; foreach (RoomWall boundary in boundaries) { Vector2 value = point - boundary.Center; Vector2 value2 = new Vector2(0f - boundary.Normal.Y, boundary.Normal.X); float num2 = Vector2.Dot(value, boundary.Normal); float num3 = Math.Max(0f, Math.Abs(Vector2.Dot(value, value2)) - boundary.HalfWidth); float num4 = num2 * num2 + num3 * num3; bool flag2 = CutawayMath.Front(boundary.Normal, boundary.Center, anchor, camera, previous: false); if (num4 < num - 0.001f) { num = num4; flag = flag2; } else if (Math.Abs(num4 - num) <= 0.001f) { flag = flag || flag2; } } return float.IsPositiveInfinity(num) ? CutawayMath.FrontFrame(point, anchor, camera, previous: false) : flag; } internal static List FrontSections(Vector2 min, Vector2 max, Vector2 anchor, Vector2 camera, IList boundaries) { bool x = max.X - min.X >= max.Y - min.Y; float num = (x ? min.X : min.Y); float num2 = (x ? max.X : max.Y); Vector2 center = (min + max) / 2f; List list = new List(); bool flag = Side(num); float num3 = num; float num4 = num; int num5 = Math.Max(1, Math.Min(256, (int)Math.Ceiling((num2 - num) / 0.125f))); for (int i = 1; i <= num5; i++) { float num6 = num + (num2 - num) * (float)i / (float)num5; bool flag2 = Side(num6); if (flag2 != flag) { float num7 = num4; float num8 = num6; for (int j = 0; j < 20; j++) { float num9 = (num7 + num8) / 2f; if (Side(num9) == flag) { num7 = num9; } else { num8 = num9; } } float num10 = (num7 + num8) / 2f; if (num10 - num3 > 0.0001f) { list.Add(new SectionRun(num3, num10, flag, x)); } num3 = num10; flag = flag2; } num4 = num6; } if (num2 - num3 > 0.0001f) { list.Add(new SectionRun(num3, num2, flag, x)); } if (list.Count == 0) { list.Add(new SectionRun(num, num2, flag, x)); } return list; bool Side(float at) { return FrontSupport(x ? new Vector2(at, center.Y) : new Vector2(center.X, at), anchor, camera, boundaries); } } internal static List CameraSections(Vector2 min, Vector2 max, Vector2 player, Vector2 camera) { bool x = max.X - min.X >= max.Y - min.Y; float num = (x ? min.X : min.Y); float num2 = (x ? max.X : max.Y); Vector2 center = (min + max) / 2f; Vector2 vector = Vector2.Normalize(camera - player); float num3 = (x ? vector.X : vector.Y); float num4 = (x ? vector.Y : vector.X); List list = new List(); if (Math.Abs(num3) > 0.0001f) { float num5 = (x ? player.X : player.Y) - ((x ? (center.Y - player.Y) : (center.X - player.X)) * num4 + 0.15f) / num3; if (num5 > num + 0.0001f && num5 < num2 - 0.0001f) { list.Add(new SectionRun(num, num5, Side((num + num5) / 2f), x)); list.Add(new SectionRun(num5, num2, Side((num2 + num5) / 2f), x)); return list; } } list.Add(new SectionRun(num, num2, Side((num + num2) / 2f), x)); return list; bool Side(float at) { return CutawayMath.CameraSide(x ? new Vector2(at, center.Y) : new Vector2(center.X, at), player, camera); } } internal static List SupportPlanes(Vector2 min, Vector2 max, IList walls) { List list = new List(); Vector2 vector = (min + max) / 2f; bool flag = max.X - min.X >= max.Y - min.Y; for (int i = 0; i < 5; i++) { float num = (float)i / 4f; Vector2 point = (flag ? new Vector2(min.X + (max.X - min.X) * num, vector.Y) : new Vector2(vector.X, min.Y + (max.Y - min.Y) * num)); float num2 = float.PositiveInfinity; foreach (RoomWall wall in walls) { num2 = Math.Min(num2, ViewOcclusion.DistanceSquared(wall, point)); } foreach (RoomWall wall2 in walls) { if (ViewOcclusion.DistanceSquared(wall2, point) <= num2 + 0.001f && !list.Contains(wall2)) { list.Add(wall2); } } } return list; } internal static List ViewSections(Vector2 min, Vector2 max, Vector2 player, Vector2 camera, IList walls) { bool x = max.X - min.X >= max.Y - min.Y; float num = (x ? min.X : min.Y); float num2 = (x ? max.X : max.Y); Vector2 center = (min + max) / 2f; List list = new List(); bool flag = Side(num); float num3 = num; float num4 = num; int num5 = Math.Max(1, Math.Min(128, (int)Math.Ceiling((num2 - num) / 0.125f))); for (int i = 1; i <= num5; i++) { float num6 = num + (num2 - num) * (float)i / (float)num5; bool flag2 = Side(num6); if (flag2 != flag) { float num7 = num4; float num8 = num6; for (int j = 0; j < 18; j++) { float num9 = (num7 + num8) / 2f; if (Side(num9) == flag) { num7 = num9; } else { num8 = num9; } } float num10 = (num7 + num8) / 2f; if (num10 - num3 > 0.0001f) { list.Add(new SectionRun(num3, num10, flag, x)); } num3 = num10; flag = flag2; } num4 = num6; } if (num2 - num3 > 0.0001f) { list.Add(new SectionRun(num3, num2, flag, x)); } if (list.Count == 0) { list.Add(new SectionRun(num, num2, flag, x)); } return list; bool Side(float at) { Vector2 point = (x ? new Vector2(at, center.Y) : new Vector2(center.X, at)); float num11 = float.PositiveInfinity; bool flag3 = false; foreach (RoomWall wall in walls) { float num12 = ViewOcclusion.DistanceSquared(wall, point); bool flag4 = ViewOcclusion.WallBetween(wall, player, camera); if (num12 < num11 - 0.001f) { num11 = num12; flag3 = flag4; } else if (Math.Abs(num12 - num11) <= 0.001f) { flag3 = flag3 || flag4; } } return float.IsPositiveInfinity(num11) ? CutawayMath.CameraSide(point, player, camera) : flag3; } } } internal readonly struct SectionRun { internal readonly float From; internal readonly float To; internal readonly bool Front; internal readonly bool AlongX; internal SectionRun(float from, float to, bool front, bool alongX) { From = from; To = to; Front = front; AlongX = alongX; } } internal static class CameraMath { internal const float IsometricPitch = 35.26439f; internal static float NormalizeYaw(float yaw) { return (yaw % 360f + 360f) % 360f; } internal static float SnapDiagonalYaw(float yaw) { return (float)Math.Floor(NormalizeYaw(yaw) / 90f) * 90f + 45f; } internal static float TurnDiagonal(float yaw, int direction) { return NormalizeYaw(SnapDiagonalYaw(yaw) + (float)(Math.Sign(direction) * 90)); } internal static int ArrowTurn(bool left, bool right) { return (left != right) ? (left ? 1 : (-1)) : 0; } internal static float SimulatedDistance(float framingDistance, float nativeFov, float simulatedFov) { return framingDistance * (float)(Math.Tan((double)nativeFov * Math.PI / 360.0) / Math.Tan((double)simulatedFov * Math.PI / 360.0)); } internal static (float Distance, float Fov) InteriorProjection(float framingDistance, float nativeFov, float simulatedFov) { float num = SimulatedDistance(framingDistance, nativeFov, simulatedFov); if (num <= 30f) { return (Distance: num, Fov: simulatedFov); } double num2 = (double)framingDistance * Math.Tan((double)nativeFov * Math.PI / 360.0); return (Distance: 30f, Fov: (float)(Math.Atan(num2 / 30.0) * 360.0 / Math.PI)); } internal static float Zoom(float distance, float wheel, float sensitivity) { return Math.Max(3f, Math.Min(30f, distance - Math.Max(-1f, Math.Min(1f, wheel)) * sensitivity)); } internal static void StepProjectile(ref Vector3 position, ref Vector3 velocity, float gravity, float drag, float dt) { velocity -= Vector3.UnitY * gravity * dt; float num = velocity.Length(); if (num > 0f) { velocity -= velocity / num * (num * num * drag * dt); } position += velocity * dt; } } internal sealed class CameraTurn { private readonly Queue turns = new Queue(); private float start; private float target; private float elapsed; private bool moving; internal float Value { get; private set; } internal void Reset(float yaw) { Value = (start = (target = yaw)); elapsed = 0f; moving = false; turns.Clear(); } internal void Turn(int sign) { if (sign != 0) { if (moving) { turns.Enqueue(Math.Sign(sign)); } else { Start(Math.Sign(sign)); } } } private void Start(int direction) { start = Value; target = start + (float)(direction * 90); elapsed = 0f; moving = true; } internal float Advance(float dt, float duration) { duration = Math.Max(0.01f, duration); dt = Math.Max(0f, dt); while (moving && dt > 0f) { float num = Math.Min(dt, duration - elapsed); dt -= num; elapsed += num; float num2 = Math.Min(1f, elapsed / duration); Value = start + (target - start) * num2 * num2 * (3f - 2f * num2); if (elapsed < duration) { break; } Value = target; moving = false; if (turns.Count > 0) { Start(turns.Dequeue()); } } return CameraMath.NormalizeYaw(Value); } } internal static class ControlMath { internal static Vector3 Horizontal(Vector3 value, Vector3 fallback) { value.Y = 0f; return (value.LengthSquared() > 1E-06f) ? Vector3.Normalize(value) : fallback; } internal static Vector3 Movement(Vector3 input, Vector3 cameraForward) { input.Y = 0f; if (input.LengthSquared() > 1f) { input = Vector3.Normalize(input); } Vector3 vector = Horizontal(cameraForward, Vector3.UnitZ); Vector3 vector2 = Vector3.Cross(Vector3.UnitY, vector); return vector * input.Z + vector2 * input.X; } internal static Vector3 Rebase(Vector3 world, Vector3 lookForward) { Vector3 vector = Horizontal(lookForward, Vector3.UnitZ); return new Vector3(Vector3.Dot(world, Vector3.Cross(Vector3.UnitY, vector)), 0f, Vector3.Dot(world, vector)); } internal static float FollowWeight(float responsiveness, float dt) { return 1f - (float)Math.Exp((0f - Math.Max(0f, responsiveness)) * Math.Max(0f, dt)); } internal static Vector3 AimDirection(Vector3 spawn, Vector3 point, Vector3 fallback) { Vector3 value = point - spawn; return (value.LengthSquared() > 1E-06f) ? Vector3.Normalize(value) : Vector3.Normalize(fallback); } internal static bool PlanePoint(Vector3 origin, Vector3 direction, float height, out Vector3 point) { point = default(Vector3); if (Math.Abs(direction.Y) < 1E-05f) { return false; } float num = (height - origin.Y) / direction.Y; if (num < 0f || float.IsNaN(num) || float.IsInfinity(num)) { return false; } point = origin + direction * num; return true; } } internal sealed class DragState { private bool waitingForRelease; internal float Step(bool allowed, bool held, float delta, float sensitivity, bool invert) { if (!allowed) { waitingForRelease = held; return 0f; } if (!held) { waitingForRelease = false; return 0f; } return waitingForRelease ? 0f : (delta * sensitivity * (float)((!invert) ? 1 : (-1))); } internal void Reset() { waitingForRelease = true; } } internal sealed class BowReleaseGate { private bool requireRelease; internal bool Step(bool allowed, bool held) { if (!allowed) { requireRelease = true; } bool result = !allowed || requireRelease; if (allowed && !held) { requireRelease = false; } return result; } } internal enum BuildingKind { Other, Wall, Floor, Roof, Stair, Frame } internal static class CutawayMath { internal static BuildingKind Kind(string name, bool door = false, bool furniture = false, bool construction = false) { if (furniture) { return BuildingKind.Other; } name = (name ?? "").ToLowerInvariant(); if (name.Contains("portal") || name.Contains("teleport")) { return BuildingKind.Other; } if (name.Contains("stair") || name.Contains("step") || name.Contains("ladder") || name.Contains("ramp")) { return BuildingKind.Stair; } if (door || name.Contains("wall") || name.Contains("gate") || name.Contains("window") || name.Contains("arch") || name.Contains("door")) { return BuildingKind.Wall; } if (name.Contains("beam") || name.Contains("pole") || name.Contains("pillar") || name.Contains("column")) { return BuildingKind.Frame; } if (name.Contains("roof") || name.Contains("shingle")) { return BuildingKind.Roof; } if (name.Contains("floor") || name.Contains("ceiling")) { return BuildingKind.Floor; } return construction ? BuildingKind.Frame : BuildingKind.Other; } internal static RoomOpening Opening(string name, bool door) { name = (name ?? "").ToLowerInvariant(); if (door || name.Contains("door") || name.Contains("gate") || name.Contains("arch")) { return RoomOpening.Passage; } return name.Contains("window") ? RoomOpening.Window : RoomOpening.Solid; } internal static bool WallOnFloor(float min, float max, float origin, float floor, RoomOpening opening) { if (max <= floor + 0.3f) { return false; } if (min < floor + 1.15f && max > floor + 0.65f) { return true; } if (opening == RoomOpening.Passage) { return Math.Abs(origin - floor) < 0.6f && min < floor + 3f; } return opening == RoomOpening.Window && min < floor + 1.8f && origin < floor + 1.8f && max > floor + 0.65f; } internal static bool Structural(BuildingKind kind) { return kind == BuildingKind.Wall || kind == BuildingKind.Frame || kind == BuildingKind.Floor || kind == BuildingKind.Roof || kind == BuildingKind.Stair; } internal static bool CameraSide(Vector2 point, Vector2 player, Vector2 camera, float margin = 0.15f) { Vector2 value = camera - player; return value.LengthSquared() > 0.0001f && Vector2.Dot(point - player, Vector2.Normalize(value)) >= 0f - margin; } internal static bool FrontFrame(Vector2 center, Vector2 inside, Vector2 cameraDirection, bool previous) { Vector2 normal = center - inside; return normal.LengthSquared() < 0.0625f || Front(normal, center, inside, cameraDirection, previous); } internal static bool Front(Vector2 normal, Vector2 wall, Vector2 inside, Vector2 cameraDirection, bool previous) { if (Vector2.Dot(normal, wall - inside) < 0f) { normal = -normal; } float num = Vector2.Dot(Vector2.Normalize(normal), Vector2.Normalize(cameraDirection)); return num > 0.04f || (num >= -0.04f && previous); } internal static float Coverage(float radiusFraction, float feather, float minimumVisibility) { float num = 1f - Math.Clamp(feather, 0.05f, 1f); float num2 = Math.Clamp((radiusFraction - num) / Math.Max(0.01f, 1f - num), 0f, 1f); return (1f - minimumVisibility) * (1f - num2 * num2 * (3f - 2f * num2)); } internal static float Threshold(int x, int y) { int num = 0; for (int i = 0; i < 3; i++) { int num2 = (x >> i) & 1; int num3 = (y >> i) & 1; num = num * 4 + ((num2 ^ num3) * 2 + num3); } return ((float)num + 0.5f) / 64f; } } internal sealed class FloorTracker { private float candidate; private float stableTime; private bool initialized; internal float Floor { get; private set; } internal float Reveal { get; private set; } internal bool OnStairs { get; private set; } internal void Reset() { initialized = false; OnStairs = false; stableTime = 0f; } internal void Update(bool grounded, bool stair, float supportY, float dt) { if (!initialized) { float floor = (Reveal = (candidate = supportY)); Floor = floor; initialized = true; } if (!grounded) { return; } OnStairs = stair; if (stair) { stableTime = 0f; } else { if (Math.Abs(supportY - candidate) > 0.15f) { candidate = supportY; stableTime = 0f; } stableTime += Math.Max(0f, dt); if (stableTime >= 0.2f) { Floor = candidate; } } Reveal = Floor; } } internal enum DungeonFace { Keep, CutWall, HideRoof } internal readonly struct DungeonSlice : IEquatable { internal readonly Vector2 Interior; internal readonly Vector2 TowardCamera; internal readonly float Floor; internal readonly bool HideRoof; internal DungeonSlice(Vector2 interior, Vector2 towardCamera, float floor, bool hideRoof) { Interior = interior; TowardCamera = towardCamera; Floor = floor; HideRoof = hideRoof; } public bool Equals(DungeonSlice other) { return Interior == other.Interior && TowardCamera == other.TowardCamera && Floor == other.Floor && HideRoof == other.HideRoof; } public override bool Equals(object obj) { return obj is DungeonSlice other && Equals(other); } public override int GetHashCode() { return HashCode.Combine(Interior, TowardCamera, Floor, HideRoof); } internal DungeonFace Face(Vector3 a, Vector3 b, Vector3 c, float cutHeight) { if (Math.Max(a.Y, Math.Max(b.Y, c.Y)) <= cutHeight) { return DungeonFace.Keep; } Vector3 vector = Vector3.Cross(b - a, c - a); float num = vector.Length(); if (num < 1E-05f) { return DungeonFace.Keep; } float num2 = Math.Abs(vector.Y) / num; if (num2 > 0.65f) { return (HideRoof && Math.Min(a.Y, Math.Min(b.Y, c.Y)) >= Floor + 1.8f) ? DungeonFace.HideRoof : DungeonFace.Keep; } Vector2 vector2 = new Vector2((a.X + b.X + c.X) / 3f, (a.Z + b.Z + c.Z) / 3f); return (Vector2.Dot(vector2 - Interior, TowardCamera) >= -0.15f && CutawayMath.Front(new Vector2(vector.X, vector.Z), vector2, Interior, TowardCamera, previous: false)) ? DungeonFace.CutWall : DungeonFace.Keep; } } internal static class HoverHintText { internal static string RemapUse(string text, string nativeUse, string primary) { text = (text ?? string.Empty).Replace("$KEY_Use", primary); if (string.IsNullOrEmpty(nativeUse) || nativeUse == primary) { return text; } return Regex.Replace(text, "\\[[^\\]\\r\\n]*\\]", (Match bracket) => Regex.Replace(bracket.Value, "<[^>]*>|[^<]+", (Match part) => part.Value.StartsWith("<", StringComparison.Ordinal) ? part.Value : Regex.Replace(part.Value, "(? primary))); } internal static string Combine(string primary, string secondary) { return string.IsNullOrWhiteSpace(secondary) ? primary : (string.IsNullOrWhiteSpace(primary) ? secondary : (primary.TrimEnd() + "\n" + secondary.TrimStart())); } } internal static class InteractionMath { internal static bool FaceCursor(float movementSquared, bool attacking) { return movementSquared < 0.0001f || attacking; } internal static bool PrecisionEnabled(bool mode, bool local, bool ranged) { return mode && local && ranged; } internal static float FadeProgress(float current, bool obstructing, float dt, float duration) { float num = Math.Max(0f, dt) / Math.Max(0.01f, duration); return obstructing ? Math.Min(1f, current + num) : Math.Max(0f, current - num); } internal static float Opacity(float progress, float minimum) { float num = Math.Max(0f, Math.Min(1f, progress)); return 1f - (1f - minimum) * num * num * (3f - 2f * num); } internal static Vector3 NearRayOrigin(Vector3 origin, Vector3 direction, Vector3 focus) { return origin + direction * Math.Max(0f, Vector3.Dot(focus - origin, direction) - 20f); } } internal static class OcclusionRules { internal const float NearbyCharacterDistance = 12f; internal const float NearCameraRadius = 1.1f; internal const float NearOpacity = 0.3f; internal const float HaloOpacity = 0.82f; internal const int MaximumHalos = 6; internal static bool Eligible(float viewportX, float viewportY, float depth, float distanceToPlayer) { return depth > 0f && distanceToPlayer <= 12f && Math.Abs(viewportX - 0.5f) <= 0.24f && Math.Abs(viewportY - 0.5f) <= 0.28f; } internal static float Radius(float depth, float verticalFovDegrees) { float val = 1.3f / (2f * Math.Max(0.1f, depth) * (float)Math.Tan((double)verticalFovDegrees * Math.PI / 360.0)); return Math.Max(0.035f, Math.Min(0.095f, val)); } internal static float HaloAlpha(float radiusFraction) { return (radiusFraction <= 0.55f) ? 0.82f : (0.82f * Math.Max(0f, Math.Min(1f, (1f - radiusFraction) / 0.45f))); } } internal static class PatchCompatibility { internal static bool IsKnownCompatible(string targetType, string targetMethod, string owner, string patchKind, string patchType, string patchMethod, string assemblyVersion) { return (targetType == "GameCamera" && targetMethod == "UpdateCamera" && owner == "dellarion.valheim.vanillabuildswap" && patchKind == "transpiler" && patchType == "VanillaBuildSwap.UpgradeController" && patchMethod == "CameraInput" && (assemblyVersion == "0.1.3.0" || assemblyVersion == "0.1.4.0")) || (targetType == "GameCamera" && targetMethod == "UpdateMouseCapture" && owner == "_shudnal.ConfigurationManager" && patchKind == "prefix" && patchType == "ConfigurationManager.ConfigurationManager+NativeCursor_WindowOverride" && patchMethod == "Prefix" && assemblyVersion == "1.1.27.0"); } } internal static class RemotePlayerVisibility { internal static float Opacity(float distance, bool publicPosition, float fullDistance = 10f, float hiddenDistance = 30f) { if (publicPosition || distance <= fullDistance) { return 1f; } if (distance >= hiddenDistance || hiddenDistance <= fullDistance) { return 0f; } float num = Math.Clamp((distance - fullDistance) / (hiddenDistance - fullDistance), 0f, 1f); float num2 = num * num * (3f - 2f * num); return 1f - num2; } } internal static class RevealMath { internal static Vector4 Crop(Vector2 center, Vector2 radius, int width, int height) { int num = Math.Min(width, Math.Max(64, (int)Math.Ceiling(radius.X * 2f * (float)width / 64f) * 64)); int num2 = Math.Min(height, Math.Max(64, (int)Math.Ceiling(radius.Y * 2f * (float)height / 64f) * 64)); int num3 = Math.Clamp((int)Math.Floor(center.X * (float)width - (float)num / 2f), 0, width - num); int num4 = Math.Clamp((int)Math.Floor(center.Y * (float)height - (float)num2 / 2f), 0, height - num2); return new Vector4((float)num3 / (float)width, (float)num4 / (float)height, (float)num / (float)width, (float)num2 / (float)height); } internal static float Weight(Vector2 point, Vector2 center, Vector2 radius, float feather, float progress, float visibility) { if (radius.X <= 0f || radius.Y <= 0f) { return 0f; } return CutawayMath.Coverage(((point - center) / radius).Length(), feather, visibility) * (1f - InteractionMath.Opacity(progress, 0f)); } } internal enum RoomOpening { Solid, Passage, Window } internal readonly struct RoomCover { internal readonly Vector2 Min; internal readonly Vector2 Max; internal RoomCover(Vector2 min, Vector2 max) { Min = min; Max = max; } internal bool Contains(Vector2 point) { return point.X >= Min.X && point.X <= Max.X && point.Y >= Min.Y && point.Y <= Max.Y; } } internal readonly struct RoomWall { internal readonly Vector2 Center; internal readonly Vector2 Normal; internal readonly float HalfWidth; internal readonly float HalfDepth; internal readonly RoomOpening Opening; internal RoomWall(Vector2 center, Vector2 normal, float halfWidth, RoomOpening opening = RoomOpening.Solid, float halfDepth = 0.05f) { Center = center; Normal = Vector2.Normalize(normal); HalfWidth = halfWidth; Opening = opening; HalfDepth = halfDepth; } internal bool Crosses(Vector2 a, Vector2 b) { float num = Vector2.Dot(a - Center, Normal); float num2 = Vector2.Dot(b - Center, Normal); if ((num > 0f && num2 > 0f) || (num < 0f && num2 < 0f) || Math.Abs(num - num2) < 1E-05f) { return false; } Vector2 vector = a + (b - a) * (num / (num - num2)); return Math.Abs(Vector2.Dot(vector - Center, new Vector2(0f - Normal.Y, Normal.X))) <= HalfWidth + 0.08f; } } internal sealed class RoomLayout { internal const float Cell = 0.5f; private readonly HashSet<(int X, int Y)> cells = new HashSet<(int, int)>(); private readonly Queue<(int X, int Y)> queue = new Queue<(int, int)>(); private static readonly (int X, int Y)[] Steps = new(int, int)[4] { (1, 0), (0, 1), (-1, 0), (0, -1) }; private Vector2 origin; private int seedX; private int seedY; internal Vector2 Center { get; private set; } internal bool Enclosed { get; private set; } internal bool RoofBounded { get; private set; } internal void Resolve(Vector2 player, float radius, IList walls, IList covers = null) { seedX = (int)Math.Floor(player.X / 0.5f); seedY = (int)Math.Floor(player.Y / 0.5f); origin = new Vector2(((float)seedX + 0.5f) * 0.5f, ((float)seedY + 0.5f) * 0.5f); List list = SealOpenings(walls); RoofBounded = false; Enclosed = list.Count >= 3 && Flood(radius, list, null); if (!Enclosed && Covered(player, covers)) { RoofBounded = true; Enclosed = Flood(radius, list, covers); } if (!Enclosed) { cells.Clear(); Center = origin; return; } long num = 0L; long num2 = 0L; foreach (var cell in cells) { num += seedX + cell.X; num2 += seedY + cell.Y; } Center = new Vector2((float)(((double)num / (double)cells.Count + 0.5) * 0.5), (float)(((double)num2 / (double)cells.Count + 0.5) * 0.5)); } private bool Flood(float radius, IList walls, IList covers) { cells.Clear(); queue.Clear(); int num = Math.Max(2, (int)Math.Floor(radius / 0.5f)); cells.Add((0, 0)); queue.Enqueue((0, 0)); while (queue.Count > 0) { (int, int) tuple = queue.Dequeue(); (int, int)[] steps = Steps; for (int i = 0; i < steps.Length; i++) { (int, int) tuple2 = steps[i]; (int, int) item = (tuple.Item1 + tuple2.Item1, tuple.Item2 + tuple2.Item2); if (cells.Contains(item)) { continue; } Vector2 a = origin + new Vector2(tuple.Item1, tuple.Item2) * 0.5f; Vector2 vector = origin + new Vector2(item.Item1, item.Item2) * 0.5f; if (covers != null && !Covered(vector, covers)) { continue; } bool flag = false; foreach (RoomWall wall in walls) { if (wall.Crosses(a, vector)) { flag = true; break; } } if (!flag) { if (Math.Abs(item.Item1) >= num || Math.Abs(item.Item2) >= num) { queue.Clear(); return false; } cells.Add(item); queue.Enqueue(item); } } } return true; } internal static List SealOpenings(IList walls) { List list = new List(walls); for (int i = 0; i < walls.Count; i++) { for (int j = i + 1; j < walls.Count; j++) { RoomWall roomWall = walls[i]; RoomWall roomWall2 = walls[j]; if (!(Math.Abs(Vector2.Dot(roomWall.Normal, roomWall2.Normal)) < 0.995f) && !(Math.Abs(Vector2.Dot(roomWall2.Center - roomWall.Center, roomWall.Normal)) > 0.15f)) { Vector2 vector = new Vector2(0f - roomWall.Normal.Y, roomWall.Normal.X); float value = Vector2.Dot(roomWall2.Center - roomWall.Center, vector); float num = Math.Abs(value) - roomWall.HalfWidth - roomWall2.HalfWidth; if (!(num <= 0.15f) && !(num > 2.1f)) { float num2 = Math.Sign(value); list.Add(new RoomWall(roomWall.Center + vector * num2 * (roomWall.HalfWidth + num / 2f), roomWall.Normal, num / 2f, RoomOpening.Passage)); } } } } return list; } private static bool Covered(Vector2 point, IList covers) { if (covers != null) { foreach (RoomCover cover in covers) { if (cover.Contains(point)) { return true; } } } return false; } internal bool Contains(Vector2 point) { if (!Enclosed) { return false; } return cells.Contains(((int)Math.Floor(point.X / 0.5f) - seedX, (int)Math.Floor(point.Y / 0.5f) - seedY)); } internal bool Near(Vector2 point, float halfWidth) { if (Contains(point)) { return true; } (int, int)[] steps = Steps; for (int i = 0; i < steps.Length; i++) { (int, int) tuple = steps[i]; if (Contains(point + new Vector2(tuple.Item1, tuple.Item2) * Math.Max(0.5f, halfWidth))) { return true; } } return false; } internal bool Intersects(Vector2 min, Vector2 max) { foreach (var cell in cells) { Vector2 vector = origin + new Vector2(cell.X, cell.Y) * 0.5f; if (vector.X + 0.25f >= min.X && vector.X - 0.25f <= max.X && vector.Y + 0.25f >= min.Y && vector.Y - 0.25f <= max.Y) { return Enclosed; } } return false; } } internal enum RoomDeparture { Keep, Boundary, Floor } internal sealed class RoomResidence { private float outside; internal float Floor { get; private set; } internal Vector2 Anchor { get; private set; } internal void Commit(float floor, Vector2 anchor) { Floor = floor; Anchor = anchor; outside = 0f; } internal RoomDeparture Check(bool contains, bool grounded, bool stairs, float floor, float dt) { if (!grounded || stairs) { outside = 0f; return RoomDeparture.Keep; } if (Math.Abs(floor - Floor) > 0.65f) { return RoomDeparture.Floor; } outside = (contains ? 0f : (outside + Math.Max(0f, dt))); return (outside >= 0.35f) ? RoomDeparture.Boundary : RoomDeparture.Keep; } } internal static class ScreenSpaceMath { internal static Vector2 Viewport(Vector2 pointer, float displayWidth, float displayHeight) { return new Vector2(pointer.X / Math.Max(1f, displayWidth), pointer.Y / Math.Max(1f, displayHeight)); } internal static bool InViewport(Vector3 point) { return point.Z > 0f && point.X >= 0f && point.X <= 1f && point.Y >= 0f && point.Y <= 1f; } internal static bool InReach(float squaredDistance) { return squaredDistance <= 9f; } internal static Vector2 StealthOffsets(float nameTop, float gap, float barHeight, float iconHeight) { return new Vector2(nameTop + gap + barHeight / 2f, nameTop + gap * 2f + barHeight + iconHeight / 2f); } internal static float Halo(Vector2 point, Vector2 center, float aspect, float radius) { Vector2 vector = point - center; vector.X *= aspect; float num = Math.Clamp((vector.Length() / radius - 0.55f) / 0.45f, 0f, 1f); return num * num * (3f - 2f * num); } } internal readonly struct SectionEdge { internal readonly Vector3 A; internal readonly Vector3 B; internal readonly int Material; internal SectionEdge(Vector3 a, Vector3 b, int material) { A = a; B = b; Material = material; } } internal readonly struct SectionVertex { internal readonly Vector3 Position; internal readonly Vector2 Uv; internal readonly int Edge; internal readonly float Along; internal SectionVertex(Vector3 position, Vector2 uv, int edge, float along) { Position = position; Uv = uv; Edge = edge; Along = along; } } internal sealed class SectionSurface { internal readonly List Vertices = new List(); internal readonly List Materials = new List(); } internal static class SectionCap { internal const float Epsilon = 0.0001f; internal static SectionSurface Build(IList source, Vector3 normal, bool convexOpen = false) { SectionSurface sectionSurface = new SectionSurface(); if (source.Count == 0) { return sectionSurface; } normal = Vector3.Normalize(normal); Vector3 vector = Vector3.Normalize(Vector3.Cross((Math.Abs(normal.Y) < 0.9f) ? Vector3.UnitY : Vector3.UnitZ, normal)); Vector3 vector2 = Vector3.Cross(normal, vector); float num = 0.0001f; foreach (SectionEdge item in source) { num = Math.Max(num, Math.Max(MaxAbs(item.A), MaxAbs(item.B)) * 5E-07f); } List list = new List(); List<(int, int, int)> list2 = new List<(int, int, int)>(); Dictionary<(long, long, long), List> buckets = new Dictionary<(long, long, long), List>(); Dictionary<(int, int), int> dictionary = new Dictionary<(int, int), int>(); for (int i = 0; i < source.Count; i++) { int num2 = Weld(source[i].A, list, buckets, num); int num3 = Weld(source[i].B, list, buckets, num); if (num2 != num3) { (int, int) key = (Math.Min(num2, num3), Math.Max(num2, num3)); if (dictionary.TryGetValue(key, out var value)) { list2[value] = (-1, -1, -1); dictionary.Remove(key); } else { dictionary.Add(key, list2.Count); list2.Add((num2, num3, i)); } } } list2.RemoveAll(((int A, int B, int Source) edge) => edge.Source < 0); int[] array = new int[list.Count]; foreach (var item2 in list2) { array[item2.Item1]++; array[item2.Item2]++; } int[] array2 = array; foreach (int num5 in array2) { if ((num5 & 1) != 0) { if (convexOpen) { return Convex(source, normal, vector, vector2); } throw new InvalidOperationException("The section contour is open; retaining the original solid."); } } List list3 = new List(); foreach (Vector3 item3 in list) { list3.Add(Vector3.Dot(item3, vector2)); } list3.Sort(); List list4 = new List(); foreach (float item4 in list3) { if (list4.Count == 0 || item4 - list4[list4.Count - 1] > 0.0001f) { list4.Add(item4); } } List<(float, int)> list5 = new List<(float, int)>(); for (int num6 = 1; num6 < list4.Count; num6++) { float num7 = list4[num6 - 1]; float num8 = list4[num6]; float num9 = (num7 + num8) * 0.5f; list5.Clear(); for (int num10 = 0; num10 < list2.Count; num10++) { (int, int, int) tuple = list2[num10]; float num11 = Vector3.Dot(list[tuple.Item1], vector2); float num12 = Vector3.Dot(list[tuple.Item2], vector2); if (!(num9 <= Math.Min(num11, num12)) && !(num9 >= Math.Max(num11, num12))) { Vector3 vector3 = Vector3.Lerp(list[tuple.Item1], list[tuple.Item2], (num9 - num11) / (num12 - num11)); list5.Add((Vector3.Dot(vector3, vector), num10)); } } list5.Sort(delegate((float X, int Edge) tuple4, (float X, int Edge) tuple5) { int num14 = tuple4.X.CompareTo(tuple5.X); return (num14 != 0) ? num14 : tuple4.Edge.CompareTo(tuple5.Edge); }); if ((list5.Count & 1) != 0) { throw new InvalidOperationException("The section has an unmatched boundary."); } for (int num13 = 0; num13 < list5.Count; num13 += 2) { if (!(list5[num13 + 1].Item1 - list5[num13].Item1 <= 0.0001f)) { (int, int, int) tuple2 = list2[list5[num13].Item2]; (int, int, int) tuple3 = list2[list5[num13 + 1].Item2]; SectionVertex a = At(source, tuple2.Item3, num7, vector, vector2); SectionVertex b = At(source, tuple3.Item3, num7, vector, vector2); SectionVertex sectionVertex = At(source, tuple3.Item3, num8, vector, vector2); SectionVertex c = At(source, tuple2.Item3, num8, vector, vector2); Add(sectionSurface, a, b, sectionVertex, source[tuple2.Item3].Material, normal); Add(sectionSurface, a, sectionVertex, c, source[tuple2.Item3].Material, normal); } } } return sectionSurface; } private static SectionSurface Convex(IList source, Vector3 normal, Vector3 u, Vector3 v) { List list = new List(); for (int i = 0; i < source.Count; i++) { int[] array = new int[2] { 0, 1 }; foreach (int num in array) { Vector3 vector = ((num == 0) ? source[i].A : source[i].B); list.Add(new SectionVertex(vector, new Vector2(Vector3.Dot(vector, u), Vector3.Dot(vector, v)), i, num)); } } list.Sort(delegate(SectionVertex a, SectionVertex b) { int num4 = a.Uv.X.CompareTo(b.Uv.X); return (num4 != 0) ? num4 : a.Uv.Y.CompareTo(b.Uv.Y); }); List list2 = new List(); foreach (SectionVertex item in list) { if (list2.Count == 0 || Vector2.DistanceSquared(item.Uv, list2[list2.Count - 1].Uv) > 9.999999E-09f) { list2.Add(item); } } List list3 = new List(); foreach (SectionVertex item2 in list2) { while (list3.Count >= 2 && Cross(list3[list3.Count - 2], list3[list3.Count - 1], item2) <= 0f) { list3.RemoveAt(list3.Count - 1); } list3.Add(item2); } int count = list3.Count; for (int num2 = list2.Count - 2; num2 >= 0; num2--) { SectionVertex sectionVertex = list2[num2]; while (list3.Count > count && Cross(list3[list3.Count - 2], list3[list3.Count - 1], sectionVertex) <= 0f) { list3.RemoveAt(list3.Count - 1); } list3.Add(sectionVertex); } if (list3.Count > 1) { list3.RemoveAt(list3.Count - 1); } SectionSurface sectionSurface = new SectionSurface(); for (int num3 = 1; num3 < list3.Count - 1; num3++) { Add(sectionSurface, list3[0], list3[num3], list3[num3 + 1], source[list3[0].Edge].Material, normal); } return sectionSurface; static float Cross(SectionVertex a, SectionVertex b, SectionVertex c) { return (b.Uv.X - a.Uv.X) * (c.Uv.Y - a.Uv.Y) - (b.Uv.Y - a.Uv.Y) * (c.Uv.X - a.Uv.X); } } private static float MaxAbs(Vector3 p) { return Math.Max(Math.Abs(p.X), Math.Max(Math.Abs(p.Y), Math.Abs(p.Z))); } private static int Weld(Vector3 point, List points, Dictionary<(long, long, long), List> buckets, float epsilon) { long num = (long)Math.Floor(point.X / epsilon); long num2 = (long)Math.Floor(point.Y / epsilon); long num3 = (long)Math.Floor(point.Z / epsilon); int num4 = int.MaxValue; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { for (int k = -1; k <= 1; k++) { if (!buckets.TryGetValue((num + i, num2 + j, num3 + k), out var value)) { continue; } foreach (int item in value) { if (item < num4 && Vector3.DistanceSquared(point, points[item]) <= epsilon * epsilon) { num4 = item; } } } } } if (num4 != int.MaxValue) { return num4; } int count = points.Count; points.Add(point); if (!buckets.TryGetValue((num, num2, num3), out var value2)) { value2 = (buckets[(num, num2, num3)] = new List()); } value2.Add(count); return count; } private static SectionVertex At(IList edges, int index, float y, Vector3 u, Vector3 v) { SectionEdge sectionEdge = edges[index]; float num = Vector3.Dot(sectionEdge.A, v); float num2 = Vector3.Dot(sectionEdge.B, v); float num3 = Math.Clamp((y - num) / (num2 - num), 0f, 1f); Vector3 vector = Vector3.Lerp(sectionEdge.A, sectionEdge.B, num3); return new SectionVertex(vector, new Vector2(Vector3.Dot(vector, u), Vector3.Dot(vector, v)), index, num3); } private static void Add(SectionSurface surface, SectionVertex a, SectionVertex b, SectionVertex c, int material, Vector3 normal) { float num = Vector3.Dot(Vector3.Cross(b.Position - a.Position, c.Position - a.Position), normal); if (!(Math.Abs(num) <= 9.999999E-09f)) { surface.Vertices.Add(a); surface.Vertices.Add((num > 0f) ? b : c); surface.Vertices.Add((num > 0f) ? c : b); surface.Materials.Add(material); } } } internal sealed class StateLease { private readonly Func exists; private readonly Func read; private readonly Action apply; private readonly Action restore; private readonly List<(T item, TState state)> saved = new List<(T, TState)>(); private readonly HashSet seen = new HashSet(); internal StateLease(Func exists, Func read, Action apply, Action restore) { this.exists = exists; this.read = read; this.apply = apply; this.restore = restore; } internal void Begin(IEnumerable items) { End(); try { foreach (T item in items) { if (exists(item) && seen.Add(item)) { TState val = read(item); saved.Add((item, val)); apply(item, val); } } } catch { End(); throw; } } internal void End() { Exception ex = null; try { for (int num = saved.Count - 1; num >= 0; num--) { try { if (exists(saved[num].item)) { restore(saved[num].item, saved[num].state); } } catch (Exception ex2) { ex = ex ?? ex2; } } } finally { saved.Clear(); seen.Clear(); } if (ex != null) { throw new InvalidOperationException("A render state could not be restored.", ex); } } } internal readonly struct StoreyFloor { internal readonly Vector2 Min; internal readonly Vector2 Max; internal readonly float Bottom; internal readonly float Top; internal readonly bool Hidden; internal StoreyFloor(Vector2 min, Vector2 max, float bottom, float top, bool hidden) { Min = min; Max = max; Bottom = bottom; Top = top; Hidden = hidden; } } internal static class StoreyVisibility { internal static bool Hidden(Vector3 origin, float lowestSolidPoint, float playerFloor, IList floors) { float num = Math.Min(origin.Y, lowestSolidPoint); float num2 = float.NegativeInfinity; bool flag = false; foreach (StoreyFloor floor in floors) { if (!(origin.X < floor.Min.X - 0.05f) && !(origin.X > floor.Max.X + 0.05f) && !(origin.Z < floor.Min.Y - 0.05f) && !(origin.Z > floor.Max.Y + 0.05f) && !(num < floor.Bottom - 0.05f) && !(num < floor.Top - 0.35f)) { bool flag2 = floor.Hidden && floor.Bottom > playerFloor + 0.8f; if (floor.Top > num2 + 0.001f) { num2 = floor.Top; flag = flag2; } else if (Math.Abs(floor.Top - num2) <= 0.001f) { flag = flag && flag2; } } } return flag; } } internal sealed class TargetSelection where T : class { internal T Target { get; private set; } internal void Click(T candidate) { if (candidate != null) { Target = candidate; } } internal void Validate(Func valid) { if (Target != null && !valid(Target)) { Clear(); } } internal void Clear() { Target = null; } } internal static class TemporaryVisibility { internal static void Render(IEnumerable objects, Func exists, Func read, Action write, Action render) { Dictionary dictionary = new Dictionary(); try { foreach (T @object in objects) { if (exists(@object) && !dictionary.ContainsKey(@object)) { dictionary.Add(@object, read(@object)); write(@object, arg2: true); } } render(); } finally { foreach (KeyValuePair item in dictionary) { if (exists(item.Key)) { write(item.Key, item.Value); } } } } } internal readonly struct ClipPoint { internal readonly Vector3 Position; internal readonly Vector3 Weights; internal readonly bool OnPlane; internal ClipPoint(Vector3 position, Vector3 weights, bool onPlane = false) { Position = position; Weights = weights; OnPlane = onPlane; } } internal static class TriangleClip { internal static void Below(Vector3 a, Vector3 b, Vector3 c, Vector4 plane, bool below, List result) { result.Clear(); ClipPoint[] array = new ClipPoint[3] { new ClipPoint(a, Vector3.UnitX), new ClipPoint(b, Vector3.UnitY), new ClipPoint(c, Vector3.UnitZ) }; for (int i = 0; i < 3; i++) { ClipPoint clipPoint = array[i]; ClipPoint clipPoint2 = array[(i + 1) % 3]; float num = Distance(clipPoint.Position, plane); float num2 = Distance(clipPoint2.Position, plane); bool flag = (below ? (num <= 0f) : (num >= 0f)); bool flag2 = (below ? (num2 <= 0f) : (num2 >= 0f)); if (flag) { result.Add(new ClipPoint(clipPoint.Position, clipPoint.Weights, Math.Abs(num) <= 0.0001f)); } if (flag != flag2) { float amount = num / (num - num2); result.Add(new ClipPoint(Vector3.Lerp(clipPoint.Position, clipPoint2.Position, amount), Vector3.Lerp(clipPoint.Weights, clipPoint2.Weights, amount), onPlane: true)); } } } private static float Distance(Vector3 p, Vector4 plane) { return (float)((double)p.X * (double)plane.X + (double)p.Y * (double)plane.Y + (double)p.Z * (double)plane.Z + (double)plane.W); } } internal static class ViewOcclusion { internal static bool WallBetween(RoomWall wall, Vector2 player, Vector2 camera) { float num = Vector2.Dot(player - wall.Center, wall.Normal); float num2 = Vector2.Dot(camera - wall.Center, wall.Normal); float num3 = Math.Max(0.02f, wall.HalfDepth) + 0.04f; return Math.Abs(num) > num3 && num * num2 < 0f; } internal static float DistanceSquared(RoomWall wall, Vector2 point) { Vector2 value = point - wall.Center; Vector2 value2 = new Vector2(0f - wall.Normal.Y, wall.Normal.X); float num = Vector2.Dot(value, wall.Normal); float num2 = Math.Max(0f, Math.Abs(Vector2.Dot(value, value2)) - wall.HalfWidth); return num * num + num2 * num2; } internal static bool NearSegment(Vector3 point, Vector3 player, Vector3 camera, float margin) { Vector3 vector = camera - player; float num = vector.LengthSquared(); float num2 = ((num > 0.0001f) ? Math.Clamp(Vector3.Dot(point - player, vector) / num, 0f, 1f) : 0f); return Vector3.DistanceSquared(point, player + vector * num2) <= margin * margin; } internal static bool CameraCanopy(Vector4 rectangle, float nearest, float playerDepth, float distanceFromPlayer, bool containsCamera) { if (nearest >= playerDepth - 0.25f || distanceFromPlayer < 6f) { return false; } float num = Math.Max(0f, Math.Min(0.95f, rectangle.Z) - Math.Max(0.05f, rectangle.X)); float num2 = Math.Max(0f, Math.Min(0.95f, rectangle.W) - Math.Max(0.05f, rectangle.Y)); return num * num2 >= 0.15f && (containsCamera || nearest < playerDepth * 0.8f); } } internal enum PartView { Native, Protected, Hidden, Cut } internal readonly struct PartVisibility : IEquatable { internal readonly PartView View; internal readonly float Height; internal readonly SectionRun[] Sections; internal PartVisibility(PartView view, float height = 0f, IList sections = null) { View = view; Height = height; Sections = null; if (sections != null) { Sections = new SectionRun[sections.Count]; for (int i = 0; i < sections.Count; i++) { Sections[i] = sections[i]; } } } public bool Equals(PartVisibility other) { if (View == other.View && Height == other.Height) { SectionRun[] sections = Sections; int num = ((sections != null) ? sections.Length : 0); SectionRun[] sections2 = other.Sections; if (num == ((sections2 != null) ? sections2.Length : 0)) { if (Sections != null) { for (int i = 0; i < Sections.Length; i++) { SectionRun sectionRun = Sections[i]; SectionRun sectionRun2 = other.Sections[i]; if (sectionRun.From != sectionRun2.From || sectionRun.To != sectionRun2.To || sectionRun.Front != sectionRun2.Front || sectionRun.AlongX != sectionRun2.AlongX) { return false; } } } return true; } } return false; } public override bool Equals(object value) { return value is PartVisibility other && Equals(other); } public override int GetHashCode() { return ((int)View * 397) ^ Height.GetHashCode(); } } internal sealed class VisibilityOverlay { private readonly Dictionary baseline = new Dictionary(); private readonly Dictionary overrides = new Dictionary(); private readonly Dictionary current = new Dictionary(); private readonly HashSet affected = new HashSet(); private readonly List changed = new List(); private readonly IEqualityComparer comparer; internal IReadOnlyDictionary Current => current; internal VisibilityOverlay(IEqualityComparer comparer = null) { this.comparer = comparer ?? EqualityComparer.Default; } internal bool TryOverride(TKey key, out TState value) { return overrides.TryGetValue(key, out value); } internal bool TryBaseline(TKey key, out TState value) { return baseline.TryGetValue(key, out value); } internal void Reset(IEnumerable> values) { Clear(); foreach (KeyValuePair value in values) { baseline.Add(value.Key, value.Value); current.Add(value.Key, value.Value); } } internal IReadOnlyList Replace(IReadOnlyDictionary next) { affected.Clear(); changed.Clear(); foreach (TKey key in overrides.Keys) { affected.Add(key); } foreach (TKey key2 in next.Keys) { affected.Add(key2); } foreach (TKey item in affected) { TState value; bool flag = current.TryGetValue(item, out value); TState value2; bool flag2 = next.TryGetValue(item, out value2) || baseline.TryGetValue(item, out value2); if (flag != flag2 || (flag && !comparer.Equals(value, value2))) { if (flag2) { current[item] = value2; } else { current.Remove(item); } changed.Add(item); } } overrides.Clear(); foreach (KeyValuePair item2 in next) { overrides.Add(item2.Key, item2.Value); } return changed; } internal void Clear() { baseline.Clear(); overrides.Clear(); current.Clear(); affected.Clear(); changed.Clear(); } } internal static class VisualRules { internal static bool Bush(string prefab, bool tree, bool character) { return !tree && !character && (Contains(prefab, "bush") || Contains(prefab, "shrub")); } internal static bool Natural(string prefab, bool tree) { return tree || Contains(prefab, "bush") || Contains(prefab, "shrub") || Contains(prefab, "rock") || Contains(prefab, "boulder"); } private static bool Contains(string value, string part) { return value != null && value.IndexOf(part, StringComparison.OrdinalIgnoreCase) >= 0; } internal static bool Backdrop(float width, float height, float screenWidth, float screenHeight) { return width >= screenWidth * 0.85f && height >= screenHeight * 0.85f; } internal static bool Foreground(bool hidden, bool natural, bool character, float depthFromPlayer) { return !character && (hidden || (natural && depthFromPlayer < -1f)); } internal static bool CoversPlayer(float minX, float minY, float maxX, float maxY, float nearestDepth, float playerDepth, float x, float y, float radiusX, float radiusY) { if (nearestDepth >= playerDepth - 0.25f || radiusX <= 0f || radiusY <= 0f) { return false; } float num = Math.Max(minX - x, Math.Max(0f, x - maxX)) / radiusX; float num2 = Math.Max(minY - y, Math.Max(0f, y - maxY)) / radiusY; return num * num + num2 * num2 <= 1f; } } internal sealed class WorldClickState { private int lastPress = -1; private bool pressLatched; private float expires; internal bool Consumed { get; private set; } internal bool Pending { get; private set; } internal bool Begin(bool held, bool down, int frame) { if (!held && !down) { Consumed = false; pressLatched = false; return false; } if (!down || pressLatched || lastPress == frame) { return false; } pressLatched = true; lastPress = frame; return true; } internal void Consume() { Consumed = true; } internal void Defer(float now) { Pending = true; expires = now + 1f; } internal bool Complete(float now, bool allowed, bool inventoryVisible, bool reopened) { if (!Pending) { return false; } if (!allowed || reopened || now >= expires) { Pending = false; return false; } if (inventoryVisible) { return false; } Pending = false; return true; } internal void Reset() { Consumed = false; Pending = false; pressLatched = false; lastPress = -1; } } internal sealed class BowTrajectoryPreview { private const int Capacity = 512; private const float LineWidth = 0.035f; private static readonly int HitMask = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "terrain", "character", "character_net", "character_ghost", "hitbox", "vehicle", "viewblock" }); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[64]; private readonly Vector3[] points = (Vector3[])(object)new Vector3[512]; private LineRenderer line; private Material material; private Player lastPlayer; private ItemData lastWeapon; private Transform origin; internal void Update(Camera camera, Player player) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_0199: 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_01a4: 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_01bb: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: 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) ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); if (!((Character)player).IsDrawingBow() || currentWeapon?.m_shared?.m_attack == null || !currentWeapon.m_shared.m_attack.m_bowDraw) { Hide(); return; } Attack attack = currentWeapon.m_shared.m_attack; ItemData ammoItem = ((Humanoid)player).GetAmmoItem(); ProjectileAim.Parameters(player, attack, ammoItem, ((Humanoid)player).GetAttackDrawPercentage(), out var projectile, out var speed); if (!Object.op_Implicit((Object)(object)projectile)) { Hide(); return; } if ((Object)(object)lastPlayer != (Object)(object)player || lastWeapon != currentWeapon || !Object.op_Implicit((Object)(object)origin)) { lastPlayer = player; lastWeapon = currentWeapon; origin = ((!string.IsNullOrEmpty(attack.m_attackOriginJoint) && Object.op_Implicit((Object)(object)((Character)player).GetVisual())) ? Utils.FindChild(((Character)player).GetVisual().transform, attack.m_attackOriginJoint, (IterativeSearchType)0) : ((Component)player).transform); } if (!Object.op_Implicit((Object)(object)origin)) { Hide(); return; } Transform transform = ((Component)player).transform; Vector3 val = origin.position + transform.up * attack.m_attackHeight + transform.forward * attack.m_attackRange + transform.right * attack.m_attackOffset; Vector3 val2 = ProjectileAim.Direction(camera, player, val, projectile, speed); Vector3 position = CameraRelativeMovement.ToNumerics(val); Vector3 velocity = CameraRelativeMovement.ToNumerics(val2 * speed); points[0] = val; int num = 1; float dt = Mathf.Max(0.001f, Time.fixedDeltaTime); for (int i = 1; i < 512; i++) { Vector3 val3 = CameraRelativeMovement.ToUnity(position); CameraMath.StepProjectile(ref position, ref velocity, projectile.m_gravity, projectile.m_drag, dt); Vector3 val4 = CameraRelativeMovement.ToUnity(position); if (Trace(val3, val4, projectile.m_rayRadius, player, out var point)) { points[num++] = point; break; } points[num++] = val4; } if (EnsureLine()) { Image val5 = (Object.op_Implicit((Object)(object)Hud.instance) ? Hud.instance.m_crosshairBow : null); Color val6 = (Object.op_Implicit((Object)(object)val5) ? ((Graphic)val5).color : Color.white); line.startColor = val6; line.endColor = val6; line.positionCount = num; for (int j = 0; j < num; j++) { line.SetPosition(j, points[j]); } ((Renderer)line).enabled = true; } } private bool Trace(Vector3 from, Vector3 to, float radius, Player player, out Vector3 point) { //IL_0001: 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_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) Vector3 val = to - from; int num = ((radius > 0f) ? Physics.SphereCastNonAlloc(from, radius, ((Vector3)(ref val)).normalized, hits, ((Vector3)(ref val)).magnitude, HitMask, (QueryTriggerInteraction)1) : Physics.RaycastNonAlloc(from, ((Vector3)(ref val)).normalized, hits, ((Vector3)(ref val)).magnitude, HitMask, (QueryTriggerInteraction)1)); float num2 = float.PositiveInfinity; point = to; for (int i = 0; i < num; i++) { RaycastHit val2 = hits[i]; if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() == (Object)(object)player) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; point = ((RaycastHit)(ref val2)).point; } } return num2 < float.PositiveInfinity; } private bool EnsureLine() { //IL_0045: 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_0058: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)line)) { return true; } Shader val = Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val) || !val.isSupported) { return false; } material = new Material(val) { hideFlags = (HideFlags)61 }; GameObject val2 = new GameObject("IsometricView trajectory") { hideFlags = (HideFlags)61 }; line = val2.AddComponent(); ((Renderer)line).sharedMaterial = material; line.useWorldSpace = true; line.startWidth = 0.035f; line.endWidth = 0.035f; ((Renderer)line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)line).receiveShadows = false; ((Renderer)line).enabled = false; return true; } internal void Hide() { if (Object.op_Implicit((Object)(object)line)) { ((Renderer)line).enabled = false; } } internal void Dispose() { if (Object.op_Implicit((Object)(object)line)) { Object.Destroy((Object)(object)((Component)line).gameObject); } if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } line = null; material = null; lastPlayer = null; lastWeapon = null; origin = null; } } internal static class CameraRelativeMovement { internal static Vector3 ToNumerics(Vector3 value) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector3(value.x, value.y, value.z); } internal static Vector3 ToUnity(Vector3 value) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(value.X, value.Y, value.Z); } internal static Vector3 Rebase(Vector3 input, Vector3 forward, Vector3 look) { //IL_0000: 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_0011: 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) return ToUnity(ControlMath.Rebase(ControlMath.Movement(ToNumerics(input), ToNumerics(forward)), ToNumerics(look))); } } internal sealed class CenterCrosshairVisibility { private Graphic image; private bool originalEnabled; internal void Hide(Graphic nativeImage) { if ((Object)(object)image != (Object)(object)nativeImage) { Restore(); image = nativeImage; if (Object.op_Implicit((Object)(object)image)) { originalEnabled = ((Behaviour)image).enabled; } } if (Object.op_Implicit((Object)(object)image)) { ((Behaviour)image).enabled = false; } } internal void Restore() { if (Object.op_Implicit((Object)(object)image)) { ((Behaviour)image).enabled = originalEnabled; } image = null; } } internal static class ChestFilterTooltip { internal const string PluginId = "dellarion.valheim.vanillachestitemcategory"; private static Action track; private static Action flush; internal static void Install(Harmony harmony) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("dellarion.valheim.vanillachestitemcategory", out var value) || !Object.op_Implicit((Object)(object)value.Instance)) { return; } try { Type type = ((object)value.Instance).GetType().Assembly.GetType("VanillaChestItemCategory.HudHoverFilterIcon"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "Track", new Type[2] { typeof(Hud), typeof(Player) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "Flush", Type.EmptyTypes, (Type[])null); if (!(methodInfo == null) && !(methodInfo2 == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(ChestFilterTooltip), "UseCursorTooltip", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); track = (Action)methodInfo.CreateDelegate(typeof(Action)); flush = (Action)methodInfo2.CreateDelegate(typeof(Action)); } } } catch (Exception error) { Report(error); } } private static IEnumerable UseCursorTooltip(IEnumerable instructions) { List list = new List(instructions); FieldInfo objB = AccessTools.Field(typeof(Hud), "m_hoverName"); MethodInfo methodInfo = AccessTools.Method(typeof(Humanoid), "GetHoverObject", (Type[])null, (Type[])null); int num = 0; int num2 = 0; foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldfld && object.Equals(item.operand, objB)) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(ChestFilterTooltip), "Label", (Type[])null, (Type[])null); num++; } else if ((item.opcode == OpCodes.Callvirt || item.opcode == OpCodes.Call) && item.operand is MethodInfo methodInfo2 && methodInfo2.GetBaseDefinition() == methodInfo.GetBaseDefinition()) { item.opcode = OpCodes.Call; item.operand = AccessTools.Method(typeof(ChestFilterTooltip), "Target", (Type[])null, (Type[])null); num2++; } } if (num != 1 || num2 != 1) { throw new InvalidOperationException("Unrecognized ChestItemFilter tooltip layout."); } return list; } private static TextMeshProUGUI Label(Hud hud) { CursorInteractionController cursorInteractionController = Plugin.Instance?.Interactions; return Object.op_Implicit((Object)(object)cursorInteractionController?.DisplayedLabel) ? cursorInteractionController.DisplayedLabel : hud.m_hoverName; } private static GameObject Target(Humanoid player) { CursorInteractionController cursorInteractionController = Plugin.Instance?.Interactions; return Object.op_Implicit((Object)(object)cursorInteractionController?.DisplayedLabel) ? cursorInteractionController.DisplayedTarget : player.GetHoverObject(); } internal static void Refresh(TMP_Text label) { if (track == null) { return; } try { track(Hud.instance, Player.m_localPlayer); label.ForceMeshUpdate(false, false); flush(); } catch (Exception error) { Report(error); } } private static void Report(Exception error) { track = null; Plugin.Instance?.Warn("Chest filter cursor icon unavailable: " + error.Message); } } internal static class CombatTextRange { internal static void Install(Harmony harmony) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(DamageText), "RPC_DamageText", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(CombatTextRange), "Rewrite", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } private static IEnumerable Rewrite(IEnumerable instructions) { MethodInfo position = AccessTools.PropertyGetter(typeof(Transform), "position"); MethodInfo origin = AccessTools.Method(typeof(CombatTextRange), "Origin", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, position)) { instruction.opcode = OpCodes.Call; instruction.operand = origin; } yield return instruction; } } private static Vector3 Origin(Transform camera) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Plugin instance = Plugin.Instance; return (instance != null && instance.CameraController.Active && Object.op_Implicit((Object)(object)localPlayer)) ? ((Component)localPlayer).transform.position : camera.position; } } internal sealed class CursorDrawIndicator { private RectTransform rect; private Vector3 originalPosition; private Vector2 originalPivot; private Quaternion originalRotation; internal void Update(Image image) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)image) || !((Component)image).gameObject.activeInHierarchy) { Restore(); return; } if ((Object)(object)rect != (Object)(object)((Graphic)image).rectTransform) { Restore(); rect = ((Graphic)image).rectTransform; originalPosition = ((Transform)rect).localPosition; originalPivot = rect.pivot; originalRotation = ((Transform)rect).localRotation; } rect.pivot = new Vector2(0.5f, 0.5f); ((Transform)rect).localRotation = Quaternion.identity; Transform parent = ((Transform)rect).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); Canvas componentInParent = ((Component)image).GetComponentInParent(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)componentInParent)) { Camera val2 = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera); Vector3 position = default(Vector3); if (RectTransformUtility.ScreenPointToWorldPointInRectangle(val, Vector2.op_Implicit(ZInput.pointerPosition), val2, ref position)) { ((Transform)rect).position = position; } } } internal void Restore() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)rect)) { rect.pivot = originalPivot; ((Transform)rect).localRotation = originalRotation; ((Transform)rect).localPosition = originalPosition; } rect = null; } } internal sealed class CursorFacingController { private static readonly FieldRef Pitch = AccessTools.FieldRefAccess("m_lookPitch"); private Player player; private float originalPitch; private static readonly FieldRef MoveDirection = AccessTools.FieldRefAccess("m_moveDir"); internal bool ShouldFace(Player local) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) bool attacking = ZInput.GetMouseButton(0) || ZInput.GetMouseButton(2); Vector3 val = MoveDirection.Invoke((Character)(object)local); return InteractionMath.FaceCursor(((Vector3)(ref val)).sqrMagnitude, attacking); } internal void ApplyMovement(Player local, Vector3 direction) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player != (Object)(object)local) { Restore(); player = local; originalPitch = Pitch.Invoke(local); } if (((Vector3)(ref direction)).sqrMagnitude > 0.0001f) { ((Character)local).SetLookDir(((Vector3)(ref direction)).normalized, 0f); } Pitch.Invoke(local) = 0f; } internal void Apply(Player local, Camera camera) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) if ((Object)(object)player != (Object)(object)local) { Restore(); player = local; originalPitch = Pitch.Invoke(local); } Ray val = ScreenCoordinates.PointerRay(camera); Plane val2 = default(Plane); ((Plane)(ref val2))..ctor(Vector3.up, ((Character)local).GetCenterPoint()); float num = default(float); Vector3 val3 = (((Plane)(ref val2)).Raycast(val, ref num) ? ((Ray)(ref val)).GetPoint(num) : (((Character)local).GetCenterPoint() + ((Component)camera).transform.forward)); Vector3 val4 = val3 - ((Character)local).GetCenterPoint(); val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude > 0.0001f) { ((Character)local).SetLookDir(((Vector3)(ref val4)).normalized, 0f); } Pitch.Invoke(local) = 0f; } internal void Restore() { if (Object.op_Implicit((Object)(object)player)) { Pitch.Invoke(player) = originalPitch; } player = null; } } internal sealed class CursorInteractionController { private static readonly FieldRef Mask = AccessTools.FieldRefAccess("m_interactMask"); private static readonly MethodInfo NativeInteract = AccessTools.Method(typeof(Player), "Interact", (Type[])null, (Type[])null); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[128]; private GameObject hovering; private Hoverable hoverable; private Interactable interactable; private Collider hitCollider; private readonly WorldClickState clicks = new WorldClickState(); private readonly UiPointerHitTest ui = new UiPointerHitTest(); private static readonly FieldRef InventoryAnimator = AccessTools.FieldRefAccess("m_animator"); private static readonly FieldRef InventoryHiddenFrames = AccessTools.FieldRefAccess("m_hiddenFrames"); private GameObject pendingTarget; private Collider pendingCollider; private bool pendingAlternate; private bool invokingNative; private Player seatingPlayer; private float seatingTransitionUntil; private Canvas canvas; private TextMeshProUGUI tooltip; private TMP_Text template; private string measuredText; private float measuredWidth; private float measuredHeight; internal TextMeshProUGUI DisplayedLabel => (Object.op_Implicit((Object)(object)tooltip) && ((Behaviour)tooltip).isActiveAndEnabled) ? tooltip : null; internal GameObject DisplayedTarget { get; private set; } internal static bool InventoryPanelVisible() { return Object.op_Implicit((Object)(object)InventoryGui.instance) && InventoryHiddenFrames.Invoke(InventoryGui.instance) <= 1; } internal void Update(Plugin plugin) { //IL_00f1: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0119: 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_0145: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: 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_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: 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_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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) if (!plugin.CameraController.Active || !plugin.Guard.IsWorldPointerAllowed() || ((Character)Player.m_localPlayer).InPlaceMode()) { ClearVisuals(); return; } Query(plugin, Player.m_localPlayer); if (!Object.op_Implicit((Object)(object)hovering) || hoverable == null || Hud.IsUserHidden()) { ClearVisuals(); return; } EnsureTooltip(); if (Object.op_Implicit((Object)(object)tooltip)) { PresentationTokens current = PresentationTokens.Current; ((TMP_Text)tooltip).text = (CanReserveClick() ? CursorNativeActions.HoverText(hovering, hoverable) : hoverable.GetHoverText()); ((Graphic)tooltip).color = (InRange(Player.m_localPlayer) ? ((Graphic)template).color : current.hoverColor); RectTransform val = (RectTransform)((Component)canvas).transform; Vector2 pointerViewport = ScreenCoordinates.PointerViewport; Rect rect = val.rect; float num = ((Rect)(ref rect)).width - current.tooltipOffset * 2f; float tooltipWidth = current.tooltipWidth; rect = template.rectTransform.rect; float num2 = Mathf.Min(num, Mathf.Max(tooltipWidth, ((Rect)(ref rect)).width)); float num3 = Mathf.Max(0.001f, ((Transform)((TMP_Text)tooltip).rectTransform).localScale.x); float num4 = Mathf.Max(0.001f, ((Transform)((TMP_Text)tooltip).rectTransform).localScale.y); float num5 = num2 / num3; bool flag = measuredText != ((TMP_Text)tooltip).text || measuredWidth != num5; bool flag2 = (Object)(object)DisplayedTarget != (Object)(object)hovering || !((Component)tooltip).gameObject.activeSelf; if (flag) { measuredText = ((TMP_Text)tooltip).text; measuredWidth = num5; measuredHeight = ((TMP_Text)tooltip).GetPreferredValues(((TMP_Text)tooltip).text, num5, float.PositiveInfinity).y; } float num6 = measuredHeight * num4; ((TMP_Text)tooltip).rectTransform.sizeDelta = new Vector2(num5, measuredHeight); RectTransform rectTransform = ((TMP_Text)tooltip).rectTransform; Vector2 anchorMin = (((TMP_Text)tooltip).rectTransform.anchorMax = pointerViewport); rectTransform.anchorMin = anchorMin; rect = val.rect; float width = ((Rect)(ref rect)).width; rect = val.rect; float height = ((Rect)(ref rect)).height; ((TMP_Text)tooltip).rectTransform.anchoredPosition = new Vector2(Mathf.Clamp(current.tooltipOffset, (0f - width) * pointerViewport.x + current.tooltipOffset, width * (1f - pointerViewport.x) - num2 - current.tooltipOffset), Mathf.Clamp(0f - current.tooltipOffset, num6 - height * pointerViewport.y + current.tooltipOffset, height * (1f - pointerViewport.y) - current.tooltipOffset)); ((Component)tooltip).gameObject.SetActive(true); DisplayedTarget = hovering; if (flag2 || flag) { ChestFilterTooltip.Refresh((TMP_Text)(object)tooltip); } bool flag3 = VisualRules.Bush(((Object)hovering).name, Object.op_Implicit((Object)(object)hovering.GetComponentInParent()), Object.op_Implicit((Object)(object)hovering.GetComponentInParent())); plugin.CameraController.SetHoveredBush((flag3 && InRange(Player.m_localPlayer)) ? hovering.transform : null); } } internal void Tick(Plugin plugin) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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) Player localPlayer = Player.m_localPlayer; if (!plugin.CameraController.Active || !plugin.Guard.IsWorldPointerContext()) { clicks.Reset(); pendingTarget = null; pendingCollider = null; return; } bool reopened = clicks.Pending && Object.op_Implicit((Object)(object)InventoryGui.instance) && InventoryAnimator.Invoke(InventoryGui.instance).GetBool("visible"); if (clicks.Complete(Time.unscaledTime, !plugin.Guard.IsModalUiOpen(), !plugin.Guard.IsWorldPointerAllowed(), reopened) && Object.op_Implicit((Object)(object)pendingTarget) && Object.op_Implicit((Object)(object)pendingCollider)) { Vector3 val = pendingCollider.ClosestPoint(((Character)localPlayer).GetCenterPoint()) - ((Character)localPlayer).GetCenterPoint(); if (ScreenSpaceMath.InReach(((Vector3)(ref val)).sqrMagnitude) && plugin.Guard.IsWorldPointerAllowed()) { InvokeNative(localPlayer, pendingTarget, pendingAlternate); } } if (!clicks.Pending) { pendingTarget = null; pendingCollider = null; } ConsumeClick(plugin, localPlayer); } internal bool ConsumeClick(Plugin plugin, Player player) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!clicks.Begin(ZInput.GetMouseButton(0), ZInput.GetMouseButtonDown(0), Time.frameCount)) { return clicks.Consumed; } if (plugin.Guard.IsInventoryWorldClickAllowed()) { if (ui.OverInterface(Vector2.op_Implicit(ZInput.pointerPosition))) { return clicks.Consumed; } clicks.Consume(); Query(plugin, player); pendingTarget = ((Object.op_Implicit((Object)(object)hovering) && CanReserveClick() && InRange(player)) ? hovering : null); pendingCollider = (Object.op_Implicit((Object)(object)pendingTarget) ? hitCollider : null); pendingAlternate = CursorNativeActions.Alternate && (!Object.op_Implicit((Object)(object)pendingTarget) || !Object.op_Implicit((Object)(object)pendingTarget.GetComponentInParent())); InventoryGui.instance.Hide(); if (Object.op_Implicit((Object)(object)pendingTarget)) { clicks.Defer(Time.unscaledTime); } return true; } if (!plugin.Guard.IsWorldPointerAllowed() || ((Character)player).InPlaceMode()) { return clicks.Consumed; } ItemDrop val = plugin.CombatHud.ItemAtLabel(); if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).isActiveAndEnabled && !val.IsPiece() && !plugin.CameraController.IsHiddenContent(((Component)val).gameObject)) { clicks.Consume(); if (GroundItemLabels.InReach(val, player)) { InvokeNative(player, ((Component)val).gameObject, alternate: false); } return true; } Query(plugin, player); if (Object.op_Implicit((Object)(object)hovering) && CanReserveClick()) { clicks.Consume(); if (InRange(player)) { InvokeNative(player, hovering, CursorNativeActions.Alternate && !Object.op_Implicit((Object)(object)hovering.GetComponentInParent())); } } return clicks.Consumed; } private bool CanReserveClick() { //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Invalid comparison between Unknown and I4 if (hoverable == null || !Object.op_Implicit((Object)(object)hovering)) { return false; } if (Object.op_Implicit((Object)(object)hovering.GetComponentInParent())) { return false; } if (Object.op_Implicit((Object)(object)hovering.GetComponentInParent()) || Object.op_Implicit((Object)(object)hovering.GetComponentInParent())) { return false; } if (Object.op_Implicit((Object)(object)hovering.GetComponentInParent()) || Object.op_Implicit((Object)(object)hovering.GetComponentInParent())) { return false; } Pickable componentInParent = hovering.GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { return interactable != null && componentInParent.CanBePicked(); } Piece componentInParent2 = hovering.GetComponentInParent(); string prefab = (Object.op_Implicit((Object)(object)componentInParent2) ? ((Object)((Component)componentInParent2).gameObject).name : ((Object)hovering).name); if (!Object.op_Implicit((Object)(object)componentInParent2) && VisualRules.Natural(prefab, tree: false)) { return false; } bool flag = Object.op_Implicit((Object)(object)componentInParent2) && ((int)componentInParent2.m_category == 4 || componentInParent2.m_comfort > 0 || Object.op_Implicit((Object)(object)hovering.GetComponentInParent()) || Object.op_Implicit((Object)(object)hovering.GetComponentInParent())); return interactable != null || flag; } private void InvokeNative(Player player, GameObject target, bool alternate) { Pickable val = (Object.op_Implicit((Object)(object)target) ? target.GetComponentInParent() : null); if (Object.op_Implicit((Object)(object)val) && !val.CanBePicked()) { return; } bool flag = Object.op_Implicit((Object)(object)target) && (Object.op_Implicit((Object)(object)target.GetComponentInParent()) || Object.op_Implicit((Object)(object)target.GetComponentInParent())); invokingNative = true; try { NativeInteract.Invoke(player, new object[3] { target, false, alternate }); if (flag || ((Character)player).IsAttached() || ((Character)player).IsSitting()) { seatingPlayer = player; seatingTransitionUntil = Time.unscaledTime + 0.75f; } } finally { invokingNative = false; } } internal bool BlockSeatingAttack(Player player) { if (!Object.op_Implicit((Object)(object)seatingPlayer) || (Object)(object)seatingPlayer != (Object)(object)player) { return false; } bool flag = Time.unscaledTime < seatingTransitionUntil; if (!flag && !((Character)player).IsAttached() && !((Character)player).IsSitting()) { seatingPlayer = null; return false; } return flag || ((Character)player).IsAttached() || ((Character)player).IsSitting(); } internal bool SeatingTransitionPending(Player player) { return (Object)(object)seatingPlayer == (Object)(object)player && Time.unscaledTime < seatingTransitionUntil; } internal bool AllowNativeInteraction(Plugin plugin, Player player) { if (invokingNative) { return true; } if (!plugin.Guard.IsWorldPointerContext()) { return true; } ConsumeClick(plugin, player); return !clicks.Consumed; } private bool InRange(Player player) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) int result; if (Object.op_Implicit((Object)(object)hovering) && Object.op_Implicit((Object)(object)hitCollider) && hoverable != null) { Vector3 val = hitCollider.ClosestPoint(((Character)player).GetCenterPoint()) - ((Character)player).GetCenterPoint(); result = (ScreenSpaceMath.InReach(((Vector3)(ref val)).sqrMagnitude) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } private void Query(Plugin plugin, Player player) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) hovering = null; hoverable = null; interactable = null; Ray val = ScreenCoordinates.PointerRay(plugin.CameraController.Camera); ((Ray)(ref val)).origin = CameraRelativeMovement.ToUnity(InteractionMath.NearRayOrigin(CameraRelativeMovement.ToNumerics(((Ray)(ref val)).origin), CameraRelativeMovement.ToNumerics(((Ray)(ref val)).direction), CameraRelativeMovement.ToNumerics(((Character)player).m_eye.position))); int num = Physics.RaycastNonAlloc(val, hits, 1000f, Mask.Invoke(player), (QueryTriggerInteraction)2); RaycastHit[] array = hits; if (num == hits.Length) { array = Physics.RaycastAll(val, 1000f, Mask.Invoke(player), (QueryTriggerInteraction)2); num = array.Length; } float num2 = float.PositiveInfinity; int num3 = int.MaxValue; GameObject val2 = NativeCursorRays.Ghost.Invoke(player); for (int i = 0; i < num; i++) { RaycastHit hit = array[i]; if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider) || (Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent() == (Object)(object)player || (Object.op_Implicit((Object)(object)val2) && ((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(val2.transform)) || plugin.CameraController.IsHiddenContent(((Component)((RaycastHit)(ref hit)).collider).gameObject)) { continue; } Hoverable val3 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); Interactable val4 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); Switch val5 = CursorNativeActions.Port(((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(), CursorNativeActions.Alternate); if (Object.op_Implicit((Object)(object)val5)) { val3 = (Hoverable)(object)val5; val4 = (Interactable)(object)val5; } if ((val4 == null && CursorOcclusion.Ignore(hit, plugin.CameraController.Camera, player)) || (((RaycastHit)(ref hit)).collider.isTrigger && val3 == null) || (val4 == null && plugin.CameraController.IsHiddenObstacle(((RaycastHit)(ref hit)).collider))) { continue; } int instanceID = ((Object)((RaycastHit)(ref hit)).collider).GetInstanceID(); if (((RaycastHit)(ref hit)).distance > num2 || (((RaycastHit)(ref hit)).distance == num2 && instanceID >= num3)) { continue; } num2 = ((RaycastHit)(ref hit)).distance; num3 = instanceID; hovering = null; hoverable = null; interactable = null; if (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent()) && val3 != null) { Component val6 = (Component)(object)((val4 is Component) ? val4 : null); object obj; if (val6 == null) { Component val7 = (Component)(object)((val3 is Component) ? val3 : null); obj = ((val7 != null) ? val7.gameObject : ((Component)((RaycastHit)(ref hit)).collider).gameObject); } else { obj = val6.gameObject; } hovering = (GameObject)obj; hoverable = val3; interactable = val4; hitCollider = ((RaycastHit)(ref hit)).collider; } } } private void EnsureTooltip() { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = (Object.op_Implicit((Object)(object)Hud.instance) ? Hud.instance.m_hoverName : null); if (Object.op_Implicit((Object)(object)tooltip) && (Object)(object)template == (Object)(object)val) { return; } if (Object.op_Implicit((Object)(object)tooltip)) { Object.Destroy((Object)(object)((Component)tooltip).gameObject); } template = (TMP_Text)(object)val; if (!Object.op_Implicit((Object)(object)val)) { return; } Canvas componentInParent = ((Component)val).GetComponentInParent(); canvas = ((componentInParent != null) ? componentInParent.rootCanvas : null); if (Object.op_Implicit((Object)(object)canvas)) { tooltip = Object.Instantiate(val, ((Component)canvas).transform, false); Transform val2 = ((TMP_Text)tooltip).transform.Find("ChestItemFilter_HoverIcon"); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)val2).gameObject); } measuredText = null; ((Object)tooltip).name = "Isometric cursor actions"; Graphic[] componentsInChildren = ((Component)tooltip).GetComponentsInChildren(true); foreach (Graphic val3 in componentsInChildren) { val3.raycastTarget = false; } ContentSizeFitter component = ((Component)tooltip).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { ((Behaviour)component).enabled = false; } LayoutElement component2 = ((Component)tooltip).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.ignoreLayout = true; } ((Behaviour)tooltip).enabled = true; ((TMP_Text)tooltip).alignment = (TextAlignmentOptions)257; ((TMP_Text)tooltip).enableAutoSizing = false; ((TMP_Text)tooltip).overflowMode = (TextOverflowModes)0; ((Graphic)tooltip).raycastTarget = false; ((TMP_Text)tooltip).margin = Vector4.zero; RectTransform rectTransform = ((TMP_Text)tooltip).rectTransform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); rectTransform.anchorMax = val4; rectTransform.anchorMin = val4; rectTransform.pivot = new Vector2(0f, 1f); ((Transform)rectTransform).localRotation = Quaternion.identity; Vector3 lossyScale = ((Component)canvas).transform.lossyScale; Vector3 lossyScale2 = ((TMP_Text)val).transform.lossyScale; ((Transform)rectTransform).localScale = new Vector3(lossyScale2.x / Mathf.Max(0.001f, lossyScale.x), lossyScale2.y / Mathf.Max(0.001f, lossyScale.y), 1f); rectTransform.sizeDelta = new Vector2(PresentationTokens.Current.tooltipWidth, PresentationTokens.Current.tooltipHeight); Canvas.ForceUpdateCanvases(); } } private void ClearVisuals() { DisplayedTarget = null; hovering = null; hoverable = null; interactable = null; Plugin.Instance?.CameraController.SetHoveredBush(null); if (Object.op_Implicit((Object)(object)tooltip)) { ((Component)tooltip).gameObject.SetActive(false); } } internal void Suspend() { seatingPlayer = null; ClearVisuals(); clicks.Reset(); pendingTarget = null; pendingCollider = null; if (Object.op_Implicit((Object)(object)tooltip)) { Object.Destroy((Object)(object)((Component)tooltip).gameObject); } canvas = null; tooltip = null; template = null; } } internal static class CursorNativeActions { private static readonly FieldRef Ore = AccessTools.FieldRefAccess("m_addOreSwitch"); private static readonly FieldRef Fuel = AccessTools.FieldRefAccess("m_addWoodSwitch"); private static readonly FieldInfo Keys = AccessTools.Field(typeof(ZInput), "s_keyLocalizationMap"); internal static bool Alternate => ZInput.GetKey((KeyCode)304, true) || ZInput.GetKey((KeyCode)303, true); internal static Switch Port(Smelter smelter, bool alternate) { if (!Object.op_Implicit((Object)(object)smelter)) { return null; } Switch val = Ore.Invoke(smelter); Switch val2 = Fuel.Invoke(smelter); return (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !((Object)(object)val != (Object)(object)val2)) ? null : (alternate ? val2 : val); } private static string Label(string key, string fallback) { IDictionary dictionary = Keys.GetValue(null) as IDictionary; string value; return Localization.instance.Localize((dictionary != null && dictionary.TryGetValue(key, out value)) ? value : fallback); } internal static string HoverText(GameObject target, Hoverable hover) { Smelter val = (Object.op_Implicit((Object)(object)target) ? target.GetComponentInParent() : null); Switch val2 = (Object.op_Implicit((Object)(object)val) ? Ore.Invoke(val) : null); Switch val3 = (Object.op_Implicit((Object)(object)val) ? Fuel.Invoke(val) : null); string text = Label("MouseLeft", "LMB"); string native = Localization.instance.Localize("$KEY_Use"); if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val3) && (Object)(object)val2 != (Object)(object)val3) { return HoverHintText.Combine(Adapt(val2.GetHoverText(), text), Adapt(val3.GetHoverText(), Label("LeftShift", "Shift") + " + " + text)); } return Adapt(hover.GetHoverText(), text); string Adapt(string text2, string binding) { return HoverHintText.RemapUse(Localization.instance.Localize(text2 ?? string.Empty), native, binding); } } } internal static class CursorOcclusion { internal static bool Ignore(RaycastHit hit, Camera camera, Player player) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Collider collider = ((RaycastHit)(ref hit)).collider; if (!Object.op_Implicit((Object)(object)collider)) { return true; } if (Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent())) { return false; } GameObject val = NativeCursorRays.Ghost.Invoke(player); if (Object.op_Implicit((Object)(object)val) && ((Component)collider).transform.IsChildOf(val.transform)) { return true; } Plugin instance = Plugin.Instance; bool hidden = (Object)(object)instance != (Object)null && instance.CameraController.IsHiddenObstacle(collider); bool tree = Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()); Destructible componentInParent = ((Component)collider).GetComponentInParent(); string prefab = (Object.op_Implicit((Object)(object)componentInParent) ? ((Object)((Component)componentInParent).gameObject).name : ((Object)((Component)collider).gameObject).name); bool natural = !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) && VisualRules.Natural(prefab, tree); float depthFromPlayer = Vector3.Dot(((RaycastHit)(ref hit)).point - ((Character)player).GetCenterPoint(), ((Component)camera).transform.forward); return VisualRules.Foreground(hidden, natural, character: false, depthFromPlayer); } } internal static class CursorTranspilers { internal static IEnumerable CursorRay(IEnumerable source, bool building, bool hammer = false) { //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown List list = new List(source); int num = 0; int num2 = 0; for (int i = 2; i < list.Count; i++) { if (list[i - 2].operand is MethodInfo methodInfo && !(methodInfo.DeclaringType != typeof(GameCamera)) && !(methodInfo.Name != "get_instance") && list[i - 1].operand is MethodInfo methodInfo2 && !(methodInfo2.Name != "get_transform") && list[i].operand is MethodInfo methodInfo3 && !(methodInfo3.DeclaringType != typeof(Transform)) && (!(methodInfo3.Name != "get_position") || !(methodInfo3.Name != "get_forward"))) { list[i].opcode = OpCodes.Ldarg_0; list[i].operand = null; list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NativeCursorRays), (methodInfo3.Name == "get_position") ? "Origin" : "Forward", (Type[])null, (Type[])null))); num++; } } for (int j = 0; j < list.Count; j++) { if (list[j].operand is MethodInfo methodInfo4 && !(methodInfo4.DeclaringType != typeof(Physics)) && !(methodInfo4.Name != "Raycast")) { ParameterInfo[] parameters = methodInfo4.GetParameters(); if (parameters.Length == 5 && !(parameters[0].ParameterType != typeof(Vector3)) && !(parameters[1].ParameterType != typeof(Vector3)) && parameters[2].ParameterType.IsByRef) { list[j].opcode = OpCodes.Ldarg_0; list[j].operand = null; list.Insert(++j, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NativeCursorRays), hammer ? "HammerCast" : "PlacementCast", (Type[])null, (Type[])null))); num2++; } } } if (num != 2 || num2 != (building ? 1 : 0)) { throw new InvalidOperationException("Native cursor-ray structure changed; no placement or hover replacement was installed."); } return list; } internal static IEnumerable PrecisionSpread(IEnumerable source) { bool afterSpawn = false; int replaced = 0; foreach (CodeInstruction instruction in source) { object operand = instruction.operand; if (operand is MethodInfo method && method.DeclaringType == typeof(Attack) && method.Name == "GetProjectileSpawnPoint") { afterSpawn = true; } yield return instruction; if (afterSpawn && (!(instruction.opcode != OpCodes.Ldloc_S) || !(instruction.opcode != OpCodes.Ldloc))) { operand = instruction.operand; int index = ((operand is LocalVariableInfo local) ? local.LocalIndex : ((instruction.operand is int integer) ? integer : ((instruction.operand is byte small) ? small : (-1)))); if (index == 4) { replaced++; yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ProjectileAim), "Accuracy", (Type[])null, (Type[])null)); } } } if (replaced != 6) { throw new InvalidOperationException("Native projectile accuracy structure changed; precision aiming was not installed."); } } } internal sealed class MeshChannels { internal Vector3[] Positions; internal Vector3[] Normals; internal Vector4[] Tangents; internal Color[] Colors; internal Vector4[][] Uv = new Vector4[8][]; internal int[][] Triangles; private static readonly Dictionary Cache = new Dictionary(); private static Func batchStart; internal static MeshChannels Read(Mesh source) { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Invalid comparison between Unknown and I4 //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_0248: Expected I4, but got Unknown //IL_01de: 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_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected I4, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Invalid comparison between Unknown and I4 //IL_025e: 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_02a0: 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_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue(source, out var value)) { return value; } MeshChannels meshChannels = new MeshChannels(); int vertexCount = source.vertexCount; meshChannels.Positions = (Vector3[])(object)new Vector3[vertexCount]; if (source.isReadable) { meshChannels.Positions = source.vertices; meshChannels.Normals = source.normals; meshChannels.Tangents = source.tangents; meshChannels.Colors = source.colors; for (int i = 0; i < 8; i++) { List list = new List(); source.GetUVs(i, list); meshChannels.Uv[i] = list.ToArray(); } meshChannels.Triangles = new int[source.subMeshCount][]; for (int j = 0; j < source.subMeshCount; j++) { meshChannels.Triangles[j] = source.GetTriangles(j); } } else { Dictionary dictionary = new Dictionary(); VertexAttributeDescriptor[] vertexAttributes = source.GetVertexAttributes(); for (int k = 0; k < vertexAttributes.Length; k++) { VertexAttributeDescriptor val = vertexAttributes[k]; if ((int)((VertexAttributeDescriptor)(ref val)).attribute > 11) { continue; } if (!dictionary.TryGetValue(((VertexAttributeDescriptor)(ref val)).stream, out var value2)) { GraphicsBuffer vertexBuffer = source.GetVertexBuffer(((VertexAttributeDescriptor)(ref val)).stream); try { value2 = new byte[vertexCount * source.GetVertexBufferStride(((VertexAttributeDescriptor)(ref val)).stream)]; vertexBuffer.GetData((Array)value2); dictionary.Add(((VertexAttributeDescriptor)(ref val)).stream, value2); } finally { ((IDisposable)vertexBuffer)?.Dispose(); } } Vector4[] array = (Vector4[])(object)new Vector4[vertexCount]; int vertexBufferStride = source.GetVertexBufferStride(((VertexAttributeDescriptor)(ref val)).stream); int vertexAttributeOffset = source.GetVertexAttributeOffset(((VertexAttributeDescriptor)(ref val)).attribute); for (int l = 0; l < vertexCount; l++) { for (int m = 0; m < ((VertexAttributeDescriptor)(ref val)).dimension; m++) { ((Vector4)(ref array[l]))[m] = ReadNumber(value2, l * vertexBufferStride + vertexAttributeOffset + m * Size(((VertexAttributeDescriptor)(ref val)).format), ((VertexAttributeDescriptor)(ref val)).format); } } VertexAttribute attribute = ((VertexAttributeDescriptor)(ref val)).attribute; VertexAttribute val2 = attribute; switch ((int)val2) { case 0: { for (int num3 = 0; num3 < vertexCount; num3++) { meshChannels.Positions[num3] = Vector4.op_Implicit(array[num3]); } break; } case 1: { meshChannels.Normals = (Vector3[])(object)new Vector3[vertexCount]; for (int n = 0; n < vertexCount; n++) { meshChannels.Normals[n] = Vector4.op_Implicit(array[n]); } break; } case 2: meshChannels.Tangents = array; break; case 3: { meshChannels.Colors = (Color[])(object)new Color[vertexCount]; for (int num2 = 0; num2 < vertexCount; num2++) { if (((VertexAttributeDescriptor)(ref val)).dimension < 4) { array[num2].w = 1f; } meshChannels.Colors[num2] = Color.op_Implicit(array[num2]); } break; } default: { int num = ((VertexAttributeDescriptor)(ref val)).attribute - 4; if (num >= 0 && num < 8) { meshChannels.Uv[num] = array; } break; } } } GraphicsBuffer indexBuffer = source.GetIndexBuffer(); try { int[] array3; if ((int)source.indexFormat == 1) { uint[] array2 = new uint[indexBuffer.count]; indexBuffer.GetData((Array)array2); array3 = Array.ConvertAll(array2, (uint x) => checked((int)x)); } else { ushort[] array4 = new ushort[indexBuffer.count]; indexBuffer.GetData((Array)array4); array3 = Array.ConvertAll(array4, (Converter)((ushort x) => x)); } meshChannels.Triangles = new int[source.subMeshCount][]; for (int num4 = 0; num4 < source.subMeshCount; num4++) { SubMeshDescriptor subMesh = source.GetSubMesh(num4); if ((int)((SubMeshDescriptor)(ref subMesh)).topology > 0) { throw new NotSupportedException("Cutaway requires triangle topology."); } int[] array5 = new int[((SubMeshDescriptor)(ref subMesh)).indexCount]; for (int num5 = 0; num5 < array5.Length; num5++) { array5[num5] = array3[((SubMeshDescriptor)(ref subMesh)).indexStart + num5] + ((SubMeshDescriptor)(ref subMesh)).baseVertex; } meshChannels.Triangles[num4] = array5; } } finally { ((IDisposable)indexBuffer)?.Dispose(); } } Cache[source] = meshChannels; return meshChannels; } internal static MeshChannels ForRenderer(Mesh mesh, Renderer renderer) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_01a1: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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) MeshChannels meshChannels = Read(mesh); if (!renderer.isPartOfStaticBatch) { return meshChannels; } if (batchStart == null) { PropertyInfo property = typeof(Renderer).GetProperty("staticBatchIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property == null) { throw new NotSupportedException("Static batch range is unavailable."); } batchStart = (Renderer item) => (int)property.GetValue(item); } int num = batchStart(renderer); int num2 = renderer.sharedMaterials.Length; if (num < 0 || num2 < 1 || num + num2 > meshChannels.Triangles.Length) { throw new NotSupportedException("Static batch range is unavailable."); } int[][] array = new int[num2][]; Array.Copy(meshChannels.Triangles, num, array, 0, num2); bool flag = false; Bounds val = default(Bounds); int[][] array2 = array; foreach (int[] array3 in array2) { int[] array4 = array3; foreach (int num5 in array4) { Matrix4x4 localToWorldMatrix = renderer.localToWorldMatrix; Vector3 val2 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(meshChannels.Positions[num5]); if (!flag) { ((Bounds)(ref val))..ctor(val2, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2); } } } Bounds bounds = renderer.bounds; Vector3 val3 = ((Bounds)(ref bounds)).size; float num6 = Mathf.Max(0.1f, ((Vector3)(ref val3)).magnitude * 0.03f); if (flag) { val3 = ((Bounds)(ref val)).min - ((Bounds)(ref bounds)).min; if (!(((Vector3)(ref val3)).magnitude > num6)) { val3 = ((Bounds)(ref val)).max - ((Bounds)(ref bounds)).max; if (!(((Vector3)(ref val3)).magnitude > num6)) { return new MeshChannels { Positions = meshChannels.Positions, Normals = meshChannels.Normals, Tangents = meshChannels.Tangents, Colors = meshChannels.Colors, Uv = meshChannels.Uv, Triangles = array }; } } } throw new NotSupportedException("Static batch submesh bounds do not match this wall renderer."); } internal static void ClearCache() { Cache.Clear(); } private static int Size(VertexAttributeFormat format) { //IL_0001: 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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected I4, but got Unknown switch ((int)format) { case 0: case 10: case 11: return 4; case 1: case 4: case 5: case 8: case 9: return 2; default: return 1; } } private unsafe static float ReadNumber(byte[] data, int offset, VertexAttributeFormat format) { //IL_0001: 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_0004: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected I4, but got Unknown VertexAttributeFormat val = format; VertexAttributeFormat val2 = val; switch ((int)val2) { case 0: return BitConverter.ToSingle(data, offset); case 1: { int num = BitConverter.ToUInt16(data, offset); int num2 = (num >> 10) & 0x1F; int num3 = num & 0x3FF; float num4 = ((num2 == 0) ? ((float)num3 * (float)Math.Pow(2.0, -24.0)) : ((1f + (float)num3 / 1024f) * (float)Math.Pow(2.0, num2 - 15))); return ((num & 0x8000) == 0) ? num4 : (0f - num4); } case 2: return (float)(int)data[offset] / 255f; case 3: return Math.Max(-1f, (float)(sbyte)data[offset] / 127f); case 4: return (float)(int)BitConverter.ToUInt16(data, offset) / 65535f; case 5: return Math.Max(-1f, (float)BitConverter.ToInt16(data, offset) / 32767f); case 6: return (int)data[offset]; case 7: return (sbyte)data[offset]; case 8: return (int)BitConverter.ToUInt16(data, offset); case 9: return BitConverter.ToInt16(data, offset); case 10: return BitConverter.ToUInt32(data, offset); case 11: return BitConverter.ToInt32(data, offset); default: throw new NotSupportedException("Unsupported native vertex format: " + ((object)(*(VertexAttributeFormat*)(&format))/*cast due to .constrained prefix*/).ToString()); } } } internal static class CutMeshBuilder { internal static Mesh Build(MeshChannels input, Vector4 plane, bool below, bool attributes, bool convexOpen = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return ToMesh(Clip(input, plane, below, attributes, convexOpen)); } internal static Mesh BuildDungeon(MeshChannels input, Matrix4x4 matrix, float height, DungeonSlice slice) { //IL_0001: 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_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_001b: 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) return ToMesh(Clip(input, new Vector4(matrix.m10, matrix.m11, matrix.m12, matrix.m13 - height), below: true, attributes: true, convexOpen: false, slice, matrix, height)); } internal static Mesh BuildSections(MeshChannels input, Matrix4x4 matrix, float height, IList sections, bool convexOpen = false) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector4 plane = default(Vector4); foreach (SectionRun section in sections) { int num = ((!section.AlongX) ? 2 : 0); ((Vector4)(ref plane))..ctor(((Matrix4x4)(ref matrix))[num, 0], ((Matrix4x4)(ref matrix))[num, 1], ((Matrix4x4)(ref matrix))[num, 2], ((Matrix4x4)(ref matrix))[num, 3] - section.From); MeshChannels input2 = Clip(input, plane, below: false, attributes: true, convexOpen); plane.w = ((Matrix4x4)(ref matrix))[num, 3] - section.To; input2 = Clip(input2, plane, below: true, attributes: true, convexOpen); if (section.Front) { input2 = Clip(input2, new Vector4(matrix.m10, matrix.m11, matrix.m12, matrix.m13 - height), below: true, attributes: true, convexOpen); } list.Add(input2); } MeshChannels meshChannels = new MeshChannels(); meshChannels.Positions = Array.Empty(); meshChannels.Triangles = new int[input.Triangles.Length][]; MeshChannels meshChannels2 = meshChannels; List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List[] array = new List[8]; List[] array2 = new List[input.Triangles.Length]; for (int i = 0; i < 8; i++) { array[i] = new List(); } for (int j = 0; j < array2.Length; j++) { array2[j] = new List(); } foreach (MeshChannels item in list) { int count = list2.Count; list2.AddRange(item.Positions); if (item.Normals != null) { list3.AddRange(item.Normals); } if (item.Tangents != null) { list4.AddRange(item.Tangents); } if (item.Colors != null) { list5.AddRange(item.Colors); } for (int k = 0; k < 8; k++) { if (item.Uv[k] != null) { array[k].AddRange(item.Uv[k]); } } for (int l = 0; l < array2.Length; l++) { int[] array3 = item.Triangles[l]; foreach (int num2 in array3) { array2[l].Add(count + num2); } } } meshChannels2.Positions = list2.ToArray(); meshChannels2.Normals = list3.ToArray(); meshChannels2.Tangents = list4.ToArray(); meshChannels2.Colors = list5.ToArray(); for (int n = 0; n < 8; n++) { meshChannels2.Uv[n] = array[n].ToArray(); } for (int num3 = 0; num3 < array2.Length; num3++) { meshChannels2.Triangles[num3] = array2[num3].ToArray(); } return ToMesh(meshChannels2); } private static MeshChannels Clip(MeshChannels input, Vector4 plane, bool below, bool attributes, bool convexOpen = false, DungeonSlice? dungeon = null, Matrix4x4 matrix = default(Matrix4x4), float height = 0f) { //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_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_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_01f4: 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_0169: 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_0366: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_080b: Unknown result type (might be due to invalid IL or missing references) //IL_0845: Unknown result type (might be due to invalid IL or missing references) //IL_08a8: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: 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_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0911: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_0974: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0992: Unknown result type (might be due to invalid IL or missing references) //IL_099f: Unknown result type (might be due to invalid IL or missing references) //IL_09ab: Unknown result type (might be due to invalid IL or missing references) //IL_09b0: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0a20: Unknown result type (might be due to invalid IL or missing references) //IL_0a30: Unknown result type (might be due to invalid IL or missing references) //IL_0a3c: Unknown result type (might be due to invalid IL or missing references) //IL_0a41: Unknown result type (might be due to invalid IL or missing references) //IL_0a51: Unknown result type (might be due to invalid IL or missing references) //IL_0a5d: Unknown result type (might be due to invalid IL or missing references) //IL_0a62: Unknown result type (might be due to invalid IL or missing references) //IL_0a67: Unknown result type (might be due to invalid IL or missing references) //IL_0a6e: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List<(int, int, int, ClipPoint, ClipPoint)> list2 = new List<(int, int, int, ClipPoint, ClipPoint)>(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List list6 = new List(); List[] array = new List[8]; for (int i = 0; i < 8; i++) { array[i] = new List(); } List[] array2 = new List[input.Triangles.Length]; List list7 = new List(4); for (int j = 0; j < array2.Length; j++) { array2[j] = new List(); int[] array3 = input.Triangles[j]; for (int k = 0; k < array3.Length; k += 3) { int num = array3[k]; int num2 = array3[k + 1]; int num3 = array3[k + 2]; if (dungeon.HasValue) { DungeonFace dungeonFace = dungeon.Value.Face(ToN(((Matrix4x4)(ref matrix)).MultiplyPoint3x4(input.Positions[num])), ToN(((Matrix4x4)(ref matrix)).MultiplyPoint3x4(input.Positions[num2])), ToN(((Matrix4x4)(ref matrix)).MultiplyPoint3x4(input.Positions[num3])), height); if (dungeonFace == DungeonFace.HideRoof) { continue; } if (dungeonFace == DungeonFace.Keep) { list7.Clear(); list7.Add(new ClipPoint(ToN(input.Positions[num]), Vector3.UnitX)); list7.Add(new ClipPoint(ToN(input.Positions[num2]), Vector3.UnitY)); list7.Add(new ClipPoint(ToN(input.Positions[num3]), Vector3.UnitZ)); } else { TriangleClip.Below(ToN(input.Positions[num]), ToN(input.Positions[num2]), ToN(input.Positions[num3]), new Vector4(plane.x, plane.y, plane.z, plane.w), below, list7); } } else { TriangleClip.Below(ToN(input.Positions[num]), ToN(input.Positions[num2]), ToN(input.Positions[num3]), new Vector4(plane.x, plane.y, plane.z, plane.w), below, list7); } if (list7.Count < 3) { continue; } if (attributes) { for (int l = 0; l < list7.Count; l++) { ClipPoint item = list7[l]; ClipPoint item2 = list7[(l + 1) % list7.Count]; if (item.OnPlane && item2.OnPlane) { list.Add(new SectionEdge(item.Position, item2.Position, j)); list2.Add((num, num2, num3, item, item2)); } } } int count = list3.Count; foreach (ClipPoint item4 in list7) { Vector3 weights = item4.Weights; list3.Add(new Vector3(item4.Position.X, item4.Position.Y, item4.Position.Z)); if (!attributes) { continue; } if (input.Normals?.Length == input.Positions.Length) { Vector3 val = input.Normals[num] * weights.X + input.Normals[num2] * weights.Y + input.Normals[num3] * weights.Z; list4.Add(((Vector3)(ref val)).normalized); } if (input.Tangents?.Length == input.Positions.Length) { list5.Add(input.Tangents[num] * weights.X + input.Tangents[num2] * weights.Y + input.Tangents[num3] * weights.Z); } if (input.Colors?.Length == input.Positions.Length) { list6.Add(input.Colors[num] * weights.X + input.Colors[num2] * weights.Y + input.Colors[num3] * weights.Z); } for (int m = 0; m < 8; m++) { if (input.Uv[m]?.Length == input.Positions.Length) { array[m].Add(input.Uv[m][num] * weights.X + input.Uv[m][num2] * weights.Y + input.Uv[m][num3] * weights.Z); } } } for (int n = 1; n < list7.Count - 1; n++) { array2[j].Add(count); array2[j].Add(count + n); array2[j].Add(count + n + 1); } } } if (attributes && list.Count > 0) { Vector3 vector = Vector3.Normalize(new Vector3(plane.x, plane.y, plane.z)) * (below ? 1 : (-1)); SectionSurface sectionSurface = SectionCap.Build(list, vector, convexOpen); Vector3 vector2 = Vector3.Normalize(Vector3.Cross((Math.Abs(vector.Y) < 0.9f) ? Vector3.UnitY : Vector3.UnitZ, vector)); for (int num4 = 0; num4 < sectionSurface.Vertices.Count; num4++) { SectionVertex sectionVertex = sectionSurface.Vertices[num4]; (int, int, int, ClipPoint, ClipPoint) tuple = list2[sectionVertex.Edge]; Vector3 weights2 = Vector3.Lerp(tuple.Item4.Weights, tuple.Item5.Weights, sectionVertex.Along); int a = tuple.Item1; int b = tuple.Item2; int c = tuple.Item3; int count2 = list3.Count; int material = sectionSurface.Materials[num4 / 3]; MapCap(input, new Vector3(sectionVertex.Position.X, sectionVertex.Position.Y, sectionVertex.Position.Z), new Vector3(vector.X, vector.Y, vector.Z), material, ref a, ref b, ref c, ref weights2); list3.Add(new Vector3(sectionVertex.Position.X, sectionVertex.Position.Y, sectionVertex.Position.Z)); if (input.Normals?.Length == input.Positions.Length) { list4.Add(new Vector3(vector.X, vector.Y, vector.Z)); } if (input.Tangents?.Length == input.Positions.Length) { list5.Add(new Vector4(vector2.X, vector2.Y, vector2.Z, 1f)); } if (input.Colors?.Length == input.Positions.Length) { list6.Add(input.Colors[a] * weights2.X + input.Colors[b] * weights2.Y + input.Colors[c] * weights2.Z); } for (int num5 = 0; num5 < 8; num5++) { if (input.Uv[num5]?.Length == input.Positions.Length) { Vector4 item3 = input.Uv[num5][a] * weights2.X + input.Uv[num5][b] * weights2.Y + input.Uv[num5][c] * weights2.Z; array[num5].Add(item3); } } array2[sectionSurface.Materials[num4 / 3]].Add(count2); } } MeshChannels meshChannels = new MeshChannels(); meshChannels.Positions = list3.ToArray(); meshChannels.Normals = list4.ToArray(); meshChannels.Tangents = list5.ToArray(); meshChannels.Colors = list6.ToArray(); meshChannels.Triangles = new int[array2.Length][]; MeshChannels meshChannels2 = meshChannels; for (int num6 = 0; num6 < 8; num6++) { meshChannels2.Uv[num6] = array[num6].ToArray(); } for (int num7 = 0; num7 < array2.Length; num7++) { meshChannels2.Triangles[num7] = array2[num7].ToArray(); } return meshChannels2; } private static Mesh ToMesh(MeshChannels data) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown Mesh val = new Mesh { name = "Isometric closed structural section", hideFlags = (HideFlags)61, indexFormat = (IndexFormat)1 }; val.vertices = data.Positions; Vector3[] normals = data.Normals; if (normals != null && normals.Length != 0) { val.normals = data.Normals; } Vector4[] tangents = data.Tangents; if (tangents != null && tangents.Length != 0) { val.tangents = data.Tangents; } Color[] colors = data.Colors; if (colors != null && colors.Length != 0) { val.colors = data.Colors; } for (int i = 0; i < 8; i++) { Vector4[] obj = data.Uv[i]; if (obj != null && obj.Length != 0) { val.SetUVs(i, new List(data.Uv[i])); } } val.subMeshCount = data.Triangles.Length; for (int j = 0; j < data.Triangles.Length; j++) { val.SetTriangles(data.Triangles[j], j, false); } Vector3[] normals2 = data.Normals; if (normals2 != null && normals2.Length == 0) { val.RecalculateNormals(); } val.RecalculateBounds(); return val; } private static Vector3 ToN(Vector3 p) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector3(p.x, p.y, p.z); } private static void MapCap(MeshChannels data, Vector3 point, Vector3 normal, int material, ref int a, ref int b, ref int c, ref Vector3 weights) { //IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0054: 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_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_0099: 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) //IL_009c: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00bd: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_01a9: 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) float num = float.PositiveInfinity; int[] array = data.Triangles[material]; for (int i = 0; i < array.Length; i += 3) { int num2 = array[i]; int num3 = array[i + 1]; int num4 = array[i + 2]; Vector3 val = data.Positions[num2]; Vector3 val2 = data.Positions[num3]; Vector3 val3 = data.Positions[num4]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); if (Vector3.Dot(((Vector3)(ref val4)).normalized, normal) < 0.5f) { continue; } Vector3 val5 = val2 - val; val5 -= normal * Vector3.Dot(val5, normal); Vector3 val6 = val3 - val; val6 -= normal * Vector3.Dot(val6, normal); Vector3 val7 = point - val; val7 -= normal * Vector3.Dot(val7, normal); float num5 = Vector3.Dot(val5, val5); float num6 = Vector3.Dot(val5, val6); float num7 = Vector3.Dot(val6, val6); float num8 = Vector3.Dot(val7, val5); float num9 = Vector3.Dot(val7, val6); float num10 = num5 * num7 - num6 * num6; if (Mathf.Abs(num10) < 1E-07f) { continue; } float num11 = (num8 * num7 - num9 * num6) / num10; float num12 = (num9 * num5 - num8 * num6) / num10; float num13 = 1f - num11 - num12; if (!(num13 < -0.001f) && !(num11 < -0.001f) && !(num12 < -0.001f)) { float num14 = Mathf.Abs(Vector3.Dot(val - point, normal)); if (!(num14 >= num)) { num = num14; a = num2; b = num3; c = num4; weights = new Vector3(Mathf.Max(0f, num13), Mathf.Max(0f, num11), Mathf.Max(0f, num12)); weights /= weights.X + weights.Y + weights.Z; } } } } } internal sealed class DungeonCutaway { private const float ProbeInterval = 0.35f; private static readonly int ShellMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "viewblock" }); private readonly List candidates = new List(); private readonly List meshColliders = new List(); private readonly HashSet collisionMeshes = new HashSet(); private Transform root; private Vector3 origin; private float floor; private float yaw = float.NaN; private float lip; private float radius; private float nextProbe; private bool hideRoof; internal DungeonSlice Slice { get; private set; } internal bool Update(Camera camera, Player player, IsometricConfig config, HashSet hidden, Dictionary cuts, out bool topologyChanged) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: 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_02af: 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_039e: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: 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_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: 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_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: 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_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) topologyChanged = false; Vector3 position = ((Component)player).transform.position; Collider val = (((Character)player).IsOnGround() ? ((Character)player).GetLastGroundCollider() : null); if (!Object.op_Implicit((Object)(object)val) && !Object.op_Implicit((Object)(object)root) && Time.unscaledTime >= nextProbe) { nextProbe = Time.unscaledTime + 0.35f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(position + Vector3.up * 0.2f, Vector3.down, ref val2, 3f, ShellMask, (QueryTriggerInteraction)1)) { val = ((RaycastHit)(ref val2)).collider; } } Transform val3 = (Object.op_Implicit((Object)(object)val) ? FindRoot(((Component)val).transform) : root); bool flag = Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)((Component)val3).GetComponent()); bool flag2 = (Object)(object)root != (Object)(object)val3; float value = config.RoomSearchRadius.Value; bool flag3 = !flag && HorizontalDistance(position, origin) > 3f; bool flag4 = flag2 || value != radius || (flag3 && Time.unscaledTime >= nextProbe); if (flag4) { topologyChanged = true; root = val3; origin = position; radius = value; nextProbe = Time.unscaledTime + 0.35f; candidates.Clear(); meshColliders.Clear(); collisionMeshes.Clear(); if (Object.op_Implicit((Object)(object)root)) { ((Component)root).GetComponentsInChildren(false, candidates); ((Component)root).GetComponentsInChildren(false, meshColliders); foreach (MeshCollider meshCollider in meshColliders) { if (Object.op_Implicit((Object)(object)meshCollider) && ((Collider)meshCollider).enabled && !((Collider)meshCollider).isTrigger && Object.op_Implicit((Object)(object)meshCollider.sharedMesh)) { collisionMeshes.Add(meshCollider.sharedMesh); } } } } float num = ((!float.IsNaN(yaw)) ? floor : position.y); if (Object.op_Implicit((Object)(object)val) && (flag4 || Mathf.Abs(position.y - floor) >= 0.75f)) { num = Mathf.Round(position.y * 4f) * 0.25f; } float num2 = CameraMath.SnapDiagonalYaw(((Component)camera).transform.eulerAngles.y); float num3 = (config.BuildingCutaway.Value ? config.BuildingWallHeight.Value : config.WallCutHeight.Value); bool flag5 = config.BuildingCutaway.Value || config.HideRoofs.Value; if (!flag4 && floor == num && yaw == num2 && lip == num3 && hideRoof == flag5) { return false; } floor = num; yaw = num2; lip = num3; hideRoof = flag5; hidden.Clear(); cuts.Clear(); if (!Object.op_Implicit((Object)(object)root)) { return true; } Vector3 val4 = (flag ? root.position : origin); Vector3 val5 = Quaternion.Euler(0f, yaw, 0f) * Vector3.back; Slice = new DungeonSlice(new Vector2(val4.x, val4.z), new Vector2(val5.x, val5.z), floor, hideRoof); foreach (MeshRenderer candidate in candidates) { if (!IsShell(candidate, out var roof)) { continue; } Bounds bounds = ((Renderer)candidate).bounds; if (((Bounds)(ref bounds)).max.y <= floor + lip) { continue; } if (!flag) { Vector3 val6 = ((Bounds)(ref bounds)).ClosestPoint(origin) - origin; if (((Vector3)(ref val6)).sqrMagnitude > radius * radius) { continue; } } if (roof && ((Bounds)(ref bounds)).min.y >= floor + 1.8f) { if (hideRoof) { hidden.Add((Renderer)(object)candidate); } } else { cuts[(Renderer)(object)candidate] = floor + lip; } } return true; } private static Transform FindRoot(Transform node) { Room componentInParent = ((Component)node).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { return ((Component)componentInParent).transform; } Location componentInParent2 = ((Component)node).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent2) && Object.op_Implicit((Object)(object)componentInParent2.m_interiorTransform) && node.IsChildOf(componentInParent2.m_interiorTransform)) { return componentInParent2.m_interiorTransform; } Transform val = node; while (Object.op_Implicit((Object)(object)val.parent) && Character.InInterior(val.parent)) { val = val.parent; } return Character.InInterior(val) ? val : null; } private bool IsShell(MeshRenderer renderer, out bool roof) { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01c8: Unknown result type (might be due to invalid IL or missing references) roof = false; if (!Object.op_Implicit((Object)(object)renderer) || !((Renderer)renderer).enabled || Object.op_Implicit((Object)(object)((Component)renderer).GetComponent()) || Object.op_Implicit((Object)(object)((Component)renderer).GetComponentInParent()) || ((Component)renderer).GetComponentInParent() != null) { return false; } MeshFilter component = ((Component)renderer).GetComponent(); Mesh val = ((component != null) ? component.sharedMesh : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } bool flag = false; bool flag2 = collisionMeshes.Contains(val); Transform val2 = ((Component)renderer).transform; while (Object.op_Implicit((Object)(object)val2)) { Collider component2 = ((Component)val2).GetComponent(); flag2 |= Object.op_Implicit((Object)(object)component2) && component2.enabled && !component2.isTrigger; if ((Object)(object)val2 == (Object)(object)root) { break; } string name = ((Object)val2).name; BuildingKind buildingKind = CutawayMath.Kind(name); int num; switch (buildingKind) { case BuildingKind.Stair: return false; default: num = ((name.IndexOf("ceiling", StringComparison.OrdinalIgnoreCase) >= 0) ? 1 : 0); break; case BuildingKind.Roof: num = 1; break; } bool flag3 = (byte)num != 0; roof |= flag3; flag = flag || flag3 || buildingKind == BuildingKind.Wall || buildingKind == BuildingKind.Frame; val2 = val2.parent; } if (flag) { return true; } Bounds bounds = ((Renderer)renderer).bounds; bool flag4 = Mathf.Min(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) >= 3.2f; return (((Bounds)(ref bounds)).size.y > 1.6f && ((flag2 && Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) > 1.4f) || (flag4 && ((Bounds)(ref bounds)).size.y >= 2.2f))) || (flag2 && flag4 && ((Bounds)(ref bounds)).min.y >= floor + 1.8f); } private static float HorizontalDistance(Vector3 a, Vector3 b) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) a.y = b.y; return Vector3.Distance(a, b); } internal void Clear() { root = null; radius = 0f; yaw = float.NaN; nextProbe = 0f; candidates.Clear(); meshColliders.Clear(); collisionMeshes.Clear(); } } internal sealed class EnemyPresentation { private sealed class Entry { internal readonly SurfaceRing Ring = new SurfaceRing(); internal HealthWidget Health; internal void Dispose() { Ring.Dispose(); Health?.Dispose(); } } private static readonly FieldInfo Huds = AccessTools.Field(typeof(EnemyHud), "m_huds"); private static readonly Type Data = AccessTools.Inner(typeof(EnemyHud), "HudData"); private static readonly FieldInfo Timer = AccessTools.Field(Data, "m_hoverTimer"); private static readonly FieldInfo Gui = AccessTools.Field(Data, "m_gui"); private static readonly FieldInfo Name = AccessTools.Field(Data, "m_name"); private static readonly FieldInfo HudRoot = AccessTools.Field(typeof(EnemyHud), "m_hudRoot"); private static readonly MethodInfo Show = AccessTools.Method(typeof(EnemyHud), "ShowHud", (Type[])null, (Type[])null); private readonly Dictionary entries = new Dictionary(); private readonly List characters = new List(); private readonly List removed = new List(); private readonly HashSet visible = new HashSet(); private readonly List hiddenNative = new List(); private readonly StateLease nativeOpacity = new StateLease((CanvasGroup group) => Object.op_Implicit((Object)(object)group), (CanvasGroup group) => group.alpha, delegate(CanvasGroup group, float _) { group.alpha = 0f; }, delegate(CanvasGroup group, float alpha) { group.alpha = alpha; }); internal static bool Visible(Camera camera, Player player, Character character) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) return Object.op_Implicit((Object)(object)camera) && Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)character) && (Object)(object)character != (Object)(object)player && !character.IsPlayer() && !character.IsDead() && !character.m_hideHud && BaseAI.IsEnemy((Character)(object)player, character) && ScreenSpaceMath.InViewport(CameraRelativeMovement.ToNumerics(camera.WorldToViewportPoint(character.GetCenterPoint()))); } internal static void KeepNativeBars(EnemyHud hud) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.CameraController.Active || !instance.Guard.IsCameraViewAllowed() || !(Huds.GetValue(hud) is IDictionary dictionary)) { return; } foreach (DictionaryEntry item in dictionary) { Camera camera = instance.CameraController.Camera; Player localPlayer = Player.m_localPlayer; object key = item.Key; if (!Visible(camera, localPlayer, (Character)((key is Character) ? key : null))) { object key2 = item.Key; Player val = (Player)((key2 is Player) ? key2 : null); if (val == null || !instance.CombatHud.ShowPlayerBar(val)) { continue; } } Timer.SetValue(item.Value, 0f); } } private static object NativeData(Character character) { return (Object.op_Implicit((Object)(object)character) && Object.op_Implicit((Object)(object)EnemyHud.instance) && Huds.GetValue(EnemyHud.instance) is IDictionary dictionary) ? dictionary[character] : null; } internal static void EnsureLocalBar(EnemyHud hud, Player player) { if (!Object.op_Implicit((Object)(object)NativeBar((Character)(object)player))) { if (NativeData((Character)(object)player) != null) { hud.RemoveCharacterHud((Character)(object)player); } Show.Invoke(hud, new object[2] { player, false }); } } internal static GameObject NativeBar(Character character) { object obj = NativeData(character); return (GameObject)((obj == null) ? null : /*isinst with value type is only supported in some contexts*/); } internal static GameObject NativeName(Player player) { object obj = NativeData((Character)(object)player); object result; if (obj != null) { object? value = Name.GetValue(obj); TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null); if (val != null && Object.op_Implicit((Object)(object)val)) { result = ((Component)val).gameObject; goto IL_0030; } } result = null; goto IL_0030; IL_0030: return (GameObject)result; } private static bool NativeBarVisible(Character character) { if (character.IsBoss()) { return false; } GameObject val = NativeBar(character); return Object.op_Implicit((Object)(object)val) && val.activeInHierarchy; } internal GameObject OverheadBar(Character character) { if (NativeBarVisible(character)) { return NativeBar(character); } Entry value; return (entries.TryGetValue(character, out value) && value.Health != null) ? ((Component)value.Health.Root).gameObject : null; } internal void UpdateNativeVisibility(IsometricCameraController controller, Player player, bool windowOpen) { hiddenNative.Clear(); EnemyHud instance = EnemyHud.instance; if (Object.op_Implicit((Object)(object)instance) && windowOpen) { object? value = HudRoot.GetValue(instance); HideNative((GameObject)((value is GameObject) ? value : null)); } else if (Object.op_Implicit((Object)(object)instance) && Huds.GetValue(instance) is IDictionary dictionary) { foreach (DictionaryEntry item in dictionary) { object key = item.Key; Character val = (Character)((key is Character) ? key : null); if (val != null && Object.op_Implicit((Object)(object)val) && val.IsBoss()) { object? value2 = Gui.GetValue(item.Value); GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null); if (val2 != null && Object.op_Implicit((Object)(object)val2) && val2.activeInHierarchy && !TargetPicker.Retain(val, player, controller)) { HideNative(val2); } } } } nativeOpacity.Begin(hiddenNative); } private void HideNative(GameObject node) { if (Object.op_Implicit((Object)(object)node)) { CanvasGroup component = node.GetComponent(); hiddenNative.Add(Object.op_Implicit((Object)(object)component) ? component : node.AddComponent()); } } internal void Update(Camera camera, Player player, Hud hud, RectTransform root, bool groundRings) { //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_0197: 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_015c: Unknown result type (might be due to invalid IL or missing references) visible.Clear(); characters.Clear(); if (!Hud.IsUserHidden()) { characters.AddRange(Character.GetAllCharacters()); } characters.Sort((Character a, Character b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID())); foreach (Character character in characters) { if (!Visible(camera, player, character)) { continue; } visible.Add(character); if (!entries.TryGetValue(character, out var value)) { value = new Entry(); entries.Add(character, value); } if (groundRings) { value.Ring.Update(character); } else { value.Ring.Hide(); } if (NativeBarVisible(character)) { HealthWidget health = value.Health; if (health != null) { ((Component)health.Root).gameObject.SetActive(false); } continue; } if (value.Health == null) { value.Health = new HealthWidget(hud, (Transform)(object)root, PresentationTokens.Current.playerWidth, targetWidget: true); value.Health.Root.pivot = new Vector2(0.5f, 0f); } value.Health.Update(character, hostile: true); ScreenCoordinates.PlaceAbove(value.Health.Root, camera, character.GetTopPoint() + Vector3.up * PresentationTokens.Current.headOffset); } removed.Clear(); foreach (KeyValuePair entry in entries) { if (!Object.op_Implicit((Object)(object)entry.Key) || !visible.Contains(entry.Key)) { removed.Add(entry.Key); } } foreach (Character item in removed) { entries[item].Dispose(); entries.Remove(item); } } internal void Dispose() { nativeOpacity.End(); hiddenNative.Clear(); foreach (Entry value in entries.Values) { value.Dispose(); } entries.Clear(); visible.Clear(); characters.Clear(); removed.Clear(); } } internal sealed class FadeProxyMarker : MonoBehaviour { } internal static class GrassCameraLod { private static readonly FieldRef NativeRadius = AccessTools.FieldRefAccess("m_distance"); private static readonly FieldRef PatchSize = AccessTools.FieldRefAccess("m_grassPatchSize"); private static readonly FieldRef GrassRoot = AccessTools.FieldRefAccess("m_grassRoot"); private static readonly FieldRef NativeLod = AccessTools.FieldRefAccess("m_useLod"); private static int footprintFrame = -1; private static float footprint; private static Camera footprintCamera; internal static void Install(Harmony harmony) { MethodInfo methodInfo = AccessTools.Method(typeof(InstanceRenderer), "CustomUpdate", new Type[2] { typeof(float), typeof(float) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ClutterSystem), "GeneratePatches", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(ClutterSystem), "GeneratePatch", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null) { throw new MissingMethodException("Grass renderer or patch generation has changed."); } Patch(harmony, methodInfo, "ReplaceLod"); Patch(harmony, methodInfo2, "ReplaceRadius"); Patch(harmony, methodInfo3, "ReplaceRadius"); } private static void Patch(Harmony harmony, MethodInfo method, string patch) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown harmony.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(GrassCameraLod), patch, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } private static IEnumerable ReplaceLod(IEnumerable code) { return ReplaceRead(code, typeof(InstanceRenderer), "m_useLod", "UseDistanceLod"); } private static IEnumerable ReplaceRadius(IEnumerable code) { return ReplaceRead(code, typeof(ClutterSystem), "m_distance", "PatchRadius"); } private static IEnumerable ReplaceRead(IEnumerable code, Type owner, string field, string wrapper) { FieldInfo original = AccessTools.Field(owner, field); MethodInfo replacement = AccessTools.Method(typeof(GrassCameraLod), wrapper, (Type[])null, (Type[])null); foreach (CodeInstruction instruction in code) { if (instruction.opcode == OpCodes.Ldfld && object.Equals(instruction.operand, original)) { instruction.opcode = OpCodes.Call; instruction.operand = replacement; } yield return instruction; } } private static Camera ActiveCamera() { Plugin instance = Plugin.Instance; return ((Object)(object)instance != (Object)null && instance.CameraController.Active && instance.Settings.Enabled.Value) ? instance.CameraController.Camera : null; } private static bool UseDistanceLod(InstanceRenderer renderer) { if (!NativeLod.Invoke(renderer)) { return false; } ClutterSystem instance = ClutterSystem.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)ActiveCamera())) { return true; } GameObject val = GrassRoot.Invoke(instance); return !Object.op_Implicit((Object)(object)val) || !((Component)renderer).transform.IsChildOf(val.transform); } private static float PatchRadius(ClutterSystem clutter) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) float num = NativeRadius.Invoke(clutter); Camera val = ActiveCamera(); Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)localPlayer)) { return num; } if (footprintFrame != Time.frameCount || (Object)(object)footprintCamera != (Object)(object)val) { footprintCamera = val; footprintFrame = Time.frameCount; footprint = GroundFootprint(val, ((Component)localPlayer).transform.position); } float num2 = Mathf.Max(1f, PatchSize.Invoke(clutter)); return Mathf.Max(num, Mathf.Ceil(footprint / num2) * num2 + num2); } private static float GroundFootprint(Camera camera, Vector3 player) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_004c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) float num = 0f; for (int i = 0; i <= 1; i++) { for (int j = 0; j <= 1; j++) { Ray val = camera.ViewportPointToRay(new Vector3((float)j, (float)i)); if (!(((Ray)(ref val)).direction.y >= -0.01f)) { float num2 = (player.y - ((Ray)(ref val)).origin.y) / ((Ray)(ref val)).direction.y; if (!(num2 <= 0f)) { Vector3 val2 = ((Ray)(ref val)).GetPoint(num2) - player; num = Mathf.Max(num, val2.x * val2.x + val2.z * val2.z); } } } } return Mathf.Sqrt(num); } } internal sealed class GroundItemLabels { private readonly List occupied = new List(); private readonly List displayed = new List(); private RectTransform displayRoot; private static readonly FieldRef> Instances = AccessTools.StaticFieldRefAccess>(AccessTools.Field(typeof(ItemDrop), "s_instances")); private readonly List labels = new List(); private static bool AltHeld => ZInput.GetKey((KeyCode)308, true) || ZInput.GetKey((KeyCode)307, true); internal void Update(RectTransform root, Hud hud, IsometricCameraController controller, Player player, bool allowed) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0106: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: 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_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_0300: Unknown result type (might be due to invalid IL or missing references) int num = 0; displayRoot = root; occupied.Clear(); displayed.Clear(); TextMeshProUGUI hoverName = hud.m_hoverName; if (allowed && Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)hoverName) && Object.op_Implicit((Object)(object)((TMP_Text)hoverName).font) && Localization.instance != null && !Hud.IsUserHidden() && AltHeld) { PresentationTokens current = PresentationTokens.Current; Rect rect = root.rect; Vector2 pointerViewport = ScreenCoordinates.PointerViewport; Vector2 val = ((Rect)(ref rect)).min + Vector2.Scale(pointerViewport, ((Rect)(ref rect)).size); foreach (ItemDrop item in Instances.Invoke()) { if (!Object.op_Implicit((Object)(object)item) || !((Behaviour)item).isActiveAndEnabled || item.IsPiece() || controller.IsHiddenContent(((Component)item).gameObject)) { continue; } Vector3 position = ((Component)item).transform.position; Vector3 val2 = controller.Camera.WorldToViewportPoint(position + Vector3.up * item.GetHoverOffset()); if (val2.z <= 0f || val2.x <= 0f || val2.x >= 1f || val2.y <= 0f || val2.y >= 1f) { continue; } string hoverName2 = item.GetHoverName(); if (string.IsNullOrEmpty(hoverName2)) { continue; } TextMeshProUGUI val3 = ((num < labels.Count) ? labels[num] : Create(root, (TMP_Text)(object)hoverName)); ((TMP_Text)val3).text = Localization.instance.Localize(hoverName2); RectTransform val4 = (RectTransform)((TMP_Text)val3).transform.parent; Vector2 size = Vector2.Min(((Rect)(ref rect)).size, ((TMP_Text)val3).GetPreferredValues() + new Vector2(current.lootPaddingX, current.lootPaddingY)); Vector2 anchor = ((Rect)(ref rect)).min + Vector2.Scale(new Vector2(val2.x, val2.y), ((Rect)(ref rect)).size); if (Place(rect, anchor, size, current.lootPaddingY, out var slot)) { occupied.Add(slot); displayed.Add(item); num++; val4.sizeDelta = ((Rect)(ref slot)).size; val4.anchoredPosition = ((Rect)(ref slot)).min - ((Rect)(ref rect)).min; ((Component)val4).gameObject.SetActive(true); bool flag = InReach(item, player); bool flag2 = ((Rect)(ref slot)).Contains(val); Color color = ((flag || flag2) ? current.textColor : current.lootIdleText); if (!flag && flag2) { color.a = current.lootHoverAlpha; } ((Graphic)val3).color = color; } } } for (int i = num; i < labels.Count; i++) { ((Component)((TMP_Text)labels[i]).transform.parent).gameObject.SetActive(false); } } private bool Place(Rect bounds, Vector2 anchor, Vector2 size, float gap, out Rect slot) { //IL_0001: 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_0022: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(anchor.x - size.x / 2f, ((Rect)(ref bounds)).xMin, ((Rect)(ref bounds)).xMax - size.x); float num2 = Mathf.Clamp(anchor.y, ((Rect)(ref bounds)).yMin, ((Rect)(ref bounds)).yMax - size.y); slot = new Rect(num, num2, size.x, size.y); for (int i = 0; i < 5; i++) { if (((Rect)(ref slot)).yMax > ((Rect)(ref bounds)).yMax) { return false; } bool flag = false; foreach (Rect item in occupied) { Rect current = item; if (((Rect)(ref slot)).Overlaps(current)) { ((Rect)(ref slot)).y = ((Rect)(ref current)).yMax + gap; flag = true; } } if (!flag) { return true; } } return false; } private TextMeshProUGUI Create(RectTransform root, TMP_Text template) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Ground item label", new Type[2] { typeof(RectTransform), typeof(Image) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)root, false); Vector2 val3 = (val2.pivot = Vector2.zero); Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; Image component = val.GetComponent(); ((Graphic)component).color = PresentationTokens.Current.lootBackground; ((Graphic)component).raycastTarget = false; TextMeshProUGUI component2 = new GameObject("Name", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }).GetComponent(); ((TMP_Text)component2).transform.SetParent((Transform)(object)val2, false); ((TMP_Text)component2).rectTransform.anchorMin = Vector2.zero; ((TMP_Text)component2).rectTransform.anchorMax = Vector2.one; ((TMP_Text)component2).rectTransform.sizeDelta = Vector2.zero; ((TMP_Text)component2).font = template.font; ((TMP_Text)component2).fontSharedMaterial = ((TMP_Asset)template.font).material; ((TMP_Text)component2).fontSize = PresentationTokens.Current.tooltipFontSize; ((TMP_Text)component2).overflowMode = (TextOverflowModes)1; ((TMP_Text)component2).richText = false; ((TMP_Text)component2).alignment = (TextAlignmentOptions)514; ((Graphic)component2).raycastTarget = false; labels.Add(component2); return component2; } internal static bool InReach(ItemDrop item, Player player) { //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_0025: 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_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 centerPoint = ((Character)player).GetCenterPoint(); Collider componentInChildren = ((Component)item).GetComponentInChildren(); Vector3 val = ((Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.enabled) ? componentInChildren.ClosestPoint(centerPoint) : ((Component)item).transform.position); Vector3 val2 = val - centerPoint; return ScreenSpaceMath.InReach(((Vector3)(ref val2)).sqrMagnitude); } internal ItemDrop Hit() { //IL_002b: 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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)displayRoot) || !AltHeld || Hud.IsUserHidden()) { return null; } Rect rect = displayRoot.rect; Vector2 val = ((Rect)(ref rect)).min + Vector2.Scale(ScreenCoordinates.PointerViewport, ((Rect)(ref rect)).size); for (int i = 0; i < occupied.Count; i++) { Rect val2 = occupied[i]; if (((Rect)(ref val2)).Contains(val)) { return displayed[i]; } } return null; } internal void Clear() { labels.Clear(); occupied.Clear(); displayed.Clear(); displayRoot = null; } } internal sealed class HealthWidget { internal readonly RectTransform Root; private readonly TMP_Text name; private readonly TMP_Text value; private readonly Image fallbackFill; private readonly Image healthBackground; private bool healthVisible = true; private bool nameVisible = true; private bool characterVisible; private readonly CanvasGroup opacity; private readonly Color baseColor; private readonly float width; internal bool HasVisibleContent => healthVisible || nameVisible; internal HealthWidget(Hud hud, Transform parent, float width, bool targetWidget = false) { //IL_0049: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_027c: 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_01d9: Invalid comparison between Unknown and I4 this.width = width; PresentationTokens current = PresentationTokens.Current; Root = new GameObject("IsometricHealth", new Type[2] { typeof(RectTransform), typeof(CanvasGroup) }).GetComponent(); ((Transform)Root).SetParent(parent, false); opacity = ((Component)Root).GetComponent(); opacity.interactable = false; opacity.blocksRaycasts = false; Root.sizeDelta = new Vector2(width, current.nameHeight + current.healthHeight); TMP_Text healthText = hud.m_healthText; name = CreateText(healthText, "Name", current.nameSize, current.nameHeight); name.rectTransform.anchoredPosition = new Vector2(0f, current.healthHeight); GuiBar val = FindNativeBar(hud, targetWidget); Image val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponentInChildren(true) : null); baseColor = ((Object.op_Implicit((Object)(object)val2) && ((Graphic)val2).color.a > 0f) ? ((Graphic)val2).color : current.healthColor); Image val3 = (healthBackground = Image("HealthBackground", (Transform)(object)Root, current.surfaceColor)); ((Graphic)val3).rectTransform.sizeDelta = new Vector2(width, current.healthHeight); fallbackFill = Image("HealthFill", ((Component)val3).transform, baseColor); if (Object.op_Implicit((Object)(object)val2) && ((Graphic)val2).color.a > 0f) { fallbackFill.sprite = val2.sprite; fallbackFill.type = (Type)((int)val2.type == 1); } RectTransform rectTransform = ((Graphic)fallbackFill).rectTransform; RectTransform rectTransform2 = ((Graphic)fallbackFill).rectTransform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 0.5f); rectTransform2.anchorMax = val4; rectTransform.anchorMin = val4; ((Graphic)fallbackFill).rectTransform.pivot = new Vector2(0f, 0.5f); ((Graphic)fallbackFill).rectTransform.anchoredPosition = Vector2.zero; value = CreateText(healthText, "HealthValue", current.healthTextSize, current.healthHeight); value.rectTransform.anchoredPosition = Vector2.zero; Graphic[] componentsInChildren = ((Component)Root).GetComponentsInChildren(true); foreach (Graphic val5 in componentsInChildren) { val5.raycastTarget = false; } } private static GuiBar FindNativeBar(Hud hud, bool targetWidget) { if (Object.op_Implicit((Object)(object)EnemyHud.instance) && Object.op_Implicit((Object)(object)EnemyHud.instance.m_baseHudPlayer)) { GameObject val = (targetWidget ? EnemyHud.instance.m_baseHud : EnemyHud.instance.m_baseHudPlayer); Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.transform.Find("Health/health_fast") : null); if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Component)val2).GetComponent())) { return ((Component)val2).GetComponent(); } } return hud.m_healthBarFast; } private TMP_Text CreateText(TMP_Text source, string label, float size, float height) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_007c: Unknown result type (might be due to invalid IL or missing references) TMP_Text component = new GameObject(label, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }).GetComponent(); component.transform.SetParent((Transform)(object)Root, false); if (Object.op_Implicit((Object)(object)source) && Object.op_Implicit((Object)(object)source.font)) { component.font = source.font; component.fontSharedMaterial = ((TMP_Asset)source.font).material; component.fontStyle = source.fontStyle; } ((Object)component).name = label; ((Behaviour)component).enabled = true; ((Component)component).gameObject.SetActive(true); component.text = ""; component.fontSize = size; component.enableAutoSizing = false; component.overflowMode = (TextOverflowModes)1; component.alignment = (TextAlignmentOptions)514; ((Graphic)component).color = PresentationTokens.Current.textColor; RectTransform rectTransform = component.rectTransform; RectTransform rectTransform2 = component.rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform2.anchorMax = val; rectTransform.anchorMin = val; component.rectTransform.pivot = new Vector2(0.5f, 0f); component.rectTransform.sizeDelta = new Vector2(width, height); ((Transform)component.rectTransform).localScale = Vector3.one; ((Transform)component.rectTransform).localRotation = Quaternion.identity; component.margin = Vector4.zero; return component; } private static Image Image(string name, Transform parent, Color color) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Image component = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent(); ((Component)component).transform.SetParent(parent, false); RectTransform rectTransform = ((Graphic)component).rectTransform; RectTransform rectTransform2 = ((Graphic)component).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform2.anchorMax = val; rectTransform.anchorMin = val; ((Graphic)component).rectTransform.pivot = new Vector2(0.5f, 0f); ((Graphic)component).color = color; return component; } internal void SetHealthVisible(bool visible) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (healthVisible != visible) { healthVisible = visible; ((Component)healthBackground).gameObject.SetActive(visible); ((Component)value).gameObject.SetActive(visible); PresentationTokens current = PresentationTokens.Current; name.rectTransform.anchoredPosition = new Vector2(0f, visible ? current.healthHeight : 0f); Root.sizeDelta = new Vector2(width, current.nameHeight + (visible ? current.healthHeight : 0f)); RefreshVisibility(); } } internal void SetNameVisible(bool visible) { if (nameVisible != visible) { nameVisible = visible; ((Component)name).gameObject.SetActive(visible); RefreshVisibility(); } } internal void SetOpacity(float value) { opacity.alpha = Mathf.Clamp01(value); } private void RefreshVisibility() { ((Component)Root).gameObject.SetActive(characterVisible && HasVisibleContent); } internal void Update(Character character, bool hostile) { //IL_00c4: 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_00ec: Unknown result type (might be due to invalid IL or missing references) characterVisible = Object.op_Implicit((Object)(object)character); RefreshVisibility(); if (Object.op_Implicit((Object)(object)character)) { float num = Mathf.Clamp01(character.GetHealthPercentage()); TMP_Text obj = name; Player val = (Player)(object)((character is Player) ? character : null); obj.text = ((val != null) ? val.GetPlayerName() : Localization.instance.Localize(character.GetHoverName())); value.text = Mathf.CeilToInt(character.GetHealth()) + " / " + Mathf.CeilToInt(character.GetMaxHealth()); if (Object.op_Implicit((Object)(object)fallbackFill)) { ((Graphic)fallbackFill).color = (hostile ? PresentationTokens.Current.threatColor : baseColor); ((Graphic)fallbackFill).rectTransform.sizeDelta = new Vector2(width * num, PresentationTokens.Current.healthHeight); } } } internal void Dispose() { if (Object.op_Implicit((Object)(object)Root)) { Object.Destroy((Object)(object)((Component)Root).gameObject); } } } internal sealed class InputContextGuard { private readonly IsometricConfig config; private readonly Func available; private readonly Func nativeInputAllowed; private static readonly List<(object Instance, PropertyInfo Property)> ConfigurationWindows = new List<(object, PropertyInfo)>(); private static readonly List> AlmanacWindows = new List>(); private static int cachedPluginCount = -1; internal InputContextGuard(IsometricConfig config, Func available, Func nativeInputAllowed = null) { this.config = config; this.available = available; this.nativeInputAllowed = nativeInputAllowed ?? ((Func)(() => true)); } internal bool IsLocal(Player player) { return Object.op_Implicit((Object)(object)player) && (Object)(object)player == (Object)(object)Player.m_localPlayer && ((Character)player).IsOwner(); } internal bool IsModeAllowed() { return ModeAllowed(allowSwimming: false); } private bool ModeAllowed(bool allowSwimming, bool allowSeated = false) { Player localPlayer = Player.m_localPlayer; bool flag = allowSeated && Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).IsSitting(); return available() && config.Enabled.Value && Application.isFocused && IsLocal(localPlayer) && Object.op_Implicit((Object)(object)GameCamera.instance) && !GameCamera.InFreeFly() && !ZInput.IsGamepadActive() && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting() && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).InIntro() && (allowSwimming || !((Character)localPlayer).IsSwimming()) && !((Character)localPlayer).IsRiding() && (flag || (!((Character)localPlayer).IsAttached() && !((Character)localPlayer).IsSitting() && !((Character)localPlayer).InEmote())) && localPlayer.GetDoodadController() == null && !Object.op_Implicit((Object)(object)localPlayer.GetControlledShip()); } internal bool IsUiOpen() { return InventoryGui.IsVisible() || IsModalUiOpen(); } internal bool IsModalUiOpen() { return Menu.IsVisible() || Menu.IsActive() || Console.IsVisible() || Minimap.IsOpen() || Minimap.InTextInput() || TextInput.IsVisible() || StoreGui.IsVisible() || UnifiedPopup.IsVisible() || ZNet.IsPasswordDialogShowing() || Hud.IsPieceSelectionVisible() || Hud.InRadial() || PlayerCustomizaton.IsBarberGuiVisible() || (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) || ConfigurationWindowOpen() || AlmanacWindowOpen(); } private static void RefreshWindowBindings() { if (cachedPluginCount == Chainloader.PluginInfos.Count) { return; } ConfigurationWindows.Clear(); AlmanacWindows.Clear(); cachedPluginCount = Chainloader.PluginInfos.Count; foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if ((Object)(object)value.Instance == (Object)null) { continue; } string gUID = value.Metadata.GUID; if (gUID.IndexOf("configurationmanager", StringComparison.OrdinalIgnoreCase) >= 0) { PropertyInfo property = ((object)value.Instance).GetType().GetProperty("DisplayingWindow", BindingFlags.Instance | BindingFlags.Public); if (property?.PropertyType == typeof(bool)) { ConfigurationWindows.Add((value.Instance, property)); } } if (!gUID.Equals("RustyMods.Almanac", StringComparison.OrdinalIgnoreCase)) { continue; } Assembly assembly = ((object)value.Instance).GetType().Assembly; string[] array = new string[3] { "AlmanacPanel", "DialoguePanel", "NPCCustomization" }; foreach (string text in array) { MethodInfo methodInfo = assembly.GetType("Almanac.UI." + text)?.GetMethod("IsVisible", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (methodInfo?.ReturnType == typeof(bool) && Delegate.CreateDelegate(typeof(Func), methodInfo, throwOnBindFailure: false) is Func item) { AlmanacWindows.Add(item); } } } } internal static bool ConfigurationWindowOpen() { RefreshWindowBindings(); foreach (var configurationWindow in ConfigurationWindows) { if ((bool)configurationWindow.Property.GetValue(configurationWindow.Instance, null)) { return true; } } return false; } private static bool AlmanacWindowOpen() { foreach (Func almanacWindow in AlmanacWindows) { if (almanacWindow()) { return true; } } return false; } internal bool IsGameplayInputAllowed() { return IsModeAllowed() && !((Character)Player.m_localPlayer).InPlaceMode() && !IsUiOpen() && nativeInputAllowed(); } internal bool IsCursorInputAllowed() { return IsModeAllowed() && !IsUiOpen() && nativeInputAllowed(); } internal bool IsCameraControlAllowed() { return IsGameplayInputAllowed(); } internal bool IsPointerCaptureAllowed() { return ModeAllowed(allowSwimming: true, allowSeated: true) && !IsUiOpen() && nativeInputAllowed(); } internal bool IsWorldPointerContext() { return ModeAllowed(allowSwimming: false, allowSeated: true); } internal bool IsWorldPointerAllowed() { return IsWorldPointerContext() && !IsUiOpen() && nativeInputAllowed(); } internal bool IsMovementOverrideAllowed() { return ModeAllowed(allowSwimming: true) && nativeInputAllowed(); } internal bool IsInventoryWorldClickAllowed() { return IsWorldPointerContext() && InventoryGui.IsVisible() && !IsModalUiOpen(); } internal bool IsCameraViewAllowed() { return available() && config.Enabled.Value && IsLocal(Player.m_localPlayer) && Object.op_Implicit((Object)(object)GameCamera.instance) && !GameCamera.InFreeFly(); } } internal sealed class IsometricCameraController { private readonly LocalOcclusionController visibility = new LocalOcclusionController(); private readonly BowTrajectoryPreview trajectory = new BowTrajectoryPreview(); private Player followedPlayer; private GameCamera followedCamera; private Vector3 anchor; private float yaw; private float pitch; private bool freeOrientation; private bool orbitPress; private bool wasInterior; private int orbitFrame = -1; private const float OrbitDegreesPerPixel = 0.22f; private readonly CameraTurn turn = new CameraTurn(); private bool ownsCursor; private CursorLockMode previousLock; private bool previousVisible; private bool projectionOwned; private bool originalOrthographic; private float originalFov; private float originalNear; private float originalFar; private Camera originalSky; private float originalSkyFov; private float configuredDistance = float.NaN; private float viewDistance; internal bool Active { get; private set; } internal Camera Camera { get; private set; } internal Vector3 Forward => Quaternion.Euler(0f, yaw, 0f) * Vector3.forward; internal bool IsHiddenObstacle(Collider collider) { return visibility.IsObstruction(collider); } internal bool HammerSurface(Ray ray, ref RaycastHit hit) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return visibility.HammerSurface(ray, ref hit); } internal bool IsHiddenContent(GameObject target) { return Object.op_Implicit((Object)(object)target) && visibility.IsContentHidden(target.GetComponentInParent()); } internal void SetHoveredBush(Transform target) { visibility.SetHoveredBush(target); } internal void Turn(int direction) { if (Active) { turn.Turn(direction); } } internal bool IsOrbitHeld(InputContextGuard guard, IsometricConfig config) { return Active && config.FreeCameraRotation.Value && guard.IsCursorInputAllowed() && ZInput.GetMouseButton(2) && (ZInput.GetKey((KeyCode)308, true) || ZInput.GetKey((KeyCode)307, true)) && !ZInput.GetKey((KeyCode)304, true) && !ZInput.GetKey((KeyCode)303, true); } internal bool OrbitOwnsMiddle(InputContextGuard guard, IsometricConfig config) { if (!ZInput.GetMouseButton(2)) { orbitPress = false; } else if (IsOrbitHeld(guard, config)) { orbitPress = true; } return orbitPress; } internal void Update(GameCamera camera, Camera renderCamera, Camera skyCamera, float fov, float dt, InputContextGuard guard, IsometricConfig config) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02be: 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_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: 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_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; bool flag = ((Character)localPlayer).InInterior(); bool flag2 = flag != wasInterior; wasInterior = flag; bool flag3 = (Object)(object)localPlayer != (Object)(object)followedPlayer || (Object)(object)camera != (Object)(object)followedCamera || (Object.op_Implicit((Object)(object)Camera) && (Object)(object)Camera != (Object)(object)renderCamera); if (flag3 && projectionOwned) { Suspend(); } if (!Active || flag3) { yaw = CameraMath.SnapDiagonalYaw(flag3 ? ((Component)camera).transform.eulerAngles.y : yaw); turn.Reset(yaw); pitch = config.CameraPitch.Value; freeOrientation = config.FreeCameraRotation.Value; anchor = ((Component)localPlayer).transform.position; followedPlayer = localPlayer; followedCamera = camera; } Active = true; if (!projectionOwned) { originalOrthographic = renderCamera.orthographic; originalFov = renderCamera.fieldOfView; originalNear = renderCamera.nearClipPlane; originalFar = renderCamera.farClipPlane; originalSky = skyCamera; if (Object.op_Implicit((Object)(object)originalSky)) { originalSkyFov = originalSky.fieldOfView; } projectionOwned = true; } Camera = renderCamera; if (flag3 || configuredDistance != config.CameraDistance.Value) { configuredDistance = config.CameraDistance.Value; viewDistance = configuredDistance; } if (guard.IsCameraControlAllowed()) { viewDistance = CameraMath.Zoom(viewDistance, ZInput.GetMouseScrollWheel(), config.CameraZoomSensitivity.Value); } (float, float) tuple = (flag ? CameraMath.InteriorProjection(viewDistance, fov, config.Fov.Value) : (CameraMath.SimulatedDistance(viewDistance, fov, config.Fov.Value), config.Fov.Value)); var (num, _) = tuple; if (flag2) { anchor = ((Component)localPlayer).transform.position; } anchor = Vector3.Lerp(anchor, ((Component)localPlayer).transform.position, ControlMath.FollowWeight(config.CameraFollowSmoothness.Value, dt)); UpdateOrientation(guard, config, dt); Quaternion val = Quaternion.Euler(pitch, yaw, 0f); ((Component)camera).transform.SetPositionAndRotation(anchor + Vector3.up * config.CameraHeight.Value - val * Vector3.forward * num, val); renderCamera.orthographic = false; renderCamera.ResetProjectionMatrix(); renderCamera.fieldOfView = tuple.Item2; renderCamera.farClipPlane = originalFar + Mathf.Max(0f, num - viewDistance); if (Object.op_Implicit((Object)(object)skyCamera)) { skyCamera.fieldOfView = renderCamera.fieldOfView; } visibility.Update(renderCamera, localPlayer, Mathf.Max(0f, num - viewDistance), config); } private void UpdateOrientation(InputContextGuard guard, IsometricConfig config, float dt) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) bool value = config.FreeCameraRotation.Value; if (!value) { if (freeOrientation) { turn.Reset(CameraMath.SnapDiagonalYaw(yaw)); } pitch = config.CameraPitch.Value; } freeOrientation = value; if (IsOrbitHeld(guard, config)) { if (orbitFrame != Time.frameCount) { orbitFrame = Time.frameCount; orbitPress = true; Vector2 val = ZInput.GetMouseDelta() * 0.22f; yaw = CameraMath.NormalizeYaw(yaw + val.x); pitch = Mathf.Clamp(pitch - val.y, 25f, 75f); turn.Reset(yaw); } } else { yaw = turn.Advance(dt, PresentationTokens.Current.cameraTurnDuration); } } internal void Present(InputContextGuard guard) { if (guard.IsGameplayInputAllowed()) { trajectory.Update(Camera, Player.m_localPlayer); } else { trajectory.Hide(); } } internal void CaptureCursor() { //IL_0010: 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) if (!ownsCursor) { previousLock = ZCursor.LockState; previousVisible = Cursor.visible; ownsCursor = true; } ZCursor.LockState = (CursorLockMode)2; ZCursor.Show(); } internal void ReleaseCursor() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (ownsCursor) { ZCursor.LockState = previousLock; if (previousVisible) { ZCursor.Show(); } else { ZCursor.Hide(); } ownsCursor = false; } } internal void Suspend() { visibility.Suspend(); if (projectionOwned && Object.op_Implicit((Object)(object)Camera)) { Camera.orthographic = originalOrthographic; Camera.fieldOfView = originalFov; Camera.nearClipPlane = originalNear; Camera.farClipPlane = originalFar; Camera.ResetProjectionMatrix(); if (Object.op_Implicit((Object)(object)originalSky)) { originalSky.fieldOfView = originalSkyFov; } } projectionOwned = false; Active = false; orbitPress = false; orbitFrame = -1; Camera = null; trajectory.Dispose(); ReleaseCursor(); } } internal sealed class IsometricConfig { internal readonly ConfigEntry Enabled; internal readonly ConfigEntry HideRoofs; internal readonly ConfigEntry RoomCutaway; internal readonly ConfigEntry BuildingCutaway; internal readonly ConfigEntry EnemyGroundRings; internal readonly ConfigEntry PlayerGroundRing; internal readonly ConfigEntry PlayerHealthBar; internal readonly ConfigEntry PlayerName; internal readonly ConfigEntry FreeCameraRotation; internal readonly ConfigEntry ViewToggleKey; internal readonly ConfigEntry ExperienceAbovePlayer; internal readonly ConfigEntry CameraDistance; internal readonly ConfigEntry CameraHeight; internal readonly ConfigEntry CameraPitch; internal readonly ConfigEntry CameraFollowSmoothness; internal readonly ConfigEntry CameraZoomSensitivity; internal readonly ConfigEntry Fov; internal readonly ConfigEntry OcclusionRadius; internal readonly ConfigEntry HaloFeather; internal readonly ConfigEntry WallCutHeight; internal readonly ConfigEntry RoomSearchRadius; internal readonly ConfigEntry BuildingWallHeight; internal IsometricConfig(ConfigFile config) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown Enabled = config.Bind("General", "Enabled", true, "Enable local isometric camera and mouse aiming."); ViewToggleKey = config.Bind("General", "ViewToggleKey", (KeyCode)289, "Switch camera views. Hold either Ctrl key with this key to toggle the building cutaway."); EnemyGroundRings = config.Bind("HUD", "EnemyGroundRings", true, "Show ground rings below visible hostile creatures in isometric mode. Health bars remain independent."); PlayerGroundRing = config.Bind("HUD", "PlayerGroundRing", true, "Show a ground ring below the local player in isometric mode."); PlayerHealthBar = config.Bind("HUD", "PlayerHealthBar", true, "Show the player's overhead health bar, values, status icons and other nameplate decorations. The name has a separate setting."); PlayerName = config.Bind("HUD", "PlayerName", true, "Show the local player's name above the character. This does not hide names of other players."); FreeCameraRotation = config.Bind("Camera", "FreeCameraRotation", false, "Hold Alt and middle mouse, then drag to orbit the player."); CameraDistance = config.Bind("Camera", "CameraDistance", 14f, new ConfigDescription("Distance from the elevated follow point in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 30f), Array.Empty())); CameraHeight = config.Bind("Camera", "CameraHeight", 1.5f, new ConfigDescription("Follow point height above the player's feet in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); CameraPitch = config.Bind("Camera", "CameraPitch", 35.26439f, new ConfigDescription("Downward view angle in degrees. The default gives equal isometric axes.", (AcceptableValueBase)(object)new AcceptableValueRange(25f, 75f), Array.Empty())); CameraFollowSmoothness = config.Bind("Camera", "CameraFollowSmoothness", 8f, new ConfigDescription("Follow responsiveness per second; larger values follow faster.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 30f), Array.Empty())); Fov = config.Bind("Camera", "Fov", 15f, new ConfigDescription("Narrow perspective field of view. Distance adjusts to keep framing.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 25f), Array.Empty())); CameraZoomSensitivity = config.Bind("Camera", "CameraZoomSensitivity", 3f, new ConfigDescription("Framing distance change per wheel input unit. Wheel remains native while building.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 10f), Array.Empty())); OcclusionRadius = config.Bind("Visibility", "OcclusionRadius", 3.5f, new ConfigDescription("Radius of the local obstruction and ceiling reveal area in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 8f), Array.Empty())); HideRoofs = config.Bind("Visibility", "HideRoofs", true, "Reveal building roofs and upper floors above the local player."); HaloFeather = config.Bind("Visibility", "HaloFeather", 0.65f, new ConfigDescription("Fraction of the reveal radius used for the smooth transparency transition.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 1f), Array.Empty())); RoomCutaway = config.Bind("Visibility", "RoomCutaway", true, "Enable local room and storey cutaway with protected rear walls and walking surfaces."); WallCutHeight = config.Bind("Visibility", "WallCutHeight", 0.5f, new ConfigDescription("Visible height of camera-facing room walls above the current floor in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 1.5f), Array.Empty())); RoomSearchRadius = config.Bind("Visibility", "RoomSearchRadius", 16f, new ConfigDescription("Maximum local room boundary search radius in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(6f, 24f), Array.Empty())); BuildingCutaway = config.Bind("Visibility", "BuildingCutaway", true, "Use a connected-building cutaway with hidden roof, lower front sides and complete rear sides. Ctrl plus the view toggle key toggles it in camera mode."); BuildingWallHeight = config.Bind("Visibility", "BuildingWallHeight", 1f, new ConfigDescription("Lower front wall course height in the Building cutaway, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 2f), Array.Empty())); ExperienceAbovePlayer = BindExperienceToggle(config); KeepFinite(BuildingWallHeight, 1f); KeepFinite(HaloFeather, 0.65f); KeepFinite(WallCutHeight, 0.5f); KeepFinite(RoomSearchRadius, 16f); KeepFinite(OcclusionRadius, 3.5f); KeepFinite(CameraDistance, 14f); KeepFinite(CameraHeight, 1.5f); KeepFinite(CameraPitch, 35.26439f); KeepFinite(CameraFollowSmoothness, 8f); KeepFinite(CameraZoomSensitivity, 3f); KeepFinite(Fov, 15f); } private static ConfigEntry BindExperienceToggle(ConfigFile config) { bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { ConfigEntry val = config.Bind("Compability PoV", "ExperienceAbovePlayer", "true", (ConfigDescription)null); string text = val.Value.Trim(); bool value = !string.Equals(text, "Disabled", StringComparison.OrdinalIgnoreCase); if (bool.TryParse(text, out var result)) { value = result; } config.Remove(((ConfigEntryBase)val).Definition); ConfigEntry val2 = config.Bind("Compability PoV", "ExperienceAbovePlayer", true, "Move Path of Valheiman experience numbers above the local player in isometric view."); val2.Value = value; return val2; } finally { config.SaveOnConfigSet = saveOnConfigSet; if (saveOnConfigSet) { config.Save(); } } } private static void KeepFinite(ConfigEntry entry, float fallback) { Normalize(); entry.SettingChanged += delegate { Normalize(); }; void Normalize() { if (float.IsNaN(entry.Value) || float.IsInfinity(entry.Value)) { entry.Value = fallback; } } } } internal sealed class IsometricFog { private const float NearDensity = 0.16f; private const float FarDensity = 0.045f; private const float ParticleAlpha = 0.12f; private const int MaxScopedParticles = 4096; private const int MaxRainParticles = 16384; private static readonly FieldRef EnvObject = AccessTools.FieldRefAccess("m_currentEnvObject"); private static readonly FieldRef EnvParticles = AccessTools.FieldRefAccess("m_currentPSystems"); private readonly HashSet emitters = new HashSet(); private readonly HashSet rainEmitters = new HashSet(); private readonly List search = new List(); private readonly Dictionary originals = new Dictionary(); private readonly List expired = new List(); private readonly List<(ParticleSystem System, int Count, bool Rain)> leased = new List<(ParticleSystem, int, bool)>(); private Particle[] particles = (Particle[])(object)new Particle[4096]; private readonly RainRoofCoverage roofs = new RainRoofCoverage(); private float nextSearch; private GameObject environment; private GameObject[] environmentParticles; private bool applied; private float density; private float end; internal void Apply(Camera camera, Player player, RoomCutawayController room, float roofRadius) { //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 if (!applied) { float num = Vector3.Distance(((Component)camera).transform.position, ((Character)player).GetCenterPoint()); float num2 = Mathf.Lerp(0.16f, 0.045f, Mathf.InverseLerp(16f, 65f, num)); density = RenderSettings.fogDensity; end = RenderSettings.fogEndDistance; applied = true; if ((int)RenderSettings.fogMode == 1) { float fogStartDistance = RenderSettings.fogStartDistance; RenderSettings.fogEndDistance = fogStartDistance + (end - fogStartDistance) / num2; } else { RenderSettings.fogDensity = density * num2; } ApplyParticles(Mathf.Lerp(0.12f, 0.048f, Mathf.InverseLerp(16f, 65f, num)), camera, player, room, roofRadius); } } private void ApplyParticles(float alphaScale, Camera camera, Player player, RoomCutawayController room, float roofRadius) { EnvMan instance = EnvMan.instance; GameObject val = (Object.op_Implicit((Object)(object)instance) ? EnvObject.Invoke(instance) : null); GameObject[] array = (Object.op_Implicit((Object)(object)instance) ? EnvParticles.Invoke(instance) : null); if (Time.unscaledTime >= nextSearch || (Object)(object)environment != (Object)(object)val || environmentParticles != array) { nextSearch = Time.unscaledTime + 1f; environment = val; environmentParticles = array; emitters.Clear(); rainEmitters.Clear(); expired.Clear(); foreach (ParticleSystem key in originals.Keys) { if (!Object.op_Implicit((Object)(object)key) || !((Component)key).gameObject.activeInHierarchy) { expired.Add(key); } } foreach (ParticleSystem item in expired) { originals.Remove(item); } DistantFogEmitter[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (DistantFogEmitter val2 in array2) { Collect(((Component)val2).gameObject, requireFogName: false); } MistEmitter[] array3 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (MistEmitter val3 in array3) { Collect(((Component)val3).gameObject, requireFogName: false); } if (Object.op_Implicit((Object)(object)environment)) { Collect(environment, requireFogName: true); } if (environmentParticles != null) { GameObject[] array4 = environmentParticles; foreach (GameObject scope in array4) { CollectRain(scope); } } CollectRain(environment); ParticleSystemRenderer[] array5 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (ParticleSystemRenderer val4 in array5) { Material sharedMaterial = ((Renderer)val4).sharedMaterial; if (RainRenderer(val4)) { rainEmitters.Add(val4); } else if (FogName(((Object)val4).name) || (Object.op_Implicit((Object)(object)sharedMaterial) && (FogName(((Object)sharedMaterial).name) || (Object.op_Implicit((Object)(object)sharedMaterial.shader) && FogName(((Object)sharedMaterial.shader).name))))) { emitters.Add(val4); } } emitters.ExceptWith(rainEmitters); } foreach (ParticleSystemRenderer emitter in emitters) { FilterParticles(emitter, alphaScale, rain: false); } if (rainEmitters.Count == 0) { return; } roofs.Begin(camera, player, room, roofRadius); foreach (ParticleSystemRenderer rainEmitter in rainEmitters) { FilterParticles(rainEmitter, 0f, rain: true); } } private void FilterParticles(ParticleSystemRenderer renderer, float alphaScale, bool rain) { //IL_00e4: 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_00ec: 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_00fb: Invalid comparison between Unknown and I4 //IL_0123: 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_0128: 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_0141: Invalid comparison between Unknown and I4 //IL_018f: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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) if (!Object.op_Implicit((Object)(object)renderer) || !((Renderer)renderer).enabled || !((Component)renderer).gameObject.activeInHierarchy || ((Renderer)renderer).forceRenderingOff) { return; } ParticleSystem component = ((Component)renderer).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || component.particleCount == 0 || component.particleCount > (rain ? 16384 : 4096)) { return; } if (component.particleCount > particles.Length) { Array.Resize(ref particles, Mathf.NextPowerOfTwo(component.particleCount)); } int num = component.GetParticles(particles); if (!originals.TryGetValue(component, out var value) || value.Length < num) { value = (Particle[])(object)new Particle[Mathf.NextPowerOfTwo(num)]; originals[component] = value; } MainModule main = component.main; Transform val = (((int)((MainModule)(ref main)).simulationSpace == 0) ? ((Component)component).transform : (((int)((MainModule)(ref main)).simulationSpace == 2) ? ((MainModule)(ref main)).customSimulationSpace : null)); Matrix4x4 toWorld = (Object.op_Implicit((Object)(object)val) ? val.localToWorldMatrix : Matrix4x4.identity); bool flag = rain && roofs.HasProjectedInterior && (int)renderer.renderMode == 1; float lengthScale = (flag ? Mathf.Abs(renderer.lengthScale) : 0f); float velocityScale = (flag ? Mathf.Abs(renderer.velocityScale) : 0f); bool flag2 = false; for (int i = 0; i < num; i++) { value[i] = particles[i]; if (!rain || HideRain(particles[i], toWorld, flag, lengthScale, velocityScale)) { flag2 = true; Color32 startColor = ((Particle)(ref particles[i])).startColor; startColor.a = (byte)Mathf.RoundToInt((float)(int)startColor.a * alphaScale); ((Particle)(ref particles[i])).startColor = startColor; if (rain) { ((Particle)(ref particles[i])).startSize3D = Vector3.zero; } } } if (flag2) { leased.Add((component, num, rain)); component.SetParticles(particles, num); } } private bool HideRain(Particle particle, Matrix4x4 toWorld, bool checkStreak, float lengthScale, float velocityScale) { //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) //IL_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Matrix4x4)(ref toWorld)).MultiplyPoint3x4(((Particle)(ref particle)).position); if (roofs.CoversRoomInView(val) || roofs.Covers(val)) { return true; } if (!checkStreak) { return false; } Vector3 val2 = ((Matrix4x4)(ref toWorld)).MultiplyVector(((Particle)(ref particle)).totalVelocity); float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.001f) { return false; } Vector3 val3 = val2 * (Mathf.Min(6f, lengthScale * ((Particle)(ref particle)).startSize + velocityScale * magnitude) / magnitude); return roofs.CoversRoomInView(val - val3) || roofs.CoversRoomInView(val + val3); } private void CollectRain(GameObject scope) { if (!Object.op_Implicit((Object)(object)scope)) { return; } search.Clear(); scope.GetComponentsInChildren(false, search); foreach (ParticleSystemRenderer item in search) { if (!Object.op_Implicit((Object)(object)item)) { continue; } if (RainRenderer(item)) { rainEmitters.Add(item); continue; } Transform parent = ((Component)item).transform.parent; while (Object.op_Implicit((Object)(object)parent) && parent.IsChildOf(scope.transform)) { if (RainName(((Object)parent).name)) { rainEmitters.Add(item); break; } parent = parent.parent; } } } private static bool RainRenderer(ParticleSystemRenderer renderer) { Material sharedMaterial = ((Renderer)renderer).sharedMaterial; return RainName(((Object)renderer).name) || (Object.op_Implicit((Object)(object)sharedMaterial) && (RainName(((Object)sharedMaterial).name) || (Object.op_Implicit((Object)(object)sharedMaterial.shader) && RainName(((Object)sharedMaterial.shader).name)))); } private static bool RainName(string name) { int num = name.IndexOf("rain", StringComparison.OrdinalIgnoreCase); if (num < 0 || name.IndexOf("rainbow", StringComparison.OrdinalIgnoreCase) >= 0) { return false; } if (num == 0 || !char.IsLetterOrDigit(name[num - 1])) { return true; } return name.IndexOf("heavyrain", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("lightrain", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("stormrain", StringComparison.OrdinalIgnoreCase) >= 0; } private void Collect(GameObject scope, bool requireFogName) { search.Clear(); scope.GetComponentsInChildren(false, search); foreach (ParticleSystemRenderer item in search) { if (!Object.op_Implicit((Object)(object)item)) { continue; } Transform val = ((Component)item).transform; while (Object.op_Implicit((Object)(object)val) && val.IsChildOf(scope.transform)) { if (!requireFogName || FogName(((Object)val).name)) { emitters.Add(item); break; } val = val.parent; } } } private static bool FogName(string name) { return name.IndexOf("fog", StringComparison.OrdinalIgnoreCase) >= 0 || (name.IndexOf("mist", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("mistlands", StringComparison.OrdinalIgnoreCase) < 0); } internal void Restore() { //IL_00e7: 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) if (!applied) { return; } RenderSettings.fogDensity = density; RenderSettings.fogEndDistance = end; foreach (var item in leased) { if (!Object.op_Implicit((Object)(object)item.System) || item.System.particleCount > particles.Length) { continue; } int num = item.System.GetParticles(particles); Particle[] array = originals[item.System]; for (int i = 0; i < Mathf.Min(num, item.Count); i++) { if (((Particle)(ref particles[i])).randomSeed == ((Particle)(ref array[i])).randomSeed) { ((Particle)(ref particles[i])).startColor = ((Particle)(ref array[i])).startColor; if (item.Rain) { ((Particle)(ref particles[i])).startSize3D = ((Particle)(ref array[i])).startSize3D; } } } item.System.SetParticles(particles, num); } leased.Clear(); applied = false; } internal void ClearRainCoverage() { roofs.Clear(); } } internal sealed class IsometricHudController { private readonly TargetSelection selection = new TargetSelection(); private readonly EnemyPresentation enemies = new EnemyPresentation(); private readonly RemotePlayerPresentation players = new RemotePlayerPresentation(); private readonly SurfaceRing playerRing = new SurfaceRing(playerRing: true); private readonly StealthIndicatorPosition stealth = new StealthIndicatorPosition(); private readonly GroundItemLabels loot = new GroundItemLabels(); private Hud owner; private Canvas canvas; private RectTransform root; private readonly SelectedHudMirror targetHealth = new SelectedHudMirror(); private HealthWidget localFallback; private int clickFrame = -1; internal ItemDrop ItemAtLabel() { return loot.Hit(); } internal bool ShowPlayerBar(Player player) { return RemotePlayerPresentation.Opacity(Plugin.Instance.CameraController.Camera, Player.m_localPlayer, player) > 0f; } internal void PreparePlayerBars(EnemyHud hud, Player player) { players.Prepare(hud, player); } internal void Update(IsometricCameraController controller, Player player, bool selectionAllowed, bool lootAllowed, bool windowOpen, IsometricConfig settings) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) Hud instance = Hud.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)controller.Camera)) { Suspend(); return; } if ((Object)(object)owner != (Object)(object)instance || !Object.op_Implicit((Object)(object)root)) { Suspend(); Create(instance); } ((Behaviour)canvas).enabled = !windowOpen; enemies.UpdateNativeVisibility(controller, player, windowOpen); if (selectionAllowed && ZInput.GetMouseButtonDown(0) && clickFrame != Time.frameCount && !Object.op_Implicit((Object)(object)ItemAtLabel())) { clickFrame = Time.frameCount; selection.Click(TargetPicker.Pick(controller, player, ZInput.pointerPosition)); } selection.Validate((Character target2) => TargetPicker.Retain(target2, player, controller)); Canvas componentInParent = ((Component)instance).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { canvas.scaleFactor = componentInParent.rootCanvas.scaleFactor; } loot.Update(root, instance, controller, player, lootAllowed); Character target = selection.Target; RectTransform val = players.Update(controller.Camera, player, settings); GameObject val2 = EnemyPresentation.NativeName(player); TMP_Text val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent() : null); bool flag = Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val3) && ((Behaviour)val3).isActiveAndEnabled && ((Graphic)val3).color.a > 0.01f && !string.IsNullOrWhiteSpace(val3.text); bool flag2 = settings.PlayerName.Value && !flag; bool flag3 = settings.PlayerHealthBar.Value && !Object.op_Implicit((Object)(object)val); if (localFallback == null && (flag2 || flag3)) { localFallback = new HealthWidget(instance, (Transform)(object)root, PresentationTokens.Current.playerWidth); } if (localFallback != null) { localFallback.SetNameVisible(flag2); localFallback.SetHealthVisible(flag3); localFallback.Update((Character)(object)player, hostile: false); ScreenCoordinates.PlaceAbove(localFallback.Root, controller.Camera, ((Character)player).GetTopPoint() + Vector3.up * (PresentationTokens.Current.headOffset + 0.25f), !Hud.IsUserHidden() && localFallback.HasVisibleContent); if (!Object.op_Implicit((Object)(object)val) && ((Component)localFallback.Root).gameObject.activeSelf) { val = localFallback.Root; } } if (!windowOpen && Object.op_Implicit((Object)(object)val)) { stealth.Update(instance, val); } else { stealth.Restore(); } enemies.Update(controller.Camera, player, instance, root, settings.EnemyGroundRings.Value); if (settings.PlayerGroundRing.Value && !Hud.IsUserHidden()) { playerRing.Update((Character)(object)player); } else { playerRing.Hide(); } GameObject val4 = ((Object.op_Implicit((Object)(object)target) && target.IsBoss()) ? EnemyPresentation.NativeBar(target) : null); if (!Object.op_Implicit((Object)(object)target)) { targetHealth.Dispose(); } else { targetHealth.Show((!windowOpen && (!Object.op_Implicit((Object)(object)val4) || !val4.activeInHierarchy)) ? enemies.OverheadBar(target) : null, root, target, controller.Camera); } } private void Create(Hud hud) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown owner = hud; GameObject val = new GameObject("IsometricHud", new Type[2] { typeof(RectTransform), typeof(Canvas) }); canvas = val.GetComponent(); canvas.renderMode = (RenderMode)0; Canvas componentInParent = ((Component)hud).GetComponentInParent(); canvas.sortingOrder = (Object.op_Implicit((Object)(object)componentInParent) ? (componentInParent.rootCanvas.sortingOrder - 1) : (-1)); if (Object.op_Implicit((Object)(object)componentInParent)) { canvas.scaleFactor = componentInParent.rootCanvas.scaleFactor; } root = val.GetComponent(); Canvas.ForceUpdateCanvases(); } internal void Suspend() { selection.Clear(); stealth.Restore(); enemies.Dispose(); players.Dispose(); loot.Clear(); playerRing.Dispose(); targetHealth.Dispose(); localFallback?.Dispose(); localFallback = null; if (Object.op_Implicit((Object)(object)root)) { Object.Destroy((Object)(object)((Component)root).gameObject); } root = null; canvas = null; owner = null; } } internal sealed class KeyHintVisibility { private static readonly string[] Names = new string[7] { "m_buildHints", "m_combatHints", "m_inventoryHints", "m_inventoryWithContainerHints", "m_fishingHints", "m_barberHints", "m_radialHints" }; private static readonly FieldInfo[] Fields = Array.ConvertAll(Names, (string name) => AccessTools.Field(typeof(KeyHints), name)); private readonly Dictionary groups = new Dictionary(); internal void Hide(KeyHints hints) { if (!Object.op_Implicit((Object)(object)hints)) { return; } FieldInfo[] fields = Fields; for (int i = 0; i < fields.Length; i++) { object? obj = fields[i]?.GetValue(hints); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { CanvasGroup val2 = val.GetComponent(); bool item = !Object.op_Implicit((Object)(object)val2); if (!Object.op_Implicit((Object)(object)val2)) { val2 = val.AddComponent(); } if (!groups.ContainsKey(val2)) { groups.Add(val2, (val2.alpha, item)); } val2.alpha = 0f; } } } internal void Restore() { foreach (KeyValuePair group in groups) { if (Object.op_Implicit((Object)(object)group.Key)) { group.Key.alpha = group.Value.Item1; if (group.Value.Item2) { Object.Destroy((Object)(object)group.Key); } } } groups.Clear(); } } internal sealed class LocalOcclusionController { private readonly struct ViewState { internal readonly NativeRendererColors colors; internal readonly bool hidden; internal readonly ShadowCastingMode shadow; internal ViewState(Renderer renderer, NativeRendererColors colors) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) this.colors = colors; hidden = renderer.forceRenderingOff; shadow = renderer.shadowCastingMode; } } private static readonly int WorldMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "vehicle", "viewblock" }); private readonly HashSet blockers = new HashSet(); private readonly HashSet obstacles = new HashSet(); private readonly List candidates = new List(); private readonly HashSet candidateSet = new HashSet(); private readonly HashSet revealSources = new HashSet(); private readonly List renderStack = new List(); private readonly List nearbyCharacters = new List(); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[128]; private readonly Collider[] overlaps = (Collider[])(object)new Collider[128]; private readonly StateLease lease; private readonly Dictionary colorStates = new Dictionary(); private readonly HashSet obstacleRoots = new HashSet(); private readonly HashSet bushRenderers = new HashSet(); private Transform bush; private float revealRadius; private IsometricConfig config; private readonly RoomCutawayController room = new RoomCutawayController(); private readonly RoomCutawayRenderer roomRenderer = new RoomCutawayRenderer(); private readonly NaturalOcclusionController natural = new NaturalOcclusionController(); private readonly NaturalRevealRenderer naturalRenderer = new NaturalRevealRenderer(delegate(string message) { Plugin.Instance?.Warn(message); }); private readonly VisibilityTiming timing = new VisibilityTiming(); private Camera main; private Player player; private float shadowOffset; private float originalShadow; private bool ownsShadow; private bool ownsOcclusion; private bool originalOcclusion; private float nextSearch; private readonly IsometricFog fog = new IsometricFog(); internal LocalOcclusionController() { lease = new StateLease((Renderer item) => Object.op_Implicit((Object)(object)item), Capture, ApplyRenderer, delegate(Renderer item, ViewState state) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) state.colors?.Restore(); item.forceRenderingOff = state.hidden; item.shadowCastingMode = state.shadow; }); } private ViewState Capture(Renderer renderer) { bool flag = bushRenderers.Contains(renderer) && !room.Hidden.Contains(renderer) && !roomRenderer.CutSources.Contains(renderer); NativeRendererColors value = null; if (flag) { if (!colorStates.TryGetValue(renderer, out value)) { value = new NativeRendererColors(renderer); colorStates.Add(renderer, value); } value.Capture(); } return new ViewState(renderer, flag ? value : null); } private void ApplyRenderer(Renderer renderer, ViewState state) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 bool flag = room.Hidden.Contains(renderer) || roomRenderer.CutSources.Contains(renderer); if (state.colors != null) { state.colors.Apply(fade: false); } else if (flag) { if ((int)state.shadow == 0) { renderer.forceRenderingOff = true; } else { renderer.shadowCastingMode = (ShadowCastingMode)3; } } } internal void SetHoveredBush(Transform target) { if ((Object)(object)bush == (Object)(object)target) { return; } bush = target; bushRenderers.Clear(); if (!Object.op_Implicit((Object)(object)bush)) { return; } candidates.Clear(); ((Component)bush).GetComponentsInChildren(false, candidates); foreach (Renderer candidate in candidates) { if (Object.op_Implicit((Object)(object)candidate) && !Object.op_Implicit((Object)(object)((Component)candidate).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)candidate).GetComponentInParent())) { bushRenderers.Add(candidate); } } } internal bool IsObstruction(Collider collider) { return Object.op_Implicit((Object)(object)collider) && !room.Protects(collider) && (natural.Contains(collider) || HasRoomMask(collider) || (naturalRenderer.Active && (obstacles.Contains(collider) || obstacleRoots.Contains(Root(collider))))); } internal bool IsContentHidden(Piece piece) { return room.IsHiddenContent(piece); } internal bool HammerSurface(Ray ray, ref RaycastHit hit) { //IL_004e: 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_00a6: 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_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_00be: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) if (!IsObstruction(((RaycastHit)(ref hit)).collider)) { return true; } Piece componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); if (room.HasMask(componentInParent, roomRenderer.CutSources)) { return room.HammerSurface(componentInParent, ray, ref hit); } if (!Object.op_Implicit((Object)(object)main) || !Object.op_Implicit((Object)(object)player) || !naturalRenderer.Active) { return true; } Vector3 val = main.WorldToViewportPoint(((Character)player).GetCenterPoint()); Vector3 val2 = main.WorldToViewportPoint(((RaycastHit)(ref hit)).point); if (val2.z >= val.z) { return true; } Vector3 val3 = main.WorldToViewportPoint(((Character)player).GetCenterPoint() + ((Component)main).transform.up * revealRadius); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor((val2.x - val.x) * main.aspect, val2.y - val.y); return ((Vector2)(ref val4)).magnitude >= Mathf.Abs(val3.y - val.y); } private bool HasRoomMask(Collider collider) { return Object.op_Implicit((Object)(object)collider) && room.HasMask(((Component)collider).GetComponentInParent(), roomRenderer.CutSources); } private static Transform Root(Collider collider) { Component val = (Component)(object)((Component)collider).GetComponentInParent(); if (!Object.op_Implicit((Object)(object)val)) { val = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)val)) { val = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)val)) { val = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)val)) { val = (Component)(object)collider.attachedRigidbody; } return Object.op_Implicit((Object)(object)val) ? val.transform : ((Component)collider).transform; } internal void Update(Camera camera, Player localPlayer, float extraDistance, IsometricConfig settings) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown Restore(); renderStack.Clear(); shadowOffset = extraDistance; config = settings; if (!((Object)(object)main == (Object)(object)camera) || !((Object)(object)player == (Object)(object)localPlayer)) { Suspend(); main = camera; player = localPlayer; shadowOffset = extraDistance; config = settings; revealRadius = settings.OcclusionRadius.Value; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(BeforeCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(AfterRender)); } } private void BeforeCull(Camera camera) { //IL_029a: Unknown result type (might be due to invalid IL or missing references) if (naturalRenderer.Capturing) { natural.Bark.Show(natural.BarkSources); } else { if (!Object.op_Implicit((Object)(object)main) || !Object.op_Implicit((Object)(object)player)) { return; } try { Restore(); renderStack.Add(camera); if ((Object)(object)camera != (Object)(object)main) { return; } long start = VisibilityTiming.Begin(); room.Update(main, player, config); timing.End(1, start); start = VisibilityTiming.Begin(); roomRenderer.Prepare(room); timing.End(2, start); start = VisibilityTiming.Begin(); natural.Update(main, player, config.OcclusionRadius.Value); if (room.Level.OnStairs) { blockers.Clear(); obstacles.Clear(); obstacleRoots.Clear(); } else if (Time.unscaledTime >= nextSearch) { CollectObstacles(); nextSearch = Time.unscaledTime + 0.1f; } blockers.RemoveWhere((Renderer renderer) => !Object.op_Implicit((Object)(object)renderer) || ProtectedRenderer(renderer)); if (room.InDungeon) { blockers.RemoveWhere((Renderer renderer) => room.Hidden.Contains(renderer) || roomRenderer.CutSources.Contains(renderer)); } revealSources.Clear(); revealSources.UnionWith(natural.Hidden); revealSources.UnionWith(blockers); timing.End(3, start); start = VisibilityTiming.Begin(); Apply(); timing.End(4, start); start = VisibilityTiming.Begin(); PresentationTokens current = PresentationTokens.Current; revealRadius = config.OcclusionRadius.Value * current.blockedRevealScale; bool flag = blockers.Count > 0 && natural.Hidden.Count == 0; if (flag) { revealRadius = config.OcclusionRadius.Value; } try { naturalRenderer.Prepare(main, ((Character)player).GetCenterPoint(), revealRadius, flag ? Mathf.Max(0.85f, config.HaloFeather.Value) : config.HaloFeather.Value, current.occluderVisibility, flag ? 0.55f : current.haloFadeDuration, Time.unscaledDeltaTime, revealSources, natural.CameraObstructed, natural.Trunks, natural.TrunkCount, blockers.Count == 0 && natural.OnlyTreeRenderers, natural.TreeRenderers); } finally { natural.Bark.Hide(); } timing.End(5, start); string text = timing.Report(room.SnapshotCount, room.LocalChangeCount, room.Hidden.Count, roomRenderer.CutSources.Count); if (text != null) { Plugin.Instance?.LogVisibility(text); } } catch (Exception ex) { Suspend(); Plugin.Instance?.Warn("Camera obstruction hiding stopped: " + ex); } } } private void AfterRender(Camera camera) { if (naturalRenderer.Capturing) { natural.Bark.Hide(); } else { if (!Object.op_Implicit((Object)(object)main)) { return; } try { Restore(); int num = renderStack.LastIndexOf(camera); if (num >= 0) { renderStack.RemoveRange(num, renderStack.Count - num); } if (renderStack.Count > 0 && (Object)(object)renderStack[renderStack.Count - 1] == (Object)(object)main) { Apply(); } } catch (Exception ex) { Suspend(); Plugin.Instance?.Warn("Camera render restoration stopped: " + ex); } } } private void Apply() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Invalid comparison between Unknown and I4 fog.Apply(main, player, room, config.RoomSearchRadius.Value + 4f); originalOcclusion = main.useOcclusionCulling; ownsOcclusion = true; if (revealSources.Count > 0 || room.Hidden.Count > 0 || roomRenderer.CutSources.Count > 0) { main.useOcclusionCulling = false; } originalShadow = QualitySettings.shadowDistance; ownsShadow = true; if (originalShadow > 0f && (int)QualitySettings.shadows > 0) { QualitySettings.shadowDistance = originalShadow + shadowOffset; } candidateSet.Clear(); foreach (Renderer item in room.Hidden) { if (Object.op_Implicit((Object)(object)item) && !ProtectedRenderer(item)) { candidateSet.Add(item); } } foreach (Renderer cutSource in roomRenderer.CutSources) { if (Object.op_Implicit((Object)(object)cutSource) && !ProtectedRenderer(cutSource)) { candidateSet.Add(cutSource); } } candidateSet.UnionWith(bushRenderers); candidates.Clear(); candidates.AddRange(candidateSet); candidates.Sort((Renderer a, Renderer b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID())); roomRenderer.SetVisible(visible: true, main, room); lease.Begin(candidates); } private void Restore() { long start = VisibilityTiming.Begin(); try { roomRenderer.SetVisible(visible: false, null, room); lease.End(); } finally { fog.Restore(); if (ownsShadow) { QualitySettings.shadowDistance = originalShadow; } ownsShadow = false; if (ownsOcclusion && Object.op_Implicit((Object)(object)main)) { main.useOcclusionCulling = originalOcclusion; } ownsOcclusion = false; timing.End(0, start); } } private void CollectObstacles() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00bd: 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_00bf: 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_00cc: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_0199: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_0209: Unknown result type (might be due to invalid IL or missing references) blockers.Clear(); obstacles.Clear(); obstacleRoots.Clear(); if (colorStates.Count > 128) { colorStates.Clear(); } Vector3 centerPoint = ((Character)player).GetCenterPoint(); Vector3 val = ((Component)main).transform.position - centerPoint; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = ((Component)main).transform.right * ((Character)player).GetRadius() * 0.6f; Trace(centerPoint, normalized); Trace(((Character)player).GetTopPoint(), normalized); Trace(centerPoint + val2, normalized); Trace(centerPoint - val2, normalized); Trace(((Component)player).transform.position + Vector3.up * 0.15f, normalized); nearbyCharacters.Clear(); nearbyCharacters.AddRange(Character.GetAllCharacters()); nearbyCharacters.Sort(delegate(Character a, Character b) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_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_007e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)a)) { return Object.op_Implicit((Object)(object)b) ? 1 : 0; } if (!Object.op_Implicit((Object)(object)b)) { return -1; } Vector3 val4 = ((Component)a).transform.position - ((Component)player).transform.position; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; val4 = ((Component)b).transform.position - ((Component)player).transform.position; int num5 = sqrMagnitude.CompareTo(((Vector3)(ref val4)).sqrMagnitude); return (num5 != 0) ? num5 : ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID()); }); int num = 0; foreach (Character nearbyCharacter in nearbyCharacters) { if (!Object.op_Implicit((Object)(object)nearbyCharacter) || (Object)(object)nearbyCharacter == (Object)(object)player || nearbyCharacter.IsDead()) { continue; } Vector3 val3 = main.WorldToViewportPoint(nearbyCharacter.GetCenterPoint()); if (OcclusionRules.Eligible(val3.x, val3.y, val3.z, Vector3.Distance(((Component)nearbyCharacter).transform.position, ((Component)player).transform.position))) { Vector3 centerPoint2 = nearbyCharacter.GetCenterPoint(); val = ((Component)main).transform.position - nearbyCharacter.GetCenterPoint(); Trace(centerPoint2, ((Vector3)(ref val)).normalized); if (++num >= 6) { break; } } } int num2 = Physics.OverlapSphereNonAlloc(((Component)main).transform.position, 1.2f, overlaps, WorldMask, (QueryTriggerInteraction)1); if (num2 == overlaps.Length) { Collider[] array = Physics.OverlapSphere(((Component)main).transform.position, 1.2f, WorldMask, (QueryTriggerInteraction)1); foreach (Collider collider in array) { AddObstacle(collider); } } else { for (int num4 = 0; num4 < num2; num4++) { AddObstacle(overlaps[num4]); } } } private void Trace(Vector3 origin, Vector3 direction) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_001f: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)main).transform.position - origin; direction = ((Vector3)(ref val)).normalized; float num = Mathf.Max(0f, ((Vector3)(ref val)).magnitude - 0.08f); origin += direction * 0.08f; int num2 = Physics.RaycastNonAlloc(origin, direction, hits, num, WorldMask, (QueryTriggerInteraction)1); if (num2 == hits.Length) { RaycastHit[] array = Physics.RaycastAll(origin, direction, num, WorldMask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; AddObstacle(((RaycastHit)(ref val2)).collider); } } else { for (int j = 0; j < num2; j++) { AddObstacle(((RaycastHit)(ref hits[j])).collider); } } } private void AddObstacle(Collider collider) { if (NaturalOcclusionController.IsNatural(collider) || !Object.op_Implicit((Object)(object)collider) || collider.isTrigger || collider is TerrainCollider || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || room.IsFloor(((Component)collider).GetComponentInParent()) || room.Protects(collider)) { return; } GameObject val = (Object.op_Implicit((Object)(object)player) ? NativeCursorRays.Ghost.Invoke(player) : null); if (Object.op_Implicit((Object)(object)val) && ((Component)collider).transform.IsChildOf(val.transform)) { return; } obstacles.Add(collider); Transform val2 = Root(collider); if (!obstacleRoots.Add(val2)) { return; } candidates.Clear(); ((Component)val2).GetComponentsInChildren(false, candidates); if (candidates.Count == 0) { Renderer componentInParent = ((Component)collider).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { candidates.Add(componentInParent); } } foreach (Renderer candidate in candidates) { if (Object.op_Implicit((Object)(object)candidate) && !Object.op_Implicit((Object)(object)((Component)candidate).GetComponent()) && candidate.enabled && !candidate.forceRenderingOff && (candidate is MeshRenderer || candidate is SkinnedMeshRenderer) && !Object.op_Implicit((Object)(object)((Component)candidate).GetComponentInParent())) { blockers.Add(candidate); } } } private bool ProtectedRenderer(Renderer renderer) { Piece piece = room.PieceOf(renderer); return room.ProtectsPiece(piece); } internal void Suspend() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(BeforeCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(AfterRender)); Restore(); fog.ClearRainCoverage(); naturalRenderer.Dispose(); natural.Dispose(); roomRenderer.Dispose(); room.Dispose(); MeshChannels.ClearCache(); renderStack.Clear(); blockers.Clear(); obstacles.Clear(); revealSources.Clear(); nearbyCharacters.Clear(); nextSearch = 0f; obstacleRoots.Clear(); colorStates.Clear(); bushRenderers.Clear(); bush = null; timing.Reset(); main = null; player = null; } } internal static class MouseAimController { private static readonly int AimMask = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "terrain", "character", "character_net", "character_ghost", "hitbox", "vehicle", "viewblock" }); private static readonly RaycastHit[] HitBuffer = (RaycastHit[])(object)new RaycastHit[128]; private static int cachedFrame = -1; private static Camera cachedCamera; private static Player cachedPlayer; private static Vector3 cachedPointer; private static Vector3 cachedCameraPosition; private static Vector3 cachedPoint; private static Quaternion cachedCameraRotation; private static float cachedFov; private static float cachedAspect; private static bool cachedValid; internal static bool IsRanged(ItemData item) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 return item?.m_shared != null && ((int)item.m_shared.m_skillType == 8 || (int)item.m_shared.m_skillType == 14); } private static bool TryPoint(Camera camera, Player player, out Vector3 aimPoint) { //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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_029c: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: 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_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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) Vector3 pointerPosition = ZInput.pointerPosition; if (cachedFrame == Time.frameCount && (Object)(object)cachedCamera == (Object)(object)camera && (Object)(object)cachedPlayer == (Object)(object)player && cachedPointer == pointerPosition && cachedCameraPosition == ((Component)camera).transform.position && cachedCameraRotation == ((Component)camera).transform.rotation && cachedFov == camera.fieldOfView && cachedAspect == camera.aspect) { aimPoint = cachedPoint; return cachedValid; } cachedFrame = Time.frameCount; cachedCamera = camera; cachedPlayer = player; cachedPointer = pointerPosition; cachedCameraPosition = ((Component)camera).transform.position; cachedCameraRotation = ((Component)camera).transform.rotation; cachedFov = camera.fieldOfView; cachedAspect = camera.aspect; Ray val = ScreenCoordinates.PointerRay(camera); int num = Physics.RaycastNonAlloc(val, HitBuffer, 1000f, AimMask, (QueryTriggerInteraction)2); RaycastHit[] array = HitBuffer; if (num == HitBuffer.Length) { array = Physics.RaycastAll(val, 1000f, AimMask, (QueryTriggerInteraction)2); num = array.Length; } float num2 = float.PositiveInfinity; int num3 = int.MaxValue; aimPoint = default(Vector3); for (int i = 0; i < num; i++) { RaycastHit hit = array[i]; if (Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider) && !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(((Component)player).transform) && !((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent() == (Object)(object)player) && !CursorOcclusion.Ignore(hit, camera, player) && (!((RaycastHit)(ref hit)).collider.isTrigger || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent()))) { int instanceID = ((Object)((RaycastHit)(ref hit)).collider).GetInstanceID(); if (!(((RaycastHit)(ref hit)).distance > num2) && (((RaycastHit)(ref hit)).distance != num2 || instanceID < num3)) { num2 = ((RaycastHit)(ref hit)).distance; num3 = instanceID; aimPoint = ((RaycastHit)(ref hit)).point; } } } if (num2 < float.PositiveInfinity) { cachedPoint = aimPoint; cachedValid = true; return true; } if (ControlMath.PlanePoint(CameraRelativeMovement.ToNumerics(((Ray)(ref val)).origin), CameraRelativeMovement.ToNumerics(((Ray)(ref val)).direction), ((Component)player).transform.position.y, out var point)) { aimPoint = CameraRelativeMovement.ToUnity(point); cachedPoint = aimPoint; cachedValid = true; return true; } aimPoint = ((Character)player).GetCenterPoint() + ((Component)camera).transform.forward * 100f; cachedPoint = aimPoint; cachedValid = false; return false; } internal static Vector3 Point(Camera camera, Player player) { //IL_000b: 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_000f: Unknown result type (might be due to invalid IL or missing references) TryPoint(camera, player, out var aimPoint); return aimPoint; } internal static Vector3 Direction(Camera camera, Player player, Vector3 spawn) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0044: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!TryPoint(camera, player, out var aimPoint)) { return ((Component)camera).transform.forward; } Vector3 val = aimPoint - spawn; return (((Vector3)(ref val)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val)).normalized : ((Component)camera).transform.forward; } } internal static class NativeCursorRays { private static readonly RaycastHit[] PlacementHits = (RaycastHit[])(object)new RaycastHit[128]; internal static readonly FieldRef Ghost = AccessTools.FieldRefAccess("m_placementGhost"); internal static Vector3 Origin(Transform native, Player subject) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0093: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.Guard.IsLocal(subject) || !instance.CameraController.Active || !instance.Guard.IsCursorInputAllowed()) { return native.position; } Ray val = ScreenCoordinates.PointerRay(instance.CameraController.Camera); return CameraRelativeMovement.ToUnity(InteractionMath.NearRayOrigin(CameraRelativeMovement.ToNumerics(((Ray)(ref val)).origin), CameraRelativeMovement.ToNumerics(((Ray)(ref val)).direction), CameraRelativeMovement.ToNumerics(((Character)Player.m_localPlayer).m_eye.position))); } internal static Vector3 Forward(Transform native, Player subject) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0053: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; Vector3 result; if (!((Object)(object)instance != (Object)null) || !instance.Guard.IsLocal(subject) || !instance.CameraController.Active || !instance.Guard.IsCursorInputAllowed()) { result = native.forward; } else { Ray val = ScreenCoordinates.PointerRay(instance.CameraController.Camera); result = ((Ray)(ref val)).direction; } return result; } internal static bool PlacementCast(Vector3 origin, Vector3 direction, out RaycastHit closest, float distance, int mask, Player subject) { //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) return Cast(origin, direction, out closest, distance, mask, subject, hammer: false); } internal static bool HammerCast(Vector3 origin, Vector3 direction, out RaycastHit closest, float distance, int mask, Player subject) { //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) return Cast(origin, direction, out closest, distance, mask, subject, hammer: true); } private static bool Cast(Vector3 origin, Vector3 direction, out RaycastHit closest, float distance, int mask, Player subject, bool hammer) { //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_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.Guard.IsLocal(subject) || !instance.CameraController.Active || !instance.Guard.IsCursorInputAllowed()) { return Physics.Raycast(origin, direction, ref closest, distance, mask); } int num = Physics.RaycastNonAlloc(origin, direction, PlacementHits, distance, mask, (QueryTriggerInteraction)0); RaycastHit[] array = PlacementHits; if (num == array.Length) { array = Physics.RaycastAll(origin, direction, distance, mask, (QueryTriggerInteraction)0); num = array.Length; } closest = default(RaycastHit); float num2 = float.PositiveInfinity; int num3 = int.MaxValue; GameObject val = Ghost.Invoke(subject); Ray ray = default(Ray); ((Ray)(ref ray))..ctor(origin, direction); for (int i = 0; i < num; i++) { RaycastHit hit = array[i]; if (Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider) && !((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent() == (Object)(object)subject) && (!Object.op_Implicit((Object)(object)val) || !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(val.transform)) && !(hammer ? (!instance.CameraController.HammerSurface(ray, ref hit)) : instance.CameraController.IsHiddenObstacle(((RaycastHit)(ref hit)).collider))) { int instanceID = ((Object)((RaycastHit)(ref hit)).collider).GetInstanceID(); if (!(((RaycastHit)(ref hit)).distance > num2) && (((RaycastHit)(ref hit)).distance != num2 || instanceID < num3)) { num2 = ((RaycastHit)(ref hit)).distance; num3 = instanceID; closest = hit; } } } return num2 < float.PositiveInfinity; } } internal static class NativeInputGate { private static readonly Func TakeInput = AccessTools.MethodDelegate>(AccessTools.Method(typeof(PlayerController), "TakeInput", new Type[1] { typeof(bool) }, (Type[])null), (object)null, true); private static Player currentPlayer; private static PlayerController controller; internal static bool IsAllowed() { Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return false; } if ((Object)(object)localPlayer != (Object)(object)currentPlayer || !Object.op_Implicit((Object)(object)controller)) { currentPlayer = localPlayer; controller = ((Component)localPlayer).GetComponent(); } return Object.op_Implicit((Object)(object)controller) && TakeInput(controller, arg2: false); } } internal sealed class NativeRendererColors { private static readonly int ColorId = Shader.PropertyToID("_Color"); private static readonly HashSet Reported = new HashSet(); private readonly Renderer source; private readonly Material[] materials; private readonly MaterialPropertyBlock[] saved; private readonly MaterialPropertyBlock[] working; private readonly Color[] colors; internal readonly bool CanFade; internal NativeRendererColors(Renderer renderer) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown source = renderer; materials = source.sharedMaterials; saved = (MaterialPropertyBlock[])(object)new MaterialPropertyBlock[materials.Length]; working = (MaterialPropertyBlock[])(object)new MaterialPropertyBlock[materials.Length]; colors = (Color[])(object)new Color[materials.Length]; CanFade = materials.Length != 0; for (int i = 0; i < materials.Length; i++) { saved[i] = new MaterialPropertyBlock(); working[i] = new MaterialPropertyBlock(); Material val = materials[i]; bool flag = Object.op_Implicit((Object)(object)val) && val.renderQueue >= 3000 && val.HasProperty(ColorId) && val.HasProperty("_SrcBlend") && val.HasProperty("_DstBlend") && val.HasProperty("_ZWrite") && val.GetInt("_ZWrite") == 0 && val.GetInt("_SrcBlend") == 5 && val.GetInt("_DstBlend") == 10; CanFade &= flag; if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.shader) || !Reported.Add(val.shader)) { continue; } List list = new List(); for (int j = 0; j < val.shader.GetPropertyCount(); j++) { string propertyName = val.shader.GetPropertyName(j); if (propertyName.IndexOf("Fade", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName.IndexOf("Alpha", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName.IndexOf("Dither", StringComparison.OrdinalIgnoreCase) >= 0 || propertyName == "_Opacity" || propertyName == "_Color") { list.Add(propertyName); } } Plugin.Instance?.LogMaterial("Native visibility shader: " + ((Object)val.shader).name + ", queue=" + val.renderQueue + ", native-alpha=" + flag + ", relevant properties=" + string.Join(",", list)); } } internal void Capture() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) for (int i = 0; i < materials.Length; i++) { source.GetPropertyBlock(saved[i], i); source.GetPropertyBlock(working[i], i); if (working[i].isEmpty) { source.GetPropertyBlock(working[i]); } colors[i] = (working[i].HasColor(ColorId) ? working[i].GetColor(ColorId) : ((Object.op_Implicit((Object)(object)materials[i]) && materials[i].HasProperty(ColorId)) ? materials[i].GetColor(ColorId) : Color.white)); } } internal void Apply(bool fade) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) for (int i = 0; i < materials.Length; i++) { if (Object.op_Implicit((Object)(object)materials[i]) && materials[i].HasProperty(ColorId)) { Color val = colors[i]; if (fade) { val.a *= PresentationTokens.Current.occluderVisibility; } else { float bushTintStrength = PresentationTokens.Current.bushTintStrength; val.r *= bushTintStrength; val.g *= bushTintStrength; val.b *= bushTintStrength; } working[i].SetColor(ColorId, val); source.SetPropertyBlock(working[i], i); } } } internal void Restore() { if (Object.op_Implicit((Object)(object)source)) { for (int i = 0; i < materials.Length; i++) { source.SetPropertyBlock(saved[i].isEmpty ? null : saved[i], i); } } } } internal sealed class NaturalOcclusionController { internal readonly HashSet Hidden = new HashSet(); internal readonly HashSet TreeRenderers = new HashSet(); private readonly HashSet roots = new HashSet(); private readonly Dictionary seen = new Dictionary(); private readonly Dictionary renderers = new Dictionary(); private readonly List expired = new List(); private readonly List trees = new List(); internal readonly Vector4[] Trunks = (Vector4[])(object)new Vector4[16]; private readonly List nearTrunks = new List(); internal readonly TrunkGeometry Bark = new TrunkGeometry(); internal readonly HashSet BarkSources = new HashSet(); private readonly HashSet onBodyRay = new HashSet(); private readonly HashSet rearTrunks = new HashSet(); private readonly Dictionary rayTrunks = new Dictionary(); private float nextCheck; private float nextTrees; private static readonly int Mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "vehicle", "viewblock" }); internal bool CameraObstructed { get; private set; } internal bool OnlyTreeRenderers { get; private set; } internal int TrunkCount { get; private set; } internal static bool IsNatural(Collider collider) { if (!Object.op_Implicit((Object)(object)collider) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent())) { return false; } Transform val = Root(collider); return Object.op_Implicit((Object)(object)val) && (Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || VisualRules.Natural(((Object)val).name, Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent()))); } private static Transform Root(Collider collider) { if (!Object.op_Implicit((Object)(object)collider)) { return null; } Component componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); if (!Object.op_Implicit((Object)(object)componentInParent)) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)componentInParent)) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)componentInParent)) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)componentInParent)) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } if (!Object.op_Implicit((Object)(object)componentInParent)) { componentInParent = (Component)(object)((Component)collider).GetComponentInParent(); } return Object.op_Implicit((Object)(object)componentInParent) ? componentInParent.transform : ((Component)collider).transform; } internal bool Contains(Collider collider) { return Object.op_Implicit((Object)(object)collider) && roots.Contains(Root(collider)); } internal void Update(Camera camera, Player player, float haloMetres) { //IL_0030: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0304: 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_0171: 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) //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_018b: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: 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_0385: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: 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_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06ed: Unknown result type (might be due to invalid IL or missing references) //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0878: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < nextCheck) { return; } nextCheck = Time.unscaledTime + 0.1f; Vector3 center = ((Character)player).GetCenterPoint(); CameraObstructed = false; onBodyRay.Clear(); rearTrunks.Clear(); BarkSources.Clear(); Vector3[] array = (Vector3[])(object)new Vector3[3] { center, ((Character)player).GetTopPoint(), ((Component)player).transform.position + Vector3.up * 0.15f }; foreach (Vector3 val in array) { Vector3 val2 = ((Component)camera).transform.position - val; rayTrunks.Clear(); float num = float.NegativeInfinity; RaycastHit[] array2 = Physics.RaycastAll(val + ((Vector3)(ref val2)).normalized * 0.08f, ((Vector3)(ref val2)).normalized, Mathf.Max(0f, ((Vector3)(ref val2)).magnitude - 0.08f), Mask, (QueryTriggerInteraction)1); for (int j = 0; j < array2.Length; j++) { RaycastHit val3 = array2[j]; if (!IsNatural(((RaycastHit)(ref val3)).collider)) { continue; } Transform val4 = Root(((RaycastHit)(ref val3)).collider); Mark(val4); Vector3 val5 = ((RaycastHit)(ref val3)).point - val4.position; if (val5.x * val5.x + val5.z * val5.z >= 1f) { continue; } onBodyRay.Add(val4); if (Object.op_Implicit((Object)(object)((Component)val4).GetComponent())) { if (!rayTrunks.TryGetValue(val4, out var value) || ((RaycastHit)(ref val3)).distance > value) { rayTrunks[val4] = ((RaycastHit)(ref val3)).distance; } num = Mathf.Max(num, ((RaycastHit)(ref val3)).distance); } } foreach (KeyValuePair rayTrunk in rayTrunks) { if (rayTrunk.Value + 0.15f < num) { rearTrunks.Add(rayTrunk.Key); } } } if (Time.unscaledTime >= nextTrees) { trees.Clear(); trees.AddRange(Object.FindObjectsByType((FindObjectsSortMode)1)); nextTrees = Time.unscaledTime + 1f; } RaycastHit[] array3 = Physics.RaycastAll(((Component)camera).transform.position, Vector3.down, Mathf.Max(30f, ((Component)camera).transform.position.y - center.y + 30f), Mask, (QueryTriggerInteraction)1); for (int k = 0; k < array3.Length; k++) { RaycastHit val6 = array3[k]; if (IsNatural(((RaycastHit)(ref val6)).collider)) { Transform root = Root(((RaycastHit)(ref val6)).collider); Renderer[] array4 = Renderers(root); if (array4.Length != 0 && Covers(camera, center, BoundsOf(root, array4), haloMetres, out var canopy)) { Mark(root); CameraObstructed |= canopy; } } } foreach (TreeBase tree in trees) { if (!Object.op_Implicit((Object)(object)tree) || !((Component)tree).gameObject.activeInHierarchy || Object.op_Implicit((Object)(object)((Component)tree).GetComponentInParent())) { continue; } Vector3 position = ((Component)tree).transform.position; Vector3 position2 = ((Component)camera).transform.position; if (ViewOcclusion.NearSegment(new Vector3(position.x, 0f, position.z), new Vector3(center.x, 0f, center.z), new Vector3(position2.x, 0f, position2.z), 32f)) { Renderer[] array5 = Renderers(((Component)tree).transform); if (array5.Length != 0 && Covers(camera, center, BoundsOf(((Component)tree).transform, array5), haloMetres, out var canopy2)) { Mark(((Component)tree).transform); CameraObstructed |= canopy2; } } } expired.Clear(); foreach (KeyValuePair item in seen) { if (!Object.op_Implicit((Object)(object)item.Key) || Time.unscaledTime - item.Value > 0.35f) { expired.Add(item.Key); } } foreach (Transform item2 in expired) { seen.Remove(item2); renderers.Remove(item2); } Hidden.Clear(); TreeRenderers.Clear(); roots.Clear(); nearTrunks.Clear(); OnlyTreeRenderers = true; foreach (KeyValuePair item3 in seen) { if (!Object.op_Implicit((Object)(object)item3.Key)) { continue; } roots.Add(item3.Key); Vector3 position3 = item3.Key.position; bool flag = Object.op_Implicit((Object)(object)((Component)item3.Key).GetComponent()); Vector3 val7 = position3 - ((Component)player).transform.position; bool flag2 = ((Vector3)(ref val7)).sqrMagnitude < 100f; if (flag) { Renderer[] array6 = Renderers(item3.Key); if (array6.Length != 0) { Bounds val8 = BoundsOf(item3.Key, array6); Vector3 extents = ((Bounds)(ref val8)).extents; float num2 = Mathf.Clamp(Mathf.Min(extents.x, extents.z) * 0.25f, 0.55f, 2.4f); nearTrunks.Add(new Vector4(position3.x, position3.y, position3.z, num2)); if (rearTrunks.Contains(item3.Key) || (flag2 && !onBodyRay.Contains(item3.Key))) { Renderer[] array7 = array6; foreach (Renderer val9 in array7) { if (Object.op_Implicit((Object)(object)val9) && val9.enabled && ((Component)val9).gameObject.activeInHierarchy) { LODGroup componentInParent = ((Component)val9).GetComponentInParent(); if (!Object.op_Implicit((Object)(object)componentInParent) || componentInParent.lodCount <= 0 || Array.IndexOf(componentInParent.GetLODs()[0].renderers, val9) >= 0) { BarkSources.Add(val9); Bark.Prepare(val9, item3.Key); } } } } } } Renderer[] array8 = Renderers(item3.Key); foreach (Renderer val10 in array8) { if (Object.op_Implicit((Object)(object)val10) && val10.enabled && !val10.forceRenderingOff && Covers(camera, center, val10.bounds, haloMetres, out var _)) { Hidden.Add(val10); if (flag) { TreeRenderers.Add(val10); } OnlyTreeRenderers &= flag; } } } if (nearTrunks.Count > Trunks.Length) { nearTrunks.Sort(delegate(Vector4 a, Vector4 b) { //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_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_0011: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) Vector3 val11 = Vector4.op_Implicit(a) - center; float sqrMagnitude = ((Vector3)(ref val11)).sqrMagnitude; val11 = Vector4.op_Implicit(b) - center; return sqrMagnitude.CompareTo(((Vector3)(ref val11)).sqrMagnitude); }); } TrunkCount = Mathf.Min(Trunks.Length, nearTrunks.Count); Bark.Retain(BarkSources); nearTrunks.CopyTo(0, Trunks, 0, TrunkCount); } private void Mark(Transform root) { if (Object.op_Implicit((Object)(object)root)) { seen[root] = Time.unscaledTime; } } private Renderer[] Renderers(Transform root) { if (renderers.TryGetValue(root, out var value)) { return value; } List list = new List(); ((Component)root).GetComponentsInChildren(false, list); list.RemoveAll((Renderer r) => !Object.op_Implicit((Object)(object)r) || Object.op_Implicit((Object)(object)((Component)r).GetComponent()) || (!(r is MeshRenderer) && !(r is SkinnedMeshRenderer) && !(r is BillboardRenderer))); value = list.ToArray(); renderers[root] = value; return value; } private static Bounds BoundsOf(Transform root, Renderer[] values) { //IL_0020: 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_0011: 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_0025: 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_0040: 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) Bounds result = (Bounds)(Object.op_Implicit((Object)(object)values[0]) ? values[0].bounds : new Bounds(root.position, Vector3.zero)); foreach (Renderer val in values) { if (Object.op_Implicit((Object)(object)val)) { ((Bounds)(ref result)).Encapsulate(val.bounds); } } return result; } private static bool Covers(Camera camera, Vector3 player, Bounds bounds, float haloMetres, out bool canopy) { //IL_0009: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_018b: 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_0199: 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_01ac: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008b: 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_00aa: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Bounds)(ref bounds)).Contains(((Component)camera).transform.position); canopy = false; Vector2 val = Vector2.one * float.PositiveInfinity; Vector2 val2 = Vector2.one * float.NegativeInfinity; float num = float.PositiveInfinity; for (int i = 0; i < 8; i++) { Vector3 val3 = camera.WorldToViewportPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))))); if (val3.z <= camera.nearClipPlane) { flag = true; continue; } val = Vector2.Min(val, Vector2.op_Implicit(val3)); val2 = Vector2.Max(val2, Vector2.op_Implicit(val3)); num = Mathf.Min(num, val3.z); } Vector3 val4 = camera.WorldToViewportPoint(player); float num2 = Mathf.Clamp(haloMetres * 0.6f, 0.35f, 2.2f); Vector3 val5 = camera.WorldToViewportPoint(player + ((Component)camera).transform.up * num2); float num3 = Mathf.Clamp(Mathf.Abs(val5.y - val4.y), 0.005f, 0.05f); if (flag) { val = Vector2.zero; val2 = Vector2.one; num = camera.nearClipPlane; } canopy = ViewOcclusion.CameraCanopy(new Vector4(val.x, val.y, val2.x, val2.y), num, val4.z, Vector3.Distance(((Bounds)(ref bounds)).center, player), flag); bool flag2 = VisualRules.CoversPlayer(val.x, val.y, val2.x, val2.y, num, val4.z, val4.x, val4.y, num3 / camera.aspect, num3); canopy &= flag2; return flag2; } internal void Dispose() { Bark.Dispose(); BarkSources.Clear(); Hidden.Clear(); TreeRenderers.Clear(); roots.Clear(); seen.Clear(); renderers.Clear(); trees.Clear(); expired.Clear(); nextCheck = (nextTrees = 0f); CameraObstructed = false; } } internal sealed class NaturalRevealRenderer { private static readonly int Copy = Shader.PropertyToID("_IsoRevealColor"); private static readonly int OriginalDepth = Shader.PropertyToID("_IsoRevealOriginalDepth"); private static readonly int MixedDepth = Shader.PropertyToID("_IsoRevealMixedDepth"); private static readonly int Occluded = Shader.PropertyToID("_IsoRevealOccluded"); private readonly HashSet active = new HashSet(); private readonly Vector4[] solidMin = (Vector4[])(object)new Vector4[24]; private readonly Vector4[] solidMax = (Vector4[])(object)new Vector4[24]; private readonly Dictionary saved = new Dictionary(); private Camera owner; private Camera view; private GameObject viewObject; private CommandBuffer before; private CommandBuffer after; private CommandBuffer capture; private RenderTexture background; private RenderTexture backgroundDepth; private RenderTexture gateHistory; private Material material; private AssetBundle bundle; private float progress; private float cameraProgress; private bool failed; private bool treeOnly; private DepthTextureMode originalDepthMode; private readonly Action warning; private readonly byte[] suppliedBundle; internal bool Capturing { get; private set; } internal bool Active => active.Count > 0 && progress > 0f && !failed; internal NaturalRevealRenderer(Action warning = null, byte[] suppliedBundle = null) { this.warning = warning; this.suppliedBundle = suppliedBundle; } internal void Prepare(Camera camera, Vector3 point, float metres, float feather, float visibility, float duration, float delta, HashSet wanted, bool cameraObstructed = false, Vector4[] trunks = null, int trunkCount = 0, bool onlyTrees = false, HashSet trees = null) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: 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_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_0722: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_074a: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_086e: Unknown result type (might be due to invalid IL or missing references) CommandBuffer obj = before; if (obj != null) { obj.Clear(); } CommandBuffer obj2 = after; if (obj2 != null) { obj2.Clear(); } if (failed) { return; } progress = InteractionMath.FadeProgress(progress, wanted.Count > 0, delta, duration); cameraProgress = InteractionMath.FadeProgress(cameraProgress, cameraObstructed && wanted.Count > 0, delta, duration); if (wanted.Count > 0) { active.Clear(); active.UnionWith(wanted); treeOnly = onlyTrees; } active.RemoveWhere((Renderer item) => !Object.op_Implicit((Object)(object)item) || !item.enabled || !((Component)item).gameObject.activeInHierarchy); if (progress <= 0f || active.Count == 0) { active.Clear(); return; } try { if (Ensure(camera)) { Vector3 val = camera.WorldToViewportPoint(point); float num = Mathf.Clamp(Mathf.Abs(camera.WorldToViewportPoint(point + ((Component)camera).transform.up * metres).y - val.y), 0.04f, 0.45f); Vector4 vector = RevealMath.Crop(new Vector2(val.x, val.y), new Vector2(num / camera.aspect, num), camera.pixelWidth, camera.pixelHeight); if (cameraProgress > 0f) { vector = new Vector4(0f, 0f, 1f, 1f); } Resize(Mathf.RoundToInt(vector.Z * (float)camera.pixelWidth), Mathf.RoundToInt(vector.W * (float)camera.pixelHeight), camera.allowHDR); view.CopyFrom(camera); ((Behaviour)view).enabled = false; view.targetTexture = background; view.rect = new Rect(0f, 0f, 1f, 1f); ((Component)view).transform.SetPositionAndRotation(((Component)camera).transform.position, ((Component)camera).transform.rotation); view.useOcclusionCulling = false; view.depthTextureMode = (DepthTextureMode)1; view.allowMSAA = false; Matrix4x4 identity = Matrix4x4.identity; identity.m00 = 1f / vector.Z; identity.m03 = (1f - 2f * vector.X - vector.Z) / vector.Z; identity.m11 = 1f / vector.W; identity.m13 = (1f - 2f * vector.Y - vector.W) / vector.W; view.projectionMatrix = identity * camera.projectionMatrix; Skybox component = ((Component)camera).GetComponent(); viewObject.GetComponent().material = (Object.op_Implicit((Object)(object)component) ? component.material : null); ((Behaviour)viewObject.GetComponent()).enabled = Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled; material.SetTexture("_RevealBackground", (Texture)(object)background); material.SetTexture("_RevealDepth", (Texture)(object)backgroundDepth); material.SetVector("_RevealCrop", new Vector4(vector.X, vector.Y, vector.Z, vector.W)); material.SetVector("_RevealHalo", new Vector4(val.x, val.y, num / camera.aspect, num)); material.SetFloat("_RevealFeather", feather); material.SetFloat("_RevealStrength", 1f - InteractionMath.Opacity(progress, 0f)); material.SetFloat("_RevealVisibility", visibility); ConfigureFoliage(trunkCount, trees); material.SetFloat("_RevealPlayerDepth", val.z); float num2 = Mathf.Abs(camera.WorldToViewportPoint(point + ((Component)camera).transform.up * 0.6f).y - val.y); material.SetVector("_RevealProbe", new Vector4(val.x, val.y, num2 / camera.aspect, num2)); material.SetFloat("_RevealGateStep", Mathf.Clamp01(delta / Mathf.Max(0.001f, duration))); material.SetFloat("_RevealCameraStrength", 1f - InteractionMath.Opacity(cameraProgress, 0f)); material.SetInt("_TrunkCount", trunkCount); if (trunkCount > 0) { material.SetVectorArray("_Trunks", trunks); float num3 = Mathf.Tan(camera.fieldOfView * (MathF.PI / 180f) * 0.5f); material.SetVector("_Eye", Vector4.op_Implicit(((Component)camera).transform.position)); material.SetVector("_Look", Vector4.op_Implicit(((Component)camera).transform.forward)); material.SetVector("_RightSlope", Vector4.op_Implicit(((Component)camera).transform.right * (num3 * camera.aspect))); material.SetVector("_UpSlope", Vector4.op_Implicit(((Component)camera).transform.up * num3)); material.SetVector("_PlayerWorld", Vector4.op_Implicit(point)); } capture.Clear(); capture.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)0), RenderTargetIdentifier.op_Implicit((Texture)(object)backgroundDepth), material, 1); RenderBackground(); before.GetTemporaryRT(Copy, -1, -1, 0, (FilterMode)1, (RenderTextureFormat)(camera.allowHDR ? 9 : 7)); before.GetTemporaryRT(OriginalDepth, -1, -1, 0, (FilterMode)0, (RenderTextureFormat)14, (RenderTextureReadWrite)1); before.GetTemporaryRT(MixedDepth, -1, -1, 0, (FilterMode)0, (RenderTextureFormat)14, (RenderTextureReadWrite)1); before.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)0), RenderTargetIdentifier.op_Implicit(OriginalDepth), material, 1); before.SetGlobalTexture("_RevealOriginalDepth", RenderTargetIdentifier.op_Implicit(OriginalDepth)); before.GetTemporaryRT(Occluded, 1, 1, 0, (FilterMode)0, (RenderTextureFormat)14, (RenderTextureReadWrite)1); before.Blit((Texture)(object)gateHistory, RenderTargetIdentifier.op_Implicit(Occluded), material, 3); before.Blit(RenderTargetIdentifier.op_Implicit(Occluded), RenderTargetIdentifier.op_Implicit((Texture)(object)gateHistory)); before.SetGlobalTexture("_RevealOccluded", RenderTargetIdentifier.op_Implicit(Occluded)); before.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit(Copy)); before.Blit(RenderTargetIdentifier.op_Implicit(Copy), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), material, 0); before.Blit(RenderTargetIdentifier.op_Implicit(OriginalDepth), RenderTargetIdentifier.op_Implicit(MixedDepth), material, 2); before.SetGlobalTexture("_CameraDepthTexture", RenderTargetIdentifier.op_Implicit(MixedDepth)); after.SetGlobalTexture("_CameraDepthTexture", RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)3)); after.SetGlobalTexture("_RevealOccluded", RenderTargetIdentifier.op_Implicit((Texture)(object)Texture2D.blackTexture)); after.ReleaseTemporaryRT(Occluded); after.ReleaseTemporaryRT(Copy); after.ReleaseTemporaryRT(OriginalDepth); after.ReleaseTemporaryRT(MixedDepth); after.SetRenderTarget(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2)); } } catch (Exception ex) { Dispose(); failed = true; warning?.Invoke("Natural reveal stopped; scenery remains visible: " + ex); } } private void ConfigureFoliage(int trunkCount, HashSet trees) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) int num = 0; bool flag = trunkCount > 0; if (flag && !treeOnly) { bool flag2 = false; foreach (Renderer item in active) { if (trees != null && trees.Contains(item)) { flag2 = true; continue; } if (num == solidMin.Length) { flag = false; break; } Bounds bounds = item.bounds; ((Bounds)(ref bounds)).Expand(0.12f); solidMin[num] = Vector4.op_Implicit(((Bounds)(ref bounds)).min); solidMax[num++] = Vector4.op_Implicit(((Bounds)(ref bounds)).max); } flag = flag && flag2; } material.SetFloat("_RevealFoliage", (float)(flag ? 1 : 0)); material.SetInt("_RevealSolidCount", flag ? num : 0); if (flag && num > 0) { material.SetVectorArray("_RevealSolidMin", solidMin); material.SetVectorArray("_RevealSolidMax", solidMax); } } private bool Ensure(Camera camera) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_01b0: 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_0294: 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_02a7: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown if ((Object)(object)owner == (Object)(object)camera && Object.op_Implicit((Object)(object)material)) { return true; } List other = new List(active); float num = progress; float num2 = cameraProgress; Dispose(); active.UnionWith(other); progress = num; cameraProgress = num2; owner = camera; originalDepthMode = owner.depthTextureMode; Camera obj = owner; obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode | 1); if (suppliedBundle != null) { bundle = AssetBundle.LoadFromMemory(suppliedBundle); } else { using Stream stream = typeof(NaturalRevealRenderer).Assembly.GetManifestResourceStream("IsometricView.natural-reveal"); if (stream == null) { throw new InvalidOperationException("The verified reveal shader bundle is missing."); } byte[] array = new byte[stream.Length]; int num3; for (int i = 0; i < array.Length; i += num3) { num3 = stream.Read(array, i, array.Length - i); if (num3 == 0) { throw new InvalidOperationException("Incomplete reveal shader bundle."); } } bundle = AssetBundle.LoadFromMemory(array); } Shader val = (Object.op_Implicit((Object)(object)bundle) ? bundle.LoadAsset("Assets/NaturalReveal.shader") : null); if (!Object.op_Implicit((Object)(object)val) || !val.isSupported || !SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)14)) { throw new NotSupportedException("Natural reveal shader/depth format is unsupported on " + ((object)SystemInfo.graphicsDeviceType/*cast due to .constrained prefix*/).ToString() + "; shader=" + (Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "missing") + "."); } material = new Material(val) { hideFlags = (HideFlags)61 }; gateHistory = new RenderTexture(1, 1, 0, (RenderTextureFormat)14, (RenderTextureReadWrite)1) { name = "Isometric obstruction history", hideFlags = (HideFlags)61, filterMode = (FilterMode)0 }; gateHistory.Create(); RenderTexture val2 = RenderTexture.active; try { Graphics.Blit((Texture)(object)Texture2D.blackTexture, gateHistory); } finally { RenderTexture.active = val2; } viewObject = new GameObject("Isometric reveal crop", new Type[2] { typeof(Camera), typeof(Skybox) }) { hideFlags = (HideFlags)61 }; view = viewObject.GetComponent(); ((Behaviour)view).enabled = false; before = new CommandBuffer { name = "Isometric soft natural reveal" }; after = new CommandBuffer { name = "Isometric reveal cleanup" }; capture = new CommandBuffer { name = "Isometric crop depth" }; owner.AddCommandBuffer((CameraEvent)18, before); owner.AddCommandBuffer((CameraEvent)19, after); view.AddCommandBuffer((CameraEvent)12, capture); return true; } private void RenderBackground() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0086: Invalid comparison between Unknown and I4 RenderTexture val = RenderTexture.active; Texture globalTexture = Shader.GetGlobalTexture("_CameraDepthTexture"); Texture globalTexture2 = Shader.GetGlobalTexture("_CameraDepthNormalsTexture"); Capturing = true; saved.Clear(); try { foreach (Renderer item in active) { if (Object.op_Implicit((Object)(object)item)) { saved.Add(item, (item.forceRenderingOff, item.shadowCastingMode)); if ((int)item.shadowCastingMode == 0) { item.forceRenderingOff = true; } else { item.shadowCastingMode = (ShadowCastingMode)3; } } } view.Render(); } finally { foreach (KeyValuePair item2 in saved) { if (Object.op_Implicit((Object)(object)item2.Key)) { item2.Key.forceRenderingOff = item2.Value.Item1; item2.Key.shadowCastingMode = item2.Value.Item2; } } saved.Clear(); Capturing = false; RenderTexture.active = val; Shader.SetGlobalTexture("_CameraDepthTexture", globalTexture); Shader.SetGlobalTexture("_CameraDepthNormalsTexture", globalTexture2); } } private void Resize(int width, int height, bool hdr) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) RenderTextureFormat val = (RenderTextureFormat)(hdr ? 2 : 0); if (!Object.op_Implicit((Object)(object)background) || ((Texture)background).width != width || ((Texture)background).height != height || background.format != val) { ReleaseTextures(); background = new RenderTexture(width, height, 24, val, (RenderTextureReadWrite)0) { name = "Isometric cropped native color", hideFlags = (HideFlags)61 }; background.Create(); backgroundDepth = new RenderTexture(width, height, 0, (RenderTextureFormat)14, (RenderTextureReadWrite)1) { name = "Isometric cropped native depth", hideFlags = (HideFlags)61, filterMode = (FilterMode)0 }; backgroundDepth.Create(); if (!background.IsCreated() || !backgroundDepth.IsCreated()) { throw new InvalidOperationException("Reveal render targets were not created."); } } } private void ReleaseTextures() { if (Object.op_Implicit((Object)(object)view)) { view.targetTexture = null; } if (Object.op_Implicit((Object)(object)background)) { background.Release(); Object.Destroy((Object)(object)background); } if (Object.op_Implicit((Object)(object)backgroundDepth)) { backgroundDepth.Release(); Object.Destroy((Object)(object)backgroundDepth); } background = (backgroundDepth = null); } internal void Dispose() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) if (Object.op_Implicit((Object)(object)owner) && before != null) { owner.RemoveCommandBuffer((CameraEvent)18, before); } if (Object.op_Implicit((Object)(object)owner) && after != null) { owner.RemoveCommandBuffer((CameraEvent)19, after); } if (Object.op_Implicit((Object)(object)owner) && owner.depthTextureMode == (DepthTextureMode)(originalDepthMode | 1)) { owner.depthTextureMode = originalDepthMode; } if (Object.op_Implicit((Object)(object)view) && capture != null) { view.RemoveCommandBuffer((CameraEvent)12, capture); } CommandBuffer obj = before; if (obj != null) { obj.Release(); } CommandBuffer obj2 = after; if (obj2 != null) { obj2.Release(); } CommandBuffer obj3 = capture; if (obj3 != null) { obj3.Release(); } before = (after = (capture = null)); ReleaseTextures(); if (Object.op_Implicit((Object)(object)viewObject)) { Object.Destroy((Object)(object)viewObject); } if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } if (Object.op_Implicit((Object)(object)bundle)) { bundle.Unload(false); } if (Object.op_Implicit((Object)(object)gateHistory)) { gateHistory.Release(); Object.Destroy((Object)(object)gateHistory); gateHistory = null; } owner = (view = null); viewObject = null; material = null; bundle = null; active.Clear(); saved.Clear(); progress = (cameraProgress = 0f); Capturing = false; } } [BepInPlugin("dellarion.valheim.isometricview", "IsometricView", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "dellarion.valheim.isometricview"; public const string PluginVersion = "0.2.0"; internal static Plugin Instance; internal IsometricConfig Settings; internal InputContextGuard Guard; internal readonly IsometricCameraController CameraController = new IsometricCameraController(); internal readonly CursorFacingController Facing = new CursorFacingController(); internal readonly CursorDrawIndicator ChargeIndicator = new CursorDrawIndicator(); internal readonly CenterCrosshairVisibility CenterCrosshair = new CenterCrosshairVisibility(); internal readonly CenterCrosshairVisibility InventoryBowCrosshair = new CenterCrosshairVisibility(); internal readonly KeyHintVisibility KeyHintsVisibility = new KeyHintVisibility(); internal readonly IsometricHudController CombatHud = new IsometricHudController(); internal readonly CursorInteractionController Interactions = new CursorInteractionController(); internal readonly CenterCrosshairVisibility HoverTextVisibility = new CenterCrosshairVisibility(); private readonly BowReleaseGate bowGate = new BowReleaseGate(); private bool bowManaged; private Player bowPlayer; private Harmony harmony; private bool available; private float nextConflictCheck; private MethodBase[] targets; private readonly HashSet reportedCompatiblePatches = new HashSet(StringComparer.Ordinal); private readonly HashSet reportedOverlaps = new HashSet(StringComparer.Ordinal); private void Awake() { //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Expected O, but got Unknown //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Expected O, but got Unknown Instance = this; Settings = new IsometricConfig(((BaseUnityPlugin)this).Config); Guard = new InputContextGuard(Settings, () => available && ((Behaviour)this).isActiveAndEnabled, NativeInputGate.IsAllowed); try { MethodBase[] array = new MethodInfo[17] { AccessTools.Method(typeof(GameCamera), "UpdateCamera", new Type[1] { typeof(float) }, (Type[])null), AccessTools.Method(typeof(GameCamera), "UpdateMouseCapture", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(Player), "SetMouseLook", new Type[1] { typeof(Vector2) }, (Type[])null), AccessTools.Method(typeof(Player), "SetControls", (Type[])null, (Type[])null), AccessTools.Method(typeof(Attack), "GetProjectileSpawnPoint", new Type[2] { typeof(Vector3).MakeByRefType(), typeof(Vector3).MakeByRefType() }, (Type[])null), AccessTools.Method(typeof(Player), "UpdateAttackBowDraw", new Type[2] { typeof(ItemData), typeof(float) }, (Type[])null), AccessTools.Method(typeof(Player), "AlwaysRotateCamera", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(Hud), "UpdateCrosshair", new Type[2] { typeof(Player), typeof(float) }, (Type[])null), AccessTools.Method(typeof(KeyHints), "UpdateHints", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(Player), "PieceRayTest", (Type[])null, (Type[])null), AccessTools.Method(typeof(Player), "FindHoverObject", (Type[])null, (Type[])null), AccessTools.Method(typeof(Attack), "FireProjectileBurst", (Type[])null, (Type[])null), AccessTools.Method(typeof(EnemyHud), "TestShow", new Type[2] { typeof(Character), typeof(bool) }, (Type[])null), AccessTools.Method(typeof(EnemyHud), "LateUpdate", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(Player), "Interact", new Type[3] { typeof(GameObject), typeof(bool), typeof(bool) }, (Type[])null), AccessTools.Method(typeof(Player), "UpdateWearNTearHover", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(Player), "CopyPiece", Type.EmptyTypes, (Type[])null) }; targets = array; if (targets.Any((MethodBase method) => method == null)) { throw new MissingMethodException("A required Valheim camera/input contract is missing."); } harmony = new Harmony("dellarion.valheim.isometricview"); ReportOverlaps(); for (int num = 0; num < targets.Length; num++) { HarmonyMethod val = new HarmonyMethod(typeof(RuntimePatches), RuntimePatches.Names[num], (Type[])null); if (num == 0 || num == 1 || num == 12) { val.priority = 0; } if ((num >= 9 && num <= 11) || num == 15 || num == 16) { harmony.Patch(targets[num], (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } else if (num == 4 || num == 6 || num == 7 || num == 8 || num == 12) { harmony.Patch(targets[num], (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Patch(targets[num], val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } RoomTopology.Install(harmony); CombatTextRange.Install(harmony); ChestFilterTooltip.Install(harmony); try { GrassCameraLod.Install(harmony); } catch (Exception ex) { Warn("Isometric grass distance unavailable: " + ex.Message); } try { WiresAllyHud.Install(harmony); } catch (Exception ex2) { Warn("Wire's own nameplate compatibility unavailable: " + ex2.Message); } try { PathOfValheiman.Install(harmony); } catch (Exception ex3) { Warn("Path of Valheiman experience HUD compatibility unavailable: " + ex3.Message); } available = true; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(Present)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"IsometricView 0.2.0: local camera/input hooks installed. Camera defaults require in-game validation."); } catch (Exception error) { Fail(error); } } private unsafe void Update() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 if (!available) { return; } try { KeyCode value = Settings.ViewToggleKey.Value; if ((int)value != 0 && ZInput.GetKeyDown(value, true) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && !InputContextGuard.ConfigurationWindowOpen() && !Console.IsVisible() && !TextInput.IsVisible() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus())) { if (((int)value != 306 && ZInput.GetKey((KeyCode)306, true)) || ((int)value != 305 && ZInput.GetKey((KeyCode)305, true))) { if (CameraController.Active && Guard.IsCursorInputAllowed()) { Settings.BuildingCutaway.Value = !Settings.BuildingCutaway.Value; ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Building cutaway " + (Settings.BuildingCutaway.Value ? "enabled" : "disabled") + " with Ctrl+" + ((object)(*(KeyCode*)(&value))/*cast due to .constrained prefix*/).ToString() + ".")); } } else { Settings.Enabled.Value = !Settings.Enabled.Value; ((BaseUnityPlugin)this).Config.Save(); SuspendControl(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("IsometricView " + (Settings.Enabled.Value ? "enabled" : "disabled") + " with " + ((object)(*(KeyCode*)(&value))/*cast due to .constrained prefix*/).ToString() + ".")); } } if (CameraController.Active && Guard.IsCursorInputAllowed() && !CameraController.IsOrbitHeld(Guard, Settings) && (ZInput.GetKey((KeyCode)308, true) || ZInput.GetKey((KeyCode)307, true))) { bool keyDown = ZInput.GetKeyDown((KeyCode)276, true); bool keyDown2 = ZInput.GetKeyDown((KeyCode)275, true); if (keyDown != keyDown2) { CameraController.Turn(CameraMath.ArrowTurn(keyDown, keyDown2)); } } if (Time.unscaledTime >= nextConflictCheck) { nextConflictCheck = Time.unscaledTime + 5f; ReportOverlaps(); } Interactions.Tick(this); if (!Guard.IsCameraViewAllowed()) { SuspendControl(); } else if (!Guard.IsCursorInputAllowed()) { Facing.Restore(); ChargeIndicator.Restore(); } } catch (Exception error) { Fail(error); } } private void Present(Camera camera) { if (!available || !CameraController.Active || (Object)(object)camera != (Object)(object)CameraController.Camera) { return; } try { CameraController.Present(Guard); bool windowOpen = Guard.IsModalUiOpen() || (InventoryGui.IsVisible() && !CursorInteractionController.InventoryPanelVisible()); CombatHud.Update(CameraController, Player.m_localPlayer, Guard.IsGameplayInputAllowed(), Guard.IsModeAllowed() && !Guard.IsUiOpen(), windowOpen, Settings); Interactions.Update(this); } catch (Exception error) { Fail(error); } } private void ReportOverlaps() { MethodBase[] array = targets; foreach (MethodBase methodBase in array) { Patches patchInfo = Harmony.GetPatchInfo(methodBase); if (patchInfo == null) { continue; } HashSet hashSet = new HashSet(StringComparer.Ordinal); InspectPatches(methodBase, patchInfo.Prefixes, "prefix", hashSet); InspectPatches(methodBase, patchInfo.Postfixes, "postfix", hashSet); InspectPatches(methodBase, patchInfo.Transpilers, "transpiler", hashSet); InspectPatches(methodBase, patchInfo.Finalizers, "finalizer", hashSet); if (hashSet.Count == 0) { continue; } string[] array2 = hashSet.OrderBy((string owner) => owner, StringComparer.Ordinal).ToArray(); string[] array3 = array2; foreach (string text in array3) { string item = methodBase.DeclaringType?.FullName + "." + methodBase.Name + ":" + text; if (reportedOverlaps.Add(item)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Camera/input overlap: " + methodBase.DeclaringType?.Name + "." + methodBase.Name + " is also patched by " + text + ". Isometric control remains available; test the combined behavior. Use F8 to return to vanilla if needed. No re-patching will be attempted.")); } } } } private void InspectPatches(MethodBase target, IEnumerable patches, string kind, HashSet blocked) { foreach (Patch patch in patches) { if (patch.owner == "dellarion.valheim.isometricview") { continue; } MethodInfo patchMethod = patch.PatchMethod; if (!PatchCompatibility.IsKnownCompatible(target.DeclaringType?.FullName, target.Name, patch.owner, kind, patchMethod?.DeclaringType?.FullName, patchMethod?.Name, patchMethod?.DeclaringType?.Assembly.GetName().Version.ToString())) { blocked.Add(patch.owner); continue; } string item = patch.owner + ":" + target.Name + ":" + kind + ":" + patchMethod.Name; if (reportedCompatiblePatches.Add(item)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Compatible camera hook: " + patch.owner + " " + patchMethod.DeclaringType?.FullName + "." + patchMethod.Name + ". Isometric control remains available and yields to building/UI contexts.")); } } } internal void Fail(Exception error) { available = false; SuspendControl(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } ((BaseUnityPlugin)this).Logger.LogError((object)("IsometricView disabled; vanilla control restored after an error: " + error)); } internal void LogMaterial(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } internal void LogVisibility(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } internal void Warn(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } internal void SuspendControl() { CameraController.Suspend(); Facing.Restore(); ChargeIndicator.Restore(); CenterCrosshair.Restore(); InventoryBowCrosshair.Restore(); KeyHintsVisibility.Restore(); CombatHud.Suspend(); HoverTextVisibility.Restore(); Interactions.Suspend(); } internal void BowInput(Player player, ItemData weapon, ref float drawTime, ref bool attackHold, ZSyncAnimation animation) { if (!Guard.IsLocal(player)) { return; } if ((Object)(object)bowPlayer != (Object)(object)player) { bowPlayer = player; bowManaged = false; } bool flag = Guard.IsGameplayInputAllowed() && CameraController.Active && MouseAimController.IsRanged(weapon); if (flag) { bowManaged = true; } if (!bowManaged) { return; } bool mouseButton = ZInput.GetMouseButton(0); if (bowGate.Step(flag, mouseButton)) { drawTime = -1f; attackHold = false; string text = weapon?.m_shared?.m_attack?.m_drawAnimationState; if (Object.op_Implicit((Object)(object)animation) && !string.IsNullOrEmpty(text)) { animation.SetBool(text, false); } } if (!flag && !mouseButton) { bowManaged = false; } } private void OnDisable() { SuspendControl(); } private void OnDestroy() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown available = false; Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(Present)); SuspendControl(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } internal static class RuntimePatches { internal static readonly string[] Names = new string[17] { "CameraUpdate", "MouseCapture", "MouseLook", "Controls", "ProjectileDirection", "BowDraw", "FaceCursor", "DrawIndicator", "HideKeyHints", "BuildingRay", "HoverRay", "PreciseShot", "VisibleEnemy", "EnemyTimers", "Interaction", "HammerRay", "HammerRay" }; internal static bool Interaction(Player __instance, GameObject __0) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.Guard.IsLocal(__instance) || !instance.CameraController.Active) { return true; } try { return !instance.CameraController.IsHiddenContent(__0) && instance.Interactions.AllowNativeInteraction(instance, __instance); } catch (Exception error) { instance.Fail(error); return true; } } internal static IEnumerable BuildingRay(IEnumerable source) { return CursorTranspilers.CursorRay(source, building: true); } internal static IEnumerable HammerRay(IEnumerable source) { return CursorTranspilers.CursorRay(source, building: true, hammer: true); } internal static IEnumerable HoverRay(IEnumerable source) { return CursorTranspilers.CursorRay(source, building: false); } internal static IEnumerable PreciseShot(IEnumerable source) { return CursorTranspilers.PrecisionSpread(source); } internal static void VisibleEnemy(Character __0, ref bool __result) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (instance.CameraController.Active && instance.Guard.IsCameraViewAllowed()) { Player val = (Player)(object)((__0 is Player) ? __0 : null); if (val != null) { __result = instance.CombatHud.ShowPlayerBar(val); return; } } if (instance.CameraController.Active && instance.Guard.IsCameraViewAllowed() && EnemyPresentation.Visible(instance.CameraController.Camera, Player.m_localPlayer, __0)) { __result = true; } } catch (Exception error) { instance.Fail(error); } } internal static void EnemyTimers(EnemyHud __instance) { try { Plugin instance = Plugin.Instance; if ((Object)(object)instance != (Object)null && instance.CameraController.Active && instance.Guard.IsCameraViewAllowed()) { instance.CombatHud.PreparePlayerBars(__instance, Player.m_localPlayer); } EnemyPresentation.KeepNativeBars(__instance); } catch (Exception error) { Plugin.Instance?.Fail(error); } } internal static bool CameraUpdate(GameCamera __instance, float dt, Camera ___m_camera, float ___m_fov) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } try { if (!instance.Guard.IsCameraViewAllowed() || !Object.op_Implicit((Object)(object)___m_camera)) { instance.SuspendControl(); return true; } instance.CameraController.Update(__instance, ___m_camera, __instance.m_skyCamera, ___m_fov, dt, instance.Guard, instance.Settings); if (instance.Guard.IsCursorInputAllowed() && !instance.CameraController.OrbitOwnsMiddle(instance.Guard, instance.Settings)) { Player localPlayer = Player.m_localPlayer; if (instance.Facing.ShouldFace(localPlayer)) { instance.Facing.Apply(localPlayer, ___m_camera); } } return false; } catch (Exception error) { instance.Fail(error); return true; } } internal static bool MouseCapture() { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return true; } try { if (!instance.Guard.IsPointerCaptureAllowed()) { instance.CameraController.ReleaseCursor(); return true; } instance.CameraController.CaptureCursor(); return false; } catch (Exception error) { instance.Fail(error); return true; } } internal static void MouseLook(Player __instance, ref Vector2 __0) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00af: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (!instance.Guard.IsLocal(__instance)) { return; } if (instance.Guard.IsCursorInputAllowed() && instance.CameraController.Active && Object.op_Implicit((Object)(object)instance.CameraController.Camera)) { if (!instance.CameraController.OrbitOwnsMiddle(instance.Guard, instance.Settings) && instance.Facing.ShouldFace(__instance)) { instance.Facing.Apply(__instance, instance.CameraController.Camera); } __0 = Vector2.zero; } else { instance.Facing.Restore(); if (instance.CameraController.Active && instance.Guard.IsPointerCaptureAllowed()) { __0 = Vector2.zero; } } } catch (Exception error) { instance.Fail(error); } } internal static void Controls(Player __instance, ref Vector3 __0, ref bool __1, ref bool __2, ref bool __3, ref bool __4) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c8: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0275: 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_0285: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (!instance.Guard.IsLocal(__instance) || !instance.CameraController.Active) { return; } bool flag = instance.CameraController.OrbitOwnsMiddle(instance.Guard, instance.Settings); if (flag) { __3 = false; __4 = false; } if (((Character)__instance).IsSitting() && instance.Guard.IsWorldPointerContext() && (instance.Interactions.ConsumeClick(instance, __instance) || instance.Guard.IsUiOpen())) { __1 = false; __2 = false; } if (instance.Interactions.BlockSeatingAttack(__instance)) { __1 = false; __2 = false; if (instance.Interactions.SeatingTransitionPending(__instance)) { return; } } if (!instance.Guard.IsMovementOverrideAllowed()) { return; } if (((Character)__instance).IsSwimming()) { __0 = CameraRelativeMovement.Rebase(__0, instance.CameraController.Forward, ((Character)__instance).GetLookDir()); return; } bool flag2 = instance.Interactions.ConsumeClick(instance, __instance); if (flag2) { __1 = false; __2 = false; } if (((Character)__instance).IsAttached() || ((Character)__instance).IsSitting()) { return; } if (!instance.Guard.IsCursorInputAllowed()) { __1 = false; __2 = false; if (((Vector3)(ref __0)).sqrMagnitude > 0.0001f) { instance.Facing.ApplyMovement(__instance, CameraRelativeMovement.ToUnity(ControlMath.Movement(CameraRelativeMovement.ToNumerics(__0), CameraRelativeMovement.ToNumerics(instance.CameraController.Forward)))); } __0 = CameraRelativeMovement.Rebase(__0, instance.CameraController.Forward, ((Character)__instance).GetLookDir()); } else { if (!flag && InteractionMath.FaceCursor(((Vector3)(ref __0)).sqrMagnitude, (!flag2 && ZInput.GetMouseButton(0)) || ZInput.GetMouseButton(2))) { instance.Facing.Apply(__instance, instance.CameraController.Camera); } else { instance.Facing.ApplyMovement(__instance, CameraRelativeMovement.ToUnity(ControlMath.Movement(CameraRelativeMovement.ToNumerics(__0), CameraRelativeMovement.ToNumerics(instance.CameraController.Forward)))); } __0 = CameraRelativeMovement.Rebase(__0, instance.CameraController.Forward, ((Character)__instance).GetLookDir()); } } catch (Exception error) { instance.Fail(error); } } internal static void ProjectileDirection(Attack __instance, Humanoid ___m_character, ItemData ___m_weapon, Vector3 __0, ref Vector3 __1) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { Player player = (Player)(object)((___m_character is Player) ? ___m_character : null); if (instance.Guard.IsLocal(player) && instance.Guard.IsGameplayInputAllowed() && instance.CameraController.Active && Object.op_Implicit((Object)(object)instance.CameraController.Camera) && MouseAimController.IsRanged(___m_weapon)) { ProjectileAim.Parameters(player, __instance, ProjectileAim.Ammo.Invoke(__instance), ProjectileAim.Draw.Invoke(__instance), out var projectile, out var speed); Vector3 val = ProjectileAim.Direction(instance.CameraController.Camera, player, __0, projectile, speed); __1 = Quaternion.AngleAxis(0f - __instance.m_launchAngle, Vector3.Cross(Vector3.up, val)) * val; } } catch (Exception error) { instance.Fail(error); } } internal static void BowDraw(Player __instance, ItemData weapon, ref float ___m_attackDrawTime, ref bool ___m_attackHold, ZSyncAnimation ___m_zanim) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { instance.BowInput(__instance, weapon, ref ___m_attackDrawTime, ref ___m_attackHold, ___m_zanim); } catch (Exception error) { instance.Fail(error); } } internal static void FaceCursor(Player __instance, ref bool __result) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (instance.Guard.IsLocal(__instance) && instance.Guard.IsCursorInputAllowed() && instance.CameraController.Active) { __result = !instance.CameraController.OrbitOwnsMiddle(instance.Guard, instance.Settings) && instance.Facing.ShouldFace(__instance); } } catch (Exception error) { instance.Fail(error); } } internal static void DrawIndicator(Hud __instance, Player __0) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { bool flag = instance.Guard.IsLocal(__0) && instance.Guard.IsCameraViewAllowed() && instance.CameraController.Active; if (flag) { instance.CenterCrosshair.Hide((Graphic)(object)__instance.m_crosshair); instance.HoverTextVisibility.Hide((Graphic)(object)__instance.m_hoverName); } else { instance.CenterCrosshair.Restore(); instance.HoverTextVisibility.Restore(); } if (flag && instance.Guard.IsUiOpen()) { instance.InventoryBowCrosshair.Hide((Graphic)(object)__instance.m_crosshairBow); } else { instance.InventoryBowCrosshair.Restore(); } if (instance.Guard.IsLocal(__0) && instance.Guard.IsGameplayInputAllowed() && instance.CameraController.Active && ((Character)__0).IsDrawingBow()) { instance.ChargeIndicator.Update(__instance.m_crosshairBow); } else { instance.ChargeIndicator.Restore(); } } catch (Exception error) { instance.Fail(error); } } internal static void HideKeyHints(KeyHints __instance) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return; } try { if (instance.CameraController.Active && instance.Guard.IsCameraViewAllowed() && !instance.Guard.IsUiOpen()) { instance.KeyHintsVisibility.Hide(__instance); } else { instance.KeyHintsVisibility.Restore(); } } catch (Exception error) { instance.Fail(error); } } } [Serializable] internal sealed class PresentationTokens { internal static readonly PresentationTokens Current = Load(); public float playerWidth; public float targetWidth; public float healthHeight; public float nameHeight; public float nameSize; public float healthTextSize; public float targetTopOffset; public float headOffset; public float ringWidth; public float ringOffset; public float outlineWidth; public float hoverOutlineWidth; public float tooltipWidth; public float tooltipHeight; public float tooltipFontSize; public float tooltipOffset; public float cameraTurnDuration; public float bushTintStrength; public float occluderVisibility; public float haloFadeDuration; public float blockedRevealScale; public float stealthGap; public Color threatColor; public Color playerRingColor; public Color healthColor; public Color surfaceColor; public Color textColor; public Color hoverColor; public Color lootBackground; public Color lootIdleText; public float lootPaddingX; public float lootPaddingY; public float lootHoverAlpha; private static PresentationTokens Load() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("IsometricView.presentation.json"); using StreamReader streamReader = new StreamReader(stream ?? throw new InvalidOperationException("Missing presentation tokens.")); return JsonUtility.FromJson(streamReader.ReadToEnd()); } } internal static class ProjectileAim { internal static readonly FieldRef Draw = AccessTools.FieldRefAccess("m_attackDrawPercentage"); internal static readonly FieldRef Ammo = AccessTools.FieldRefAccess("m_ammoItem"); private static readonly FieldRef Owner = AccessTools.FieldRefAccess("m_character"); private static readonly FieldRef Weapon = AccessTools.FieldRefAccess("m_weapon"); internal static void Parameters(Player player, Attack attack, ItemData ammo, float draw, out Projectile projectile, out float speed) { Attack val = ammo?.m_shared?.m_attack; bool flag = Object.op_Implicit((Object)(object)val?.m_attackProjectile); GameObject val2 = (flag ? val.m_attackProjectile : attack.m_attackProjectile); projectile = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent() : null); float num = attack.m_projectileVel + (flag ? val.m_projectileVel : 0f); float num2 = attack.m_projectileVelMin + (flag ? val.m_projectileVelMin : 0f); AnimationCurve val3 = (flag ? val.m_drawVelocityCurve : attack.m_drawVelocityCurve); speed = (attack.m_bowDraw ? Mathf.Lerp(num2, num, (val3 != null) ? val3.Evaluate(draw) : draw) : num); } internal static Vector3 Direction(Camera camera, Player player, Vector3 spawn, Projectile projectile, float speed) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0069: Unknown result type (might be due to invalid IL or missing references) Vector3 value = MouseAimController.Point(camera, player) - spawn; if (Object.op_Implicit((Object)(object)projectile) && BallisticAim.Solve(CameraRelativeMovement.ToNumerics(value), speed, projectile.m_gravity, projectile.m_drag, Time.fixedDeltaTime, out var direction)) { return CameraRelativeMovement.ToUnity(direction); } return (((Vector3)(ref value)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref value)).normalized : ((Component)camera).transform.forward; } internal static float Accuracy(float native, Attack attack) { Plugin instance = Plugin.Instance; bool mode = (Object)(object)instance != (Object)null && instance.CameraController.Active && instance.Guard.IsGameplayInputAllowed(); return InteractionMath.PrecisionEnabled(mode, (Object)(object)Owner.Invoke(attack) == (Object)(object)Player.m_localPlayer, MouseAimController.IsRanged(Weapon.Invoke(attack))) ? 0f : native; } } internal sealed class RainRoofCoverage { private const int MaxProbesPerFrame = 32; private const float CellSize = 0.75f; private const float HeightBand = 8f; private const int ViewColumns = 192; private const int ViewRows = 108; private static readonly int RoofMask = LayerMask.GetMask(new string[4] { "piece", "Default", "static_solid", "Default_small" }); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[32]; private readonly Dictionary columns = new Dictionary(); private readonly Dictionary viewDepths = new Dictionary(); private Vector3 playerPosition; private Vector3 cacheAnchor; private Camera camera; private RoomCutawayController room; private bool projectInterior; private float roomFloor; private float roomTop; private int frame = -1; private int budget; private long revision = -1L; private float heightBand; private float radiusSquared; private float now; internal bool HasProjectedInterior => projectInterior; internal void Begin(Camera renderCamera, Player player, RoomCutawayController cutaway, float radius) { //IL_0008: 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_00bc: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) playerPosition = ((Component)player).transform.position; radiusSquared = radius * radius; if (frame == Time.frameCount) { return; } frame = Time.frameCount; camera = renderCamera; room = cutaway; projectInterior = room.RainInterior(out roomFloor, out roomTop); viewDepths.Clear(); budget = 32; now = Time.unscaledTime; float num = Mathf.Floor(playerPosition.y / 8f) * 8f; if (num == heightBand && revision == RoomTopology.Revision) { Vector3 val = playerPosition - cacheAnchor; if (((Vector3)(ref val)).sqrMagnitude < 64f) { return; } } cacheAnchor = playerPosition; heightBand = num; revision = RoomTopology.Revision; columns.Clear(); } internal bool Covers(Vector3 particle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_004a: 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_0082: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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) float num = particle.x - playerPosition.x; float num2 = particle.z - playerPosition.z; if (num * num + num2 * num2 > radiusSquared || particle.y < heightBand - 8f || particle.y > heightBand + 32f) { return false; } Vector2Int val = default(Vector2Int); ((Vector2Int)(ref val))..ctor(Mathf.FloorToInt(particle.x / 0.75f), Mathf.FloorToInt(particle.z / 0.75f)); (float, float) value; bool flag = columns.TryGetValue(val, out value); if (budget > 0 && (!flag || now >= value.Item2)) { budget--; value = (RoofHeight(val), now + 2f); columns[val] = value; flag = true; } return flag && particle.y <= value.Item1; } internal bool CoversRoomInView(Vector3 point) { //IL_001c: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0057: Unknown result type (might be due to invalid IL or missing references) if (!projectInterior) { return false; } Vector3 val = camera.WorldToViewportPoint(point); if (val.z <= 0f || val.x < 0f || val.x >= 1f || val.y < 0f || val.y >= 1f) { return false; } Vector2Int val2 = default(Vector2Int); ((Vector2Int)(ref val2))..ctor((int)(val.x * 192f), (int)(val.y * 108f)); if (!viewDepths.TryGetValue(val2, out var value)) { value = (viewDepths[val2] = InteriorDepth(val2)); } return val.z <= value; } private float InteriorDepth(Vector2Int cell) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_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) Ray val = camera.ViewportPointToRay(new Vector3(((float)((Vector2Int)(ref cell)).x + 0.5f) / 192f, ((float)((Vector2Int)(ref cell)).y + 0.5f) / 108f)); if (((Ray)(ref val)).direction.y >= -0.01f) { return 0f; } float num = (roomFloor + 0.05f - ((Ray)(ref val)).origin.y) / ((Ray)(ref val)).direction.y; float num2 = Mathf.Max(0f, (roomTop - 0.05f - ((Ray)(ref val)).origin.y) / ((Ray)(ref val)).direction.y); if (num < num2) { return 0f; } for (float num3 = num; num3 >= num2; num3 -= 0.25f) { Vector3 point = ((Ray)(ref val)).GetPoint(num3); if (room.ContainsRainInterior(point)) { return camera.WorldToViewportPoint(point).z; } } return 0f; } private float RoofHeight(Vector2Int cell) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_006d: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((float)((Vector2Int)(ref cell)).x + 0.5f) * 0.75f, heightBand + 32f, ((float)((Vector2Int)(ref cell)).y + 0.5f) * 0.75f); int num = Physics.RaycastNonAlloc(val, Vector3.down, hits, 40f, RoofMask, (QueryTriggerInteraction)1); RaycastHit[] array = ((num == hits.Length) ? Physics.RaycastAll(val, Vector3.down, 40f, RoofMask, (QueryTriggerInteraction)1) : hits); if (array != hits) { num = array.Length; } float num2 = float.NegativeInfinity; for (int i = 0; i < num; i++) { RaycastHit val2 = array[i]; if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).point.y <= num2)) { Piece componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent(); BuildingKind buildingKind = RoomCutawayController.Classify(componentInParent); if (buildingKind == BuildingKind.Roof || buildingKind == BuildingKind.Floor) { num2 = ((RaycastHit)(ref val2)).point.y; } } } return num2; } internal void Clear() { frame = -1; columns.Clear(); viewDepths.Clear(); camera = null; room = null; projectInterior = false; } } internal sealed class RemotePlayerPresentation { internal const float LocalLift = 0.25f; private readonly Dictionary opacity = new Dictionary(); private readonly Dictionary visibility = new Dictionary(); private readonly List graphics = new List(); private readonly List hiddenGraphics = new List(); private EnemyHud owner; private Player localHud; private RectTransform movedBar; private Vector3 previousPosition; internal void Prepare(EnemyHud hud, Player player) { Restore(); if ((Object)(object)owner != (Object)(object)hud || (Object)(object)localHud != (Object)(object)player) { Dispose(); owner = hud; localHud = player; } if (Object.op_Implicit((Object)(object)player) && !((Character)player).IsDead() && !Hud.IsUserHidden()) { EnemyPresentation.EnsureLocalBar(hud, player); } } internal static float Opacity(Camera camera, Player local, Player player) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00ac: 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_00bc: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)camera) || !Object.op_Implicit((Object)(object)local) || !Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead() || Hud.IsUserHidden()) { return 0f; } if (!ScreenSpaceMath.InViewport(CameraRelativeMovement.ToNumerics(camera.WorldToViewportPoint(((Character)player).GetCenterPoint())))) { return 0f; } if ((Object)(object)player == (Object)(object)local) { return 1f; } if (Object.op_Implicit((Object)(object)ZNet.instance)) { ZDOID zDOID = ((Character)player).GetZDOID(); foreach (PlayerInfo player2 in ZNet.instance.GetPlayerList()) { if (player2.m_characterID == zDOID && player2.m_publicPosition) { return 1f; } } } return RemotePlayerVisibility.Opacity(Vector3.Distance(((Component)local).transform.position, ((Component)player).transform.position), publicPosition: false); } internal RectTransform Update(Camera camera, Player local, IsometricConfig settings) { //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_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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) Restore(); foreach (Player allPlayer in Player.GetAllPlayers()) { if ((Object)(object)allPlayer == (Object)(object)local) { continue; } GameObject val = EnemyPresentation.NativeBar((Character)(object)allPlayer); if (!Object.op_Implicit((Object)(object)val)) { continue; } float num = Opacity(camera, local, allPlayer); if (num < 1f && val.activeInHierarchy) { CanvasGroup val2 = val.GetComponent(); if (!Object.op_Implicit((Object)(object)val2)) { val2 = val.AddComponent(); } opacity[val2] = val2.alpha; CanvasGroup obj = val2; obj.alpha *= num; } } GameObject val3 = EnemyPresentation.NativeBar((Character)(object)local); if (!Object.op_Implicit((Object)(object)val3) || Opacity(camera, local, local) <= 0f) { return null; } Transform transform = val3.transform; RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (!Object.op_Implicit((Object)(object)val4)) { return null; } SetVisible(val3, visible: true); if (!val3.activeInHierarchy) { return null; } CanvasGroup component = val3.GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.alpha < 1f) { opacity[component] = component.alpha; component.alpha = 1f; } movedBar = val4; previousPosition = val4.anchoredPosition3D; Vector3 val5 = Utils.WorldToScreenPointScaled(camera, ((Character)local).GetHeadPoint() + Vector3.up * 0.55f); ((Transform)val4).position = new Vector3(val5.x, val5.y, ((Transform)val4).position.z); if (!settings.PlayerHealthBar.Value) { GameObject val6 = EnemyPresentation.NativeName(local); ((Component)val4).GetComponentsInChildren(true, graphics); foreach (Graphic graphic in graphics) { if (((Behaviour)graphic).enabled && (!Object.op_Implicit((Object)(object)val6) || !((Component)graphic).transform.IsChildOf(val6.transform))) { hiddenGraphics.Add(graphic); ((Behaviour)graphic).enabled = false; } } graphics.Clear(); } if (!settings.PlayerName.Value) { SetVisible(EnemyPresentation.NativeName(local), visible: false); } return val4; } private void SetVisible(GameObject node, bool visible) { if (Object.op_Implicit((Object)(object)node) && node.activeSelf != visible && !visibility.ContainsKey(node)) { visibility.Add(node, node.activeSelf); node.SetActive(visible); } } private void Restore() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) foreach (Graphic hiddenGraphic in hiddenGraphics) { if (Object.op_Implicit((Object)(object)hiddenGraphic)) { ((Behaviour)hiddenGraphic).enabled = true; } } hiddenGraphics.Clear(); if (Object.op_Implicit((Object)(object)movedBar)) { movedBar.anchoredPosition3D = previousPosition; } movedBar = null; foreach (KeyValuePair item in opacity) { if (Object.op_Implicit((Object)(object)item.Key)) { item.Key.alpha = item.Value; } } foreach (KeyValuePair item2 in visibility) { if (Object.op_Implicit((Object)(object)item2.Key)) { item2.Key.SetActive(item2.Value); } } opacity.Clear(); visibility.Clear(); } internal void Dispose() { Restore(); if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)localHud) && (Object)(object)owner == (Object)(object)EnemyHud.instance) { owner.RemoveCharacterHud((Character)(object)localHud); } owner = null; localHud = null; } } internal sealed class RoomCutawayController { private sealed class Info { internal Piece Piece; internal BuildingKind Kind; internal Bounds Bounds; internal Renderer[] Renderers; internal RoomWall Wall; internal List SupportPlanes; } internal readonly HashSet Hidden = new HashSet(); internal readonly Dictionary Cuts = new Dictionary(); internal readonly Dictionary> Sections = new Dictionary>(); internal readonly HashSet Protected = new HashSet(); internal readonly FloorTracker Level = new FloorTracker(); private Vector2 viewPosition; private static readonly int PieceMask = LayerMask.GetMask(new string[4] { "piece", "Default", "static_solid", "Default_small" }); private static readonly FieldRef GroundPoint = AccessTools.FieldRefAccess("m_lastGroundPoint"); private static readonly FieldRef Move = AccessTools.FieldRefAccess("m_moveDir"); private static readonly FieldRef UnderRoof = AccessTools.FieldRefAccess("m_underRoof"); private readonly List pieces = new List(); private readonly List infos = new List(); private readonly List contents = new List(); private readonly List storeyFloors = new List(); private readonly HashSet hiddenContents = new HashSet(); private readonly List watchedPieces = new List(); private readonly Dictionary infoByPiece = new Dictionary(); private readonly VisibilityOverlay selection = new VisibilityOverlay(); private readonly Dictionary localSelection = new Dictionary(); private readonly List renderers = new List(); private readonly List colliders = new List(); private readonly List walls = new List(); private readonly List covers = new List(); private readonly HashSet building = new HashSet(); private readonly List buildingFloor = new List(); private readonly List sideWalls = new List(); private readonly Dictionary kinds = new Dictionary(); private readonly Dictionary doors = new Dictionary(); private readonly Dictionary rendererPieces = new Dictionary(); private readonly HashSet foreground = new HashSet(); private readonly Dictionary foregroundSeen = new Dictionary(); private readonly List expiredForeground = new List(); private readonly RaycastHit[] foregroundHits = (RaycastHit[])(object)new RaycastHit[96]; private float nextForeground; private Vector2 buildingAnchor; private Vector2 buildingMin; private Vector2 buildingMax; private readonly HashSet walking = new HashSet(); private readonly RoomResidence residence = new RoomResidence(); private RoomLayout room = new RoomLayout(); private readonly DungeonCutaway dungeon = new DungeonCutaway(); private float nextProbe; private float ceiling; private float searchRadius; private float cutHeight; private bool roofs; private bool roofEvidence; private Vector3 scanned; private long revision = -1L; private float sector = float.NaN; private int lastFrame = -1; internal bool Inside { get; private set; } internal bool InDungeon { get; private set; } internal int Version { get; private set; } internal int Generation { get; private set; } internal int SnapshotCount { get; private set; } internal int LocalChangeCount { get; private set; } internal bool SuppressHalo => Inside || Level.OnStairs; internal bool BuildingMode { get; private set; } internal Vector3 Focus { get; private set; } internal DungeonSlice? DungeonSection => InDungeon ? new DungeonSlice?(dungeon.Slice) : ((DungeonSlice?)null); internal void Update(Camera camera, Player player, IsometricConfig config) { //IL_004e: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: 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_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: 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_0610: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) if (lastFrame == Time.frameCount) { return; } bool flag = ((Character)player).InInterior(); if (flag != InDungeon) { Dispose(); } InDungeon = flag; lastFrame = Time.frameCount; Focus = ((Character)player).GetCenterPoint(); viewPosition = new Vector2(((Component)camera).transform.position.x, ((Component)camera).transform.position.z); if (InDungeon) { Inside = true; if (!config.RoomCutaway.Value && !config.BuildingCutaway.Value) { if (Hidden.Count > 0 || Cuts.Count > 0) { ClearSelection(); } dungeon.Clear(); return; } if (dungeon.Update(camera, player, config, Hidden, Cuts, out var topologyChanged)) { Version++; } if (topologyChanged) { Generation++; } return; } walking.Clear(); Collider lastGroundCollider = ((Character)player).GetLastGroundCollider(); Piece val = (Object.op_Implicit((Object)(object)lastGroundCollider) ? ((Component)lastGroundCollider).GetComponentInParent() : null); bool flag2 = ((Character)player).IsOnGround() && Mathf.Abs(GroundPoint.Invoke((Character)(object)player).y - ((Component)player).transform.position.y) < 1.5f; Level.Update(flag2, KindOf(val) == BuildingKind.Stair, flag2 ? GroundPoint.Invoke((Character)(object)player).y : ((Component)player).transform.position.y, Time.unscaledDeltaTime); if (Object.op_Implicit((Object)(object)val)) { walking.Add(((Component)val).transform); } Vector3 val2 = Move.Invoke((Character)(object)player); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.001f) { ((Vector3)(ref val2)).Normalize(); } RaycastHit val4 = default(RaycastHit); for (int i = 1; i <= 3; i++) { Vector3 val3 = ((Component)player).transform.position + val2 * ((float)i * 0.65f) + Vector3.up * 1.5f; if (Physics.Raycast(val3, Vector3.down, ref val4, 3f, PieceMask, (QueryTriggerInteraction)1)) { Piece componentInParent = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent(); BuildingKind buildingKind = KindOf(componentInParent); if (Object.op_Implicit((Object)(object)componentInParent) && (buildingKind == BuildingKind.Stair || buildingKind == BuildingKind.Floor)) { walking.Add(((Component)componentInParent).transform); } } } if (!config.RoomCutaway.Value && !config.BuildingCutaway.Value) { if (Inside || Hidden.Count > 0 || Cuts.Count > 0) { ClearSelection(); } Inside = false; searchRadius = 0f; sector = float.NaN; roofEvidence = false; RoomTopology.Stop(); return; } bool flag3 = UnderRoof.Invoke(player) || player.InShelter(); Vector2 point = new Vector2(((Component)player).transform.position.x, ((Component)player).transform.position.z); bool flag4 = searchRadius != config.RoomSearchRadius.Value || BuildingMode != config.BuildingCutaway.Value; bool flag5 = revision != RoomTopology.Revision && Time.unscaledTime >= RoomTopology.LastChange + 0.3f; bool contains = ((!BuildingMode) ? room.Contains(point) : ((Object.op_Implicit((Object)(object)val) && building.Contains(val)) || InBuilding(point))); RoomDeparture roomDeparture = (Inside ? residence.Check(contains, flag2, Level.OnStairs, Level.Floor, Time.unscaledDeltaTime) : RoomDeparture.Keep); bool flag6 = roomDeparture != RoomDeparture.Keep; int num; if (!Inside && flag3 && Time.unscaledTime >= nextProbe) { if (roofEvidence) { Vector3 val5 = ((Component)player).transform.position - scanned; num = ((((Vector3)(ref val5)).sqrMagnitude >= 0.25f) ? 1 : 0); } else { num = 1; } } else { num = 0; } bool flag7 = (byte)num != 0; if (flag2 && !Level.OnStairs && (flag4 || flag5 || flag6 || flag7)) { searchRadius = config.RoomSearchRadius.Value; BuildingMode = config.BuildingCutaway.Value; Plugin.Instance?.LogVisibility("Room refresh: " + (flag4 ? "settings/mode" : (flag5 ? "placed/removed module" : (flag6 ? roomDeparture.ToString() : "entry")))); if (flag6 && roomDeparture == RoomDeparture.Floor && !flag4 && !flag5 && infos.Count > 0) { ResolveFloor(player); } else { Scan(player, searchRadius); } scanned = ((Component)player).transform.position; nextProbe = Time.unscaledTime + 1f; revision = RoomTopology.Revision; sector = float.NaN; } roofEvidence = flag3; float num2 = CameraMath.SnapDiagonalYaw(((Component)camera).transform.eulerAngles.y); if (sector != num2) { foreground.Clear(); foregroundSeen.Clear(); nextForeground = 0f; } bool flag8 = UpdateForeground(camera, player); float num3 = (BuildingMode ? config.BuildingWallHeight.Value : config.WallCutHeight.Value); bool flag9 = BuildingMode || config.HideRoofs.Value; if (sector != num2 || cutHeight != num3 || roofs != flag9) { sector = num2; cutHeight = num3; roofs = flag9; Select(); } else if (flag8) { ApplyForeground(); } } private bool UpdateForeground(Camera camera, Player player) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a5: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0151: Unknown result type (might be due to invalid IL or missing references) if (!Inside) { bool result = foreground.Count > 0; foreground.Clear(); foregroundSeen.Clear(); return result; } if (Time.unscaledTime < nextForeground) { return false; } nextForeground = Time.unscaledTime + 0.15f; Vector3[] array = (Vector3[])(object)new Vector3[2] { ((Character)player).GetCenterPoint(), ((Character)player).GetTopPoint() }; foreach (Vector3 val in array) { Vector3 val2 = ((Component)camera).transform.position - val; Vector3 val3 = val + ((Vector3)(ref val2)).normalized * 0.08f; int num = Physics.RaycastNonAlloc(val3, ((Vector3)(ref val2)).normalized, foregroundHits, Mathf.Max(0f, ((Vector3)(ref val2)).magnitude - 0.08f), PieceMask, (QueryTriggerInteraction)1); if (num == foregroundHits.Length) { RaycastHit[] array2 = Physics.RaycastAll(val3, ((Vector3)(ref val2)).normalized, Mathf.Max(0f, ((Vector3)(ref val2)).magnitude - 0.08f), PieceMask, (QueryTriggerInteraction)1); foreach (RaycastHit hit in array2) { SeeForeground(hit); } } else { for (int k = 0; k < num; k++) { SeeForeground(foregroundHits[k]); } } } expiredForeground.Clear(); foreach (KeyValuePair item in foregroundSeen) { if (!Object.op_Implicit((Object)(object)item.Key) || Time.unscaledTime - item.Value > 0.5f) { expiredForeground.Add(item.Key); } } foreach (Piece item2 in expiredForeground) { foregroundSeen.Remove(item2); } bool flag = foreground.Count != foregroundSeen.Count; foreach (Piece key in foregroundSeen.Keys) { if (!foreground.Contains(key)) { flag = true; } } if (flag) { foreground.Clear(); foreach (Piece key2 in foregroundSeen.Keys) { foreground.Add(key2); } } return flag; } private void SeeForeground(RaycastHit hit) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d8: Unknown result type (might be due to invalid IL or missing references) Collider collider = ((RaycastHit)(ref hit)).collider; Piece val = (Object.op_Implicit((Object)(object)collider) ? ((Component)collider).GetComponentInParent() : null); if (Object.op_Implicit((Object)(object)val) && !IsDoor(val) && building.Contains(val) && !walking.Contains(((Component)val).transform)) { BuildingKind buildingKind = KindOf(val); if ((buildingKind != BuildingKind.Wall || !infoByPiece.TryGetValue(val, out var value) || ViewOcclusion.WallBetween(value.Wall, new Vector2(Focus.x, Focus.z), viewPosition)) && CutawayMath.CameraSide(new Vector2(((RaycastHit)(ref hit)).point.x, ((RaycastHit)(ref hit)).point.z), new Vector2(Focus.x, Focus.z), viewPosition) && (buildingKind == BuildingKind.Wall || buildingKind == BuildingKind.Frame)) { foregroundSeen[val] = Time.unscaledTime; } } } private void Select() { //IL_0045: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_0333: 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_035a: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) SnapshotCount++; ClearSelection(); if (!Inside) { return; } Dictionary dictionary = new Dictionary(); Vector3 val = Quaternion.Euler(0f, sector, 0f) * Vector3.back; Vector2 vector = new Vector2(val.x, val.z); Vector2 vector2 = new Vector2(Focus.x, Focus.z); Vector2 camera = vector2 + vector * Vector2.Distance(vector2, viewPosition); float cut = residence.Floor + cutHeight; sideWalls.Clear(); foreach (Info info in infos) { if (Object.op_Implicit((Object)(object)info.Piece) && info.Kind == BuildingKind.Wall && CutawayMath.WallOnFloor(((Bounds)(ref info.Bounds)).min.y, ((Bounds)(ref info.Bounds)).max.y, ((Component)info.Piece).transform.position.y, residence.Floor, info.Wall.Opening) && Selected(info)) { sideWalls.Add(info.Wall); } } foreach (Info info2 in infos) { if (!Object.op_Implicit((Object)(object)info2.Piece) || IsDoor(info2.Piece) || !CutawayMath.Structural(info2.Kind) || info2.Kind == BuildingKind.Stair || !Selected(info2)) { continue; } bool flag = info2.Kind == BuildingKind.Frame && ((Bounds)(ref info2.Bounds)).min.y >= ceiling - 0.75f && ((Bounds)(ref info2.Bounds)).size.y < Mathf.Max(((Bounds)(ref info2.Bounds)).size.x, ((Bounds)(ref info2.Bounds)).size.z); bool flag2 = ((Bounds)(ref info2.Bounds)).min.y >= ceiling - 0.12f || flag; if (roofs && (info2.Kind == BuildingKind.Roof || flag2)) { dictionary[info2.Piece] = new PartVisibility(PartView.Hidden); } else { if (info2.Kind != BuildingKind.Wall && info2.Kind != BuildingKind.Frame) { continue; } bool flag3 = ViewOcclusion.WallBetween(info2.Wall, vector2, camera); List list = null; if (info2.Kind == BuildingKind.Frame) { if (info2.SupportPlanes == null) { info2.SupportPlanes = BuildingLayout.SupportPlanes(new Vector2(((Bounds)(ref info2.Bounds)).min.x, ((Bounds)(ref info2.Bounds)).min.z), new Vector2(((Bounds)(ref info2.Bounds)).max.x, ((Bounds)(ref info2.Bounds)).max.z), sideWalls); } list = BuildingLayout.ViewSections(new Vector2(((Bounds)(ref info2.Bounds)).min.x, ((Bounds)(ref info2.Bounds)).min.z), new Vector2(((Bounds)(ref info2.Bounds)).max.x, ((Bounds)(ref info2.Bounds)).max.z), vector2, camera, info2.SupportPlanes); flag3 = list.Exists((SectionRun section) => section.Front); } dictionary[info2.Piece] = (flag3 ? CutState(info2, cut, list) : new PartVisibility(PartView.Protected)); } } SelectContents(dictionary); selection.Reset(dictionary); foreach (KeyValuePair item in selection.Current) { WriteVisibility(item.Key, item.Value); } ApplyForeground(); Plugin.Instance?.LogVisibility(string.Format("Room snapshot {0}: mode={1}, floor={2:F2}, view={3:F0}, roofs={4}, cuts={5}, members={6}; retained until a room/floor/view/topology change.", Version, BuildingMode ? "Building" : "Room", residence.Floor, sector, Hidden.Count, Cuts.Count, building.Count)); } private void SelectContents(Dictionary baseline) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_017a: Unknown result type (might be due to invalid IL or missing references) storeyFloors.Clear(); foreach (Info info in infos) { if (Object.op_Implicit((Object)(object)info.Piece) && info.Kind == BuildingKind.Floor) { PartVisibility value; bool hidden = baseline.TryGetValue(info.Piece, out value) && value.View == PartView.Hidden; storeyFloors.Add(new StoreyFloor(new Vector2(((Bounds)(ref info.Bounds)).min.x, ((Bounds)(ref info.Bounds)).min.z), new Vector2(((Bounds)(ref info.Bounds)).max.x, ((Bounds)(ref info.Bounds)).max.z), ((Bounds)(ref info.Bounds)).min.y, ((Bounds)(ref info.Bounds)).max.y, hidden)); } } foreach (Info content in contents) { if (Object.op_Implicit((Object)(object)content.Piece) && !IsDoor(content.Piece)) { Vector3 position = ((Component)content.Piece).transform.position; if (StoreyVisibility.Hidden(new Vector3(position.x, position.y, position.z), ((Bounds)(ref content.Bounds)).min.y, residence.Floor, storeyFloors)) { hiddenContents.Add(content.Piece); baseline[content.Piece] = new PartVisibility(PartView.Hidden); } } } } private static PartVisibility CutState(Info info, float cut, List sections) { //IL_0033: 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) bool flag = sections?.Exists((SectionRun section) => !section.Front) ?? false; if (((Bounds)(ref info.Bounds)).min.y >= cut && !flag) { return new PartVisibility(PartView.Hidden); } if (((Bounds)(ref info.Bounds)).max.y > cut) { return new PartVisibility(PartView.Cut, cut, flag ? sections : null); } return new PartVisibility(PartView.Native); } private void ApplyForeground() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) localSelection.Clear(); Vector3 val = Quaternion.Euler(0f, sector, 0f) * Vector3.back; Vector2 vector = new Vector2(Focus.x, Focus.z); Vector2 camera = vector + new Vector2(val.x, val.z) * Vector2.Distance(vector, viewPosition); foreach (Piece item in foreground) { if (Object.op_Implicit((Object)(object)item) && infoByPiece.TryGetValue(item, out var value)) { if (selection.TryBaseline(item, out var value2) && value2.View == PartView.Hidden) { localSelection.Add(item, value2); continue; } if (selection.TryOverride(item, out var value3)) { localSelection.Add(item, value3); continue; } List sections = ((value.Kind == BuildingKind.Frame) ? BuildingLayout.CameraSections(new Vector2(((Bounds)(ref value.Bounds)).min.x, ((Bounds)(ref value.Bounds)).min.z), new Vector2(((Bounds)(ref value.Bounds)).max.x, ((Bounds)(ref value.Bounds)).max.z), vector, camera) : null); localSelection.Add(item, CutState(value, residence.Floor + cutHeight, sections)); } } IReadOnlyList readOnlyList = selection.Replace(localSelection); if (readOnlyList.Count == 0) { return; } LocalChangeCount++; foreach (Piece item2 in readOnlyList) { WriteVisibility(item2, selection.Current.TryGetValue(item2, out var value4) ? value4 : new PartVisibility(PartView.Native)); } Version++; } private void WriteVisibility(Piece piece, PartVisibility state) { if (!Object.op_Implicit((Object)(object)piece) || !infoByPiece.TryGetValue(piece, out var value)) { return; } Protected.Remove(((Component)piece).transform); if (state.View == PartView.Protected) { Protected.Add(((Component)piece).transform); } Renderer[] array = value.Renderers; foreach (Renderer val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Hidden.Remove(val); Cuts.Remove(val); Sections.Remove(val); if (state.View == PartView.Hidden) { Hidden.Add(val); } else if (state.View == PartView.Cut) { Cuts[val] = state.Height; if (state.Sections != null) { Sections[val] = new List(state.Sections); } } } } private bool Selected(Info info) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) return BuildingMode ? building.Contains(info.Piece) : room.Intersects(new Vector2(((Bounds)(ref info.Bounds)).min.x - 0.1f, ((Bounds)(ref info.Bounds)).min.z - 0.1f), new Vector2(((Bounds)(ref info.Bounds)).max.x + 0.1f, ((Bounds)(ref info.Bounds)).max.z + 0.1f)); } private bool InBuilding(Vector2 point) { foreach (RoomCover item in buildingFloor) { if (item.Contains(point)) { return true; } } return false; } internal bool RainInterior(out float floor, out float top) { floor = residence.Floor; top = ceiling; return Inside && !InDungeon && top > floor; } internal bool ContainsRainInterior(Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Vector2 point2 = new Vector2(point.x, point.z); return room.Enclosed ? room.Contains(point2) : (BuildingMode && point2.X >= buildingMin.X && point2.X <= buildingMax.X && point2.Y >= buildingMin.Y && point2.Y <= buildingMax.Y && InBuilding(point2)); } private void ClearSelection() { Hidden.Clear(); Cuts.Clear(); Sections.Clear(); Protected.Clear(); hiddenContents.Clear(); selection.Clear(); localSelection.Clear(); Version++; } private void Scan(Player player, float radius) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: 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_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_030b: 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_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0368: 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_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038f: 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_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: 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_043d: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) Generation++; pieces.Clear(); infos.Clear(); contents.Clear(); infoByPiece.Clear(); walls.Clear(); covers.Clear(); kinds.Clear(); doors.Clear(); rendererPieces.Clear(); float num = (BuildingMode ? (radius * 2f) : radius); Piece.GetAllPiecesInRadius(((Component)player).transform.position, num, pieces); pieces.Sort((Piece a, Piece b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID())); float floor = Level.Floor; Bounds bounds = default(Bounds); foreach (Piece piece in pieces) { if (!Object.op_Implicit((Object)(object)piece)) { continue; } BuildingKind buildingKind = KindOf(piece); bool content = buildingKind == BuildingKind.Other && IsStoreyContent(piece); if (!content && !CutawayMath.Structural(buildingKind)) { continue; } renderers.Clear(); ((Component)piece).GetComponentsInChildren(false, renderers); renderers.RemoveAll((Renderer r) => !Object.op_Implicit((Object)(object)r) || (!content && !(r is MeshRenderer) && !(r is SkinnedMeshRenderer)) || Object.op_Implicit((Object)(object)((Component)r).GetComponent()) || Object.op_Implicit((Object)(object)((Component)r).GetComponentInParent()) || (Object)(object)((Component)r).GetComponentInParent() != (Object)(object)piece); if (renderers.Count == 0) { continue; } bool flag = false; ((Bounds)(ref bounds))..ctor(((Component)piece).transform.position, Vector3.zero); foreach (Renderer renderer in renderers) { if (renderer is MeshRenderer || renderer is SkinnedMeshRenderer) { if (flag) { ((Bounds)(ref bounds)).Encapsulate(renderer.bounds); continue; } bounds = renderer.bounds; flag = true; } } if (!flag) { continue; } Vector3 normal = ((Component)piece).transform.forward; normal.y = 0f; if (((Vector3)(ref normal)).sqrMagnitude < 0.1f) { normal = Vector3.forward; } ((Vector3)(ref normal)).Normalize(); Vector3 val = Vector3.Cross(Vector3.up, normal); float width = Mathf.Abs(val.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(val.z) * ((Bounds)(ref bounds)).extents.z; bool flag2 = IsDoor(piece); if (flag2) { width = Mathf.Max(1f, width); } Vector3 center = (flag2 ? ((Component)piece).transform.position : ((Bounds)(ref bounds)).center); float halfDepth = Mathf.Abs(normal.x) * ((Bounds)(ref bounds)).extents.x + Mathf.Abs(normal.z) * ((Bounds)(ref bounds)).extents.z; if (flag2) { halfDepth = 0.08f; } else if (buildingKind == BuildingKind.Wall) { WallGeometry(piece, ref center, ref normal, ref width, ref halfDepth); } RoomWall roomWall = new RoomWall(new Vector2(center.x, center.z), new Vector2(normal.x, normal.z), width, CutawayMath.Opening(((Object)piece).name, flag2), halfDepth); Info info = new Info { Piece = piece, Kind = buildingKind, Bounds = bounds, Renderers = renderers.ToArray(), Wall = roomWall }; if (content) { contents.Add(info); } else { infos.Add(info); } infoByPiece[piece] = info; foreach (Renderer renderer2 in renderers) { rendererPieces[renderer2] = piece; } if (buildingKind == BuildingKind.Wall && CutawayMath.WallOnFloor(((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.y, ((Component)piece).transform.position.y, floor, roomWall.Opening)) { walls.Add(roomWall); } } FindBuilding(player); watchedPieces.Clear(); watchedPieces.AddRange(building); foreach (Info content2 in contents) { watchedPieces.Add(content2.Piece); } RoomTopology.Watch(((Component)player).transform.position, num + 2f, watchedPieces); ResolveFloor(player); } private void WallGeometry(Piece piece, ref Vector3 center, ref Vector3 normal, ref float width, ref float halfDepth) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) colliders.Clear(); ((Component)piece).GetComponentsInChildren(false, colliders); float num = 0f; Bounds bounds = default(Bounds); foreach (Collider collider in colliders) { if (!Object.op_Implicit((Object)(object)collider) || collider.isTrigger || (Object)(object)((Component)collider).GetComponentInParent() != (Object)(object)piece) { continue; } BoxCollider val = (BoxCollider)(object)((collider is BoxCollider) ? collider : null); if (val != null) { ((Bounds)(ref bounds))..ctor(val.center, val.size); } else { MeshCollider val2 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val2 == null || !Object.op_Implicit((Object)(object)val2.sharedMesh)) { continue; } bounds = val2.sharedMesh.bounds; } Vector3 val3 = ((Component)collider).transform.TransformVector(Vector3.right * ((Bounds)(ref bounds)).size.x); Vector3 val4 = ((Component)collider).transform.TransformVector(Vector3.forward * ((Bounds)(ref bounds)).size.z); float magnitude = ((Vector3)(ref val3)).magnitude; float magnitude2 = ((Vector3)(ref val4)).magnitude; if (Mathf.Min(magnitude, magnitude2) <= 0.001f || Mathf.Max(magnitude, magnitude2) < Mathf.Min(magnitude, magnitude2) * 1.5f) { continue; } float num2 = Mathf.Max(magnitude, magnitude2) * ((Bounds)(ref bounds)).size.y; if (!(num2 <= num)) { Vector3 val5 = ((magnitude < magnitude2) ? val3 : val4); val5.y = 0f; if (!(((Vector3)(ref val5)).sqrMagnitude < 0.0001f)) { num = num2; center = ((Component)collider).transform.TransformPoint(((Bounds)(ref bounds)).center); normal = ((Vector3)(ref val5)).normalized; width = Mathf.Max(magnitude, magnitude2) * 0.5f; halfDepth = Mathf.Min(magnitude, magnitude2) * 0.5f; } } } } private void ResolveFloor(Player player) { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_032e: 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_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) float floor = Level.Floor; float num = searchRadius; walls.Clear(); covers.Clear(); foreground.Clear(); foregroundSeen.Clear(); foreach (Info info in infos) { info.SupportPlanes = null; } foreach (Info info2 in infos) { if (Object.op_Implicit((Object)(object)info2.Piece) && info2.Kind == BuildingKind.Wall && CutawayMath.WallOnFloor(((Bounds)(ref info2.Bounds)).min.y, ((Bounds)(ref info2.Bounds)).max.y, ((Component)info2.Piece).transform.position.y, floor, info2.Wall.Opening)) { walls.Add(info2.Wall); } } ceiling = float.PositiveInfinity; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Component)player).transform.position.x, floor + 0.2f, ((Component)player).transform.position.z); for (int i = 0; i < 5; i++) { Vector3 val2 = (Vector3)((i == 0) ? Vector3.zero : new Vector3(i switch { 2 => -0.35f, 1 => 0.35f, _ => 0f, }, 0f, i switch { 4 => -0.35f, 3 => 0.35f, _ => 0f, })); RaycastHit[] array = Physics.RaycastAll(val + val2, Vector3.up, num, PieceMask, (QueryTriggerInteraction)1); for (int j = 0; j < array.Length; j++) { RaycastHit val3 = array[j]; Piece piece = (Object.op_Implicit((Object)(object)((RaycastHit)(ref val3)).collider) ? ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() : null); BuildingKind buildingKind = KindOf(piece); if ((buildingKind == BuildingKind.Floor || buildingKind == BuildingKind.Roof) && ((RaycastHit)(ref val3)).point.y > floor + 0.8f) { ceiling = Mathf.Min(ceiling, ((RaycastHit)(ref val3)).point.y); } } } Vector2 vector = new Vector2(((Component)player).transform.position.x, ((Component)player).transform.position.z); if (float.IsPositiveInfinity(ceiling)) { foreach (Info info3 in infos) { if ((info3.Kind == BuildingKind.Roof || info3.Kind == BuildingKind.Floor) && !(((Bounds)(ref info3.Bounds)).min.y <= floor + 0.8f) && new RoomCover(new Vector2(((Bounds)(ref info3.Bounds)).min.x, ((Bounds)(ref info3.Bounds)).min.z), new Vector2(((Bounds)(ref info3.Bounds)).max.x, ((Bounds)(ref info3.Bounds)).max.z)).Contains(vector)) { ceiling = Mathf.Min(ceiling, ((Bounds)(ref info3.Bounds)).min.y); } } } if (!float.IsPositiveInfinity(ceiling)) { foreach (Info info4 in infos) { if (info4.Kind == BuildingKind.Roof || info4.Kind == BuildingKind.Floor) { float num2 = ((info4.Kind == BuildingKind.Roof) ? 2.5f : 0.75f); if (!(((Bounds)(ref info4.Bounds)).max.y < ceiling - 0.2f) && !(((Bounds)(ref info4.Bounds)).min.y > ceiling + num2) && !(((Bounds)(ref info4.Bounds)).max.y <= floor + 0.8f)) { covers.Add(new RoomCover(new Vector2(((Bounds)(ref info4.Bounds)).min.x, ((Bounds)(ref info4.Bounds)).min.z), new Vector2(((Bounds)(ref info4.Bounds)).max.x, ((Bounds)(ref info4.Bounds)).max.z))); } } } } room = new RoomLayout(); room.Resolve(vector, num, walls, covers); Inside = (room.Enclosed || (BuildingMode && building.Count >= 3)) && (!float.IsPositiveInfinity(ceiling) || player.InShelter() || UnderRoof.Invoke(player)); if (float.IsPositiveInfinity(ceiling)) { ceiling = floor + 4f; } if (Inside) { residence.Commit(floor, BuildingMode ? buildingAnchor : room.Center); } Plugin.Instance?.LogVisibility(string.Format("Room discovery: {0}; walls={1}, ceiling={2:F2}, floor={3:F2}; windows and passages retain virtual boundaries.", Inside ? "inside" : "outside", walls.Count, ceiling, floor)); } private void FindBuilding(Player player) { //IL_0047: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00eb: 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_00f2: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) building.Clear(); buildingFloor.Clear(); List list = new List(); int seed = -1; float num = float.PositiveInfinity; Collider lastGroundCollider = ((Character)player).GetLastGroundCollider(); Piece val = (Object.op_Implicit((Object)(object)lastGroundCollider) ? ((Component)lastGroundCollider).GetComponentInParent() : null); Vector3 position = ((Component)player).transform.position; for (int i = 0; i < infos.Count; i++) { Info info = infos[i]; list.Add(new BuildingPart(new Vector3(((Bounds)(ref info.Bounds)).min.x, ((Bounds)(ref info.Bounds)).min.y, ((Bounds)(ref info.Bounds)).min.z), new Vector3(((Bounds)(ref info.Bounds)).max.x, ((Bounds)(ref info.Bounds)).max.y, ((Bounds)(ref info.Bounds)).max.z))); Vector3 val2 = ((Bounds)(ref info.Bounds)).ClosestPoint(position) - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if ((Object)(object)info.Piece == (Object)(object)val) { seed = i; num = -1f; } else if (num >= 0f && sqrMagnitude < num) { seed = i; num = sqrMagnitude; } } buildingMin = new Vector2(float.PositiveInfinity); buildingMax = new Vector2(float.NegativeInfinity); foreach (int item in BuildingLayout.Connected(list, seed)) { Info info2 = infos[item]; building.Add(info2.Piece); Vector2 vector = new Vector2(((Bounds)(ref info2.Bounds)).min.x, ((Bounds)(ref info2.Bounds)).min.z); Vector2 vector2 = new Vector2(((Bounds)(ref info2.Bounds)).max.x, ((Bounds)(ref info2.Bounds)).max.z); buildingMin = Vector2.Min(buildingMin, vector); buildingMax = Vector2.Max(buildingMax, vector2); if ((info2.Kind == BuildingKind.Floor && ((Bounds)(ref info2.Bounds)).min.y < Level.Floor + 0.75f && ((Bounds)(ref info2.Bounds)).max.y > Level.Floor - 0.75f) || info2.Kind == BuildingKind.Roof) { buildingFloor.Add(new RoomCover(vector, vector2)); } } buildingAnchor = ((building.Count > 0) ? ((buildingMin + buildingMax) / 2f) : new Vector2(position.x, position.z)); } internal bool Protects(Collider collider) { return ProtectsPiece(Object.op_Implicit((Object)(object)collider) ? ((Component)collider).GetComponentInParent() : null); } internal bool IsFloor(Piece piece) { return KindOf(piece) == BuildingKind.Floor; } internal bool ProtectsPiece(Piece piece) { if (!Object.op_Implicit((Object)(object)piece)) { return false; } if (hiddenContents.Contains(piece)) { return false; } BuildingKind buildingKind = KindOf(piece); return IsDoor(piece) || !CutawayMath.Structural(buildingKind) || buildingKind == BuildingKind.Stair || Protected.Contains(((Component)piece).transform) || walking.Contains(((Component)piece).transform); } internal bool IsHiddenContent(Piece piece) { return Object.op_Implicit((Object)(object)piece) && hiddenContents.Contains(piece); } internal static bool IsStoreyContent(Piece piece) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 return Object.op_Implicit((Object)(object)piece) && !Object.op_Implicit((Object)(object)((Component)piece).GetComponentInChildren(true)) && ((int)piece.m_category == 4 || (int)piece.m_category == 1 || piece.m_comfort > 0 || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponentInChildren(true))); } private bool IsDoor(Piece piece) { if (!Object.op_Implicit((Object)(object)piece)) { return false; } if (!doors.TryGetValue(piece, out var value)) { value = (doors[piece] = Object.op_Implicit((Object)(object)((Component)piece).GetComponentInChildren(true))); } return value; } private BuildingKind KindOf(Piece piece) { if (!Object.op_Implicit((Object)(object)piece)) { return BuildingKind.Other; } if (!kinds.TryGetValue(piece, out var value)) { value = (kinds[piece] = Classify(piece)); } return value; } internal Piece PieceOf(Renderer renderer) { if (!Object.op_Implicit((Object)(object)renderer)) { return null; } if (!rendererPieces.TryGetValue(renderer, out var value)) { value = (rendererPieces[renderer] = ((Component)renderer).GetComponentInParent()); } return value; } internal bool IsFrame(Renderer renderer) { Piece val = PieceOf(renderer); Info value; return KindOf(val) == BuildingKind.Frame || (Object.op_Implicit((Object)(object)val) && infoByPiece.TryGetValue(val, out value) && value.Wall.Opening == RoomOpening.Passage); } internal bool IsForeground(Renderer renderer) { return foreground.Contains(PieceOf(renderer)); } internal bool HasMask(Piece piece, HashSet cuts) { if (!Inside || !Object.op_Implicit((Object)(object)piece) || !infoByPiece.TryGetValue(piece, out var value)) { return false; } Renderer[] array = value.Renderers; foreach (Renderer val in array) { if (Object.op_Implicit((Object)(object)val) && (Hidden.Contains(val) || cuts.Contains(val))) { return true; } } return false; } internal bool HammerSurface(Piece piece, Ray ray, ref RaycastHit hit) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_009f: 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_0179: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) if (!selection.Current.TryGetValue(piece, out var value)) { return true; } if (value.View == PartView.Hidden) { return false; } if (value.View != PartView.Cut || ((RaycastHit)(ref hit)).point.y <= value.Height) { return true; } if (value.Sections != null) { SectionRun[] sections = value.Sections; for (int i = 0; i < sections.Length; i++) { SectionRun sectionRun = sections[i]; float num = (sectionRun.AlongX ? ((RaycastHit)(ref hit)).point.x : ((RaycastHit)(ref hit)).point.z); if (!sectionRun.Front && num >= sectionRun.From && num <= sectionRun.To) { return true; } } } if (((Ray)(ref ray)).direction.y >= 0f) { return false; } Collider collider = ((RaycastHit)(ref hit)).collider; if (!(collider is BoxCollider) && !(collider is SphereCollider) && !(collider is CapsuleCollider)) { MeshCollider val = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val == null || !val.convex) { return false; } } float num2 = (value.Height - ((Ray)(ref ray)).origin.y) / ((Ray)(ref ray)).direction.y; Vector3 point = ((Ray)(ref ray)).GetPoint(num2); if (!(num2 < ((RaycastHit)(ref hit)).distance)) { Vector3 val2 = collider.ClosestPoint(point) - point; if (!(((Vector3)(ref val2)).sqrMagnitude > 1E-06f)) { ((RaycastHit)(ref hit)).distance = num2; ((RaycastHit)(ref hit)).point = point; ((RaycastHit)(ref hit)).normal = Vector3.up; return true; } } return false; } internal static BuildingKind Classify(Piece piece) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)piece)) { return BuildingKind.Other; } bool furniture = (int)piece.m_category == 4 || (int)piece.m_category == 1 || piece.m_comfort > 0 || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponent()) || Object.op_Implicit((Object)(object)((Component)piece).GetComponentInChildren(true)); WearNTear component = ((Component)piece).GetComponent(); bool construction = (int)piece.m_category == 2 || (int)piece.m_category == 3 || (Object.op_Implicit((Object)(object)component) && component.m_supports); return CutawayMath.Kind(((Object)piece).name, Object.op_Implicit((Object)(object)((Component)piece).GetComponent()), furniture, construction); } internal void Dispose() { dungeon.Clear(); InDungeon = false; Level.Reset(); ClearSelection(); Generation++; walking.Clear(); pieces.Clear(); infos.Clear(); contents.Clear(); storeyFloors.Clear(); watchedPieces.Clear(); walls.Clear(); covers.Clear(); building.Clear(); buildingFloor.Clear(); sideWalls.Clear(); kinds.Clear(); doors.Clear(); rendererPieces.Clear(); infoByPiece.Clear(); foreground.Clear(); foregroundSeen.Clear(); Inside = false; int snapshotCount = (LocalChangeCount = 0); SnapshotCount = snapshotCount; revision = -1L; sector = float.NaN; searchRadius = 0f; nextProbe = 0f; nextForeground = 0f; roofEvidence = false; lastFrame = -1; RoomTopology.Stop(); } } internal sealed class RoomCutawayRenderer { private sealed class SharedGeometry { internal Mesh Mesh; internal int Users; } private sealed class Lower { internal Renderer Source; internal Mesh Mesh; internal MeshRenderer Renderer; internal GameObject Object; internal float Height; internal List Sections; internal Mesh NativeMesh; internal Matrix4x4 Basis; internal Piece Piece; internal DungeonSlice? Dungeon; internal int MaterialCount; internal string GeometryKey; internal LODGroup Group; } internal readonly HashSet CutSources = new HashSet(); private readonly Dictionary> cache = new Dictionary>(); private readonly Dictionary geometry = new Dictionary(); private readonly List active = new List(); private readonly List<(Renderer Source, float Height, List Sections)> pending = new List<(Renderer, float, List)>(); private int nextPending; private readonly List ordered = new List(); private readonly HashSet<(Renderer, int, int)> failed = new HashSet<(Renderer, int, int)>(); private readonly MaterialPropertyBlock block = new MaterialPropertyBlock(); private readonly Dictionary selectedLods = new Dictionary(); private int version = -1; private int generation = -1; internal void Prepare(RoomCutawayController room) { //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: 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_02ec: Unknown result type (might be due to invalid IL or missing references) if (generation != room.Generation) { failed.Clear(); generation = room.Generation; List list = new List(); foreach (KeyValuePair> item in cache) { if (!Object.op_Implicit((Object)(object)item.Key) || (item.Value.Count > 0 && item.Value[0].Dungeon.HasValue && !room.Cuts.ContainsKey(item.Key))) { list.Add(item.Key); } } foreach (Renderer item2 in list) { foreach (Lower item3 in cache[item2]) { Release(item3); } cache.Remove(item2); } } if (version != room.Version) { SetVisible(visible: false, null, room); version = room.Version; CutSources.Clear(); active.Clear(); pending.Clear(); nextPending = 0; ordered.Clear(); ordered.AddRange(room.Cuts.Keys); ordered.Sort((Renderer a, Renderer b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID())); foreach (Renderer item4 in ordered) { if (!Object.op_Implicit((Object)(object)item4)) { continue; } room.Sections.TryGetValue(item4, out var value); float num = room.Cuts[item4]; MeshFilter component = ((Component)item4).GetComponent(); Mesh val = ((component != null) ? component.sharedMesh : null); Lower lower = null; if (cache.TryGetValue(item4, out var value2)) { foreach (Lower item5 in value2) { if ((Object)(object)item5.NativeMesh == (Object)(object)val && Mathf.Abs(item5.Height - num) < 0.01f && SameSections(item5.Sections, value) && Nullable.Equals(item5.Dungeon, room.DungeonSection) && SameMatrix(item5.Basis, item4.localToWorldMatrix)) { lower = item5; break; } } } if (lower != null) { Activate(lower); } else { pending.Add((item4, num, value)); } } Dictionary priority = new Dictionary(); foreach (var item6 in pending) { Dictionary dictionary = priority; var (key, _, _) = item6; float value3; if (!room.IsForeground(item6.Source)) { Bounds bounds = item6.Source.bounds; Vector3 val2 = ((Bounds)(ref bounds)).ClosestPoint(room.Focus) - room.Focus; value3 = ((Vector3)(ref val2)).sqrMagnitude; } else { value3 = -1f; } dictionary[key] = value3; } pending.Sort(delegate((Renderer Source, float Height, List Sections) a, (Renderer Source, float Height, List Sections) b) { int num3 = priority[a.Source].CompareTo(priority[b.Source]); return (num3 != 0) ? num3 : ((Object)a.Source).GetInstanceID().CompareTo(((Object)b.Source).GetInstanceID()); }); } if (nextPending >= pending.Count) { return; } Stopwatch stopwatch = Stopwatch.StartNew(); int num2 = 0; while (nextPending < pending.Count && num2 < 3 && (num2 == 0 || stopwatch.Elapsed.TotalMilliseconds < 2.0)) { (Renderer, float, List) tuple2 = pending[nextPending++]; num2++; if (!Object.op_Implicit((Object)(object)tuple2.Item1)) { continue; } Lower lower2 = Build(tuple2.Item1, tuple2.Item2, tuple2.Item3, room.IsFrame(tuple2.Item1), room.DungeonSection); if (lower2 != null) { if (!cache.TryGetValue(tuple2.Item1, out var value4)) { value4 = (cache[tuple2.Item1] = new List()); } if (value4.Count >= 8) { Release(value4[0]); value4.RemoveAt(0); } value4.Add(lower2); Activate(lower2); } } } private void Activate(Lower entry) { active.Add(entry); CutSources.Add(entry.Source); } private static bool SameMatrix(Matrix4x4 a, Matrix4x4 b) { for (int i = 0; i < 16; i++) { if (Mathf.Abs(((Matrix4x4)(ref a))[i] - ((Matrix4x4)(ref b))[i]) > 0.0001f) { return false; } } return true; } private static bool SameSections(List a, List b) { if (a == null || b == null) { return a == b; } if (a.Count != b.Count) { return false; } for (int i = 0; i < a.Count; i++) { if (a[i].From != b[i].From || a[i].To != b[i].To || a[i].Front != b[i].Front || a[i].AlongX != b[i].AlongX) { return false; } } return true; } private Lower Build(Renderer source, float height, List sections, bool frame, DungeonSlice? dungeon) { //IL_0017: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: 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) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0292: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02be: 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_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: 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_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_023a: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) MeshFilter component = ((Component)source).GetComponent(); Mesh val = ((component != null) ? component.sharedMesh : null); Mesh nativeMesh = val; Matrix4x4 localToWorldMatrix = source.localToWorldMatrix; Matrix4x4 val2 = source.localToWorldMatrix; int num = 0; if (sections != null) { foreach (SectionRun section in sections) { num = (num * 397) ^ section.From.GetHashCode() ^ section.To.GetHashCode() ^ (section.Front ? 1 : 0); } } if (dungeon.HasValue) { num = (num * 397) ^ dungeon.Value.GetHashCode(); } (Renderer, int, int) item = (source, Mathf.RoundToInt(height * 1000f), num); bool flag = false; if (source.isPartOfStaticBatch) { Piece componentInParent = ((Component)source).GetComponentInParent(); GameObject val3 = ((Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)ZNetScene.instance)) ? ZNetScene.instance.GetPrefab(Utils.GetPrefabName(((Component)componentInParent).gameObject)) : null); if (Object.op_Implicit((Object)(object)val3)) { List list = new List(); Transform val4 = ((Component)source).transform; while (Object.op_Implicit((Object)(object)val4) && (Object)(object)val4 != (Object)(object)((Component)componentInParent).transform) { list.Add(((Object)val4).name); val4 = val4.parent; } list.Reverse(); Transform val5 = ((list.Count == 0) ? val3.transform : val3.transform.Find(string.Join("/", list))); object obj; if (!Object.op_Implicit((Object)(object)val5)) { obj = null; } else { MeshFilter component2 = ((Component)val5).GetComponent(); obj = ((component2 != null) ? component2.sharedMesh : null); } Mesh val6 = (Mesh)obj; if (Object.op_Implicit((Object)(object)val6)) { Bounds bounds = val6.bounds; Bounds val7 = default(Bounds); bool flag2 = true; Matrix4x4 localToWorldMatrix2 = ((Component)source).transform.localToWorldMatrix; for (int i = 0; i < 8; i++) { Vector3 val8 = ((Matrix4x4)(ref localToWorldMatrix2)).MultiplyPoint3x4(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))))); if (flag2) { ((Bounds)(ref val7))..ctor(val8, Vector3.zero); flag2 = false; } else { ((Bounds)(ref val7)).Encapsulate(val8); } } Bounds bounds2 = source.bounds; Vector3 val9 = ((Bounds)(ref bounds2)).size; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val9)).magnitude * 0.03f); Vector3 min = ((Bounds)(ref val7)).min; bounds2 = source.bounds; val9 = min - ((Bounds)(ref bounds2)).min; if (((Vector3)(ref val9)).magnitude <= num2) { Vector3 max = ((Bounds)(ref val7)).max; bounds2 = source.bounds; val9 = max - ((Bounds)(ref bounds2)).max; if (((Vector3)(ref val9)).magnitude <= num2) { val = val6; val2 = localToWorldMatrix2; flag = true; } } } } } if (!Object.op_Implicit((Object)(object)val) || failed.Contains(item)) { return null; } GameObject val10 = null; Mesh val11 = null; string text = null; bool flag3 = false; try { Vector4 plane = default(Vector4); ((Vector4)(ref plane))..ctor(val2.m10, val2.m11, val2.m12, val2.m13 - height); text = Key(val, (dungeon.HasValue || (source.isPartOfStaticBatch && !flag)) ? ((Object)source).GetInstanceID() : 0, plane, val2, sections, frame, dungeon); flag3 = geometry.TryGetValue(text, out var value); if (flag3) { val11 = value.Mesh; } else { MeshChannels input = (flag ? MeshChannels.Read(val) : MeshChannels.ForRenderer(val, source)); val11 = (dungeon.HasValue ? CutMeshBuilder.BuildDungeon(input, val2, height, dungeon.Value) : ((sections == null) ? CutMeshBuilder.Build(input, plane, below: true, attributes: true, frame) : CutMeshBuilder.BuildSections(input, val2, height, sections, frame))); } val10 = new GameObject("Isometric cached room wall") { hideFlags = (HideFlags)61, layer = ((Component)source).gameObject.layer }; val10.AddComponent(); if (flag || !source.isPartOfStaticBatch) { val10.transform.SetParent(((Component)source).transform, false); val10.transform.localPosition = Vector3.zero; val10.transform.localRotation = Quaternion.identity; val10.transform.localScale = Vector3.one; } else { val10.transform.SetPositionAndRotation(Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3)), ((Matrix4x4)(ref val2)).rotation); val10.transform.localScale = ((Matrix4x4)(ref val2)).lossyScale; Matrix4x4 localToWorldMatrix3 = val10.transform.localToWorldMatrix; for (int j = 0; j < 16; j++) { if (Mathf.Abs(((Matrix4x4)(ref localToWorldMatrix3))[j] - ((Matrix4x4)(ref val2))[j]) > 0.001f) { throw new NotSupportedException("Static batch transform is not representable by a native renderer."); } } } val10.AddComponent().sharedMesh = val11; MeshRenderer val12 = val10.AddComponent(); ((Renderer)val12).enabled = false; ((Renderer)val12).sharedMaterials = source.sharedMaterials; ((Renderer)val12).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val12).receiveShadows = source.receiveShadows; ((Renderer)val12).lightProbeUsage = source.lightProbeUsage; ((Renderer)val12).reflectionProbeUsage = source.reflectionProbeUsage; ((Renderer)val12).probeAnchor = (Object.op_Implicit((Object)(object)source.probeAnchor) ? source.probeAnchor : ((Component)source).transform); ((Renderer)val12).lightmapIndex = source.lightmapIndex; ((Renderer)val12).lightmapScaleOffset = source.lightmapScaleOffset; if (flag3) { value.Users++; } else { geometry.Add(text, new SharedGeometry { Mesh = val11, Users = 1 }); } return new Lower { Source = source, Mesh = val11, Renderer = val12, Object = val10, Height = height, Sections = ((sections == null) ? null : new List(sections)), NativeMesh = nativeMesh, Basis = localToWorldMatrix, Piece = ((Component)source).GetComponentInParent(), Dungeon = dungeon, MaterialCount = source.sharedMaterials.Length, GeometryKey = text, Group = ((Component)source).GetComponentInParent() }; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val10)) { Object.Destroy((Object)(object)val10); } if (Object.op_Implicit((Object)(object)val11) && !flag3) { Object.Destroy((Object)(object)val11); } failed.Add(item); Plugin instance = Plugin.Instance; if (instance != null) { string[] obj2 = new string[6] { "Cached room section remains native: ", null, null, null, null, null }; Piece componentInParent2 = ((Component)source).GetComponentInParent(); obj2[1] = ((componentInParent2 != null) ? ((Object)componentInParent2).name : null); obj2[2] = "/"; obj2[3] = ((Object)val).name; obj2[4] = ": "; obj2[5] = ex.Message; instance.Warn(string.Concat(obj2)); } return null; } } private static string Key(Mesh mesh, int isolated, Vector4 plane, Matrix4x4 matrix, List sections, bool frame, DungeonSlice? dungeon) { //IL_003b: 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_01df: Unknown result type (might be due to invalid IL or missing references) StringBuilder key = new StringBuilder(); key.Append(((Object)mesh).GetInstanceID()).Append('/').Append(isolated) .Append('/') .Append(frame); Add(plane); if (dungeon.HasValue) { DungeonSlice value = dungeon.Value; key.Append("/dungeon/").Append(value.HideRoof); key.Append('/').Append(value.Interior.X).Append('/') .Append(value.Interior.Y) .Append('/') .Append(value.Floor); key.Append('/').Append(value.TowardCamera.X).Append('/') .Append(value.TowardCamera.Y); for (int i = 0; i < 16; i++) { key.Append('/').Append(((Matrix4x4)(ref matrix))[i]); } } if (sections != null) { foreach (SectionRun section in sections) { int num = ((!section.AlongX) ? 2 : 0); key.Append('/').Append(section.Front); Add(new Vector4(((Matrix4x4)(ref matrix))[num, 0], ((Matrix4x4)(ref matrix))[num, 1], ((Matrix4x4)(ref matrix))[num, 2], ((Matrix4x4)(ref matrix))[num, 3] - section.From)); Add(new Vector4(((Matrix4x4)(ref matrix))[num, 0], ((Matrix4x4)(ref matrix))[num, 1], ((Matrix4x4)(ref matrix))[num, 2], ((Matrix4x4)(ref matrix))[num, 3] - section.To)); } } return key.ToString(); void Add(Vector4 val2) { //IL_0001: 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_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) Vector3 val = new Vector3(val2.x, val2.y, val2.z); float magnitude = ((Vector3)(ref val)).magnitude; for (int j = 0; j < 4; j++) { key.Append('/').Append(Mathf.RoundToInt(((Vector4)(ref val2))[j] / magnitude * 10000f)); } } } private void Release(Lower entry) { if (Object.op_Implicit((Object)(object)entry.Object)) { Object.Destroy((Object)(object)entry.Object); } if (entry.GeometryKey != null && geometry.TryGetValue(entry.GeometryKey, out var value) && --value.Users <= 0) { if (Object.op_Implicit((Object)(object)value.Mesh)) { Object.Destroy((Object)(object)value.Mesh); } geometry.Remove(entry.GeometryKey); } } internal void SetVisible(bool visible, Camera camera, RoomCutawayController room) { if (visible) { selectedLods.Clear(); } foreach (Lower item in active) { Renderer source = item.Source; bool flag = visible && Object.op_Implicit((Object)(object)source) && Object.op_Implicit((Object)(object)item.Renderer) && CutSources.Contains(source) && source.enabled && ((Component)source).gameObject.activeInHierarchy && !source.forceRenderingOff && !room.ProtectsPiece(item.Piece) && SelectedLod(item, camera); if (!Object.op_Implicit((Object)(object)item.Renderer)) { continue; } ((Renderer)item.Renderer).enabled = flag; if (!flag) { continue; } for (int i = 0; i < item.MaterialCount; i++) { block.Clear(); source.GetPropertyBlock(block, i); if (block.isEmpty) { source.GetPropertyBlock(block); } ((Renderer)item.Renderer).SetPropertyBlock(block, i); } } } private bool SelectedLod(Lower entry, Camera camera) { //IL_0050: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) LODGroup val = entry.Group; if (!Object.op_Implicit((Object)(object)val) || !val.enabled) { return true; } if (!selectedLods.TryGetValue(val, out (LOD[], int) value)) { LOD[] lODs = val.GetLODs(); Vector3 lossyScale = ((Component)val).transform.lossyScale; float num = val.size * Mathf.Max(new float[3] { Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z) }); float num2 = Vector3.Distance(((Component)val).transform.TransformPoint(val.localReferencePoint), ((Component)camera).transform.position); float num3 = num * QualitySettings.lodBias / Mathf.Max(0.01f, 2f * num2 * Mathf.Tan(camera.fieldOfView * (MathF.PI / 180f) / 2f)); int item = lODs.Length; for (int i = Mathf.Min(QualitySettings.maximumLODLevel, lODs.Length); i < lODs.Length; i++) { if (num3 >= lODs[i].screenRelativeTransitionHeight) { item = i; break; } } value = (selectedLods[val] = (lODs, item)); } for (int j = 0; j < value.Item1.Length; j++) { Renderer[] renderers = value.Item1[j].renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)(object)entry.Source) { return j == value.Item2; } } } return true; } internal void Dispose() { foreach (List value in cache.Values) { foreach (Lower item in value) { Release(item); } } cache.Clear(); geometry.Clear(); selectedLods.Clear(); active.Clear(); pending.Clear(); nextPending = 0; CutSources.Clear(); ordered.Clear(); failed.Clear(); version = -1; generation = -1; } } internal static class RoomTopology { private static Vector3 center; private static float radius; private static readonly HashSet watched = new HashSet(); internal static long Revision { get; private set; } internal static float LastChange { get; private set; } internal static void Watch(Vector3 position, float range, IEnumerable pieces) { //IL_0001: 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) center = position; radius = range; watched.Clear(); foreach (Piece piece in pieces) { if (Object.op_Implicit((Object)(object)piece)) { watched.Add(((Object)piece).GetInstanceID()); } } } internal static void Stop() { radius = 0f; watched.Clear(); } internal static void Install(Harmony harmony) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(Piece), "OnPlaced", Type.EmptyTypes, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RoomTopology), "Placed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Piece), "OnDestroy", Type.EmptyTypes, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(RoomTopology), "Removed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Placed(Piece __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) if (radius <= 0f || !Object.op_Implicit((Object)(object)__instance) || ((Component)__instance).gameObject.layer == LayerMask.NameToLayer("ghost")) { return; } Vector3 val = ((Component)__instance).transform.position - center; if (!(((Vector3)(ref val)).sqrMagnitude > radius * radius)) { ZNetView component = ((Component)__instance).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.IsValid() && (CutawayMath.Structural(RoomCutawayController.Classify(__instance)) || RoomCutawayController.IsStoreyContent(__instance))) { Revision++; LastChange = Time.unscaledTime; } } } private static void Removed(Piece __instance) { if (!(radius <= 0f) && Object.op_Implicit((Object)(object)__instance) && watched.Remove(((Object)__instance).GetInstanceID())) { Revision++; LastChange = Time.unscaledTime; } } } internal static class ScreenCoordinates { internal static Vector2 PointerViewport { get { //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_0007: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Vector3 pointerPosition = ZInput.pointerPosition; Vector2 vector = ScreenSpaceMath.Viewport(new Vector2(pointerPosition.x, pointerPosition.y), Screen.width, Screen.height); return new Vector2(vector.X, vector.Y); } } internal static Ray PointerRay(Camera camera) { //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) return PointerRayAt(camera, ZInput.pointerPosition); } internal static Ray PointerRayAt(Camera camera, Vector3 pointer) { //IL_0001: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Vector2 vector = ScreenSpaceMath.Viewport(new Vector2(pointer.x, pointer.y), Screen.width, Screen.height); return camera.ViewportPointToRay(Vector2.op_Implicit(new Vector2(vector.X, vector.Y))); } internal static bool PlaceAbove(RectTransform widget, Camera camera, Vector3 world, bool show = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //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_0009: 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_0034: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = camera.WorldToViewportPoint(world); bool flag = ScreenSpaceMath.InViewport(CameraRelativeMovement.ToNumerics(val)); ((Component)widget).gameObject.SetActive(flag && show); if (flag) { Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x, val.y); widget.anchorMax = val2; widget.anchorMin = val2; widget.anchoredPosition = Vector2.zero; } return flag; } } internal sealed class SelectedHudMirror { private readonly Dictionary nodes = new Dictionary(); private readonly HashSet current = new HashSet(); private readonly List expired = new List(); private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4]; private RectTransform host; private RectTransform source; private Canvas canvas; private Camera camera; private Character target; internal void Show(GameObject bar, RectTransform parent, Character character, Camera renderCamera) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) //IL_00f9: Expected O, but got Unknown target = character; camera = renderCamera; source = (RectTransform)(Object.op_Implicit((Object)(object)bar) ? /*isinst with value type is only supported in some contexts*/: null); if (!Object.op_Implicit((Object)(object)source)) { if (Object.op_Implicit((Object)(object)host)) { ((Component)host).gameObject.SetActive(false); } return; } if (!Object.op_Implicit((Object)(object)host)) { host = new GameObject("SelectedHudMirror", new Type[1] { typeof(RectTransform) }).GetComponent(); ((Transform)host).SetParent((Transform)(object)parent, false); RectTransform obj = host; RectTransform obj2 = host; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 1f); obj2.anchorMax = val; obj.anchorMin = val; canvas = ((Component)parent).GetComponentInParent(); Canvas.willRenderCanvases += new WillRenderCanvases(Render); } ((Component)host).gameObject.SetActive(true); } private void Render() { //IL_0084: 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) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_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) if (!Object.op_Implicit((Object)(object)host) || !Object.op_Implicit((Object)(object)source) || !((Component)source).gameObject.activeInHierarchy || Hud.IsUserHidden() || !TargetPicker.OnScreen(target, camera)) { if (Object.op_Implicit((Object)(object)host)) { ((Component)host).gameObject.SetActive(false); } return; } host.pivot = source.pivot; RectTransform obj = host; Rect rect = source.rect; obj.sizeDelta = ((Rect)(ref rect)).size; Vector3 lossyScale = ((Transform)source).lossyScale; Vector3 lossyScale2 = ((Transform)host).parent.lossyScale; ((Transform)host).localScale = new Vector3(2f * lossyScale.x / Mathf.Max(0.001f, lossyScale2.x), 2f * lossyScale.y / Mathf.Max(0.001f, lossyScale2.y), 1f); RectTransform obj2 = host; rect = source.rect; float num = (0f - ((Rect)(ref rect)).center.x) * ((Transform)host).localScale.x; float num2 = 0f - PresentationTokens.Current.targetTopOffset; rect = source.rect; obj2.anchoredPosition = new Vector2(num, num2 - ((Rect)(ref rect)).yMax * ((Transform)host).localScale.y); Canvas componentInParent = ((Component)source).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent)) { Canvas obj3 = canvas; obj3.additionalShaderChannels |= componentInParent.additionalShaderChannels; } current.Clear(); RenderNode((Transform)(object)source, host, 0); expired.Clear(); foreach (KeyValuePair node in nodes) { if (!current.Contains(node.Key)) { expired.Add(node.Key); } } foreach (Transform item in expired) { RectTransform val = nodes[item]; if (Object.op_Implicit((Object)(object)val)) { ((Component)val).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)val).gameObject); } nodes.Remove(item); } } private void RenderNode(Transform original, RectTransform parent, int order) { //IL_004b: 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_00a9: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) current.Add(original); if (!nodes.TryGetValue(original, out var value)) { value = new GameObject("HudVisual", new Type[2] { typeof(RectTransform), typeof(CanvasRenderer) }).GetComponent(); ((Transform)value).SetParent((Transform)(object)parent, false); nodes.Add(original, value); } if (((Transform)value).GetSiblingIndex() != order) { ((Transform)value).SetSiblingIndex(order); } RectTransform val = (RectTransform)(object)((original is RectTransform) ? original : null); if (val != null) { value.pivot = val.pivot; RectTransform obj = value; Rect rect = val.rect; obj.sizeDelta = ((Rect)(ref rect)).size; } ((Transform)value).localPosition = (((Object)(object)original == (Object)(object)source) ? Vector3.zero : original.localPosition); ((Transform)value).localRotation = (((Object)(object)original == (Object)(object)source) ? Quaternion.identity : original.localRotation); ((Transform)value).localScale = (((Object)(object)original == (Object)(object)source) ? Vector3.one : original.localScale); ((Component)value).gameObject.SetActive(((Component)original).gameObject.activeSelf); if (!((Component)original).gameObject.activeSelf) { return; } TextMeshProUGUI component = ((Component)original).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { CopyText(component, value); } else { CopyRenderer(((Component)original).GetComponent(), ((Component)value).GetComponent()); } int num = 0; for (int i = 0; i < original.childCount; i++) { Transform child = original.GetChild(i); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)((Component)child).GetComponent())) { RenderNode(child, value, num++); } } } private void CopyText(TextMeshProUGUI original, RectTransform node) { //IL_0081: 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_009b: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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) TextMeshProUGUI val = ((Component)node).GetComponent(); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)node).gameObject.AddComponent(); } ((Graphic)val).raycastTarget = false; ((Behaviour)val).enabled = ((Behaviour)original).isActiveAndEnabled; if (((Behaviour)val).enabled && Object.op_Implicit((Object)(object)((TMP_Text)original).font)) { ((TMP_Text)val).font = ((TMP_Text)original).font; ((TMP_Text)val).fontSharedMaterial = ((TMP_Text)original).fontSharedMaterial; ((TMP_Text)val).fontSize = ((TMP_Text)original).fontSize; ((TMP_Text)val).fontStyle = ((TMP_Text)original).fontStyle; ((TMP_Text)val).alignment = ((TMP_Text)original).alignment; ((TMP_Text)val).margin = ((TMP_Text)original).margin; ((TMP_Text)val).overflowMode = ((TMP_Text)original).overflowMode; ((TMP_Text)val).richText = ((TMP_Text)original).richText; Color color = ((Graphic)original).color; color.a *= original.canvasRenderer.GetInheritedAlpha(); ((Graphic)val).color = color; ((TMP_Text)val).text = ((TMP_Text)original).text; ApplyClip(original.canvasRenderer, val.canvasRenderer); } } private void CopyRenderer(CanvasRenderer original, CanvasRenderer copy) { //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_00f8: Unknown result type (might be due to invalid IL or missing references) Mesh val = ((Object.op_Implicit((Object)(object)original) && !original.cull && original.materialCount > 0) ? original.GetMesh() : null); if (!Object.op_Implicit((Object)(object)val) || val.vertexCount == 0) { copy.Clear(); copy.hasPopInstruction = false; return; } copy.SetMesh(val); copy.materialCount = original.materialCount; for (int i = 0; i < original.materialCount; i++) { copy.SetMaterial(original.GetMaterial(i), i); } Graphic component = ((Component)original).GetComponent(); copy.SetTexture(Object.op_Implicit((Object)(object)component) ? component.mainTexture : null); Image val2 = (Image)(object)((component is Image) ? component : null); copy.SetAlphaTexture((Texture)(object)((val2 != null && Object.op_Implicit((Object)(object)val2.overrideSprite)) ? val2.overrideSprite.associatedAlphaSplitTexture : null)); Color color = original.GetColor(); color.a *= original.GetInheritedAlpha(); copy.SetColor(color); copy.hasPopInstruction = original.hasPopInstruction; copy.popMaterialCount = original.popMaterialCount; for (int j = 0; j < original.popMaterialCount; j++) { copy.SetPopMaterial(original.GetPopMaterial(j), j); } ApplyClip(original, copy); } private void ApplyClip(CanvasRenderer original, CanvasRenderer copy) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_011b: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_00ec: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_010a: Unknown result type (might be due to invalid IL or missing references) copy.DisableRectClipping(); if (!original.hasRectClipping) { return; } Rect val = default(Rect); bool flag = false; Transform parent = ((Component)original).transform.parent; while (Object.op_Implicit((Object)(object)parent)) { RectMask2D component = ((Component)parent).GetComponent(); if (Object.op_Implicit((Object)(object)component) && ((Behaviour)component).isActiveAndEnabled) { component.rectTransform.GetWorldCorners(corners); Vector2 val2 = Vector2.op_Implicit(((Component)canvas).transform.InverseTransformPoint(((Transform)host).TransformPoint(((Transform)source).InverseTransformPoint(corners[0])))); Vector2 val3 = Vector2.op_Implicit(((Component)canvas).transform.InverseTransformPoint(((Transform)host).TransformPoint(((Transform)source).InverseTransformPoint(corners[2])))); if (flag) { val2 = Vector2.Max(val2, ((Rect)(ref val)).min); val3 = Vector2.Min(val3, ((Rect)(ref val)).max); } val = Rect.MinMaxRect(val2.x, val2.y, Mathf.Max(val2.x, val3.x), Mathf.Max(val2.y, val3.y)); flag = true; } parent = parent.parent; } if (flag) { copy.EnableRectClipping(val); copy.clippingSoftness = original.clippingSoftness; } } internal void Dispose() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Canvas.willRenderCanvases -= new WillRenderCanvases(Render); if (Object.op_Implicit((Object)(object)host)) { ((Component)host).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)host).gameObject); } host = null; source = null; canvas = null; camera = null; target = null; nodes.Clear(); current.Clear(); expired.Clear(); } } internal sealed class StealthIndicatorPosition { private readonly Dictionary positions = new Dictionary(); private readonly List icons = new List(); private Hud owner; internal void Update(Hud hud, RectTransform health) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner != (Object)(object)hud) { Restore(); owner = hud; } icons.Clear(); Add(hud.m_targetedAlert); Add(hud.m_targeted); Add(hud.m_hidden); RectTransform val = (RectTransform)(Object.op_Implicit((Object)(object)hud.m_stealthBar) ? /*isinst with value type is only supported in some contexts*/: null); float num = Mathf.Max(0.001f, ((Transform)health).lossyScale.y); float num2 = 0f; Rect rect; foreach (RectTransform icon in icons) { float num3 = num2; rect = icon.rect; num2 = Mathf.Max(num3, ((Rect)(ref rect)).height * ((Transform)icon).lossyScale.y / num); } float num4; if (!Object.op_Implicit((Object)(object)val)) { num4 = 0f; } else { rect = val.rect; num4 = ((Rect)(ref rect)).height * ((Transform)val).lossyScale.y / num; } float barHeight = num4; rect = health.rect; Vector2 vector = ScreenSpaceMath.StealthOffsets(((Rect)(ref rect)).height, PresentationTokens.Current.stealthGap, barHeight, num2); if (Object.op_Implicit((Object)(object)val)) { Place(val, health, vector.X); } foreach (RectTransform icon2 in icons) { Place(icon2, health, vector.Y); } } private void Add(GameObject node) { RectTransform val = (RectTransform)(Object.op_Implicit((Object)(object)node) ? /*isinst with value type is only supported in some contexts*/: null); if (Object.op_Implicit((Object)(object)val)) { icons.Add(val); } } private void Place(RectTransform rect, RectTransform health, float height) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_001c: Unknown result type (might be due to invalid IL or missing references) if (!positions.ContainsKey(rect)) { positions.Add(rect, rect.anchoredPosition3D); } Rect rect2 = rect.rect; Vector3 val = ((Transform)rect).TransformVector(Vector2.op_Implicit(((Rect)(ref rect2)).center)); ((Transform)rect).position = ((Transform)health).TransformPoint(new Vector3(0f, height, 0f)) - val; } internal void Restore() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair position in positions) { if (Object.op_Implicit((Object)(object)position.Key)) { position.Key.anchoredPosition3D = position.Value; } } positions.Clear(); icons.Clear(); owner = null; } } internal sealed class SurfaceRing { private const int Segments = 40; private static readonly int GroundMask = LayerMask.GetMask(new string[6] { "terrain", "piece", "Default", "static_solid", "Default_small", "vehicle" }); private readonly Vector3[] points = (Vector3[])(object)new Vector3[41]; private LineRenderer line; private Material material; private Vector3 sampledPosition; private float nextSample; private readonly bool playerRing; internal SurfaceRing(bool playerRing = false) { this.playerRing = playerRing; } internal void Update(Character character) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_00e4: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_01e6: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)line)) { Shader val = Shader.Find("Hidden/Internal-Colored"); if (!Object.op_Implicit((Object)(object)val)) { return; } material = MakeMaterial(val); line = new GameObject("Isometric hostile surface ring", new Type[1] { typeof(FadeProxyMarker) }).AddComponent(); ((Component)line).gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); ((Renderer)line).sharedMaterial = material; line.useWorldSpace = true; line.positionCount = 41; LineRenderer obj = line; float startWidth = (line.endWidth = PresentationTokens.Current.ringWidth); obj.startWidth = startWidth; LineRenderer obj2 = line; Color startColor = (line.endColor = Color.white); obj2.startColor = startColor; ((Renderer)line).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)line).receiveShadows = false; } Vector3 position = ((Component)character).transform.position; ((Renderer)line).enabled = true; if (!(Time.unscaledTime >= nextSample)) { Vector3 val2 = position - sampledPosition; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.01f)) { return; } } float num = Mathf.Max(0.4f, character.GetRadius()) + PresentationTokens.Current.ringOffset; RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 40; i++) { float num2 = (float)i * MathF.PI * 2f / 40f; Vector3 val3 = position + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * num; points[i] = (Physics.Raycast(val3 + Vector3.up * 1.5f, Vector3.down, ref val4, 5f, GroundMask, (QueryTriggerInteraction)1) ? (((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * PresentationTokens.Current.ringOffset) : (val3 + Vector3.up * PresentationTokens.Current.ringOffset)); } points[40] = points[0]; line.SetPositions(points); sampledPosition = position; nextSample = Time.unscaledTime + 0.1f; } private Material MakeMaterial(Shader shader) { //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_0011: Expected O, but got Unknown //IL_0030: 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) Material val = new Material(shader) { hideFlags = (HideFlags)61 }; val.SetColor("_Color", playerRing ? PresentationTokens.Current.playerRingColor : PresentationTokens.Current.threatColor); val.SetInt("_SrcBlend", 5); val.SetInt("_DstBlend", 10); val.SetInt("_Cull", 0); val.SetInt("_ZWrite", 0); val.SetInt("_ZTest", 4); return val; } internal void Hide() { if (Object.op_Implicit((Object)(object)line)) { ((Renderer)line).enabled = false; } } internal void Dispose() { if (Object.op_Implicit((Object)(object)line)) { Object.Destroy((Object)(object)((Component)line).gameObject); } if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } line = null; material = null; } } internal static class TargetPicker { private const float SelectRange = 18f; private const float RetainRange = 22f; private static readonly int Mask = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "terrain", "character", "character_net", "character_ghost", "hitbox", "vehicle", "viewblock" }); private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[128]; internal static Character Pick(IsometricCameraController controller, Player player, Vector3 pointer) { //IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) Ray val = ScreenCoordinates.PointerRayAt(controller.Camera, pointer); int num = Physics.RaycastNonAlloc(val, Hits, 1000f, Mask, (QueryTriggerInteraction)2); RaycastHit[] array = Hits; if (num == Hits.Length) { array = Physics.RaycastAll(val, 1000f, Mask, (QueryTriggerInteraction)2); num = array.Length; } float num2 = float.PositiveInfinity; int num3 = int.MaxValue; Character val2 = null; for (int i = 0; i < num; i++) { RaycastHit hit = array[i]; if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider) || CursorOcclusion.Ignore(hit, controller.Camera, player)) { continue; } Character componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)(object)player) && (Object.op_Implicit((Object)(object)componentInParent) || (!((RaycastHit)(ref hit)).collider.isTrigger && !controller.IsHiddenObstacle(((RaycastHit)(ref hit)).collider)))) { int instanceID = ((Object)((RaycastHit)(ref hit)).collider).GetInstanceID(); if (!(((RaycastHit)(ref hit)).distance > num2) && (((RaycastHit)(ref hit)).distance != num2 || instanceID < num3)) { num2 = ((RaycastHit)(ref hit)).distance; num3 = instanceID; val2 = ((Object.op_Implicit((Object)(object)componentInParent) && !componentInParent.IsPlayer() && !componentInParent.IsDead() && BaseAI.IsEnemy((Character)(object)player, componentInParent)) ? componentInParent : null); } } } return InRange(val2, player, 18f) ? val2 : null; } internal static bool OnScreen(Character target, Camera camera) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) return Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)camera) && ((Behaviour)target).isActiveAndEnabled && !target.m_hideHud && !target.IsDead() && target.GetHealth() > 0f && ScreenSpaceMath.InViewport(CameraRelativeMovement.ToNumerics(camera.WorldToViewportPoint(target.GetCenterPoint()))); } internal static bool Retain(Character target, Player player, IsometricCameraController controller) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Camera camera = controller.Camera; if (!InRange(target, player, 22f) || !OnScreen(target, camera) || !BaseAI.IsEnemy((Character)(object)player, target)) { return false; } return ClearSight(target.GetCenterPoint(), target, player, controller) || ClearSight(target.GetTopPoint(), target, player, controller); } private static bool ClearSight(Vector3 point, Character target, Player player, IsometricCameraController controller) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0018: 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_0024: 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) Camera camera = controller.Camera; Ray val = camera.ViewportPointToRay(camera.WorldToViewportPoint(point)); float num = Vector3.Distance(((Ray)(ref val)).origin, point); int num2 = Physics.RaycastNonAlloc(val, Hits, num, Mask, (QueryTriggerInteraction)1); RaycastHit[] array = Hits; if (num2 == Hits.Length) { array = Physics.RaycastAll(val, num, Mask, (QueryTriggerInteraction)1); num2 = array.Length; } GameObject val2 = NativeCursorRays.Ghost.Invoke(player); for (int i = 0; i < num2; i++) { Collider collider = ((RaycastHit)(ref array[i])).collider; if (Object.op_Implicit((Object)(object)collider)) { Character componentInParent = ((Component)collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)(object)target) && !((Object)(object)componentInParent == (Object)(object)player) && !controller.IsHiddenObstacle(collider) && (!Object.op_Implicit((Object)(object)val2) || !((Component)collider).transform.IsChildOf(val2.transform))) { return false; } } } return true; } private static bool InRange(Character target, Player player, float radius) { //IL_0016: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) int result; if (Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)player)) { Vector3 val = ((Component)target).transform.position - ((Component)player).transform.position; result = ((((Vector3)(ref val)).sqrMagnitude <= radius * radius) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } } internal sealed class TrunkGeometry : IDisposable { private readonly Dictionary copies = new Dictionary(); private readonly List expired = new List(); private readonly List visible = new List(); private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock(); internal void Prepare(Renderer source, Transform tree) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_040a: Unknown result type (might be due to invalid IL or missing references) if (copies.ContainsKey(source) || !(source is MeshRenderer)) { return; } copies[source] = null; MeshFilter component = ((Component)source).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.sharedMesh)) { return; } Mesh val = null; GameObject val2 = null; try { MeshChannels meshChannels = MeshChannels.ForRenderer(component.sharedMesh, source); Matrix4x4 val3 = tree.worldToLocalMatrix * source.localToWorldMatrix; List list = new List(); List list2 = new List(); Bounds bounds = source.bounds; float r = Mathf.Clamp(((Bounds)(ref bounds)).size.y * 0.085f, 0.6f, 2f) / Mathf.Max(0.01f, Mathf.Abs(tree.lossyScale.x)); int[][] triangles = meshChannels.Triangles; foreach (int[] array in triangles) { list.Clear(); for (int j = 0; j < array.Length; j += 3) { Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(meshChannels.Positions[array[j]]); Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(meshChannels.Positions[array[j + 1]]); Vector3 val6 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(meshChannels.Positions[array[j + 2]]); if (!(Mathf.Min(new float[3] { val4.y, val5.y, val6.y }) > 8f) && Inside(val4, r) && Inside(val5, r) && Inside(val6, r)) { list.Add(array[j]); list.Add(array[j + 1]); list.Add(array[j + 2]); } } list2.Add(list.ToArray()); } if (!list2.Exists((int[] s) => s.Length != 0)) { return; } val = new Mesh { name = "Isometric trunk", indexFormat = (IndexFormat)1, hideFlags = (HideFlags)61 }; val.vertices = meshChannels.Positions; Vector3[] normals = meshChannels.Normals; if (normals != null && normals.Length != 0) { val.normals = meshChannels.Normals; } Vector4[] tangents = meshChannels.Tangents; if (tangents != null && tangents.Length != 0) { val.tangents = meshChannels.Tangents; } Color[] colors = meshChannels.Colors; if (colors != null && colors.Length != 0) { val.colors = meshChannels.Colors; } for (int num = 0; num < meshChannels.Uv.Length; num++) { Vector4[] obj = meshChannels.Uv[num]; if (obj != null && obj.Length != 0) { val.SetUVs(num, new List(meshChannels.Uv[num])); } } val.subMeshCount = list2.Count; for (int num2 = 0; num2 < list2.Count; num2++) { val.SetTriangles(list2[num2], num2, false); } val.RecalculateBounds(); val2 = new GameObject("Isometric captured bark") { hideFlags = (HideFlags)61, layer = ((Component)source).gameObject.layer }; val2.transform.SetParent(((Component)source).transform, false); val2.AddComponent(); val2.AddComponent().sharedMesh = val; MeshRenderer val7 = val2.AddComponent(); ((Renderer)val7).enabled = false; ((Renderer)val7).sharedMaterials = source.sharedMaterials; ((Renderer)val7).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val7).receiveShadows = source.receiveShadows; ((Renderer)val7).lightProbeUsage = source.lightProbeUsage; ((Renderer)val7).probeAnchor = source.probeAnchor; copies[source] = val7; } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } Plugin.Instance?.Warn("Keeping original tree reveal for " + ((Object)source).name + ": " + ex.Message); } } private static bool Inside(Vector3 p, float r) { //IL_0000: 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_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) return p.x * p.x + p.z * p.z <= r * r; } internal void Show(HashSet sources) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 foreach (Renderer source in sources) { if (Object.op_Implicit((Object)(object)source) && (source.forceRenderingOff || (int)source.shadowCastingMode == 3) && copies.TryGetValue(source, out var value) && Object.op_Implicit((Object)(object)value)) { source.GetPropertyBlock(properties); ((Renderer)value).SetPropertyBlock(properties); ((Renderer)value).enabled = true; visible.Add(value); } } } internal void Hide() { foreach (MeshRenderer item in visible) { if (Object.op_Implicit((Object)(object)item)) { ((Renderer)item).enabled = false; } } visible.Clear(); } private void Remove(Renderer source) { MeshRenderer val = copies[source]; if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)((Component)val).GetComponent().sharedMesh); Object.Destroy((Object)(object)((Component)val).gameObject); } copies.Remove(source); } internal void Retain(HashSet sources) { expired.Clear(); foreach (Renderer key in copies.Keys) { if (!Object.op_Implicit((Object)(object)key) || !sources.Contains(key)) { expired.Add(key); } } foreach (Renderer item in expired) { Remove(item); } } public void Dispose() { Hide(); Retain(new HashSet()); } } internal sealed class UiPointerHitTest { private readonly List results = new List(); private readonly List fallback = new List(); private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4]; private EventSystem events; private PointerEventData pointer; internal bool OverInterface(Vector2 position) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_014b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)InventoryGui.instance)) { return true; } if (!Object.op_Implicit((Object)(object)EventSystem.current)) { fallback.Clear(); ((Component)InventoryGui.instance).GetComponentsInChildren(false, fallback); foreach (Graphic item in fallback) { if (Blocks(item, position)) { return true; } } return false; } if ((Object)(object)events != (Object)(object)EventSystem.current) { events = EventSystem.current; pointer = new PointerEventData(events); } ((AbstractEventData)pointer).Reset(); pointer.position = position; results.Clear(); events.RaycastAll(pointer, results); foreach (RaycastResult result in results) { RaycastResult current2 = result; if (current2.module is GraphicRaycaster && Object.op_Implicit((Object)(object)((RaycastResult)(ref current2)).gameObject) && Blocks(((RaycastResult)(ref current2)).gameObject.GetComponent(), position)) { return true; } } return false; } private bool Blocks(Graphic graphic, Vector2 position) { //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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d7: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)graphic) || !((Behaviour)graphic).enabled || !graphic.raycastTarget || !((Component)graphic).gameObject.activeInHierarchy) { return false; } Canvas componentInParent = ((Component)graphic).GetComponentInParent(); Camera val = ((Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); RectTransform rectTransform = graphic.rectTransform; if (!RectTransformUtility.RectangleContainsScreenPoint(rectTransform, position, val) || !graphic.Raycast(position, val)) { return false; } rectTransform.GetWorldCorners(corners); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(float.PositiveInfinity, float.PositiveInfinity); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(float.NegativeInfinity, float.NegativeInfinity); Vector3[] array = corners; foreach (Vector3 val4 in array) { Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val, val4); val2 = Vector2.Min(val2, val5); val3 = Vector2.Max(val3, val5); } if (VisualRules.Backdrop(val3.x - val2.x, val3.y - val2.y, Screen.width, Screen.height)) { return false; } return graphic.color.a > 0f || Object.op_Implicit((Object)(object)((Component)graphic).GetComponentInParent()); } } internal sealed class VisibilityTiming { private static readonly string[] Names = new string[6] { "restore", "room", "geometry", "queries", "scope", "reveal" }; private readonly long[] totals = new long[6]; private readonly long[] peaks = new long[6]; private readonly int[] calls = new int[6]; private long reported; private int previousSnapshots; private int previousLocal; internal static long Begin() { return Stopwatch.GetTimestamp(); } internal void End(int phase, long start) { long num = Stopwatch.GetTimestamp() - start; totals[phase] += num; if (num > peaks[phase]) { peaks[phase] = num; } calls[phase]++; } internal string Report(int snapshots, int local, int hidden, int cuts) { long timestamp = Stopwatch.GetTimestamp(); if (reported == 0) { reported = timestamp; previousSnapshots = snapshots; previousLocal = local; return null; } if (timestamp - reported < Stopwatch.Frequency * 10) { return null; } reported = timestamp; StringBuilder stringBuilder = new StringBuilder("Visibility timing (main-thread mean/max ms): "); double num = 1000.0 / (double)Stopwatch.Frequency; for (int i = 0; i < Names.Length; i++) { if (i > 0) { stringBuilder.Append("; "); } stringBuilder.Append(Names[i]).Append('='); stringBuilder.Append(((calls[i] > 0) ? ((double)totals[i] * num / (double)calls[i]) : 0.0).ToString("F2", CultureInfo.InvariantCulture)).Append('/'); stringBuilder.Append(((double)peaks[i] * num).ToString("F2", CultureInfo.InvariantCulture)).Append(" n=").Append(calls[i]); totals[i] = (peaks[i] = 0L); calls[i] = 0; } stringBuilder.Append("; full snapshots=").Append(snapshots - previousSnapshots).Append("; local changes=") .Append(local - previousLocal); stringBuilder.Append("; hidden=").Append(hidden).Append("; cuts=") .Append(cuts); previousSnapshots = snapshots; previousLocal = local; return stringBuilder.ToString(); } internal void Reset() { reported = 0L; for (int i = 0; i < Names.Length; i++) { totals[i] = (peaks[i] = 0L); calls[i] = 0; } previousSnapshots = (previousLocal = 0); } } internal static class PathOfValheiman { internal const string PluginId = "treextr.pathofvalheiman"; private static FieldInfo floaters; private static FieldInfo rect; private static FieldInfo from; internal static void Install(Harmony harmony) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("treextr.pathofvalheiman", out var value) || !Object.op_Implicit((Object)(object)value.Instance)) { return; } Type type = ((object)value.Instance).GetType().Assembly.GetType("PassiveTree.UI.HudWidget"); if (type == null) { return; } MethodInfo methodInfo = AccessTools.Method(type, "TickFloaters", (Type[])null, (Type[])null); Type type2 = AccessTools.Inner(type, "Floater"); if (!(methodInfo == null) && !(type2 == null)) { floaters = AccessTools.Field(type, "floaters"); rect = AccessTools.Field(type2, "Rect"); from = AccessTools.Field(type2, "From"); if (!(floaters == null) && !(rect == null) && !(from == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(PathOfValheiman), "PositionExperience", (Type[])null) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void PositionExperience(object __instance) { //IL_0099: 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_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_00c0: 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_00c7: 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_00e7: 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_0196: 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_016b: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || !instance.Settings.ExperienceAbovePlayer.Value || !instance.CameraController.Active || !instance.Guard.IsCameraViewAllowed() || !Object.op_Implicit((Object)(object)localPlayer)) { return; } Camera camera = instance.CameraController.Camera; if (!Object.op_Implicit((Object)(object)camera) || !(floaters.GetValue(__instance) is IList { Count: not 0 } list)) { return; } Vector3 val = ((Character)localPlayer).GetTopPoint() + Vector3.up * (PresentationTokens.Current.headOffset * 2f); Vector3 val2 = camera.WorldToViewportPoint(val); if (val2.z <= 0f) { return; } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x * (float)Screen.width, val2.y * (float)Screen.height); Vector2 val6 = default(Vector2); Vector2 val8 = default(Vector2); for (int i = 0; i < list.Count; i++) { object obj = list[i]; object? value = rect.GetValue(obj); RectTransform val4 = (RectTransform)((value is RectTransform) ? value : null); if (val4 == null || !Object.op_Implicit((Object)(object)val4)) { continue; } Transform parent = ((Transform)val4).parent; RectTransform val5 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (val5 == null) { continue; } object value2 = from.GetValue(obj); int num; if (value2 is Vector2) { val6 = (Vector2)value2; num = 1; } else { num = 0; } if (num != 0) { Canvas componentInParent = ((Component)val5).GetComponentInParent(); Camera val7 = ((Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val5, val3, val7, ref val8)) { Vector2 val9 = val4.anchoredPosition - val6; Vector2 val10 = val8; float x = val9.x; float num2 = Mathf.Abs(val9.y); float num3 = i; Rect val11 = val4.rect; Vector2 val12 = val10 + new Vector2(x, num2 + num3 * ((Rect)(ref val11)).height); ((Transform)val4).position = ((Transform)val5).TransformPoint(Vector2.op_Implicit(val12)); } } } } } internal static class WiresAllyHud { internal const string PluginId = "kajetan.valheim.enemyhudrework"; internal static void Install(Harmony harmony) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown if (Chainloader.PluginInfos.TryGetValue("kajetan.valheim.enemyhudrework", out var value) && Object.op_Implicit((Object)(object)value.Instance)) { MethodInfo methodInfo = AccessTools.Method(((object)value.Instance).GetType(), "UpdateDebugHuds", new Type[1] { typeof(EnemyHud) }, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(WiresAllyHud), "UseLocalNameplate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } } private static IEnumerable UseLocalNameplate(IEnumerable instructions) { List list = instructions.ToList(); MethodInfo configGetter = AccessTools.PropertyGetter(typeof(ConfigEntry), "Value"); MethodInfo crouch = AccessTools.Method(typeof(Character), "IsCrouching", (Type[])null, (Type[])null); int num = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.Calls(instruction, configGetter)); int num2 = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.Calls(instruction, crouch)); if (num <= 0 || num2 <= num || !(list[num - 1].operand is FieldInfo fieldInfo) || fieldInfo.Name != "_debugSeeOwnHealthBar") { Plugin.Instance?.Warn("Wire's own nameplate compatibility pattern changed."); return list; } list[num].opcode = OpCodes.Call; list[num].operand = AccessTools.Method(typeof(WiresAllyHud), "ShowOwnNameplate", (Type[])null, (Type[])null); list[num2].opcode = OpCodes.Call; list[num2].operand = AccessTools.Method(typeof(WiresAllyHud), "HideWhileCrouching", (Type[])null, (Type[])null); return list; } private static bool ShowOwnNameplate(ConfigEntry setting) { return setting.Value || IsometricOwnNameplate(); } private static bool HideWhileCrouching(Character character) { return character.IsCrouching() && !IsometricOwnNameplate(); } private static bool IsometricOwnNameplate() { Plugin instance = Plugin.Instance; return (Object)(object)instance != (Object)null && instance.CameraController.Active && instance.Guard.IsCameraViewAllowed() && !((Character)Player.m_localPlayer).IsDead() && !Hud.IsUserHidden(); } } }