using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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 Marioalexsan.Multitool.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Marioalexsan.BetterPrismUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+d56c87b8773298884cdf92fdf68a1f8bfcbbee8b")]
[assembly: AssemblyProduct("BetterPrismUI")]
[assembly: AssemblyTitle("Marioalexsan.BetterPrismUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 Marioalexsan.BetterPrismUI
{
public class PrismUIData
{
public Image? FillImage;
public Player? Player;
public float LastKnownMaxShield;
public float LastKnownShield;
public bool Lerp = true;
public void UpdateFill()
{
if (!((Object)(object)Player == (Object)null) && !((Object)(object)FillImage == (Object)null))
{
LastKnownShield = Player._statusEntity._damageAbsorbtion;
if (LastKnownShield <= 0f)
{
LastKnownMaxShield = 0f;
}
else
{
LastKnownMaxShield = Math.Max(LastKnownMaxShield, LastKnownShield);
}
float fillAmount = FillImage.fillAmount;
float num = ((LastKnownMaxShield != 0f) ? (LastKnownShield / LastKnownMaxShield) : 0f);
FillImage.fillAmount = (Lerp ? Mathf.Lerp(fillAmount, num, Time.deltaTime * 12f) : num);
}
}
}
[HarmonyPatch(typeof(InGameUI), "Awake")]
internal static class PrismHealthUI
{
private static void Postfix()
{
if (!Object.op_Implicit((Object)(object)GameObject.Find("_valueOrb(Prism)(BetterPrismUI)")))
{
GameObject val = HierarchyTraverse.GoToChild(GameObject.Find("_valueOrb(Health)"), "_healthFill");
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
val2.transform.SetSiblingIndex(val.transform.GetSiblingIndex() + 1);
HierarchyTraverse.ForComponent<RectTransform>(HierarchyTraverse.ForComponent<Image>(HierarchyTraverse.Rename(val2, "_absorbtionFill"), (Action<Image>)delegate(Image image)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
BetterPrismUI.PrismImage = image;
image.sprite = BetterPrismUI.Sprite;
((Graphic)image).color = new Color(1f, 1f, 1f, 0.6f);
image.fillAmount = 0f;
}), (Action<RectTransform>)delegate(RectTransform rect)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
rect.sizeDelta += new Vector2(5f, 5f);
});
}
}
}
[HarmonyPatch(typeof(PartyUIManager), "Awake")]
[HarmonyWrapSafe]
internal static class PartyPrismHealthUI
{
private static void Postfix(PartyUIManager __instance)
{
BetterPrismUI.PartyShields.Clear();
PartyUIDataEntry[] partyDataEntries = __instance._partyDataEntries;
foreach (PartyUIDataEntry entry in partyDataEntries)
{
GameObject val = HierarchyTraverse.GoToChild(((Component)entry).gameObject, "_playerStatusValuesTab/_playerHealthBar/_healthFill");
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
val2.transform.SetSiblingIndex(val.transform.GetSiblingIndex() + 1);
HierarchyTraverse.ForComponent<RectTransform>(HierarchyTraverse.ForComponent<Image>(HierarchyTraverse.Rename(val2, "_absorbtionFill"), (Action<Image>)delegate(Image image)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
((Graphic)image).color = new Color(1f, 1f, 1f, 0.6f);
image.fillAmount = 0f;
BetterPrismUI.PartyShields[entry] = new PrismUIData
{
FillImage = image,
Lerp = false
};
}), (Action<RectTransform>)delegate(RectTransform rect)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
rect.sizeDelta += new Vector2(5f, 5f);
});
}
}
}
[HarmonyPatch]
internal static class DisplayWorldHealbarDuringPrism
{
private static MethodInfo TargetMethod()
{
return AccessTools.FirstMethod(typeof(StatusEntityGUI), (Func<MethodInfo, bool>)((MethodInfo x) => x.Name.Contains("Handle_PlayerHealthBar")));
}
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Expected O, but got Unknown
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Expected O, but got Unknown
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Expected O, but got Unknown
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Expected O, but got Unknown
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Expected O, but got Unknown
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Expected O, but got Unknown
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(code, (ILGenerator)null);
Label? label3 = default(Label?);
val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.IsLdarg(x, (int?)0)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.LoadsField(x, AccessTools.Field(typeof(StatusEntityGUI), "_statusEntity"), false)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.LoadsField(x, AccessTools.Field(typeof(StatusEntity), "_currentHealth"), false)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.LoadsConstant(x, 0L)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.Branches(x, ref label3)), (string)null)
});
Label? label = default(Label?);
if (!val.IsValid || !CodeInstructionExtensions.Branches(val.Instruction, ref label))
{
Logging.LogWarning("Couldn't find branch location to transpile for DisplayWorldHealbarDuringPrism!");
Logging.LogWarning("World healthbar display may be impacted! Please notify the mod developer about this!");
return val.InstructionEnumeration();
}
Label? label2 = default(Label?);
val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.IsLdarg(x, (int?)0)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.LoadsField(x, AccessTools.Field(typeof(StatusEntityGUI), "_statusEntity"), false)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.LoadsField(x, AccessTools.Field(typeof(StatusEntity), "_currentHealth"), false)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.IsLdarg(x, (int?)1)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => x.opcode == OpCodes.Ldfld), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.Branches(x, ref label2)), (string)null)
});
if (!val.IsValid)
{
Logging.LogWarning("Couldn't find insert location to transpile for DisplayWorldHealbarDuringPrism!");
Logging.LogWarning("World healthbar display may be impacted! Please notify the mod developer about this!");
return val.InstructionEnumeration();
}
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StatusEntityGUI), "_statusEntity")),
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(DisplayWorldHealbarDuringPrism), "HasActivePrism", (Type[])null, (Type[])null)),
new CodeInstruction(OpCodes.Brtrue, (object)label)
});
return val.InstructionEnumeration();
}
private static bool HasActivePrism(StatusEntity entity)
{
return entity._damageAbsorbtion > 0f;
}
}
[HarmonyPatch(typeof(Player), "Awake")]
[HarmonyWrapSafe]
internal static class PlayerPrismUI
{
private static void Postfix(Player __instance)
{
Player __instance2 = __instance;
GameObject val = HierarchyTraverse.GoToChild(((Component)__instance2).gameObject, "_Canvas_statusBars/_healthbarFillBackdrop/_healthbarFill");
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
val2.transform.SetSiblingIndex(val.transform.GetSiblingIndex() + 1);
HierarchyTraverse.ForComponent<RectTransform>(HierarchyTraverse.ForComponent<Image>(HierarchyTraverse.Rename(val2, "_absorbtionFill"), (Action<Image>)delegate(Image image)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
((Graphic)image).color = new Color(0.75f, 1f, 1f, 0.5f);
image.fillAmount = 0f;
BetterPrismUI.PlayerWorldHealthbarShields[__instance2] = new PrismUIData
{
Player = __instance2,
FillImage = image,
Lerp = false
};
}), (Action<RectTransform>)delegate(RectTransform rect)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
rect.sizeDelta += new Vector2(0.4f, 0.4f);
});
}
}
[BepInPlugin("Marioalexsan.BetterPrismUI", "BetterPrismUI", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BetterPrismUI : BaseUnityPlugin
{
private static BetterPrismUI? _plugin;
private readonly Harmony _harmony = new Harmony("Marioalexsan.BetterPrismUI");
internal static Texture2D Texture = null;
internal static Sprite Sprite = null;
internal static Image PrismImage = null;
private static readonly PrismUIData MainPlayerShield = new PrismUIData();
public static readonly Dictionary<Player, PrismUIData> PlayerWorldHealthbarShields = new Dictionary<Player, PrismUIData>();
public static readonly Dictionary<PartyUIDataEntry, PrismUIData> PartyShields = new Dictionary<PartyUIDataEntry, PrismUIData>();
public static BetterPrismUI Plugin => _plugin ?? throw new InvalidOperationException("BetterPrismUI hasn't been initialized yet. Either wait until initialization, or check via ChainLoader instead.");
internal static ManualLogSource Logger { get; private set; } = null;
private BetterPrismUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_plugin = this;
Logger = ((BaseUnityPlugin)this).Logger;
}
public void Awake()
{
//IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0083: 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)
_harmony.PatchAll();
Texture = new Texture2D(1, 1, (TextureFormat)5, false)
{
name = "Marioalexsan.BetterPrismUI-prismFillTex",
filterMode = (FilterMode)1
};
ImageConversion.LoadImage(Texture, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets", "prismFill.png")));
Sprite = Sprite.Create(Texture, new Rect(0f, 0f, (float)((Texture)Texture).width, (float)((Texture)Texture).height), new Vector2(0.5f, 0.5f));
((Object)Sprite).name = "Marioalexsan.BetterPrismUI-prismFillSprite";
}
public void Update()
{
if ((Object)(object)Player._mainPlayer != (Object)null)
{
MainPlayerShield.Player = Player._mainPlayer;
MainPlayerShield.FillImage = PrismImage;
MainPlayerShield.UpdateFill();
}
if ((Object)(object)PartyUIManager._current != (Object)null)
{
PartyUIDataEntry[] partyDataEntries = PartyUIManager._current._partyDataEntries;
foreach (PartyUIDataEntry val in partyDataEntries)
{
if (PartyShields.TryGetValue(val, out PrismUIData value))
{
if ((Object)(object)value.Player != (Object)(object)val._player)
{
value.LastKnownShield = 0f;
value.LastKnownMaxShield = 0f;
value.Player = val._player;
}
value.UpdateFill();
}
}
}
bool flag = false;
foreach (KeyValuePair<Player, PrismUIData> playerWorldHealthbarShield in PlayerWorldHealthbarShields)
{
if (!Object.op_Implicit((Object)(object)playerWorldHealthbarShield.Key))
{
flag = true;
continue;
}
PrismUIData value2 = playerWorldHealthbarShield.Value;
value2.UpdateFill();
}
if (!flag)
{
return;
}
Player[] array = PlayerWorldHealthbarShields.Keys.ToArray();
foreach (Player val2 in array)
{
if (!Object.op_Implicit((Object)(object)val2))
{
PlayerWorldHealthbarShields.Remove(val2);
}
}
}
}
internal static class Logging
{
private static ManualLogSource InternalLogger => BetterPrismUI.Logger;
public static void LogFatal(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)1, toggle);
}
public static void LogError(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)2, toggle);
}
public static void LogWarning(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)4, toggle);
}
public static void LogMessage(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)8, toggle);
}
public static void LogInfo(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)16, toggle);
}
public static void LogDebug(object data, ConfigEntry<bool>? toggle = null)
{
Log(data, (LogLevel)32, toggle);
}
private static void Log(object data, LogLevel level = 16, ConfigEntry<bool>? toggle = null)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (toggle == null || toggle.Value)
{
ManualLogSource internalLogger = InternalLogger;
if (internalLogger != null)
{
internalLogger.Log(level, data);
}
}
}
}
internal static class ModInfo
{
public const string GUID = "Marioalexsan.BetterPrismUI";
public const string NAME = "BetterPrismUI";
public const string VERSION = "1.1.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}