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 NearbyPanel v1.1.0
NearbyPanel.Core.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("NearbyPanel.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+5690fb2d4691b8683a13f211ad9cb433667b3b27")] [assembly: AssemblyProduct("NearbyPanel.Core")] [assembly: AssemblyTitle("NearbyPanel.Core")] [assembly: AssemblyVersion("1.1.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [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; } } [EditorBrowsable(EditorBrowsableState.Never)] internal static class IsExternalInit { } } namespace NearbyPanel.Core { public enum Awareness { Calm, Tracking, Alerted } public sealed record Breeding(int LovePoints, int RequiredLovePoints, bool Pregnant, float? PregnancySecondsLeft, float PregnancyDuration, string OffspringPrefab, string PartnerPrefab, bool SeparatePartner, bool NeedsPartner, float CrowdRange, int MaxCrowd, float PartnerRange, bool Hungry, int? Crowd = null, int? Partners = null, string? NearestCrowder = null, float? NearestCrowderDistance = null, bool PartnerHungry = false, bool PartnerPregnant = false, float? PartnerPregnancySecondsLeft = null, float? PartnerPregnancyProgress = null) { public float? PregnancyProgress { get { if (Pregnant) { float? pregnancySecondsLeft = PregnancySecondsLeft; if (pregnancySecondsLeft.HasValue) { float valueOrDefault = pregnancySecondsLeft.GetValueOrDefault(); if (PregnancyDuration > 0f) { return 1f - ((valueOrDefault < 0f) ? 0f : ((valueOrDefault > PregnancyDuration) ? PregnancyDuration : valueOrDefault)) / PregnancyDuration; } } } return null; } } public bool IsCrowded { get { int? crowd = Crowd; if (crowd.HasValue) { int valueOrDefault = crowd.GetValueOrDefault(); return valueOrDefault >= MaxCrowd; } return false; } } public bool LacksPartner { get { if (NeedsPartner) { int? partners = Partners; if (partners.HasValue) { int valueOrDefault = partners.GetValueOrDefault(); return valueOrDefault < (SeparatePartner ? 1 : 2); } } return false; } } } public static class BreedingRules { public static float Reach(IEnumerable<NearbyEntity> found, Vec3 viewer, float radius) { float num = 0f; foreach (NearbyEntity item in found) { Breeding breeding = item.Breeding; if ((object)breeding != null && !(Geometry.Distance(viewer, item.Position) > radius)) { if (breeding.CrowdRange > num) { num = breeding.CrowdRange; } if (breeding.PartnerRange > num) { num = breeding.PartnerRange; } } } return num; } public static void Resolve(IList<NearbyEntity> found) { for (int i = 0; i < found.Count; i++) { NearbyEntity nearbyEntity = found[i]; Breeding breeding = nearbyEntity.Breeding; if ((object)breeding == null || nearbyEntity.Prefab == null) { continue; } int num = 0; int num2 = 0; NearbyEntity nearbyEntity2 = null; float num3 = float.MaxValue; bool partnerHungry = false; bool partnerPregnant = false; float? num4 = null; float? partnerPregnancyProgress = null; foreach (NearbyEntity item in found) { float num5 = Geometry.Distance(nearbyEntity.Position, item.Position); bool flag = num5 <= breeding.PartnerRange && item.Prefab == breeding.PartnerPrefab && item.ReadyToMate; if (flag) { num2++; } else if (num5 <= breeding.PartnerRange && item.Prefab == breeding.PartnerPrefab && (object)item != nearbyEntity) { Breeding breeding2 = item.Breeding; if ((object)breeding2 != null) { if (breeding2.Pregnant) { partnerPregnant = true; float? pregnancySecondsLeft = breeding2.PregnancySecondsLeft; if (pregnancySecondsLeft.HasValue) { float valueOrDefault = pregnancySecondsLeft.GetValueOrDefault(); if (!num4.HasValue || valueOrDefault < num4) { num4 = valueOrDefault; partnerPregnancyProgress = breeding2.PregnancyProgress; } } } else if (breeding2.Hungry) { partnerHungry = true; } } } if (num5 <= breeding.CrowdRange && (item.Prefab == nearbyEntity.Prefab || item.Prefab == breeding.OffspringPrefab)) { num++; if ((object)item != nearbyEntity && !flag && num5 < num3) { nearbyEntity2 = item; num3 = num5; } } } found[i] = nearbyEntity with { Breeding = breeding with { Crowd = num, Partners = num2, NearestCrowder = nearbyEntity2?.Name, NearestCrowderDistance = ((nearbyEntity2 != null) ? new float?(num3) : ((float?)null)), PartnerHungry = partnerHungry, PartnerPregnant = partnerPregnant, PartnerPregnancySecondsLeft = num4, PartnerPregnancyProgress = partnerPregnancyProgress } }; } } } public enum DirectionFormat { Degrees, Relative, Compass, Arrow } public enum EntityKind { Creature, Tameable, Player } public static class Geometry { public static float GroundDistance(Vec3 from, Vec3 to) { float num = to.X - from.X; float num2 = to.Z - from.Z; return (float)Math.Sqrt(num * num + num2 * num2); } public static float Distance(Vec3 from, Vec3 to) { float num = to.X - from.X; float num2 = to.Y - from.Y; float num3 = to.Z - from.Z; return (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3); } public static float HeightDelta(Vec3 from, Vec3 to) { return to.Y - from.Y; } public static float RelativeBearing(Vec3 from, Vec3 forward, Vec3 to) { float num = to.X - from.X; float num2 = to.Z - from.Z; if (num == 0f && num2 == 0f) { return 0f; } double num3 = Math.Atan2(num, num2); double num4 = Math.Atan2(forward.X, forward.Z); return (float)Normalise((num3 - num4) * 180.0 / Math.PI); } public static string RelativeHeading(float relativeBearing) { return RelativeSector(relativeBearing) switch { 0 => "F", 1 => "FR", 2 => "R", 3 => "BR", 4 => "B", 5 => "BL", 6 => "L", _ => "FL", }; } public static string RelativeArrow(float relativeBearing) { if (float.IsNaN(relativeBearing) || float.IsInfinity(relativeBearing)) { return "?"; } return RelativeSector(relativeBearing) switch { 0 => "↑", 1 => "↗", 2 => "→", 3 => "↘", 4 => "↓", 5 => "↙", 6 => "←", _ => "↖", }; } private static int RelativeSector(float relativeBearing) { double num = Normalise(relativeBearing); if (num < 0.0) { num += 360.0; } return (int)Math.Floor(num / 45.0 + 0.5) % 8; } public static float CompassBearing(Vec3 from, Vec3 to) { float num = to.X - from.X; float num2 = to.Z - from.Z; if (num == 0f && num2 == 0f) { return 0f; } double num3 = Math.Atan2(num, num2) * 180.0 / Math.PI; if (num3 < 0.0) { num3 += 360.0; } return (float)num3; } public static string CompassPoint(float compassBearing) { double num = (double)compassBearing % 360.0; if (num < 0.0) { num += 360.0; } return ((int)Math.Floor(num / 45.0 + 0.5) % 8) switch { 0 => "N", 1 => "NE", 2 => "E", 3 => "SE", 4 => "S", 5 => "SW", 6 => "W", _ => "NW", }; } public static string DegreesLabel(float relativeBearing) { if (float.IsNaN(relativeBearing) || float.IsInfinity(relativeBearing)) { return "?"; } double num = Normalise(relativeBearing); int num2 = (int)((num < 0.0) ? Math.Ceiling(num - 0.5) : Math.Floor(num + 0.5)); if (num2 == -180) { num2 = 180; } return num2.ToString(CultureInfo.InvariantCulture) + "°"; } private static double Normalise(double degrees) { degrees %= 360.0; if (degrees <= -180.0) { degrees += 360.0; } else if (degrees > 180.0) { degrees -= 360.0; } return degrees; } } public sealed record NearbyEntity(string Name, EntityKind Kind, Vec3 Position, int Level, string? Status, float? TamingProgress, Awareness Awareness = Awareness.Calm, bool Hostile = false, bool? TargetsYou = null, float? GrowthProgress = null, bool HasGivenName = false, float? TamingSecondsLeft = null, float? GrowthSecondsLeft = null, string? Prefab = null, bool ReadyToMate = true, Breeding? Breeding = null); public static class NearbyList { public static IReadOnlyList<NearbyEntity> Build(IEnumerable<NearbyEntity> found, Vec3 viewer, float radius, int limit, Func<NearbyEntity, bool>? include = null, bool namedFirst = false) { IEnumerable<NearbyEntity> source = found.Where((NearbyEntity e) => Geometry.Distance(viewer, e.Position) <= radius); if (include != null) { source = source.Where(include); } return (from e in source orderby namedFirst && !e.HasGivenName, Geometry.Distance(viewer, e.Position) select e).ThenBy<NearbyEntity, string>((NearbyEntity e) => e.Name, StringComparer.Ordinal).Take(limit).ToList(); } public static bool IsTameable(NearbyEntity entity) { return entity.Kind == EntityKind.Tameable; } public static bool IsCreature(NearbyEntity entity) { return entity.Kind != EntityKind.Player; } public static bool MatchesText(NearbyEntity entity, string? text) { if (string.IsNullOrWhiteSpace(text)) { return true; } string value = text.Trim(); return (entity.Name ?? string.Empty).IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0; } public static Func<NearbyEntity, bool> Filter(string? text) { return (NearbyEntity entity) => IsCreature(entity) && MatchesText(entity, text); } } public enum PanelAnchor { TopLeft, TopRight, BottomLeft, BottomRight } public readonly struct PanelRect { public float X { get; } public float Y { get; } public float Width { get; } public float Height { get; } public PanelRect(float x, float y, float width, float height) { X = x; Y = y; Width = width; Height = height; } } public static class PanelLayout { public const float Padding = 8f; public static float RowHeight(int fontSize) { float num = (float)fontSize * 1.35f; if (!(num < 14f)) { return num; } return 14f; } public static int VisibleRows(int rowCount, int maxVisibleRows) { if (rowCount < 0) { return 0; } int num = ((maxVisibleRows >= 0) ? maxVisibleRows : 0); if (rowCount >= num) { return num; } return rowCount; } public static float Height(int rowCount, int maxVisibleRows, int fontSize) { int num = VisibleRows(rowCount, maxVisibleRows); bool flag = rowCount > num; float num2 = 2f + (float)num + (flag ? 1f : 0f); return 16f + num2 * RowHeight(fontSize); } public static PanelRect Place(PanelAnchor anchor, float marginX, float marginY, float width, float height, float screenWidth, float screenHeight) { float num = Clamp(width, 0f, screenWidth); float num2 = Clamp(height, 0f, screenHeight); float num3 = ((marginX < 0f) ? 0f : marginX); float num4 = ((marginY < 0f) ? 0f : marginY); bool num5 = anchor == PanelAnchor.TopRight || anchor == PanelAnchor.BottomRight; bool flag = anchor == PanelAnchor.BottomLeft || anchor == PanelAnchor.BottomRight; float value = (num5 ? (screenWidth - num - num3) : num3); float value2 = (flag ? (screenHeight - num2 - num4) : num4); return new PanelRect(Clamp(value, 0f, Max(0f, screenWidth - num)), Clamp(value2, 0f, Max(0f, screenHeight - num2)), num, num2); } public static void ColumnEdges(float[] widths, float innerWidth, float[] edges) { float num = ((innerWidth < 0f) ? 0f : innerWidth); float num2 = 0f; for (int i = 0; i < widths.Length; i++) { edges[i] = num2; num2 = Clamp(num2 + ((widths[i] < 0f) ? 0f : widths[i]), 0f, num); } edges[widths.Length] = num2; edges[widths.Length + 1] = num; } private static float Clamp(float value, float min, float max) { if (!(value < min)) { if (!(value > max)) { return value; } return max; } return min; } private static float Max(float a, float b) { if (!(a > b)) { return b; } return a; } } public enum ProgressFormat { Percent, Time, Both } public sealed record RowCells(string Name, string Distance, string Direction, string Altitude, string Level, string Awareness, string Status, bool Progress = false, bool Threat = false); public static class RowFormatter { private readonly record struct Column(string Name, int Width, bool RightAligned); private static readonly Column[] Layout = new Column[7] { new Column("NAME", 18, RightAligned: false), new Column("DIST", 6, RightAligned: true), new Column("DIR", 5, RightAligned: true), new Column("ALT", 4, RightAligned: true), new Column("★", 2, RightAligned: true), new Column("ALERT", 5, RightAligned: false), new Column("STATUS", 0, RightAligned: false) }; public static string[] ColumnNames => Layout.Select((Column c) => c.Name).ToArray(); public static bool[] ColumnRightAligned => Layout.Select((Column c) => c.RightAligned).ToArray(); public static string Header => Compose(Layout.Select((Column c) => c.Name).ToArray()); public static RowCells Cells(NearbyEntity entity, Vec3 viewer, Vec3 forward, DirectionFormat format = DirectionFormat.Degrees, ProgressFormat progress = ProgressFormat.Percent) { float value = Geometry.GroundDistance(viewer, entity.Position); float value2 = Geometry.HeightDelta(viewer, entity.Position); string direction = Direction(entity, viewer, forward, format); return new RowCells(entity.Name ?? string.Empty, Format(value, "0.0"), direction, Format(value2, "+0;-0;0"), Stars(entity.Level), AwarenessLabel(entity), StatusText(entity, progress), HasProgress(entity), entity.Hostile && entity.Awareness == Awareness.Alerted); } public static string StatusText(NearbyEntity entity, ProgressFormat format = ProgressFormat.Percent) { string text = entity.Status ?? string.Empty; float? tamingProgress = entity.TamingProgress; if (tamingProgress.HasValue) { float valueOrDefault = tamingProgress.GetValueOrDefault(); string percent = Percent(valueOrDefault); tamingProgress = entity.TamingSecondsLeft; object time; if (tamingProgress.HasValue) { float valueOrDefault2 = tamingProgress.GetValueOrDefault(); time = Duration(valueOrDefault2) + " fed"; } else { time = null; } string text2 = Progress(percent, (string?)time, format); if (text.Length != 0) { return text2 + " " + text; } return text2; } tamingProgress = entity.GrowthProgress; if (tamingProgress.HasValue) { float valueOrDefault3 = tamingProgress.GetValueOrDefault(); string text3 = Percent(valueOrDefault3) + " grown"; tamingProgress = entity.GrowthSecondsLeft; string text4; if (tamingProgress.HasValue) { float valueOrDefault4 = tamingProgress.GetValueOrDefault(); text4 = format switch { ProgressFormat.Time => "grown in " + Duration(valueOrDefault4), ProgressFormat.Both => text3 + " · " + Duration(valueOrDefault4), _ => text3, }; } else { text4 = text3; } string text5 = text4; if (text.Length != 0) { return text5 + ", " + text; } return text5; } Breeding breeding = entity.Breeding; if ((object)breeding != null) { string text6 = BreedingText(breeding, format); if (text6 != null) { return text6; } } if (text.Length == 0 && entity.Hostile) { return "hostile"; } return text; } public static bool HasProgress(NearbyEntity entity) { if (!entity.TamingProgress.HasValue && !entity.GrowthProgress.HasValue) { return entity.Breeding?.Pregnant ?? false; } return true; } private static string? BreedingText(Breeding breeding, ProgressFormat format) { if (breeding.Pregnant) { float? pregnancySecondsLeft = breeding.PregnancySecondsLeft; if (pregnancySecondsLeft.HasValue) { float valueOrDefault = pregnancySecondsLeft.GetValueOrDefault(); pregnancySecondsLeft = breeding.PregnancyProgress; if (pregnancySecondsLeft.HasValue) { float valueOrDefault2 = pregnancySecondsLeft.GetValueOrDefault(); if (!(valueOrDefault <= 0f)) { return "Pregnant " + Progress(Percent(valueOrDefault2), Duration(valueOrDefault), format); } return "Pregnant, due"; } } return "Pregnant"; } if (breeding.Hungry) { return null; } if (breeding.IsCrowded) { string text = "Crowded " + Count(breeding.Crowd.Value) + "/" + Count(breeding.MaxCrowd); string nearestCrowder = breeding.NearestCrowder; if (nearestCrowder != null) { float? pregnancySecondsLeft = breeding.NearestCrowderDistance; if (pregnancySecondsLeft.HasValue) { float valueOrDefault3 = pregnancySecondsLeft.GetValueOrDefault(); return text + " · " + nearestCrowder + " " + Format(valueOrDefault3, "0.0") + " m"; } } return text; } if (breeding.LacksPartner) { if (breeding.PartnerHungry) { return "Partner hungry"; } if (breeding.PartnerPregnant) { float? pregnancySecondsLeft = breeding.PartnerPregnancySecondsLeft; if (pregnancySecondsLeft.HasValue) { float valueOrDefault4 = pregnancySecondsLeft.GetValueOrDefault(); pregnancySecondsLeft = breeding.PartnerPregnancyProgress; if (pregnancySecondsLeft.HasValue) { float valueOrDefault5 = pregnancySecondsLeft.GetValueOrDefault(); if (!(valueOrDefault4 <= 0f)) { return "Partner pregnant " + Progress(Percent(valueOrDefault5), Duration(valueOrDefault4), format); } return "Partner pregnant, due"; } } return "Partner pregnant"; } return "No partner"; } return "Love " + Count(breeding.LovePoints) + "/" + Count(breeding.RequiredLovePoints); } private static string Count(int value) { return value.ToString(CultureInfo.InvariantCulture); } private static string Progress(string percent, string? time, ProgressFormat format) { if (time == null) { return percent; } return format switch { ProgressFormat.Time => time, ProgressFormat.Both => percent + " · " + time, _ => percent, }; } public static string Duration(float seconds) { if (float.IsNaN(seconds) || float.IsInfinity(seconds) || seconds < 0f) { return "?"; } long num = (long)Math.Ceiling(seconds); if (num < 60) { return num.ToString(CultureInfo.InvariantCulture) + " s"; } long num2 = (num + 59) / 60; if (num2 < 60) { return num2.ToString(CultureInfo.InvariantCulture) + " min"; } return (num2 / 60).ToString(CultureInfo.InvariantCulture) + " h " + (num2 % 60).ToString("00", CultureInfo.InvariantCulture); } private static string Direction(NearbyEntity entity, Vec3 viewer, Vec3 forward, DirectionFormat format) { if (format == DirectionFormat.Compass) { return Geometry.CompassPoint(Geometry.CompassBearing(viewer, entity.Position)); } float relativeBearing = Geometry.RelativeBearing(viewer, forward, entity.Position); return format switch { DirectionFormat.Relative => Geometry.RelativeHeading(relativeBearing), DirectionFormat.Arrow => Geometry.RelativeArrow(relativeBearing), _ => Geometry.DegreesLabel(relativeBearing), }; } public static string Row(NearbyEntity entity, Vec3 viewer, Vec3 forward, DirectionFormat format = DirectionFormat.Degrees, ProgressFormat progress = ProgressFormat.Percent) { RowCells rowCells = Cells(entity, viewer, forward, format, progress); return Compose(new string[7] { rowCells.Name, rowCells.Distance, rowCells.Direction, rowCells.Altitude, rowCells.Level, rowCells.Awareness, rowCells.Status }); } public static string AwarenessLabel(NearbyEntity entity) { return entity.Awareness switch { Awareness.Alerted => (entity.TargetsYou == true) ? "!you" : "!", Awareness.Tracking => "?", _ => "-", }; } public static string Stars(int level) { int num = level - 1; if (num > 0) { return num.ToString(CultureInfo.InvariantCulture); } return string.Empty; } public static string Percent(float progress) { if (float.IsNaN(progress)) { return "?"; } return ((int)(Clamp01(progress) * 100f)).ToString(CultureInfo.InvariantCulture) + "%"; } public static string Truncate(string value, int max) { if (value == null || max <= 0) { return string.Empty; } if (value.Length <= max) { return value; } if (max != 1) { return value.Substring(0, max - 1) + "…"; } return "…"; } private static string Compose(string[] values) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < Layout.Length; i++) { Column column = Layout[i]; string value = ((i < values.Length) ? (values[i] ?? string.Empty) : string.Empty); if (i > 0) { stringBuilder.Append(' '); } if (column.Width <= 0) { stringBuilder.Append(value); continue; } value = Truncate(value, column.Width); stringBuilder.Append(column.RightAligned ? value.PadLeft(column.Width) : value.PadRight(column.Width)); } return stringBuilder.ToString().TrimEnd(Array.Empty<char>()); } private static string Format(float value, string format) { if (float.IsNaN(value) || float.IsInfinity(value)) { return "?"; } return value.ToString(format, CultureInfo.InvariantCulture); } private static float Clamp01(float value) { if (!(value < 0f)) { if (!(value > 1f)) { return value; } return 1f; } return 0f; } public static int[] ColumnOffsets() { int[] array = new int[Layout.Length]; int num = 0; for (int i = 0; i < Layout.Length; i++) { array[i] = num; num += Math.Max(Layout[i].Width, 0) + 1; } return array; } } public static class TamingBoost { public static float SecondsLeft(float remaining, int boostedPlayers, float multiplier) { if (boostedPlayers <= 0 || !(multiplier > 0f)) { return remaining; } return (float)((double)remaining / Math.Pow(multiplier, boostedPlayers)); } } public readonly struct Vec3 { public readonly float X; public readonly float Y; public readonly float Z; public Vec3(float x, float y, float z) { X = x; Y = y; Z = z; } } }
NearbyPanel.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.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using NearbyPanel.Core; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] 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; } } } public sealed class ConfigurationManagerAttributes { public int? Order; public bool? IsAdvanced; public bool? Browsable; public bool? ReadOnly; public string? Category; public string? DispName; public string? Description; public bool? ShowRangeAsPercent; public bool? HideDefaultButton; public bool? HideSettingName; public Action<ConfigEntryBase>? CustomDrawer; } namespace NearbyPanel { internal static class DumpCommand { private const string Name = "nearby_dump"; public static void Register(EntityScanner scanner) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand("nearby_dump", "lists the creatures near you, nearest first", (ConsoleEvent)delegate(ConsoleEventArgs args) { Run(args, scanner); }, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void Run(ConsoleEventArgs args, EntityScanner scanner) { //IL_0093: 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_00a3: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList<NearbyEntity> readOnlyList = scanner.Scan(FilterState.Predicate(), Plugin.NamedFirst); string text = $"{50f:0} m{FilterState.Describe()}"; if (readOnlyList.Count == 0) { Write(args, ((Object)(object)Player.m_localPlayer == (Object)null) ? "no local player yet" : ("nothing within " + text)); return; } Write(args, $"{readOnlyList.Count} within {text}"); Write(args, RowFormatter.Header); foreach (NearbyEntity item in readOnlyList) { Write(args, RowFormatter.Row(item, scanner.Viewer, scanner.Forward, Plugin.DirectionFormat, Plugin.ProgressFormat)); Breeding breeding = item.Breeding; if (breeding != null) { WriteBreeding(args, item, breeding, scanner.Found); } } } private static void WriteBreeding(ConsoleEventArgs args, NearbyEntity self, Breeding breeding, IReadOnlyList<NearbyEntity> found) { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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) Write(args, " " + self.Prefab + ": offspring " + breeding.OffspringPrefab + ", partner " + breeding.PartnerPrefab + ", " + $"crowd {breeding.Crowd}/{breeding.MaxCrowd} in {breeding.CrowdRange:0.#} m, " + $"partners {breeding.Partners} in {breeding.PartnerRange:0.#} m, love {breeding.LovePoints}/{breeding.RequiredLovePoints}"); foreach (NearbyEntity item in found) { if (!(item.Prefab != self.Prefab) || !(item.Prefab != breeding.OffspringPrefab) || !(item.Prefab != breeding.PartnerPrefab)) { float num = Geometry.Distance(self.Position, item.Position); if (!(num > breeding.CrowdRange + 10f)) { string arg = ((num <= breeding.CrowdRange) ? "crowd" : "-"); Write(args, $" {item.Name} {item.Prefab} 3d {num:0.0} ground {Geometry.GroundDistance(self.Position, item.Position):0.0} " + $"dy {item.Position.Y - self.Position.Y:+0.0;-0.0} ready {item.ReadyToMate} {arg}"); } } } } private static void Write(ConsoleEventArgs args, string line) { if ((Object)(object)args.Context != (Object)null) { args.Context.AddString(line); } Plugin.Log.LogInfo((object)line); } } internal static class EntityMapper { private static readonly List<Player> NearbyPlayers = new List<Player>(); public static Vec3 ToVec3(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) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vec3(value.x, value.y, value.z); } public static NearbyEntity? FromCharacter(Character character) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown if ((Object)(object)character == (Object)null || character.IsDead()) { return null; } if ((Object)(object)character == (Object)(object)Player.m_localPlayer) { return null; } Tameable component = ((Component)character).GetComponent<Tameable>(); EntityKind val = (EntityKind)(character.IsPlayer() ? 2 : (((Object)(object)component != (Object)null) ? 1 : 0)); BaseAI baseAI = character.GetBaseAI(); string text = GivenName(component); (float? Progress, float? SecondsLeft) tuple = Taming(component); float? item = tuple.Progress; float? item2 = tuple.SecondsLeft; (float? Progress, float? SecondsLeft) tuple2 = Growth(character); float? item3 = tuple2.Progress; float? item4 = tuple2.SecondsLeft; Procreation component2 = ((Component)character).GetComponent<Procreation>(); return new NearbyEntity(text ?? Localize(character.m_name), val, ToVec3(((Component)character).transform.position), character.GetLevel(), ((Object)(object)component != (Object)null) ? Localize(component.GetStatusString()) : null, item, AwarenessOf(baseAI), IsHostileToPlayer(baseAI), TargetsLocalPlayer(character, baseAI), item3, text != null, item2, item4, ((Object)((Component)character).gameObject).name, (Object)(object)component2 == (Object)null || component2.ReadyForProcreation(), BreedingOf(component2, component)); } private static Breeding? BreedingOf(Procreation? procreation, Tameable? tameable) { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown if ((Object)(object)procreation == (Object)null || (Object)(object)tameable == (Object)null || !tameable.IsTamed() || (Object)(object)procreation.m_offspring == (Object)null) { return null; } ZDO val = ZdoOf((Component)(object)procreation); if (val == null) { return null; } long num = val.GetLong(ZDOVars.s_pregnant, 0L); bool flag = num != 0; float? num2 = null; if (flag && (Object)(object)ZNet.instance != (Object)null && num > 0) { DateTime maxValue = DateTime.MaxValue; if (num <= maxValue.Ticks) { double totalSeconds = (ZNet.instance.GetTime() - new DateTime(num)).TotalSeconds; if (!double.IsNaN(totalSeconds)) { num2 = (float)((double)procreation.m_pregnancyDuration - totalSeconds); } } } GameObject seperatePartner = procreation.m_seperatePartner; return new Breeding(val.GetInt(ZDOVars.s_lovePoints, 0), procreation.m_requiredLovePoints, flag, num2, procreation.m_pregnancyDuration, ((Object)procreation.m_offspring).name + "(Clone)", ((Object)(object)seperatePartner != (Object)null) ? (((Object)seperatePartner).name + "(Clone)") : ((Object)((Component)procreation).gameObject).name, (Object)(object)seperatePartner != (Object)null, (Object)(object)procreation.m_noPartnerOffspring == (Object)null, procreation.m_totalCheckRange, procreation.m_maxCreatures, procreation.m_partnerCheckRange, tameable.IsHungry(), (int?)null, (int?)null, (string)null, (float?)null, false, false, (float?)null, (float?)null); } private static string? GivenName(Tameable? tameable) { if ((Object)(object)tameable != (Object)null && tameable.IsTamed()) { ZDO val = ZdoOf((Component)(object)tameable); if (val != null) { string text = val.GetString(ZDOVars.s_tamedName, string.Empty); if (!string.IsNullOrEmpty(text)) { return text; } } } return null; } private static (float? Progress, float? SecondsLeft) Taming(Tameable? tameable) { if ((Object)(object)tameable == (Object)null || tameable.IsTamed()) { return (Progress: null, SecondsLeft: null); } float tamingTime = tameable.m_tamingTime; if (tamingTime <= 0f) { return (Progress: null, SecondsLeft: null); } ZDO val = ZdoOf((Component)(object)tameable); if (val == null) { return (Progress: null, SecondsLeft: null); } float num = Mathf.Clamp(val.GetFloat(ZDOVars.s_tameTimeLeft, tamingTime), 0f, tamingTime); float value = TamingBoost.SecondsLeft(num, BoostedPlayers(tameable), tameable.m_tamingBoostMultiplier); return (Progress: 1f - num / tamingTime, SecondsLeft: value); } private static int BoostedPlayers(Tameable tameable) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) NearbyPlayers.Clear(); Player.GetPlayersInRange(((Component)tameable).transform.position, tameable.m_tamingSpeedMultiplierRange, NearbyPlayers); int num = 0; foreach (Player nearbyPlayer in NearbyPlayers) { if (((Character)nearbyPlayer).GetSEMan().HaveStatusAttribute((StatusAttribute)8)) { num++; } } return num; } private static (float? Progress, float? SecondsLeft) Growth(Character character) { Growup component = ((Component)character).GetComponent<Growup>(); if ((Object)(object)component == (Object)null) { return (Progress: null, SecondsLeft: null); } float growTime = component.m_growTime; if (growTime <= 0f) { return (Progress: null, SecondsLeft: null); } ZDO val = ZdoOf((Component)(object)component); if (val == null || (Object)(object)ZNet.instance == (Object)null) { return (Progress: null, SecondsLeft: null); } long num = val.GetLong(ZDOVars.s_spawnTime, 0L); if (num > 0) { DateTime maxValue = DateTime.MaxValue; if (num <= maxValue.Ticks) { double totalSeconds = (ZNet.instance.GetTime() - new DateTime(num)).TotalSeconds; if (double.IsNaN(totalSeconds)) { return (Progress: null, SecondsLeft: null); } float num2 = Mathf.Clamp01((float)(totalSeconds / (double)growTime)); return (Progress: num2, SecondsLeft: growTime * (1f - num2)); } } return (Progress: null, SecondsLeft: null); } private static Awareness AwarenessOf(BaseAI? ai) { if (!((Object)(object)ai == (Object)null)) { if (!ai.IsAlerted()) { if (ai.HaveTarget()) { return (Awareness)1; } return (Awareness)0; } return (Awareness)2; } return (Awareness)0; } private static bool IsHostileToPlayer(BaseAI? ai) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)ai != (Object)null && (Object)(object)localPlayer != (Object)null) { return ai.IsEnemy((Character)(object)localPlayer); } return false; } private static bool? TargetsLocalPlayer(Character character, BaseAI? ai) { if ((Object)(object)ai == (Object)null) { return null; } ZNetView component = ((Component)character).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner()) { return null; } Player localPlayer = Player.m_localPlayer; return (Object)(object)localPlayer != (Object)null && (Object)(object)ai.GetTargetCreature() == (Object)(object)localPlayer; } private static ZDO? ZdoOf(Component component) { ZNetView component2 = component.GetComponent<ZNetView>(); if (!((Object)(object)component2 != (Object)null) || !component2.IsValid()) { return null; } return component2.GetZDO(); } private static string Localize(string token) { if (Localization.instance == null) { return token; } return Localization.instance.Localize(token); } } internal sealed class EntityScanner { private readonly List<Character> _characters = new List<Character>(); private readonly List<NearbyEntity> _found = new List<NearbyEntity>(); public Vec3 Viewer { get; private set; } public Vec3 Forward { get; private set; } public IReadOnlyList<NearbyEntity> Found => _found; public bool Faulted { get; private set; } public IReadOnlyList<NearbyEntity> Scan(Func<NearbyEntity, bool>? include = null, bool namedFirst = false) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { Faulted = false; return Array.Empty<NearbyEntity>(); } Transform transform = ((Component)localPlayer).transform; Viewer = EntityMapper.ToVec3(transform.position); Forward = EntityMapper.ToVec3(transform.forward); _characters.Clear(); _found.Clear(); Faulted = false; try { Character.GetCharactersInRange(transform.position, 50f, _characters); } catch (Exception error) { Fault("range query failed", error); return Array.Empty<NearbyEntity>(); } MapAll(transform.position, 0f); try { float num = BreedingRules.Reach((IEnumerable<NearbyEntity>)_found, Viewer, 50f); if (num > 0f) { _characters.Clear(); Character.GetCharactersInRange(transform.position, 50f + num, _characters); MapAll(transform.position, 50f); } } catch (Exception error2) { Fault("breeding range query failed", error2); } try { BreedingRules.Resolve((IList<NearbyEntity>)_found); } catch (Exception error3) { Fault("could not work out breeding", error3); } try { return NearbyList.Build((IEnumerable<NearbyEntity>)_found, Viewer, 50f, int.MaxValue, include, namedFirst); } catch (Exception error4) { Fault("could not build the list", error4); return Array.Empty<NearbyEntity>(); } } private void MapAll(Vector3 viewer, float minimumDistance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) float num = minimumDistance * minimumDistance; foreach (Character character in _characters) { try { if (!(minimumDistance > 0f)) { goto IL_0041; } Vector3 val = ((Component)character).transform.position - viewer; if (!(((Vector3)(ref val)).sqrMagnitude < num)) { goto IL_0041; } goto end_IL_001a; IL_0041: NearbyEntity val2 = EntityMapper.FromCharacter(character); if (val2 != (NearbyEntity)null) { _found.Add(val2); } end_IL_001a:; } catch (Exception error) { Fault("could not read a creature", error); } } } private void Fault(string what, Exception error) { if (!Faulted) { Faulted = true; Plugin.Log.LogWarning((object)("NearbyPanel: " + what + " (" + error.GetType().Name + ": " + error.Message + ")")); } } } internal static class FilterCommand { private const string Name = "nearby_filter"; public static void Register() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand("nearby_filter", "filters the nearby list by name; no argument clears it", new ConsoleEvent(Run), false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void Run(ConsoleEventArgs args) { FilterState.Set((args.Length > 1) ? string.Join(" ", args.Args, 1, args.Length - 1) : string.Empty); string text = (FilterState.Active ? ("nearby filter set to \"" + FilterState.Text + "\"") : "nearby filter cleared"); if ((Object)(object)args.Context != (Object)null) { args.Context.AddString(text); } Plugin.Log.LogInfo((object)text); } } internal static class FilterState { private static ConfigEntry<string>? _entry; public static string Text => _entry?.Value ?? string.Empty; public static bool Active => !string.IsNullOrWhiteSpace(Text); public static void Bind(ConfigEntry<string> entry) { _entry = entry; } public static void Set(string? text) { if (_entry != null) { _entry.Value = (string.IsNullOrWhiteSpace(text) ? string.Empty : text.Trim()); } } public static string Describe() { if (!Active) { return string.Empty; } return " matching \"" + Text + "\""; } public static Func<NearbyEntity, bool> Predicate() { return NearbyList.Filter(Text); } } internal static class InputGate { private static bool _imguiHasFocus; public static void SampleGuiFocus() { _imguiHasFocus = GUIUtility.keyboardControl != 0; } public static bool AcceptsHotkey() { return Blocker() == null; } public static string? Blocker() { if (!Player.m_localPlayerExists || (Object)(object)Player.m_localPlayer == (Object)null) { return "no local player"; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return "chat has focus"; } if (Console.IsVisible()) { return "console is open"; } if (TextInput.IsVisible()) { return "a text prompt is open"; } if (Menu.IsVisible()) { return "the menu is open"; } if (InventoryGui.IsVisible()) { return "the inventory is open"; } if (_imguiHasFocus) { return "an IMGUI text field has focus"; } if (((Character)Player.m_localPlayer).InPlaceMode()) { return "placing a building piece"; } return null; } public static bool ShouldDraw() { if (Player.m_localPlayerExists && (Object)(object)Player.m_localPlayer != (Object)null) { return !Menu.IsVisible(); } return false; } } internal sealed class PanelView { private const float Padding = 8f; private readonly float[] _columnEdges = new float[RowFormatter.ColumnNames.Length + 1]; private static readonly Color Background = new Color(0.07f, 0.06f, 0.05f, 0.88f); private static readonly Color RowTint = new Color(1f, 1f, 1f, 0.045f); private static readonly Color Rule = new Color(0.85f, 0.76f, 0.56f, 0.35f); private static readonly Color TextColour = new Color(0.93f, 0.9f, 0.83f, 1f); private static readonly Color HeaderColour = new Color(0.85f, 0.73f, 0.47f, 1f); private static readonly Color TitleColour = new Color(1f, 0.95f, 0.85f, 1f); private static readonly Color ProgressColour = new Color(1f, 0.72f, 0.36f, 1f); private static readonly Color ThreatTint = new Color(0.75f, 0.13f, 0.11f, 0.26f); private static readonly Color ThreatColour = new Color(1f, 0.55f, 0.48f, 1f); private readonly string[] _values = new string[7]; private static readonly string[] Headings = RowFormatter.ColumnNames; private static readonly bool[] RightAligned = RowFormatter.ColumnRightAligned; private Texture2D? _pixel; private GUIStyle? _rowStyle; private GUIStyle? _rowStyleRight; private GUIStyle? _progressStyle; private GUIStyle? _threatStyle; private GUIStyle? _headerStyle; private GUIStyle? _titleStyle; private int _styleFontSize = -1; private GUIStyle? _headerStyleRight; public void Draw(IReadOnlyList<RowCells> rows, PanelRect placement, int maxVisibleRows, int fontSize, string title, float[] columnWidths) { //IL_004b: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) EnsureStyles(fontSize); float num = PanelLayout.RowHeight(fontSize); int num2 = PanelLayout.VisibleRows(rows.Count, maxVisibleRows); bool flag = rows.Count > num2; Rect rect = default(Rect); ((Rect)(ref rect))..ctor(((PanelRect)(ref placement)).X, ((PanelRect)(ref placement)).Y, ((PanelRect)(ref placement)).Width, ((PanelRect)(ref placement)).Height); Fill(rect, Background); float num3 = ((Rect)(ref rect)).y + 8f; float num4 = ((PanelRect)(ref placement)).Width - 16f; float num5 = ((Rect)(ref rect)).x + 8f; PanelLayout.ColumnEdges(columnWidths, num4, _columnEdges); GUI.Label(new Rect(num5, num3, num4, num), title, _titleStyle); num3 += num; DrawCells(num5, num3, num, Headings, _headerStyle, null); num3 += num; Fill(new Rect(num5, num3 - 1f, num4, 1f), Rule); for (int i = 0; i < num2; i++) { RowCells val = rows[i]; if (val.Threat) { Fill(new Rect(((Rect)(ref rect)).x + 2f, num3, ((PanelRect)(ref placement)).Width - 4f, num), ThreatTint); } else if (i % 2 == 1) { Fill(new Rect(((Rect)(ref rect)).x + 2f, num3, ((PanelRect)(ref placement)).Width - 4f, num), RowTint); } _values[0] = val.Name; _values[1] = val.Distance; _values[2] = val.Direction; _values[3] = val.Altitude; _values[4] = val.Level; _values[5] = val.Awareness; _values[6] = val.Status; GUIStyle lastColumnStyle = (val.Progress ? _progressStyle : (val.Threat ? _threatStyle : null)); DrawCells(num5, num3, num, _values, val.Threat ? _threatStyle : _rowStyle, lastColumnStyle); num3 += num; } if (flag) { GUI.Label(new Rect(num5, num3, num4, num), "+" + (rows.Count - num2) + " more", _headerStyle); } } private void DrawCells(float x, float y, float rowHeight, string[] values, GUIStyle normal, GUIStyle? lastColumnStyle) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) bool[] rightAligned = RightAligned; bool flag = normal == _headerStyle; for (int i = 0; i < values.Length && i + 1 < _columnEdges.Length; i++) { float num = x + _columnEdges[i]; float num2 = x + _columnEdges[i + 1]; GUIStyle val = normal; if (!flag) { if (i == values.Length - 1 && lastColumnStyle != null) { val = lastColumnStyle; } else if (i < rightAligned.Length && rightAligned[i]) { val = _rowStyleRight; } } if (flag && i < rightAligned.Length && rightAligned[i]) { val = _headerStyleRight; } GUI.Label(new Rect(num, y, num2 - num, rowHeight), values[i], val); } } private void Fill(Rect rect, Color colour) { //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) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_pixel == (Object)null) { _pixel = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61 }; _pixel.SetPixel(0, 0, Color.white); _pixel.Apply(); } Color color = GUI.color; GUI.color = colour; GUI.DrawTexture(rect, (Texture)(object)_pixel); GUI.color = color; } private void EnsureStyles(int fontSize) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_005c: 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_007a: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (_rowStyle == null || _styleFontSize != fontSize) { _styleFontSize = fontSize; _rowStyle = new GUIStyle(GUI.skin.label) { fontSize = fontSize, alignment = (TextAnchor)3, clipping = (TextClipping)1, wordWrap = false, richText = false }; _rowStyle.normal.textColor = TextColour; _rowStyle.padding = new RectOffset(3, 3, 0, 0); _rowStyleRight = new GUIStyle(_rowStyle) { alignment = (TextAnchor)5 }; _progressStyle = new GUIStyle(_rowStyle); _progressStyle.normal.textColor = ProgressColour; _threatStyle = new GUIStyle(_rowStyle); _threatStyle.normal.textColor = ThreatColour; _headerStyle = new GUIStyle(_rowStyle) { fontStyle = (FontStyle)1 }; _headerStyle.normal.textColor = HeaderColour; _headerStyleRight = new GUIStyle(_headerStyle) { alignment = (TextAnchor)5 }; _titleStyle = new GUIStyle(_rowStyle) { fontStyle = (FontStyle)1 }; _titleStyle.normal.textColor = TitleColour; } } } [BepInPlugin("I3_rett.NearbyPanel", "NearbyPanel", "1.1.0")] public sealed class Plugin : BaseUnityPlugin { private const float RefreshSeconds = 0.25f; internal static ManualLogSource Log = null; internal static ConfigEntry<bool> Enabled = null; private static ConfigEntry<ProgressFormat> _progressFormat = null; private static ConfigEntry<KeyboardShortcut> _toggleKey = null; private static ConfigEntry<bool> _namedFirst = null; private static ConfigEntry<bool> _openOnStart = null; private static ConfigEntry<PanelAnchor> _anchor = null; private static ConfigEntry<DirectionFormat> _directionFormat = null; private static ConfigEntry<int> _maxVisibleRows = null; private static ConfigEntry<int> _fontSize = null; private static readonly ConfigEntry<float>[] ColumnWidthSettings = new ConfigEntry<float>[RowFormatter.ColumnNames.Length - 1]; private readonly float[] _columnWidths = new float[RowFormatter.ColumnNames.Length - 1]; private static ConfigEntry<float> _panelWidth = null; private static ConfigEntry<float> _marginX = null; private static ConfigEntry<float> _marginY = null; private readonly EntityScanner _scanner = new EntityScanner(); private readonly PanelView _view = new PanelView(); private readonly List<RowCells> _rows = new List<RowCells>(); private bool _open; private float _sinceRefresh; private bool _hadPlayer; private string _title = string.Empty; internal static DirectionFormat DirectionFormat { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (_directionFormat != null) { return _directionFormat.Value; } return (DirectionFormat)3; } } internal static ProgressFormat ProgressFormat { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (_progressFormat != null) { return _progressFormat.Value; } return (ProgressFormat)2; } } internal static bool NamedFirst { get { if (_namedFirst != null) { return _namedFirst.Value; } return true; } } private void Awake() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Expected O, but got Unknown //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Expected O, but got Unknown //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Master switch. Turning this off hides the panel and stops the scan.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 100 } })); _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle key", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), new ConfigDescription("Shows and hides the panel. Ignored while typing in chat or the console. A shortcut with no modifier will not fire while a modifier is held.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 90 } })); FilterState.Bind(((BaseUnityPlugin)this).Config.Bind<string>("General", "Name filter", string.Empty, new ConfigDescription("Only list creatures whose name contains this text, case-insensitively. Empty lists everything. Also settable in game with: nearby_filter <text>", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 80 } }))); _openOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Open on start", false, new ConfigDescription("Whether the panel is already showing when you load into a world.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 70 } })); _namedFirst = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Named first", true, new ConfigDescription("List animals you have named before the rest, each group nearest first. A named animal is then never pushed off the bottom of the list by a crowd of unnamed ones.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 60 } })); _directionFormat = ((BaseUnityPlugin)this).Config.Bind<DirectionFormat>("Panel", "Direction format", (DirectionFormat)3, new ConfigDescription("How the DIR column reads. Degrees: angle from where you are looking, 0 ahead, 90 right, -90 left, 180 behind. Relative: the same as letters, F ahead, R right, B behind. Compass: world direction, N NE E SE S SW W NW, which does not change as you turn. Arrow: the same as Relative, drawn as eight arrows.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 95 } })); _progressFormat = ((BaseUnityPlugin)this).Config.Bind<ProgressFormat>("Panel", "Progress format", (ProgressFormat)2, new ConfigDescription("How taming, growth and pregnancy read in STATUS. Percent: how far along, 42%. Time: how long is left, 4 min. Taming time only counts down while the animal is fed, so it reads '4 min fed'. Both: 42% · 4 min fed.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 94 } })); _anchor = ((BaseUnityPlugin)this).Config.Bind<PanelAnchor>("Panel", "Anchor", (PanelAnchor)3, new ConfigDescription("Which corner of the screen the panel is pinned to. The margins below are measured from that corner.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 100 } })); _marginX = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Margin X", 12f, new ConfigDescription("Horizontal distance from the anchored corner, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), new object[1] { new ConfigurationManagerAttributes { Order = 90 } })); _marginY = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Margin Y", 120f, new ConfigDescription("Vertical distance from the anchored corner, in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), new object[1] { new ConfigurationManagerAttributes { Order = 80 } })); _panelWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Width", 700f, new ConfigDescription("Panel width in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(240f, 1200f), new object[1] { new ConfigurationManagerAttributes { Order = 70 } })); _maxVisibleRows = ((BaseUnityPlugin)this).Config.Bind<int>("Panel", "Visible rows", 12, new ConfigDescription("Rows drawn before the list is cut short with a count of the rest.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), new object[1] { new ConfigurationManagerAttributes { Order = 60 } })); _fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Panel", "Font size", 20, new ConfigDescription("Text size in the panel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 32), new object[1] { new ConfigurationManagerAttributes { Order = 50 } })); BindColumnWidths(); _open = _openOnStart.Value; DumpCommand.Register(_scanner); FilterCommand.Register(); Log.LogInfo((object)"NearbyPanel 1.1.0 loaded (client-side only)."); } private void Update() { //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) bool flag = Player.m_localPlayerExists && (Object)(object)Player.m_localPlayer != (Object)null; if (_hadPlayer && !flag) { _rows.Clear(); } _hadPlayer = flag; if (!Enabled.Value) { _open = false; return; } KeyboardShortcut value = _toggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { string text = InputGate.Blocker(); if (text == null) { _open = !_open; _sinceRefresh = 0.25f; Log.LogInfo((object)("Panel " + (_open ? "opened" : "closed") + ".")); } else { Log.LogInfo((object)("Toggle key ignored: " + text + ".")); } } if (_open && InputGate.ShouldDraw()) { _sinceRefresh += Time.unscaledDeltaTime; if (!(_sinceRefresh < 0.25f)) { _sinceRefresh = 0f; Refresh(); } } } private void Refresh() { //IL_003c: 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_0051: 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) try { IReadOnlyList<NearbyEntity> readOnlyList = _scanner.Scan(FilterState.Predicate(), NamedFirst); _rows.Clear(); foreach (NearbyEntity item in readOnlyList) { _rows.Add(RowFormatter.Cells(item, _scanner.Viewer, _scanner.Forward, _directionFormat.Value, _progressFormat.Value)); } string text = "50 m" + FilterState.Describe(); _title = ((_rows.Count == 0) ? ("Nearby — nothing within " + text) : ("Nearby — " + _rows.Count + " within " + text)); if (_scanner.Faulted) { _title += " (partial)"; } } catch (Exception ex) { _title = "Nearby — error, see the log"; Log.LogError((object)("NearbyPanel refresh failed: " + ex)); } } private void OnGUI() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) InputGate.SampleGuiFocus(); if (Enabled.Value && _open && InputGate.ShouldDraw()) { PanelRect placement = PanelLayout.Place(_anchor.Value, _marginX.Value, _marginY.Value, _panelWidth.Value, PanelLayout.Height(_rows.Count, _maxVisibleRows.Value, _fontSize.Value), (float)Screen.width, (float)Screen.height); for (int i = 0; i < _columnWidths.Length; i++) { _columnWidths[i] = ColumnWidthSettings[i].Value; } _view.Draw(_rows, placement, _maxVisibleRows.Value, _fontSize.Value, _title, _columnWidths); } } private void BindColumnWidths() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown float[] array = new float[6] { 120f, 64f, 64f, 64f, 32f, 80f }; string[] array2 = new string[6] { "NAME", "DIST", "DIR", "ALT", "Stars", "ALERT" }; for (int i = 0; i < ColumnWidthSettings.Length; i++) { ColumnWidthSettings[i] = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", array2[i] + " width", array[i], new ConfigDescription("Width of the " + RowFormatter.ColumnNames[i] + " column in pixels. STATUS takes whatever is left of the panel width. 0 hides the column.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), new object[1] { new ConfigurationManagerAttributes { Order = 100 - i } })); } } } internal static class PluginInfo { public const string Guid = "I3_rett.NearbyPanel"; public const string Name = "NearbyPanel"; public const string Version = "1.1.0"; } internal static class Tuning { public const float ScanRadius = 50f; public const int MaxVisibleRows = 50; public const string RadiusLabel = "50"; } }