using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RcHud")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("a racecar hud idk")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+381e4446180f7f71353488ab51f632198fc0a70e")]
[assembly: AssemblyProduct("RcHud")]
[assembly: AssemblyTitle("RcHud")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RcHud
{
public enum StaminaColorMode
{
Vanilla,
Static,
AllRed,
AllDark,
RedDark
}
public static class Config
{
private static ConfigEntry<bool> refreshFistOnPunch;
private static ConfigEntry<bool> refreshFistOnSwitch;
private static ConfigEntry<bool> refreshGunOnSwitch;
private static ConfigEntry<bool> refreshOnMusic;
private static ConfigEntry<bool> refreshOnBossBar;
private static ConfigEntry<bool> hiVisOverheal;
private static ConfigEntry<bool> persistentHp;
private static ConfigEntry<StaminaColorMode> staminaColorMode;
private static ConfigEntry<float> iconFade;
private static ConfigEntry<float> wheelFade;
private static ConfigEntry<float> fistScale;
private static ConfigEntry<float> gunScale;
private static ConfigEntry<float> fistOffset;
private static ConfigEntry<float> gunOffset;
public static bool RefreshFistOnPunch => refreshFistOnPunch.Value;
public static bool RefreshFistOnSwitch => refreshFistOnSwitch.Value;
public static bool RefreshGunOnSwitch => refreshGunOnSwitch.Value;
public static bool RefreshIconsOnBattleMusic => refreshOnMusic.Value;
public static bool RefreshIconsOnBossHealthBar => refreshOnBossBar.Value;
public static bool HiVisOverheal => hiVisOverheal.Value;
public static bool PersistentHp => persistentHp.Value;
public static StaminaColorMode StaminaColorMode => staminaColorMode.Value;
public static float IconFadeTime => iconFade.Value;
public static float WheelFadeTime => wheelFade.Value;
public static float FistIconScale => fistScale.Value;
public static float GunIconScale => gunScale.Value;
public static float FistIconOffset => fistOffset.Value * 2f / 3f;
public static float GunIconOffset => gunOffset.Value * 2f / 3f;
public static void Init(ConfigFile cfg)
{
refreshFistOnPunch = cfg.Bind<bool>("Refresh", "Punch", true, (ConfigDescription)null);
refreshFistOnSwitch = cfg.Bind<bool>("Refresh", "FistSwitch", true, (ConfigDescription)null);
refreshGunOnSwitch = cfg.Bind<bool>("Refresh", "GunSwitch", true, (ConfigDescription)null);
refreshOnMusic = cfg.Bind<bool>("Refresh", "BattleMusic", true, (ConfigDescription)null);
refreshOnBossBar = cfg.Bind<bool>("Refresh", "BossHealthBar", true, (ConfigDescription)null);
string[] value = new string[6] { "Vanilla: vanilla behavior (first segment red while charging)", "Static: all segments blue, all the time", "AllRed: all segments red while charging", "AllDark: all segments dark blue while charging", "RedDark: first segment red while charging, other segments dark blue", "(the actual colors reflect game color settings)" };
staminaColorMode = cfg.Bind<StaminaColorMode>("Tweaks", "StaminaColorMode", StaminaColorMode.AllRed, string.Join("\n", value));
hiVisOverheal = cfg.Bind<bool>("Tweaks", "HiVisOverheal", true, "Display overheal as a dark green ring with a different thickness");
persistentHp = cfg.Bind<bool>("Tweaks", "PersistentHp", true, "Prevent HP wheel from fading if damaged or overhealed");
iconFade = cfg.Bind<float>("FadeTime", "WeaponIcons", 4f, AcceptableRange(0f, 30f));
wheelFade = cfg.Bind<float>("FadeTime", "RailcannonMeter", 5f, AcceptableRange(0f, 30f));
fistScale = cfg.Bind<float>("IconScale", "Fist", 1.25f, AcceptableRange(0f, 10f));
gunScale = cfg.Bind<float>("IconScale", "Gun", 0.1f, AcceptableRange(0f, 10f));
fistOffset = cfg.Bind<float>("IconOffset", "Fist", 50f, AcceptableRange(0f, 1000f));
gunOffset = cfg.Bind<float>("IconOffset", "Gun", 45f, AcceptableRange(0f, 1000f));
}
private static ConfigDescription AcceptableRange<T>(T min, T max) where T : IComparable
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
return new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<T>(min, max), Array.Empty<object>());
}
}
[BepInPlugin("RcHud", "RcHud", "1.2.2")]
public sealed class Plugin : BaseUnityPlugin
{
public void Awake()
{
Config.Init(((BaseUnityPlugin)this).Config);
Harmony.CreateAndPatchAll(((object)this).GetType(), (string)null);
}
public void Start()
{
RacecarHud.SetLogger(((BaseUnityPlugin)this).Logger);
}
public void Update()
{
_ = MonoSingleton<RacecarHud>.Instance;
if (Config.RefreshIconsOnBattleMusic)
{
MusicManager instance = MonoSingleton<MusicManager>.Instance;
if ((Object)(object)instance != (Object)null && (instance.battleTheme.volume > 0f || instance.bossTheme.volume > 0f))
{
RefreshBothIcons();
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(FistControl), "UpdateFistIcon")]
private static void RefreshFistIconOnSwitch()
{
if (Config.RefreshFistOnSwitch)
{
MonoSingleton<RacecarHud>.Instance.RefreshFist();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Punch), "PunchStart")]
private static void RefreshFistIconOnPunch()
{
if (Config.RefreshFistOnPunch)
{
MonoSingleton<RacecarHud>.Instance.RefreshFist();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GunControl), "SwitchWeapon")]
[HarmonyPatch(new Type[]
{
typeof(int),
typeof(bool)
})]
[HarmonyPatch(new Type[]
{
typeof(int),
typeof(List<GameObject>),
typeof(bool),
typeof(bool),
typeof(bool),
typeof(bool)
})]
private static void RefreshGunIcon()
{
if (Config.RefreshGunOnSwitch)
{
MonoSingleton<RacecarHud>.Instance.RefreshGun();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GunControl), "SwitchVariant")]
private static void RefreshGunIcon2()
{
if (Config.RefreshGunOnSwitch)
{
MonoSingleton<RacecarHud>.Instance.RefreshGun();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BossHealthBar), "Update")]
private static void RefreshBothIcons()
{
if (Config.RefreshIconsOnBossHealthBar)
{
MonoSingleton<RacecarHud>.Instance.RefreshFist();
MonoSingleton<RacecarHud>.Instance.RefreshGun();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDOptions), "HudFade")]
private static void SetIconFade(bool stuff)
{
MonoSingleton<RacecarHud>.Instance.fadeIcons = stuff;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsMenuToManager), "WeaponPosition")]
private static void SetWeaponPos(int stuff)
{
MonoSingleton<RacecarHud>.Instance.LeftHanded = stuff == 2;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Crosshair), "CheckCrossHair")]
private static void UpdateCrosshairSettings()
{
MonoSingleton<RacecarHud>.Instance.ApplyHiVisOverhealSettings();
}
}
public sealed class RacecarHud : MonoSingleton<RacecarHud>
{
private static ManualLogSource log = new ManualLogSource("");
private bool initialized;
private GameObject fist = new GameObject();
private GameObject gun = new GameObject();
private GameObject wheel = new GameObject();
private Crosshair crosshairReference = new Crosshair();
private List<GameObject> fistList = new List<GameObject>();
private float fistFade = Config.IconFadeTime;
private float gunFade = Config.IconFadeTime;
internal bool fadeIcons;
private bool southpaw;
private bool newHandedness = true;
public bool LeftHanded
{
get
{
return southpaw;
}
set
{
southpaw = value;
newHandedness = true;
}
}
internal static void SetLogger(ManualLogSource logger)
{
log = logger;
}
public void RefreshFist()
{
fistFade = Config.IconFadeTime;
}
public void RefreshGun()
{
gunFade = Config.IconFadeTime;
}
public void Update()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
if (TryInit())
{
UpdateHandedness();
UpdateFade(ref fistFade, fist);
UpdateFade(ref gunFade, gun);
Image component = gun.GetComponent<Image>();
gun.GetComponent<RectTransform>().sizeDelta = GetTexSize(component) * Config.GunIconScale;
GunControl instance = MonoSingleton<GunControl>.Instance;
bool isActiveAndEnabled = ((Behaviour)MonoSingleton<WeaponWheel>.Instance).isActiveAndEnabled;
Scene activeScene = SceneManager.GetActiveScene();
bool flag;
switch (((Scene)(ref activeScene)).name)
{
case "Level 0-S":
case "Level 1-S":
case "Level 4-S":
flag = true;
break;
default:
flag = false;
break;
}
bool flag2 = flag;
bool flag3 = true;
flag3 = flag3 && !isActiveAndEnabled;
flag3 &= instance.allWeapons.Count > 1;
flag3 = flag3 && !flag2;
bool flag4 = true;
flag4 = flag4 && !isActiveAndEnabled;
flag4 &= fistList.Count > 1;
flag4 = flag4 && !flag2;
bool flag5 = true;
flag5 &= instance.slot4.Count > 0;
flag5 = flag5 && !flag2;
gun.SetActive(flag3);
fist.SetActive(flag4);
wheel.SetActive(flag5);
WeaponCharges instance2 = MonoSingleton<WeaponCharges>.Instance;
ColorBlindSettings instance3 = MonoSingleton<ColorBlindSettings>.Instance;
Slider component2 = wheel.GetComponent<Slider>();
component2.value = instance2.raicharge;
((Graphic)wheel.GetComponent<Image>()).color = ((component2.normalizedValue < 1f) ? instance3.railcannonChargingColor : instance3.railcannonFullColor);
UpdateStaminaColors();
UpdatePersistentHp();
}
}
private void UpdateFade(ref float fade, GameObject icon)
{
fade = (fadeIcons ? Mathf.MoveTowards(fade, 0f, Time.deltaTime) : Config.IconFadeTime);
icon.GetComponent<CanvasRenderer>().SetAlpha(Mathf.Min(1f, fade));
}
private void UpdateHandedness()
{
//IL_0091: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_0050: 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)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
if (newHandedness)
{
newHandedness = false;
RectTransform component = fist.GetComponent<RectTransform>();
RectTransform component2 = gun.GetComponent<RectTransform>();
if (southpaw)
{
component.pivot = new Vector2(0f, 0.5f);
component.anchoredPosition = new Vector2(Config.FistIconOffset, 0f);
component2.pivot = new Vector2(1f, 0.5f);
component2.anchoredPosition = new Vector2(0f - Config.GunIconOffset, 0f);
}
else
{
component.pivot = new Vector2(1f, 0.5f);
component.anchoredPosition = new Vector2(0f - Config.FistIconOffset, 0f);
component2.pivot = new Vector2(0f, 0.5f);
component2.anchoredPosition = new Vector2(Config.GunIconOffset, 0f);
}
}
}
private void UpdateStaminaColors()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
ColorBlindSettings instance = MonoSingleton<ColorBlindSettings>.Instance;
Color staminaColor = instance.staminaColor;
Color val = instance.staminaChargingColor * 0.6f;
Color staminaEmptyColor = instance.staminaEmptyColor;
for (int i = 2; i < 5; i++)
{
Image obj = crosshairReference.chuds[i];
SliderToFillAmount component = ((Component)obj).GetComponent<SliderToFillAmount>();
component.copyColor = false;
bool flag = obj.fillAmount == component.maxFill;
bool flag2 = i == 2;
Image val2 = obj;
((Graphic)val2).color = (Color)(Config.StaminaColorMode switch
{
StaminaColorMode.Vanilla => flag ? staminaColor : (flag2 ? staminaEmptyColor : staminaColor),
StaminaColorMode.Static => staminaColor,
StaminaColorMode.AllRed => flag ? staminaColor : staminaEmptyColor,
StaminaColorMode.AllDark => flag ? staminaColor : val,
StaminaColorMode.RedDark => flag ? staminaColor : (flag2 ? staminaEmptyColor : val),
_ => Color.magenta,
});
}
}
private void UpdatePersistentHp()
{
if (Config.PersistentHp)
{
Image[] chuds = crosshairReference.chuds;
Image val = chuds[1];
Image val2 = chuds[7];
SliderToFillAmount component = ((Component)val).GetComponent<SliderToFillAmount>();
if (val.fillAmount < component.maxFill || val2.fillAmount > 0f)
{
component.mama.fadeOutTime = 2f;
}
}
}
public void ApplyHiVisOverhealSettings()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
Image[] chuds = crosshairReference.chuds;
Sprite[] circles = crosshairReference.circles;
Image val = chuds[7];
Image val2 = chuds[6];
if (!Config.HiVisOverheal)
{
((Graphic)val).color = new Color(0.703f, 1f, 0.704f);
return;
}
Sprite val3;
switch (MonoSingleton<PrefsManager>.Instance.GetInt("crossHairHud", 0))
{
default:
return;
case 1:
val3 = circles[2];
break;
case 2:
val3 = circles[3];
break;
case 3:
val3 = circles[0];
break;
case 4:
val3 = circles[1];
break;
}
Sprite sprite = (val.sprite = val3);
val2.sprite = sprite;
((Graphic)val).color = Color.green * 0.65f;
}
private bool TryInit()
{
if (initialized)
{
return true;
}
FistControl instance = MonoSingleton<FistControl>.Instance;
WeaponHUD instance2 = MonoSingleton<WeaponHUD>.Instance;
PowerUpMeter instance3 = MonoSingleton<PowerUpMeter>.Instance;
HUDOptions instance4 = MonoSingleton<HUDOptions>.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || (Object)(object)instance3 == (Object)null || (Object)(object)instance4 == (Object)null)
{
return false;
}
crosshairReference = ((Component)instance4).GetComponentInChildren<Crosshair>();
fadeIcons = MonoSingleton<PrefsManager>.Instance.GetBool("crossHairHudFade", false);
InitFist(instance);
InitGun(instance2);
InitWheel(instance3);
log.LogInfo((object)"hud initialized");
initialized = true;
return true;
}
private void InitFist(FistControl fistControl)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//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)
GameObject val = new GameObject("Fist");
val.AddComponent<Image>();
Image fistIcon = fistControl.fistIcon;
CopyImage obj = val.AddComponent<CopyImage>();
obj.imgToCopy = fistIcon;
obj.copyColor = true;
InitTransform(val).sizeDelta = GetTexSize(fistIcon) * Config.FistIconScale;
FieldInfo field = ((object)fistControl).GetType().GetField("spawnedArms", BindingFlags.Instance | BindingFlags.NonPublic);
fistList = (List<GameObject>)field.GetValue(fistControl);
fist = val;
}
private void InitGun(WeaponHUD weaponHud)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
GameObject val = new GameObject("Gun");
val.AddComponent<Image>();
CopyImage obj = val.AddComponent<CopyImage>();
obj.imgToCopy = ((Component)weaponHud).GetComponentInChildren<Image>();
obj.copyColor = true;
InitTransform(val);
gun = val;
}
private void InitWheel(PowerUpMeter powerUpMeter)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Wheel");
Image obj = val.AddComponent<Image>();
obj.type = (Type)3;
obj.fillMethod = (FillMethod)4;
obj.fillAmount = 0.5f;
obj.sprite = ((Component)powerUpMeter).GetComponentInChildren<Image>().sprite;
RectTransform obj2 = InitTransform(val);
obj2.sizeDelta = new Vector2(64f, 64f);
obj2.anchoredPosition = new Vector2(0f, 0f);
((Transform)obj2).Rotate(0f, 0f, 180f);
((Component)powerUpMeter).GetComponent<RectTransform>().sizeDelta = new Vector2(69f, 69f);
Slider val2 = val.AddComponent<Slider>();
val2.minValue = 0f;
val2.maxValue = 4f;
SliderToFillAmount obj3 = val.AddComponent<SliderToFillAmount>();
obj3.targetSlider = val2;
obj3.maxFill = 1f;
val.AddComponent<FadeOutBars>().fadeOutTime = Config.WheelFadeTime;
wheel = val;
}
private RectTransform InitTransform(GameObject obj)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_004f: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = obj.GetComponent<RectTransform>();
((Transform)component).parent = ((Component)crosshairReference).transform;
((Transform)component).localScale = Vector3.one * 2f / 3f;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0.5f, 0.5f);
component.anchorMax = val;
component.anchorMin = val;
return component;
}
private static Vector2 GetTexSize(Image icon)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
return new Vector2((float)((Graphic)icon).mainTexture.width, (float)((Graphic)icon).mainTexture.height);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RcHud";
public const string PLUGIN_NAME = "RcHud";
public const string PLUGIN_VERSION = "1.2.2";
}
}