Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of scrap button mod v0.1.0
ScrapButton.dll
Decompiled 2 years agousing System; using System.Collections; 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 Microsoft.CodeAnalysis; using MysteryButton.ExtensionMethod; using MysteryButton.MonoBehaviors; using MysteryButton.NetcodePatcher; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("UnityEngine")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("MysteryButton")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A new type of scrap")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MysteryButton")] [assembly: AssemblyTitle("MysteryButton")] [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 MysteryButton { [BepInPlugin("gloveman.ScrapButton", "ScrapButton", "1.0.0.0")] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { private const string GUID = "gloveman.ScrapButton"; private AssetBundle assets; public Item buttonItem; public ConfigEntry<double> bombChance; public ConfigEntry<double> floodChance; private ConfigEntry<int> spawnRate; public ConfigEntry<bool> leaveScrap; private readonly Harmony harmony = new Harmony("gloveman.ScrapButton"); public ManualLogSource logger; public static Plugin Instance; public GameObject networkManagerObject; public GameObject indoorFlooding; private AudioClip waterRush; private AudioClip burstSFX; private void Awake() { logger = Logger.CreateLogSource("gloveman.ScrapButton"); logger.LogInfo((object)"ScrapButton is awake!"); if ((Object)(object)Instance == (Object)null) { Instance = this; } bombChance = ((BaseUnityPlugin)this).Config.Bind<double>("General", "Bomb_Chance", 0.3, "Chance that a button press will explode (out of 1)"); floodChance = ((BaseUnityPlugin)this).Config.Bind<double>("General", "Flood_Chance", 0.001, "Chance that a button press will flood the facility (out of 1)"); spawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Spawn Rate", 20, "How much the device will spawn as scrap. Higher is more common."); leaveScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Leave Scrap", false, "Should players drop scrap when teleporting with the device?"); assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "assets")); UnpackAssets(assets); DoPatches(); 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 void UnpackAssets(AssetBundle assetBundle) { this.buttonItem = assetBundle.LoadAsset<Item>("Assets/AssetBundles/Bundle/ButtonItem.asset"); Material blueGlow = assetBundle.LoadAsset<Material>("Assets/AssetBundles/Bundle/glow2.mat"); Material redGlow = assetBundle.LoadAsset<Material>("Assets/AssetBundles/Bundle/glow.mat"); AudioClip pressed = assetBundle.LoadAsset<AudioClip>("Assets/AssetBundles/Bundle/Press.ogg"); burstSFX = assetBundle.LoadAsset<AudioClip>("Assets/AssetBundles/Bundle/Burst2.ogg"); waterRush = assetBundle.LoadAsset<AudioClip>("Assets/AssetBundles/Bundle/WaterRush.ogg"); ButtonItem buttonItem = this.buttonItem.spawnPrefab.AddComponent<ButtonItem>(); ((GrabbableObject)buttonItem).grabbable = true; ((GrabbableObject)buttonItem).grabbableToEnemies = true; ((GrabbableObject)buttonItem).itemProperties = this.buttonItem; buttonItem.redGlow = redGlow; buttonItem.blueGlow = blueGlow; buttonItem.mainAudio = this.buttonItem.spawnPrefab.GetComponent<AudioSource>(); buttonItem.pressed = pressed; AudioSource[] componentsInChildren = this.buttonItem.spawnPrefab.GetComponentsInChildren<AudioSource>(); AudioSource[] array = componentsInChildren; foreach (AudioSource val in array) { AudioMixerGroup val2 = val.outputAudioMixerGroup.audioMixer.FindMatchingGroups(((Object)val.outputAudioMixerGroup).name)[0]; if ((Object)(object)val2 != (Object)null) { val.outputAudioMixerGroup = val2; } } } public void DoPatches() { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Terminal), "Awake", (Type[])null, (Type[])null); MethodInfo method = typeof(Plugin).GetMethod("TerminalAwake"); MethodInfo methodInfo2 = AccessTools.Method(typeof(StartOfRound), "Update", (Type[])null, (Type[])null); MethodInfo method2 = typeof(Plugin).GetMethod("Debug"); MethodInfo methodInfo3 = AccessTools.Method(typeof(GameNetworkManager), "Start", (Type[])null, (Type[])null); MethodInfo method3 = typeof(Plugin).GetMethod("NetworkStart"); MethodInfo methodInfo4 = AccessTools.Method(typeof(StartOfRound), "openingDoorsSequence", (Type[])null, (Type[])null); MethodInfo method4 = typeof(Plugin).GetMethod("OpenDoors"); MethodInfo methodInfo5 = AccessTools.Method(typeof(EntranceTeleport), "TeleportPlayer", (Type[])null, (Type[])null); MethodInfo method5 = typeof(Plugin).GetMethod("TeleportPlayer"); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(method3), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)methodInfo4, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(method5), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void TerminalAwake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown StartOfRound instance = StartOfRound.Instance; SelectableLevel[] levels = instance.levels; foreach (SelectableLevel val in levels) { SpawnableItemWithRarity item = new SpawnableItemWithRarity { rarity = Instance.spawnRate.Value, spawnableItem = Instance.buttonItem }; if (val.spawnableScrap.TrueForAll((SpawnableItemWithRarity scrap) => (Object)(object)scrap.spawnableItem != (Object)(object)Instance.buttonItem)) { val.spawnableScrap.Add(item); } } instance.allItemsList.itemsList.Add(Instance.buttonItem); if ((Object)(object)Instance.indoorFlooding == (Object)null) { try { Instance.indoorFlooding = Object.Instantiate<GameObject>(GameObject.Find("Systems/GameSystems/TimeAndWeather/Flooding")); Instance.indoorFlooding.SetActive(false); Object.Destroy((Object)(object)Instance.indoorFlooding.GetComponent<FloodWeather>()); IndoorFlood indoorFlood = Instance.indoorFlooding.AddComponent<IndoorFlood>(); indoorFlood.waterAudio = Instance.indoorFlooding.GetComponentInChildren<AudioSource>(); indoorFlood.burstSFX = Instance.burstSFX; indoorFlood.waterRush = Instance.waterRush; } catch (Exception ex) { Instance.logger.LogError((object)("Encountered error grabbing GameObject: " + ex.Message)); Instance.floodChance.Value = 0.0; } } } public static void Debug(StartOfRound __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (((ButtonControl)Keyboard.current[(Key)94]).wasPressedThisFrame) { GameObject val = Object.Instantiate<GameObject>(Instance.buttonItem.spawnPrefab, ((Component)__instance.localPlayerController.gameplayCamera).transform.position, Quaternion.identity); val.GetComponent<NetworkObject>().Spawn(false); } } public static void NetworkStart(GameNetworkManager __instance) { if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(Instance.buttonItem.spawnPrefab)) { NetworkManager.Singleton.AddNetworkPrefab(Instance.buttonItem.spawnPrefab); } } public static void OpenDoors() { ButtonItem.NewSeed(); } public static void spawnNetPrefab(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsHost) { GameObject val = Object.Instantiate<GameObject>(Instance.networkManagerObject); val.GetComponent<NetworkObject>().Spawn(false); } } public static bool TeleportPlayer(EntranceTeleport __instance) { //IL_0038: 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) if (!__instance.isEntranceToBuilding) { return true; } IndoorFlood[] array = Object.FindObjectsOfType<IndoorFlood>(); IndoorFlood[] array2 = array; foreach (IndoorFlood indoorFlood in array2) { if (((Behaviour)indoorFlood).enabled && ((Component)indoorFlood).transform.position.y > RoundManager.FindMainEntrancePosition(false, false).y) { HUDManager.Instance.DisplayTip("???", "The entrance appears to be blocked.", false, false, "LC_Tip1"); return false; } } return true; } } public static class PluginInfo { public const string PLUGIN_GUID = "MysteryButton"; public const string PLUGIN_NAME = "MysteryButton"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace MysteryButton.Network { public class MyButtonNetworkManager : NetworkBehaviour { public static MyButtonNetworkManager instance; private void Awake() { instance = this; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected internal override string __getTypeName() { return "MyButtonNetworkManager"; } } } namespace MysteryButton.MonoBehaviors { internal class ButtonItem : PhysicsProp { private Random random; private int bomb; private int flood; private float boomTimer = 0f; public AudioSource mainAudio; public AudioClip beep; public AudioClip detonate; public AudioClip pressed; private Light light; private MeshRenderer innerRenderer; public Material redGlow; public Material blueGlow; public Material defMat; private bool lastLit = true; public bool exploding = false; public PlayerControllerB playerLastHeldBy; public AudioClip beamUpAudio; public AudioClip beamUpAudio2; public AudioClip tpSFX; public AudioClip inverseSFX; private static Random tpSeed; public override void Start() { ((GrabbableObject)this).Start(); random = new Random(StartOfRound.Instance.randomMapSeed); bomb = (int)(Plugin.Instance.bombChance.Value * 10000.0); flood = 0; light = ((Component)this).GetComponentInChildren<Light>(); Transform child = ((Component)this).gameObject.transform.GetChild(0).GetChild(4); innerRenderer = ((Component)child).GetComponent<MeshRenderer>(); defMat = ((Renderer)innerRenderer).GetMaterial(); mainAudio = ((Component)this).gameObject.GetComponent<AudioSource>(); if ((Object)(object)beamUpAudio == (Object)null || (Object)(object)beamUpAudio2 == (Object)null || (Object)(object)tpSFX == (Object)null || (Object)(object)inverseSFX == (Object)null) { try { Plugin.Instance.logger.LogInfo((object)"Grabbing vanilla assets (2)"); ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); beamUpAudio = array[0].beamUpPlayerBodySFX; beamUpAudio2 = array[0].teleporterBeamUpSFX; ShipTeleporter[] array2 = array; foreach (ShipTeleporter val in array2) { if ((Object)(object)tpSFX != (Object)null && (Object)(object)inverseSFX != (Object)null) { break; } if ((Object)(object)tpSFX == (Object)null && !val.isInverseTeleporter) { tpSFX = val.teleporterSpinSFX; } if ((Object)(object)inverseSFX == (Object)null && val.isInverseTeleporter) { inverseSFX = val.teleporterSpinSFX; } } ButtonItem component = Plugin.Instance.buttonItem.spawnPrefab.GetComponent<ButtonItem>(); if ((Object)(object)component.beamUpAudio == (Object)null || (Object)(object)component.beamUpAudio2 == (Object)null || (Object)(object)component.tpSFX == (Object)null || (Object)(object)inverseSFX == (Object)null) { component.beamUpAudio = beamUpAudio; component.beamUpAudio2 = beamUpAudio2; component.tpSFX = tpSFX; component.inverseSFX = inverseSFX; } } catch (Exception ex) { Plugin.Instance.logger.LogError((object)("Encountered error grabbing AudioClips: " + ex.Message)); } } if (!((Object)(object)beep == (Object)null) && !((Object)(object)detonate == (Object)null)) { return; } try { Plugin.Instance.logger.LogInfo((object)"Grabbing vanilla assets (3)"); Landmine componentInChildren = RoundManager.Instance.spawnableMapObjects[0].prefabToSpawn.GetComponentInChildren<Landmine>(); beep = componentInChildren.mineTrigger; detonate = componentInChildren.mineDetonate; ButtonItem component2 = Plugin.Instance.buttonItem.spawnPrefab.GetComponent<ButtonItem>(); if ((Object)(object)component2.beep == (Object)null || (Object)(object)component2.detonate == (Object)null) { component2.beep = componentInChildren.mineTrigger; component2.detonate = componentInChildren.mineDetonate; } } catch (Exception ex2) { Plugin.Instance.logger.LogError((object)("Encountered error grabbing AudioClips: " + ex2.Message)); } } public static void NewSeed() { tpSeed = new Random(StartOfRound.Instance.randomMapSeed + 17 + (int)GameNetworkManager.Instance.localPlayerController.playerClientId); } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).ItemActivate(used, buttonDown); NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) { return; } ((GrabbableObject)this).currentUseCooldown = 3.5f; ulong playerClientId = ((GrabbableObject)this).playerHeldBy.playerClientId; mainAudio.PlayOneShot(pressed); if (!StartOfRound.Instance.inShipPhase) { if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) { ExecuteButtonPressOnServer(playerClientId); } else { RequestButtonPressServerRpc(); } } } public override void Update() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Update(); if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null) { playerLastHeldBy = ((GrabbableObject)this).playerHeldBy; } if (boomTimer > 0f) { boomTimer -= Time.deltaTime; bool flag = Math.Sin(Math.PI * ((double)boomTimer + 0.1) / 0.2) > 0.0; if (flag != lastLit) { if (flag) { ((Renderer)innerRenderer).SetMaterial(redGlow); light.color = Color.red; ((Behaviour)light).enabled = true; } else { ((Renderer)innerRenderer).SetMaterial(defMat); ((Behaviour)light).enabled = false; } } lastLit = flag; } else if (exploding) { Detonate(); Object.Destroy((Object)(object)((Component)this).gameObject); } } public override void OnDestroy() { ((MonoBehaviour)this).StopAllCoroutines(); } public void ExecuteButtonPressOnServer(ulong id) { ((MonoBehaviour)this).StartCoroutine(DecideFunction(id)); } public IEnumerator DecideFunction(ulong id) { yield return (object)new WaitForSeconds(1f); int i = random.Next(10000); if (i < flood) { ExecuteFloodOnServer(); } else if (i < bomb + flood) { ExecuteBombTriggerOnServer(); } else { ExecuteTeleportOnServer(id); } } public void ExecuteTeleportOnServer(ulong id) { ExecuteTeleportClientRpc(Plugin.Instance.leaveScrap.Value, id); } public void ExecuteBombTriggerOnServer() { boomTimer = 1.7f; exploding = true; StartBlinkingClientRpc(); } public void Detonate() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) mainAudio.pitch = Random.Range(0.93f, 1.07f); mainAudio.PlayOneShot(detonate, 1f); Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up, true, 1f, 4.4f); } public void ExecuteFloodOnServer() { if (IndoorFlood.CheckBounds()) { StartFloodClientRpc(); } else { ExecuteErrorOnServer(); } } public void ExecuteErrorOnServer() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Plugin.Instance.logger.LogError((object)$"Flood function can't find the level bounds on: ${((Object)RoundManager.Instance.currentLevel).name}. If this is a custom map, please fill out a bug report with a link to the map. For now, get a prize."); PlayPrizeSoundClientRpc(); GameObject val = Object.Instantiate<GameObject>(GameObject.Find("GoldBar"), ((Component)this).transform.position, Quaternion.identity); ((GrabbableObject)val.GetComponent<PhysicsProp>()).SetScrapValue(210); val.GetComponent<NetworkObject>().Spawn(false); Object.Destroy((Object)(object)((Component)this).gameObject); } [ClientRpc] public void PlayPrizeSoundClientRpc() { //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(662338345u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 662338345u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { mainAudio.PlayOneShot(Object.FindObjectOfType<GiftBoxItem>().openGiftAudio); } } } [ClientRpc] public void StartFloodClientRpc() { //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_00d4: 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(2094321251u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2094321251u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { ((Renderer)innerRenderer).SetMaterial(blueGlow); light.color = Color.cyan; ((Behaviour)light).enabled = true; GameObject val3 = Object.Instantiate<GameObject>(Plugin.Instance.indoorFlooding); val3.SetActive(true); } } } [ServerRpc(RequireOwnership = false)] public void RequestButtonPressServerRpc(ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3887845519u, serverRpcParams, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 3887845519u, serverRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ulong senderClientId = serverRpcParams.Receive.SenderClientId; ExecuteButtonPressOnServer(senderClientId); } } } [ClientRpc] public void StartBlinkingClientRpc() { //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_00f8: 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(357737398u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 357737398u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { boomTimer = 1.7f; exploding = true; mainAudio.PlayOneShot(beep); ((Renderer)innerRenderer).SetMaterial(redGlow); light.color = Color.red; ((Behaviour)light).enabled = true; } } } [ClientRpc] public void ExecuteTeleportClientRpc(bool dropScrap, ulong id) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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(744666155u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref dropScrap, default(ForPrimitives)); BytePacker.WriteValueBitPacked(val2, id); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 744666155u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds; if (((Bounds)(ref bounds)).Contains(((Component)this).transform.position)) { ((MonoBehaviour)this).StartCoroutine(BeamToFactory(dropScrap, id)); } else { ((MonoBehaviour)this).StartCoroutine(BeamToShip(dropScrap, id)); } } } public IEnumerator BeamToFactory(bool dropScrap, ulong id) { PlayerControllerB playerToTp = ((GrabbableObject)this).playerHeldBy; if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) { playerToTp = StartOfRound.Instance.allPlayerObjects[(uint)id].GetComponent<PlayerControllerB>(); } playerToTp.beamOutBuildupParticle.Play(); playerToTp.movementAudio.PlayOneShot(beamUpAudio); mainAudio.PlayOneShot(inverseSFX, 0.6f); yield return (object)new WaitForSeconds(5f); if (!((Object)(object)playerToTp != (Object)null)) { yield break; } Vector3 vector2 = RoundManager.Instance.insideAINodes[tpSeed.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position; vector2 = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(vector2, 10f, default(NavMeshHit), tpSeed, -1); if ((Object)(object)playerToTp.deadBody != (Object)null) { DeadBodyInfo deadBody = playerToTp.deadBody; if ((Object)(object)deadBody != (Object)null) { deadBody.attachedTo = null; deadBody.attachedLimb = null; deadBody.secondaryAttachedLimb = null; deadBody.secondaryAttachedTo = null; if ((Object)(object)deadBody.grabBodyObject != (Object)null && deadBody.grabBodyObject.isHeld && (Object)(object)deadBody.grabBodyObject.playerHeldBy != (Object)null) { deadBody.grabBodyObject.playerHeldBy.DropAllHeldItems(true, false); } deadBody.isInShip = false; deadBody.parentedToShip = false; ((Component)deadBody).transform.SetParent((Transform)null, true); deadBody.SetRagdollPositionSafely(vector2, true); } } else { if (dropScrap) { playerToTp.DropAllHeldItemsExcept((GrabbableObject)(object)this); } playerToTp.isInElevator = false; playerToTp.isInHangarShipRoom = false; playerToTp.isInsideFactory = true; playerToTp.averageVelocity = 0f; playerToTp.velocityLastFrame = Vector3.zero; playerToTp.TeleportPlayer(vector2, false, 0f, false, true); playerToTp.beamOutParticle.Play(); playerToTp.movementAudio.PlayOneShot(beamUpAudio2); if ((Object)(object)playerToTp == (Object)(object)GameNetworkManager.Instance.localPlayerController) { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } } } public IEnumerator BeamToShip(bool dropScrap, ulong id) { PlayerControllerB playerToTp = ((GrabbableObject)this).playerHeldBy; if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) { playerToTp = StartOfRound.Instance.allPlayerObjects[(uint)id].GetComponent<PlayerControllerB>(); } playerToTp.beamUpParticle.Play(); playerToTp.movementAudio.PlayOneShot(beamUpAudio); mainAudio.PlayOneShot(tpSFX, 0.6f); ShipTeleporter[] tpers = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter[] array = tpers; foreach (ShipTeleporter tp2 in array) { if (!tp2.isInverseTeleporter) { tp2.shipTeleporterAudio.PlayOneShot(tp2.teleporterSpinSFX); tp2.teleporterAnimator.SetTrigger("useTeleporter"); tp2.cooldownTime = tp2.cooldownAmount; tp2.buttonTrigger.interactable = false; break; } } yield return (object)new WaitForSeconds(3f); ShipTeleporter tpOptional = null; ShipTeleporter[] tpOptionals = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter[] array2 = tpOptionals; foreach (ShipTeleporter tp in array2) { if (!tp.isInverseTeleporter) { tpOptional = tp; } } Vector3 shipPos = ((!((Object)(object)tpOptional != (Object)null)) ? StartOfRound.Instance.middleOfShipNode.position : tpOptional.teleporterPosition.position); if (!((Object)(object)playerToTp != (Object)null)) { yield break; } if ((Object)(object)playerToTp.deadBody != (Object)null) { if ((Object)(object)playerToTp.deadBody.grabBodyObject == (Object)null || !playerToTp.deadBody.grabBodyObject.isHeldByEnemy) { playerToTp.deadBody.attachedTo = null; playerToTp.deadBody.attachedLimb = null; playerToTp.deadBody.secondaryAttachedLimb = null; playerToTp.deadBody.secondaryAttachedTo = null; playerToTp.deadBody.SetRagdollPositionSafely(shipPos, true); ((Component)playerToTp.deadBody).transform.SetParent(StartOfRound.Instance.elevatorTransform, true); if ((Object)(object)playerToTp.deadBody.grabBodyObject != (Object)null && playerToTp.deadBody.grabBodyObject.isHeld && (Object)(object)playerToTp.deadBody.grabBodyObject.playerHeldBy != (Object)null) { playerToTp.deadBody.grabBodyObject.playerHeldBy.DropAllHeldItems(true, false); } } yield break; } if (dropScrap) { playerToTp.DropAllHeldItemsExcept((GrabbableObject)(object)this); } if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>())) { Object.FindObjectOfType<AudioReverbPresets>().audioPresets[3].ChangeAudioReverbForPlayer(playerToTp); } playerToTp.isInElevator = true; playerToTp.isInHangarShipRoom = true; playerToTp.isInsideFactory = false; playerToTp.averageVelocity = 0f; playerToTp.velocityLastFrame = Vector3.zero; playerToTp.TeleportPlayer(shipPos, true, 160f, false, true); playerToTp.movementAudio.PlayOneShot(beamUpAudio2); if (GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom) { HUDManager.Instance.ShakeCamera((ScreenShakeType)1); } playerToTp.beamUpParticle.Stop(); } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_ButtonItem() { //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(662338345u, new RpcReceiveHandler(__rpc_handler_662338345)); NetworkManager.__rpc_func_table.Add(2094321251u, new RpcReceiveHandler(__rpc_handler_2094321251)); NetworkManager.__rpc_func_table.Add(3887845519u, new RpcReceiveHandler(__rpc_handler_3887845519)); NetworkManager.__rpc_func_table.Add(357737398u, new RpcReceiveHandler(__rpc_handler_357737398)); NetworkManager.__rpc_func_table.Add(744666155u, new RpcReceiveHandler(__rpc_handler_744666155)); } private static void __rpc_handler_662338345(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; ((ButtonItem)(object)target).PlayPrizeSoundClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2094321251(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; ((ButtonItem)(object)target).StartFloodClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3887845519(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((ButtonItem)(object)target).RequestButtonPressServerRpc(server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_357737398(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; ((ButtonItem)(object)target).StartBlinkingClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_744666155(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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool dropScrap = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref dropScrap, default(ForPrimitives)); ulong id = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref id); target.__rpc_exec_stage = (__RpcExecStage)2; ((ButtonItem)(object)target).ExecuteTeleportClientRpc(dropScrap, id); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ButtonItem"; } } public class IndoorFlood : MonoBehaviour { public AudioSource waterAudio; public AudioClip burstSFX; public AudioClip waterRush; public AudioClip warningSFX; public float entranceY; public float factoryBoundsY; public float surfaceBoundsY; public float floodLevel; public float age; public void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = new Vector3(0f, 0f, 0f); age = 0f; } public static bool CheckBounds() { float[] array = FindBounds(); float num = array[0]; float num2 = array[1]; if (float.IsNaN(num) || float.IsNaN(num2) || num == num2) { return false; } return true; } public void OnEnable() { //IL_0035: 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) float[] array = FindBounds(); factoryBoundsY = Mathf.Min(array); surfaceBoundsY = Mathf.Max(array); ((Component)this).transform.position = new Vector3(0f, factoryBoundsY, 0f); entranceY = RoundManager.FindMainEntrancePosition(false, false).y; } public void Start() { ((MonoBehaviour)this).StartCoroutine(PlayEffects()); } private static float[] FindBounds() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) int num = 0; float[] array = new float[2] { float.NaN, float.NaN }; OutOfBoundsTrigger[] array2 = Object.FindObjectsOfType<OutOfBoundsTrigger>(); OutOfBoundsTrigger[] array3 = array2; foreach (OutOfBoundsTrigger val in array3) { if (((Behaviour)val).enabled) { array[num] = ((Component)val).transform.position.y; num++; if (num > 1) { break; } } } return array; } public void OnDisable() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) waterAudio.volume = 0f; floodLevel = 0f; ((Component)this).transform.position = new Vector3(0f, -50f, 0f); } public void Update() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) age += Time.deltaTime; if (!GameNetworkManager.Instance.localPlayerController.isInsideFactory) { waterAudio.volume = 0f; return; } if (age < 46f) { ((Component)this).transform.position = new Vector3(0f, Mathf.Lerp(factoryBoundsY, entranceY + 40f, age / 45f), 0f); } ((Component)waterAudio).transform.position = new Vector3(((Component)GameNetworkManager.Instance.localPlayerController).transform.position.x, ((Component)this).transform.position.y + 3f, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.z); if (Physics.Linecast(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position, ((Component)waterAudio).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { waterAudio.volume = Mathf.Lerp(waterAudio.volume, 0f, 0.5f * Time.deltaTime); } else { waterAudio.volume = Mathf.Lerp(waterAudio.volume, 1f, 0.5f * Time.deltaTime); } } public IEnumerator PlayEffects() { if (GameNetworkManager.Instance.localPlayerController.isInsideFactory) { SoundManager.Instance.PlaySoundAroundLocalPlayer(burstSFX, 1f); } else { SoundManager.Instance.PlaySoundAroundLocalPlayer(burstSFX, 0.2f); } yield return (object)new WaitForSeconds(1f); if (GameNetworkManager.Instance.localPlayerController.isInsideFactory) { HUDManager.Instance.ShakeCamera((ScreenShakeType)3); } else { HUDManager.Instance.ShakeCamera((ScreenShakeType)0); } yield return (object)new WaitForSeconds(2f); HUDManager.Instance.DisplayFloodWarning(); if (!GameNetworkManager.Instance.localPlayerController.isInsideFactory) { } } } } namespace MysteryButton.ExtensionMethod { public static class PlayerControllerExtension { public static void DropAllHeldItemsExcept(this PlayerControllerB pcb, GrabbableObject except, bool itemsFall = true, bool disconnecting = false) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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) for (int i = 0; i < pcb.ItemSlots.Length; i++) { GrabbableObject val = pcb.ItemSlots[i]; if (!((Object)(object)val != (Object)null) || (Object)(object)val == (Object)(object)except) { continue; } if (itemsFall) { val.parentObject = null; val.heldByPlayerOnServer = false; if (pcb.isInElevator) { ((Component)val).transform.SetParent(pcb.playersManager.elevatorTransform, true); } else { ((Component)val).transform.SetParent(pcb.playersManager.propsContainer, true); } pcb.SetItemInElevator(pcb.isInHangarShipRoom, pcb.isInElevator, val); val.EnablePhysics(true); val.EnableItemMeshes(true); ((Component)val).transform.localScale = val.originalScale; val.isHeld = false; val.isPocketed = false; val.startFallingPosition = ((Component)val).transform.parent.InverseTransformPoint(((Component)val).transform.position); val.FallToGround(true); val.fallTime = Random.Range(-0.3f, 0.05f); if (((NetworkBehaviour)pcb).IsOwner) { val.DiscardItemOnClient(); } else if (!val.itemProperties.syncDiscardFunction) { val.playerHeldBy = null; } } if (((NetworkBehaviour)pcb).IsOwner && !disconnecting) { ((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false; ((Behaviour)HUDManager.Instance.itemSlotIcons[i]).enabled = false; HUDManager.Instance.ClearControlTips(); pcb.activatingItem = false; } pcb.ItemSlots[i] = null; } if (pcb.isHoldingObject) { pcb.isHoldingObject = false; if ((Object)(object)pcb.currentlyHeldObjectServer != (Object)null) { pcb.SetSpecialGrabAnimationBool(false, pcb.currentlyHeldObjectServer); } pcb.playerBodyAnimator.SetBool("cancelHolding", true); pcb.playerBodyAnimator.SetTrigger("Throw"); } pcb.activatingItem = false; pcb.twoHanded = false; pcb.carryWeight = 1f; pcb.currentlyHeldObjectServer = null; } } public static class HUDManagerExtension { public static void DisplayFloodWarning(this HUDManager hm) { hm.DisplayTip("Facility is flooding.", "Leave now. You have 45 seconds.", true, false, "LC_Tip1"); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace MysteryButton.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }