#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BakaMODs.CatBrainRot.NetcodePatcher;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BakaMODs.CatBrainRot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CatBrainRot")]
[assembly: AssemblyTitle("BakaMODs.CatBrainRot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CatBrainRot
{
internal class CatBrainRotAI : EnemyAI
{
private enum State
{
Spawning,
SearchingForPlayer,
ChasingPlayer
}
[CompilerGenerated]
private sealed class <PauseLoopForSpecialAttack>d__18 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CatBrainRotAI <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PauseLoopForSpecialAttack>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((EnemyAI)<>4__this).creatureVoice.Stop();
if ((Object)(object)<>4__this.instaKillSFX != (Object)null)
{
((EnemyAI)<>4__this).creatureVoice.PlayOneShot(<>4__this.instaKillSFX);
<>2__current = (object)new WaitForSeconds(<>4__this.instaKillSFX.length);
<>1__state = 1;
return true;
}
break;
case 1:
<>1__state = -1;
break;
}
if (!((EnemyAI)<>4__this).isEnemyDead && ((EnemyAI)<>4__this).currentBehaviourStateIndex == 2)
{
((EnemyAI)<>4__this).creatureVoice.Play();
}
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();
}
}
[CompilerGenerated]
private sealed class <SpawnAnimationDelay>d__15 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CatBrainRotAI <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnAnimationDelay>d__15(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (((NetworkBehaviour)<>4__this).IsOwner)
{
<>4__this.LogIfDebugBuild("Spawn delay finished. Starting to search for players.");
((EnemyAI)<>4__this).StartSearch(((Component)<>4__this).transform.position, (AISearchRoutine)null);
((EnemyAI)<>4__this).SwitchToBehaviourClientRpc(1);
}
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 Transform turnCompass = null;
public Transform attackArea = null;
private float timeSinceLastDamage;
public float damageRadius = 2.5f;
public float damageInterval = 1f;
public int damageAmount = 5;
[Header("Insta-Kill Attack")]
public float instaKillChancePerSecond = 0.05f;
public AudioClip instaKillSFX;
public AudioClip standardAttackSFX;
private const int INSTA_KILL_DAMAGE = 1000;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
((EnemyAI)this).Start();
LogIfDebugBuild("CatBrainRot Spawned");
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
((MonoBehaviour)this).StartCoroutine(SpawnAnimationDelay());
}
public override void Update()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (!base.isEnemyDead && ((NetworkBehaviour)this).IsOwner)
{
Animator creatureAnimator = base.creatureAnimator;
Vector3 velocity = base.agent.velocity;
creatureAnimator.SetBool("isWalking", ((Vector3)(ref velocity)).magnitude > 0.1f);
}
}
public override void DoAIInterval()
{
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
base.agent.speed = 0f;
break;
case 1:
base.agent.speed = 2f;
if (FoundClosestPlayerInRange(25f, 3f))
{
LogIfDebugBuild("Start Target Player");
((EnemyAI)this).StopSearch(base.currentSearch, true);
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
StartChasingLoopClientRpc();
}
break;
case 2:
base.agent.speed = 4f;
if (!TargetClosestPlayerInAnyCase() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 20f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
{
LogIfDebugBuild("Stop Target Player");
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
StopChasingLoopClientRpc();
break;
}
((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
if (((NetworkBehaviour)this).IsServer)
{
timeSinceLastDamage += base.AIIntervalTime;
if (timeSinceLastDamage >= damageInterval)
{
timeSinceLastDamage = 0f;
DamagePlayersInAreaServer();
}
if ((Object)(object)base.targetPlayer != (Object)null && Random.value < instaKillChancePerSecond * base.AIIntervalTime)
{
LogIfDebugBuild("Triggering insta-kill attack!");
PerformInstaKillAttackServer();
}
}
break;
default:
LogIfDebugBuild("This Behavior State doesn't exist!");
break;
}
}
[IteratorStateMachine(typeof(<SpawnAnimationDelay>d__15))]
private IEnumerator SpawnAnimationDelay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnAnimationDelay>d__15(0)
{
<>4__this = this
};
}
private void PerformInstaKillAttackServer()
{
//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_0029: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)base.targetPlayer == (Object)null))
{
base.targetPlayer.KillPlayer(Vector3.zero, true, (CauseOfDeath)3, 0, default(Vector3));
LogIfDebugBuild("Insta-killing and exploding player " + base.targetPlayer.playerUsername + "!");
InterruptLoopWithOneShotClientRpc();
}
}
[ClientRpc]
private void InterruptLoopWithOneShotClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1753015395u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1753015395u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
((MonoBehaviour)this).StartCoroutine(PauseLoopForSpecialAttack());
}
}
}
[IteratorStateMachine(typeof(<PauseLoopForSpecialAttack>d__18))]
private IEnumerator PauseLoopForSpecialAttack()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PauseLoopForSpecialAttack>d__18(0)
{
<>4__this = this
};
}
[ClientRpc]
private void PlayStandardAttackSoundClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(891529785u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 891529785u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)standardAttackSFX != (Object)null)
{
base.creatureVoice.PlayOneShot(standardAttackSFX);
}
}
}
[ClientRpc]
private void StartChasingLoopClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1310417669u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1310417669u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !base.creatureVoice.isPlaying)
{
base.creatureVoice.Play();
}
}
}
[ClientRpc]
private void StopChasingLoopClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(623469361u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 623469361u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureVoice.Stop();
}
}
}
private void DamagePlayersInAreaServer()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (!val.isPlayerDead && val.isPlayerControlled && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < damageRadius)
{
LogIfDebugBuild("Damaging player " + val.playerUsername + "!");
val.DamagePlayer(damageAmount, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
flag = true;
}
}
if (flag)
{
PlayStandardAttackSoundClientRpc();
}
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
return (Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
private bool TargetClosestPlayerInAnyCase()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
base.mostOptimalDistance = 2000f;
base.targetPlayer = null;
for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
{
if (!StartOfRound.Instance.allPlayerScripts[i].isPlayerDead)
{
base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
if (base.tempDist < base.mostOptimalDistance)
{
base.mostOptimalDistance = base.tempDist;
base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
}
}
}
return (Object)(object)base.targetPlayer != (Object)null;
}
public override void OnCollideWithPlayer(Collider other)
{
((EnemyAI)this).OnCollideWithPlayer(other);
}
public override void OnCollideWithEnemy(Collider other, EnemyAI collidedEnemy = null)
{
((EnemyAI)this).OnCollideWithEnemy(other, collidedEnemy);
}
public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
if (!base.isEnemyDead)
{
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
{
((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
KillEnemyEffectsClientRpc();
((EnemyAI)this).KillEnemyOnOwnerClient(false);
}
}
}
[ClientRpc]
public void KillEnemyEffectsClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(943349379u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 943349379u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureAnimator.SetTrigger("KillEnemy");
if (base.creatureVoice.isPlaying)
{
base.creatureVoice.Stop();
}
base.creatureVoice.PlayOneShot(base.dieSFX);
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CatBrainRotAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1753015395u, new RpcReceiveHandler(__rpc_handler_1753015395));
NetworkManager.__rpc_func_table.Add(891529785u, new RpcReceiveHandler(__rpc_handler_891529785));
NetworkManager.__rpc_func_table.Add(1310417669u, new RpcReceiveHandler(__rpc_handler_1310417669));
NetworkManager.__rpc_func_table.Add(623469361u, new RpcReceiveHandler(__rpc_handler_623469361));
NetworkManager.__rpc_func_table.Add(943349379u, new RpcReceiveHandler(__rpc_handler_943349379));
}
private static void __rpc_handler_1753015395(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CatBrainRotAI)(object)target).InterruptLoopWithOneShotClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_891529785(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CatBrainRotAI)(object)target).PlayStandardAttackSoundClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1310417669(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CatBrainRotAI)(object)target).StartChasingLoopClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_623469361(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CatBrainRotAI)(object)target).StopChasingLoopClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_943349379(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((CatBrainRotAI)(object)target).KillEnemyEffectsClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "CatBrainRotAI";
}
}
public class PentagramTrap : NetworkBehaviour
{
[CompilerGenerated]
private sealed class <SummonAndDestroyRoutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Vector3 position;
public Quaternion rotation;
public PentagramTrap <>4__this;
private GameObject <enemyInstance>5__1;
private NetworkObject <enemyNetObj>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SummonAndDestroyRoutine>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<enemyInstance>5__1 = null;
<enemyNetObj>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.LogIfDebugBuild("SERVER: Calling PlayEffectsClientRpc to start visuals on all clients.");
<>4__this.PlayEffectsClientRpc();
<>2__current = (object)new WaitForSeconds(<>4__this.spawnDelay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)<>4__this.enemyToSpawnPrefab != (Object)null)
{
<>4__this.LogIfDebugBuild("SERVER: Instantiating enemy prefab '" + ((Object)<>4__this.enemyToSpawnPrefab).name + "'.");
<enemyInstance>5__1 = Object.Instantiate<GameObject>(<>4__this.enemyToSpawnPrefab, position, rotation);
if (<enemyInstance>5__1.TryGetComponent<NetworkObject>(ref <enemyNetObj>5__2))
{
<>4__this.LogIfDebugBuild("SERVER: Spawning enemy NetworkObject for all clients.");
<enemyNetObj>5__2.Spawn(true);
}
else
{
<>4__this.LogIfDebugBuild("SERVER CRITICAL ERROR: The enemy prefab is missing a NetworkObject component!");
Object.Destroy((Object)(object)<enemyInstance>5__1);
}
<enemyInstance>5__1 = null;
<enemyNetObj>5__2 = null;
}
<>4__this.LogIfDebugBuild("SERVER: Summon sequence finished. Despawning pentagram.");
if (((NetworkBehaviour)<>4__this).IsServer && ((NetworkBehaviour)<>4__this).NetworkObject.IsSpawned)
{
((NetworkBehaviour)<>4__this).NetworkObject.Despawn(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();
}
}
public GameObject enemyToSpawnPrefab;
public AudioClip spawnSFX;
public AudioSource creatureVoice;
public Animator pentagramAnimator;
[Header("Trap Settings")]
public float spawnDelay = 2f;
private bool hasBeenTriggered = false;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)("[PentagramTrap] " + text));
}
public override void OnNetworkSpawn()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
((NetworkBehaviour)this).OnNetworkSpawn();
LogIfDebugBuild($"Pentagram has spawned at position {((Component)this).transform.position}.");
Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
if (componentsInChildren != null)
{
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.enabled = true;
}
LogIfDebugBuild($"Enabled {componentsInChildren.Length} renderers for the pentagram.");
}
if ((Object)(object)enemyToSpawnPrefab == (Object)null)
{
LogIfDebugBuild("CRITICAL ERROR: The 'enemyToSpawnPrefab' is not assigned in the Inspector!");
}
}
private void OnTriggerEnter(Collider other)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
if (!hasBeenTriggered && ((Component)other).CompareTag("Player"))
{
PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component).IsOwner)
{
hasBeenTriggered = true;
LogIfDebugBuild("Player '" + component.playerUsername + "' has triggered the trap! Requesting spawn sequence.");
SpawnSequenceServerRpc(((Component)this).transform.position, ((Component)this).transform.rotation);
}
}
}
[ServerRpc(RequireOwnership = false)]
private void SpawnSequenceServerRpc(Vector3 position, Quaternion rotation)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(196879066u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 196879066u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
LogIfDebugBuild("SERVER: Received SpawnSequenceServerRpc request.");
if (((NetworkBehaviour)this).IsServer)
{
((MonoBehaviour)this).StartCoroutine(SummonAndDestroyRoutine(position, rotation));
}
}
}
[IteratorStateMachine(typeof(<SummonAndDestroyRoutine>d__10))]
private IEnumerator SummonAndDestroyRoutine(Vector3 position, Quaternion rotation)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SummonAndDestroyRoutine>d__10(0)
{
<>4__this = this,
position = position,
rotation = rotation
};
}
[ClientRpc]
private void PlayEffectsClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: 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_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4262207865u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4262207865u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
LogIfDebugBuild("CLIENT: Received PlayEffectsClientRpc. Starting effects.");
Collider component = ((Component)this).GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
component.enabled = false;
}
if ((Object)(object)pentagramAnimator != (Object)null)
{
pentagramAnimator.SetTrigger("startGlow");
}
if ((Object)(object)spawnSFX != (Object)null && (Object)(object)creatureVoice != (Object)null)
{
creatureVoice.PlayOneShot(spawnSFX);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_PentagramTrap()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(196879066u, new RpcReceiveHandler(__rpc_handler_196879066));
NetworkManager.__rpc_func_table.Add(4262207865u, new RpcReceiveHandler(__rpc_handler_4262207865));
}
private static void __rpc_handler_196879066(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
Quaternion rotation = default(Quaternion);
((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PentagramTrap)(object)target).SpawnSequenceServerRpc(position, rotation);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4262207865(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((PentagramTrap)(object)target).PlayEffectsClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "PentagramTrap";
}
}
[BepInPlugin("BakaMODs.CatBrainRot", "CatBrainRot", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(RoundManager))]
internal class PentagramSpawnCounterPatch
{
private static bool hasLoggedSpawnCount;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void ResetLogFlagPatch()
{
hasLoggedSpawnCount = false;
}
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPostfix]
private static void CountSpawnedPentagramsPatch()
{
if (!hasLoggedSpawnCount)
{
PentagramTrap[] array = Object.FindObjectsOfType<PentagramTrap>();
int num = array.Length;
Logger.LogInfo((object)$"A total of {num} pentagrams have spawned in the facility.");
hasLoggedSpawnCount = true;
}
}
}
internal static ManualLogSource Logger;
public static AssetBundle? ModAssets;
private readonly Harmony harmony = new Harmony("BakaMODs.CatBrainRot");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
InitializeNetworkBehaviours();
string path = "catbrainrotassets";
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
if ((Object)(object)ModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets bundle!");
return;
}
Logger.LogInfo((object)"Successfully loaded assets bundle.");
GameObject val = ModAssets.LoadAsset<GameObject>("catbrainrot 1");
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)"Failed to load 'catbrainrot 1' enemy prefab from bundle!");
return;
}
Logger.LogInfo((object)"Successfully loaded enemy prefab.");
SpawnableMapObjectDef val2 = ModAssets.LoadAsset<SpawnableMapObjectDef>("PentagramTrapMapObject");
if ((Object)(object)val2 == (Object)null)
{
Logger.LogError((object)"Failed to load 'PentagramTrapMapObject' asset from bundle! Check asset name and ensure it's in the bundle.");
return;
}
Logger.LogInfo((object)"Successfully loaded SpawnableMapObjectDef asset.");
if (val2.spawnableMapObject == null)
{
Logger.LogError((object)"'spawnableMapObject' inside the PentagramTrapMapObjectDef is null!");
return;
}
if ((Object)(object)val2.spawnableMapObject.prefabToSpawn == (Object)null)
{
Logger.LogError((object)"'prefabToSpawn' inside the PentagramTrapMapObjectDef is null! Make sure you assigned the prefab in the Unity Editor.");
return;
}
Logger.LogInfo((object)"SpawnableMapObjectDef asset seems valid.");
PentagramTrap pentagramTrap = default(PentagramTrap);
if (val2.spawnableMapObject.prefabToSpawn.TryGetComponent<PentagramTrap>(ref pentagramTrap))
{
pentagramTrap.enemyToSpawnPrefab = val;
Logger.LogInfo((object)"Successfully found PentagramTrap script and assigned enemy prefab.");
Func<SelectableLevel, AnimationCurve> func = (SelectableLevel level) => new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, 5f),
new Keyframe(1f, 5f)
});
NetworkPrefabs.RegisterNetworkPrefab(val2.spawnableMapObject.prefabToSpawn);
NetworkPrefabs.RegisterNetworkPrefab(val);
MapObjects.RegisterMapObject(val2, (LevelTypes)(-1), func);
harmony.PatchAll(typeof(PentagramSpawnCounterPatch));
Logger.LogInfo((object)"Plugin BakaMODs.CatBrainRot is loaded!");
}
else
{
Logger.LogError((object)"Could not find PentagramTrap script on the pentagram prefab!");
}
}
private static void InitializeNetworkBehaviours()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BakaMODs.CatBrainRot";
public const string PLUGIN_NAME = "CatBrainRot";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CatBrainRot.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> EasyMoonSpawnWeight;
public ConfigEntry<int> MediumMoonSpawnWeight;
public ConfigEntry<int> HardMoonSpawnWeight;
public ConfigEntry<int> ModdedMoonSpawnWeight;
public PluginConfig(ConfigFile cfg)
{
EasyMoonSpawnWeight = cfg.Bind<int>("Spawn Weights", "1. Easy Moons (Experimentation, Assurance, Vow)", 20, "The spawn chance weight on easy moons. Lower is more rare.");
MediumMoonSpawnWeight = cfg.Bind<int>("Spawn Weights", "2. Medium Moons (Offense, March)", 40, "The spawn chance weight on medium moons. Lower is more rare.");
HardMoonSpawnWeight = cfg.Bind<int>("Spawn Weights", "3. Hard Moons (Rend, Dine, Titan)", 80, "The spawn chance weight on hard moons. Lower is more rare.");
ModdedMoonSpawnWeight = cfg.Bind<int>("Spawn Weights", "4. Modded Moons", 80, "The default spawn chance weight for modded moons that are not specified manually.");
ClearUnusedEntries(cfg);
}
private void ClearUnusedEntries(ConfigFile cfg)
{
PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
dictionary.Clear();
cfg.Save();
}
}
}
namespace BakaMODs.CatBrainRot.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}