using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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.Movement;
using Unity.Netcode;
using UnityEngine;
[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("MycopunkRebalance")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.6+d2180b337983bf65f74280844d433f93f0695d29")]
[assembly: AssemblyProduct("MycopunkRebalance")]
[assembly: AssemblyTitle("MycopunkRebalance")]
[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(FlamethrowerArmTip), "UpdateMaxLength")]
public class FlamethrowerArmTipPatch
{
private static void Postfix(FlamethrowerArmTip __instance, ref Vector3 position, ref Quaternion rotation, ref float __result)
{
if ((Object)(object)((EnemyPart)__instance).Brain != (Object)null && ((EnemyPart)__instance).Brain.EnemyClass.customSpawner is AmalgamationSpawner)
{
__result = Mathf.Min(__result, 12f);
}
}
}
[HarmonyPatch(typeof(SwarmGun), "OnActiveUpdate")]
public class SwarmGun_OnActiveUpdate_Patch
{
private static bool Prefix(SwarmGun __instance, float ___lastAutoRegenAmmoTime)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
float time = Time.time;
Data swarmData = __instance.SwarmData;
if (swarmData.autoAmmoRegenInterval > 0f && time - ((Gun)__instance).LastFireTime >= 1f && __instance.HoveringBullets.Count > 0 && time - ___lastAutoRegenAmmoTime > swarmData.autoAmmoRegenInterval)
{
((Gun)__instance).StoredAmmo = Mathf.Min(((Gun)__instance).StoredAmmo + 1f, (float)((Gun)__instance).GunData.ammoCapacity);
typeof(SwarmGun).GetField("lastAutoRegenAmmoTime", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, time);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(AutocannonArmTip), "OnUpdate")]
public class AutocannonArmTipPatch
{
private static float startTime = -1f;
private static void Prefix(AutocannonArmTip __instance, ref Vector3 position, ref Quaternion rotation)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
Traverse val = Traverse.Create((object)__instance);
bool value = val.Field("isFiring").GetValue<bool>();
if (value && startTime < 0f)
{
startTime = Time.time;
}
if (!value)
{
startTime = -1f;
}
if (startTime >= 0f)
{
float num = Time.time - startTime;
float num2 = Mathf.Max(1f, 6f - num);
Vector2 value2 = val.Field("bulletSpread").GetValue<Vector2>();
val.Field("bulletSpread").SetValue((object)(value2 * num2));
}
}
private static void Postfix(AutocannonArmTip __instance, ref Vector3 position, ref Quaternion rotation)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0062: Unknown result type (might be due to invalid IL or missing references)
if (!(startTime < 0f))
{
Traverse val = Traverse.Create((object)__instance);
if (val.Field("isFiring").GetValue<bool>())
{
float num = Time.time - startTime;
float num2 = Mathf.Max(1f, 6f - num);
Vector2 value = val.Field("bulletSpread").GetValue<Vector2>();
val.Field("bulletSpread").SetValue((object)(value / num2));
}
}
}
}
public static class CoreProtectionRework
{
public static Dictionary<EnemyShell, int> ShellID = new Dictionary<EnemyShell, int>();
public static Dictionary<int, int> LayerIndex = new Dictionary<int, int>();
public static void SetShellIDs(EnemyPart part)
{
try
{
if (((part != null) ? part.ChildComponents : null) == null)
{
return;
}
foreach (IEnemyComponent childComponent in part.ChildComponents)
{
EnemyShell val = (EnemyShell)(object)((childComponent is EnemyShell) ? childComponent : null);
if (val != null && (Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null)
{
string name = ((Object)((Component)val).gameObject).name;
int num = 0;
if (name.Contains("Large"))
{
num = 1;
}
else if (name.Contains("Inner"))
{
num = 2;
}
else if (name.Contains("L1"))
{
num = 1;
}
else if (name.Contains("L2"))
{
num = 2;
}
else if (name.Contains("L3"))
{
num = 3;
}
int value;
int num2 = (LayerIndex.TryGetValue(num, out value) ? value : 0);
int value2 = num * 100 + num2;
ShellID[val] = value2;
LayerIndex[num] = num2 + 1;
}
EnemyPart val2 = (EnemyPart)(object)((childComponent is EnemyPart) ? childComponent : null);
if (val2 != null)
{
SetShellIDs(val2);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in SetShellIDs: " + ex.Message));
}
}
public static bool HasShellChildren(EnemyPart part)
{
try
{
if (((part != null) ? part.ChildComponents : null) == null)
{
return false;
}
foreach (IEnemyComponent childComponent in part.ChildComponents)
{
if (childComponent != null && childComponent.IsAlive && childComponent is EnemyShell)
{
return true;
}
EnemyPart val = (EnemyPart)(object)((childComponent is EnemyPart) ? childComponent : null);
if (val != null && HasShellChildren(val))
{
return true;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in HasShellChildren: " + ex.Message));
}
return false;
}
public static int CountAliveMetalShells(EnemyPart part)
{
try
{
int num = 0;
if (((part != null) ? part.ChildComponents : null) == null)
{
return num;
}
foreach (IEnemyComponent childComponent in part.ChildComponents)
{
if (childComponent != null && childComponent.IsAlive)
{
EnemyShell val = (EnemyShell)(object)((childComponent is EnemyShell) ? childComponent : null);
if (val != null && (Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null)
{
string name = ((Object)((Component)val).gameObject).name;
if (name.Contains("Large") || name.Contains("Inner") || name.Contains("L1") || name.Contains("L2") || name.Contains("L3") || name.Contains("Shell"))
{
num++;
}
}
}
EnemyPart val2 = (EnemyPart)(object)((childComponent is EnemyPart) ? childComponent : null);
if (val2 != null)
{
num += CountAliveMetalShells(val2);
}
}
return num;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in CountAliveMetalShells: " + ex.Message));
return 0;
}
}
public static int CountRemainingMetal(EnemyPart part, string layerString)
{
try
{
if (string.IsNullOrEmpty(layerString) || ((part != null) ? part.ChildComponents : null) == null)
{
return 0;
}
int num = 0;
foreach (IEnemyComponent childComponent in part.ChildComponents)
{
EnemyShell val = (EnemyShell)(object)((childComponent is EnemyShell) ? childComponent : null);
if (val != null && (Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null && ((Object)((Component)val).gameObject).name.Contains(layerString))
{
num++;
}
EnemyPart val2 = (EnemyPart)(object)((childComponent is EnemyPart) ? childComponent : null);
if (val2 != null)
{
num += CountRemainingMetal(val2, layerString);
}
}
return num;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in CountRemainingMetal: " + ex.Message));
return 0;
}
}
public static bool HasLayer(EnemyPart part, string check)
{
try
{
if (((part != null) ? part.ChildComponents : null) == null || string.IsNullOrEmpty(check))
{
return false;
}
foreach (IEnemyComponent childComponent in part.ChildComponents)
{
EnemyShell val = (EnemyShell)(object)((childComponent is EnemyShell) ? childComponent : null);
if (val != null && (Object)(object)((val != null) ? ((Component)val).gameObject : null) != (Object)null && ((Object)((Component)val).gameObject).name.Contains(check))
{
return true;
}
EnemyPart val2 = (EnemyPart)(object)((childComponent is EnemyPart) ? childComponent : null);
if (val2 != null && HasLayer(val2, check))
{
return true;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in HasLayer: " + ex.Message));
}
return false;
}
}
public static class CoreProtectionPatches
{
[CompilerGenerated]
private sealed class <DelayedCheckCoreDestruction>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public EnemyPart core;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedCheckCoreDestruction>d__2(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;
try
{
EnemyPart obj = core;
EnemyCore val = (EnemyCore)(object)((obj is EnemyCore) ? obj : null);
if (val != null && !CoreProtectionRework.HasShellChildren(core))
{
((EnemyPart)val).Kill((DamageFlags)0);
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in DelayedCheckCoreDestruction: " + ex.Message));
}
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();
}
}
[HarmonyPatch(typeof(EnemyManager), "AddChildren", new Type[]
{
typeof(EnemyClass),
typeof(EnemyPart),
typeof(float)
})]
[HarmonyPostfix]
private static void PostfixAddChildren(EnemyClass enemyClass, EnemyPart part, float healthMultiplier)
{
try
{
if (part is EnemyCore)
{
CoreProtectionRework.LayerIndex.Clear();
CoreProtectionRework.SetShellIDs(part);
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in PostfixAddChildren: " + ex.Message));
}
}
[HarmonyPatch(typeof(EnemyShell), "OnKill_Server", new Type[]
{
typeof(IDamageSource),
typeof(DamageFlags)
})]
[HarmonyPrefix]
private static void PrefixOnKill_Server(EnemyShell __instance, IDamageSource source, DamageFlags flags)
{
try
{
IEnemyComponent obj = ((__instance != null) ? ((EnemyPart)__instance).Parent : null);
EnemyPart val = (EnemyPart)(object)((obj is EnemyPart) ? obj : null);
if (val == null)
{
return;
}
EnemyCore val2 = (EnemyCore)(object)((val is EnemyCore) ? val : null);
if (val2 != null)
{
if (CoreProtectionRework.CountAliveMetalShells((EnemyPart)(object)val2) - 1 >= 3)
{
((MonoBehaviour)GameManager.Instance).StartCoroutine(DelayedCheckCoreDestruction(val, source));
}
else if (!CoreProtectionRework.HasShellChildren((EnemyPart)(object)val2))
{
((EnemyPart)val2).Kill((DamageFlags)0);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in PrefixOnKill_Server: " + ex.Message));
}
}
[IteratorStateMachine(typeof(<DelayedCheckCoreDestruction>d__2))]
private static IEnumerator DelayedCheckCoreDestruction(EnemyPart core, IDamageSource source)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DelayedCheckCoreDestruction>d__2(0)
{
core = core
};
}
[HarmonyPatch(typeof(EnemyPart), "Damage", new Type[]
{
typeof(DamageData),
typeof(IDamageSource),
typeof(Vector3)
})]
[HarmonyPrefix]
private static bool PrefixDamage(EnemyPart __instance, ref DamageData data, ref bool __result)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Invalid comparison between Unknown and I4
try
{
bool num = CoreProtectionRework.HasLayer(__instance, "L3");
bool flag = CoreProtectionRework.HasLayer(__instance, "L2") || CoreProtectionRework.HasLayer(__instance, "Inner");
int num2 = (num ? 3 : ((!flag) ? 1 : 2));
string layerString = num2 switch
{
1 => "Large",
2 => "Inner",
3 => "L3",
_ => "",
};
bool flag2 = false;
if (__instance is EnemyCore)
{
int num3 = CoreProtectionRework.CountRemainingMetal(__instance, layerString);
flag2 = num2 != 1 && num3 > 0;
}
else
{
EnemyShell val = (EnemyShell)(object)((__instance is EnemyShell) ? __instance : null);
if (val != null && CoreProtectionRework.ShellID.TryGetValue(val, out var value))
{
flag2 = CoreProtectionRework.CountRemainingMetal(__instance, (value / 100) switch
{
2 => "Large",
3 => "Inner",
_ => "",
}) > 0;
}
}
if (flag2 && (int)data.effect != -1)
{
__result = false;
return false;
}
if (!flag2 && (int)data.effect == -1)
{
int num4 = CoreProtectionRework.CountRemainingMetal(__instance, "Large");
int num5 = CoreProtectionRework.CountRemainingMetal(__instance, "Inner");
int num6 = CoreProtectionRework.CountRemainingMetal(__instance, "L3");
float num7 = 1f;
if (__instance is EnemyCore)
{
num7 = ((num6 == 3) ? 0.25f : ((num6 == 2 && num5 == 3) ? 0.5f : ((num6 == 2 && num5 == 2 && num4 == 3) ? 0.75f : 1f)));
}
else
{
EnemyShell val2 = (EnemyShell)(object)((__instance is EnemyShell) ? __instance : null);
if (val2 != null && CoreProtectionRework.ShellID.TryGetValue(val2, out var value2))
{
switch (value2 / 100)
{
case 3:
num7 = 1f;
break;
case 2:
num7 = ((num6 == 3) ? 0.75f : 1f);
break;
case 1:
num7 = ((num6 == 3) ? 0.5f : ((num5 == 3) ? 0.75f : 1f));
break;
}
}
}
data.damage *= num7;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in PrefixDamage: " + ex.Message));
}
return true;
}
}
public static class DefaultCloudSkip
{
public static ConfigEntry<bool> enableCloudSkip;
}
internal static class DefaultCloudSkipPatches
{
private static readonly FieldInfo airJumpsField = AccessTools.Field(typeof(Player), "airJumps");
private static readonly FieldInfo airJumpUpSpeedField = AccessTools.Field(typeof(Player), "airJumpUpSpeed");
[HarmonyPatch(typeof(Player), "Movement")]
[HarmonyPrefix]
public static bool MovementPrefix(Player __instance)
{
if (!((NetworkBehaviour)__instance).IsLocalPlayer)
{
return true;
}
if (!DefaultCloudSkip.enableCloudSkip.Value)
{
return true;
}
airJumpsField.SetValue(__instance, 1);
airJumpUpSpeedField.SetValue(__instance, 18.3f);
return true;
}
}
public static class DefaultMagboots
{
public static ConfigEntry<bool> enableWallrunning;
public static void Init(ConfigFile config)
{
enableWallrunning = config.Bind<bool>("Movement Modifications", "Wallrunning", true, "Enables wallrunning ability.");
}
public static void SetupWallrunningPatch(Harmony harmony)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(Player), "EnableWallrun");
if (!(methodInfo == null))
{
HarmonyMethod val = new HarmonyMethod(typeof(DefaultMagboots), "EnableWallrunGetPrefix", (Type[])null);
harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public static bool EnableWallrunGetPrefix(Player __instance, ref bool __result)
{
if (!((NetworkBehaviour)__instance).IsLocalPlayer)
{
return true;
}
if (!enableWallrunning.Value)
{
return true;
}
__result = true;
return false;
}
}
public static class DefaultMigration
{
public static ConfigEntry<bool> enableCanFireWhileSprinting;
public static ConfigEntry<bool> enableCanFireWhileSliding;
public static ConfigEntry<bool> enableSprintToFireFix;
public static void Init(ConfigFile config)
{
enableCanFireWhileSprinting = config.Bind<bool>("Movement Modifications", "CanFireWhileSprinting", true, "Allows firing weapons while sprinting.");
enableCanFireWhileSliding = config.Bind<bool>("Movement Modifications", "CanFireWhileSliding", true, "Allows firing weapons while sliding.");
enableSprintToFireFix = config.Bind<bool>("Movement Modifications", "SprintToFireFix", true, "Enables the Sprint-to-Fire fix that allows immediate firing while sprinting and proper sprint resume behavior.");
}
public static void ApplyFireConstraints(ref GunData gunData)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (enableCanFireWhileSprinting.Value)
{
gunData.fireConstraints.canFireWhileSprinting = (ActionFireMode)1;
}
if (enableCanFireWhileSliding.Value)
{
gunData.fireConstraints.canFireWhileSliding = (ActionFireMode)1;
}
}
}
public static class DefaultStructuralSurvey
{
public static ConfigEntry<bool> enableStructuralSurvey;
}
[HarmonyPatch]
public static class HighlightLowHealthPatch
{
[HarmonyPatch(typeof(EnemyPart), "get_AutoHighlight")]
[HarmonyPrefix]
public static bool AutoHighlightPrefix(EnemyPart __instance, ref bool __result)
{
if (DefaultStructuralSurvey.enableStructuralSurvey.Value && (double)__instance.Health < (double)__instance.MaxHealth * 0.3799999952316284)
{
__result = true;
return false;
}
return true;
}
}
public static class EnhancedAiming
{
public static ConfigEntry<bool> enableCanAimWhileSliding;
public static ConfigEntry<bool> enableCanAimWhileReloading;
public static ConfigEntry<bool> enableCanAimWhileSprinting;
private static readonly FieldInfo lockSprintingField = AccessTools.Field(typeof(Gun), "lockSprinting");
public static void Init(ConfigFile config)
{
enableCanAimWhileSliding = config.Bind<bool>("Movement Modifications", "CanAimWhileSliding", true, "Allows aiming weapons while sliding.");
enableCanAimWhileReloading = config.Bind<bool>("Movement Modifications", "CanAimWhileReloading", true, "Allows aiming weapons while reloading.");
enableCanAimWhileSprinting = config.Bind<bool>("Movement Modifications", "CanAimWhileSprinting", true, "Allows aiming weapons while sprinting.");
}
public static void ApplyAimingConstraints(ref GunData gunData, Gun gunPrefab, ModGunData modGunData)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
gunData.fireConstraints.canAimWhileSliding = (ActionFireMode)enableCanAimWhileSliding.Value;
gunData.fireConstraints.canAimWhileReloading = enableCanAimWhileReloading.Value;
modGunData.CanAimWhileSprinting = enableCanAimWhileSprinting.Value;
bool flag = !enableCanAimWhileSprinting.Value;
lockSprintingField.SetValue(gunPrefab, flag);
}
public static void SetupAimingPatches(Harmony harmony)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(Gun), "OnStartAim", (Type[])null, (Type[])null);
if (methodInfo == null)
{
SparrohPlugin.Logger.LogError((object)"Could not find Gun.OnStartAim method!");
return;
}
HarmonyMethod val = new HarmonyMethod(typeof(EnhancedAiming), "OnStartAimPrefix", (Type[])null);
HarmonyMethod val2 = new HarmonyMethod(typeof(EnhancedAiming), "OnStartAimPostfix", (Type[])null);
harmony.Patch((MethodBase)methodInfo, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(Gun), "CanAim", (Type[])null, (Type[])null);
if (methodInfo2 == null)
{
SparrohPlugin.Logger.LogError((object)"Could not find Gun.CanAim method!");
return;
}
HarmonyMethod val3 = new HarmonyMethod(typeof(EnhancedAiming), "CanAimPrefix", (Type[])null);
harmony.Patch((MethodBase)methodInfo2, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in SetupAimingPatches: " + ex.Message));
}
}
public static bool OnStartAimPrefix(Gun __instance)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
try
{
ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
if ((Object)(object)component != (Object)null && component.CanAimWhileSprinting)
{
FieldInfo fieldInfo = AccessTools.Field(typeof(Gun), "player");
if (fieldInfo != null)
{
Player val = (Player)fieldInfo.GetValue(__instance);
if ((Object)(object)val != (Object)null)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "IsSprinting");
if (propertyInfo != null)
{
component.WasSprinting = (bool)propertyInfo.GetValue(val);
}
}
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in OnStartAimPrefix: " + ex.Message));
}
return true;
}
public static void OnStartAimPostfix(Gun __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
try
{
ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
if (!((Object)(object)component != (Object)null) || !component.CanAimWhileSprinting || !component.WasSprinting)
{
return;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(Gun), "player");
if (fieldInfo != null)
{
Player val = (Player)fieldInfo.GetValue(__instance);
if ((Object)(object)val != (Object)null)
{
MethodInfo methodInfo = AccessTools.Method(typeof(Player), "ResumeSprint", (Type[])null, (Type[])null);
if (methodInfo != null)
{
methodInfo.Invoke(val, null);
}
}
}
component.WasSprinting = false;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in OnStartAimPostfix: " + ex.Message));
}
}
public static bool CanAimPrefix(Gun __instance, ref bool __result)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
try
{
ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
if ((Object)(object)component != (Object)null && component.CanAimWhileSprinting)
{
FieldInfo fieldInfo = AccessTools.Field(typeof(Gun), "player");
if (fieldInfo != null)
{
Player val = (Player)fieldInfo.GetValue(__instance);
if ((Object)(object)val != (Object)null)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(Player), "IsSprinting");
if (propertyInfo != null && (bool)propertyInfo.GetValue(val))
{
FieldInfo fieldInfo2 = AccessTools.Field(typeof(Gun), "isAimInputHeld");
if (fieldInfo2 != null && (bool)fieldInfo2.GetValue(__instance))
{
__result = true;
return false;
}
}
}
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in CanAimPrefix: " + ex.Message));
}
return true;
}
}
public class ModGunData : MonoBehaviour
{
public bool CanAimWhileSprinting { get; set; }
public bool WasSprinting { get; set; }
public bool SprintingLockedBySprintToFire { get; set; }
public bool PreviousFireInputHeld { get; set; }
}
public static class EnhancedStrafing
{
public static ConfigEntry<bool> enableStrafing;
public static ConfigEntry<bool> enableWingsuitStrafing;
public static void Init(ConfigFile config)
{
enableStrafing = config.Bind<bool>("Movement Modifications", "Strafing", true, "Enables improved strafing speed.");
enableWingsuitStrafing = config.Bind<bool>("Movement Modifications", "WingsuitStrafing", true, "Enables strafing while flying with wingsuit.");
}
public static void SetupStrafingPatches(Harmony harmony)
{
harmony.PatchAll(typeof(StrafingSpeedPatch));
harmony.PatchAll(typeof(WingsuitStrafingPatch));
}
}
[HarmonyPatch]
public static class WingsuitStrafingPatch
{
[HarmonyPatch(typeof(Wingsuit), "OnJumpPressed")]
[HarmonyPostfix]
public static void OnJumpPressedPostfix(Wingsuit __instance)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: 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_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
if (!EnhancedStrafing.enableWingsuitStrafing.Value)
{
return;
}
FieldInfo field = ((object)__instance).GetType().GetField("wingsuitData", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
{
return;
}
object value = field.GetValue(__instance);
if (value == null)
{
return;
}
FieldInfo field2 = value.GetType().GetField("lockFlyDirection", BindingFlags.Instance | BindingFlags.Public);
if (field2 == null || !(bool)field2.GetValue(value))
{
return;
}
FieldInfo field3 = ((object)__instance).GetType().GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);
if (field3 == null)
{
return;
}
object value2 = field3.GetValue(__instance);
if (value2 == null)
{
return;
}
Vector2 val = PlayerInput.MoveInput();
if (((Vector2)(ref val)).magnitude < 0.1f)
{
return;
}
FieldInfo field4 = ((object)__instance).GetType().GetField("isFlying", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(field4 != null) || !(bool)field4.GetValue(__instance))
{
return;
}
Vector3 val2 = new Vector3(val.x, val.y, 0f);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
FieldInfo field5 = value.GetType().GetField("flySpeed", BindingFlags.Instance | BindingFlags.Public);
if (field5 == null)
{
return;
}
float num = (float)field5.GetValue(value);
float num2 = Mathf.Abs(normalized.x) * num * 0.5f;
if (num2 > 0f)
{
Vector3 val3 = ((Component)__instance).transform.right * (float)((normalized.x > 0f) ? 1 : (-1)) * num2;
MethodInfo method = value2.GetType().GetMethod("AddForce", new Type[1] { typeof(Vector3) });
if (method != null)
{
method.Invoke(value2, new object[1] { val3 });
}
}
}
[HarmonyPatch(typeof(Wingsuit), "FixedUpdate")]
[HarmonyPostfix]
public static void FixedUpdatePostfix(Wingsuit __instance)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
if (!EnhancedStrafing.enableWingsuitStrafing.Value)
{
return;
}
FieldInfo field = ((object)__instance).GetType().GetField("isFlying", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || !(bool)field.GetValue(__instance))
{
return;
}
Vector2 val = PlayerInput.MoveInput();
if (((Vector2)(ref val)).magnitude < 0.01f)
{
return;
}
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(val.x, val.y, 0f);
float magnitude = ((Vector3)(ref val2)).magnitude;
if (magnitude > 0f)
{
val2 /= magnitude;
}
FieldInfo field2 = ((object)__instance).GetType().GetField("wingsuitData", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 == null)
{
return;
}
object value = field2.GetValue(__instance);
if (value == null)
{
return;
}
FieldInfo field3 = value.GetType().GetField("flySpeed", BindingFlags.Instance | BindingFlags.Public);
FieldInfo field4 = value.GetType().GetField("flySpeedCurve", BindingFlags.Instance | BindingFlags.Public);
FieldInfo field5 = value.GetType().GetField("flySpeedCurveDuration", BindingFlags.Instance | BindingFlags.Public);
if (field3 == null || field4 == null)
{
return;
}
float num = (float)field3.GetValue(value);
object? value2 = field4.GetValue(value);
AnimationCurve val3 = (AnimationCurve)((value2 is AnimationCurve) ? value2 : null);
float num2 = ((field5 != null) ? ((float)field5.GetValue(value)) : 1f);
FieldInfo field6 = ((object)__instance).GetType().GetField("flyStartTime", BindingFlags.Instance | BindingFlags.NonPublic);
if (field6 == null)
{
return;
}
float num3 = (float)field6.GetValue(__instance);
float num4 = Mathf.Min((Time.time - num3) / num2, 1f);
float num5 = val3.Evaluate(num4);
FieldInfo field7 = ((object)__instance).GetType().GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);
if (field7 == null)
{
return;
}
object value3 = field7.GetValue(__instance);
if (value3 == null)
{
return;
}
float x = val2.x;
if (Mathf.Abs(x) > 0.1f)
{
float num6 = num * num5 * 2f;
Vector3 val4 = ((Component)__instance).transform.right * x * num6;
MethodInfo method = value3.GetType().GetMethod("AddForce", new Type[1] { typeof(Vector3) });
if (method != null)
{
method.Invoke(value3, new object[1] { val4 });
}
}
}
}
[HarmonyPatch]
public static class StrafingSpeedPatch
{
[HarmonyTargetMethod]
public static MethodBase TargetMethod()
{
Type type = Type.GetType("Pigeon.Movement.Player, Assembly-CSharp");
if (type == null)
{
return null;
}
MethodInfo method = type.GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null)
{
return method;
}
MethodInfo method2 = type.GetMethod("Start", BindingFlags.Instance | BindingFlags.NonPublic);
if (method2 != null)
{
return method2;
}
return null;
}
[HarmonyPostfix]
public static void Postfix(object __instance)
{
if (EnhancedStrafing.enableStrafing.Value)
{
Type type = __instance.GetType();
FieldInfo field = type.GetField("strafeSpeedMultiplier", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = type.GetField("strafeSpeedMultiplierWhileMoving", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(__instance, 1f);
}
if (field2 != null)
{
field2.SetValue(__instance, 1f);
}
}
}
}
[BepInPlugin("sparroh.mycopunkrebalance", "MycopunkRebalance", "1.1.0")]
public class SparrohPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.mycopunkrebalance";
public const string PluginName = "MycopunkRebalance";
public const string PluginVersion = "1.1.0";
internal static ManualLogSource Logger;
private Harmony harmony;
private void Awake()
{
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
try
{
DefaultMigration.Init(((BaseUnityPlugin)this).Config);
EnhancedAiming.Init(((BaseUnityPlugin)this).Config);
DefaultMagboots.Init(((BaseUnityPlugin)this).Config);
EnhancedStrafing.Init(((BaseUnityPlugin)this).Config);
DefaultStructuralSurvey.enableStructuralSurvey = ((BaseUnityPlugin)this).Config.Bind<bool>("Structural Survey", "AlwaysActive", true, "Makes the Structural Survey upgrade always active, highlighting low-health enemy parts.");
DefaultCloudSkip.enableCloudSkip = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement Modifications", "CloudSkip", true, "Enables Cloud Skip (Double Jump) ability at all times.");
ConfigFile configFile = ((ConfigEntryBase)DefaultMigration.enableCanFireWhileSprinting).ConfigFile;
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "sparroh.mycopunkrebalance.cfg");
fileSystemWatcher.Changed += delegate
{
Logger.LogInfo((object)"Config file changed, reloading");
configFile.Reload();
};
fileSystemWatcher.EnableRaisingEvents = true;
}
catch (Exception ex)
{
Logger.LogError((object)("Error during config initialization: " + ex.Message));
}
harmony = new Harmony("sparroh.mycopunkrebalance");
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(Gun), "Setup", new Type[3]
{
typeof(Player),
typeof(PlayerAnimation),
typeof(IGear)
}, (Type[])null);
if (methodInfo == null)
{
Logger.LogError((object)"Could not find Gun.Setup method for patching.");
return;
}
HarmonyMethod val = new HarmonyMethod(typeof(SparrohPlugin), "ModifyWeaponPrefix", (Type[])null);
harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex2)
{
Logger.LogError((object)("Error patching Gun.Setup: " + ex2.Message));
}
try
{
EnhancedAiming.SetupAimingPatches(harmony);
}
catch (Exception ex3)
{
Logger.LogError((object)("Error setting up aiming patches: " + ex3.Message));
}
try
{
DefaultMagboots.SetupWallrunningPatch(harmony);
}
catch (Exception ex4)
{
Logger.LogError((object)("Error setting up wallrunning patches: " + ex4.Message));
}
try
{
EnhancedStrafing.SetupStrafingPatches(harmony);
}
catch (Exception ex5)
{
Logger.LogError((object)("Error setting up strafing patches: " + ex5.Message));
}
try
{
harmony.PatchAll(typeof(HighlightLowHealthPatch));
harmony.PatchAll(typeof(SwarmGun_OnActiveUpdate_Patch));
harmony.PatchAll(typeof(FlamethrowerArmTipPatch));
harmony.PatchAll(typeof(AutocannonArmTipPatch));
harmony.PatchAll(typeof(CoreProtectionPatches));
harmony.PatchAll(typeof(DefaultCloudSkipPatches));
if (DefaultMigration.enableSprintToFireFix.Value)
{
harmony.PatchAll(typeof(SprintToFireFixPatches));
Logger.LogInfo((object)"SprintToFireFix enabled");
}
else
{
Logger.LogInfo((object)"SprintToFireFix disabled");
}
}
catch (Exception ex6)
{
Logger.LogError((object)("Error applying Harmony patches: " + ex6.Message));
}
Logger.LogInfo((object)"MycopunkRebalance loaded successfully.");
}
public static void ModifyWeaponPrefix(Gun __instance, IGear prefab)
{
ModGunData modGunData = ((Component)__instance).gameObject.AddComponent<ModGunData>();
ApplyGunConstraints(prefab, modGunData);
}
private static void ApplyGunConstraints(IGear prefab, ModGunData modGunData)
{
if (prefab != null)
{
Gun val = (Gun)(object)((prefab is Gun) ? prefab : null);
if (val != null)
{
ref GunData gunData = ref val.GunData;
DefaultMigration.ApplyFireConstraints(ref gunData);
EnhancedAiming.ApplyAimingConstraints(ref gunData, val, modGunData);
}
}
}
}
public static class SprintToFireFixPatches
{
private static readonly FieldInfo playerField = AccessTools.Field(typeof(Gun), "player");
private static readonly FieldInfo gunDataField = AccessTools.Field(typeof(Gun), "gunData");
private static readonly FieldInfo isFireInputHeldField = AccessTools.Field(typeof(Gun), "isFireInputHeld");
private static readonly MethodInfo tryFireMethod = AccessTools.Method(typeof(Gun), "TryFire", (Type[])null, (Type[])null);
private static readonly PropertyInfo canFireWithoutAmmoProperty = AccessTools.Property(typeof(Gun), "CanFireWithoutAmmo");
[HarmonyPatch(typeof(Gun), "CanFireDuringAnimationState")]
[HarmonyPrefix]
private static bool CanFireDuringAnimationStatePrefix(Gun __instance, ref bool __result)
{
try
{
if ((bool)isFireInputHeldField.GetValue(__instance))
{
__result = true;
return false;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in CanFireDuringAnimationState patch: " + ex.Message));
}
return true;
}
[HarmonyPatch(typeof(Gun), "MinWalkingWeightToFire")]
[HarmonyPrefix]
private static bool MinWalkingWeightToFirePrefix(Gun __instance, ref float __result)
{
try
{
if ((bool)isFireInputHeldField.GetValue(__instance))
{
__result = 0f;
return false;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in MinWalkingWeightToFire patch: " + ex.Message));
}
return true;
}
[HarmonyPatch(typeof(Gun), "Update")]
[HarmonyPostfix]
private static void UpdatePostfix(Gun __instance)
{
try
{
bool flag = (bool)isFireInputHeldField.GetValue(__instance);
ModGunData modGunData = ((Component)__instance).gameObject.GetComponent<ModGunData>();
if ((Object)(object)modGunData == (Object)null)
{
modGunData = ((Component)__instance).gameObject.AddComponent<ModGunData>();
}
if (modGunData.PreviousFireInputHeld && !flag && modGunData.SprintingLockedBySprintToFire)
{
object? value = playerField.GetValue(__instance);
Player val = (Player)((value is Player) ? value : null);
if ((Object)(object)val != (Object)null)
{
val.SprintLocks = 0;
modGunData.SprintingLockedBySprintToFire = false;
if (val.AutoSprint)
{
FieldInfo field = typeof(Player).GetField("wantsToSprint", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(val, true);
}
}
}
}
modGunData.PreviousFireInputHeld = flag;
if (flag)
{
AccessTools.Property(typeof(Gun), "WantsToFire").SetValue(__instance, true);
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in Update postfix: " + ex.Message));
}
}
[HarmonyPatch(typeof(Gun), "HandleFiring")]
[HarmonyPrefix]
private static bool HandleFiringPrefix(Gun __instance)
{
try
{
object? value = playerField.GetValue(__instance);
Player val = (Player)((value is Player) ? value : null);
if ((Object)(object)val == (Object)null)
{
return true;
}
object value2 = gunDataField.GetValue(__instance);
if (value2 == null)
{
return true;
}
bool flag = (bool)isFireInputHeldField.GetValue(__instance);
_ = (bool)AccessTools.Property(typeof(Gun), "WantsToFire").GetValue(__instance);
if (val.IsSprinting && flag)
{
object value3 = value2.GetType().GetField("chargeData").GetValue(value2);
bool num = (bool)value3.GetType().GetProperty("CanFire").GetValue(value3);
bool flag2 = (bool)canFireWithoutAmmoProperty.GetValue(__instance);
if (num && ((double)__instance.RemainingAmmo >= 1.0 || flag2))
{
object value4 = value2.GetType().GetField("fireConstraints").GetValue(value2);
if ((int)value4.GetType().GetField("canFireWhileSprinting").GetValue(value4) != 1)
{
val.SprintLocks = 1;
ModGunData component = ((Component)__instance).gameObject.GetComponent<ModGunData>();
if ((Object)(object)component != (Object)null)
{
component.SprintingLockedBySprintToFire = true;
}
}
tryFireMethod.Invoke(__instance, null);
return false;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in SprintToFireFix patch: " + ex.Message));
SparrohPlugin.Logger.LogError((object)("Stack trace: " + ex.StackTrace));
}
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.d2180b337983bf65f74280844d433f93f0695d29";
public const string FullSemVer = "0.0.1-7";
public const string InformationalVersion = "0.0.1-7+Branch.master.Sha.d2180b337983bf65f74280844d433f93f0695d29";
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 = "d2180b337983bf65f74280844d433f93f0695d29";
public const string ShortSha = "d2180b3";
public const string UncommittedChanges = "19";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55007";
}
namespace MycopunkRebalance
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MycopunkRebalance";
public const string PLUGIN_NAME = "MycopunkRebalance";
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)
{
}
}
}