using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AK.Wwise;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
using Pigeon.Movement;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;
[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("UnofficialPatch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.6+5723c953a74d2c67755caace0ea16c9a3c6be082")]
[assembly: AssemblyProduct("UnofficialPatch")]
[assembly: AssemblyTitle("UnofficialPatch")]
[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;
}
}
}
[HarmonyPatch(typeof(Player), "set_AutoSprint")]
public static class Player_AutoSprint_Patch
{
public static void Postfix(Player __instance, bool value)
{
if (SparrohPlugin.EnableAutoSprintFix.Value && !__instance.ToggleSprint)
{
((object)__instance).GetType().GetField("wantsToSprint", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, value);
}
}
}
[HarmonyPatch(typeof(FlatTundraObjective), "PlayLastIntroDialogue")]
public static class FlatTundraObjective_PlayLastIntroDialogue_Patch
{
[HarmonyPrefix]
public static bool Prefix(FlatTundraObjective __instance)
{
if (!SparrohPlugin.EnableCraniusDialogueFix.Value)
{
return true;
}
try
{
if ((Object)(object)__instance == (Object)null || !((Component)__instance).gameObject.activeInHierarchy || !((Behaviour)__instance).enabled)
{
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[CraniusDialogueFix] Error in FlatTundraObjective_PlayLastIntroDialogue_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch]
public class CartridgeSMGFixes
{
[HarmonyPatch(typeof(CartridgeSMG), "OnUpgradesDisabled")]
[HarmonyPrefix]
public static bool OnUpgradesDisabledPrefix(CartridgeSMG __instance)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
if (!SparrohPlugin.EnableCyclerDestructionFix.Value)
{
return true;
}
object value = Traverse.Create((object)__instance).Field("player").GetValue();
if (value != null)
{
if (UpgradeFlagsExtensions.IsEnabled(((Gun)__instance).UpgradeFlags, (SMGUpgradeFlags)512))
{
object value2 = Traverse.Create((object)__instance).Field("NetworkManager").GetValue();
if (value2 != null)
{
object value3 = Traverse.Create(value2).Property("NetworkTickSystem", (object[])null).GetValue();
if (value3 != null)
{
Action value4 = Traverse.Create(value3).Field("Tick").GetValue<Action>();
value4 = (Action)Delegate.Remove(value4, Traverse.Create((object)__instance).Method("OnTick", Array.Empty<object>()).GetValue<Action>());
Traverse.Create(value3).Field("Tick").SetValue((object)value4);
}
}
Traverse.Create((object)__instance).Field("gunData").Property("useAmmoOnFire", (object[])null)
.SetValue((object)1);
int value5 = Traverse.Create(Traverse.Create((object)__instance).Field("gunData").GetValue()).Field("magazineSize").GetValue<int>();
Traverse.Create((object)__instance).Property("RemainingAmmo", (object[])null).SetValue((object)(float)value5);
}
if (Traverse.Create(Traverse.Create((object)__instance).Field("data").GetValue()).Field("returnEnergyOnCorrodeDOTAmount").GetValue<int>() > 0)
{
object value6 = Traverse.Create(value).Field("OnDamageTarget").GetValue();
if (value6 != null)
{
object value7 = Traverse.Create((object)__instance).Method("ReturnEnergyOnCorrodeDOT", Array.Empty<object>()).GetValue();
Delegate value8 = Delegate.Remove((Delegate)value6, (Delegate)value7);
Traverse.Create(value).Field("OnDamageTarget").SetValue((object)value8);
}
}
if (!UpgradeFlagsExtensions.IsEnabled(((Gun)__instance).UpgradeFlags, (SMGUpgradeFlags)1))
{
return false;
}
Traverse.Create((object)__instance).Field("forceEnableFire").SetValue((object)false);
}
return false;
}
[HarmonyPatch(typeof(CartridgeSMG), "OnTick")]
[HarmonyPrefix]
public static bool OnTickPrefix(CartridgeSMG __instance)
{
if (!SparrohPlugin.EnableCyclerDestructionFix.Value)
{
return true;
}
if (((Gun)__instance).SkinRenderers == null || ((Gun)__instance).SkinRenderers.Length == 0 || (Object)(object)((Gun)__instance).SkinRenderers[0] == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ScoutLaserHUD), "OnLaserChargeChanged")]
public class ScoutLaserHUD_OnLaserChargeChanged_Patch
{
[HarmonyPrefix]
public static bool Prefix(ScoutLaserHUD __instance, float charge, float capacity)
{
if (!SparrohPlugin.EnableDMLRBatteryFix.Value)
{
return true;
}
try
{
Traverse val = Traverse.Create((object)__instance);
if (!(val.Field("batterySegments").GetValue() is List<Graphic> list) || list.Count == 0)
{
return false;
}
if (!(val.Field("gear").GetValue() is IGear))
{
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[DMLRBatteryFix] Error in ScoutLaserHUD_OnLaserChargeChanged_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(UpgradeProperty_Player_ApplyElementOnSaturate), "OnSaturateTarget")]
public class ApplyElementOnSaturatePatch
{
[HarmonyPrefix]
public static bool Prefix(ref EffectCallbackData effectData)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
if (!SparrohPlugin.EnableElementalCocktailFix.Value)
{
return true;
}
try
{
ref UpgradeVariableData upgradeVariables = ref Player.LocalPlayer.UpgradeVariables;
if (effectData.effect != upgradeVariables.elementSynergyPrimary || (double)((Random)(ref Random.shared)).NextFloat() > (double)upgradeVariables.elementSynergyChance)
{
return false;
}
IDamageSource.DamageTarget((IDamageSource)(object)GameManager.Instance, effectData.target, new DamageData(0f, upgradeVariables.elementSynergySecondary, 10f), effectData.position, (Collider)null);
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[ElementalCocktailFix] Error in ApplyElementOnSaturatePatch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(GlobblerBullet), "Detonate")]
public static class GlobblerBullet_Detonate_Patch
{
public static bool Prefix(GlobblerBullet __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Expected O, but got Unknown
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
if (!SparrohPlugin.EnableGlobblerFriendFireFix.Value)
{
return true;
}
try
{
Traverse obj = Traverse.Create((object)__instance);
Vector3 value = obj.Field("positionNext").GetValue<Vector3>();
Event value2 = obj.Field("explosionSound").GetValue<Event>();
float value3 = obj.Property("ExplosionShake", (object[])null).GetValue<float>();
float value4 = obj.Field("explosionVisualSizeMultiplier").GetValue<float>();
object value5 = obj.Field("data").GetValue();
Type type = value5.GetType();
int num = (int)type.GetField("targetCollisionMask").GetValue(value5);
float num2 = (float)type.GetField("force").GetValue(value5);
float num3 = (float)type.GetField("damage").GetValue(value5);
EffectType val = (EffectType)type.GetField("damageEffect").GetValue(value5);
float num4 = (float)type.GetField("damageEffectAmount").GetValue(value5);
DamageFlags val2 = (DamageFlags)type.GetField("damageFlags").GetValue(value5);
TargetEnumerator val3 = default(TargetEnumerator);
try
{
int num5 = (BulletFlagsExtensions.OnlyDamageLocalPlayer(((SimpleProjectileBullet)__instance).Flags) ? 1024 : ((((uint)num & 8u) != 0) ? (num | 0x400) : num));
if (((TargetEnumerator)(ref val3)).GetTargetsInSphere(value, num2, num5, (TargetType)5))
{
DamageData val4 = default(DamageData);
((DamageData)(ref val4))..ctor(num3, val, num4, (DamageFlags)(val2 | 0x10));
while (((TargetEnumerator)(ref val3)).MoveNext())
{
if (((TargetEnumerator)(ref val3)).Current == Player.LocalPlayer)
{
val4.effectAmount *= ((GrenadeBullet)__instance).SelfEffectMultiplier;
}
IDamageSource.DamageTarget((IDamageSource)(object)__instance, ((TargetEnumerator)(ref val3)).Current, val4, ((IFollowable)((TargetEnumerator)(ref val3)).Current).GetHealthbarPosition(), (Collider)null);
}
}
}
finally
{
((TargetEnumerator)(ref val3)).Dispose();
}
Globbler val5 = (Globbler)((SimpleProjectileBullet)__instance).ParentSource;
ref Data globblerData = ref val5.GlobblerData;
if (globblerData.acidPuddleDuration > 0f)
{
GameManager.Instance.SpawnAcidPuddle_Rpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val5), value, globblerData.acidPuddleDuration, (TargetType)5, globblerData.acidPuddleSize);
}
if (BulletFlagsExtensions.OnlyDamageLocalPlayer(((SimpleProjectileBullet)__instance).Flags))
{
if (((BaseType)value2).Id == 0)
{
GameManager.Instance.SpawnExplosionVisual(value, num2 * value4, val);
}
else
{
GameManager.Instance.SpawnExplosionVisual(value, num2 * value4, val, ((BaseType)value2).Id, Mathf.InverseLerp(0.9f, 3f, num2), false);
}
return false;
}
if (((BaseType)value2).Id == 0)
{
GameManager.Instance.SpawnExplosionVisualObserverSeeThrough_Rpc(value, num2 * value4, val, (uint)NetworkManager.Singleton.LocalClientId);
}
else
{
GameManager.Instance.SpawnExplosionVisual_Rpc(value, num2 * value4, val, ((BaseType)value2).Id, Mathf.InverseLerp(0.9f, 3f, num2), NetworkManager.Singleton.LocalClientId);
}
IDamageSource.ApplyExplosionScreenshake(ref value, num2, value3);
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[GlobblerFriendFireFix] Error in Detonate patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(VoltaicGrenade), "OverrideActivate")]
public class LivewireVoltaicGrenade_OverrideActivate_Patch
{
private static bool Prefix(VoltaicGrenade __instance, ref bool __result)
{
if (!SparrohPlugin.EnableLivewireFix.Value)
{
return true;
}
try
{
Traverse val = Traverse.Create((object)__instance);
Traverse val2 = val.Field("grenadeData");
float value = val2.Field("selfGrenadeDuration").GetValue<float>();
float value2 = val.Field("selfGrenadeTimer").GetValue<float>();
float value3 = val.Field("cooldownData").Field("charge").GetValue<float>();
SparrohPlugin.Logger.LogInfo((object)$"[Livewire] OverrideActivate called. Duration: {value}, Timer: {value2}, Charge: {value3}");
if (value > 0f && value2 < 0f)
{
if (value3 >= 1f)
{
val.Field("selfGrenadeTimer").SetValue((object)0f);
float value4 = val2.Field("selfGrenadeExplodeInterval").GetValue<float>();
val.Field("selfGrenadeExplosionTimer").SetValue((object)value4);
Player value5 = val.Field("player").GetValue<Player>();
Sprite value6 = val.Field("livewireIcon").GetValue<Sprite>();
value5.UpdateStackDisplay((object)typeof(UpgradeProperty_VoltaicGrenade_Livewire), TextBlocks.GetString("Livewire", 0), value6, 1, value);
float num = value3;
val.Field("cooldownData").Field("charge").SetValue((object)(num - 1f));
val.Method("InvokeOnCooldownChanged", new object[1] { num - 1f }).GetValue();
SparrohPlugin.Logger.LogInfo((object)$"[Livewire] Activated successfully. New charge: {num - 1f}");
__result = true;
return false;
}
SparrohPlugin.Logger.LogInfo((object)"[Livewire] Failed: insufficient charge");
__result = false;
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in LivewireVoltaicGrenade_OverrideActivate_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(Player), "TryThrow")]
public class Player_TryThrow_Patch
{
[CompilerGenerated]
private sealed class <RechargeVoltaicGrenade>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public VoltaicGrenade grenade;
public float duration;
private float <time>5__2;
private Traverse <traverse>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RechargeVoltaicGrenade>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<traverse>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<time>5__2 = 0f;
<traverse>5__3 = Traverse.Create((object)grenade);
break;
case 1:
<>1__state = -1;
break;
}
if (<time>5__2 < duration)
{
<time>5__2 += Time.deltaTime;
float num = Mathf.Min(<time>5__2 / duration, 1f);
<traverse>5__3.Field("cooldownData").Field("charge").SetValue((object)num);
<traverse>5__3.Method("InvokeOnCooldownChanged", new object[1] { num }).GetValue();
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool Prefix(Player __instance)
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
if (!SparrohPlugin.EnableLivewireFix.Value)
{
return true;
}
try
{
IGear throwableGear = __instance.ThrowableGear;
VoltaicGrenade val = (VoltaicGrenade)(object)((throwableGear is VoltaicGrenade) ? throwableGear : null);
if ((Object)(object)val != (Object)null)
{
Traverse val2 = Traverse.Create((object)val);
if (val2.Field("grenadeData").Field("selfGrenadeDuration").GetValue<float>() <= 0f)
{
return true;
}
if (val2.Field("selfGrenadeTimer").GetValue<float>() < 0f)
{
if (val2.Field("cooldownData").Field("charge").GetValue<float>() >= 1f)
{
((Throwable)val).OverrideActivate();
CooldownData value = val2.Field("cooldownData").GetValue<CooldownData>();
((MonoBehaviour)__instance).StartCoroutine(RechargeVoltaicGrenade(val, value.rechargeDuration));
AbilityRechargeUI rechargeUI = __instance.PlayerLook.GetRechargeUI((IActivatedAbility)(object)val);
if ((Object)(object)rechargeUI != (Object)null)
{
((Component)rechargeUI).gameObject.SetActive(true);
}
return false;
}
return false;
}
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Player_TryThrow_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
[IteratorStateMachine(typeof(<RechargeVoltaicGrenade>d__1))]
private static IEnumerator RechargeVoltaicGrenade(VoltaicGrenade grenade, float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RechargeVoltaicGrenade>d__1(0)
{
grenade = grenade,
duration = duration
};
}
}
[HarmonyPatch(typeof(Throwable), "Fire")]
public class Throwable_Fire_Patch
{
private static bool Prefix(Throwable __instance)
{
if (!SparrohPlugin.EnableLivewireFix.Value)
{
return true;
}
try
{
if (__instance is VoltaicGrenade)
{
if (Traverse.Create((object)__instance).Field("grenadeData").Field("selfGrenadeDuration")
.GetValue<float>() <= 0f)
{
return true;
}
if (Traverse.Create((object)__instance).Field("selfGrenadeTimer").GetValue<float>() >= 0f)
{
return false;
}
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_Fire_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(Throwable))]
[HarmonyPatch("get_CanEquipWhenUncharged")]
public class Throwable_CanEquipWhenUncharged_Patch
{
private static void Postfix(ref bool __result, Throwable __instance)
{
if (!SparrohPlugin.EnableLivewireFix.Value)
{
return;
}
try
{
if (__instance is VoltaicGrenade && Traverse.Create((object)__instance).Field("grenadeData").Field("selfGrenadeDuration")
.GetValue<float>() > 0f)
{
__result = true;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_CanEquipWhenUncharged_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "OnCooldownChanged")]
public class AbilityRechargeUI_OnCooldownChanged_Patch
{
private static void Postfix(AbilityRechargeUI __instance, float charge)
{
try
{
if (__instance.Ability is VoltaicGrenade)
{
((Component)__instance).gameObject.SetActive(true);
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_OnCooldownChanged_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "OnCooldownChanged")]
public class AbilityRechargeUI_OnCooldownChanged_Livewire_Patch
{
private static void Postfix(AbilityRechargeUI __instance, float charge)
{
try
{
if (SparrohPlugin.EnableLivewireFix.Value && ((object)__instance.Ability).GetType().Name == "VoltaicGrenade")
{
((Component)__instance).gameObject.SetActive(true);
if ((Object)(object)PlayerLook.Instance.GetRechargeUI(__instance.Ability) == (Object)null)
{
PlayerLook.Instance.AddRechargeUI(__instance);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_OnCooldownChanged_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "Setup")]
public class AbilityRechargeUI_Setup_Patch
{
private static void Postfix(AbilityRechargeUI __instance, IActivatedAbility ability, Vector2 position, AbilityRechargeUI prefab, int priority)
{
try
{
if (ability is VoltaicGrenade)
{
((Component)__instance).gameObject.SetActive(true);
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_Setup_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "Setup")]
public class AbilityRechargeUI_Setup_Livewire_Patch
{
private static void Postfix(AbilityRechargeUI __instance, IActivatedAbility ability, Vector2 position, AbilityRechargeUI prefab, int priority)
{
try
{
if (SparrohPlugin.EnableLivewireFix.Value && ((object)ability).GetType().Name == "VoltaicGrenade")
{
((Component)__instance).gameObject.SetActive(true);
if ((Object)(object)PlayerLook.Instance.GetRechargeUI(ability) == (Object)null)
{
PlayerLook.Instance.AddRechargeUI(__instance);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_Setup_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(Throwable), "DisableHUD")]
public class Throwable_DisableHUD_Livewire_Patch
{
private static void Postfix(Throwable __instance)
{
try
{
if (SparrohPlugin.EnableLivewireFix.Value && __instance is VoltaicGrenade)
{
AbilityRechargeUI rechargeUI = PlayerLook.Instance.GetRechargeUI((IActivatedAbility)(object)__instance);
if ((Object)(object)rechargeUI != (Object)null)
{
((Component)rechargeUI).gameObject.SetActive(true);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_DisableHUD_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[BepInPlugin("sparroh.unofficialpatch", "UnofficialPatch", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SparrohPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.unofficialpatch";
public const string PluginName = "UnofficialPatch";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Logger;
public static ConfigFile Config { get; private set; }
public static ConfigEntry<bool> EnableGlobblerFriendFireFix { get; private set; }
public static ConfigEntry<bool> EnableLivewireFix { get; private set; }
public static ConfigEntry<bool> EnablePressureCookerFix { get; private set; }
public static ConfigEntry<bool> EnablePrismDetailsFix { get; private set; }
public static ConfigEntry<bool> EnableCraniusDialogueFix { get; private set; }
public static ConfigEntry<bool> EnableDMLRBatteryFix { get; private set; }
public static ConfigEntry<bool> EnableElementalCocktailFix { get; private set; }
public static ConfigEntry<bool> EnableRoachardSleepFix { get; private set; }
public static ConfigEntry<bool> EnableSetDestinationFix { get; private set; }
public static ConfigEntry<bool> EnableStartupSuppression { get; private set; }
public static ConfigEntry<bool> EnableThrilloftheFightFix { get; private set; }
public static ConfigEntry<bool> EnableSelfDestructFix { get; private set; }
public static ConfigEntry<bool> EnableAutoSprintFix { get; private set; }
public static ConfigEntry<bool> EnableCyclerDestructionFix { get; private set; }
private void Awake()
{
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Expected O, but got Unknown
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Expected O, but got Unknown
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Config = ((BaseUnityPlugin)this).Config;
EnableGlobblerFriendFireFix = Config.Bind<bool>("Modules", "Enable Globbler Friend Fire Fix", true, "Enable/disable the Globbler friend fire fix module.");
EnableLivewireFix = Config.Bind<bool>("Modules", "Enable Livewire Fix", true, "Enable/disable the Livewire fix module.");
EnablePressureCookerFix = Config.Bind<bool>("Modules", "Enable Pressure Cooker Fix", true, "Enable/disable the Pressure Cooker fix module.");
GlobblerPatches.IsEnabled = EnablePressureCookerFix.Value;
EnablePrismDetailsFix = Config.Bind<bool>("Modules", "Enable Prism Details Fix", true, "Enable/disable the Prism Details fix module.");
EnableCraniusDialogueFix = Config.Bind<bool>("Modules", "Enable Cranius Dialogue Fix", true, "Enable/disable the Cranius Dialogue fix module.");
EnableDMLRBatteryFix = Config.Bind<bool>("Modules", "Enable DMLR Battery Fix", true, "Enable/disable the DMLR Battery fix module.");
EnableElementalCocktailFix = Config.Bind<bool>("Modules", "Enable Elemental Cocktail Fix", true, "Enable/disable the Elemental Cocktail fix module.");
EnableRoachardSleepFix = Config.Bind<bool>("Modules", "Enable Roachard Sleep Fix", true, "Enable/disable the Roachard Sleep fix module.");
EnableSetDestinationFix = Config.Bind<bool>("Modules", "Enable Set Destination Fix", true, "Enable/disable the Set Destination fix module.");
EnableStartupSuppression = Config.Bind<bool>("Modules", "Enable Startup Suppression", true, "Enable/disable the Startup Suppression module.");
EnableThrilloftheFightFix = Config.Bind<bool>("Modules", "Enable Thrill of the Fight Fix", true, "Enable/disable the Thrill of the Fight fix module.");
EnableSelfDestructFix = Config.Bind<bool>("Modules", "Enable Self Destruct Fix", true, "Enable/disable the Self Destruct fix module.");
EnableAutoSprintFix = Config.Bind<bool>("Modules", "Enable Auto Sprint Fix", true, "Enable/disable the Auto Sprint fix module.");
EnableCyclerDestructionFix = Config.Bind<bool>("Modules", "Enable Cycler Destruction Fix", true, "Enable/disable the Cycler Destruction fix module.");
if (EnableStartupSuppression.Value)
{
Debug.logger.logHandler = (ILogHandler)(object)new FilteredLogHandler(Debug.logger.logHandler);
}
Harmony val = new Harmony("sparroh.unofficialpatch");
val.PatchAll();
val.PatchAll(typeof(GlobblerPatches));
if (EnableRoachardSleepFix.Value)
{
MethodInfo methodInfo = AccessTools.Method(typeof(Roachard).GetNestedType("SleepState", BindingFlags.NonPublic), "OnEnter", (Type[])null, (Type[])null);
val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RoachardSleepFix).GetMethod("SleepState_OnEnter_Prefix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
if (EnableSetDestinationFix.Value)
{
MethodInfo methodInfo2 = AccessTools.Method(typeof(NavMeshAgent), "SetDestination", new Type[1] { typeof(Vector3) }, (Type[])null);
val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(SetDestinationFix).GetMethod("SetDestinationPrefix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
Logger.LogInfo((object)"UnofficialPatch loaded successfully.");
}
}
public static class GlobblerPatches
{
public static bool IsEnabled = true;
[HarmonyPatch(typeof(Globbler), "OverrideHoldReload")]
[HarmonyPrefix]
public static void OverrideHoldReload_Prefix(Globbler __instance, ref bool __result)
{
if (!IsEnabled)
{
return;
}
try
{
if (__instance.GlobblerData.chargeTimePerAmmo > 0f && ((Gun)__instance).WantsToFire)
{
__result = true;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OverrideHoldReload_Prefix: " + ex.Message + "\n" + ex.StackTrace));
}
}
[HarmonyPatch(typeof(Gun), "OnReloadPerformed")]
[HarmonyPrefix]
public static bool OnReloadPerformed_Prefix(Gun __instance, object context)
{
if (!IsEnabled)
{
return true;
}
try
{
Globbler val = (Globbler)(object)((__instance is Globbler) ? __instance : null);
if (val != null && val.GlobblerData.chargeTimePerAmmo > 0f && ((Gun)val).WantsToFire)
{
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OnReloadPerformed_Prefix: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
[HarmonyPatch(typeof(Globbler), "OnFire")]
[HarmonyPrefix]
public static bool OnFire_Prefix(Globbler __instance, int numBullets)
{
if (!IsEnabled)
{
return true;
}
try
{
Traverse.Create((object)__instance).Field<float>("globChargeTimer").Value = 0f;
Traverse.Create((object)__instance).Field<int>("globChargeAmmo").Value = 0;
if (__instance.GlobblerData.chargeTimePerAmmo <= 0f)
{
return true;
}
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OnFire_Prefix: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(Upgrade), "GetStatList")]
public static class Upgrade_GetStatList_Patch
{
private static bool ShowExtraInfo()
{
Type type = Type.GetType("Pigeon.HoverInfo, Assembly-CSharp");
if (type != null)
{
MethodInfo method = type.GetMethod("ShowExtraInfo", BindingFlags.Static | BindingFlags.Public);
if (method != null)
{
return (bool)method.Invoke(null, null);
}
}
return false;
}
[HarmonyPostfix]
public static void Postfix(ref string __result, Upgrade __instance, int seed, UpgradeInstance instance)
{
//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)
if (!SparrohPlugin.EnablePrismDetailsFix.Value)
{
return;
}
try
{
if (__result == null)
{
return;
}
UpgradePropertyList properties = __instance.Properties;
if (!((UpgradePropertyList)(ref properties)).HasProperties)
{
return;
}
bool flag = false;
foreach (UpgradeProperty item in (UpgradePropertyList)(ref properties))
{
if (item is UpgradeProperty_MiniCannon_Prism)
{
flag = true;
break;
}
}
if (flag && ShowExtraInfo())
{
string[] array = __result.Split(new char[1] { '\n' });
if (array.Length != 0 && array[0].Contains("Efficiency"))
{
array[0] += " [50% - 150%]";
__result = string.Join("\n", array);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[PrismDetailsFix] Error in Upgrade_GetStatList_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
public class RoachardSleepFix
{
[CompilerGenerated]
private sealed class <SetParentDelayed>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Transform child;
public Transform parent;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SetParentDelayed>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
child.SetParent(parent, false);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static bool SleepState_OnEnter_Prefix(object __instance, AI ai)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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)
if (!SparrohPlugin.EnableRoachardSleepFix.Value)
{
return true;
}
try
{
Traverse val = Traverse.Create(__instance);
BurstEffect val2 = BurstEffect.InitializeObjectPosition(val.Field<BurstEffect>("SleepEffectPrefab").Value, default(Vector3), Quaternion.identity);
val.Field<BurstEffect>("sleepEffect").Value = val2;
object value = val.Field("SnoringSound").GetValue();
value.GetType().GetMethod("Post", new Type[1] { typeof(GameObject) }).Invoke(value, new object[1] { ((Component)ai).gameObject });
Transform value2 = val.Field<Transform>("Head").Value;
((MonoBehaviour)ai).StartCoroutine(SetParentDelayed(((Component)val2).transform, value2));
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[RoachardSleepFix] Error in SleepState_OnEnter_Prefix: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
[IteratorStateMachine(typeof(<SetParentDelayed>d__1))]
private static IEnumerator SetParentDelayed(Transform child, Transform parent)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SetParentDelayed>d__1(0)
{
child = child,
parent = parent
};
}
}
[HarmonyPatch(typeof(EnemyCore), "RushPlayerWhenTooWeak")]
public class EnemyCore_RushPlayerWhenTooWeak_Patch
{
[HarmonyPrefix]
public static bool Prefix()
{
if (!SparrohPlugin.EnableSelfDestructFix.Value)
{
return true;
}
try
{
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[SelfDestructFix] Error in EnemyCore_RushPlayerWhenTooWeak_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
public class SetDestinationFix
{
public static bool SetDestinationPrefix(NavMeshAgent __instance, Vector3 target)
{
try
{
if (!((Behaviour)__instance).isActiveAndEnabled || !__instance.isOnNavMesh)
{
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[SetDestinationFix] Error in SetDestinationPrefix: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
public class FilteredLogHandler : ILogHandler
{
private ILogHandler originalHandler;
public FilteredLogHandler(ILogHandler original)
{
originalHandler = original;
}
public void LogFormat(LogType logType, Object context, string format, params object[] args)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
string message = string.Format(format, args);
if (!ShouldSuppress(message))
{
originalHandler.LogFormat(logType, context, format, args);
}
}
public void LogException(Exception exception, Object context)
{
string message = exception?.ToString() ?? "";
if (!ShouldSuppress(message))
{
originalHandler.LogException(exception, context);
}
}
private bool ShouldSuppress(string message)
{
if (!message.Contains("missing") && !message.Contains("Missing") && !message.Contains("Convex Mesh") && !message.Contains("NetworkPrefab") && !message.Contains("Removing invalid prefabs") && !message.Contains("Post Event failed") && !message.Contains("render texture"))
{
return message.Contains("Event System");
}
return true;
}
}
[HarmonyPatch(typeof(NetworkManager), "Awake")]
public class NetworkManager_Awake_Patch
{
[HarmonyPostfix]
public static void Postfix(NetworkManager __instance)
{
if (!SparrohPlugin.EnableStartupSuppression.Value)
{
return;
}
try
{
foreach (NetworkPrefab prefab in __instance.NetworkConfig.Prefabs.Prefabs)
{
if ((Object)(object)prefab.Prefab != (Object)null && !Object.op_Implicit((Object)(object)prefab.Prefab.GetComponent<NetworkObject>()))
{
prefab.Prefab.AddComponent<NetworkObject>();
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[StartupSuppression] Error in NetworkManager_Awake_Patch: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
[HarmonyPatch(typeof(Character), "GetUtilAbility")]
public class Character_GetUtilAbility_Patch
{
[HarmonyPrefix]
public static bool Prefix(Character __instance, ref IActivatedAbility __result)
{
if (!SparrohPlugin.EnableThrilloftheFightFix.Value)
{
return true;
}
try
{
if (__instance.Index == 3)
{
IGear obj = Player.LocalPlayer.Gear[2];
Wingsuit val = (Wingsuit)(object)((obj is Wingsuit) ? obj : null);
if (val != null)
{
__result = (IActivatedAbility)(object)val.RocketSalvoCooldown;
}
else
{
IGear val2 = Player.LocalPlayer.Gear[2];
__result = (IActivatedAbility)(object)((val2 is IActivatedAbility) ? val2 : null);
}
}
else
{
IGear val3 = Player.LocalPlayer.Gear[2];
__result = (IActivatedAbility)(object)((val3 is IActivatedAbility) ? val3 : null);
}
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[ThrilloftheFightFix] Error in Character_GetUtilAbility_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(Character), "GetMovementAbility")]
public class Character_GetMovementAbility_Patch
{
[HarmonyPrefix]
public static bool Prefix(Character __instance, ref IActivatedAbility __result)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if (!SparrohPlugin.EnableThrilloftheFightFix.Value)
{
return true;
}
try
{
switch (__instance.Index)
{
case 0:
__result = (IActivatedAbility)(object)((AirDashUpgrade)__instance.DefaultUpgrade).Cooldown;
break;
case 1:
__result = (IActivatedAbility)(object)((NoseDiveUpgrade)__instance.DefaultUpgrade).Cooldown;
break;
case 2:
__result = (IActivatedAbility)(object)((JetpackUpgrade)__instance.DefaultUpgrade).Cooldown;
break;
case 3:
{
IGear val = Player.LocalPlayer.Gear[2];
__result = (IActivatedAbility)(object)((val is IActivatedAbility) ? val : null);
break;
}
default:
__result = null;
break;
}
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[ThrilloftheFightFix] Error in Character_GetMovementAbility_Patch: " + ex.Message + "\n" + ex.StackTrace));
return true;
}
}
}
[HarmonyPatch(typeof(WideGun), "GetMostChargedAbility")]
public class WideGun_GetMostChargedAbility_Patch
{
[HarmonyPrefix]
public static bool Prefix(WideGun __instance, out IActivatedAbility leastCharged, ref IActivatedAbility __result)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
if (!SparrohPlugin.EnableThrilloftheFightFix.Value)
{
leastCharged = null;
return true;
}
try
{
object? value = typeof(WideGun).GetField("player", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
object? obj = ((value is Player) ? value : null);
IActivatedAbility val = (IActivatedAbility)((Player)obj).ThrowableGear;
float num = val.CooldownData.charge;
if ((double)num >= 1.0)
{
num = 0f;
}
IActivatedAbility utilAbility = ((Player)obj).Character.GetUtilAbility();
float num2 = float.MaxValue;
if (utilAbility != null)
{
num2 = utilAbility.CooldownData.charge;
if ((double)num2 >= 1.0)
{
num2 = 0f;
}
}
IActivatedAbility movementAbility = ((Player)obj).Character.GetMovementAbility();
float num3 = movementAbility.CooldownData.charge;
if ((double)num3 >= 1.0)
{
num3 = 0f;
}
leastCharged = ((!((double)num >= (double)num2)) ? (((double)num < (double)num3) ? val : movementAbility) : (((double)num2 < (double)num3) ? utilAbility : movementAbility));
__result = ((!((double)num <= (double)num2)) ? (((double)num <= (double)num3) ? movementAbility : val) : (((double)num2 <= (double)num3) ? movementAbility : utilAbility));
return false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("[ThrilloftheFightFix] Error in WideGun_GetMostChargedAbility_Patch: " + ex.Message + "\n" + ex.StackTrace));
leastCharged = null;
return true;
}
}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public const string AssemblySemFileVer = "0.0.1.0";
public const string AssemblySemVer = "0.0.1.0";
public const string BranchName = "master";
public const string BuildMetaData = "";
public const string CommitDate = "2025-12-26";
public const string CommitsSinceVersionSource = "7";
public const string EscapedBranchName = "master";
public const string FullBuildMetaData = "Branch.master.Sha.5723c953a74d2c67755caace0ea16c9a3c6be082";
public const string FullSemVer = "0.0.1-7";
public const string InformationalVersion = "0.0.1-7+Branch.master.Sha.5723c953a74d2c67755caace0ea16c9a3c6be082";
public const string Major = "0";
public const string MajorMinorPatch = "0.0.1";
public const string Minor = "0";
public const string Patch = "1";
public const string PreReleaseLabel = "";
public const string PreReleaseLabelWithDash = "";
public const string PreReleaseNumber = "7";
public const string PreReleaseTag = "7";
public const string PreReleaseTagWithDash = "-7";
public const string SemVer = "0.0.1-7";
public const string Sha = "5723c953a74d2c67755caace0ea16c9a3c6be082";
public const string ShortSha = "5723c95";
public const string UncommittedChanges = "10";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55007";
}
namespace UnofficialPatch
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "UnofficialPatch";
public const string PLUGIN_NAME = "UnofficialPatch";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}