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 TMPro;
using UnityEngine;
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("UKFreshnessCoach")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Helps maintain weapon freshness in ULTRAKILL.")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+491aead17341e744dad672d4e889d79241032d58")]
[assembly: AssemblyProduct("UKFreshnessCoach")]
[assembly: AssemblyTitle("UKFreshnessCoach")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace UKFreshnessCoach
{
[BepInPlugin("UKFreshnessCoach", "UKFreshnessCoach", "1.2.0")]
[BepInProcess("ULTRAKILL.exe")]
public class UKFreshnessCoach : BaseUnityPlugin
{
private static Harmony harmony;
private static ManualLogSource _logger;
private static ConfigEntry<bool> shaking;
private static ConfigEntry<bool> flashing;
private static ConfigEntry<string> usedMessage;
private static ConfigEntry<string> staleMessage;
private static ConfigEntry<string> dullMessage;
private static ConfigEntry<string> usedPrimaryColor;
private static ConfigEntry<string> usedSecondaryColor;
private static ConfigEntry<string> stalePrimaryColor;
private static ConfigEntry<string> staleSecondaryColor;
private static ConfigEntry<string> dullPrimaryColor;
private static ConfigEntry<string> dullSecondaryColor;
private static GameObject crosshair;
private static GameObject textObject;
private static Vector3 textHomePos;
private static TextMeshProUGUI textComp;
private static float freshMin;
private static float usedMin;
private static float staleMin;
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
harmony = new Harmony("UKFreshnessCoach");
harmony.PatchAll(typeof(UKFreshnessCoach));
_logger = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogDebug((object)"Plugin UKFreshnessCoach is loaded!");
shaking = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Shaking", true, "Shake the text.");
flashing = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Flashing", true, "Flash the text.");
usedMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "UsedMessage", "USE A DIFFERENT FUCKING GUN", "Message displayed when the current freshness is \"Used\".");
staleMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StaleMessage", "YOU'RE NOT VERY GOOD AT THIS", "Message displayed when the current freshness is \"Stale\".");
dullMessage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DullMessage", "GO PLAY A VISUAL NOVEL", "Message displayed when the current freshness is \"Dull\".");
usedPrimaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "UsedPrimaryColor", "white", "Primary color used when the current freshness is \"Used\".");
usedSecondaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "UsedSecondaryColor", "orange", "Secondary color used when the current freshness is \"Used\".");
stalePrimaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "StalePrimaryColor", "orange", "Primary color used when the current freshness is \"Stale\".");
staleSecondaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "StaleSecondaryColor", "red", "Secondary color used when the current freshness is \"Stale\".");
dullPrimaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "DullPrimaryColor", "red", "Primary color used when the current freshness is \"Dull\".");
dullSecondaryColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "DullSecondaryColor", "black", "Secondary color used when the current freshness is \"Dull\".");
}
[HarmonyPatch(typeof(StyleHUD), "Start")]
[HarmonyPostfix]
private static void InspectStyleHUD(StyleHUD __instance)
{
//IL_0026: 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: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Invalid comparison between Unknown and I4
foreach (StyleFreshnessData item in Traverse.Create((object)__instance).Field("freshnessStateData").GetValue<List<StyleFreshnessData>>())
{
if ((int)item.state == 0)
{
freshMin = item.min;
}
else if ((int)item.state == 1)
{
usedMin = item.min;
}
else if ((int)item.state == 2)
{
staleMin = item.min;
}
}
}
[HarmonyPatch(typeof(Crosshair), "Start")]
[HarmonyPrefix]
private static void GetCrosshair()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
crosshair = GameObject.Find("Canvas/Crosshair Filler/Crosshair");
textObject = new GameObject("FreshnessCoach");
textObject = Object.Instantiate<GameObject>(textObject, crosshair.transform);
textObject.SetActive(false);
textHomePos = new Vector3(textObject.transform.localPosition.x, textObject.transform.localPosition.y - 60f, textObject.transform.localPosition.z);
textObject.transform.localPosition = textHomePos;
textComp = textObject.AddComponent<TextMeshProUGUI>();
TMP_FontAsset font = ((TMP_Text)GameObject.Find("Canvas/Boss Healths/Boss Health 1/Panel/Filler/Slider/HP Text").GetComponent<TextMeshProUGUI>()).font;
((TMP_Text)textComp).font = font;
((Graphic)textComp).color = Color.red;
((TMP_Text)textComp).fontSize = 16f;
((TMP_Text)textComp).alignment = (TextAlignmentOptions)514;
}
[HarmonyPatch(typeof(StyleHUD), "SetFreshness")]
[HarmonyPostfix]
private static void SetFreshnessCoach(GameObject sourceWeapon, float amt, ref GunControl ___gc)
{
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sourceWeapon != (Object)(object)___gc.currentWeapon)
{
return;
}
textObject.SetActive(amt < freshMin);
int num = (int)(((double)Time.fixedTime - Math.Truncate(Time.fixedTime)) * 100.0);
if (amt < staleMin)
{
string text = ((!flashing.Value || num / 4 % 2 != 0) ? dullPrimaryColor.Value : dullSecondaryColor.Value);
((TMP_Text)textComp).text = "<color=" + text + ">" + dullMessage.Value + "</color>";
((TMP_Text)textComp).fontSize = 22f;
if (shaking.Value)
{
textObject.transform.localPosition = new Vector3(textHomePos.x + (float)Random.Range(-4, 4), textHomePos.y + (float)Random.Range(-4, 4), textHomePos.z);
}
}
else if (amt < usedMin)
{
string text = ((!flashing.Value || num / 4 % 2 != 0) ? stalePrimaryColor.Value : staleSecondaryColor.Value);
((TMP_Text)textComp).text = "<color=" + text + ">" + staleMessage.Value + "</color>";
((TMP_Text)textComp).fontSize = 20f;
if (shaking.Value)
{
textObject.transform.localPosition = new Vector3(textHomePos.x + (float)Random.Range(-3, 3), textHomePos.y + (float)Random.Range(-3, 3), textHomePos.z);
}
}
else if (amt < freshMin)
{
string text = ((!flashing.Value || num / 6 % 2 != 0) ? usedPrimaryColor.Value : usedSecondaryColor.Value);
((TMP_Text)textComp).text = "<color=" + text + ">" + usedMessage.Value + "</color>";
((TMP_Text)textComp).fontSize = 16f;
if (shaking.Value)
{
textObject.transform.localPosition = new Vector3(textHomePos.x + (float)Random.Range(-2, 2), textHomePos.y + (float)Random.Range(-2, 2), textHomePos.z);
}
}
}
[HarmonyPatch(typeof(NewMovement), "GetHurt")]
[HarmonyPostfix]
private static void ClearTextOnDeath(NewMovement __instance)
{
if (__instance.dead)
{
textObject.SetActive(false);
}
}
[HarmonyPatch(typeof(StyleHUD), "ComboOver")]
[HarmonyPostfix]
private static void ClearTextOnComboOver()
{
if (Object.op_Implicit((Object)(object)textObject))
{
textObject.SetActive(false);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "UKFreshnessCoach";
public const string PLUGIN_NAME = "UKFreshnessCoach";
public const string PLUGIN_VERSION = "1.2.0";
}
}