using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LethalJacky")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalJacky")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1d1a78e0-0f27-4a72-a970-5b69e3b843e5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalJacky;
[BepInPlugin("Letena.LethalJacky", "Lethal Jacky", "1.0.0.0")]
public class LethalJacky : BaseUnityPlugin
{
private const string modGUID = "Letena.LethalJacky";
private const string modName = "Lethal Jacky";
private const string modVersion = "1.0.0.0";
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("Letena.LethalJacky").PatchAll();
((BaseUnityPlugin)this).Logger.LogMessage((object)"Lethal Jacky has loaded UwU");
}
}
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
public class HealthPatch
{
private static void Postfix(PlayerControllerB __instance)
{
int health = __instance.health;
if (__instance.isPlayerDead)
{
HUDManager.HideLowHealthImage();
}
else if (health <= 32)
{
HUDManager.ShowLowHealthImage();
}
else
{
HUDManager.HideLowHealthImage();
}
}
}
public class HUDManager : MonoBehaviour
{
private static GameObject lowHealthImage;
private static bool isInitialized;
private static AssetBundle myAssetBundle;
public static void Initialize()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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)
if (isInitialized)
{
return;
}
LoadAssetBundle();
ReplaceTextures();
Texture2D val = LoadTextureFromBundle("WeNeedADoctor");
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Failed to load texture from Asset Bundle.");
return;
}
lowHealthImage = new GameObject("LowHealthImage");
lowHealthImage.AddComponent<Image>().sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
GameObject val2 = GameObject.Find("Canvas");
if ((Object)(object)val2 != (Object)null)
{
lowHealthImage.transform.SetParent(val2.transform, false);
RectTransform component = lowHealthImage.GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.sizeDelta = new Vector2(130f, 130f);
component.anchorMin = new Vector2(0f, 0.5f);
component.anchorMax = new Vector2(0f, 0.5f);
component.pivot = new Vector2(0f, 0.5f);
component.anchoredPosition = new Vector2(70f, 0f);
}
lowHealthImage.SetActive(false);
isInitialized = true;
}
else
{
Debug.LogError((object)"Canvas not found in the scene.");
}
}
private static void LoadAssetBundle()
{
if ((Object)(object)myAssetBundle != (Object)null)
{
return;
}
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wolftekst");
if (File.Exists(text))
{
myAssetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)myAssetBundle == (Object)null)
{
Debug.LogError((object)"Failed to load Asset Bundle!");
}
}
else
{
Debug.LogError((object)"Asset Bundle file not found!");
}
}
public static Texture2D LoadTextureFromBundle(string textureName)
{
if ((Object)(object)myAssetBundle == (Object)null)
{
return null;
}
return myAssetBundle.LoadAsset<Texture2D>(textureName);
}
public static void ReplaceTextures()
{
ReplaceTexture("StickyNoteTex");
ReplaceTexture("artificeHint");
ReplaceTexture("StopSignTex");
}
private static void ReplaceTexture(string textureName)
{
Texture2D val = LoadTextureFromBundle(textureName);
if ((Object)(object)val != (Object)null)
{
Material[] array = Resources.FindObjectsOfTypeAll<Material>();
foreach (Material val2 in array)
{
if ((Object)(object)val2.mainTexture != (Object)null && ((Object)val2.mainTexture).name == textureName)
{
val2.mainTexture = (Texture)(object)val;
Debug.Log((object)("Replaced texture: " + textureName));
}
}
}
else
{
Debug.LogError((object)("Failed to load texture '" + textureName + "' from Asset Bundle."));
}
}
public static void ShowLowHealthImage()
{
Initialize();
if ((Object)(object)lowHealthImage != (Object)null)
{
lowHealthImage.SetActive(true);
}
else
{
Debug.LogError((object)"LowHealthImage GameObject is not initialized.");
}
}
public static void HideLowHealthImage()
{
Initialize();
if ((Object)(object)lowHealthImage != (Object)null)
{
lowHealthImage.SetActive(false);
}
else
{
Debug.LogError((object)"LowHealthImage GameObject is not initialized.");
}
}
}