using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("fToParry2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("fToParry2")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b3780545-da19-4ea8-888c-94dcdeffdb15")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace imNotGonnaSugarcoatIt;
[BepInPlugin("com.yourname.ultrakill.imnotgonnasugarcoatit", "imNotGonnaSugarcoatIt", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static Texture2D CustomParryImage;
public static AudioClip CustomParrySound;
private void Awake()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string path = Path.Combine(directoryName, "parry_image.png");
string path2 = Path.Combine(directoryName, "parry_sound.mp3");
if (File.Exists(path))
{
byte[] array = File.ReadAllBytes(path);
CustomParryImage = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(CustomParryImage, array);
}
if (File.Exists(path2))
{
((MonoBehaviour)this).StartCoroutine(LoadAudioClip(path2));
}
Harmony val = new Harmony("com.yourname.ultrakill.ftoparry2");
val.PatchAll();
}
private IEnumerator LoadAudioClip(string path)
{
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)13);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result == 1)
{
CustomParrySound = DownloadHandlerAudioClip.GetContent(uwr);
}
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
}
public class ParryScreenOverlay : MonoBehaviour
{
private GameObject customImageObj;
private Image imageComp;
private float timer = 0f;
private float duration = 1f;
private bool isShowing = false;
private void Awake()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.CustomParryImage != (Object)null)
{
customImageObj = new GameObject("SugarcoatImageCentered");
customImageObj.transform.SetParent(((Component)this).transform, false);
RectTransform val = customImageObj.AddComponent<RectTransform>();
val.anchorMin = new Vector2(0.5f, 0.5f);
val.anchorMax = new Vector2(0.5f, 0.5f);
val.pivot = new Vector2(0.5f, 0.5f);
val.anchoredPosition = Vector2.zero;
val.sizeDelta = new Vector2(413f, 360f);
customImageObj.AddComponent<CanvasRenderer>();
imageComp = customImageObj.AddComponent<Image>();
Sprite sprite = Sprite.Create(Plugin.CustomParryImage, new Rect(0f, 0f, (float)((Texture)Plugin.CustomParryImage).width, (float)((Texture)Plugin.CustomParryImage).height), new Vector2(0.5f, 0.5f));
imageComp.sprite = sprite;
customImageObj.SetActive(false);
}
}
public void TriggerParryEffect()
{
//IL_003c: 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_0054: Unknown result type (might be due to invalid IL or missing references)
timer = duration;
isShowing = true;
if ((Object)(object)customImageObj != (Object)null && (Object)(object)imageComp != (Object)null)
{
Color color = ((Graphic)imageComp).color;
color.a = 1f;
((Graphic)imageComp).color = color;
customImageObj.SetActive(true);
}
}
private void Update()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (isShowing && (Object)(object)customImageObj != (Object)null && (Object)(object)imageComp != (Object)null)
{
timer -= Time.deltaTime;
float a = Mathf.Clamp01(timer / duration);
Color color = ((Graphic)imageComp).color;
color.a = a;
((Graphic)imageComp).color = color;
if (timer <= 0f)
{
isShowing = false;
customImageObj.SetActive(false);
}
}
}
}
[HarmonyPatch(typeof(StyleHUD), "AddPoints")]
public class StyleParryPatch
{
[HarmonyPrefix]
public static void Prefix(object[] __args)
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
if (__args == null || __args.Length < 2)
{
return;
}
string text = __args[1]?.ToString();
if (string.IsNullOrEmpty(text) || !text.ToLower().Contains("parry"))
{
return;
}
GameObject val = GameObject.Find("Canvas");
if ((Object)(object)val != (Object)null)
{
ParryScreenOverlay parryScreenOverlay = val.GetComponent<ParryScreenOverlay>();
if ((Object)(object)parryScreenOverlay == (Object)null)
{
parryScreenOverlay = val.AddComponent<ParryScreenOverlay>();
}
parryScreenOverlay.TriggerParryEffect();
}
if ((Object)(object)Plugin.CustomParrySound != (Object)null)
{
GameObject val2 = new GameObject("ParrySoundObj");
AudioSource val3 = val2.AddComponent<AudioSource>();
val3.clip = Plugin.CustomParrySound;
val3.volume = 1f;
val3.Play();
Object.Destroy((Object)(object)val2, Plugin.CustomParrySound.length);
}
}
}