using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MHZ")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Masaicker")]
[assembly: AssemblyDescription("A Hollow Knight Silksong mod that changes enemy HP flash colors")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("HPFlashColor")]
[assembly: AssemblyTitle("HPFlashColor")]
[assembly: AssemblyVersion("1.0.1.0")]
[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 HPFlashColor
{
[BepInPlugin("Mhz.hpflashcolor", "HP Flash Color", "1.0.1")]
public class HPFlashColorPlugin : BaseUnityPlugin
{
public const string ModGUID = "Mhz.hpflashcolor";
public const string ModName = "HP Flash Color";
public const string ModVersion = "1.0.1";
internal static ManualLogSource? Logger;
private static Harmony? _harmony;
public static ConfigEntry<bool>? EnableDebugLog;
public static ConfigEntry<string>? InitialColor;
public static ConfigEntry<string>? TargetColor;
private void Awake()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
EnableDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLog", false, "启用调试日志输出 / Enable debug log output");
InitialColor = ((BaseUnityPlugin)this).Config.Bind<string>("HPGradient", "InitialColor", "255,255,255", "初始颜色 (满血时的颜色,R,G,B格式,如 255,255,255 为白色) / Initial color (color at full HP, R,G,B format, e.g. 255,255,255 for white)");
TargetColor = ((BaseUnityPlugin)this).Config.Bind<string>("HPGradient", "TargetColor", "255,0,0", "目标颜色 (空血时的颜色,R,G,B格式,如 255,0,0 为红色) / Target color (color at low HP, R,G,B format, e.g. 255,0,0 for red)");
_harmony = new Harmony("Mhz.hpflashcolor");
_harmony.PatchAll();
Logger.LogInfo((object)"插件 HP Flash Color 1.0.1 已加载!");
}
private void OnDestroy()
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
public static Color ParseColorFromConfig(string? configValue, Color defaultColor)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_008d: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
try
{
if (string.IsNullOrEmpty(configValue))
{
return defaultColor;
}
string[] array = configValue.Split(',');
if (array.Length != 3)
{
return defaultColor;
}
float num = Mathf.Clamp01((float)int.Parse(array[0].Trim()) / 255f);
float num2 = Mathf.Clamp01((float)int.Parse(array[1].Trim()) / 255f);
float num3 = Mathf.Clamp01((float)int.Parse(array[2].Trim()) / 255f);
return new Color(num, num2, num3, 1f);
}
catch (Exception ex)
{
ManualLogSource? logger = Logger;
if (logger != null)
{
logger.LogWarning((object)("颜色配置解析失败,使用默认颜色: " + ex.Message));
}
return defaultColor;
}
}
public static Color ParseInitialColorFromConfig()
{
//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)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
return ParseColorFromConfig(InitialColor?.Value, Color.white);
}
public static Color ParseTargetColorFromConfig()
{
//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)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
return ParseColorFromConfig(TargetColor?.Value, Color.red);
}
public static Color CalculateHPGradientColor(float hpPercentage)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
Color val = ParseInitialColorFromConfig();
Color val2 = ParseTargetColorFromConfig();
float num = 1f - hpPercentage;
return Color.Lerp(val, val2, num);
}
}
[HarmonyPatch]
public static class OptimizedSpriteFlashPatches
{
[HarmonyPatch(typeof(HealthManager), "TakeDamage", new Type[] { typeof(HitInstance) })]
[HarmonyPostfix]
public static void TakeDamage_Postfix(HealthManager __instance, int ___initHp)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_006e: 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_00c3: 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_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: 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)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
try
{
int hp = __instance.hp;
if (___initHp <= 0)
{
return;
}
float num = Mathf.Clamp01((float)hp / (float)___initHp);
SpriteFlash spriteFlash = __instance.SpriteFlash;
if (!((Object)(object)spriteFlash != (Object)null))
{
return;
}
Color val = HPFlashColorPlugin.CalculateHPGradientColor(num);
spriteFlash.FlashEnemyHit(val);
ConfigEntry<bool>? enableDebugLog = HPFlashColorPlugin.EnableDebugLog;
if (enableDebugLog != null && enableDebugLog.Value)
{
Color val2 = HPFlashColorPlugin.ParseInitialColorFromConfig();
Color val3 = HPFlashColorPlugin.ParseTargetColorFromConfig();
ManualLogSource? logger = HPFlashColorPlugin.Logger;
if (logger != null)
{
logger.LogInfo((object)($"攻击完成后触发自定义闪烁: {((Object)((Component)__instance).gameObject).name} - {hp}/{___initHp} ({num:P1})\n" + $"初始颜色: RGB({val2.r:F2}, {val2.g:F2}, {val2.b:F2})\n" + $"目标颜色: RGB({val3.r:F2}, {val3.g:F2}, {val3.b:F2})\n" + $"当前颜色: RGB({val.r:F2}, {val.g:F2}, {val.b:F2})"));
}
}
}
catch (Exception arg)
{
ManualLogSource? logger2 = HPFlashColorPlugin.Logger;
if (logger2 != null)
{
logger2.LogError((object)$"TakeDamage_Postfix 错误: {arg}");
}
}
}
}
}