using System;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using TheRollingChair.NetcodePatcher;
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("TheRollingChair")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+57bf82bb76f3d568c70b7da68739f074be9d1fea")]
[assembly: AssemblyProduct("TheRollingChair")]
[assembly: AssemblyTitle("TheRollingChair")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace TheRollingChair
{
internal class Chair : EnemyAI
{
private PlayerControllerB selectedPlayer = null;
public GameObject RopePhysics;
public GameObject Noose;
public Transform ViewPoint;
public AudioSource RollingAudio;
public override void Start()
{
((EnemyAI)this).Start();
RollingAudio.volume = Plugin.RollVolume.Value;
}
public override void DoAIInterval()
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (StartOfRound.Instance.allPlayersDead || base.isEnemyDead || (Object)(object)selectedPlayer == (Object)null)
{
return;
}
if (!selectedPlayer.isInsideFactory)
{
base.agent.speed = 0f;
base.agent.angularSpeed = 0f;
}
if (!selectedPlayer.HasLineOfSightToPosition(ViewPoint.position, 45f, 60, -1f))
{
base.agent.acceleration = Plugin.RollSpeed.Value * 1.8f;
base.agent.speed = Plugin.RollSpeed.Value;
base.agent.angularSpeed = 120f;
((EnemyAI)this).SetDestinationToPosition(RoundManager.Instance.GetNavMeshPosition(((Component)selectedPlayer).transform.position, RoundManager.Instance.navHit, 2.75f, -1), false);
if (!RollingAudio.isPlaying)
{
PlayRollingAudioClientRpc();
}
}
else
{
base.agent.acceleration = 0.2f;
base.agent.speed = 0f;
base.agent.angularSpeed = 0f;
((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
if (RollingAudio.isPlaying)
{
StopPlayingRollingAudioClientRpc();
}
}
}
private PlayerControllerB nearestPlayer()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
float num = float.MaxValue;
PlayerControllerB result = null;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position);
if (num2 < num)
{
num = num2;
result = val;
}
}
return result;
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_0021: 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)
//IL_0068: 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)
((EnemyAI)this).OnCollideWithPlayer(other);
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if (!selectedPlayer.HasLineOfSightToPosition(ViewPoint.position, 45f, 60, -1f) && GameNetworkManager.Instance.localPlayerController.playerClientId == component.playerClientId)
{
component.DamagePlayer(100, false, true, (CauseOfDeath)4, 0, false, default(Vector3));
HangPlayerServerRpc(new NetworkObjectReference(((Component)other).gameObject.GetComponent<NetworkObject>()));
}
}
[ServerRpc(RequireOwnership = false)]
public void HangPlayerServerRpc(NetworkObjectReference player)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_00e3: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4145103938u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref player, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4145103938u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
HangPlayerClientRpc(player);
}
}
}
[ClientRpc]
public void PlayRollingAudioClientRpc()
{
//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)
//IL_00c1: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2568651165u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2568651165u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
RollingAudio.Play();
}
}
}
[ClientRpc]
public void StopPlayingRollingAudioClientRpc()
{
//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)
//IL_00c1: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1922315864u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1922315864u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
RollingAudio.Stop();
}
}
}
[ClientRpc]
public void HangPlayerClientRpc(NetworkObjectReference player)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2997312918u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref player, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2997312918u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
NetworkObject val3 = default(NetworkObject);
if (!((NetworkObjectReference)(ref player)).TryGet(ref val3, (NetworkManager)null))
{
return;
}
PlayerControllerB component = ((Component)val3).GetComponent<PlayerControllerB>();
DeadBodyInfo deadBody = component.deadBody;
if (!((Object)(object)deadBody == (Object)null))
{
Vector3 val4 = ((Component)this).transform.position + Vector3.up * 6f;
RaycastHit val5 = default(RaycastHit);
if (Physics.Raycast(((Component)this).transform.position, Vector3.up, ref val5, 25f, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
{
val4 = ((RaycastHit)(ref val5)).point;
}
SetLineRendererPoints component2 = Object.Instantiate<GameObject>(RopePhysics, val4, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform).GetComponent<SetLineRendererPoints>();
component2.target.position = ((Component)deadBody.bodyParts[0]).transform.position;
Object.Instantiate<GameObject>(Noose, ((Component)deadBody.bodyParts[0]).transform, false);
deadBody.attachedLimb = deadBody.bodyParts[0];
deadBody.attachedTo = component2.target;
}
}
public override void Update()
{
((EnemyAI)this).Update();
selectedPlayer = nearestPlayer();
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(4145103938u, new RpcReceiveHandler(__rpc_handler_4145103938), "HangPlayerServerRpc");
((NetworkBehaviour)this).__registerRpc(2568651165u, new RpcReceiveHandler(__rpc_handler_2568651165), "PlayRollingAudioClientRpc");
((NetworkBehaviour)this).__registerRpc(1922315864u, new RpcReceiveHandler(__rpc_handler_1922315864), "StopPlayingRollingAudioClientRpc");
((NetworkBehaviour)this).__registerRpc(2997312918u, new RpcReceiveHandler(__rpc_handler_2997312918), "HangPlayerClientRpc");
((EnemyAI)this).__initializeRpcs();
}
private static void __rpc_handler_4145103938(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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)
//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference player = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref player, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((Chair)(object)target).HangPlayerServerRpc(player);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2568651165(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)1;
((Chair)(object)target).PlayRollingAudioClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1922315864(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)1;
((Chair)(object)target).StopPlayingRollingAudioClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2997312918(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: 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)
//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference player = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref player, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((Chair)(object)target).HangPlayerClientRpc(player);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "Chair";
}
}
[BepInPlugin("ccode.chair", "Rolling Chair", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "ccode.chair";
public const string NAME = "Rolling Chair";
public const string VERSION = "1.0.0";
private static readonly Harmony Harmony = new Harmony("ccode.chair");
public static ManualLogSource Log;
public static EnemyType ChairEnemy;
public static ConfigEntry<float> RollSpeed;
public static ConfigEntry<float> RollVolume;
public static ConfigEntry<string> Levels;
private void Awake()
{
RollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Roll Speed", 0.6f, "The movement speed of the chair.");
RollVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Roll Volume", 0.5f, "The volume of the rolling sound effect. This setting is client side.");
Levels = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Moons", "All:75", "Moons that it will spawn on. Format as: \"MoonName:SpawnWeight\".");
(Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) tuple = SolveLevels(Levels.Value);
Dictionary<LevelTypes, int> item = tuple.spawnRateByLevelType;
Dictionary<string, int> item2 = tuple.spawnRateByCustomLevelType;
Log = ((BaseUnityPlugin)this).Logger;
Assets.PopulateAssets();
ChairEnemy = Assets.MainAssetBundle.LoadAsset<EnemyType>("Chair.asset");
TerminalNode val = Assets.MainAssetBundle.LoadAsset<TerminalNode>("ChairTN");
TerminalKeyword val2 = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("ChairKW");
Enemies.RegisterEnemy(ChairEnemy, item, item2, val, val2);
NetworkPrefabs.RegisterNetworkPrefab(ChairEnemy.enemyPrefab);
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);
}
}
}
}
private (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) SolveLevels(string config)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
string[] array = config.Split(';');
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Trim().Split(':');
if (array3.Length != 2)
{
continue;
}
int result = 0;
if (int.TryParse(array3[1], out result))
{
if (Enum.TryParse<LevelTypes>(array3[0], ignoreCase: true, out LevelTypes result2))
{
dictionary[result2] = result;
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registered spawn rate for level type {result2} to {result}");
}
else
{
dictionary2[array3[0]] = result;
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registered spawn rate for custom level type {array3[0]} to {result}");
}
}
}
return (dictionary, dictionary2);
}
}
public static class Assets
{
public static AssetBundle MainAssetBundle;
public static void PopulateAssets()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "chairassets"));
if ((Object)(object)MainAssetBundle == (Object)null)
{
Plugin.Log.LogError((object)"Failed to load custom assets.");
}
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace TheRollingChair.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}