Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GnomeBangerEnhancements v1.0.1
GnomeBangerEnhancements.dll
Decompiled a month agousing System; using System.Collections.Generic; 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 Photon.Pun; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GnomeBangerEnhancements")] [assembly: AssemblyTitle("GnomeBangerEnhancements")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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.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 REPOJP.GnomeBangerEnhancements { [HarmonyPatch] internal static class BangEnhancementPatches { private static readonly FieldRef<EnemyBang, ParticleScriptExplosion> BangParticleScriptExplosionRef = AccessTools.FieldRefAccess<EnemyBang, ParticleScriptExplosion>("particleScriptExplosion"); private static readonly FieldRef<EnemyBang, ParticlePrefabExplosion> BangExplosionScriptRef = AccessTools.FieldRefAccess<EnemyBang, ParticlePrefabExplosion>("explosionScript"); [HarmonyPatch(typeof(EnemyBang), "FuseLogic")] [HarmonyPrefix] private static bool EnemyBang_FuseLogic_Prefix(EnemyBang __instance) { if (!GnomeBangerEnhancementsPlugin.IsBangEnabled()) { return true; } if (!__instance.fuseActive) { return false; } if (!EnemyBangDirector.instance.debugNoFuseProgress) { int num = Mathf.Clamp(GnomeBangerEnhancementsPlugin.BangFuseSeconds.Value, 0, 30); if (num <= 0) { __instance.fuseLerp = 1f; } else { __instance.fuseLerp += Time.deltaTime / (float)num; } } __instance.fuseLerp = Mathf.Clamp01(__instance.fuseLerp); if (GnomeBangerEnhancementsPlugin.HasAuthority() && __instance.fuseLerp >= 1f) { if (SemiFunc.IsMultiplayer()) { __instance.photonView.RPC("ExplodeRPC", (RpcTarget)0, Array.Empty<object>()); } else { ExplodeCustom(__instance, isDeathExplosion: false); } __instance.UpdateState((State)11); __instance.enemy.EnemyParent.Despawn(); } return false; } [HarmonyPatch(typeof(EnemyBang), "ExplodeRPC")] [HarmonyPrefix] private static bool EnemyBang_ExplodeRPC_Prefix(EnemyBang __instance, PhotonMessageInfo _info = default(PhotonMessageInfo)) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsBangEnabled()) { return true; } if (!SemiFunc.MasterOnlyRPC(_info)) { return false; } ExplodeCustom(__instance, isDeathExplosion: false); return false; } [HarmonyPatch(typeof(EnemyBang), "OnDeath")] [HarmonyPrefix] private static bool EnemyBang_OnDeath_Prefix(EnemyBang __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown if (!GnomeBangerEnhancementsPlugin.IsBangEnabled()) { return true; } __instance.anim.soundDeathSFX.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f); __instance.anim.soundDeathVO.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f); if (GnomeBangerEnhancementsPlugin.HasAuthority()) { __instance.enemy.EnemyParent.Despawn(); } if (__instance.fuseActive && __instance.fuseLerp <= 1f) { if (GnomeBangerEnhancementsPlugin.BangAffectDeathExplosion.Value) { ExplodeCustom(__instance, isDeathExplosion: true); } else { ParticleScriptExplosion val = BangParticleScriptExplosionRef.Invoke(__instance); ParticlePrefabExplosion val2 = val.Spawn(__instance.enemy.CenterTransform.position, 0.5f, 15, 10, 1f, false, false, 1f); BangExplosionScriptRef.Invoke(__instance) = val2; val2.HurtCollider.onImpactEnemy.AddListener(new UnityAction(__instance.OnExplodeHitEnemy)); } } ParticleSystem[] deathEffects = __instance.deathEffects; for (int i = 0; i < deathEffects.Length; i++) { deathEffects[i].Play(); } return false; } private static void ExplodeCustom(EnemyBang bang, bool isDeathExplosion) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown float num = Mathf.Clamp(GnomeBangerEnhancementsPlugin.BangExplosionSize.Value, 0.1f, 10f); int num2 = Mathf.Clamp(GnomeBangerEnhancementsPlugin.BangExplosionDamage.Value, 0, 500); float num3 = Mathf.Clamp(GnomeBangerEnhancementsPlugin.BangExplosionForceMultiplier.Value, 0f, 20f); ParticleSystem[] deathEffects = bang.deathEffects; for (int i = 0; i < deathEffects.Length; i++) { deathEffects[i].Play(); } ParticleScriptExplosion val = BangParticleScriptExplosionRef.Invoke(bang); ParticlePrefabExplosion val2 = val.Spawn(bang.enemy.CenterTransform.position, num, num2, num2, num3, false, false, 1f); BangExplosionScriptRef.Invoke(bang) = val2; val2.HurtCollider.onImpactEnemy.AddListener(new UnityAction(bang.OnExplodeHitEnemy)); } } [BepInPlugin("REPOJP.GnomeBangerEnhancements", "GnomeBangerEnhancements", "1.0.0")] public sealed class GnomeBangerEnhancementsPlugin : BaseUnityPlugin { public const string PluginGuid = "REPOJP.GnomeBangerEnhancements"; public const string PluginName = "GnomeBangerEnhancements"; public const string PluginVersion = "1.0.0"; internal static GnomeBangerEnhancementsPlugin Instance; internal static Harmony HarmonyInstance; internal static ConfigEntry<bool> ModEnabled; internal static ConfigEntry<bool> LogEnabled; internal static ConfigEntry<bool> EnableBang; internal static ConfigEntry<bool> EnableGnome; internal static ConfigEntry<int> BangFuseSeconds; internal static ConfigEntry<float> BangExplosionSize; internal static ConfigEntry<int> BangExplosionDamage; internal static ConfigEntry<float> BangExplosionForceMultiplier; internal static ConfigEntry<bool> BangAffectDeathExplosion; internal static ConfigEntry<int> GnomeHealth; internal static ConfigEntry<float> GnomeAttackOrbitSpeed; internal static ConfigEntry<float> GnomeJumpMultiplier; internal static ConfigEntry<float> GnomeAttackRadius; internal static ConfigEntry<bool> GnomeZeroNoticeDelay; internal static ConfigEntry<bool> GnomeZeroAttackCooldown; internal static ConfigEntry<bool> GnomeOneHitBreakValuable; internal static ConfigEntry<float> GnomeValuablePriorityRadius; internal static ConfigEntry<bool> GnomeZeroIdleTime; private void Awake() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown Instance = this; try { ((Component)this).transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failure: plugin persist setup`n{arg}"); } SetupConfig(); try { HarmonyInstance = new Harmony("REPOJP.GnomeBangerEnhancements"); HarmonyInstance.PatchAll(); WriteLog("Harmony patch applied"); } catch (Exception arg2) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failure: harmony patch`n{arg2}"); } } private void SetupConfig() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ModEnabled", true, "MOD overall enable switch"); LogEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LogEnabled", false, "Debug log enable switch"); EnableBang = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableBang", true, "Bang enhancement enable switch"); EnableGnome = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableGnome", true, "Gnome enhancement enable switch"); BangFuseSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("Bang", "FuseSeconds", 5, new ConfigDescription("Seconds from ignition to explosion", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 30), Array.Empty<object>())); BangExplosionSize = ((BaseUnityPlugin)this).Config.Bind<float>("Bang", "ExplosionSize", 1f, new ConfigDescription("Explosion size for both normal and death explosions", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); BangExplosionDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Bang", "ExplosionDamage", 30, new ConfigDescription("Explosion damage for player and enemy on both normal and death explosions", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>())); BangExplosionForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bang", "ExplosionForceMultiplier", 2f, new ConfigDescription("Explosion knockback multiplier for both normal and death explosions", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); BangAffectDeathExplosion = ((BaseUnityPlugin)this).Config.Bind<bool>("Bang", "AffectDeathExplosion", true, "Apply custom explosion values to death explosion"); GnomeHealth = ((BaseUnityPlugin)this).Config.Bind<int>("Gnome", "Health", 25, new ConfigDescription("Gnome max HP", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10000), Array.Empty<object>())); GnomeAttackOrbitSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Gnome", "AttackOrbitSpeed", 4f, new ConfigDescription("Gnome orbit speed around target", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); GnomeJumpMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gnome", "JumpMultiplier", 1.5f, new ConfigDescription("Multiplier applied to all gnome jump related forces", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); GnomeAttackRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Gnome", "AttackRadius", 1.1f, new ConfigDescription("Gnome attack range radius", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); GnomeZeroNoticeDelay = ((BaseUnityPlugin)this).Config.Bind<bool>("Gnome", "ZeroNoticeDelay", true, "Set notice delay to zero"); GnomeZeroAttackCooldown = ((BaseUnityPlugin)this).Config.Bind<bool>("Gnome", "ZeroAttackCooldown", true, "Set attack cooldown to zero"); GnomeOneHitBreakValuable = ((BaseUnityPlugin)this).Config.Bind<bool>("Gnome", "OneHitBreakValuable", true, "Break any valuable in one hit"); GnomeValuablePriorityRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Gnome", "ValuablePriorityRadius", 5f, new ConfigDescription("Valuable priority search radius around player", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>())); GnomeZeroIdleTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Gnome", "ZeroIdleTime", true, "Set idle time to zero"); } internal static void WriteLog(string message) { if (!((Object)(object)Instance == (Object)null) && LogEnabled.Value) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } internal static bool IsModEnabled() { return ModEnabled != null && ModEnabled.Value; } internal static bool IsBangEnabled() { return IsModEnabled() && EnableBang != null && EnableBang.Value; } internal static bool IsGnomeEnabled() { return IsModEnabled() && EnableGnome != null && EnableGnome.Value; } internal static bool HasAuthority() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { try { if ((Object)(object)GameManager.instance == (Object)null) { return false; } return GameManager.instance.gameMode == 0 || PhotonNetwork.IsMasterClient; } catch { return false; } } } internal static float NormalizeMinMax(float a, float b, out float min, out float max) { min = Mathf.Min(a, b); max = Mathf.Max(a, b); if (max < 0.01f) { max = 0.01f; } if (min < 0f) { min = 0f; } return max; } } [HarmonyPatch] internal static class GnomeEnhancementPatches { private static readonly FieldRef<EnemyGnome, bool> GnomeStateImpulseRef = AccessTools.FieldRefAccess<EnemyGnome, bool>("stateImpulse"); private static readonly FieldRef<EnemyGnome, float> GnomeStateTimerRef = AccessTools.FieldRefAccess<EnemyGnome, float>("stateTimer"); private static readonly FieldRef<EnemyGnome, float> GnomeAttackAngleRef = AccessTools.FieldRefAccess<EnemyGnome, float>("attackAngle"); private static readonly FieldRef<EnemyGnome, Vector3> GnomeMoveBackPositionRef = AccessTools.FieldRefAccess<EnemyGnome, Vector3>("moveBackPosition"); private static readonly FieldRef<EnemyGnome, float> GnomeMoveBackTimerRef = AccessTools.FieldRefAccess<EnemyGnome, float>("moveBackTimer"); private static readonly FieldRef<EnemyGnome, State> GnomeAttackMoveStateRef = AccessTools.FieldRefAccess<EnemyGnome, State>("attackMoveState"); private static readonly FieldRef<EnemyGnomeDirector, bool> DirectorStateImpulseRef = AccessTools.FieldRefAccess<EnemyGnomeDirector, bool>("stateImpulse"); private static readonly FieldRef<EnemyGnomeDirector, PhysGrabObject> DirectorValuableTargetRef = AccessTools.FieldRefAccess<EnemyGnomeDirector, PhysGrabObject>("valuableTarget"); private static readonly MethodInfo DirectorUpdateStateMethod = AccessTools.Method(typeof(EnemyGnomeDirector), "UpdateState", (Type[])null, (Type[])null); private static readonly HashSet<int> InitializedGnomeIds = new HashSet<int>(); [HarmonyPatch(typeof(EnemyGnome), "Start")] [HarmonyPostfix] private static void EnemyGnome_Start_Postfix(EnemyGnome __instance) { if (GnomeBangerEnhancementsPlugin.IsGnomeEnabled() && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.enemy == (Object)null)) { int instanceID = ((Object)__instance).GetInstanceID(); if (!InitializedGnomeIds.Contains(instanceID)) { InitializedGnomeIds.Add(instanceID); ApplyHealth(__instance); ApplyJump(__instance); GnomeBangerEnhancementsPlugin.WriteLog($"Gnome initialized: {instanceID}"); } } } [HarmonyPatch(typeof(EnemyGnome), "StateNoticeDelay")] [HarmonyPrefix] private static bool EnemyGnome_StateNoticeDelay_Prefix(EnemyGnome __instance) { if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } if (!GnomeBangerEnhancementsPlugin.GnomeZeroNoticeDelay.Value) { return true; } __instance.UpdateState((State)3); return false; } [HarmonyPatch(typeof(EnemyGnome), "AttackPositionLogic")] [HarmonyPrefix] private static bool EnemyGnome_AttackPositionLogic_Prefix(EnemyGnome __instance, ref Vector3 __result) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_008e: 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_0094: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } float num = 0.7f; float num2 = Mathf.Clamp(GnomeBangerEnhancementsPlugin.GnomeAttackOrbitSpeed.Value, 0f, 10f); GnomeAttackAngleRef.Invoke(__instance) += Time.deltaTime * num2; Vector3 attackPosition = EnemyGnomeDirector.instance.attackPosition; Vector3 val = new Vector3(Mathf.Cos(GnomeAttackAngleRef.Invoke(__instance)), 0f, Mathf.Sin(GnomeAttackAngleRef.Invoke(__instance))) * num; __result = attackPosition + val; return false; } [HarmonyPatch(typeof(EnemyGnome), "MoveBackPosition")] [HarmonyPrefix] private static bool EnemyGnome_MoveBackPosition_Prefix(EnemyGnome __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } Vector3 position = ((Component)__instance.enemy.Rigidbody).transform.position; Vector3 position2 = ((Component)__instance).transform.position; if (Vector3.Distance(position2, position) < 1f) { Vector3 val = position2 - EnemyGnomeDirector.instance.attackPosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = position2 - position; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = ((Component)__instance).transform.forward; val.y = 0f; } ((Vector3)(ref val)).Normalize(); GnomeMoveBackPositionRef.Invoke(__instance) = position2 + val * 1.5f; } return false; } [HarmonyPatch(typeof(EnemyGnome), "StateMoveBack")] [HarmonyPrefix] private static bool EnemyGnome_StateMoveBack_Prefix(EnemyGnome __instance) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } if (GnomeStateImpulseRef.Invoke(__instance)) { GnomeStateImpulseRef.Invoke(__instance) = false; GnomeStateTimerRef.Invoke(__instance) = 3f; } __instance.enemy.NavMeshAgent.Disable(0.1f); if (!__instance.enemy.Jump.jumping) { float num = __instance.enemy.NavMeshAgent.DefaultSpeed * 1.5f; ((Component)__instance).transform.position = Vector3.MoveTowards(((Component)__instance).transform.position, GnomeMoveBackPositionRef.Invoke(__instance), num * Time.deltaTime); } SemiFunc.EnemyCartJump(__instance.enemy); GnomeStateTimerRef.Invoke(__instance) -= Time.deltaTime; bool flag = EnemyGnomeDirector.instance.CanAttack(__instance); if (GnomeStateTimerRef.Invoke(__instance) <= 0f && (Vector3.Distance(((Component)__instance).transform.position, ((Component)__instance.enemy.Rigidbody).transform.position) > 2f || __instance.enemy.Rigidbody.notMovingTimer > 0.5f)) { if (flag) { __instance.UpdateState((State)9); } else { __instance.UpdateState((State)8); } return false; } if (flag) { __instance.UpdateState((State)9); return false; } if (Vector3.Distance(((Component)__instance).transform.position, GnomeMoveBackPositionRef.Invoke(__instance)) <= 0.1f) { __instance.UpdateState((State)8); return false; } return false; } [HarmonyPatch(typeof(EnemyGnome), "StateAttackDone")] [HarmonyPrefix] private static bool EnemyGnome_StateAttackDone_Prefix(EnemyGnome __instance) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } if (GnomeStateImpulseRef.Invoke(__instance)) { GnomeStateTimerRef.Invoke(__instance) = 1f; GnomeStateImpulseRef.Invoke(__instance) = false; } __instance.enemy.StuckCount = 0; __instance.enemy.Rigidbody.DisableFollowPosition(0.1f, 5f); GnomeStateTimerRef.Invoke(__instance) -= Time.deltaTime; if (GnomeStateTimerRef.Invoke(__instance) <= 0f) { GnomeMoveBackTimerRef.Invoke(__instance) = 2f; if (GnomeBangerEnhancementsPlugin.GnomeZeroAttackCooldown.Value) { __instance.attackCooldown = 0f; } else { __instance.attackCooldown = 2f; } NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)__instance.enemy.Rigidbody).transform.position, ref val, 0.5f, -1)) { __instance.UpdateState((State)8); return false; } __instance.UpdateState(GnomeAttackMoveStateRef.Invoke(__instance)); } return false; } [HarmonyPatch(typeof(EnemyGnomeDirector), "StateAttackSet")] [HarmonyPrefix] private static bool EnemyGnomeDirector_StateAttackSet_Prefix(EnemyGnomeDirector __instance) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } if (!DirectorStateImpulseRef.Invoke(__instance)) { return false; } DirectorStateImpulseRef.Invoke(__instance) = false; DirectorValuableTargetRef.Invoke(__instance) = null; if ((Object)(object)__instance.playerTarget == (Object)null) { CallDirectorUpdateState(__instance, (State)0); return false; } float num = 0f; float num2 = Mathf.Clamp(GnomeBangerEnhancementsPlugin.GnomeValuablePriorityRadius.Value, 0.1f, 20f); Collider[] array = Physics.OverlapSphere(((Component)__instance.playerTarget).transform.position, num2, LayerMask.GetMask(new string[1] { "PhysGrabObject" })); for (int i = 0; i < array.Length; i++) { ValuableObject componentInParent = ((Component)array[i]).GetComponentInParent<ValuableObject>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.physGrabObject != (Object)null && componentInParent.dollarValueCurrent > num) { num = componentInParent.dollarValueCurrent; DirectorValuableTargetRef.Invoke(__instance) = componentInParent.physGrabObject; } } if ((Object)(object)DirectorValuableTargetRef.Invoke(__instance) != (Object)null) { CallDirectorUpdateState(__instance, (State)6); } else { CallDirectorUpdateState(__instance, (State)5); } return false; } [HarmonyPatch(typeof(EnemyGnomeDirector), "CanAttack")] [HarmonyPrefix] private static bool EnemyGnomeDirector_CanAttack_Prefix(EnemyGnomeDirector __instance, EnemyGnome _gnome, ref bool __result) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (!GnomeBangerEnhancementsPlugin.IsGnomeEnabled()) { return true; } if (_gnome.attackCooldown > 0f || _gnome.enemy.Jump.jumping) { __result = false; return false; } float num = Mathf.Clamp(GnomeBangerEnhancementsPlugin.GnomeAttackRadius.Value, 0.1f, 5f); if ((int)__instance.currentState == 5) { __result = Vector3.Distance(((Component)_gnome.enemy.Rigidbody).transform.position, __instance.attackPosition) <= num; return false; } PhysGrabObject val = DirectorValuableTargetRef.Invoke(__instance); if ((Object)(object)val != (Object)null) { _gnome.overlapCheckCooldown = 1f; if (_gnome.overlapCheckTimer <= 0f) { _gnome.overlapCheckTimer = 0.5f; _gnome.overlapCheckPrevious = false; Collider[] array = Physics.OverlapSphere(((Component)_gnome.enemy.Rigidbody).transform.position, num, LayerMask.GetMask(new string[1] { "PhysGrabObject" })); for (int i = 0; i < array.Length; i++) { ValuableObject componentInParent = ((Component)array[i]).GetComponentInParent<ValuableObject>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.physGrabObject == (Object)(object)val) { _gnome.overlapCheckPrevious = true; break; } } } __result = _gnome.overlapCheckPrevious; return false; } __result = false; return false; } [HarmonyPatch(typeof(EnemyGnomeDirector), "StateIdle")] [HarmonyPostfix] private static void EnemyGnomeDirector_StateIdle_Postfix(EnemyGnomeDirector __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 if (GnomeBangerEnhancementsPlugin.IsGnomeEnabled() && GnomeBangerEnhancementsPlugin.GnomeZeroIdleTime.Value && GnomeBangerEnhancementsPlugin.HasAuthority() && (int)__instance.currentState <= 0 && !SemiFunc.EnemySpawnIdlePause()) { CallDirectorUpdateState(__instance, (State)2); } } [HarmonyPatch(typeof(EnemyGnomeAnim), "PickaxeHit")] [HarmonyPostfix] private static void EnemyGnomeAnim_PickaxeHit_Postfix(EnemyGnomeAnim __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 if (GnomeBangerEnhancementsPlugin.IsGnomeEnabled() && GnomeBangerEnhancementsPlugin.GnomeOneHitBreakValuable.Value && GnomeBangerEnhancementsPlugin.HasAuthority() && !((Object)(object)EnemyGnomeDirector.instance == (Object)null) && (int)EnemyGnomeDirector.instance.currentState == 6) { PhysGrabObject val = DirectorValuableTargetRef.Invoke(EnemyGnomeDirector.instance); if (!((Object)(object)val == (Object)null) && (Object)(object)val.impactDetector != (Object)null && !val.impactDetector.isIndestructible) { val.heavyBreakImpulse = true; val.mediumBreakImpulse = false; val.lightBreakImpulse = false; } } } private static void ApplyHealth(EnemyGnome gnome) { if (!((Object)(object)gnome.enemy == (Object)null) && !((Object)(object)gnome.enemy.Health == (Object)null)) { int num = Mathf.Clamp(GnomeBangerEnhancementsPlugin.GnomeHealth.Value, 1, 10000); gnome.enemy.Health.health = num; gnome.enemy.Health.healthCurrent = num; } } private static void ApplyJump(EnemyGnome gnome) { if (!((Object)(object)gnome.enemy == (Object)null) && !((Object)(object)gnome.enemy.Jump == (Object)null)) { float num = Mathf.Clamp(GnomeBangerEnhancementsPlugin.GnomeJumpMultiplier.Value, 0.1f, 5f); EnemyJump jump = gnome.enemy.Jump; jump.surfaceJumpForceUp *= num; jump.surfaceJumpForceSide *= num; jump.stuckJumpForceUp *= num; jump.stuckJumpForceSide *= num; jump.gapJumpForceUp *= num; jump.gapJumpForceForward *= num; } } private static void CallDirectorUpdateState(EnemyGnomeDirector director, State state) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) DirectorUpdateStateMethod.Invoke(director, new object[1] { state }); } } }