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 OpenDoorsInSpace v1.0.2
OpenDoorsInSpacePlugin.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; [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("OpenDoorsInSpacePlugin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c064656b1718db2ee57bb0377fd8a7dc42d3e0cf")] [assembly: AssemblyProduct("OpenDoorsInSpacePlugin")] [assembly: AssemblyTitle("OpenDoorsInSpacePlugin")] [assembly: AssemblyVersion("1.0.0.0")] namespace OpenDoorsInSpacePlugin; internal class EjectPatcher { public static Harmony harmony = new Harmony("EjectPatcher"); [HarmonyPatch(typeof(MonoBehaviour), "StartCoroutine", new Type[] { typeof(IEnumerator) })] [HarmonyPrefix] private static bool StartCoroutine(ref MonoBehaviour __instance) { harmony.UnpatchSelf(); __instance.StartCoroutine(Eject()); return false; } private static IEnumerator Eject() { StartOfRound s = StartOfRound.Instance; bool endGame = OpenDoorsInSpacePlugin.EndGame; s.shipDoorsAnimator.SetBool("OpenInOrbit", true); s.shipDoorAudioSource.PlayOneShot(s.airPressureSFX); s.starSphereObject.SetActive(true); s.starSphereObject.transform.position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position; yield return (object)new WaitForSeconds(0.25f); s.suckingPlayersOutOfShip = true; s.suckingFurnitureOutOfShip = true; PlaceableShipObject[] array = Object.FindObjectsOfType<PlaceableShipObject>(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i].parentObject == (Object)null) { Debug.Log((object)("Error! No parentObject for placeable object: " + s.unlockablesList.unlockables[array[i].unlockableID].unlockableName)); } array[i].parentObject.StartSuckingOutOfShip(); if (s.unlockablesList.unlockables[array[i].unlockableID].spawnPrefab) { Collider[] componentsInChildren = ((Component)array[i].parentObject).GetComponentsInChildren<Collider>(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; } } } GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true; GameNetworkManager.Instance.localPlayerController.DropAllHeldItems(true, false); HUDManager.Instance.UIAudio.PlayOneShot(s.suckedIntoSpaceSFX); yield return (object)new WaitForSeconds(6f); SoundManager.Instance.SetDiageticMixerSnapshot(3, 2f); if (endGame) { HUDManager.Instance.ShowPlayersFiredScreen(true); } yield return (object)new WaitForSeconds(2f); s.starSphereObject.SetActive(false); s.shipDoorAudioSource.Stop(); s.speakerAudioSource.Stop(); s.suckingFurnitureOutOfShip = false; if (((NetworkBehaviour)s).IsServer && endGame) { GameNetworkManager.Instance.ResetSavedGameValues(); Debug.Log((object)"Calling reset ship!"); s.ResetShip(); } if (endGame) { Object.FindObjectOfType<Terminal>().SetItemSales(); } yield return (object)new WaitForSeconds(6f); ((Component)s.shipAnimatorObject).gameObject.GetComponent<Animator>().SetBool("AlarmRinging", false); GameNetworkManager.Instance.localPlayerController.TeleportPlayer(s.playerSpawnPositions[GameNetworkManager.Instance.localPlayerController.playerClientId].position, false, 0f, false, true); s.shipDoorsAnimator.SetBool("OpenInOrbit", false); s.currentPlanetPrefab.transform.position = ((Component)s.planetContainer).transform.position; s.suckingPlayersOutOfShip = false; FieldInfo prop = ((object)s).GetType().GetField("choseRandomFlyDirForPlayer", BindingFlags.Instance | BindingFlags.NonPublic); prop.SetValue(s, false); s.suckingPower = 0f; s.shipRoomLights.SetShipLightsOnLocalClientOnly(true); yield return (object)new WaitForSeconds(2f); if (((NetworkBehaviour)s).IsServer) { FieldInfo prop2 = ((object)s).GetType().GetField("playersRevived", BindingFlags.Instance | BindingFlags.NonPublic); prop2.SetValue(s, (int)prop2.GetValue(s) + 1); yield return (object)new WaitUntil((Func<bool>)(() => (int)prop2.GetValue(s) >= GameNetworkManager.Instance.connectedPlayers)); prop2.SetValue(s, 0); s.EndPlayersFiredSequenceClientRpc(); } else { s.PlayerHasRevivedServerRpc(); } } } internal class FirstDayPatcher { public static Harmony harmony = new Harmony("FistDayPatcher"); [HarmonyPatch(typeof(StartOfRound), "PlayFirstDayShipAnimation")] [HarmonyPrefix] private static bool FirstDay() { harmony.UnpatchSelf(); return false; } } [BepInPlugin("TitaniumTurbine.OpenDoorsInSpace", "OpenDoorsInSpace.Plugin", "1.0.0")] public class OpenDoorsInSpacePlugin : BaseUnityPlugin { public static bool EndGame; private void Awake() { ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EndGameOnEject", false, "Whether to end the game when you open the doors, the same as when you get fired"); EndGame = val.Value; Harmony.CreateAndPatchAll(typeof(OpenDoorsInSpacePlugin), (string)null); } [HarmonyPatch(typeof(HangarShipDoor), "PlayDoorAnimation")] [HarmonyPrefix] private static bool SetDoorsClosed(bool closed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //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) Scene activeScene = SceneManager.GetActiveScene(); HangarShipDoor componentInChildren = ((Scene)(ref activeScene)).GetRootGameObjects().ToList().Find((GameObject x) => ((Object)x).name == "Environment") .GetComponentInChildren<HangarShipDoor>(); activeScene = SceneManager.GetActiveScene(); StartMatchLever componentInChildren2 = ((Scene)(ref activeScene)).GetRootGameObjects().ToList().Find((GameObject x) => ((Object)x).name == "Environment") .GetComponentInChildren<StartMatchLever>(); StartOfRound instance = StartOfRound.Instance; bool flag = TimeOfDay.Instance.quotaFulfilled - TimeOfDay.Instance.profitQuota <= 0 && ((TimeOfDay.Instance.daysUntilDeadline <= 0 && instance.shipIsLeaving) || TimeOfDay.Instance.timeUntilDeadline <= 0f); if (!componentInChildren.buttonsEnabled && !closed && !flag && !componentInChildren2.leverHasBeenPulled) { int daysSpent = instance.gameStats.daysSpent; int scrapValueCollected = instance.gameStats.scrapValueCollected; int deaths = instance.gameStats.deaths; int allStepsTaken = instance.gameStats.allStepsTaken; EjectPatcher.harmony.PatchAll(typeof(EjectPatcher)); if (!EndGame) { FirstDayPatcher.harmony.PatchAll(typeof(FirstDayPatcher)); } instance.ManuallyEjectPlayersServerRpc(); if (!EndGame) { instance.gameStats.daysSpent = daysSpent; instance.gameStats.scrapValueCollected = scrapValueCollected; instance.gameStats.deaths = deaths; instance.gameStats.allStepsTaken = allStepsTaken; } } return true; } }