using System;
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.Logging;
using BigRedButton.Behaviors;
using BigRedButton.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
[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("BigRedButton")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A big red button for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+04aa1265320b89a92dee5be133323fdffc202cb8")]
[assembly: AssemblyProduct("BigRedButton")]
[assembly: AssemblyTitle("BigRedButton")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BigRedButton
{
[BepInPlugin("bricct.bigredbutton", "Big Red Button", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BigRedButton : BaseUnityPlugin
{
private const string modGUID = "bricct.bigredbutton";
private const string modName = "Big Red Button";
private const string modVersion = "1.2.1";
private readonly Harmony _harmony = new Harmony("bricct.bigredbutton");
private static BigRedButton _instance;
internal ManualLogSource _logger;
private void Awake()
{
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
_logger = Logger.CreateLogSource("bricct.bigredbutton");
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BigRedButton");
AssetBundle val = AssetBundle.LoadFromFile(text);
GameObject val2 = val.LoadAsset<GameObject>("Assets/BigRedButton/BigRedButton.prefab");
BigRedButtonController bigRedButtonController = val2.AddComponent<BigRedButtonController>();
AudioClip[] audioClips = (AudioClip[])(object)new AudioClip[5]
{
val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbutton.wav"),
val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbutton2.wav"),
val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbutton3.wav"),
val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbutton4.wav"),
val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbutton5.wav")
};
AudioClip special = val.LoadAsset<AudioClip>("Assets/BigRedButton/bigredbuttonspecial.wav");
GameObject gameObject = ((Component)val2.transform.Find("InteractTrigger")).gameObject;
InteractTrigger component = gameObject.GetComponent<InteractTrigger>();
bigRedButtonController.audioClips = audioClips;
bigRedButtonController.special = special;
bigRedButtonController.audioSource = gameObject.GetComponent<AudioSource>();
bigRedButtonController.trigger = component;
NetworkPrefabs.RegisterNetworkPrefab(val2);
UnlockableItem val3 = new UnlockableItem();
val3.unlockableName = "Big Red Button";
val3.prefabObject = val2;
val3.unlockableType = 1;
val3.alwaysInStock = true;
val3.maxNumber = 100;
val3.IsPlaceable = true;
val3.canBeStored = false;
TerminalNode val4 = new TerminalNode();
((Object)val4).name = "Big Red Button";
val4.clearPreviousText = true;
val4.displayText = "Only press in emergency situations";
Unlockables.RegisterUnlockable(val3, (StoreType)1, (TerminalNode)null, (TerminalNode)null, val4, 100);
_logger.LogInfo((object)"Loading unlockable: Big Red Button");
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);
}
}
}
_harmony.PatchAll(typeof(BigRedButton));
_harmony.PatchAll(typeof(BigRedButtonController));
_logger.LogInfo((object)"Plugin Big Red Button is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BigRedButton";
public const string PLUGIN_NAME = "BigRedButton";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace BigRedButton.Behaviors
{
public class BigRedButtonController : NetworkBehaviour
{
public AudioClip[] audioClips;
public AudioClip special;
public AudioSource audioSource;
public InteractTrigger trigger;
private Random random = new Random();
private void Start()
{
Debug.Log((object)"subscribing to trigger event");
((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)Trigger);
}
public void Trigger(PlayerControllerB player)
{
PlaySoundServerRpc();
}
[ServerRpc(RequireOwnership = false)]
public void PlaySoundServerRpc()
{
//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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2119188281u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2119188281u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
if (random.Next(0, 100) < 4)
{
Debug.Log((object)"Special Event Triggered");
PlaySoundClientRpc(-1);
}
else
{
PlaySoundClientRpc(random.Next(0, audioClips.Length));
}
}
}
[ClientRpc]
public void PlaySoundClientRpc(int index)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1487561034u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, index);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1487561034u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
AudioClip val3 = ((index != -1) ? audioClips[index] : special);
audioSource.PlayOneShot(val3);
WalkieTalkie.TransmitOneShotAudio(audioSource, val3, 1f);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_BigRedButtonController()
{
//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(2119188281u, new RpcReceiveHandler(__rpc_handler_2119188281));
NetworkManager.__rpc_func_table.Add(1487561034u, new RpcReceiveHandler(__rpc_handler_1487561034));
}
private static void __rpc_handler_2119188281(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;
((BigRedButtonController)(object)target).PlaySoundServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1487561034(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int index = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref index);
target.__rpc_exec_stage = (__RpcExecStage)2;
((BigRedButtonController)(object)target).PlaySoundClientRpc(index);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "BigRedButtonController";
}
}
}
namespace BigRedButton.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}