using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PetReaper;
[BepInPlugin("plonk.petmirror", "PetMirrorReaper", "1.0.0")]
public class MainCode : BaseUnityPlugin
{
public static GameObject follower;
public static EnemyIdentifier followereid;
public static PluginConfigurator config;
public static BoolField enabled;
public static BoolField fullSize;
public static FloatField followDistance;
public static FloatField teleportDistance;
public static StringField name;
public static StringField pronouns;
public static T Fetch<T>(string path) where T : Object
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
}
public void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
config = PluginConfigurator.Create("Mirror Reaper Friend", "plonk.petmirror");
enabled = new BoolField(config.rootPanel, "Enabled", "plonk.petmirror.enabled", true, true);
fullSize = new BoolField(config.rootPanel, "Is Full Size", "plonk.petmirror.fullsize", true, true);
followDistance = new FloatField(config.rootPanel, "Distance to keep from player", "plonk.petmirror.followdist", 10f, true);
teleportDistance = new FloatField(config.rootPanel, "Distance at which to teleport back to player", "plonk.petmirror.teledist", 30f, true);
name = new StringField(config.rootPanel, "Name", "plonk.petmirror.name", "fart baby", true);
pronouns = new StringField(config.rootPanel, "Pronouns", "plonk.petmirror.pronouns", "he/it", true);
SceneManager.sceneLoaded += OnSceneChange;
}
public void Start()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("plonk.petmirror").PatchAll();
}
public static void SpawnFollower()
{
//IL_007d: 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_0047: Unknown result type (might be due to invalid IL or missing references)
if (!enabled.value)
{
return;
}
if ((Object)(object)follower != (Object)null && (Object)(object)followereid != (Object)null && !followereid.dead)
{
follower.transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
return;
}
if ((Object)(object)follower != (Object)null)
{
Object.Destroy((Object)(object)follower);
}
follower = Object.Instantiate<GameObject>(MainCode.Fetch<GameObject>("Assets/Prefabs/Enemies/MirrorReaperCyberGrind.prefab"), ((Component)MonoSingleton<NewMovement>.Instance).transform.position, Quaternion.identity);
EnemyIdentifier component = follower.GetComponent<EnemyIdentifier>();
component.attackEnemies = true;
component.ignorePlayer = true;
component.dontCountAsKills = true;
component.difficultyOverride = 2;
follower.GetComponentInChildren<NavMeshAgent>().radius = 1f;
follower.AddComponent<ReaperPet>();
SwingCheck2[] componentsInChildren = follower.GetComponentsInChildren<SwingCheck2>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
ComponentExtensions.GetOrAddComponent<ReaperSc>((Component)(object)componentsInChildren[i]);
}
EnemyIdentifierIdentifier[] componentsInChildren2 = follower.GetComponentsInChildren<EnemyIdentifierIdentifier>();
for (int i = 0; i < componentsInChildren2.Length; i++)
{
Object.Destroy((Object)(object)componentsInChildren2[i]);
}
followereid = component;
follower.tag = "";
}
public void OnSceneChange(Scene scene, LoadSceneMode mode)
{
}
public void Update()
{
if (!enabled.value)
{
if ((Object)(object)follower != (Object)null)
{
Object.Destroy((Object)(object)follower);
}
}
else
{
if ((Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null)
{
return;
}
if (!MonoSingleton<NewMovement>.Instance.activated)
{
if ((Object)(object)follower != (Object)null)
{
Object.Destroy((Object)(object)follower);
}
return;
}
if ((Object)(object)followereid != (Object)null && followereid.dead)
{
Object.Destroy((Object)(object)((Component)followereid).gameObject);
SpawnFollower();
}
if ((Object)(object)follower == (Object)null)
{
SpawnFollower();
}
}
}
}
public class ReaperPet : MonoBehaviour
{
public void Update()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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)
((Component)this).transform.localScale = (MainCode.fullSize.value ? (Vector3.one * 2f) : Vector3.one);
}
}
public class ReaperSc : MonoBehaviour
{
private SwingCheck2 sc2;
private Collider col;
private bool damaging;
private List<EnemyIdentifier> hitEnemies = new List<EnemyIdentifier>();
private List<EnemyIdentifier> enemies = new List<EnemyIdentifier>();
public void Start()
{
sc2 = ((Component)this).GetComponent<SwingCheck2>();
col = sc2.col;
}
public void Update()
{
//IL_00bb: 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_00d0: 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_0111: 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)
if (!col.enabled)
{
col.enabled = true;
}
if (!damaging || enemies.Count == 0)
{
return;
}
foreach (EnemyIdentifier enemy in enemies)
{
if (!enemy.dead && !hitEnemies.Contains(enemy) && !((Object)(object)enemy == (Object)(object)MainCode.followereid))
{
hitEnemies.Add(enemy);
enemy.hitter = "reaperBuddySwing";
if (!enemy.hitterWeapons.Contains("reaperBuddySwing"))
{
enemy.hitterWeapons.Add("reaperBuddySwing");
}
enemy.DeliverDamage(((Component)enemy).gameObject, ((Component)this).transform.forward * 1000f, enemy.GetCenter().position, 5f, false, 0f, ((Component)this).gameObject, false, false);
if (Object.op_Implicit((Object)(object)enemy.zombie))
{
enemy.DeliverDamage(((Component)enemy).gameObject, ((Component)this).transform.forward * 1000f, enemy.GetCenter().position, 999f, false, 0f, ((Component)this).gameObject, false, false);
enemy.zombie.ChestExplosion(false, false);
}
}
}
}
public void OnTriggerEnter(Collider other)
{
EnemyIdentifier item = default(EnemyIdentifier);
if (((Component)other).TryGetComponent<EnemyIdentifier>(ref item) && !enemies.Contains(item))
{
enemies.Add(item);
}
EnemyIdentifierIdentifier val = default(EnemyIdentifierIdentifier);
if (((Component)other).TryGetComponent<EnemyIdentifierIdentifier>(ref val) && !enemies.Contains(val.eid))
{
enemies.Add(val.eid);
}
}
public void OnTriggerExit(Collider other)
{
EnemyIdentifier item = default(EnemyIdentifier);
if (((Component)other).TryGetComponent<EnemyIdentifier>(ref item) && enemies.Contains(item))
{
enemies.Remove(item);
}
}
public void DamageStart()
{
hitEnemies.Clear();
damaging = true;
}
public void DamageStop()
{
damaging = false;
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(NewMovement), "ActivatePlayer")]
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerActivator), "Activate")]
public static void SpawnReaper()
{
MainCode.SpawnFollower();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GroundWave), "Start")]
public static void MakeHandsHurtEnemies(GroundWave __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.eid == (Object)(object)MainCode.followereid)
{
HurtZone componentInChildren = ((Component)__instance).GetComponentInChildren<HurtZone>();
componentInChildren.affected = (AffectedSubjects)2;
componentInChildren.enemyDamageOverride = 4f;
componentInChildren.ignoredEnemyTypes = new List<EnemyType> { (EnemyType)41 };
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ActivateArena), "Activate")]
public static void TeleReaper()
{
//IL_0022: 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)
NavMeshHit val = default(NavMeshHit);
if (Object.op_Implicit((Object)(object)MainCode.follower) && !MainCode.followereid.dead && NavMesh.SamplePosition(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ref val, 50f, ((Component)MainCode.followereid).GetComponent<MirrorReaper>().nma.areaMask))
{
((Component)MainCode.followereid).GetComponent<MirrorReaper>().Teleport(((NavMeshHit)(ref val)).position);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MirrorReaper), "Teleport", new Type[] { typeof(Vector3) })]
public static void ClearDamageOnTele(MirrorReaper __instance)
{
if ((Object)(object)__instance.eid == (Object)(object)MainCode.followereid)
{
__instance.DamageStop();
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(NewMovement), "Respawn")]
public static void TeleReaper2()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)MainCode.follower) && !MainCode.followereid.dead)
{
MainCode.follower.transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MirrorReaper), "Update")]
public static bool MakeHimFollowThePlayer(MirrorReaper __instance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: 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_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: 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)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
ReaperPet reaperPet = default(ReaperPet);
if (!((Component)__instance).TryGetComponent<ReaperPet>(ref reaperPet))
{
return true;
}
if (__instance.IsTargetVisible(true))
{
__instance.sinceVisible = TimeSince.op_Implicit(0f);
}
if (__instance.target == null)
{
Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
NavMeshHit val = default(NavMeshHit);
if (TimeSince.op_Implicit(__instance.sinceLastTeleport) > 3f && Vector3.Distance(position, ((Component)__instance).transform.position) > MainCode.teleportDistance.value && NavMesh.SamplePosition(((Component)MonoSingleton<NewMovement>.Instance).transform.position, ref val, 25f, __instance.nma.areaMask))
{
__instance.Teleport(((NavMeshHit)(ref val)).position);
}
if (Vector3.Distance(new Vector3(position.x, ((Component)__instance).transform.position.y, position.z), ((Component)__instance).transform.position) > MainCode.followDistance.value)
{
((Behaviour)__instance.nma).enabled = true;
__instance.nma.SetDestination(((Component)MonoSingleton<NewMovement>.Instance).transform.position);
}
else
{
__instance.nma.SetDestination(((Component)__instance).transform.position);
}
return false;
}
if (!__instance.inAction && !__instance.attacking && __instance.useMirrorPhase && !__instance.inMirrorPhase && __instance.mach.health < __instance.mirrorPhaseHealth)
{
__instance.Teleport();
}
if (__instance.target != null)
{
Vector3 val2 = (__instance.targetOverride ? __instance.targetOverridePosition : __instance.lastTargetData.position);
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(val2.x, ((Component)__instance).transform.position.y, val2.z);
((Component)__instance).transform.rotation = Quaternion.LookRotation(val3 - ((Component)__instance).transform.position);
}
else
{
Vector3 position2 = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(position2.x, ((Component)__instance).transform.position.y, position2.z);
((Component)__instance).transform.rotation = Quaternion.LookRotation(val4 - ((Component)__instance).transform.position);
}
__instance.AttackCheck();
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MirrorReaper), "ProjectileBarrage")]
public static bool RemoveGasProjectilesSorry(MirrorReaper __instance)
{
ReaperPet reaperPet = default(ReaperPet);
if (!((Component)__instance).TryGetComponent<ReaperPet>(ref reaperPet))
{
return true;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MirrorReaper), "Death")]
public static bool RemoveDeath(MirrorReaper __instance)
{
ReaperPet reaperPet = default(ReaperPet);
if (!((Component)__instance).TryGetComponent<ReaperPet>(ref reaperPet))
{
return true;
}
Object.Destroy((Object)(object)((Component)__instance).gameObject);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SwingCheck2), "Update")]
public static bool RemoveSC2Update(SwingCheck2 __instance)
{
ReaperSc reaperSc = default(ReaperSc);
if (!((Component)__instance).TryGetComponent<ReaperSc>(ref reaperSc))
{
return true;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SwingCheck2), "OnEnable")]
public static bool RemoveSC2OnEnable(SwingCheck2 __instance)
{
ReaperSc reaperSc = default(ReaperSc);
if (!((Component)__instance).TryGetComponent<ReaperSc>(ref reaperSc))
{
return true;
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SwingCheck2), "DamageStart")]
public static bool ReplaceSC2DamageStart(SwingCheck2 __instance)
{
ReaperSc reaperSc = default(ReaperSc);
if (!((Component)__instance).TryGetComponent<ReaperSc>(ref reaperSc))
{
return true;
}
reaperSc.DamageStart();
if (Object.op_Implicit((Object)(object)__instance.aud))
{
AudioSourceExtensions.Play(__instance.aud, true);
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SwingCheck2), "DamageStop")]
public static bool ReplaceSC2DamageStop(SwingCheck2 __instance)
{
ReaperSc reaperSc = default(ReaperSc);
if (!((Component)__instance).TryGetComponent<ReaperSc>(ref reaperSc))
{
return true;
}
reaperSc.DamageStop();
return false;
}
}