using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BoneLib;
using BoneLib.BoneMenu;
using GTA6_HUD;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.PuppetMasta;
using LabFusion.Entities;
using LabFusion.Player;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "GTA 6 HUD", "1.0.0", "ponysaurus", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace GTA6_HUD;
public class Main : MelonMod
{
private struct Blip
{
internal Vector3 P;
internal Color C;
}
private sealed class Npc
{
internal AIBrain Brain;
internal PuppetMaster Puppet;
internal Transform Body;
internal bool WasAlive = true;
}
private sealed class FusionPlayer
{
internal Transform Head;
internal byte Id;
}
private enum SlowMode
{
None,
Game,
Manual
}
internal class GlyphLabel
{
internal enum Align
{
Left,
Center,
Right
}
private const float CellH = 128f;
private const float SpaceW = 110f;
private readonly Main owner;
private readonly Transform parent;
private readonly List<Image> pool = new List<Image>();
private readonly string name;
private readonly float height;
private readonly float x;
private readonly float y;
private readonly Align align;
private string last;
private int lastFrom = -1;
private Color tint;
internal Color Tint
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return tint;
}
set
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (((Color)(ref tint)).Equals(value))
{
return;
}
tint = value;
foreach (Image item in pool)
{
((Graphic)item).color = value;
}
lastFrom = -2;
}
}
internal GlyphLabel(Main owner, Transform parent, string name, float height, Align align, float x, float y, Color tint)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
this.owner = owner;
this.parent = parent;
this.name = name;
this.height = height;
this.align = align;
this.x = x;
this.y = y;
this.tint = tint;
}
internal void SetText(string s, int tintFrom = -1, Color tint2 = default(Color))
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
if (s == null)
{
s = "";
}
if (s == last && tintFrom == lastFrom)
{
return;
}
last = s;
lastFrom = tintFrom;
float num = height / 128f;
float num2 = 0f;
string text = s;
Rect rect;
foreach (char c in text)
{
if (c == ' ')
{
num2 += 110f * num;
continue;
}
Sprite glyph = owner.GetGlyph(c);
if ((Object)(object)glyph != (Object)null)
{
float num3 = num2;
rect = glyph.rect;
num2 = num3 + ((Rect)(ref rect)).width * num;
}
}
float num4 = ((align == Align.Left) ? x : ((align == Align.Center) ? (x - num2 * 0.5f) : (x - num2)));
int num5 = 0;
int num6 = -1;
text = s;
foreach (char c2 in text)
{
num6++;
if (c2 == ' ')
{
num4 += 110f * num;
continue;
}
Sprite glyph2 = owner.GetGlyph(c2);
if (!((Object)(object)glyph2 == (Object)null))
{
rect = glyph2.rect;
float num7 = ((Rect)(ref rect)).width * num;
while (pool.Count <= num5)
{
pool.Add(owner.MakeImage(name + "_" + pool.Count, parent, 0f, 0f, 10f, 10f, tint, null));
}
Image obj = pool[num5++];
((Component)obj).gameObject.SetActive(true);
obj.sprite = glyph2;
((Graphic)obj).color = ((tintFrom >= 0 && num6 >= tintFrom) ? tint2 : tint);
RectTransform rectTransform = ((Graphic)obj).rectTransform;
rectTransform.anchoredPosition = new Vector2(num4, 0f - y);
rectTransform.sizeDelta = new Vector2(num7, height);
num4 += num7;
}
}
for (int j = num5; j < pool.Count; j++)
{
((Component)pool[j]).gameObject.SetActive(false);
}
}
}
internal class Bar
{
private readonly Image fill;
private readonly float innerW;
private readonly float innerH;
private float lastFrac = -1f;
internal Bar(Main owner, Transform parent, string name, float x, float y, float w, float h, float border, Color fillColor, Color emptyColor)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
innerW = w - border * 2f;
innerH = h - border * 2f;
owner.MakeImage(name + "_Frame", parent, x, y, w, h, Color.black, null);
owner.MakeImage(name + "_Empty", parent, x + border, y + border, innerW, innerH, emptyColor, null);
fill = owner.MakeImage(name + "_Fill", parent, x + border, y + border, innerW, innerH, fillColor, null);
}
internal void Set(float frac)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
frac = Mathf.Clamp01(frac);
if (!(Mathf.Abs(frac - lastFrac) < 0.001f))
{
lastFrac = frac;
((Graphic)fill).rectTransform.sizeDelta = new Vector2(innerW * frac, innerH);
((Behaviour)fill).enabled = frac > 0.001f;
}
}
internal void SetFillColor(Color c)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)fill).color = c;
}
}
private const float RadarW = 280f;
private const float RadarH = 200f;
private const float BarsW = 400f;
private const float BarsH = 184f;
private const float MoneyW = 300f;
private const float MoneyH = 110f;
private const float Overscan = 1.04f;
private static readonly Color Pink = new Color(0.96f, 0.65f, 0.77f, 1f);
private static readonly Color BabyGreen = new Color(0.62f, 0.93f, 0.66f, 1f);
private static readonly Color Purple = new Color(0.63f, 0.52f, 1f, 1f);
private static readonly Color BarDark = new Color(0.11f, 0.11f, 0.14f, 1f);
private static readonly Color MoneyGreen = new Color(0.35f, 0.85f, 0.4f, 1f);
private static readonly Color MoneyRed = new Color(1f, 0.35f, 0.35f, 1f);
private static readonly Color EnemyRed = new Color(0.85f, 0.1f, 0.1f, 1f);
private static readonly Color[] PlayerPalette = (Color[])(object)new Color[10]
{
new Color(0.25f, 0.75f, 1f, 1f),
new Color(0.3f, 0.9f, 0.3f, 1f),
new Color(1f, 0.9f, 0.2f, 1f),
new Color(0.75f, 0.4f, 1f, 1f),
new Color(1f, 0.55f, 0.15f, 1f),
new Color(1f, 0.45f, 0.75f, 1f),
new Color(0.2f, 0.45f, 1f, 1f),
new Color(0.55f, 1f, 0.8f, 1f),
new Color(0.9f, 0.9f, 0.9f, 1f),
new Color(0.7f, 0.5f, 0.25f, 1f)
};
private MelonPreferences_Category cat;
private MelonPreferences_Entry<bool> pEnabled;
private MelonPreferences_Entry<bool> pHeadLocked;
private MelonPreferences_Entry<bool> pAlwaysOnTop;
private MelonPreferences_Entry<bool> pShowRadar;
private MelonPreferences_Entry<bool> pShowHealth;
private MelonPreferences_Entry<bool> pShowFocus;
private MelonPreferences_Entry<bool> pShowMoney;
private MelonPreferences_Entry<bool> pShowWeapon;
private MelonPreferences_Entry<bool> pShowStamina;
private MelonPreferences_Entry<bool> pStamina;
private MelonPreferences_Entry<bool> pBlockNative;
private MelonPreferences_Entry<bool> pRadarLogo;
private MelonPreferences_Entry<bool> pRadarOutline;
private MelonPreferences_Entry<float> pGloss;
private MelonPreferences_Entry<float> pStamSeconds;
private MelonPreferences_Entry<float> pStamRegen;
private MelonPreferences_Entry<float> pStamSpeed;
private MelonPreferences_Entry<float> pStamSlow;
private MelonPreferences_Entry<float> pStamRecover;
private MelonPreferences_Entry<float> pFocusMin;
private MelonPreferences_Entry<float> pFocusPassive;
private MelonPreferences_Entry<float> pFocusKillRefill;
private MelonPreferences_Entry<float> pFollowSpeed;
private MelonPreferences_Entry<float> pFwd;
private MelonPreferences_Entry<float> pRadarX;
private MelonPreferences_Entry<float> pRadarY;
private MelonPreferences_Entry<float> pRadarWidth;
private MelonPreferences_Entry<float> pBarsX;
private MelonPreferences_Entry<float> pBarsY;
private MelonPreferences_Entry<float> pBarsWidth;
private MelonPreferences_Entry<float> pMoneyX;
private MelonPreferences_Entry<float> pMoneyY;
private MelonPreferences_Entry<float> pMoneyWidth;
private MelonPreferences_Entry<bool> pRadarCam;
private MelonPreferences_Entry<bool> pRadarRot;
private MelonPreferences_Entry<bool> pRadarBlips;
private MelonPreferences_Entry<bool> pRadarNorth;
private MelonPreferences_Entry<float> pRange;
private MelonPreferences_Entry<float> pMapHz;
private MelonPreferences_Entry<float> pBlipHz;
private MelonPreferences_Entry<float> pCamH;
private MelonPreferences_Entry<float> pDim;
private MelonPreferences_Entry<float> pMoneySeconds;
private MelonPreferences_Entry<int> pMapRes;
private MelonPreferences_Entry<bool> pFocus;
private MelonPreferences_Entry<bool> pFocusMulti;
private MelonPreferences_Entry<string> pFocusInput;
private MelonPreferences_Entry<float> pFocusSeconds;
private MelonPreferences_Entry<float> pFocusRecharge;
private MelonPreferences_Entry<float> pFocusKill;
private MelonPreferences_Entry<float> pFocusScale;
private MelonPreferences_Entry<float> pFocusCooldown;
private MelonPreferences_Entry<float> pWeaponX;
private MelonPreferences_Entry<float> pWeaponY;
private MelonPreferences_Entry<float> pWeaponWidth;
private MelonPreferences_Entry<bool> pLogHeld;
private GameObject radarRoot;
private GameObject barsRoot;
private GameObject moneyRoot;
private GameObject healthGroup;
private GameObject staminaGroup;
private GameObject focusGroup;
private CanvasGroup moneyGroup;
private Material uiMat;
private bool built;
private bool buildFailed;
private bool visible;
private bool yawInit;
private float smoothYaw;
private string userDir;
private readonly Dictionary<char, Sprite> glyphs = new Dictionary<char, Sprite>();
private readonly HashSet<string> loggedErrors = new HashSet<string>();
private float fastTimer;
private float slowTimer;
private Bar healthBar;
private Bar staminaBar;
private Bar focusBar;
private Image healthTick;
private float healthFrac = 1f;
private float healthTrail = 1f;
private float trailHold;
private float lastHealth = 1f;
private const float BarInnerW = 324f;
private GlyphLabel moneyLabel;
private GlyphLabel deltaLabel;
private MethodInfo bitsMethod;
private float nextBitsSearch;
private float moneyTimer;
private float moneyAlpha;
private int lastBits;
private int shownBits = -1;
private int moneyDelta;
private bool haveBits;
private RawImage radarMap;
private Image radarMarker;
private Image northBadge;
private readonly List<Image> blipPool = new List<Image>();
private Camera radarCam;
private RenderTexture radarRT;
private bool radarBuilt;
private bool radarFailed;
private bool radarArmed;
private bool haveRender;
private float radarTimer;
private float scanTimer;
private float blipTimer;
private Vector3 renderPos;
private float renderYaw;
private float renderRange;
private readonly List<Blip> enemyBlips = new List<Blip>();
private readonly List<Blip> playerBlips = new List<Blip>();
private readonly List<Npc> npcCache = new List<Npc>();
private readonly List<FusionPlayer> playerCache = new List<FusionPlayer>();
private int lastNpcCount = -1;
private int lastPlayerCount = -1;
private int pendingKills;
private float charge;
private bool cooling;
private float coolT;
private float focusFlash;
private bool nativeSaved;
private bool nativeSetting;
private Image focusTick;
private float tickShownAt = -1f;
private bool slowActive;
private bool slowVerified;
private bool heldPrev;
private bool prevSlowEnabled;
private bool warnedMulti;
private SlowMode slowMode;
private float slowStart;
private float baseFixed;
private float stamina = 1f;
private float stamSpeed;
private float baseMaxVel;
private float baseCurMaxVel;
private bool exhausted;
private bool stamHavePos;
private bool capApplied;
private Vector3 stamLastPos;
private const float WeaponW = 300f;
private const float WeaponH = 215f;
private const float IconMaxW = 292f;
private const float IconMaxH = 135f;
private const float IconTop = 72f;
private static readonly Color LoadedGrey = new Color(0.78f, 0.78f, 0.78f, 1f);
private GameObject weaponRoot;
private CanvasGroup weaponGroup;
private GlyphLabel ammoLabel;
private Image weaponIcon;
private float weaponAlpha;
private float reserveTimer;
private bool weaponShow;
private string lastSig;
private int lastReserve = -1;
private readonly Dictionary<string, Sprite> icons = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, string> embeddedNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
private readonly List<(string key, string icon)> userMap = new List<(string, string)>();
private static readonly (string, string)[] GunMap = new(string, string)[41]
{
("spawngun", "SpawnGun"),
("duckseason", "M870"),
("m590", "M870"),
("m870", "M870"),
("shotgun", "M870"),
("mossberg", "M870"),
("spas", "M870"),
("fab", "FAB"),
("garand", "M16"),
("sniper", "M16"),
("dmr", "M16"),
("grenadelauncher", ""),
("launcher", ""),
("rpg", ""),
("rocket", ""),
("minigun", ""),
("tommy", "MP5"),
("thompson", "MP5"),
("akm", "AKM"),
("ak47", "AKM"),
("ak74", "AKM"),
("m16", "M16"),
("mk18", "MK18"),
("m4", "MK18"),
("mp5k", "MP5K"),
("mp5", "MP5"),
("pdrc", "PDRC"),
("ump", "MP5K"),
("vector", "MP5K"),
("uzi", "UZI"),
("m1911", "1911"),
("1911", "1911"),
("m9", "1911"),
("p350", "P350"),
("eder", "Eder22"),
("gruber", "Eder22"),
("pt8", "Eder22"),
("ehg", "Eder22"),
("stapler", "Eder22"),
("pistol", "Eder22"),
("handgun", "Eder22")
};
private static readonly (string, string)[] ObjectMap = new(string, string)[39]
{
("spawngun", "SpawnGun"),
("molotov", "Grenade"),
("grenade", "Grenade"),
("doubleaxe", "Double_Axe"),
("battleaxe", "Double_Axe"),
("doublebit", "Double_Axe"),
("hatchet", "Hatchet"),
("firefighter", "firefighter_axe"),
("fireaxe", "firefighter_axe"),
("axe", "firefighter_axe"),
("fryingpan", "Frying_Pan"),
("skillet", "Frying_Pan"),
("shovel", "Shovel"),
("spade", "Shovel"),
("crowbar", "Crowbar"),
("butcher", "Butchers_Knife"),
("cleaver", "Butchers_Knife"),
("kitchen", "Kitchen_Knife"),
("chef", "Kitchen_Knife"),
("kunai", "Kunai"),
("knife", "Combat_Knife"),
("dagger", "Combat_Knife"),
("katana", "Katana"),
("bastard", "Bastard_Sword"),
("halfsword", "Bastard_Sword"),
("machete", "Machete"),
("claymore", "Sword_Claymore"),
("sword", "Sword_Claymore"),
("trashcan", "Trashcan_Shield"),
("trashlid", "Trashcan_Shield"),
("garbagelid", "Trashcan_Shield"),
("shield", "Shield_Viking"),
("golf", "Golf_Club"),
("morningstar", "morningstar"),
("sledge", "Sledgehammer"),
("hammer", "Sledgehammer"),
("baseballbat", "Baseball_Bat"),
("barbedbat", "Baseball_Bat"),
("bat", "Baseball_Bat")
};
public override void OnInitializeMelon()
{
cat = MelonPreferences.CreateCategory("GTA6_HUD");
pEnabled = cat.CreateEntry<bool>("Enabled", true, "Enabled", "Master switch. Off = the whole HUD (and Focus slow-mo) is off.", false, false, (ValueValidator)null, (string)null);
pShowRadar = cat.CreateEntry<bool>("ShowRadar", true, "Show the radar (minimap)", "Off also switches off the map camera, so it costs nothing.", false, false, (ValueValidator)null, (string)null);
pShowHealth = cat.CreateEntry<bool>("ShowHealthBar", true, "Show the health bar", (string)null, false, false, (ValueValidator)null, (string)null);
pShowFocus = cat.CreateEntry<bool>("ShowFocusBar", true, "Show the Focus bar", "Hides only the bar; FocusEnabled controls the slow-mo ability itself.", false, false, (ValueValidator)null, (string)null);
pShowStamina = cat.CreateEntry<bool>("ShowStaminaBar", true, "Show the stamina bar", (string)null, false, false, (ValueValidator)null, (string)null);
pShowMoney = cat.CreateEntry<bool>("ShowMoney", true, "Show money", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarOutline = cat.CreateEntry<bool>("RadarOutline", true, "Radar: thin white outline", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarLogo = cat.CreateEntry<bool>("RadarLogo", true, "Radar: show the logo in the top-left corner", (string)null, false, false, (ValueValidator)null, (string)null);
pGloss = cat.CreateEntry<float>("RadarGlassEdge", 1f, "Radar: glass edge strength", "A glass bevel around the rim of the radar. 0 = off, 1 = default.", false, false, (ValueValidator)null, (string)null);
pBlockNative = cat.CreateEntry<bool>("FocusBlockGameSlowMo", true, "Block BONELAB's own slow-mo until Focus has enough", "While Focus is not active, BONELAB's built-in slow-mo is switched off so it cannot be used as a way around the kill requirement.", false, false, (ValueValidator)null, (string)null);
pShowWeapon = cat.CreateEntry<bool>("ShowWeaponAndAmmo", true, "Show weapon icon + ammo", (string)null, false, false, (ValueValidator)null, (string)null);
pHeadLocked = cat.CreateEntry<bool>("HeadLocked", true, "Head locked", "true = HUD follows your full head orientation. false = it lazily follows left/right turns only.", false, false, (ValueValidator)null, (string)null);
pFollowSpeed = cat.CreateEntry<float>("FollowSpeed", 4f, "Smooth-follow speed", (string)null, false, false, (ValueValidator)null, (string)null);
pFwd = cat.CreateEntry<float>("DistanceForward", 0.8f, "Distance in front of your head (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pAlwaysOnTop = cat.CreateEntry<bool>("AlwaysOnTop", true, "Draw over world geometry", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarX = cat.CreateEntry<float>("RadarRight", -0.3f, "Radar: offset right (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarY = cat.CreateEntry<float>("RadarHeight", -0.32f, "Radar: height of its centre (m, negative = below straight ahead)", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarWidth = cat.CreateEntry<float>("RadarWidthMeters", 0.17f, "Radar: width (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pBarsX = cat.CreateEntry<float>("FocusBarsRight", -0.31f, "Health + Focus bars: offset right (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pBarsY = cat.CreateEntry<float>("BarsTopUp", 0.18f, "Health / Stamina / Focus bars: height of their top edge (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pBarsWidth = cat.CreateEntry<float>("FocusBarsWidthMeters", 0.2f, "Health + Focus bars: width (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pMoneyX = cat.CreateEntry<float>("MoneyRight", 0.3f, "Money: offset right (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pMoneyY = cat.CreateEntry<float>("MoneyTopUp", 0.068f, "Money: height of its top edge (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pMoneyWidth = cat.CreateEntry<float>("MoneyWidthMeters", 0.15f, "Money: width (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pMoneySeconds = cat.CreateEntry<float>("MoneyShowSeconds", 4f, "Money: seconds shown after it changes", (string)null, false, false, (ValueValidator)null, (string)null);
pWeaponX = cat.CreateEntry<float>("WeaponRight", 0.3f, "Weapon icon + ammo: offset right (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pWeaponY = cat.CreateEntry<float>("WeaponTopUp", 0.18f, "Weapon icon + ammo: height of its top edge (m)", "0.18 = level with the top of the health bar, so the ammo row sits on the same line as the health bar.", false, false, (ValueValidator)null, (string)null);
pWeaponWidth = cat.CreateEntry<float>("WeaponWidthMeters", 0.15f, "Weapon icon + ammo: width (m)", (string)null, false, false, (ValueValidator)null, (string)null);
pLogHeld = cat.CreateEntry<bool>("LogHeldObjects", true, "Log held object names", "Logs what you hold and which icon was picked. Use it to fix icon mappings, then turn it off.", false, false, (ValueValidator)null, (string)null);
pRadarCam = cat.CreateEntry<bool>("RadarMapCamera", true, "Radar: render the map", "true = top-down map from a small low-rate camera. false = dark backdrop with blips only (cheapest).", false, false, (ValueValidator)null, (string)null);
pRadarRot = cat.CreateEntry<bool>("RadarRotates", true, "Radar rotates with your head (false = north-up)", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarBlips = cat.CreateEntry<bool>("RadarBlips", true, "Radar: show enemy / player blips", (string)null, false, false, (ValueValidator)null, (string)null);
pRadarNorth = cat.CreateEntry<bool>("RadarNorthBadge", true, "Radar: show the N badge on the edge", (string)null, false, false, (ValueValidator)null, (string)null);
pRange = cat.CreateEntry<float>("RadarRangeMeters", 20f, "Radar: metres from the centre to the top/bottom edge", (string)null, false, false, (ValueValidator)null, (string)null);
pMapHz = cat.CreateEntry<float>("RadarRefreshHz", 8f, "Map refresh rate (Hz)", "Lower = cheaper on Quest.", false, false, (ValueValidator)null, (string)null);
pBlipHz = cat.CreateEntry<float>("RadarBlipRefreshHz", 15f, "Blip position refresh rate (Hz)", (string)null, false, false, (ValueValidator)null, (string)null);
pMapRes = cat.CreateEntry<int>("RadarResolution", 224, "Map texture size (px)", (string)null, false, false, (ValueValidator)null, (string)null);
pCamH = cat.CreateEntry<float>("RadarCameraHeight", 1.5f, "Map camera height above head (m)", "Keep below ceilings.", false, false, (ValueValidator)null, (string)null);
pDim = cat.CreateEntry<float>("RadarDim", 0.85f, "Radar: map brightness (1 = unchanged)", (string)null, false, false, (ValueValidator)null, (string)null);
pFocus = cat.CreateEntry<bool>("FocusEnabled", true, "Focus (slow-mo) enabled", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusInput = cat.CreateEntry<string>("FocusInput", "BothSticks", "Focus trigger", "BothSticks (click both thumbsticks) | LeftStick | RightStick", false, false, (ValueValidator)null, (string)null);
pStamina = cat.CreateEntry<bool>("StaminaEnabled", true, "Stamina: sprinting drains it, and when it is empty you are slowed", "Off = the bar stays full and nothing slows you down.", false, false, (ValueValidator)null, (string)null);
pStamSeconds = cat.CreateEntry<float>("StaminaSprintSeconds", 14f, "Seconds of sprinting from a full bar", (string)null, false, false, (ValueValidator)null, (string)null);
pStamRegen = cat.CreateEntry<float>("StaminaRegenSeconds", 8f, "Seconds to refill from empty while not sprinting", (string)null, false, false, (ValueValidator)null, (string)null);
pStamSpeed = cat.CreateEntry<float>("StaminaSprintSpeed", 3f, "Horizontal speed (m/s) that counts as sprinting", "Measured from your head. Lower it if jogging doesn't drain the bar, raise it if walking does.", false, false, (ValueValidator)null, (string)null);
pStamSlow = cat.CreateEntry<float>("StaminaExhaustedSpeedFactor", 0.5f, "Your top speed while exhausted (x normal)", (string)null, false, false, (ValueValidator)null, (string)null);
pStamRecover = cat.CreateEntry<float>("StaminaRecoverFraction", 0.25f, "Bar level you must recover before the slowdown ends (0-1)", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusMin = cat.CreateEntry<float>("FocusMinToActivate", 0.4f, "Focus meter needed to activate it (0-1)", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusPassive = cat.CreateEntry<float>("FocusPassiveRechargeSeconds", 0f, "Seconds for Focus to refill by itself (0 = only kills fill it)", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusKillRefill = cat.CreateEntry<float>("FocusKillRefill", 0.2f, "Focus meter gained per NPC death (0-1)", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusCooldown = cat.CreateEntry<float>("FocusCooldownSeconds", 25f, "Focus cooldown after the bar runs out (s)", "When Focus runs dry it locks out for this long while the bar refills; no refill from kills during the cooldown.", false, false, (ValueValidator)null, (string)null);
pFocusSeconds = cat.CreateEntry<float>("FocusSeconds", 15f, "Seconds of Focus from a full meter", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusScale = cat.CreateEntry<float>("FocusFallbackScale", 0.3f, "Time scale used only if the game's own slow-mo does not respond", (string)null, false, false, (ValueValidator)null, (string)null);
pFocusMulti = cat.CreateEntry<bool>("FocusInMultiplayer", false, "Allow Focus while other Fusion players are present", "Off by default: slowing only your own game desyncs you from everyone else.", false, false, (ValueValidator)null, (string)null);
userDir = Path.Combine(MelonEnvironment.UserDataDirectory, "GTA6_HUD");
((MelonBase)this).LoggerInstance.Msg("GTA 6 HUD loaded.");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
if (assemblies[i].GetName().Name == "GTA_SA_HUD")
{
((MelonBase)this).LoggerInstance.Warning("The old GTA_SA_HUD.dll is also installed and will draw its own HUD on top of this one. Delete it from your Mods folder.");
}
}
BuildMenu();
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
yawInit = false;
capApplied = false;
stamHavePos = false;
if (slowActive)
{
EndFocus();
}
}
public override void OnUpdate()
{
if (buildFailed || !pEnabled.Value)
{
ApplyVisibility(rigOk: false);
if (slowActive)
{
EndFocus();
}
ApplyCap(on: false);
RestoreNativeSlowMo();
return;
}
try
{
Transform head = GetHead();
bool flag = (Object)(object)head != (Object)null && (Object)(object)Player.RigManager != (Object)null;
if (built && (Object)(object)barsRoot == (Object)null)
{
built = false;
visible = false;
radarBuilt = false;
}
if (!built)
{
if (!flag)
{
return;
}
BuildAll();
if (!built)
{
return;
}
}
ApplyVisibility(flag);
if (!flag)
{
if (slowActive)
{
EndFocus();
}
capApplied = false;
return;
}
float unscaledDeltaTime = Time.unscaledDeltaTime;
fastTimer += unscaledDeltaTime;
slowTimer += unscaledDeltaTime;
if (pShowHealth.Value)
{
if (fastTimer >= 0.1f)
{
fastTimer = 0f;
ReadHealth();
}
AnimateHealth(unscaledDeltaTime);
}
else
{
fastTimer = 0.1f;
}
if (pShowMoney.Value)
{
if (slowTimer >= 0.25f)
{
slowTimer = 0f;
UpdateMoney();
}
AnimateMoney(unscaledDeltaTime);
}
else
{
haveBits = false;
shownBits = -1;
moneyTimer = 0f;
moneyDelta = 0;
moneyAlpha = 0f;
if ((Object)(object)moneyGroup != (Object)null)
{
moneyGroup.alpha = 0f;
}
}
if (pShowWeapon.Value)
{
UpdateWeapon(unscaledDeltaTime);
}
else
{
lastSig = null;
weaponAlpha = 0f;
weaponShow = false;
if ((Object)(object)weaponGroup != (Object)null)
{
weaponGroup.alpha = 0f;
}
}
UpdateStamina(unscaledDeltaTime, head);
UpdateFocus(unscaledDeltaTime);
int num;
if (radarBuilt && !radarFailed)
{
num = (pShowRadar.Value ? 1 : 0);
if (num != 0 && pRadarBlips.Value)
{
goto IL_023e;
}
}
else
{
num = 0;
}
if (pFocus.Value)
{
goto IL_023e;
}
goto IL_0245;
IL_023e:
TrackNpcs(unscaledDeltaTime);
goto IL_0245;
IL_0245:
if (num == 0)
{
return;
}
try
{
UpdateRadar(head, unscaledDeltaTime);
}
catch (Exception ex)
{
radarFailed = true;
if ((Object)(object)radarCam != (Object)null)
{
((Behaviour)radarCam).enabled = false;
}
if ((Object)(object)radarRoot != (Object)null)
{
radarRoot.SetActive(false);
}
((MelonBase)this).LoggerInstance.Error("Radar disabled after error: " + ex);
}
}
catch (Exception ex2)
{
LogOnce("update", ex2);
}
}
public override void OnLateUpdate()
{
if (!built || !visible)
{
return;
}
try
{
FollowHead();
}
catch (Exception ex)
{
LogOnce("follow", ex);
}
}
private void SetPref(MelonPreferences_Entry<bool> e, bool v)
{
e.Value = v;
try
{
MelonPreferences.Save();
}
catch
{
}
}
private void BuildMenu()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
try
{
Page val = Page.Root.CreatePage("GTA 6 HUD", Pink, 0, true);
BoolElement master = val.CreateBool("HUD enabled", Color.white, pEnabled.Value, (Action<bool>)delegate(bool v)
{
SetPref(pEnabled, v);
});
BoolElement radar = val.CreateBool("Radar (minimap)", Color.white, pShowRadar.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowRadar, v);
});
BoolElement blips = val.CreateBool(" Radar: enemy/player blips", Color.white, pRadarBlips.Value, (Action<bool>)delegate(bool v)
{
SetPref(pRadarBlips, v);
});
BoolElement north = val.CreateBool(" Radar: N badge", Color.white, pRadarNorth.Value, (Action<bool>)delegate(bool v)
{
SetPref(pRadarNorth, v);
});
BoolElement rot = val.CreateBool(" Radar: rotates with head", Color.white, pRadarRot.Value, (Action<bool>)delegate(bool v)
{
SetPref(pRadarRot, v);
});
BoolElement health = val.CreateBool("Health bar", Color.white, pShowHealth.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowHealth, v);
});
BoolElement stamBar = val.CreateBool("Stamina bar", Color.white, pShowStamina.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowStamina, v);
});
BoolElement stamAbility = val.CreateBool("Stamina (sprint limit)", Color.white, pStamina.Value, (Action<bool>)delegate(bool v)
{
SetPref(pStamina, v);
});
BoolElement focusBarEl = val.CreateBool("Focus bar", Color.white, pShowFocus.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowFocus, v);
});
BoolElement ability = val.CreateBool("Focus slow-mo ability", Color.white, pFocus.Value, (Action<bool>)delegate(bool v)
{
SetPref(pFocus, v);
});
BoolElement money = val.CreateBool("Money", Color.white, pShowMoney.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowMoney, v);
});
BoolElement weapon = val.CreateBool("Weapon icon + ammo", Color.white, pShowWeapon.Value, (Action<bool>)delegate(bool v)
{
SetPref(pShowWeapon, v);
});
val.CreateFunction("Turn everything on", Color.green, (Action)delegate
{
SetPref(pEnabled, v: true);
master.Value = true;
SetPref(pShowRadar, v: true);
radar.Value = true;
SetPref(pRadarBlips, v: true);
blips.Value = true;
SetPref(pRadarNorth, v: true);
north.Value = true;
SetPref(pRadarRot, v: true);
rot.Value = true;
SetPref(pShowHealth, v: true);
health.Value = true;
SetPref(pShowStamina, v: true);
stamBar.Value = true;
SetPref(pStamina, v: true);
stamAbility.Value = true;
SetPref(pShowFocus, v: true);
focusBarEl.Value = true;
SetPref(pFocus, v: true);
ability.Value = true;
SetPref(pShowMoney, v: true);
money.Value = true;
SetPref(pShowWeapon, v: true);
weapon.Value = true;
});
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("BoneMenu page not created (the settings still work from the config file): " + ex.Message);
}
}
private GameObject MakeCanvasRoot(string name, float w, float h)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_000c: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
GameObject val = new GameObject(name);
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<Canvas>().renderMode = (RenderMode)2;
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(w, h);
component.pivot = new Vector2(0.5f, 0.5f);
return val;
}
private void BuildAll()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
try
{
LoadGlyphs();
if (pAlwaysOnTop.Value)
{
try
{
Shader val = Shader.Find("UI/Default");
if ((Object)(object)val != (Object)null)
{
uiMat = new Material(val);
uiMat.SetInt("unity_GUIZTestMode", 8);
((Object)uiMat).hideFlags = (HideFlags)32;
}
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("Always-on-top material failed: " + ex.Message);
}
}
BuildBars();
BuildMoney();
BuildWeapon();
BuildRadar();
built = true;
visible = true;
((MelonBase)this).LoggerInstance.Msg("HUD built.");
}
catch (Exception ex2)
{
buildFailed = true;
((MelonBase)this).LoggerInstance.Error("HUD build failed, disabling mod: " + ex2);
}
}
private void BuildBars()
{
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
barsRoot = MakeCanvasRoot("GTA6_Bars", 400f, 184f);
healthGroup = MakeGroup(barsRoot.transform, "HealthGroup", 400f, 184f);
staminaGroup = MakeGroup(barsRoot.transform, "StaminaGroup", 400f, 184f);
focusGroup = MakeGroup(barsRoot.transform, "FocusGroup", 400f, 184f);
Sprite s = SpriteFromBytes(ReadResource("Bars/heart.png"), mips: true);
Sprite s2 = SpriteFromBytes(ReadResource("Bars/stamina.png"), mips: true);
Sprite s3 = SpriteFromBytes(ReadResource("Bars/eye.png"), mips: true);
MakeImage("HeartIcon", healthGroup.transform, 0f, 0f, 56f, 56f, Color.white, s);
healthBar = new Bar(this, healthGroup.transform, "Health", 70f, 14f, 330f, 28f, 3f, Pink, BarDark);
healthTick = MakeImage("HealthTick", healthGroup.transform, 70f, 17f, 4f, 22f, Color.white, null);
((Behaviour)healthTick).enabled = false;
MakeImage("StaminaIcon", staminaGroup.transform, 0f, 64f, 56f, 56f, Color.white, s2);
staminaBar = new Bar(this, staminaGroup.transform, "Stamina", 70f, 78f, 330f, 28f, 3f, BabyGreen, BarDark);
MakeImage("EyeIcon", focusGroup.transform, 0f, 128f, 56f, 56f, Color.white, s3);
focusBar = new Bar(this, focusGroup.transform, "Focus", 70f, 142f, 264f, 28f, 3f, Purple, BarDark);
focusTick = MakeImage("FocusThreshold", focusGroup.transform, 70f, 145f, 3f, 22f, new Color(1f, 1f, 1f, 0.85f), null);
healthBar.Set(1f);
staminaBar.Set(stamina);
focusBar.Set(charge);
}
private void BuildMoney()
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
moneyRoot = MakeCanvasRoot("GTA6_Money", 300f, 110f);
moneyGroup = moneyRoot.AddComponent<CanvasGroup>();
moneyGroup.interactable = false;
moneyGroup.blocksRaycasts = false;
moneyGroup.alpha = 0f;
moneyLabel = new GlyphLabel(this, moneyRoot.transform, "Money", 66f, GlyphLabel.Align.Right, 296f, 0f, Color.white);
deltaLabel = new GlyphLabel(this, moneyRoot.transform, "Delta", 38f, GlyphLabel.Align.Right, 296f, 70f, MoneyGreen);
moneyLabel.SetText("$0");
}
private void BuildRadar()
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
try
{
Sprite s = SpriteFromBytes(ReadResource("Radar/mask.png"), mips: true);
Sprite val = SpriteFromBytes(ReadResource("Radar/logo.png"), mips: true);
Sprite sp = SpriteFromBytes(ReadResource("Radar/outline.png"), mips: true);
Sprite sp2 = SpriteFromBytes(ReadResource("Radar/marker.png"), mips: true);
Sprite sp3 = SpriteFromBytes(ReadResource("Radar/north.png"), mips: true);
Sprite sp4 = SpriteFromBytes(ReadResource("Radar/blip.png"), mips: true);
radarRoot = MakeCanvasRoot("GTA6_Radar", 280f, 200f);
Image val2 = MakeImage("RadarMask", radarRoot.transform, 0f, 0f, 280f, 200f, Color.white, s);
((Component)val2).gameObject.AddComponent<Mask>().showMaskGraphic = false;
if (pRadarCam.Value)
{
BuildMapCamera();
float num = 200f * Mathf.Sqrt(2.96f) * 1.04f;
GameObject val3 = new GameObject("RadarMap");
val3.transform.SetParent(((Component)val2).transform, false);
RectTransform obj = val3.AddComponent<RectTransform>();
Vector2 val4 = (obj.pivot = new Vector2(0.5f, 0.5f));
Vector2 anchorMin = (obj.anchorMax = val4);
obj.anchorMin = anchorMin;
obj.anchoredPosition = Vector2.zero;
obj.sizeDelta = new Vector2(num, num);
radarMap = val3.AddComponent<RawImage>();
radarMap.texture = (Texture)(object)radarRT;
((Graphic)radarMap).raycastTarget = false;
float num2 = Mathf.Clamp01(pDim.Value);
((Graphic)radarMap).color = new Color(num2, num2, Mathf.Min(1f, num2 * 1.03f), 1f);
if ((Object)(object)uiMat != (Object)null)
{
((Graphic)radarMap).material = uiMat;
}
((Behaviour)radarMap).enabled = false;
}
else
{
MakeCenterImage("RadarBackdrop", ((Component)val2).transform, 280f, 200f, new Color(0.16f, 0.18f, 0.2f, 1f), null);
}
for (int i = 0; i < 40; i++)
{
Image val7 = MakeCenterImage("Blip" + i, ((Component)val2).transform, 14f, 14f, Color.white, sp4);
((Component)val7).gameObject.SetActive(false);
blipPool.Add(val7);
}
if (pRadarOutline.Value)
{
MakeCenterImage("RadarOutline", radarRoot.transform, 280f, 200f, new Color(1f, 1f, 1f, 0.92f), sp);
}
if (pRadarLogo.Value)
{
float num3 = 30f;
Rect rect = val.rect;
float num4 = num3 * ((Rect)(ref rect)).height;
rect = val.rect;
float h = num4 / ((Rect)(ref rect)).width;
((Graphic)MakeCenterImage("RadarLogo", radarRoot.transform, num3, h, new Color(1f, 1f, 1f, 0.95f), val)).rectTransform.anchoredPosition = new Vector2(-115f, 76f);
}
northBadge = MakeCenterImage("NorthBadge", radarRoot.transform, 15f, 15f, Color.white, sp3);
((Component)northBadge).gameObject.SetActive(pRadarNorth.Value);
radarMarker = MakeCenterImage("PlayerMarker", radarRoot.transform, 26f, 26f, Color.white, sp2);
radarBuilt = true;
((MelonBase)this).LoggerInstance.Msg("Radar built (" + (pRadarCam.Value ? "map camera" : "blips only") + ").");
}
catch (Exception ex)
{
radarFailed = true;
((MelonBase)this).LoggerInstance.Error("Radar build failed, radar disabled (rest of the HUD unaffected): " + ex);
}
}
private void BuildMapCamera()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
int num = Mathf.Clamp(pMapRes.Value, 64, 512);
radarRT = new RenderTexture(num, num, 16, (RenderTextureFormat)0);
radarRT.antiAliasing = 1;
((Texture)radarRT).filterMode = (FilterMode)1;
((Object)radarRT).hideFlags = (HideFlags)32;
radarRT.Create();
GameObject val = new GameObject("GTA6_RadarCam");
Object.DontDestroyOnLoad((Object)(object)val);
radarCam = val.AddComponent<Camera>();
radarCam.orthographic = true;
radarCam.nearClipPlane = 0.3f;
radarCam.farClipPlane = 60f;
radarCam.clearFlags = (CameraClearFlags)2;
radarCam.backgroundColor = new Color(0.1f, 0.12f, 0.14f, 1f);
radarCam.allowHDR = false;
radarCam.allowMSAA = false;
radarCam.useOcclusionCulling = false;
radarCam.stereoTargetEye = (StereoTargetEyeMask)0;
radarCam.depth = -20f;
radarCam.cullingMask = -291;
radarCam.targetTexture = radarRT;
((Behaviour)radarCam).enabled = false;
TrimUrpCamera(radarCam);
}
private void TrimUrpCamera(Camera cam)
{
try
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
if (assembly.GetName().Name != "Unity.RenderPipelines.Universal.Runtime")
{
continue;
}
object obj = (assembly.GetType("UnityEngine.Rendering.Universal.CameraExtensions")?.GetMethod("GetUniversalAdditionalCameraData", BindingFlags.Static | BindingFlags.Public))?.Invoke(null, new object[1] { cam });
if (obj == null)
{
break;
}
string[] array = new string[4] { "renderShadows", "renderPostProcessing", "requiresDepthTexture", "requiresColorTexture" };
foreach (string name in array)
{
try
{
obj.GetType().GetProperty(name)?.SetValue(obj, false);
}
catch
{
}
}
((MelonBase)this).LoggerInstance.Msg("Radar camera: URP shadows/post/depth disabled.");
break;
}
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("Radar camera trim failed: " + ex.Message);
}
}
private static void SetActiveIf(GameObject go, bool on)
{
if ((Object)(object)go != (Object)null && go.activeSelf != on)
{
go.SetActive(on);
}
}
private void ApplyVisibility(bool rigOk)
{
if (!((Object)(object)barsRoot == (Object)null))
{
bool flag = (visible = rigOk && pEnabled.Value && !buildFailed);
SetActiveIf(barsRoot, flag && (pShowHealth.Value || pShowStamina.Value || pShowFocus.Value));
SetActiveIf(staminaGroup, flag && pShowStamina.Value);
SetActiveIf(healthGroup, flag && pShowHealth.Value);
SetActiveIf(focusGroup, flag && pShowFocus.Value);
SetActiveIf(moneyRoot, flag && pShowMoney.Value);
SetActiveIf(weaponRoot, flag && pShowWeapon.Value);
bool flag2 = flag && pShowRadar.Value && radarBuilt && !radarFailed;
SetActiveIf(radarRoot, flag2);
if (!flag2 && (Object)(object)radarCam != (Object)null && (((Behaviour)radarCam).enabled || radarArmed))
{
((Behaviour)radarCam).enabled = false;
radarArmed = false;
}
}
}
private GameObject MakeGroup(Transform parent, string name, float w, float h)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
GameObject val = new GameObject(name);
val.transform.SetParent(parent, false);
RectTransform obj = val.AddComponent<RectTransform>();
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 1f);
obj.pivot = val2;
Vector2 anchorMin = (obj.anchorMax = val2);
obj.anchorMin = anchorMin;
obj.anchoredPosition = Vector2.zero;
obj.sizeDelta = new Vector2(w, h);
return val;
}
internal Image MakeImage(string name, Transform parent, float x, float y, float w, float h, Color c, Sprite s)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0054: 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)
GameObject val = new GameObject(name);
val.transform.SetParent(parent, false);
RectTransform obj = val.AddComponent<RectTransform>();
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 1f);
obj.pivot = val2;
Vector2 anchorMin = (obj.anchorMax = val2);
obj.anchorMin = anchorMin;
obj.anchoredPosition = new Vector2(x, 0f - y);
obj.sizeDelta = new Vector2(w, h);
Image val4 = val.AddComponent<Image>();
val4.sprite = s;
((Graphic)val4).color = c;
((Graphic)val4).raycastTarget = false;
if ((Object)(object)uiMat != (Object)null)
{
((Graphic)val4).material = uiMat;
}
return val4;
}
private Image MakeCenterImage(string name, Transform parent, float w, float h, Color c, Sprite sp)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Image obj = MakeImage(name, parent, 0f, 0f, w, h, c, sp);
RectTransform rectTransform = ((Graphic)obj).rectTransform;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0.5f);
rectTransform.pivot = val;
Vector2 anchorMin = (rectTransform.anchorMax = val);
rectTransform.anchorMin = anchorMin;
rectTransform.anchoredPosition = Vector2.zero;
return obj;
}
private void FollowHead()
{
//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_00c3: 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_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
Transform head = GetHead();
if ((Object)(object)head == (Object)null)
{
return;
}
bool flag = !pHeadLocked.Value;
Quaternion yaw = Quaternion.identity;
if (flag)
{
float y = head.eulerAngles.y;
if (!yawInit)
{
smoothYaw = y;
yawInit = true;
}
smoothYaw = Mathf.LerpAngle(smoothYaw, y, 1f - Mathf.Exp((0f - Mathf.Max(0.1f, pFollowSpeed.Value)) * Time.unscaledDeltaTime));
yaw = Quaternion.Euler(0f, smoothYaw, 0f);
}
float value = pFwd.Value;
float num = pBarsWidth.Value / 400f;
Place(barsRoot, head, flag, yaw, new Vector3(pBarsX.Value, pBarsY.Value - 184f * num * 0.5f, value), num);
float num2 = pMoneyWidth.Value / 300f;
float num3 = pWeaponWidth.Value / 300f;
Place(moneyRoot, head, flag, yaw, new Vector3(pMoneyX.Value, pMoneyY.Value - 110f * num2 * 0.5f, value), num2);
Place(weaponRoot, head, flag, yaw, new Vector3(pWeaponX.Value, pWeaponY.Value - 215f * num3 * 0.5f, value), num3);
if (radarBuilt)
{
Place(radarRoot, head, flag, yaw, new Vector3(pRadarX.Value, pRadarY.Value, value), pRadarWidth.Value / 280f);
}
}
private static void Place(GameObject go, Transform head, bool lazy, Quaternion yaw, Vector3 off, float scale)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0062: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)go == (Object)null))
{
Transform transform = go.transform;
if (lazy)
{
transform.position = head.position + yaw * off;
transform.rotation = yaw;
}
else
{
transform.position = head.TransformPoint(off);
transform.rotation = head.rotation;
}
transform.localScale = Vector3.one * Mathf.Max(0.0001f, scale);
}
}
private static Transform GetHead()
{
Transform val = null;
try
{
val = Player.Head;
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
Camera main = Camera.main;
if ((Object)(object)main != (Object)null)
{
val = ((Component)main).transform;
}
}
return val;
}
private void ReadHealth()
{
Health health = Player.RigManager.health;
if ((Object)(object)health == (Object)null)
{
return;
}
Player_Health val = ((Il2CppObjectBase)health).TryCast<Player_Health>();
if (!((Object)(object)val == (Object)null))
{
float num = ((Health)val).max_Health;
if (num <= 0f)
{
num = 100f;
}
healthFrac = Mathf.Clamp01(((Health)val).curr_Health / num);
}
}
private void AnimateHealth(float dt)
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
if (healthFrac < lastHealth - 0.002f)
{
healthTrail = Mathf.Max(healthTrail, lastHealth);
trailHold = 0.7f;
}
lastHealth = healthFrac;
if (healthTrail > healthFrac)
{
if (trailHold > 0f)
{
trailHold -= dt;
}
else
{
healthTrail = Mathf.Max(healthFrac, healthTrail - dt * 0.25f);
}
}
else
{
healthTrail = healthFrac;
}
healthBar.Set(healthFrac);
bool flag = healthTrail > healthFrac + 0.01f;
((Behaviour)healthTick).enabled = flag;
if (flag)
{
((Graphic)healthTick).rectTransform.anchoredPosition = new Vector2(73f + healthTrail * 324f - 2f, -17f);
}
healthBar.SetFillColor((healthFrac < 0.25f) ? Color.Lerp(Pink, new Color(1f, 0.25f, 0.3f, 1f), 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 8f)) : Pink);
}
private void UpdateMoney()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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)
int num = ReadBits();
if (!haveBits)
{
haveBits = true;
lastBits = num;
}
else if (num != lastBits)
{
moneyDelta += num - lastBits;
lastBits = num;
moneyTimer = Mathf.Max(0.5f, pMoneySeconds.Value);
}
if (num != shownBits)
{
shownBits = num;
moneyLabel.SetText("$" + Mathf.Max(0, num).ToString("N0", CultureInfo.InvariantCulture));
}
if (moneyDelta != 0)
{
string s = ((moneyDelta > 0) ? "+$" : "-$") + Mathf.Abs(moneyDelta).ToString("N0", CultureInfo.InvariantCulture);
deltaLabel.Tint = ((moneyDelta > 0) ? MoneyGreen : MoneyRed);
deltaLabel.SetText(s);
}
else
{
deltaLabel.SetText("");
}
}
private void AnimateMoney(float dt)
{
if (moneyTimer > 0f)
{
moneyTimer -= dt;
}
else if (moneyDelta != 0 && moneyAlpha <= 0.01f)
{
moneyDelta = 0;
}
float num = ((moneyTimer > 0f) ? 1f : 0f);
moneyAlpha = Mathf.MoveTowards(moneyAlpha, num, dt * ((num > moneyAlpha) ? 6f : 1.2f));
moneyGroup.alpha = moneyAlpha;
}
private int ReadBits()
{
if (bitsMethod == null)
{
if (Time.unscaledTime < nextBitsSearch)
{
return lastBits;
}
nextBitsSearch = Time.unscaledTime + 10f;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
if (!(assembly.GetName().Name != "LabFusion"))
{
MethodInfo methodInfo = assembly.GetType("LabFusion.SDK.Points.PointItemManager")?.GetMethod("GetBitCount", BindingFlags.Static | BindingFlags.Public);
if (methodInfo != null)
{
bitsMethod = methodInfo;
((MelonBase)this).LoggerInstance.Msg("Money: using LabFusion bits.");
break;
}
}
}
if (bitsMethod == null)
{
return lastBits;
}
}
try
{
return Convert.ToInt32(bitsMethod.Invoke(null, null));
}
catch (Exception ex)
{
LogOnce("bits", ex);
bitsMethod = null;
}
return lastBits;
}
private void UpdateStamina(float dt, Transform head)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: 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_0203: Unknown result type (might be due to invalid IL or missing references)
if (!pStamina.Value)
{
stamina = 1f;
exhausted = false;
stamHavePos = false;
ApplyCap(on: false);
staminaBar.Set(1f);
staminaBar.SetFillColor(BabyGreen);
return;
}
Vector3 position = head.position;
float num = 0f;
if (stamHavePos && dt > 0.0001f)
{
Vector3 val = position - stamLastPos;
val.y = 0f;
num = Mathf.Min(15f, ((Vector3)(ref val)).magnitude / dt);
}
stamLastPos = position;
stamHavePos = true;
stamSpeed += (num - stamSpeed) * (1f - Mathf.Exp(-6f * dt));
float num2 = Mathf.Max(0.5f, pStamSpeed.Value);
if (stamSpeed >= num2)
{
if (!exhausted)
{
stamina -= dt / Mathf.Max(1f, pStamSeconds.Value);
}
}
else
{
float num3 = ((stamSpeed < 0.5f) ? 1.5f : 1f);
stamina += dt / Mathf.Max(1f, pStamRegen.Value) * num3;
}
stamina = Mathf.Clamp01(stamina);
if (!exhausted && stamina <= 0f)
{
exhausted = true;
((MelonBase)this).LoggerInstance.Msg("Stamina empty: slowed until it recovers.");
}
else if (exhausted && stamina >= Mathf.Clamp01(pStamRecover.Value))
{
exhausted = false;
((MelonBase)this).LoggerInstance.Msg("Stamina recovered.");
}
ApplyCap(exhausted);
staminaBar.Set(stamina);
staminaBar.SetFillColor(exhausted ? Color.Lerp(new Color(0.36f, 0.52f, 0.38f, 1f), BabyGreen, 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 6f)) : BabyGreen);
}
private void ApplyCap(bool on)
{
if (!on && !capApplied)
{
return;
}
try
{
RigManager rigManager = Player.RigManager;
RemapRig val = (((Object)(object)rigManager == (Object)null) ? null : rigManager.remapHeptaRig);
if ((Object)(object)val == (Object)null)
{
capApplied = false;
return;
}
float num = Mathf.Clamp(pStamSlow.Value, 0.1f, 1f);
if (on)
{
if (!capApplied)
{
baseMaxVel = val.maxVelocity;
baseCurMaxVel = val.currentMaxVelocity;
capApplied = true;
((MelonBase)this).LoggerInstance.Msg("Stamina: capping top speed (maxVelocity " + baseMaxVel.ToString("0.00") + " -> " + (baseMaxVel * num).ToString("0.00") + ").");
}
val.maxVelocity = baseMaxVel * num;
val.currentMaxVelocity = baseCurMaxVel * num;
}
else
{
val.maxVelocity = baseMaxVel;
val.currentMaxVelocity = baseCurMaxVel;
capApplied = false;
}
}
catch (Exception ex)
{
LogOnce("stamina-cap", ex);
capApplied = false;
}
}
private void UpdateRadar(Transform head, float dt)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: 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_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
bool value = pRadarRot.Value;
float y = head.eulerAngles.y;
float num = (value ? y : 0f);
Vector3 position = head.position;
float num2 = Mathf.Max(5f, pRange.Value);
float num3 = 100f / num2;
float num4 = num * ((float)Math.PI / 180f);
float num5 = Mathf.Cos(num4);
float num6 = Mathf.Sin(num4);
((Transform)((Graphic)radarMarker).rectTransform).localRotation = Quaternion.Euler(0f, 0f, value ? 0f : (0f - y));
if (pRadarNorth.Value)
{
((Component)northBadge).gameObject.SetActive(true);
float num7 = 0f - num6;
float num8 = num5;
float num9 = 137f;
float num10 = 97f;
float num11 = ((Mathf.Abs(num7) > 0.0001f) ? (num9 / Mathf.Abs(num7)) : float.MaxValue);
float num12 = ((Mathf.Abs(num8) > 0.0001f) ? (num10 / Mathf.Abs(num8)) : float.MaxValue);
float num13 = Mathf.Min(num11, num12);
((Graphic)northBadge).rectTransform.anchoredPosition = new Vector2(num7 * num13, num8 * num13);
}
else
{
((Component)northBadge).gameObject.SetActive(false);
}
if ((Object)(object)radarCam != (Object)null)
{
if (radarArmed)
{
((Behaviour)radarCam).enabled = false;
radarArmed = false;
}
radarTimer += dt;
if (radarTimer >= 1f / Mathf.Max(1f, pMapHz.Value))
{
radarTimer = 0f;
radarCam.orthographicSize = num2 * Mathf.Sqrt(2.96f) * 1.04f;
((Component)radarCam).transform.position = new Vector3(position.x, position.y + pCamH.Value, position.z);
((Component)radarCam).transform.rotation = Quaternion.Euler(90f, num, 0f);
((Behaviour)radarCam).enabled = true;
radarArmed = true;
renderPos = position;
renderYaw = num;
renderRange = num2;
if (!haveRender)
{
haveRender = true;
if ((Object)(object)radarMap != (Object)null)
{
((Behaviour)radarMap).enabled = true;
}
}
}
if (haveRender && (Object)(object)radarMap != (Object)null)
{
float num14 = num - renderYaw;
Vector3 val = renderPos - position;
float num15 = val.x * num5 - val.z * num6;
float num16 = val.x * num6 + val.z * num5;
((Transform)((Graphic)radarMap).rectTransform).localScale = Vector3.one * (renderRange / num2);
((Transform)((Graphic)radarMap).rectTransform).localRotation = Quaternion.Euler(0f, 0f, num14);
((Graphic)radarMap).rectTransform.anchoredPosition = new Vector2(num15 * num3, num16 * num3);
}
}
int num17 = 0;
if (pRadarBlips.Value)
{
num17 = PlaceBlips(enemyBlips, num17, position, num5, num6, num3);
num17 = PlaceBlips(playerBlips, num17, position, num5, num6, num3);
}
for (int i = num17; i < blipPool.Count; i++)
{
if (((Component)blipPool[i]).gameObject.activeSelf)
{
((Component)blipPool[i]).gameObject.SetActive(false);
}
}
}
private void TrackNpcs(float dt)
{
scanTimer += dt;
if (scanTimer >= 0.5f)
{
scanTimer = 0f;
ScanBlips();
blipTimer = 0f;
}
blipTimer += dt;
if (blipTimer >= 1f / Mathf.Max(1f, pBlipHz.Value))
{
blipTimer = 0f;
RefreshBlips();
}
}
private int PlaceBlips(List<Blip> list, int used, Vector3 posNow, float c, float sn, float pxPerM)
{
//IL_0034: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
float num = 131f;
float num2 = 91f;
foreach (Blip item in list)
{
if (used >= blipPool.Count)
{
break;
}
float num3 = item.P.x - posNow.x;
float num4 = item.P.z - posNow.z;
float num5 = (num3 * c - num4 * sn) * pxPerM;
float num6 = (num3 * sn + num4 * c) * pxPerM;
bool flag = Mathf.Abs(num5) > num || Mathf.Abs(num6) > num2;
if (flag)
{
float num7 = Mathf.Min(num / Mathf.Max(0.001f, Mathf.Abs(num5)), num2 / Mathf.Max(0.001f, Mathf.Abs(num6)));
num5 *= num7;
num6 *= num7;
}
Image val = blipPool[used++];
if (!((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(true);
}
((Graphic)val).color = (Color)(flag ? new Color(item.C.r, item.C.g, item.C.b, 0.65f) : item.C);
RectTransform rectTransform = ((Graphic)val).rectTransform;
rectTransform.anchoredPosition = new Vector2(num5, num6);
float num8 = (flag ? 10f : 14f);
rectTransform.sizeDelta = new Vector2(num8, num8);
}
return used;
}
private void ScanBlips()
{
List<Npc> list = new List<Npc>(npcCache);
npcCache.Clear();
playerCache.Clear();
try
{
foreach (AIBrain item in Object.FindObjectsOfType<AIBrain>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
Npc npc = new Npc
{
Brain = item,
Puppet = item.puppetMaster
};
try
{
PuppetMaster puppet = npc.Puppet;
if ((Object)(object)puppet != (Object)null)
{
Il2CppReferenceArray<Muscle> muscles = puppet.muscles;
if (muscles != null && ((Il2CppArrayBase<Muscle>)(object)muscles).Length > 0 && ((Il2CppArrayBase<Muscle>)(object)muscles)[0] != null)
{
npc.Body = ((Il2CppArrayBase<Muscle>)(object)muscles)[0].transform;
}
if ((Object)(object)npc.Body == (Object)null && (Object)(object)puppet.targetRoot != (Object)null)
{
npc.Body = puppet.targetRoot;
}
}
}
catch (Exception ex)
{
LogOnce("npc-body", ex);
}
if ((Object)(object)npc.Body == (Object)null)
{
npc.Body = ((Component)item).transform;
}
try
{
npc.WasAlive = !item.isDead && (!((Object)(object)npc.Puppet != (Object)null) || !npc.Puppet.isDead);
}
catch
{
}
foreach (Npc item2 in list)
{
if ((Object)(object)item2.Brain != (Object)null && ((Il2CppObjectBase)item2.Brain).Pointer == ((Il2CppObjectBase)item).Pointer)
{
npc.WasAlive = item2.WasAlive;
break;
}
}
npcCache.Add(npc);
}
}
catch (Exception ex2)
{
LogOnce("scan-npc", ex2);
}
if (npcCache.Count != lastNpcCount)
{
lastNpcCount = npcCache.Count;
((MelonBase)this).LoggerInstance.Msg("Radar: tracking " + npcCache.Count + " NPC(s).");
}
if (FusionPresent())
{
try
{
CollectFusionPlayers();
}
catch (Exception ex3)
{
LogOnce("fusion-players", ex3);
}
}
if (playerCache.Count != lastPlayerCount)
{
lastPlayerCount = playerCache.Count;
((MelonBase)this).LoggerInstance.Msg("Radar: tracking " + playerCache.Count + " Fusion player(s).");
}
RefreshBlips();
}
private static bool FusionPresent()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
if (assemblies[i].GetName().Name == "LabFusion")
{
return true;
}
}
return false;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void CollectFusionPlayers()
{
foreach (NetworkPlayer player in NetworkPlayer.Players)
{
if (player == null)
{
continue;
}
PlayerID playerID = player.PlayerID;
if (playerID == null || playerID.IsMe || !player.HasRig)
{
continue;
}
RigRefs rigRefs = player.RigRefs;
if (rigRefs != null && rigRefs.IsValid)
{
Transform head = rigRefs.Head;
if (!((Object)(object)head == (Object)null))
{
playerCache.Add(new FusionPlayer
{
Head = head,
Id = playerID.SmallID
});
}
}
}
}
private void RefreshBlips()
{
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
enemyBlips.Clear();
playerBlips.Clear();
try
{
foreach (Npc item in npcCache)
{
if ((Object)(object)item.Brain == (Object)null)
{
continue;
}
if (item.Brain.isDead || ((Object)(object)item.Puppet != (Object)null && item.Puppet.isDead))
{
if (item.WasAlive)
{
item.WasAlive = false;
pendingKills++;
}
}
else if (!((Object)(object)item.Body == (Object)null) && ((Component)item.Body).gameObject.activeInHierarchy)
{
enemyBlips.Add(new Blip
{
P = item.Body.position,
C = EnemyRed
});
}
}
}
catch (Exception ex)
{
LogOnce("refresh-npc", ex);
}
try
{
foreach (FusionPlayer item2 in playerCache)
{
if (!((Object)(object)item2.Head == (Object)null))
{
playerBlips.Add(new Blip
{
P = item2.Head.position,
C = PlayerPalette[item2.Id % PlayerPalette.Length]
});
}
}
}
catch (Exception ex2)
{
LogOnce("refresh-players", ex2);
}
}
private void UpdateFocus(float dt)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_041e: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
if (!pFocus.Value)
{
if (slowActive)
{
EndFocus();
}
RestoreNativeSlowMo();
return;
}
try
{
float num = Mathf.Clamp(pFocusMin.Value, 0.02f, 1f);
if (tickShownAt != num)
{
tickShownAt = num;
((Graphic)focusTick).rectTransform.anchoredPosition = new Vector2(73f + num * 258f - 1.5f, -145f);
}
if (pBlockNative.Value && !slowActive)
{
if (!nativeSaved)
{
nativeSetting = TimeManager.slowMoEnabled;
nativeSaved = true;
}
if (TimeManager.slowMoEnabled)
{
TimeManager.slowMoEnabled = false;
}
}
else if (!pBlockNative.Value)
{
RestoreNativeSlowMo();
}
float num2 = Mathf.Max(1f, pFocusCooldown.Value);
if (cooling)
{
coolT += dt;
if (coolT >= num2)
{
cooling = false;
((MelonBase)this).LoggerInstance.Msg("Focus lockout over.");
}
}
if (slowActive)
{
charge -= dt / Mathf.Max(1f, pFocusSeconds.Value);
}
else if (pFocusPassive.Value > 0f)
{
charge += dt / pFocusPassive.Value;
}
if (pendingKills > 0)
{
charge += (float)pendingKills * pFocusKillRefill.Value;
pendingKills = 0;
}
charge = Mathf.Clamp01(charge);
if (slowActive)
{
if (charge <= 0f)
{
EndFocus();
cooling = true;
coolT = 0f;
charge = 0f;
((MelonBase)this).LoggerInstance.Msg("Focus ran out: locked out for " + num2.ToString("0") + " s, then it needs more kills.");
}
else
{
MaintainFocus();
}
}
bool flag = InputHeld();
if (flag && !heldPrev)
{
if (slowActive)
{
EndFocus();
}
else if (!cooling && charge >= num && AllowedNow())
{
BeginFocus();
}
else if (!slowActive)
{
focusFlash = 0.45f;
((MelonBase)this).LoggerInstance.Msg(cooling ? "Focus is locked out." : ("Focus needs more kills: " + (charge * 100f).ToString("0") + "% of " + (num * 100f).ToString("0") + "%."));
}
}
heldPrev = flag;
focusBar.Set(charge);
Color val = Purple;
if (cooling)
{
((Color)(ref val))..ctor(0.42f, 0.38f, 0.58f, 1f);
}
else if (slowActive)
{
float num3 = 0.8f + 0.2f * Mathf.Sin(Time.unscaledTime * 10f);
((Color)(ref val))..ctor(Purple.r * num3, Purple.g * num3, Purple.b * num3, 1f);
}
else if (charge < num)
{
((Color)(ref val))..ctor(0.5f, 0.43f, 0.78f, 1f);
}
if (focusFlash > 0f)
{
focusFlash -= dt;
val = Color.Lerp(val, new Color(1f, 0.45f, 0.45f, 1f), Mathf.Clamp01(focusFlash / 0.45f) * (0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 30f)));
}
focusBar.SetFillColor(val);
}
catch (Exception ex)
{
LogOnce("focus", ex);
}
}
private void RestoreNativeSlowMo()
{
if (nativeSaved)
{
try
{
TimeManager.slowMoEnabled = nativeSetting;
}
catch
{
}
nativeSaved = false;
}
}
private bool InputHeld()
{
try
{
if (!Player.ControllersExist)
{
return false;
}
BaseController leftController = Player.LeftController;
BaseController rightController = Player.RightController;
string text = (pFocusInput.Value ?? "BothSticks").Trim().ToLowerInvariant();
if (text == "leftstick")
{
return leftController.GetThumbStick();
}
if (text == "rightstick")
{
return rightController.GetThumbStick();
}
return leftController.GetThumbStick() && rightController.GetThumbStick();
}
catch
{
return false;
}
}
private bool AllowedNow()
{
if (pFocusMulti.Value || !FusionPresent())
{
return true;
}
bool flag = false;
try
{
flag = OthersInFusionLobby();
}
catch (Exception ex)
{
LogOnce("fusion-lobby", ex);
}
if (flag && !warnedMulti)
{
warnedMulti = true;
((MelonBase)this).LoggerInstance.Msg("Focus blocked: other Fusion players are present (set FocusInMultiplayer=true to allow).");
}
return !flag;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool OthersInFusionLobby()
{
return PlayerIDManager.HasOtherPlayers;
}
private void BeginFocus()
{
slowActive = true;
slowVerified = false;
slowStart = Time.unscaledTime;
try
{
prevSlowEnabled = TimeManager.slowMoEnabled;
TimeManager.slowMoEnabled = true;
TimeManager.TOGGLE_TIMESCALE();
slowMode = SlowMode.Game;
}
catch (Exception ex)
{
LogOnce("focus-game", ex);
StartManualSlow();
}
((MelonBase)this).LoggerInstance.Msg("Focus ON (" + slowMode.ToString() + ").");
}
private void MaintainFocus()
{
if (slowMode == SlowMode.Game && !slowVerified)
{
if (Time.timeScale < 0.95f)
{
slowVerified = true;
}
else if (Time.unscaledTime - slowStart > 0.75f)
{
((MelonBase)this).LoggerInstance.Warning("Game slow-mo did not respond; using a direct time scale instead.");
try
{
TimeManager.TOGGLE_TIMESCALE();
}
catch
{
}
StartManualSlow();
}
}
else if (slowMode == SlowMode.Manual)
{
float num = Mathf.Clamp(pFocusScale.Value, 0.05f, 0.9f);
if (Mathf.Abs(Time.timeScale - num) > 0.001f)
{
Time.timeScale = num;
Time.fixedDeltaTime = baseFixed * num;
}
}
}
private void StartManualSlow()
{
slowMode = SlowMode.Manual;
if (baseFixed <= 0f)
{
baseFixed = Time.fixedDeltaTime;
}
float num = (Time.timeScale = Mathf.Clamp(pFocusScale.Value, 0.05f, 0.9f));
Time.fixedDeltaTime = baseFixed * num;
}
private void EndFocus()
{
try
{
if (slowMode == SlowMode.Game)
{
TimeManager.TOGGLE_TIMESCALE();
TimeManager.slowMoEnabled = prevSlowEnabled;
}
else if (slowMode == SlowMode.Manual)
{
Time.timeScale = 1f;
if (baseFixed > 0f)
{
Time.fixedDeltaTime = baseFixed;
}
}
}
catch (Exception ex)
{
LogOnce("focus-end", ex);
}
slowActive = false;
slowMode = SlowMode.None;
((MelonBase)this).LoggerInstance.Msg("Focus OFF.");
}
private void BuildWeapon()
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string text in manifestResourceNames)
{
embeddedNames[text] = text;
}
LoadUserMap();
weaponRoot = MakeCanvasRoot("GTA6_Weapon", 300f, 215f);
weaponGroup = weaponRoot.AddComponent<CanvasGroup>();
weaponGroup.interactable = false;
weaponGroup.blocksRaycasts = false;
weaponGroup.alpha = 0f;
ammoLabel = new GlyphLabel(this, weaponRoot.transform, "Ammo", 58f, GlyphLabel.Align.Right, 296f, 0f, Color.white);
weaponIcon = MakeImage("WeaponIcon", weaponRoot.transform, 0f, 72f, 292f, 135f, Color.white, null);
((Behaviour)weaponIcon).enabled = false;
}
private void UpdateWeapon(float dt)
{
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
GameObject val = null;
GameObject val2 = null;
try
{
if (Player.HandsExist)
{
val = Player.GetObjectInHand(Player.RightHand);
val2 = Player.GetObjectInHand(Player.LeftHand);
}
}
catch
{
}
Gun val3 = null;
GameObject val4 = null;
GameObject[] array = (GameObject[])(object)new GameObject[2] { val, val2 };
foreach (GameObject val5 in array)
{
if (!((Object)(object)val5 == (Object)null))
{
Gun val6 = val5.GetComponentInChildren<Gun>();
if ((Object)(object)val6 == (Object)null)
{
val6 = val5.GetComponentInParent<Gun>();
}
if ((Object)(object)val6 != (Object)null)
{
val3 = val6;
val4 = val5;
break;
}
}
}
if ((Object)(object)val3 == (Object)null)
{
val4 = (((Object)(object)val != (Object)null) ? val : val2);
}
string text = (((Object)(object)val4 == (Object)null) ? "" : NameBlob(((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : val4));
string text2 = (((Object)(object)val3 != (Object)null) ? "G:" : "O:") + text;
if (text2 != lastSig)
{
lastSig = text2;
lastReserve = -1;
reserveTimer = 1f;
string text3 = (((Object)(object)val4 == (Object)null) ? null : PickIcon(text, (Object)(object)val3 != (Object)null));
SetIcon(text3);
weaponShow = text3 != null;
if (pLogHeld.Value && (Object)(object)val4 != (Object)null)
{
((MelonBase)this).LoggerInstance.Msg("Held " + (((Object)(object)val3 != (Object)null) ? "gun" : "object") + " '" + text + "' -> " + ((text3 == null) ? "no icon (hidden)" : ((text3.Length == 0) ? "no icon (ammo only)" : ("icon '" + text3 + "'"))));
}
}
weaponAlpha = Mathf.MoveTowards(weaponAlpha, weaponShow ? 1f : 0f, dt * (weaponShow ? 6f : 3f));
weaponGroup.alpha = weaponAlpha;
if ((Object)(object)val3 == (Object)null)
{
ammoLabel.SetText("");
return;
}
int num = 0;
try
{
if (val3.HasMagazine())
{
num = val3.MagazineState.AmmoCount;
}
}
catch
{
}
reserveTimer += dt;
if (reserveTimer >= 0.25f)
{
reserveTimer = 0f;
lastReserve = ReadReserve(val3);
}
if (lastReserve >= 0)
{
string text4 = lastReserve.ToString();
ammoLabel.SetText(text4 + " " + num, text4.Length + 1, LoadedGrey);
}
else
{
ammoLabel.SetText(num.ToString(), 0, LoadedGrey);
}
}
private int ReadReserve(Gun gun)
{
try
{
AmmoInventory instance = AmmoInventory.Instance;
if ((Object)(object)instance == (Object)null)
{
return -1;
}
CartridgeData val = null;
try
{
MagazineState magazineState = gun.MagazineState;
if (magazineState != null)
{
val = magazineState.cartridgeData;
}
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
val = gun.defaultCartridge;
}
if ((Object)(object)val == (Object)null)
{
return -1;
}
return instance.GetCartridgeCount(val);
}
catch (Exception ex)
{
LogOnce("reserve", ex);
return -1;
}
}
private static string NameBlob(GameObject go)
{
StringBuilder stringBuilder = new StringBuilder();
Transform val = go.transform;
int num = 0;
while (num < 4 && (Object)(object)val != (Object)null)
{
stringBuilder.Append(Normalize(((Object)val).name)).Append('|');
num++;
val = val.parent;
}
return stringBuilder.ToString();
}
private static string Normalize(string s)
{
if (string.IsNullOrEmpty(s))
{
return "";
}
StringBuilder stringBuilder = new StringBuilder(s.Length);
int num = 0;
string text = s.ToLowerInvariant();
foreach (char c in text)
{
switch (c)
{
case '(':
case '[':
num++;
continue;
case ')':
case ']':
num = Math.Max(0, num - 1);
continue;
}
if (num <= 0 && char.IsLetterOrDigit(c))
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString();
}
private string PickIcon(string blob, bool isGun)
{
foreach (var (value, result) in userMap)
{
if (blob.Contains(value))
{
return result;
}
}
(string, string)[] gunMap;
if (isGun)
{
gunMap = GunMap;
for (int i = 0; i < gunMap.Length; i++)
{
var (value2, result2) = gunMap[i];
if (blob.Contains(value2))
{
return result2;
}
}
return "AKM";
}
gunMap = ObjectMap;
for (int i = 0; i < gunMap.Length; i++)
{
var (value3, result3) = gunMap[i];
if (blob.Contains(value3))
{
return result3;
}
}
return null;
}
private void LoadUserMap()
{
userMap.Clear();
try
{
Directory.CreateDirectory(Path.Combine(userDir, "Icons"));
string path = Path.Combine(userDir, "weapon_map.txt");
if (!File.Exists(path))
{
File.WriteAllText(path, "# GTA 6 HUD - custom weapon -> icon mapping.\n# One per line: keyword=iconname (no .png; keyword lowercase, no spaces)\n# The keyword is matched against the held object's name (see the log: 'Held gun ... -> icon').\n# Lines here win over the built-in mapping. Drop your own PNG into UserData/GTA6_HUD/Icons/\n# with an icon's name to override an embedded icon.\n# Example:\n# mymodgun=MP5\n");
return;
}
string[] array = File.ReadAllLines(path);
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.Length == 0 || text[0] == '#')
{
continue;
}
int num = text.IndexOf('=');
if (num > 0)
{
string text2 = Normalize(text.Substring(0, num));
string text3 = text.Substring(num + 1).Trim();
if (text3.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
{
text3 = text3.Substring(0, text3.Length - 4);
}
if (text2.Length > 0 && text3.Length > 0)
{
userMap.Add((text2, text3));
}
}
}
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("weapon_map.txt: " + ex.Message);
}
}
private void SetIcon(string name)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
Sprite val = (string.IsNullOrEmpty(name) ? null : GetIcon(name));
if ((Object)(object)val == (Object)null)
{
((Behaviour)weaponIcon).enabled = false;
return;
}
Rect rect = val.rect;
float num = 292f / ((Rect)(ref rect)).width;
rect = val.rect;
float num2 = Mathf.Min(num, 135f / ((Rect)(ref rect)).height);
rect = val.rect;
float num3 = ((Rect)(ref rect)).width * num2;
rect = val.rect;
float num4 = ((Rect)(ref rect)).height * num2;
RectTransform rectTransform = ((Graphic)weaponIcon).rectTransform;
rectTransform.sizeDelta = new Vector2(num3, num4);
rectTransform.anchoredPosition = new Vector2(296f - num3, 0f - (72f + (135f - num4) * 0.5f));
weaponIcon.sprite = val;
((Behaviour)weaponIcon).enabled = true;
}
private Sprite GetIcon(string name)
{
if (icons.TryGetValue(name, out var value))
{
return value;
}
Sprite val = null;
try
{
string path = Path.Combine(userDir, "Icons", name + ".png");
if (File.Exists(path))
{
val = SpriteFromBytes(File.ReadAllBytes(path), mips: true);
}
if ((Object)(object)val == (Object)null && embeddedNames.TryGetValue("Weapons/" + name + ".png", out var value2))
{
val = SpriteFromBytes(ReadResource(value2), mips: true);
}
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("Icon '" + name + "': " + ex.Message);
}
if ((Object)(object)val == (Object)null)
{
((MelonBase)this).LoggerInstance.Warning("Icon not found: " + name);
}
icons[name] = val;
return val;
}
private void LoadGlyphs()
{
string text = "0123456789";
for (int i = 0; i < text.Length; i++)
{
char key = text[i];
glyphs[key] = SpriteFromBytes(ReadResource("Glyphs/g_" + key + ".png"), mips: true);
}
glyphs[':'] = SpriteFromBytes(ReadResource("Glyphs/g_colon.png"), mips: true);
glyphs['$'] = SpriteFromBytes(ReadResource("Glyphs/g_dollar.png"), mips: true);
glyphs['-'] = SpriteFromBytes(ReadResource("Glyphs/g_dash.png"), mips: true);
glyphs['/'] = SpriteFromBytes(ReadResource("Glyphs/g_slash.png"), mips: true);
glyphs['+'] = SpriteFromBytes(ReadResource("Glyphs/g_plus.png"), mips: true);
glyphs[','] = SpriteFromBytes(ReadResource("Glyphs/g_comma.png"), mips: true);
}
internal Sprite GetGlyph(char c)
{
glyphs.TryGetValue(c, out var value);
return value;
}
private static byte[] ReadResource(string logicalName)
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(logicalName);
if (stream == null)
{
throw new FileNotFoundException("Embedded resource missing: " + logicalName);
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
private static Sprite SpriteFromBytes(byte[] bytes, bool mips)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, mips);
if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(bytes)))
{
return null;
}
((Texture)val).filterMode = (FilterMode)2;
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).anisoLevel = 4;
((Object)val).hideFlags = (HideFlags)32;
Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
((Object)obj).hideFlags = (HideFlags)32;
return obj;
}
private void LogOnce(string tag, Exception ex)
{
if (loggedErrors.Add(tag + ex.GetType().Name + ex.Message))
{
((MelonBase)this).LoggerInstance.Error("[" + tag + "] " + ex);
}
}
}