using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Pool;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DisableFloatingText")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0")]
[assembly: AssemblyProduct("DisableFloatingText")]
[assembly: AssemblyTitle("DisableFloatingText")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.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;
}
}
}
[BepInPlugin("com.yourname.disablefloatingtext", "DisableFloatingText", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class DisableFloatingTextMod : BaseUnityPlugin
{
private ConfigEntry<bool> showEnemyDamageText;
private ConfigEntry<bool> verboseLogging;
private bool isEnabled = true;
private static DisableFloatingTextMod Instance;
private int updateFrameCounter;
private FieldInfo poolField;
private FieldInfo activeTextsField;
private float lastClearLogTime;
private int totalCleared;
private void Awake()
{
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
Instance = this;
showEnemyDamageText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowEnemyDamageText", true, "Toggle damage text for damage dealt to enemies (true = show, false = hide).");
verboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Log details on cleared texts (target types, counts) - for troubleshooting.");
isEnabled = showEnemyDamageText.Value;
showEnemyDamageText.SettingChanged += OnConfigEntryChanged;
poolField = typeof(DamageText).GetField("pool", BindingFlags.Instance | BindingFlags.NonPublic);
activeTextsField = typeof(DamageText).GetField("activeTexts", BindingFlags.Static | BindingFlags.NonPublic);
Harmony val = new Harmony("com.yourname.disablefloatingtext");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)(val.Id + " loaded!"));
}
private void Update()
{
if (((ButtonControl)Keyboard.current.f7Key).wasPressedThisFrame)
{
isEnabled = !isEnabled;
totalCleared = 0;
}
updateFrameCounter++;
_ = updateFrameCounter % 60;
}
private void LateUpdate()
{
if (isEnabled || DamageText.activeTexts == null || DamageText.activeTexts.Count <= 0)
{
return;
}
int num = 0;
string text = "";
for (int num2 = DamageText.activeTexts.Count - 1; num2 >= 0; num2--)
{
DamageText val = DamageText.activeTexts[num2];
if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf && val.Target != null && !(val.Target is Player))
{
((Component)val).gameObject.SetActive(false);
if (poolField != null)
{
((ObjectPool<DamageText>)poolField.GetValue(val))?.Release(val);
}
num++;
totalCleared++;
if (verboseLogging.Value)
{
string name = ((object)val.Target).GetType().Name;
text = text + name + ", ";
}
DamageText.activeTexts.RemoveAt(num2);
}
}
if (num > 0 && (Time.time - lastClearLogTime > 3f || totalCleared == num))
{
string text2 = $"Runtime clearance: Hidden {num} enemy texts (total: {totalCleared}).";
if (verboseLogging.Value && !string.IsNullOrEmpty(text))
{
text2 = text2 + " Types: " + text.TrimEnd(',', ' ');
}
lastClearLogTime = Time.time;
}
}
private void OnConfigEntryChanged(object sender, EventArgs e)
{
isEnabled = showEnemyDamageText.Value;
}
[HarmonyPatch(typeof(Player), "Update")]
[HarmonyPrefix]
[HarmonyPriority(700)]
public static void PrefixPlayerUpdate(Player __instance)
{
if ((Object)(object)Instance != (Object)null)
{
_ = Time.frameCount % 120;
}
}
[HarmonyPatch(typeof(IDamageSource), "DamageTarget", new Type[]
{
typeof(IDamageSource),
typeof(ITarget),
typeof(DamageData),
typeof(Vector3),
typeof(IDamageSource)
})]
[HarmonyPrefix]
[HarmonyPriority(700)]
public static bool PrefixDamageTarget(IDamageSource source, ITarget target, DamageData damage, Vector3 hitPoint, IDamageSource childSource)
{
if ((Object)(object)Instance == (Object)null)
{
return true;
}
_ = ((object)target)?.GetType().Name;
return true;
}
[HarmonyPatch(typeof(IDamageSource), "DamageTarget", new Type[]
{
typeof(IDamageSource),
typeof(ITarget),
typeof(DamageData),
typeof(Vector3),
typeof(IDamageSource)
})]
[HarmonyPostfix]
[HarmonyPriority(700)]
public static void PostfixDamageTarget(IDamageSource source, ITarget target, DamageData damage, Vector3 hitPoint, IDamageSource childSource)
{
if ((Object)(object)Instance != (Object)null && !Instance.isEnabled && target != null && !(target is Player))
{
Instance.LateUpdate();
}
}
}
namespace DisableFloatingText
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DisableFloatingText";
public const string PLUGIN_NAME = "DisableFloatingText";
public const string PLUGIN_VERSION = "0.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}