using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace YapyapMinimap;
[BepInPlugin("com.patty.yapyap.minimap", "YAPYAP Minimap", "2.0.0")]
public class MinimapPlugin : BaseUnityPlugin
{
public const string GUID = "com.patty.yapyap.minimap";
public const string NAME = "YAPYAP Minimap";
public const string VERSION = "2.0.0";
private ConfigEntry<bool> _enabled;
private ConfigEntry<KeyCode> _toggleKey;
private ConfigEntry<KeyCode> _reloadKey;
private ConfigEntry<bool> _circular;
private ConfigEntry<bool> _flipVertical;
private ConfigEntry<float> _sizePct;
private ConfigEntry<int> _anchor;
private ConfigEntry<float> _offsetX;
private ConfigEntry<float> _offsetY;
private ConfigEntry<string> _borderColorHex;
private ConfigEntry<KeyCode> _expandKey;
private ConfigEntry<float> _expandSizePct;
private ConfigEntry<float> _expandRadius;
private ConfigEntry<float> _refreshHz;
private ConfigEntry<bool> _followCamera;
private ConfigEntry<float> _orthoSize;
private ConfigEntry<float> _cameraHeight;
private ConfigEntry<float> _ceilingClear;
private ConfigEntry<float> _floorDepth;
private ConfigEntry<bool> _rotateWithPlayer;
private ConfigEntry<float> _refreshInterval;
private ConfigEntry<string> _playerTypeName;
private ConfigEntry<string> _playerKeywords;
private ConfigEntry<bool> _requirePlayerControlled;
private ConfigEntry<string> _pcMembers;
private ConfigEntry<bool> _showExtraction;
private ConfigEntry<string> _extractionTypeName;
private ConfigEntry<string> _extractionKeywords;
private ConfigEntry<string> _extractionColorHex;
private Camera _mapCam;
private RenderTexture _rt;
private GameObject _camGo;
private Type _playerType;
private float _nextScan;
private Transform _local;
private readonly List<Transform> _mates = new List<Transform>();
private Type _extractionType;
private Transform _extraction;
private Vector3 _viewOrigin;
private float _viewYaw;
private bool _viewActive;
private bool _expanded;
private bool _active;
private float _nextRenderTick;
private Texture2D _bg;
private Texture2D _dotMate;
private Texture2D _border;
private Texture2D _arrow;
private Texture2D _arrowWhite;
private Texture2D _dotWhite;
private GUIStyle _labelStyle;
private Texture2D _mapTex;
private Texture2D _ring;
private Texture2D _disc;
private byte[] _alphaMask;
private int _maskSize = -1;
private Color32 _ringColor;
private string _cfgPath;
private DateTime _cfgMtime;
private float _nextCfgCheck;
private bool _humanFlagWarned;
private void Awake()
{
_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for the minimap.");
_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)109, "Key to show/hide the minimap.");
_reloadKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ReloadConfigKey", (KeyCode)289, "Press in-game to re-read this config file so position/size/colour tweaks apply WITHOUT restarting.");
_circular = ((BaseUnityPlugin)this).Config.Bind<bool>("Layout", "Circular", true, "Round minimap (true) or square (false).");
_flipVertical = ((BaseUnityPlugin)this).Config.Bind<bool>("Layout", "FlipVertical", false, "Only used for the round map: flip it vertically if the geometry looks mirrored top-to-bottom on your graphics card.");
_sizePct = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "SizePercent", 0.075f, "Map diameter as a fraction of screen HEIGHT (so it's the same relative size at any resolution). ~0.075 roughly matches the compass dial.");
_anchor = ((BaseUnityPlugin)this).Config.Bind<int>("Layout", "Anchor", 1, "Screen corner the map is positioned from: 0=TopLeft 1=TopRight 2=BottomLeft 3=BottomRight. The compass is top-right (1).");
_offsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "OffsetX", 0.139f, "Horizontal distance from the anchor corner to the map CENTRE, as a fraction of screen HEIGHT. Stable across resolutions and aspect ratios.");
_offsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "OffsetY", 0.103f, "Vertical distance from the anchor corner to the map CENTRE, as a fraction of screen HEIGHT.");
_borderColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Layout", "BorderColorHex", "B5B9C2", "Hex RRGGBB colour of the round border ring. Default is moon-grey. Examples: B5B9C2 (grey), CCBF66 (gold).");
_expandKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Layout", "ExpandKey", (KeyCode)9, "HOLD this key to temporarily enlarge the map to the screen centre and zoom out. Release to return to normal.");
_expandSizePct = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ExpandSizePercent", 0.7f, "Diameter of the enlarged map as a fraction of screen height (while holding ExpandKey).");
_expandRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ExpandWorldRadius", 45f, "World units shown from centre to edge while enlarged. Bigger = covers more of the level.");
_followCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "FollowMainCamera", true, "Centre and rotate the map using the main game camera (recommended; tracks and turns with the player reliably). If false, follows the detected player object instead.");
_orthoSize = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "WorldRadius", 18f, "World units shown from map centre to edge. Bigger = more zoomed out.");
_cameraHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "Height", 40f, "How far above the player the map camera floats.");
_ceilingClear = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "CeilingClearance", 3f, "Units above the player kept visible. Anything higher (ceilings/roof) is clipped so you can see into rooms.");
_floorDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "FloorDepth", 12f, "Units below the player still drawn (covers stairs/lower floors).");
_rotateWithPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "RotateWithPlayer", false, "If true the map rotates so the player always faces up. If false the map is fixed north-up (the player arrow turns instead).");
_refreshInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Players", "RescanInterval", 0.5f, "Seconds between re-scanning the scene for players.");
_playerTypeName = ((BaseUnityPlugin)this).Config.Bind<string>("Players", "PlayerTypeName", "Pawn", "Exact name of the player component. For YAPYAP this is 'Pawn'. Blank = auto-discover (but auto can mis-pick Unity types like PlayerInput, so the explicit name is safer).");
_playerKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Players", "DiscoveryKeywords", "Pawn,PlayerControlled,Player", "Comma-separated name hints used when auto-discovering the player type. Auto-discovery picks the matching type with the most live instances, which is the 'Pawn' base class.");
_requirePlayerControlled = ((BaseUnityPlugin)this).Config.Bind<bool>("Players", "OnlyHumanControlled", true, "Show dots only for human-controlled pawns (teammates), not AI guardians/monsters. Uses YAPYAP's networked 'IsPlayerControlled' flag. If teammates ever stop showing, set this false.");
_pcMembers = ((BaseUnityPlugin)this).Config.Bind<string>("Players", "HumanFlagMembers", "IsPlayerControlled,NetworkisPlayerControlled,isPlayerControlled,_isPlayerControlled", "Candidate bool member names read to tell a human pawn from an AI pawn. First one found on a pawn wins.");
_showExtraction = ((BaseUnityPlugin)this).Config.Bind<bool>("Extraction", "ShowExtractionMarker", true, "Show a marker on the map that points toward the extraction point. Only appears once an extraction point exists in the level.");
_extractionTypeName = ((BaseUnityPlugin)this).Config.Bind<string>("Extraction", "ExtractionTypeName", "TeleportExtractionCircle", "Exact component name of the extraction point. Leave default for YAPYAP; blank to auto-discover via keywords.");
_extractionKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Extraction", "ExtractionKeywords", "ExtractionCircle,Extraction,Extract", "Fallback name hints used to auto-discover the extraction point if the exact name isn't found.");
_extractionColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Extraction", "MarkerColorHex", "FFB432", "Hex RRGGBB colour of the extraction marker. Default is amber.");
_refreshHz = ((BaseUnityPlugin)this).Config.Bind<float>("Performance", "MapRefreshHz", 0f, "How many times per second the map image updates (camera render + circular-mask readback — the two costly steps). 0 = every frame (smoothest; matches the original behaviour). On slower machines / macOS Metal, set e.g. 10 to cut redraw cost: the geometry refreshes less often but the markers and overlay stay smooth.");
BuildTextures();
_cfgPath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
try
{
_cfgMtime = File.GetLastWriteTimeUtc(_cfgPath);
}
catch
{
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("YAPYAP Minimap 2.0.0 loaded at " + Screen.width + "x" + Screen.height + ". Config auto-reloads on file change."));
}
private void OnDestroy()
{
if ((Object)(object)_camGo != (Object)null)
{
Object.Destroy((Object)(object)_camGo);
}
if ((Object)(object)_rt != (Object)null)
{
_rt.Release();
Object.Destroy((Object)(object)_rt);
}
if ((Object)(object)_mapTex != (Object)null)
{
Object.Destroy((Object)(object)_mapTex);
}
if ((Object)(object)_ring != (Object)null)
{
Object.Destroy((Object)(object)_ring);
}
if ((Object)(object)_disc != (Object)null)
{
Object.Destroy((Object)(object)_disc);
}
}
private void Update()
{
//IL_000c: 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_0085: Unknown result type (might be due to invalid IL or missing references)
MaybeReloadConfig();
if (Input.GetKeyDown(_toggleKey.Value))
{
_enabled.Value = !_enabled.Value;
}
if (Input.GetKeyDown(_reloadKey.Value))
{
try
{
((BaseUnityPlugin)this).Config.Reload();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Config reloaded from disk.");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Config reload failed: " + ex.Message));
}
}
try
{
_expanded = Input.GetKey(_expandKey.Value);
}
catch
{
_expanded = false;
}
_active = _enabled.Value || _expanded;
if (!_active)
{
if ((Object)(object)_mapCam != (Object)null)
{
((Behaviour)_mapCam).enabled = false;
}
return;
}
if (Time.unscaledTime >= _nextScan)
{
_nextScan = Time.unscaledTime + Mathf.Max(0.1f, _refreshInterval.Value);
ScanPlayers();
}
EnsureCamera(CurrentTexSize());
UpdateCameraPose();
}
private int CurrentDisplaySize()
{
float num = (_expanded ? _expandSizePct.Value : _sizePct.Value);
return Mathf.Max(64, Mathf.RoundToInt(num * (float)Screen.height));
}
private int CurrentTexSize()
{
return Mathf.Clamp(CurrentDisplaySize(), 64, 512);
}
private float CurrentRadius()
{
return Mathf.Max(2f, _expanded ? _expandRadius.Value : _orthoSize.Value);
}
private void MaybeReloadConfig()
{
if (Time.unscaledTime < _nextCfgCheck)
{
return;
}
_nextCfgCheck = Time.unscaledTime + 1f;
if (string.IsNullOrEmpty(_cfgPath))
{
return;
}
try
{
DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(_cfgPath);
if (lastWriteTimeUtc != _cfgMtime)
{
_cfgMtime = lastWriteTimeUtc;
((BaseUnityPlugin)this).Config.Reload();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Config reloaded (file changed).");
}
}
catch
{
}
}
private Type ResolvePlayerType()
{
if (_playerType != null)
{
return _playerType;
}
if (!string.IsNullOrEmpty(_playerTypeName.Value))
{
_playerType = FindTypeByName(_playerTypeName.Value);
if (_playerType != null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Using configured player type: " + _playerType.FullName));
return _playerType;
}
((BaseUnityPlugin)this).Logger.LogWarning((object)("Configured PlayerTypeName '" + _playerTypeName.Value + "' not found; falling back to auto-discovery."));
}
string[] source = (from k in _playerKeywords.Value.Split(new char[1] { ',' })
select k.Trim() into k
where k.Length > 0
select k).ToArray();
Type type = null;
int num = 0;
foreach (Type item in EnumerateBehaviourTypes())
{
string i = item.Name;
if (source.Any((string k) => i.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0))
{
int num2;
try
{
num2 = Object.FindObjectsOfType(item).Length;
}
catch
{
continue;
}
if (num2 > num)
{
num = num2;
type = item;
}
}
}
if (type != null)
{
_playerType = type;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Auto-discovered player type '" + type.FullName + "' (" + num + " instance(s) in scene)."));
}
return _playerType;
}
private void ScanPlayers()
{
_mates.Clear();
_local = null;
Type type = ResolvePlayerType();
if (type == null)
{
return;
}
Object[] array = Object.FindObjectsOfType(type);
if (array == null || array.Length == 0)
{
return;
}
List<Transform> list = (from c in array.OfType<Component>()
where (Object)(object)c != (Object)null && c.gameObject.activeInHierarchy
select c.transform).ToList();
List<Transform> list2 = (_requirePlayerControlled.Value ? FilterHumanControlled(list) : list);
_local = PickLocalPlayer(list2);
foreach (Transform item in list2)
{
if ((Object)(object)item != (Object)(object)_local)
{
_mates.Add(item);
}
}
ScanExtraction();
}
private void ScanExtraction()
{
//IL_0055: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
_extraction = null;
if (!_showExtraction.Value)
{
return;
}
Type type = ResolveExtractionType();
if (type == null)
{
return;
}
Object[] array = Object.FindObjectsOfType(type);
if (array == null || array.Length == 0)
{
return;
}
Vector3 val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : _viewOrigin);
float num = float.MaxValue;
foreach (Component item in array.OfType<Component>())
{
if (!((Object)(object)item == (Object)null) && item.gameObject.activeInHierarchy)
{
Vector3 val2 = item.transform.position - val;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
_extraction = item.transform;
}
}
}
}
private Type ResolveExtractionType()
{
if (_extractionType != null)
{
return _extractionType;
}
if (!string.IsNullOrEmpty(_extractionTypeName.Value))
{
_extractionType = FindTypeByName(_extractionTypeName.Value);
if (_extractionType != null)
{
return _extractionType;
}
}
string[] source = (from s in _extractionKeywords.Value.Split(new char[1] { ',' })
select s.Trim() into s
where s.Length > 0
select s).ToArray();
Type type = null;
int num = 0;
foreach (Type t in EnumerateBehaviourTypes())
{
Func<string, bool> predicate = (string k) => t.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0;
if (source.Any(predicate))
{
int num2;
try
{
num2 = Object.FindObjectsOfType(t).Length;
}
catch
{
continue;
}
if (num2 > num)
{
num = num2;
type = t;
}
}
}
if (type != null)
{
_extractionType = type;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Extraction type: " + type.FullName));
}
return _extractionType;
}
private List<Transform> FilterHumanControlled(List<Transform> pawns)
{
string[] names = (from s in _pcMembers.Value.Split(new char[1] { ',' })
select s.Trim() into s
where s.Length > 0
select s).ToArray();
List<Transform> list = new List<Transform>();
bool flag = false;
foreach (Transform pawn in pawns)
{
bool found;
bool flag2 = ReadBoolAcrossComponents(pawn, names, out found);
if (found)
{
flag = true;
if (flag2)
{
list.Add(pawn);
}
}
}
if (!flag)
{
if (!_humanFlagWarned)
{
_humanFlagWarned = true;
((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not read an IsPlayerControlled flag on any pawn; showing all pawns (AI included). Adjust Players/HumanFlagMembers if teammate dots look wrong.");
}
return pawns;
}
return list;
}
private Transform PickLocalPlayer(List<Transform> players)
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
if (players.Count == 0)
{
return null;
}
if (players.Count == 1)
{
return players[0];
}
foreach (Transform player in players)
{
if (HasTruthyMember(player, "isLocalPlayer", "IsOwner", "isOwned", "IsLocalPlayer", "IsMine", "isMine"))
{
return player;
}
}
Camera main = Camera.main;
if ((Object)(object)main != (Object)null)
{
Transform val = ((Component)main).transform;
while ((Object)(object)val != (Object)null)
{
if (players.Contains(val))
{
return val;
}
val = val.parent;
}
Transform val2 = null;
float num = float.MaxValue;
foreach (Transform player2 in players)
{
Vector3 val3 = player2.position - ((Component)main).transform.position;
float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
val2 = player2;
}
}
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return players[0];
}
private void EnsureCamera(int size)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_007c: 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_011d: Expected O, but got Unknown
if ((Object)(object)_mapCam == (Object)null)
{
_camGo = new GameObject("YapyapMinimapCamera");
Object.DontDestroyOnLoad((Object)(object)_camGo);
((Object)_camGo).hideFlags = (HideFlags)61;
_mapCam = _camGo.AddComponent<Camera>();
_mapCam.orthographic = true;
_mapCam.clearFlags = (CameraClearFlags)2;
_mapCam.backgroundColor = new Color(0.05f, 0.06f, 0.09f, 1f);
_mapCam.cullingMask = -1;
_mapCam.depth = -100f;
_mapCam.allowHDR = false;
_mapCam.allowMSAA = false;
((Behaviour)_mapCam).enabled = false;
}
if ((Object)(object)_rt == (Object)null || ((Texture)_rt).width != size)
{
if ((Object)(object)_rt != (Object)null)
{
_mapCam.targetTexture = null;
_rt.Release();
Object.Destroy((Object)(object)_rt);
}
RenderTexture val = new RenderTexture(size, size, 16);
((Object)val).name = "YapyapMinimapRT";
val.antiAliasing = 1;
_rt = val;
_rt.Create();
_mapCam.targetTexture = _rt;
}
}
private Transform GetViewTransform()
{
if (_followCamera.Value)
{
Camera main = Camera.main;
if ((Object)(object)main != (Object)null && (Object)(object)main != (Object)(object)_mapCam)
{
return ((Component)main).transform;
}
}
return _local;
}
private void UpdateCameraPose()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_mapCam == (Object)null))
{
Transform viewTransform = GetViewTransform();
_viewActive = (Object)(object)viewTransform != (Object)null;
if (!_viewActive)
{
((Behaviour)_mapCam).enabled = false;
return;
}
_viewOrigin = viewTransform.position;
_viewYaw = viewTransform.eulerAngles.y;
((Behaviour)_mapCam).enabled = _refreshHz.Value <= 0f;
_mapCam.orthographicSize = CurrentRadius();
_camGo.transform.position = new Vector3(_viewOrigin.x, _viewOrigin.y + _cameraHeight.Value, _viewOrigin.z);
float num = (_rotateWithPlayer.Value ? _viewYaw : 0f);
_camGo.transform.rotation = Quaternion.Euler(90f, num, 0f);
_mapCam.nearClipPlane = Mathf.Max(0.05f, _cameraHeight.Value - _ceilingClear.Value);
_mapCam.farClipPlane = _cameraHeight.Value + Mathf.Max(1f, _floorDepth.Value);
}
}
private void LateUpdate()
{
if (!_active || (Object)(object)_mapCam == (Object)null || !_viewActive)
{
return;
}
float value = _refreshHz.Value;
float num = ((value > 0f) ? (1f / value) : 0.033f);
if (Time.unscaledTime < _nextRenderTick)
{
return;
}
_nextRenderTick = Time.unscaledTime + num;
if (value > 0f)
{
try
{
_mapCam.Render();
}
catch
{
}
}
if (_circular.Value)
{
EnsureMask(CurrentTexSize());
DoMaskedReadback(CurrentTexSize());
}
}
private void OnGUI()
{
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_rt == (Object)null || (!_enabled.Value && !_expanded))
{
return;
}
int num = CurrentDisplaySize();
int size = CurrentTexSize();
float num2;
float num3;
if (_expanded)
{
num2 = (float)Screen.width * 0.5f;
num3 = (float)Screen.height * 0.5f;
}
else
{
float num4 = _offsetX.Value * (float)Screen.height;
float num5 = _offsetY.Value * (float)Screen.height;
bool flag = _anchor.Value == 1 || _anchor.Value == 3;
bool flag2 = _anchor.Value == 2 || _anchor.Value == 3;
num2 = (flag ? ((float)Screen.width - num4) : num4);
num3 = (flag2 ? ((float)Screen.height - num5) : num5);
}
Rect val = default(Rect);
((Rect)(ref val))..ctor(num2 - (float)num * 0.5f, num3 - (float)num * 0.5f, (float)num, (float)num);
if (_circular.Value)
{
EnsureMask(size);
if (_viewActive)
{
GUI.DrawTexture(val, (Texture)(object)_mapTex, (ScaleMode)0, true);
}
else
{
GUI.DrawTexture(val, (Texture)(object)_disc, (ScaleMode)0, true);
GUI.Label(val, "\n Locating player...", _labelStyle);
}
GUI.DrawTexture(val, (Texture)(object)_ring, (ScaleMode)0, true);
if (_viewActive)
{
DrawMarkers(val);
}
}
else
{
GUI.DrawTexture(new Rect(((Rect)(ref val)).x - 2f, ((Rect)(ref val)).y - 2f, (float)(num + 4), (float)(num + 4)), (Texture)(object)_border);
if (_viewActive)
{
GUI.DrawTexture(val, (Texture)(object)_rt, (ScaleMode)0, false);
DrawMarkers(val);
}
else
{
GUI.DrawTexture(val, (Texture)(object)_bg, (ScaleMode)0, false);
GUI.Label(val, "\n Locating player...", _labelStyle);
}
}
}
private void DrawMarkers(Rect rect)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
Vector2 center = ((Rect)(ref rect)).center;
float pxPerUnit = ((Rect)(ref rect)).width / (2f * CurrentRadius());
float num = Mathf.Clamp(((Rect)(ref rect)).width / Mathf.Max(64f, _sizePct.Value * (float)Screen.height), 1f, 3f);
float mapYaw = (_rotateWithPlayer.Value ? _viewYaw : 0f);
Vector3 viewOrigin = _viewOrigin;
float num2 = ((Rect)(ref rect)).width * 0.5f - 8f;
foreach (Transform mate in _mates)
{
if ((Object)(object)mate == (Object)null)
{
continue;
}
Vector3 val = mate.position - viewOrigin;
if (val.x * val.x + val.z * val.z < 1f)
{
continue;
}
Vector2 val2 = ProjectToMap(mate.position, viewOrigin, center, pxPerUnit, mapYaw);
Vector2 val3 = val2 - center;
bool flag;
if (_circular.Value)
{
flag = ((Vector2)(ref val3)).magnitude > num2;
if (flag)
{
val2 = center + ((Vector2)(ref val3)).normalized * num2;
}
}
else
{
flag = !((Rect)(ref rect)).Contains(val2);
val2.x = Mathf.Clamp(val2.x, ((Rect)(ref rect)).xMin + 8f, ((Rect)(ref rect)).xMax - 8f);
val2.y = Mathf.Clamp(val2.y, ((Rect)(ref rect)).yMin + 8f, ((Rect)(ref rect)).yMax - 8f);
}
DrawDot(val2, _dotMate, (flag ? 9f : 12f) * num);
}
if (_showExtraction.Value && (Object)(object)_extraction != (Object)null)
{
Color color = Color32.op_Implicit(ParseHexColor(_extractionColorHex.Value, new Color32(byte.MaxValue, (byte)180, (byte)50, byte.MaxValue)));
Vector2 val4 = ProjectToMap(_extraction.position, viewOrigin, center, pxPerUnit, mapYaw);
Vector2 val5 = val4 - center;
bool flag2 = (_circular.Value ? (((Vector2)(ref val5)).magnitude > num2) : (!((Rect)(ref rect)).Contains(val4)));
Color color2 = GUI.color;
GUI.color = color;
if (flag2)
{
Vector2 val6 = (Vector2)((((Vector2)(ref val5)).sqrMagnitude > 0.01f) ? ((Vector2)(ref val5)).normalized : new Vector2(0f, -1f));
if (_circular.Value)
{
val4 = center + val6 * num2;
}
else
{
val4.x = Mathf.Clamp(val4.x, ((Rect)(ref rect)).xMin + 8f, ((Rect)(ref rect)).xMax - 8f);
val4.y = Mathf.Clamp(val4.y, ((Rect)(ref rect)).yMin + 8f, ((Rect)(ref rect)).yMax - 8f);
}
float num3 = Mathf.Atan2(val6.x, 0f - val6.y) * 57.29578f;
float num4 = 18f * num;
Matrix4x4 matrix = GUI.matrix;
GUIUtility.RotateAroundPivot(num3, val4);
GUI.DrawTexture(new Rect(val4.x - num4 / 2f, val4.y - num4 / 2f, num4, num4), (Texture)(object)_arrowWhite);
GUI.matrix = matrix;
}
else
{
DrawDot(val4, _dotWhite, 13f * num);
}
GUI.color = color2;
}
float num5 = (_rotateWithPlayer.Value ? 0f : _viewYaw);
float num6 = 18f * num;
Matrix4x4 matrix2 = GUI.matrix;
GUIUtility.RotateAroundPivot(num5, center);
GUI.DrawTexture(new Rect(center.x - num6 / 2f, center.y - num6 / 2f, num6, num6), (Texture)(object)_arrow);
GUI.matrix = matrix2;
}
private Vector2 ProjectToMap(Vector3 world, Vector3 origin, Vector2 center, float pxPerUnit, float mapYaw)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
float num = world.x - origin.x;
float num2 = world.z - origin.z;
if (mapYaw != 0f)
{
float num3 = mapYaw * ((float)Math.PI / 180f);
float num4 = Mathf.Cos(num3);
float num5 = Mathf.Sin(num3);
float num6 = num * num4 - num2 * num5;
float num7 = num * num5 + num2 * num4;
num = num6;
num2 = num7;
}
return new Vector2(center.x + num * pxPerUnit, center.y - num2 * pxPerUnit);
}
private void DrawDot(Vector2 p, Texture2D tex, float d)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(p.x - d / 2f, p.y - d / 2f, d, d), (Texture)(object)tex);
}
private void EnsureMask(int size)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Expected O, but got Unknown
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
Color32 val = ParseHexColor(_borderColorHex.Value, new Color32((byte)181, (byte)185, (byte)194, byte.MaxValue));
bool flag = _maskSize != size || (Object)(object)_mapTex == (Object)null;
bool flag2 = val.r != _ringColor.r || val.g != _ringColor.g || val.b != _ringColor.b || val.a != _ringColor.a;
if (!flag && !flag2)
{
return;
}
float num = (float)(size - 1) * 0.5f;
float num2 = (float)size * 0.5f - 1f;
float num3 = num2 - Mathf.Max(3f, (float)size * 0.045f);
Color32 val2 = default(Color32);
((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
if (flag)
{
_maskSize = size;
Texture2D val3 = new Texture2D(size, size, (TextureFormat)4, false);
((Texture)val3).wrapMode = (TextureWrapMode)1;
_mapTex = val3;
_alphaMask = new byte[size * size];
Color32[] array = (Color32[])(object)new Color32[size * size];
Color32 val4 = default(Color32);
((Color32)(ref val4))..ctor((byte)13, (byte)15, (byte)23, (byte)235);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
int num4 = i * size + j;
float num5 = (float)j - num;
float num6 = (float)i - num;
float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
_alphaMask[num4] = (byte)(Mathf.Clamp01(num2 - num7) * 255f);
array[num4] = ((num7 <= num2) ? val4 : val2);
}
}
_mapTex.Apply();
if ((Object)(object)_disc != (Object)null)
{
Object.Destroy((Object)(object)_disc);
}
Texture2D val5 = new Texture2D(size, size, (TextureFormat)4, false);
((Texture)val5).wrapMode = (TextureWrapMode)1;
_disc = val5;
_disc.SetPixels32(array);
_disc.Apply();
}
_ringColor = val;
Color32[] array2 = (Color32[])(object)new Color32[size * size];
for (int k = 0; k < size; k++)
{
for (int l = 0; l < size; l++)
{
int num8 = k * size + l;
float num9 = (float)l - num;
float num10 = (float)k - num;
float num11 = Mathf.Sqrt(num9 * num9 + num10 * num10);
if (num11 >= num3 && num11 <= num2 + 0.5f)
{
float num12 = Mathf.Clamp01(Mathf.Min(num11 - num3 + 1f, num2 - num11 + 1f));
Color32 val6 = val;
val6.a = (byte)(num12 * (float)(int)val.a);
array2[num8] = val6;
}
else
{
array2[num8] = val2;
}
}
}
if ((Object)(object)_ring != (Object)null)
{
Object.Destroy((Object)(object)_ring);
}
Texture2D val7 = new Texture2D(size, size, (TextureFormat)4, false);
((Texture)val7).wrapMode = (TextureWrapMode)1;
_ring = val7;
_ring.SetPixels32(array2);
_ring.Apply();
}
private static Color32 ParseHexColor(string hex, Color32 fallback)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(hex))
{
return fallback;
}
hex = hex.Trim().TrimStart(new char[1] { '#' });
if (hex.Length != 6 && hex.Length != 8)
{
return fallback;
}
try
{
byte b = Convert.ToByte(hex.Substring(0, 2), 16);
byte b2 = Convert.ToByte(hex.Substring(2, 2), 16);
byte b3 = Convert.ToByte(hex.Substring(4, 2), 16);
byte b4 = ((hex.Length == 8) ? Convert.ToByte(hex.Substring(6, 2), 16) : byte.MaxValue);
return new Color32(b, b2, b3, b4);
}
catch
{
return fallback;
}
}
private void DoMaskedReadback(int size)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_mapTex == (Object)null || _alphaMask == null || (Object)(object)_rt == (Object)null || ((Texture)_rt).width != size)
{
return;
}
RenderTexture active = RenderTexture.active;
RenderTexture.active = _rt;
try
{
_mapTex.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0, false);
}
finally
{
RenderTexture.active = active;
}
Color32[] array = _mapTex.GetPixels32();
if (_flipVertical.Value)
{
Color32[] array2 = (Color32[])(object)new Color32[array.Length];
for (int i = 0; i < size; i++)
{
Array.Copy(array, i * size, array2, (size - 1 - i) * size, size);
}
array = array2;
}
int num = Mathf.Min(array.Length, _alphaMask.Length);
for (int j = 0; j < num; j++)
{
Color32 val = array[j];
val.a = _alphaMask[j];
array[j] = val;
}
_mapTex.SetPixels32(array);
_mapTex.Apply(false);
}
private void BuildTextures()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
_bg = SolidTex(new Color(0.05f, 0.06f, 0.09f, 0.85f));
_border = SolidTex(new Color(0.8f, 0.75f, 0.4f, 1f));
_dotMate = SolidTex(new Color(0.4f, 1f, 0.5f, 1f));
_arrow = ArrowTex(new Color(0.35f, 0.9f, 1f, 1f));
_arrowWhite = ArrowTex(Color.white);
_dotWhite = SolidTex(Color.white);
GUIStyle val = new GUIStyle();
val.alignment = (TextAnchor)4;
val.fontSize = 14;
_labelStyle = val;
_labelStyle.normal.textColor = Color.white;
}
private static Texture2D SolidTex(Color c)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
val.SetPixel(0, 0, c);
val.Apply();
((Texture)val).wrapMode = (TextureWrapMode)1;
return val;
}
private static Texture2D ArrowTex(Color c, int size = 32)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
Color val2 = default(Color);
((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
for (int i = 0; i < size; i++)
{
float num = (float)i / (float)(size - 1);
float num2 = (float)size * 0.5f * (1f - num);
float num3 = (float)size * 0.5f;
for (int j = 0; j < size; j++)
{
val.SetPixel(j, i, (Mathf.Abs((float)j - num3) <= num2) ? c : val2);
}
}
val.Apply();
((Texture)val).wrapMode = (TextureWrapMode)1;
return val;
}
private static IEnumerable<Type> EnumerateBehaviourTypes()
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly asm in assemblies)
{
Type[] types;
try
{
types = asm.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types.Where((Type t) => t != null).ToArray();
}
catch
{
continue;
}
try
{
Type[] array = types;
foreach (Type t2 in array)
{
if (!(t2 == null) && !t2.IsAbstract && typeof(MonoBehaviour).IsAssignableFrom(t2))
{
string ns = t2.Namespace ?? "";
if (!ns.StartsWith("UnityEngine") && !ns.StartsWith("Unity.") && !ns.StartsWith("TMPro") && !ns.StartsWith("System") && !ns.StartsWith("BepInEx"))
{
yield return t2;
}
}
}
}
finally
{
}
}
}
finally
{
}
}
private static Type FindTypeByName(string name)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type = assembly.GetType(name, throwOnError: false) ?? assembly.GetTypes().FirstOrDefault((Type x) => x.Name == name || x.FullName == name);
if (type != null)
{
return type;
}
}
return null;
}
private static bool HasTruthyMember(Transform t, params string[] members)
{
Component[] components = ((Component)t).GetComponents<Component>();
foreach (Component val in components)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Type type = ((object)val).GetType();
foreach (string name in members)
{
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null && property.PropertyType == typeof(bool))
{
try
{
if ((bool)property.GetValue(val, null))
{
return true;
}
}
catch
{
}
}
FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (!(field != null) || !(field.FieldType == typeof(bool)))
{
continue;
}
try
{
if ((bool)field.GetValue(val))
{
return true;
}
}
catch
{
}
}
}
return false;
}
private static bool ReadBoolAcrossComponents(Transform t, string[] names, out bool found)
{
found = false;
Component[] components = ((Component)t).GetComponents<Component>();
foreach (Component val in components)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Type type = ((object)val).GetType();
foreach (string name in names)
{
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null && property.PropertyType == typeof(bool))
{
try
{
found = true;
return (bool)property.GetValue(val, null);
}
catch
{
found = false;
}
}
FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null && field.FieldType == typeof(bool))
{
try
{
found = true;
return (bool)field.GetValue(val);
}
catch
{
found = false;
}
}
}
}
return false;
}
}