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.3.1
com.aoirint.BeeOverlay.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BeeOverlay.Core.Handlers; using BeeOverlay.Core.Models; using BeeOverlay.Core.Ports; using BeeOverlay.Core.Presentation; using BeeOverlay.Core.Snapshots; using BeeOverlay.Core.State; using BeeOverlay.Core.UseCases; using BeeOverlay.Interop; using BeeOverlay.Interop.Game; using BeeOverlay.Interop.InputUtils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; 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.3.1.0")] [assembly: AssemblyInformationalVersion("0.3.1+5396c1a534a4ea389aab7f47b1338757673b531e")] [assembly: AssemblyProduct("BeeOverlay")] [assembly: AssemblyTitle("com.aoirint.BeeOverlay")] [assembly: AssemblyVersion("0.3.1.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.3.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("Lethal Company.exe")] public sealed class Plugin : BaseUnityPlugin { private static PluginController? controller; private Harmony? harmony; internal static ManualLogSource? Log { get; private set; } internal static PluginController Controller => controller; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; controller = PluginController.Create(((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config); harmony = new Harmony("com.aoirint.BeeOverlay"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BeeOverlay v0.3.1 loaded."); } } internal sealed class PluginController { private readonly FrameHandler frameHandler; private readonly BeeOverlayConfiguration configuration; private readonly HostModPresenceGate hostModPresenceGate; public bool GuestOverlayEnabled { get { if (configuration.Enabled) { return configuration.AllowGuestEnabled; } return false; } } private PluginController(FrameHandler frameHandler, BeeOverlayConfiguration configuration, HostModPresenceGate hostModPresenceGate) { this.frameHandler = frameHandler; this.configuration = configuration; this.hostModPresenceGate = hostModPresenceGate; } public static PluginController Create(ManualLogSource logger, ConfigFile config) { BeeOverlayConfiguration beeOverlayConfiguration = BeeOverlayConfiguration.Bind(config); InputUtilsOverlayInput overlayInput = new InputUtilsOverlayInput(new InputUtilsActions()); IOverlayObservationSource observationSource = new BeeObservationSource(logger); IOverlayPresenter presenter = new Overlay(logger); return new PluginController(new FrameHandler(overlayInput, observationSource, presenter, new BuildOverlayFrameUseCase(), new WorldGuideSelection()), beeOverlayConfiguration, new HostModPresenceGate()); } public void AttachHostModPresence(HUDManager hudManager) { hostModPresenceGate.Attach(hudManager); } public void ConfirmHostModPresence(bool guestOverlayAllowed) { hostModPresenceGate.ConfirmHostPresence(guestOverlayAllowed); } public void BeginHostModPresenceCheck(HostModPresenceBehaviour bridge) { hostModPresenceGate.BeginHostPresenceCheck(bridge); } public HostPresenceRequestResult TryRequestHostModPresence() { return hostModPresenceGate.TryRequestHostPresence(); } public void ResetHostModPresence() { hostModPresenceGate.Reset(); frameHandler.ResetLobbySession(); } public void HandleFrame() { frameHandler.HandleFrame(configuration.Enabled && configuration.OverlayEnabled, hostModPresenceGate.IsOverlayAllowed, configuration.PresentationOptions); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.aoirint.BeeOverlay"; public const string PLUGIN_NAME = "BeeOverlay"; public const string PLUGIN_VERSION = "0.3.1"; } } namespace BeeOverlay.Interop { internal sealed class BeeOverlayConfiguration { private readonly ConfigEntry<bool> enabled; private readonly ConfigEntry<bool> allowGuestEnabled; private readonly ConfigEntry<bool> overlayEnabled; private readonly ConfigEntry<bool> hudEnabled; private readonly ConfigEntry<bool> beeMarkerEnabled; private readonly ConfigEntry<bool> hiveMarkerEnabled; private readonly ConfigEntry<bool> knownHiveMarkerEnabled; private readonly ConfigEntry<bool> playerMarkerEnabled; private readonly ConfigEntry<bool> playerSightLineEnabled; private readonly ConfigEntry<bool> beeSightRangeSphereEnabled; private readonly ConfigEntry<bool> hiveDefenseSphereEnabled; private readonly ConfigEntry<bool> knownHiveNearSphereEnabled; private readonly ConfigEntry<bool> knownHiveLineOfSightSphereEnabled; private readonly ConfigEntry<bool> knownHiveProbeLineEnabled; private readonly ConfigEntry<bool> hivePickupSightLineEnabled; public bool Enabled => enabled.Value; public bool AllowGuestEnabled => allowGuestEnabled.Value; public bool OverlayEnabled => overlayEnabled.Value; public OverlayPresentationOptions PresentationOptions => new OverlayPresentationOptions(hudEnabled.Value, beeMarkerEnabled.Value, hiveMarkerEnabled.Value, knownHiveMarkerEnabled.Value, playerMarkerEnabled.Value, playerSightLineEnabled.Value, beeSightRangeSphereEnabled.Value, hiveDefenseSphereEnabled.Value, knownHiveNearSphereEnabled.Value, knownHiveLineOfSightSphereEnabled.Value, knownHiveProbeLineEnabled.Value, hivePickupSightLineEnabled.Value); private BeeOverlayConfiguration(ConfigEntry<bool> enabled, ConfigEntry<bool> allowGuestEnabled, ConfigEntry<bool> overlayEnabled, ConfigEntry<bool> hudEnabled, ConfigEntry<bool> beeMarkerEnabled, ConfigEntry<bool> hiveMarkerEnabled, ConfigEntry<bool> knownHiveMarkerEnabled, ConfigEntry<bool> playerMarkerEnabled, ConfigEntry<bool> playerSightLineEnabled, ConfigEntry<bool> beeSightRangeSphereEnabled, ConfigEntry<bool> hiveDefenseSphereEnabled, ConfigEntry<bool> knownHiveNearSphereEnabled, ConfigEntry<bool> knownHiveLineOfSightSphereEnabled, ConfigEntry<bool> knownHiveProbeLineEnabled, ConfigEntry<bool> hivePickupSightLineEnabled) { this.enabled = enabled; this.allowGuestEnabled = allowGuestEnabled; this.overlayEnabled = overlayEnabled; this.hudEnabled = hudEnabled; this.beeMarkerEnabled = beeMarkerEnabled; this.hiveMarkerEnabled = hiveMarkerEnabled; this.knownHiveMarkerEnabled = knownHiveMarkerEnabled; this.playerMarkerEnabled = playerMarkerEnabled; this.playerSightLineEnabled = playerSightLineEnabled; this.beeSightRangeSphereEnabled = beeSightRangeSphereEnabled; this.hiveDefenseSphereEnabled = hiveDefenseSphereEnabled; this.knownHiveNearSphereEnabled = knownHiveNearSphereEnabled; this.knownHiveLineOfSightSphereEnabled = knownHiveLineOfSightSphereEnabled; this.knownHiveProbeLineEnabled = knownHiveProbeLineEnabled; this.hivePickupSightLineEnabled = hivePickupSightLineEnabled; } public static BeeOverlayConfiguration Bind(ConfigFile config) { ConfigEntry<bool> obj = BindGeneral(config, "Enabled", "Set to false to disable all BeeOverlay functionality."); ConfigEntry<bool> val = BindGeneral(config, "AllowGuestEnabled", "Set to false to disallow non-host players from using BeeOverlay when this player hosts the lobby."); ConfigEntry<bool> val2 = BindOverlay(config, "Enabled", "Set to false to hide every BeeOverlay element while keeping general functionality enabled."); ConfigEntry<bool> val3 = BindOverlay(config, "HudEnabled", "Set to false to hide BeeOverlay's HUD text while keeping enabled world guides available."); ConfigEntry<bool> val4 = BindOverlay(config, "BeeMarkerEnabled", "Set to false to hide bee markers."); ConfigEntry<bool> val5 = BindOverlay(config, "HiveMarkerEnabled", "Set to false to hide hive markers."); ConfigEntry<bool> val6 = BindOverlay(config, "KnownHiveMarkerEnabled", "Set to false to hide known-hive markers."); ConfigEntry<bool> val7 = BindOverlay(config, "PlayerMarkerEnabled", "Set to false to hide local-player markers."); ConfigEntry<bool> val8 = BindOverlay(config, "PlayerSightLineEnabled", "Set to false to hide bee-to-player sight lines."); ConfigEntry<bool> val9 = BindOverlay(config, "BeeSightRangeSphereEnabled", "Set to false to hide bee 16-unit sight-range spheres."); ConfigEntry<bool> val10 = BindOverlay(config, "HiveDefenseSphereEnabled", "Set to false to hide hive defense-range spheres."); ConfigEntry<bool> val11 = BindOverlay(config, "KnownHiveNearSphereEnabled", "Set to false to hide known-hive 4-unit spheres."); ConfigEntry<bool> val12 = BindOverlay(config, "KnownHiveLineOfSightSphereEnabled", "Set to false to hide known-hive 8-unit line-of-sight spheres."); ConfigEntry<bool> val13 = BindOverlay(config, "KnownHiveProbeLineEnabled", "Set to false to hide bee-to-known-hive probe lines."); ConfigEntry<bool> val14 = BindOverlay(config, "HivePickupSightLineEnabled", "Set to false to hide bee-to-hive pickup-proxy sight lines."); return new BeeOverlayConfiguration(obj, val, val2, val3, val4, val5, val6, val7, val8, val9, val10, val11, val12, val13, val14); } private static ConfigEntry<bool> BindGeneral(ConfigFile config, string key, string description) { return BindGeneral(config, key, defaultValue: true, description); } private static ConfigEntry<bool> BindGeneral(ConfigFile config, string key, bool defaultValue, string description) { return config.Bind<bool>("General", key, defaultValue, description); } private static ConfigEntry<bool> BindOverlay(ConfigFile config, string key, string description) { return config.Bind<bool>("Overlay", key, true, description); } } [HarmonyPatch(typeof(HUDManager))] internal static class HudUpdatePatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostfix(HUDManager __instance) { try { Plugin.Controller.AttachHostModPresence(__instance); } catch (Exception error) { LogCallbackFailure("Host-presence setup", error); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePostfix() { try { Plugin.Controller.HandleFrame(); } catch (Exception error) { LogCallbackFailure("Overlay update", error); } } private static void LogCallbackFailure(string operation, Exception error) { try { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogError((object)$"{operation} failed: {error}"); } } catch { } } } internal sealed class Overlay : IOverlayPresenter { 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, OverlayPresentationOptions options) { //IL_0030: 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_0080: 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_00ad: 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_00d4: 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_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_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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0102: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: 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_013b: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0256: 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_0280: 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_028c: 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_0295: 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) if ((Object)(object)worldRoot == (Object)null) { return; } worldRoot.SetActive(options.HasWorldGuides); if (options.BeeMarkerEnabled) { SetMarker(beeMarker, beeEye, 0.16f); } else { beeMarker.SetActive(false); } if (options.HiveMarkerEnabled) { SetMarker(hiveMarker, hive, 0.18f); } else { hiveMarker.SetActive(false); } if (options.BeeSightRangeSphereEnabled) { beeSightRangeSphere.Set(beeEye, 16f, BeeColor); } else { beeSightRangeSphere.SetVisible(visible: false); } if (options.HiveDefenseSphereEnabled) { defenseDistanceSphere.Set(hive, defenseDistance, HiveColor); } else { defenseDistanceSphere.SetVisible(visible: false); } if (localPlayer.HasValue) { Vector3 val = Vector3.up * -0.35f; Vector3 val2 = localPlayer.Value + val; Color color = (canSeeLocalPlayer ? PlayerColor : InactiveLineColor); if (options.PlayerMarkerEnabled) { SetMarker(playerMarker, val2, 0.16f); } else { playerMarker.SetActive(false); } if (options.PlayerSightLineEnabled) { SetWorldLine(visiblePlayerSightLine, beeEye, val2, color); ((Component)visiblePlayerSightLine).gameObject.SetActive(true); } else { ((Component)visiblePlayerSightLine).gameObject.SetActive(false); } } else { playerMarker.SetActive(false); ((Component)visiblePlayerSightLine).gameObject.SetActive(false); } Vector3 val3 = ToUnityVector3(hiveMissingProbe.LastKnownHivePosition) + Vector3.up * 0.35f; if (options.KnownHiveMarkerEnabled) { lastKnownHiveMarker.SetActive(true); lastKnownHiveMarker.transform.position = val3; float num = Mathf.Clamp(hiveMissingProbe.EyeToLastKnownHiveDistance * 0.03f, 0.14f, 0.32f); lastKnownHiveMarker.transform.localScale = Vector3.one * num; } else { lastKnownHiveMarker.SetActive(false); } if (options.KnownHiveNearSphereEnabled) { lastKnownHiveNearSphere.Set(val3, 4f, LastKnownHiveNearSphereColor); } else { lastKnownHiveNearSphere.SetVisible(visible: false); } if (options.KnownHiveLineOfSightSphereEnabled) { lastKnownHiveLineOfSightSphere.Set(val3, 8f, LastKnownHiveLineOfSightSphereColor); } else { lastKnownHiveLineOfSightSphere.SetVisible(visible: false); } if (options.KnownHiveProbeLineEnabled) { Color color2 = (hiveMissingProbe.CanEvaluateMissing ? LastKnownHiveColor : InactiveLineColor); SetWorldLine(beeEyeToLastKnownHiveLine, beeEye, val3, color2); ((Component)beeEyeToLastKnownHiveLine).gameObject.SetActive(true); } else { ((Component)beeEyeToLastKnownHiveLine).gameObject.SetActive(false); } if (options.HivePickupSightLineEnabled) { SetHiveSightProbe(beeEye, hiveSightProbe); } else { ((Component)beeEyeToHiveLine).gameObject.SetActive(false); } } private void SetHiveSightProbe(Vector3 beeEye, HiveSightProbe probe) { //IL_0006: 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_0015: 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_002f: 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_0034: 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_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) Vector3 end = ToUnityVector3(probe.HivePosition) + Vector3.up * 0.35f; Color color = (probe.CanSeePickupProxy ? PickupProxyColor : InactiveLineColor); SetWorldLine(beeEyeToHiveLine, beeEye, end, color); ((Component)beeEyeToHiveLine).gameObject.SetActive(true); } 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 VisiblePlayerSightLineRenderYOffset = -0.35f; 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 ManualLogSource logger; 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 RectTransform? hudRoot; private Text? statusText; private Transform? attachedHudContainer; private float nextWaitingLogTime; public Overlay(ManualLogSource logger) { //IL_001c: 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_003c: 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_005c: Unknown result type (might be due to invalid IL or missing references) this.logger = logger; } public bool TryPrepare(bool hudEnabled) { if (!hudEnabled) { HideHud(); return true; } return TryEnsureHudRoot(); } public void Present(OverlayFrame frame, OverlayPresentationOptions options, int? selectedBeeIdentity) { HashSet<int> hashSet = new HashSet<int>(); StringBuilder stringBuilder = new StringBuilder(); bool flag = options.HudEnabled && selectedBeeIdentity.HasValue; if (flag) { stringBuilder.Append($"Bee Overlay | bees={frame.Bees.Count}"); } foreach (BeeDiagnostic bee in frame.Bees) { bool flag2 = bee.Observation.Identity == selectedBeeIdentity; if (options.HasWorldGuides && flag2) { DrawBee(bee, hashSet, options); } if (flag && flag2) { stringBuilder.AppendLine(); stringBuilder.Append(GetBeeStatusLine(bee)); } } if (options.HasWorldGuides) { foreach (KeyValuePair<int, BeeView> view in views) { if (!hashSet.Contains(view.Key)) { view.Value.SetVisible(visible: false); } } } else { HideWorldGuides(); } if (flag) { SetStatus(stringBuilder.ToString()); } else { HideHud(); } } public void DisplayTip(HudTipMessage message) { try { HUDManager instance = HUDManager.Instance; if ((Object)(object)instance == (Object)null) { LogTipFailure(message.Token, "HUDManager is unavailable."); } else { instance.DisplayTip(message.HeaderText, message.BodyText, false, false, "LC_Tip1"); } } catch (Exception ex) { LogTipFailure(message.Token, ex.ToString()); } } private void LogTipFailure(string token, string detail) { try { logger.LogWarning((object)("Failed to display HUD tip '" + token + "': " + detail)); } catch { } } private bool TryEnsureHudRoot() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0124: 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_014e: 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_0177: 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) 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) { ((Component)hudRoot).gameObject.SetActive(true); 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; logger.LogInfo((object)("Overlay attached to HUDContainer='" + ((Object)val).name + "'.")); return true; } 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 void SetStatus(string text) { if ((Object)(object)statusText != (Object)null) { statusText.text = text; } } public void HideAll() { HideHud(); HideWorldGuides(); } private void HideHud() { if ((Object)(object)hudRoot != (Object)null) { ((Component)hudRoot).gameObject.SetActive(false); } } private void HideWorldGuides() { foreach (BeeView value in views.Values) { value.SetVisible(visible: false); } } public void LogWaitingForHud() { if (!(Time.realtimeSinceStartup < nextWaitingLogTime)) { nextWaitingLogTime = Time.realtimeSinceStartup + 5f; logger.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 }; } private void DrawBee(BeeDiagnostic bee, HashSet<int> seen, OverlayPresentationOptions options) { //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_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) //IL_0053: 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) BeeObservation observation = bee.Observation; HiveDiagnostic hive = bee.Hive; if (hive != null) { GetView(observation.Identity).SetSpatialGuides(ToUnityVector3(hive.Observation.Position) + Vector3.up * 0.35f, hive.Observation.DefenseDistance, ToUnityVector3(observation.EyePosition), (bee.LocalPlayer != null) ? new Vector3?(ToUnityVector3(bee.LocalPlayer.SightTargetPosition)) : ((Vector3?)null), observation.CanSeeLocalPlayer, hive.Missing, hive.Sight, options); seen.Add(observation.Identity); } } private static string GetBeeStatusLine(BeeDiagnostic bee) { //IL_006b: 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_00db: 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_0138: 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) BeeObservation observation = bee.Observation; HiveDiagnostic hive = bee.Hive; if (hive == null) { return Tag($"bee:{bee.DisplayNumber}", BeeColor) + " hive n/a"; } HiveSightProbe sight = hive.Sight; HiveMissingProbe missing = hive.Missing; return string.Join(" ", Tag($"bee:{bee.DisplayNumber}", BeeColor), Tag("bee-player=" + FmtDistance(bee.BeeToPlayerDistance) + "/" + SeenBlocked(observation.CanSeeLocalPlayer), PlayerColor), Tag("hive-player=" + FmtDistance(hive.PlayerToHiveDistance) + "/" + InsideOutside(hive.PlayerToHiveDistance, hive.Observation.DefenseDistance), HiveColor), Tag($"bee-hive={sight.EyeToHiveDistance:F2}u/{SeenBlocked(sight.CanSeePickupProxy)}", PickupProxyColor), Tag($"bee-knownHive={missing.EyeToLastKnownHiveDistance:F2}u/{SeenBlocked(!missing.LinecastBlocked)}", LastKnownHiveColor)); } 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 static Vector3 ToUnityVector3(Vector3Value value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new Vector3(value.X, value.Y, value.Z); } } } namespace BeeOverlay.Interop.InputUtils { internal sealed class InputUtilsActions : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction? CycleWorldGuideTargetKey { get; set; } } internal sealed class InputUtilsOverlayInput : IOverlayInput { private readonly InputUtilsActions inputActions; public bool CycleWorldGuideTargetTriggered { get { InputAction? cycleWorldGuideTargetKey = inputActions.CycleWorldGuideTargetKey; if (cycleWorldGuideTargetKey == null) { return false; } return cycleWorldGuideTargetKey.triggered; } } public InputUtilsOverlayInput(InputUtilsActions inputActions) { this.inputActions = inputActions; } } } namespace BeeOverlay.Interop.Game { internal sealed class BeeObservationSource : IOverlayObservationSource { private const float BeeEyeFallbackYOffset = 0.35f; private readonly FieldRef<RedLocustBees, bool>? syncedLastKnownHivePositionRef; public BeeObservationSource(ManualLogSource logger) { syncedLastKnownHivePositionRef = CreateSyncedLastKnownHivePositionRef(logger); } public OverlayFrameObservation Capture() { RedLocustBees[] array = Object.FindObjectsOfType<RedLocustBees>(); PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); PlayerObservation localPlayer = CreatePlayerObservation(val); BeeObservation[] array2 = new BeeObservation[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = CaptureBee(array[i], val); } return new OverlayFrameObservation(localPlayer, array2); } private BeeObservation CaptureBee(RedLocustBees bee, PlayerControllerB? localPlayer) { //IL_0006: 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_0037: 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_001b: 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_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) //IL_006a: 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_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_0087: 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_008f: 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_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_00c6: 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) Vector3 position = ((Component)bee).transform.position; Vector3 val = (((Object)(object)((EnemyAI)bee).eye != (Object)null) ? ((EnemyAI)bee).eye.position : (position + Vector3.up * 0.35f)); if ((Object)(object)bee.hive == (Object)null) { return new BeeObservation(((EnemyAI)bee).thisEnemyIndex, FromUnityVector3(val), null, canSeeLocalPlayer: false); } Vector3 position2 = ((Component)bee.hive).transform.position; PlayerControllerB val2 = ((EnemyAI)bee).CheckLineOfSightForPlayer(360f, 16, 1); Vector3 lastKnownHivePosition = bee.lastKnownHivePosition; LastKnownHiveObservation lastKnownHive = new LastKnownHiveObservation(FromUnityVector3(lastKnownHivePosition), IsLinecastBlocked(val, lastKnownHivePosition), GetSyncedLastKnownHivePosition(bee)); HiveObservation hive = new HiveObservation(FromUnityVector3(position2), bee.defenseDistance, IsLinecastBlocked(val, position2), lastKnownHive); return new BeeObservation(((EnemyAI)bee).thisEnemyIndex, FromUnityVector3(val), hive, (Object)(object)val2 != (Object)null && (Object)(object)val2 == (Object)(object)localPlayer); } private static PlayerObservation? CreatePlayerObservation(PlayerControllerB? player) { //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_0047: 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_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_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_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } Vector3 position = ((Component)player).transform.position; Vector3 value = (((Object)(object)player.gameplayCamera != (Object)null) ? ((Component)player.gameplayCamera).transform.position : (position + Vector3.up * 1.6f)); return new PlayerObservation(FromUnityVector3(position), FromUnityVector3(value)); } private static bool IsLinecastBlocked(Vector3 start, Vector3 end) { //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) if (!((Object)(object)StartOfRound.Instance == (Object)null)) { return Physics.Linecast(start, end, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } return true; } private bool? GetSyncedLastKnownHivePosition(RedLocustBees bee) { if (syncedLastKnownHivePositionRef == null) { return null; } return syncedLastKnownHivePositionRef.Invoke(bee); } private static FieldRef<RedLocustBees, bool>? CreateSyncedLastKnownHivePositionRef(ManualLogSource logger) { try { return AccessTools.FieldRefAccess<RedLocustBees, bool>("syncedLastKnownHivePosition"); } catch (Exception ex) { logger.LogWarning((object)("Could not access RedLocustBees.syncedLastKnownHivePosition: " + ex.Message)); return null; } } private static Vector3Value FromUnityVector3(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 Vector3Value(value.x, value.y, value.z); } } internal sealed class HostModPresenceBehaviour : NetworkBehaviour { private const int MaximumRequestAttempts = 3; private const float RequestRetryIntervalSeconds = 5f; private Coroutine? scheduledRequest; public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); Plugin.Controller.BeginHostModPresenceCheck(this); } public void ScheduleHostPresenceRequest(float delaySeconds) { if (scheduledRequest != null) { ((MonoBehaviour)this).StopCoroutine(scheduledRequest); } scheduledRequest = ((MonoBehaviour)this).StartCoroutine(RequestHostPresenceAfterDelay(delaySeconds)); } [ServerRpc(RequireOwnership = false)] public void RequestHostPresenceServerRpc(ServerRpcParams parameters = default(ServerRpcParams)) { //IL_0016: 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_0030: 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_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { ConfirmHostPresenceClientRpc(Plugin.Controller.GuestOverlayEnabled, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new ulong[1] { parameters.Receive.SenderClientId } } }); } } [ClientRpc] public void ConfirmHostPresenceClientRpc(bool guestOverlayAllowed, ClientRpcParams parameters = default(ClientRpcParams)) { Plugin.Controller.ConfirmHostModPresence(guestOverlayAllowed); } public override void OnNetworkDespawn() { if (scheduledRequest != null) { ((MonoBehaviour)this).StopCoroutine(scheduledRequest); scheduledRequest = null; } Plugin.Controller.ResetHostModPresence(); ((NetworkBehaviour)this).OnNetworkDespawn(); } private IEnumerator RequestHostPresenceAfterDelay(float delaySeconds) { float num = delaySeconds; int requestAttempts = 0; while (requestAttempts < 3) { yield return (object)new WaitForSecondsRealtime(num); num = 5f; switch (Plugin.Controller.TryRequestHostModPresence()) { case HostPresenceRequestResult.Stop: scheduledRequest = null; yield break; case HostPresenceRequestResult.Sent: requestAttempts++; break; } } scheduledRequest = null; } } internal enum HostPresenceRequestResult { Stop, Sent } internal sealed class HostModPresenceGate { private const float RequestDelaySeconds = 3f; private HostModPresenceBehaviour? behaviour; private bool hasHostResponded; public bool IsOverlayAllowed { get; private set; } = true; public void Attach(HUDManager hud) { behaviour = ((Component)hud).GetComponent<HostModPresenceBehaviour>() ?? ((Component)hud).gameObject.AddComponent<HostModPresenceBehaviour>(); BeginHostPresenceCheck(behaviour); } public void BeginHostPresenceCheck(HostModPresenceBehaviour bridge) { behaviour = bridge; NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsClient) { IsOverlayAllowed = true; return; } if (singleton.IsHost) { IsOverlayAllowed = true; return; } IsOverlayAllowed = false; hasHostResponded = false; bridge.ScheduleHostPresenceRequest(3f); } public HostPresenceRequestResult TryRequestHostPresence() { //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) if (hasHostResponded || IsOverlayAllowed) { return HostPresenceRequestResult.Stop; } NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !singleton.IsClient || singleton.IsHost) { return HostPresenceRequestResult.Stop; } if (behaviour == null) { return HostPresenceRequestResult.Stop; } behaviour.RequestHostPresenceServerRpc(); return HostPresenceRequestResult.Sent; } public void ConfirmHostPresence(bool guestOverlayAllowed) { NetworkManager singleton = NetworkManager.Singleton; if (singleton != null && singleton.IsClient && !singleton.IsHost) { hasHostResponded = true; IsOverlayAllowed = guestOverlayAllowed; } } public void Reset() { IsOverlayAllowed = true; hasHostResponded = false; } } } namespace BeeOverlay.Core { internal static class OverlayRules { public const float PlayerLineOfSightDistance = 16f; public const float HiveMissingNearDistance = 4f; public const float HiveMissingLineOfSightDistance = 8f; } } namespace BeeOverlay.Core.UseCases { internal sealed class BuildOverlayFrameUseCase { public OverlayFrame Execute(OverlayFrameObservation frameObservation) { BeeObservation[] array = frameObservation.Bees.OrderBy((BeeObservation bee) => bee.Identity).ToArray(); BeeDiagnostic[] array2 = new BeeDiagnostic[array.Length]; for (int num = 0; num < array.Length; num++) { array2[num] = BuildBeeDiagnostic(array[num], frameObservation.LocalPlayer, num + 1); } return new OverlayFrame(array2); } private static BeeDiagnostic BuildBeeDiagnostic(BeeObservation observation, PlayerObservation? localPlayer, int displayNumber) { if (observation.Hive == null) { return new BeeDiagnostic(observation, localPlayer, displayNumber, null, null); } HiveObservation hive = observation.Hive; float? beeToPlayerDistance = ((localPlayer != null) ? new float?(observation.EyePosition.DistanceTo(localPlayer.BodyPosition)) : ((float?)null)); float? playerToHiveDistance = localPlayer?.BodyPosition.DistanceTo(hive.Position); float num = observation.EyePosition.DistanceTo(hive.Position); HiveSightProbe sight = new HiveSightProbe(hive.Position, num, hive.PickupProxyLinecastBlocked, num < 16f); LastKnownHiveObservation lastKnownHive = hive.LastKnownHive; float num2 = observation.EyePosition.DistanceTo(lastKnownHive.Position); bool flag = num2 < 4f; bool flag2 = num2 < 8f && !lastKnownHive.LinecastBlocked; bool canEvaluateMissing = lastKnownHive.IsPositionSynced != false && (flag || flag2); HiveMissingProbe missing = new HiveMissingProbe(lastKnownHive.Position, num2, lastKnownHive.LinecastBlocked, flag, flag2, canEvaluateMissing, lastKnownHive.IsPositionSynced); return new BeeDiagnostic(observation, localPlayer, displayNumber, beeToPlayerDistance, new HiveDiagnostic(hive, playerToHiveDistance, sight, missing)); } } } namespace BeeOverlay.Core.State { internal sealed class WorldGuideSelection { private int? selectedBeeIdentity; public void Reset() { selectedBeeIdentity = null; } public WorldGuideSelectionResult Update(OverlayFrame frame, bool cycleTriggered) { int num = FindSelectedIndex(frame); if (selectedBeeIdentity.HasValue && num < 0) { selectedBeeIdentity = null; return new WorldGuideSelectionResult(selectedBeeIdentity, HudTipMessage.SelectedBeeRemoved); } if (!cycleTriggered) { return new WorldGuideSelectionResult(selectedBeeIdentity, null); } if (frame.Bees.Count == 0) { return new WorldGuideSelectionResult(selectedBeeIdentity, HudTipMessage.SelectNoBee); } if (!selectedBeeIdentity.HasValue) { selectedBeeIdentity = frame.Bees[0].Observation.Identity; } else if (num + 1 < frame.Bees.Count) { selectedBeeIdentity = frame.Bees[num + 1].Observation.Identity; } else { selectedBeeIdentity = null; } return new WorldGuideSelectionResult(selectedBeeIdentity, null); } private int FindSelectedIndex(OverlayFrame frame) { if (!selectedBeeIdentity.HasValue) { return -1; } for (int i = 0; i < frame.Bees.Count; i++) { if (frame.Bees[i].Observation.Identity == selectedBeeIdentity.Value) { return i; } } return -1; } } internal sealed class WorldGuideSelectionResult { public int? SelectedBeeIdentity { get; } public HudTipMessage? TipMessage { get; } public WorldGuideSelectionResult(int? selectedBeeIdentity, HudTipMessage? tipMessage) { SelectedBeeIdentity = selectedBeeIdentity; TipMessage = tipMessage; } } } namespace BeeOverlay.Core.Snapshots { internal sealed class OverlayFrameObservation { public PlayerObservation? LocalPlayer { get; } public IReadOnlyList<BeeObservation> Bees { get; } public OverlayFrameObservation(PlayerObservation? localPlayer, IReadOnlyList<BeeObservation> bees) { LocalPlayer = localPlayer; Bees = bees; } } internal sealed class PlayerObservation { public Vector3Value BodyPosition { get; } public Vector3Value SightTargetPosition { get; } public PlayerObservation(Vector3Value bodyPosition, Vector3Value sightTargetPosition) { BodyPosition = bodyPosition; SightTargetPosition = sightTargetPosition; } } internal sealed class BeeObservation { public int Identity { get; } public Vector3Value EyePosition { get; } public HiveObservation? Hive { get; } public bool CanSeeLocalPlayer { get; } public BeeObservation(int identity, Vector3Value eyePosition, HiveObservation? hive, bool canSeeLocalPlayer) { Identity = identity; EyePosition = eyePosition; Hive = hive; CanSeeLocalPlayer = canSeeLocalPlayer; } } internal sealed class HiveObservation { public Vector3Value Position { get; } public int DefenseDistance { get; } public bool PickupProxyLinecastBlocked { get; } public LastKnownHiveObservation LastKnownHive { get; } public HiveObservation(Vector3Value position, int defenseDistance, bool pickupProxyLinecastBlocked, LastKnownHiveObservation lastKnownHive) { Position = position; DefenseDistance = defenseDistance; PickupProxyLinecastBlocked = pickupProxyLinecastBlocked; LastKnownHive = lastKnownHive; } } internal sealed class LastKnownHiveObservation { public Vector3Value Position { get; } public bool LinecastBlocked { get; } public bool? IsPositionSynced { get; } public LastKnownHiveObservation(Vector3Value position, bool linecastBlocked, bool? isPositionSynced) { Position = position; LinecastBlocked = linecastBlocked; IsPositionSynced = isPositionSynced; } } internal readonly struct Vector3Value { public float X { get; } public float Y { get; } public float Z { get; } public Vector3Value(float x, float y, float z) { X = x; Y = y; Z = z; } public float DistanceTo(Vector3Value other) { float num = X - other.X; float num2 = Y - other.Y; float num3 = Z - other.Z; return (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3); } } } namespace BeeOverlay.Core.Presentation { internal sealed class HudTipMessage { private const string DefaultHeaderText = "BeeOverlay"; public static readonly HudTipMessage SelectNoBee = new HudTipMessage("select_no_bee", "BeeOverlay", "No bee found to select."); public static readonly HudTipMessage SelectedBeeRemoved = new HudTipMessage("selected_bee_removed", "BeeOverlay", "Selected bee was removed."); public static readonly HudTipMessage TargetSelectionNotPermitted = new HudTipMessage("target_selection_not_permitted", "BeeOverlay", "BeeOverlay is not permitted by the host."); public string Token { get; } public string HeaderText { get; } public string BodyText { get; } private HudTipMessage(string token, string headerText, string bodyText) { Token = token; HeaderText = headerText; BodyText = bodyText; } } } namespace BeeOverlay.Core.Ports { internal interface IOverlayInput { bool CycleWorldGuideTargetTriggered { get; } } internal interface IOverlayObservationSource { OverlayFrameObservation Capture(); } internal interface IOverlayPresenter { bool TryPrepare(bool hudEnabled); void Present(OverlayFrame frame, OverlayPresentationOptions options, int? selectedBeeIdentity); void DisplayTip(HudTipMessage message); void HideAll(); void LogWaitingForHud(); } } namespace BeeOverlay.Core.Models { internal sealed class OverlayFrame { public IReadOnlyList<BeeDiagnostic> Bees { get; } public OverlayFrame(IReadOnlyList<BeeDiagnostic> bees) { Bees = bees; } } internal sealed class BeeDiagnostic { public BeeObservation Observation { get; } public PlayerObservation? LocalPlayer { get; } public int DisplayNumber { get; } public float? BeeToPlayerDistance { get; } public HiveDiagnostic? Hive { get; } public BeeDiagnostic(BeeObservation observation, PlayerObservation? localPlayer, int displayNumber, float? beeToPlayerDistance, HiveDiagnostic? hive) { Observation = observation; LocalPlayer = localPlayer; DisplayNumber = displayNumber; BeeToPlayerDistance = beeToPlayerDistance; Hive = hive; } } internal sealed class HiveDiagnostic { public HiveObservation Observation { get; } public float? PlayerToHiveDistance { get; } public HiveSightProbe Sight { get; } public HiveMissingProbe Missing { get; } public HiveDiagnostic(HiveObservation observation, float? playerToHiveDistance, HiveSightProbe sight, HiveMissingProbe missing) { Observation = observation; PlayerToHiveDistance = playerToHiveDistance; Sight = sight; Missing = missing; } } internal sealed class HiveSightProbe { public Vector3Value 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(Vector3Value hivePosition, float eyeToHiveDistance, bool linecastBlocked, bool withinPlayerSightRange) { HivePosition = hivePosition; EyeToHiveDistance = eyeToHiveDistance; LinecastBlocked = linecastBlocked; WithinPlayerSightRange = withinPlayerSightRange; } } internal sealed class HiveMissingProbe { public Vector3Value 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(Vector3Value lastKnownHivePosition, float eyeToLastKnownHiveDistance, bool linecastBlocked, bool nearTrigger, bool lineOfSightTrigger, bool canEvaluateMissing, bool? syncedLastKnownHivePosition) { LastKnownHivePosition = lastKnownHivePosition; EyeToLastKnownHiveDistance = eyeToLastKnownHiveDistance; LinecastBlocked = linecastBlocked; NearTrigger = nearTrigger; LineOfSightTrigger = lineOfSightTrigger; CanEvaluateMissing = canEvaluateMissing; SyncedLastKnownHivePosition = syncedLastKnownHivePosition; } } internal readonly struct OverlayPresentationOptions { public bool HudEnabled { get; } public bool BeeMarkerEnabled { get; } public bool HiveMarkerEnabled { get; } public bool KnownHiveMarkerEnabled { get; } public bool PlayerMarkerEnabled { get; } public bool PlayerSightLineEnabled { get; } public bool BeeSightRangeSphereEnabled { get; } public bool HiveDefenseSphereEnabled { get; } public bool KnownHiveNearSphereEnabled { get; } public bool KnownHiveLineOfSightSphereEnabled { get; } public bool KnownHiveProbeLineEnabled { get; } public bool HivePickupSightLineEnabled { get; } public bool HasWorldGuides { get { if (!BeeMarkerEnabled && !HiveMarkerEnabled && !KnownHiveMarkerEnabled && !PlayerMarkerEnabled && !PlayerSightLineEnabled && !BeeSightRangeSphereEnabled && !HiveDefenseSphereEnabled && !KnownHiveNearSphereEnabled && !KnownHiveLineOfSightSphereEnabled && !KnownHiveProbeLineEnabled) { return HivePickupSightLineEnabled; } return true; } } public bool HasVisibleElement { get { if (!HudEnabled) { return HasWorldGuides; } return true; } } public OverlayPresentationOptions(bool hudEnabled, bool beeMarkerEnabled, bool hiveMarkerEnabled, bool knownHiveMarkerEnabled, bool playerMarkerEnabled, bool playerSightLineEnabled, bool beeSightRangeSphereEnabled, bool hiveDefenseSphereEnabled, bool knownHiveNearSphereEnabled, bool knownHiveLineOfSightSphereEnabled, bool knownHiveProbeLineEnabled, bool hivePickupSightLineEnabled) { HudEnabled = hudEnabled; BeeMarkerEnabled = beeMarkerEnabled; HiveMarkerEnabled = hiveMarkerEnabled; KnownHiveMarkerEnabled = knownHiveMarkerEnabled; PlayerMarkerEnabled = playerMarkerEnabled; PlayerSightLineEnabled = playerSightLineEnabled; BeeSightRangeSphereEnabled = beeSightRangeSphereEnabled; HiveDefenseSphereEnabled = hiveDefenseSphereEnabled; KnownHiveNearSphereEnabled = knownHiveNearSphereEnabled; KnownHiveLineOfSightSphereEnabled = knownHiveLineOfSightSphereEnabled; KnownHiveProbeLineEnabled = knownHiveProbeLineEnabled; HivePickupSightLineEnabled = hivePickupSightLineEnabled; } } } namespace BeeOverlay.Core.Handlers { internal sealed class FrameHandler { private readonly IOverlayInput overlayInput; private readonly IOverlayObservationSource observationSource; private readonly IOverlayPresenter presenter; private readonly BuildOverlayFrameUseCase buildOverlayFrameUseCase; private readonly WorldGuideSelection worldGuideSelection; public FrameHandler(IOverlayInput overlayInput, IOverlayObservationSource observationSource, IOverlayPresenter presenter, BuildOverlayFrameUseCase buildOverlayFrameUseCase, WorldGuideSelection worldGuideSelection) { this.overlayInput = overlayInput; this.observationSource = observationSource; this.presenter = presenter; this.buildOverlayFrameUseCase = buildOverlayFrameUseCase; this.worldGuideSelection = worldGuideSelection; } public void HandleFrame(bool enabled, bool targetSelectionAllowed, OverlayPresentationOptions options) { if (!enabled || !options.HasVisibleElement) { presenter.HideAll(); return; } if (!targetSelectionAllowed) { presenter.HideAll(); if (overlayInput.CycleWorldGuideTargetTriggered) { presenter.DisplayTip(HudTipMessage.TargetSelectionNotPermitted); } return; } if (!presenter.TryPrepare(options.HudEnabled)) { presenter.HideAll(); presenter.LogWaitingForHud(); return; } OverlayFrameObservation frameObservation = observationSource.Capture(); OverlayFrame frame = buildOverlayFrameUseCase.Execute(frameObservation); WorldGuideSelectionResult worldGuideSelectionResult = worldGuideSelection.Update(frame, overlayInput.CycleWorldGuideTargetTriggered); if (worldGuideSelectionResult.TipMessage != null) { presenter.DisplayTip(worldGuideSelectionResult.TipMessage); } presenter.Present(frame, options, worldGuideSelectionResult.SelectedBeeIdentity); } public void ResetLobbySession() { worldGuideSelection.Reset(); presenter.HideAll(); } } }