using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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 Microsoft.CodeAnalysis;
using Pigeon.Math;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Pool;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sparroh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("HeavensFuryRework")]
[assembly: AssemblyTitle("HeavensFuryRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 HeavensFuryRework
{
public static class ConfigManager
{
private const float DebounceSeconds = 0.25f;
private static ConfigFile config;
private static ManualLogSource logger;
private static FileSystemWatcher configWatcher;
private static volatile bool reloadPending;
private static float lastReloadTime;
public static ConfigEntry<bool> EnableHeavensFuryRework { get; private set; }
public static void Initialize(ConfigFile configFile, ManualLogSource log)
{
config = configFile;
logger = log;
EnableHeavensFuryRework = config.Bind<bool>("General", "Enable Rework", true, "Enhances Heaven's Fury smite behavior with increased frequency and area damage.");
try
{
SetupFileWatcher();
}
catch (Exception ex)
{
logger.LogError((object)("Error setting up config file watcher: " + ex.Message));
}
}
public static void Tick()
{
if (!reloadPending || Time.unscaledTime - lastReloadTime < 0.25f)
{
return;
}
reloadPending = false;
lastReloadTime = Time.unscaledTime;
try
{
config.Reload();
logger.LogInfo((object)"Config reloaded from disk.");
}
catch (Exception ex)
{
logger.LogError((object)("Error reloading config: " + ex.Message));
}
}
public static void Dispose()
{
if (configWatcher != null)
{
configWatcher.EnableRaisingEvents = false;
configWatcher.Changed -= OnConfigFileChanged;
configWatcher.Created -= OnConfigFileChanged;
configWatcher.Renamed -= OnConfigFileChanged;
configWatcher.Dispose();
configWatcher = null;
}
}
private static void SetupFileWatcher()
{
configWatcher = new FileSystemWatcher(Paths.ConfigPath, "sparroh.heavensfuryrework.cfg");
configWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite;
configWatcher.Changed += OnConfigFileChanged;
configWatcher.Created += OnConfigFileChanged;
configWatcher.Renamed += OnConfigFileChanged;
configWatcher.EnableRaisingEvents = true;
}
private static void OnConfigFileChanged(object sender, FileSystemEventArgs e)
{
reloadPending = true;
}
}
[HarmonyPatch(typeof(WideGun), "Update")]
public static class WideGun_Update_Patch
{
private static readonly FieldRef<WideGun, int> smitesRemainingField = AccessTools.FieldRefAccess<WideGun, int>("smitesRemaining");
private static readonly FieldRef<WideGun, float> lastSmiteTimeField = AccessTools.FieldRefAccess<WideGun, float>("lastSmiteTime");
private static readonly FieldRef<WideGun, Vector3> smitePositionField = AccessTools.FieldRefAccess<WideGun, Vector3>("smitePosition");
[HarmonyPrefix]
private static bool Prefix(WideGun __instance)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigManager.EnableHeavensFuryRework.Value)
{
return true;
}
if (!((NetworkBehaviour)__instance).IsOwner)
{
return true;
}
int num = smitesRemainingField.Invoke(__instance);
if (num <= 0)
{
return true;
}
float time = Time.time;
float num2 = lastSmiteTimeField.Invoke(__instance);
if (!(time - num2 > 0.155f))
{
return true;
}
lastSmiteTimeField.Invoke(__instance) = time;
smitesRemainingField.Invoke(__instance) = num - 1;
float value;
float num3 = (SparrohPlugin.lastSmiteDamage.TryGetValue(__instance, out value) ? value : 0f);
Vector3 val = smitePositionField.Invoke(__instance);
Vector2 val2 = ((Random)(ref Random.shared)).InsideUnitCircle();
val.x += val2.x * __instance.TridentData.smiteRadius;
val.z += val2.y * __instance.TridentData.smiteRadius;
val.y += 30f;
RaycastHit val4 = default(RaycastHit);
Vector3 val3 = ((!Physics.Raycast(val, Vector3.down, ref val4, 60f, 8193)) ? (val - new Vector3(0f, 60f, 0f)) : ((RaycastHit)(ref val4)).point);
bool flag = ((Random)(ref Random.shared)).NextFloat() < __instance.TridentData.smiteSoakChance;
List<ITarget> list = CollectionPool<List<ITarget>, ITarget>.Get();
try
{
float num4 = ((__instance.TridentData.smiteSoakChance > 0f) ? 4f : 2f);
if (IDamageSource.GetTargetsInCapsule(val, val3, num4, 83080, list, (TargetType)255))
{
DamageData val5 = default(DamageData);
((DamageData)(ref val5))..ctor((__instance.TridentData.smiteSoakChance > 0f) ? (num3 * 0.5f) : 0f, (EffectType)2, 10f);
for (int i = 0; i < list.Count; i++)
{
ITarget val6 = list[i];
Vector3 healthbarPosition = ((IFollowable)val6).GetHealthbarPosition();
IDamageSource.DamageTarget((IDamageSource)(object)__instance, val6, val5, healthbarPosition, (Collider)null);
if (flag)
{
IDamageSource.DamageTarget((IDamageSource)(object)__instance, val6, new DamageData(0f, (EffectType)9, 10f), healthbarPosition, (Collider)null);
}
}
}
}
finally
{
CollectionPool<List<ITarget>, ITarget>.Release(list);
}
GameManager.Instance.SpawnLightningEffect_Rpc(val, val3);
return false;
}
}
[HarmonyPatch(typeof(WideGun), "AfterDamageTarget")]
public static class WideGun_AfterDamageTarget_Patch
{
private static readonly FieldRef<Gun, GunData> gunDataField = AccessTools.FieldRefAccess<Gun, GunData>("gunData");
[HarmonyPostfix]
private static void Postfix(WideGun __instance, in DamageCallbackData data)
{
//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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.EnableHeavensFuryRework.Value)
{
GunData val = gunDataField.Invoke((Gun)(object)__instance);
if ((object)data.source != __instance && ((int)data.damageData.effect <= 0 || data.damageData.effectAmount != 0f) && ((Random)(ref Random.shared)).NextFloat() <= __instance.TridentData.smiteChance / (float)val.bulletsPerShot)
{
SparrohPlugin.lastSmiteDamage[__instance] = data.damageData.damage;
}
}
}
}
[BepInPlugin("sparroh.heavensfuryrework", "HeavensFuryRework", "1.0.2")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SparrohPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.heavensfuryrework";
public const string PluginName = "HeavensFuryRework";
public const string PluginVersion = "1.0.2";
internal static ManualLogSource Logger;
internal static Dictionary<WideGun, float> lastSmiteDamage = new Dictionary<WideGun, float>();
private Harmony harmony;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
ConfigManager.Initialize(((BaseUnityPlugin)this).Config, Logger);
harmony = new Harmony("sparroh.heavensfuryrework");
try
{
harmony.PatchAll(typeof(WideGun_Update_Patch));
harmony.PatchAll(typeof(WideGun_AfterDamageTarget_Patch));
Logger.LogInfo((object)"Harmony patches applied.");
}
catch (Exception ex)
{
Logger.LogError((object)("Error applying patches: " + ex.Message));
}
Logger.LogInfo((object)"HeavensFuryRework v1.0.2 loaded successfully.");
}
private void Update()
{
ConfigManager.Tick();
}
private void OnDestroy()
{
ConfigManager.Dispose();
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HeavensFuryRework";
public const string PLUGIN_NAME = "HeavensFuryRework";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}