Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BeeOverlay v0.1.0
com.aoirint.BeeOverlay.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.aoirint.BeeOverlay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+efcac4962e8b590c4fa6ba5ff03f066a59697761")] [assembly: AssemblyProduct("BeeOverlay")] [assembly: AssemblyTitle("com.aoirint.BeeOverlay")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BeeOverlay { [BepInPlugin("com.aoirint.BeeOverlay", "BeeOverlay", "0.1.0")] [BepInProcess("Lethal Company.exe")] public sealed class Plugin : BaseUnityPlugin { private Harmony? harmony; internal static ManualLogSource? Log { get; private set; } private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Overlay.Instance = new Overlay(); harmony = new Harmony("com.aoirint.BeeOverlay"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BeeOverlay v0.1.0 loaded."); } } internal sealed class Overlay { private readonly struct HiveMissingProbe { public Vector3 LastKnownHivePosition { get; } public float EyeToLastKnownHiveDistance { get; } public bool LinecastBlocked { get; } public bool NearTrigger { get; } public bool LineOfSightTrigger { get; } public bool CanEvaluateMissing { get; } public bool? SyncedLastKnownHivePosition { get; } public HiveMissingProbe(Vector3 lastKnownHivePosition, float eyeToLastKnownHiveDistance, bool linecastBlocked, bool nearTrigger, bool lineOfSightTrigger, bool canEvaluateMissing, bool? syncedLastKnownHivePosition) { //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) LastKnownHivePosition = lastKnownHivePosition; EyeToLastKnownHiveDistance = eyeToLastKnownHiveDistance; LinecastBlocked = linecastBlocked; NearTrigger = nearTrigger; LineOfSightTrigger = lineOfSightTrigger; CanEvaluateMissing = canEvaluateMissing; SyncedLastKnownHivePosition = syncedLastKnownHivePosition; } } private readonly struct HiveSightProbe { public Vector3 HivePosition { get; } public float EyeToHiveDistance { get; } public bool LinecastBlocked { get; } public bool WithinPlayerSightRange { get; } public bool CanSeePickupProxy { get { if (WithinPlayerSightRange) { return !LinecastBlocked; } return false; } } public HiveSightProbe(Vector3 hivePosition, float eyeToHiveDistance, bool linecastBlocked, bool withinPlayerSightRange) { //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) HivePosition = hivePosition; EyeToHiveDistance = eyeToHiveDistance; LinecastBlocked = linecastBlocked; WithinPlayerSightRange = withinPlayerSightRange; } } private sealed class BeeView { private sealed class WireframeSphere { private readonly LineRenderer equator; private readonly LineRenderer northLatitude; private readonly LineRenderer southLatitude; private readonly LineRenderer meridian0; private readonly LineRenderer meridian60; private readonly LineRenderer meridian120; private WireframeSphere(LineRenderer equator, LineRenderer northLatitude, LineRenderer southLatitude, LineRenderer meridian0, LineRenderer meridian60, LineRenderer meridian120) { this.equator = equator; this.northLatitude = northLatitude; this.southLatitude = southLatitude; this.meridian0 = meridian0; this.meridian60 = meridian60; this.meridian120 = meridian120; } public static WireframeSphere Create(string name, Transform parent, Material material) { return new WireframeSphere(CreateWorldLine(name + "Equator", parent, material), CreateWorldLine(name + "NorthLatitude", parent, material), CreateWorldLine(name + "SouthLatitude", parent, material), CreateWorldLine(name + "Meridian0", parent, material), CreateWorldLine(name + "Meridian60", parent, material), CreateWorldLine(name + "Meridian120", parent, material)); } public void Set(Vector3 center, float radius, Color color) { //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_0030: 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_0043: 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_0056: 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_0069: 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_007c: 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) if (radius <= 0f) { SetVisible(visible: false); return; } SetVisible(visible: true); SetLatitude(equator, center, radius, 0f, color); SetLatitude(northLatitude, center, radius, 0.5f, color); SetLatitude(southLatitude, center, radius, -0.5f, color); SetMeridian(meridian0, center, radius, 0f, color); SetMeridian(meridian60, center, radius, MathF.PI / 3f, color); SetMeridian(meridian120, center, radius, MathF.PI * 2f / 3f, color); } public void SetVisible(bool visible) { ((Component)equator).gameObject.SetActive(visible); ((Component)northLatitude).gameObject.SetActive(visible); ((Component)southLatitude).gameObject.SetActive(visible); ((Component)meridian0).gameObject.SetActive(visible); ((Component)meridian60).gameObject.SetActive(visible); ((Component)meridian120).gameObject.SetActive(visible); } private static void SetLatitude(LineRenderer line, Vector3 center, float radius, float heightFactor, Color color) { //IL_0009: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) line.positionCount = 49; line.startColor = color; line.endColor = color; float num = radius * ((heightFactor == 0f) ? 1f : 0.8660254f); float num2 = radius * heightFactor; Vector3 val = default(Vector3); for (int i = 0; i <= 48; i++) { float num3 = MathF.PI * 2f * (float)i / 48f; ((Vector3)(ref val))..ctor(Mathf.Cos(num3) * num, num2, Mathf.Sin(num3) * num); line.SetPosition(i, center + val); } } private static void SetMeridian(LineRenderer line, Vector3 center, float radius, float longitude, Color color) { //IL_0009: 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_005c: 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_005f: Unknown result type (might be due to invalid IL or missing references) line.positionCount = 49; line.startColor = color; line.endColor = color; float num = Mathf.Cos(longitude); float num2 = Mathf.Sin(longitude); Vector3 val = default(Vector3); for (int i = 0; i <= 48; i++) { float num3 = MathF.PI * 2f * (float)i / 48f; float num4 = Mathf.Cos(num3) * radius; ((Vector3)(ref val))..ctor(num * num4, Mathf.Sin(num3) * radius, num2 * num4); line.SetPosition(i, center + val); } } } private readonly GameObject worldRoot; private readonly WireframeSphere beeSightRangeSphere; private readonly WireframeSphere defenseDistanceSphere; private readonly LineRenderer visiblePlayerSightLine; private readonly WireframeSphere lastKnownHiveNearSphere; private readonly WireframeSphere lastKnownHiveLineOfSightSphere; private readonly LineRenderer beeEyeToLastKnownHiveLine; private readonly LineRenderer beeEyeToHiveLine; private readonly GameObject beeMarker; private readonly GameObject hiveMarker; private readonly GameObject lastKnownHiveMarker; private readonly GameObject playerMarker; private BeeView(GameObject worldRoot, WireframeSphere beeSightRangeSphere, WireframeSphere defenseDistanceSphere, LineRenderer visiblePlayerSightLine, WireframeSphere lastKnownHiveNearSphere, WireframeSphere lastKnownHiveLineOfSightSphere, LineRenderer beeEyeToLastKnownHiveLine, LineRenderer beeEyeToHiveLine, GameObject beeMarker, GameObject hiveMarker, GameObject lastKnownHiveMarker, GameObject playerMarker) { this.worldRoot = worldRoot; this.beeSightRangeSphere = beeSightRangeSphere; this.defenseDistanceSphere = defenseDistanceSphere; this.visiblePlayerSightLine = visiblePlayerSightLine; this.lastKnownHiveNearSphere = lastKnownHiveNearSphere; this.lastKnownHiveLineOfSightSphere = lastKnownHiveLineOfSightSphere; this.beeEyeToLastKnownHiveLine = beeEyeToLastKnownHiveLine; this.beeEyeToHiveLine = beeEyeToHiveLine; this.beeMarker = beeMarker; this.hiveMarker = hiveMarker; this.lastKnownHiveMarker = lastKnownHiveMarker; this.playerMarker = playerMarker; } public static BeeView Create(int beeIndex, Material lineMaterial, Material beeMaterial, Material hiveMaterial, Material lastKnownHiveMaterial, Material playerMaterial) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GameObject val = new GameObject($"BeeWorldOverlay_{beeIndex}"); Object.DontDestroyOnLoad((Object)(object)val); WireframeSphere wireframeSphere = WireframeSphere.Create("BeeSightRangeSphere", val.transform, lineMaterial); WireframeSphere wireframeSphere2 = WireframeSphere.Create("DefenseDistanceSphere", val.transform, lineMaterial); LineRenderer val2 = CreateWorldLine("VisiblePlayerSightLine", val.transform, lineMaterial); WireframeSphere wireframeSphere3 = WireframeSphere.Create("LastKnownHiveNearSphere", val.transform, lineMaterial); WireframeSphere wireframeSphere4 = WireframeSphere.Create("LastKnownHiveLineOfSightSphere", val.transform, lineMaterial); LineRenderer val3 = CreateWorldLine("BeeEyeToLastKnownHiveLine", val.transform, lineMaterial); LineRenderer val4 = CreateWorldLine("BeeEyeToHiveLine", val.transform, lineMaterial); GameObject val5 = CreateWorldMarker("BeeEyeWorldMarker", val.transform, beeMaterial); GameObject val6 = CreateWorldMarker("HiveWorldMarker", val.transform, hiveMaterial); GameObject val7 = CreateWorldMarker("LastKnownHiveWorldMarker", val.transform, lastKnownHiveMaterial); GameObject val8 = CreateWorldMarker("LocalPlayerWorldMarker", val.transform, playerMaterial); wireframeSphere.SetVisible(visible: false); wireframeSphere2.SetVisible(visible: false); ((Component)val2).gameObject.SetActive(false); wireframeSphere3.SetVisible(visible: false); wireframeSphere4.SetVisible(visible: false); ((Component)val3).gameObject.SetActive(false); ((Component)val4).gameObject.SetActive(false); val5.SetActive(false); val6.SetActive(false); val7.SetActive(false); val8.SetActive(false); return new BeeView(val, wireframeSphere, wireframeSphere2, val2, wireframeSphere3, wireframeSphere4, val3, val4, val5, val6, val7, val8); } public void SetSpatialGuides(Vector3 hive, int defenseDistance, Vector3 beeEye, Vector3? localPlayer, bool canSeeLocalPlayer, HiveMissingProbe hiveMissingProbe, HiveSightProbe hiveSightProbe) { //IL_0021: 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_0043: 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_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_0067: 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_0081: 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_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_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_00aa: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_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) if (!((Object)(object)worldRoot == (Object)null)) { worldRoot.SetActive(true); SetMarker(beeMarker, beeEye, 0.16f); SetMarker(hiveMarker, hive, 0.18f); beeSightRangeSphere.Set(beeEye, 16f, BeeColor); defenseDistanceSphere.Set(hive, defenseDistance, HiveColor); SetHiveMissingProbe(beeEye, hiveMissingProbe); SetHiveSightProbe(beeEye, hiveSightProbe); if (localPlayer.HasValue) { Vector3 val = Vector3.up * -0.35f; Vector3 val2 = localPlayer.Value + val; Color color = (canSeeLocalPlayer ? PlayerColor : InactiveLineColor); SetMarker(playerMarker, val2, 0.16f); ((Component)visiblePlayerSightLine).gameObject.SetActive(true); SetWorldLine(visiblePlayerSightLine, beeEye, val2, color); } else { ((Component)visiblePlayerSightLine).gameObject.SetActive(false); playerMarker.SetActive(false); } } } private void SetHiveSightProbe(Vector3 beeEye, HiveSightProbe probe) { //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: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Vector3 end = probe.HivePosition + Vector3.up * 0.35f; Color color = (probe.CanSeePickupProxy ? PickupProxyColor : InactiveLineColor); SetWorldLine(beeEyeToHiveLine, beeEye, end, color); ((Component)beeEyeToHiveLine).gameObject.SetActive(true); } private void SetHiveMissingProbe(Vector3 beeEye, HiveMissingProbe probe) { //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: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0045: 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_005b: 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_006e: 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_0081: 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_0083: 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_00c8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = probe.LastKnownHivePosition + Vector3.up * 0.35f; lastKnownHiveMarker.SetActive(true); lastKnownHiveMarker.transform.position = val; lastKnownHiveNearSphere.Set(val, 4f, LastKnownHiveNearSphereColor); lastKnownHiveLineOfSightSphere.Set(val, 8f, LastKnownHiveLineOfSightSphereColor); Color color = (probe.CanEvaluateMissing ? LastKnownHiveColor : InactiveLineColor); SetWorldLine(beeEyeToLastKnownHiveLine, beeEye, val, color); ((Component)beeEyeToLastKnownHiveLine).gameObject.SetActive(true); float num = Mathf.Clamp(probe.EyeToLastKnownHiveDistance * 0.03f, 0.14f, 0.32f); lastKnownHiveMarker.transform.localScale = Vector3.one * num; } public void SetVisible(bool visible) { if ((Object)(object)worldRoot != (Object)null) { worldRoot.SetActive(visible); } } private static void SetMarker(GameObject marker, Vector3 position, float scale) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) marker.SetActive(true); marker.transform.position = position; marker.transform.localScale = Vector3.one * scale; } private static void SetWorldLine(LineRenderer line, Vector3 start, Vector3 end, Color color) { //IL_0009: 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_0018: 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) line.positionCount = 2; line.SetPosition(0, start); line.SetPosition(1, end); line.startColor = color; line.endColor = color; } private static LineRenderer CreateWorldLine(string name, Transform parent, Material material) { //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_0044: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); LineRenderer obj = val.AddComponent<LineRenderer>(); obj.positionCount = 2; obj.useWorldSpace = true; obj.startWidth = 0.06f; obj.endWidth = 0.06f; obj.numCapVertices = 4; obj.startColor = HudTextColor; obj.endColor = HudTextColor; ((Renderer)obj).material = material; return obj; } private static GameObject CreateWorldMarker(string name, Transform parent, Material material) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.GetComponent<Renderer>().material = material; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } return obj; } private static void Center(RectTransform rect) { //IL_000b: 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_0035: 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) rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f); rect.pivot = new Vector2(0.5f, 0.5f); ((Transform)rect).localScale = Vector3.one; } } private static readonly Color HudTextColor = new Color(1f, 0.85f, 0.1f, 0.95f); private static readonly Color BeeColor = new Color(1f, 0.85f, 0.1f, 0.95f); private static readonly Color HiveColor = new Color(0.25f, 1f, 0.35f, 0.95f); private static readonly Color LastKnownHiveColor = new Color(0.05f, 0.32f, 1f, 0.95f); private static readonly Color LastKnownHiveNearSphereColor = new Color(0.15f, 0.55f, 1f, 0.7f); private static readonly Color LastKnownHiveLineOfSightSphereColor = new Color(0.25f, 0.6f, 1f, 0.3f); private static readonly Color PlayerColor = new Color(1f, 0.15f, 0.1f, 0.95f); private static readonly Color PickupProxyColor = new Color(1f, 1f, 1f, 0.95f); private static readonly Color InactiveLineColor = new Color(0.18f, 0.18f, 0.18f, 0.58f); private const float PlayerLineOfSightDistance = 16f; private const float VisiblePlayerSightLineRenderYOffset = -0.35f; private const float HiveMissingNearDistance = 4f; private const float HiveMissingLineOfSightDistance = 8f; private const int WireframeSphereSegments = 48; private const float WireframeLatitudeOffsetFactor = 0.5f; private const float WireframeLatitudeRadiusFactor = 0.8660254f; private const float WorldYOffset = 0.35f; private readonly Dictionary<int, BeeView> views = new Dictionary<int, BeeView>(); private readonly Font? font = Resources.GetBuiltinResource<Font>("Arial.ttf"); private readonly Material worldLineMaterial = CreateMaterial(Color.white); private readonly Material beeMaterial = CreateMaterial(BeeColor); private readonly Material hiveMaterial = CreateMaterial(HiveColor); private readonly Material lastKnownHiveMaterial = CreateMaterial(LastKnownHiveColor); private readonly Material playerMaterial = CreateMaterial(PlayerColor); private static readonly FieldRef<RedLocustBees, bool>? SyncedLastKnownHivePositionRef = CreateSyncedLastKnownHivePositionRef(); private RectTransform? hudRoot; private Text? statusText; private Transform? attachedHudContainer; private float nextWaitingLogTime; public static Overlay? Instance { get; set; } public void Tick() { if (!TryEnsureHudRoot()) { HideAll(); LogWaitingForHud(); return; } RedLocustBees[] array = Object.FindObjectsOfType<RedLocustBees>(); Array.Sort(array, (RedLocustBees left, RedLocustBees right) => ((EnemyAI)left).thisEnemyIndex.CompareTo(((EnemyAI)right).thisEnemyIndex)); HashSet<int> hashSet = new HashSet<int>(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"Bee Overlay | bees={array.Length}"); PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); Vector3? playerBodyPosition = GetPlayerBodyPosition(val); for (int num = 0; num < array.Length; num++) { RedLocustBees bee = array[num]; DrawBee(bee, hashSet); stringBuilder.AppendLine(); stringBuilder.Append(GetBeeStatusLine(bee, num + 1, val, playerBodyPosition)); } foreach (KeyValuePair<int, BeeView> view in views) { if (!hashSet.Contains(view.Key)) { view.Value.SetVisible(visible: false); } } SetStatus(stringBuilder.ToString()); } private bool TryEnsureHudRoot() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0113: 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_013d: 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_0166: 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) GameObject val = (((Object)(object)HUDManager.Instance != (Object)null) ? HUDManager.Instance.HUDContainer : null); if ((Object)(object)val == (Object)null) { return false; } if ((Object)(object)hudRoot != (Object)null && (Object)(object)attachedHudContainer == (Object)(object)val.transform) { return true; } if ((Object)(object)hudRoot != (Object)null) { Object.Destroy((Object)(object)((Component)hudRoot).gameObject); } views.Clear(); attachedHudContainer = val.transform; GameObject val2 = new GameObject("RedLocustBeesState0Overlay", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(attachedHudContainer, false); hudRoot = val2.GetComponent<RectTransform>(); Stretch(hudRoot); GameObject val3 = new GameObject("Status", new Type[2] { typeof(RectTransform), typeof(Text) }); val3.transform.SetParent(val2.transform, false); RectTransform component = val3.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(16f, -16f); component.sizeDelta = new Vector2(1040f, 320f); statusText = val3.GetComponent<Text>(); statusText.font = font; statusText.fontSize = 15; statusText.fontStyle = (FontStyle)1; statusText.alignment = (TextAnchor)0; ((Graphic)statusText).color = HudTextColor; statusText.supportRichText = true; ((Graphic)statusText).raycastTarget = false; statusText.horizontalOverflow = (HorizontalWrapMode)1; statusText.verticalOverflow = (VerticalWrapMode)1; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)("Overlay attached to HUDContainer='" + ((Object)val).name + "'.")); } return true; } private void DrawBee(RedLocustBees bee, HashSet<int> seen) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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_006c: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00c5: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)bee == (Object)null) && !((Object)(object)bee.hive == (Object)null)) { BeeView view = GetView(((EnemyAI)bee).thisEnemyIndex); Vector3 position = ((Component)bee).transform.position; Vector3 position2 = ((Component)bee.hive).transform.position; Vector3 val = (((Object)(object)((EnemyAI)bee).eye != (Object)null) ? ((EnemyAI)bee).eye.position : (position + Vector3.up * 0.35f)); PlayerControllerB val2 = ((EnemyAI)bee).CheckLineOfSightForPlayer(360f, 16, 1); PlayerControllerB val3 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); view.SetSpatialGuides(localPlayer: GetPlayerSightTargetPosition(val3), canSeeLocalPlayer: (Object)(object)val2 != (Object)null && (Object)(object)val2 == (Object)(object)val3, hiveMissingProbe: GetHiveMissingProbe(bee, val), hiveSightProbe: GetHiveSightProbe(val, position2), hive: position2 + Vector3.up * 0.35f, defenseDistance: bee.defenseDistance, beeEye: val); seen.Add(((EnemyAI)bee).thisEnemyIndex); } } private static Vector3? GetPlayerSightTargetPosition(PlayerControllerB? player) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } if ((Object)(object)player.gameplayCamera != (Object)null) { return ((Component)player.gameplayCamera).transform.position; } return ((Component)player).transform.position + Vector3.up * 1.6f; } private static Vector3? GetPlayerBodyPosition(PlayerControllerB? player) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player != (Object)null)) { return null; } return ((Component)player).transform.position; } private BeeView GetView(int beeIndex) { if (views.TryGetValue(beeIndex, out BeeView value)) { return value; } value = BeeView.Create(beeIndex, worldLineMaterial, beeMaterial, hiveMaterial, lastKnownHiveMaterial, playerMaterial); views.Add(beeIndex, value); return value; } private static string GetBeeStatusLine(RedLocustBees bee, int displayBeeNumber, PlayerControllerB? localPlayer, Vector3? localPlayerPosition) { //IL_000e: 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_008a: 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) //IL_006e: 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_007d: 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_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_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_010b: 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_0120: 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_0129: 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_0177: 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_01d7: 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) if ((Object)(object)bee == (Object)null) { return Tag("bee:n/a", BeeColor) ?? ""; } if ((Object)(object)bee.hive == (Object)null) { return Tag($"bee:{displayBeeNumber}", BeeColor) + " hive n/a"; } Vector3 val = (((Object)(object)((EnemyAI)bee).eye != (Object)null) ? ((EnemyAI)bee).eye.position : (((Component)bee).transform.position + Vector3.up * 0.35f)); Vector3 position = ((Component)bee.hive).transform.position; PlayerControllerB val2 = ((EnemyAI)bee).CheckLineOfSightForPlayer(360f, 16, 1); bool canSee = (Object)(object)localPlayer != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val2 == (Object)(object)localPlayer; float? distance = (localPlayerPosition.HasValue ? new float?(Vector3.Distance(localPlayerPosition.Value, position)) : ((float?)null)); float? distance2 = (localPlayerPosition.HasValue ? new float?(Vector3.Distance(val, localPlayerPosition.Value)) : ((float?)null)); HiveMissingProbe hiveMissingProbe = GetHiveMissingProbe(bee, val); HiveSightProbe hiveSightProbe = GetHiveSightProbe(val, position); return string.Join(" ", Tag($"bee:{displayBeeNumber}", BeeColor), Tag("bee-player=" + FmtDistance(distance2) + "/" + SeenBlocked(canSee), PlayerColor), Tag("hive-player=" + FmtDistance(distance) + "/" + InsideOutside(distance, bee.defenseDistance), HiveColor), Tag($"bee-hive={hiveSightProbe.EyeToHiveDistance:F2}u/{SeenBlocked(hiveSightProbe.CanSeePickupProxy)}", PickupProxyColor), Tag($"bee-knownHive={hiveMissingProbe.EyeToLastKnownHiveDistance:F2}u/{SeenBlocked(!hiveMissingProbe.LinecastBlocked)}", LastKnownHiveColor)); } private static HiveSightProbe GetHiveSightProbe(Vector3 beeEyePosition, Vector3 hivePosition) { //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_001e: 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_0034: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(beeEyePosition, hivePosition); bool withinPlayerSightRange = num < 16f; bool linecastBlocked = (Object)(object)StartOfRound.Instance == (Object)null || Physics.Linecast(beeEyePosition, hivePosition, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); return new HiveSightProbe(hivePosition, num, linecastBlocked, withinPlayerSightRange); } private static HiveMissingProbe GetHiveMissingProbe(RedLocustBees bee, Vector3 beeEyePosition) { //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_0008: 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_0079: Unknown result type (might be due to invalid IL or missing references) Vector3 lastKnownHivePosition = bee.lastKnownHivePosition; float num = Vector3.Distance(beeEyePosition, lastKnownHivePosition); bool flag = (Object)(object)StartOfRound.Instance == (Object)null || Physics.Linecast(beeEyePosition, lastKnownHivePosition, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); bool? syncedLastKnownHivePosition = GetSyncedLastKnownHivePosition(bee); bool flag2 = num < 4f; bool flag3 = num < 8f && !flag; bool canEvaluateMissing = syncedLastKnownHivePosition != false && (flag2 || flag3); return new HiveMissingProbe(lastKnownHivePosition, num, flag, flag2, flag3, canEvaluateMissing, syncedLastKnownHivePosition); } private static bool? GetSyncedLastKnownHivePosition(RedLocustBees bee) { if (SyncedLastKnownHivePositionRef == null) { return null; } return SyncedLastKnownHivePositionRef.Invoke(bee); } private static FieldRef<RedLocustBees, bool>? CreateSyncedLastKnownHivePositionRef() { try { return AccessTools.FieldRefAccess<RedLocustBees, bool>("syncedLastKnownHivePosition"); } catch (Exception ex) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)("Could not access RedLocustBees.syncedLastKnownHivePosition: " + ex.Message)); } return null; } } private static string FmtDistance(float? distance) { if (!distance.HasValue) { return "n/a"; } return $"{distance.Value:F2}u"; } private static string SeenBlocked(bool canSee) { if (!canSee) { return "blocked"; } return "SEEN"; } private static string InsideOutside(float? distance, float radius) { if (!distance.HasValue || radius <= 0f) { return "n/a"; } if (!(distance.Value < radius)) { return "outside"; } return "INSIDE"; } private static string Tag(string text, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return "<color=#" + ColorUtility.ToHtmlStringRGBA(color) + ">" + text + "</color>"; } private void SetStatus(string text) { if ((Object)(object)statusText != (Object)null) { statusText.text = text; } } private void HideAll() { foreach (BeeView value in views.Values) { value.SetVisible(visible: false); } } private void LogWaitingForHud() { if (!(Time.realtimeSinceStartup < nextWaitingLogTime)) { nextWaitingLogTime = Time.realtimeSinceStartup + 5f; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)"Overlay waiting for HUDManager.HUDContainer."); } } } private static void Stretch(RectTransform rect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_002d: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; ((Transform)rect).localScale = Vector3.one; } private static Material CreateMaterial(Color color) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown return new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/Internal-Colored")) { color = color }; } } [HarmonyPatch(typeof(HUDManager), "Update")] internal static class HudUpdatePatch { [HarmonyPostfix] private static void Postfix() { Overlay.Instance?.Tick(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.aoirint.BeeOverlay"; public const string PLUGIN_NAME = "BeeOverlay"; public const string PLUGIN_VERSION = "0.1.0"; } }