using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HenryMod.Modules.Components; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace HenryChargeTweaks; [BepInPlugin("com.henrychargetweaks.plugin", "Henry Charge Tweaks", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class HenryChargeTweaksPlugin : BaseUnityPlugin { public const string PluginGuid = "com.henrychargetweaks.plugin"; public const string PluginName = "Henry Charge Tweaks"; public const string PluginVersion = "1.0.0"; private ConfigEntry pluginEnabled; private ConfigEntry furyPerSecond; private ConfigEntry furyPerPrimaryHit; private ConfigEntry furyPerKill; private void Awake() { pluginEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Set to false to leave Henry's fury meter completely unchanged by this plugin."); furyPerSecond = ((BaseUnityPlugin)this).Config.Bind("Charge sources", "Fury per second", 0.5f, "Fury gained automatically every second. Set to 0 to disable automatic charging."); furyPerPrimaryHit = ((BaseUnityPlugin)this).Config.Bind("Charge sources", "Fury per primary hit", 2f, "Fury gained for every enemy damaged by Henry's primary attack. Set to 0 to disable this source."); furyPerKill = ((BaseUnityPlugin)this).Config.Bind("Charge sources", "Fury per kill", 5f, "Fury gained when Henry gets a kill. Set to 0 to disable this source."); GlobalEventManager.onServerDamageDealt += OnServerDamageDealt; GlobalEventManager.onCharacterDeathGlobal += OnCharacterDeathGlobal; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Henry Charge Tweaks loaded."); } private void OnDestroy() { GlobalEventManager.onServerDamageDealt -= OnServerDamageDealt; GlobalEventManager.onCharacterDeathGlobal -= OnCharacterDeathGlobal; } private void FixedUpdate() { if (!NetworkServer.active || !pluginEnabled.Value || furyPerSecond.Value <= 0f) { return; } float amount = furyPerSecond.Value * Time.fixedDeltaTime; foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { AddFury(((Component)readOnlyInstances).GetComponent(), amount); } } private void OnServerDamageDealt(DamageReport report) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 if (NetworkServer.active && pluginEnabled.Value && report != null && !((Object)(object)report.attackerBody == (Object)null) && (int)report.damageInfo.damageType.damageSource == 1) { AddFury(((Component)report.attackerBody).GetComponent(), furyPerPrimaryHit.Value); } } private void OnCharacterDeathGlobal(DamageReport report) { if (NetworkServer.active && pluginEnabled.Value && report != null && !((Object)(object)report.attackerBody == (Object)null)) { AddFury(((Component)report.attackerBody).GetComponent(), furyPerKill.Value); } } private static void AddFury(HenryFuryComponent fury, float amount) { if (!((Object)(object)fury == (Object)null) && !(amount <= 0f) && !(fury.currentFury >= fury.maxFury)) { fury.AddFury(amount); } } }