using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using EggFixes.Patches;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Egg")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EasterEggFixes")]
[assembly: AssemblyCopyright("Spookybuddy 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("28f2f16b-6471-4c7e-b0a4-007e3a2450d4")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EggFixes
{
[BepInPlugin("EasterEggFixes", "EasterEggFixes", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class EasterEggFixesModBase : BaseUnityPlugin
{
public const string modGUID = "EasterEggFixes";
private const string modName = "EasterEggFixes";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("EasterEggFixes");
internal static EasterEggFixesModBase Instance;
internal static ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("EasterEggFixes");
harmony.PatchAll(typeof(EasterEggFixesModBase));
harmony.PatchAll(typeof(StunGrenadeItemPatch));
mls.LogInfo((object)"Easter Egg Fixes was loaded.");
}
}
}
namespace EggFixes.Patches
{
[HarmonyPatch(typeof(StunGrenadeItem))]
internal class StunGrenadeItemPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartFix(StunGrenadeItem __instance)
{
if (__instance.chanceToExplode == 16f)
{
__instance.chanceToExplode = -1f;
EasterEggFixesModBase.mls.LogInfo((object)"Fixed an Egg");
}
}
[HarmonyPatch("ItemActivate")]
[HarmonyPostfix]
private static void ThrowFix(StunGrenadeItem __instance)
{
if (__instance.chanceToExplode == -1f)
{
__instance.chanceToExplode = -2f;
EasterEggFixesModBase.mls.LogWarning((object)"Threw Egg!");
}
}
[HarmonyPatch("OnHitGround")]
[HarmonyPostfix]
private static void ExplodeFix(StunGrenadeItem __instance, ref bool ___hasCollided)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (__instance.hasExploded || !(__instance.chanceToExplode < -1f))
{
return;
}
if (___hasCollided || ((GrabbableObject)__instance).hasHitGround)
{
EasterEggFixesModBase.mls.LogInfo((object)"BOOM!");
__instance.hasExploded = true;
if (__instance.spawnDamagingShockwave)
{
Landmine.SpawnExplosion(((Component)__instance).transform.position + Vector3.up * 0.2f, false, 0.5f, 3f, 40, 45f, (GameObject)null);
}
Transform val = ((!((GrabbableObject)__instance).isInElevator) ? RoundManager.Instance.mapPropsContainer.transform : StartOfRound.Instance.elevatorTransform);
Object.Instantiate<GameObject>(__instance.stunGrenadeExplosion, ((Component)__instance).transform.position, Quaternion.identity, val);
__instance.itemAudio.PlayOneShot(__instance.explodeSFX);
WalkieTalkie.TransmitOneShotAudio(__instance.itemAudio, __instance.explodeSFX, 1f);
if (__instance.DestroyGrenade)
{
Object.Destroy((Object)(object)((Component)__instance).gameObject);
}
}
else
{
EasterEggFixesModBase.mls.LogError((object)"Failed to impact. Resetting Egg.");
__instance.chanceToExplode = -1f;
}
}
[HarmonyPatch("EquipItem")]
[HarmonyPostfix]
private static void EquipFix(StunGrenadeItem __instance)
{
if (__instance.chanceToExplode < 100f)
{
__instance.chanceToExplode = -1f;
EasterEggFixesModBase.mls.LogInfo((object)"Picked up an Egg");
}
}
}
}