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 EmergencyLeavingKOR v1.0.0
EmergencyTakeoffKOR.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using EmergencyTakeoffKOR.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("RadiationIsCool")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RadiationIsCool")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] 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 EmergencyTakeoffKOR { [BepInPlugin("Piggy.EmergencyTakeoffKOR", "EmergencyTakeoffKOR", "1.0.0")] public class EmergencyTakeoffKORModBase : BaseUnityPlugin { private const string modGUID = "Piggy.EmergencyTakeoffKOR"; private const string modName = "EmergencyTakeoffKOR"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("Piggy.EmergencyTakeoffKOR"); private static EmergencyTakeoffKORModBase Instance; public static ManualLogSource mls; public static int EventProbability; public static float maxProbability; public static float minProbability; public static bool showMessage; public static bool showTimer; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Piggy.EmergencyTakeoffKOR"); mls.LogInfo((object)"Emergency Takeoff Korean is loaded"); EventProbability = ((BaseUnityPlugin)this).Config.Bind<int>("General", "EventProbability", 10, "이벤트가 발생할 확률을 결정합니다. (숫자가 낮을수록 발생 확률도 늘어납니다. 1로 설정하면 무조건 일어납니다.)").Value; maxProbability = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaximumProbabilityIncrease", 0.5f, "확률이 지속적으로 증가하는 최대값입니다. 최소값보다 높아야 합니다.").Value; minProbability = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumProbabilityIncrease", 0.3f, "확률이 지속적으로 증가하는 최소값입니다. 최대값보다 낮아야 합니다.").Value; showMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowTipMessage", false, "활성화되면, 만약 이벤트가 발생할 확률이 있다면 착륙 시 메세지를 표시합니다.").Value; showTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowTimer", true, "좌측 하단에 이륙 타이머를 표시합니다.").Value; StartOfRoundPatch.eventProbability = EventProbability; TimeOfDayPatch.minimumIncrease = minProbability; TimeOfDayPatch.maximumIncrease = maxProbability; StartOfRoundPatch.messageEnabled = showMessage; HUDManagerPatch.isTimerActivated = showTimer; harmony.PatchAll(typeof(EmergencyTakeoffKORModBase)); harmony.PatchAll(typeof(TimeOfDayPatch)); harmony.PatchAll(typeof(StartOfRoundPatch)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(HUDManagerPatch)); harmony.PatchAll(typeof(WalkieTalkiePatch)); harmony.PatchAll(typeof(GameNetworkManagerPatch)); harmony.PatchAll(typeof(EmergencyActivatedBool)); harmony.PatchAll(typeof(EmergencyBool)); } } } namespace EmergencyTakeoffKOR.Patches { public static class EmergencyActivatedBool { public static bool leavingActivated; } public static class EmergencyBool { public static bool canBeLeave; } [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatch { public static float timerFloat; public static float timerFloatPublic; public static string timerString; public static float removeTextTimer; public static int removeTextCount; [HarmonyPrefix] [HarmonyPatch("LeaveCurrentSteamLobby")] private static void LeaveCurrentSteamLobby_PreFix() { //IL_0091: 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) HUDManagerPatch.isTimerActivated = false; EmergencyActivatedBool.leavingActivated = false; EmergencyBool.canBeLeave = false; PlayerControllerBPatch.timerFloat = 60f; PlayerControllerBPatch.timerFloatPublic = 60f; PlayerControllerBPatch.timerString = ""; PlayerControllerBPatch.textFlickered = false; TimeOfDayPatch.randomTriggerTimer = 0f; TimeOfDayPatch.randomTriggerPercentage = 0f; TimeOfDayPatch.randomTriggerCurrentPercentage = 100f; TimeOfDayPatch.isMessaged = false; TimeOfDayPatch.isNotCalled = true; TimeOfDayPatch.normalizedTimeOfDayB = 0f; TimeOfDayPatch.shipLeaveAutomaticallyTimeB = 0f; ((Graphic)GameObject.Find("SprintMeter").GetComponent<Image>()).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)118, (byte)0, byte.MaxValue)); if ((Object)(object)Object.FindAnyObjectByType<ShipTeleporter>() != (Object)null) { ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter[] array2 = array; foreach (ShipTeleporter val in array2) { val.buttonTrigger.interactable = true; } } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch : MonoBehaviour { public static float timerFloat; public static float timerFloatPublic; public static string timerString; public static bool textFlickered; [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_PostFix() { timerFloat = 60f; } [HarmonyPrefix] [HarmonyPatch("Update")] private static void Update_PreFix(ref float ___sprintMeter) { //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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) if (EmergencyActivatedBool.leavingActivated) { ((Component)Object.FindObjectOfType<ShipLights>()).GetComponent<ShipLights>().areLightsOn = false; ((Component)Object.FindObjectOfType<ShipLights>()).GetComponent<ShipLights>().shipLightsAnimator.SetBool("lightsOn", false); ___sprintMeter = 1f; if (timerFloat > 0f) { timerFloat -= Time.deltaTime / 4f; } if (timerFloat < 0f && !textFlickered) { timerFloat = 0f; ((TMP_Text)HUDManagerPatch.TimerTextGUI).text = "<color=red>00:00</color>"; textFlickered = true; } else { timerString = (Mathf.Floor(timerFloat * 100f) / 100f).ToString(); } if (timerFloat >= 10f) { ((TMP_Text)HUDManagerPatch.TimerTextGUI).text = timerString; } else if (!textFlickered && timerFloat > 0f && timerFloat < 10f) { ((TMP_Text)HUDManagerPatch.TimerTextGUI).text = "<color=red>0" + timerString + "</color>"; } if (timerFloat <= 0f) { } ((Graphic)GameObject.Find("SprintMeter").GetComponent<Image>()).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue)); } else { ((Graphic)GameObject.Find("SprintMeter").GetComponent<Image>()).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)118, (byte)0, byte.MaxValue)); } } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { public static TextMeshProUGUI TimerTextGUI; public static bool isTimerActivated; public static bool isTimerEnabled = EmergencyTakeoffKORModBase.showTimer; public static HUDManager hudManager; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void Awake_Postfix(ref HUDManager __instance) { hudManager = __instance; if (GameNetworkManager.Instance.isHostingGame) { SetupHUDTimerRPC(); } } [ClientRpc] public static void SetupHUDTimerRPC() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004b: 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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TimerText"); val.AddComponent<RectTransform>(); TimerTextGUI = val.AddComponent<TextMeshProUGUI>(); RectTransform rectTransform = ((TMP_Text)TimerTextGUI).rectTransform; ((Transform)rectTransform).SetParent(GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD").transform, false); rectTransform.sizeDelta = new Vector2(600f, 200f); rectTransform.anchoredPosition = new Vector2(-60f, -200f); ((Transform)rectTransform).rotation = Quaternion.Euler(19.4f, -11.7f, 0f); ((TMP_Text)TimerTextGUI).alignment = (TextAlignmentOptions)513; ((TMP_Text)TimerTextGUI).font = ((TMP_Text)hudManager.controlTipLines[0]).font; ((TMP_Text)TimerTextGUI).fontSize = 30f; } [HarmonyPrefix] [HarmonyPatch("Update")] private static void Update_Prefix() { if (!isTimerActivated) { ((TMP_Text)TimerTextGUI).text = ""; } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { public static int eventProbability = EmergencyTakeoffKORModBase.EventProbability; public static bool messageEnabled = EmergencyTakeoffKORModBase.showMessage; [HarmonyPrefix] [HarmonyPatch("OnShipLandedMiscEvents")] private static void OnShipLandedMiscEvents_Patch() { if (Random.Range(0, eventProbability) == 0) { EmergencyBool.canBeLeave = true; EmergencyTakeoffKORModBase.mls.LogInfo((object)$"canbeleave"); } else { EmergencyBool.canBeLeave = false; EmergencyTakeoffKORModBase.mls.LogInfo((object)$"cannotbeleave"); } if (EmergencyBool.canBeLeave && GameNetworkManager.Instance.isHostingGame && messageEnabled) { ShipEmergencyTextRPC(); } } public static void ShipEmergencyText() { HUDManager.Instance.DisplayTip("???", "오늘은 무언가 다른 것 같습니다.", false, false, "LC_WhatIsThisThingy"); } [ClientRpc] public static void ShipEmergencyTextRPC() { ShipEmergencyText(); } [HarmonyPrefix] [HarmonyPatch("ShipHasLeft")] private static void ShipHasLeft_Patch() { //IL_0091: 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) HUDManagerPatch.isTimerActivated = false; EmergencyActivatedBool.leavingActivated = false; EmergencyBool.canBeLeave = false; PlayerControllerBPatch.timerFloat = 60f; PlayerControllerBPatch.timerFloatPublic = 60f; PlayerControllerBPatch.timerString = ""; PlayerControllerBPatch.textFlickered = false; TimeOfDayPatch.randomTriggerTimer = 0f; TimeOfDayPatch.randomTriggerPercentage = 0f; TimeOfDayPatch.randomTriggerCurrentPercentage = 100f; TimeOfDayPatch.isMessaged = false; TimeOfDayPatch.isNotCalled = true; TimeOfDayPatch.normalizedTimeOfDayB = 0f; TimeOfDayPatch.shipLeaveAutomaticallyTimeB = 0f; ((Graphic)GameObject.Find("SprintMeter").GetComponent<Image>()).color = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)118, (byte)0, byte.MaxValue)); if ((Object)(object)Object.FindAnyObjectByType<ShipTeleporter>() != (Object)null) { ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter[] array2 = array; foreach (ShipTeleporter val in array2) { val.buttonTrigger.interactable = true; } } } } [HarmonyPatch(typeof(WalkieTalkie))] internal class WalkieTalkiePatch { public static float timerFloat; public static float timerFloatPublic; public static string timerString; public static float removeTextTimer; public static int removeTextCount; [HarmonyPrefix] [HarmonyPatch("TimeAllAudioSources")] private static void TimeAllAudioSources_PreFix() { if (!EmergencyActivatedBool.leavingActivated) { } } [HarmonyPostfix] [HarmonyPatch("Update")] private static void Update_PostFix(ref AudioClip ___playerDieOnWalkieTalkieSFX, ref AudioSource ___thisAudio, ref bool ___isBeingUsed) { if (!EmergencyActivatedBool.leavingActivated) { return; } if (___isBeingUsed) { ___thisAudio.clip = ___playerDieOnWalkieTalkieSFX; ___thisAudio.loop = true; if (!___thisAudio.isPlaying) { ___thisAudio.Play(); } } else { ___thisAudio.loop = false; } } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatch { public static bool isWeathed; public static float randomTriggerTimer; public static float randomTriggerPercentage; public static float randomTriggerCurrentPercentage = 100f; public static bool isMessaged; public static bool isNotCalled; public static float normalizedTimeOfDayB; public static float shipLeaveAutomaticallyTimeB; public static DialogueSegment[] shipLeavingEarlyDialogueB; public static float minimumIncrease = EmergencyTakeoffKORModBase.minProbability; public static float maximumIncrease = EmergencyTakeoffKORModBase.maxProbability; [HarmonyPrefix] [HarmonyPatch("Awake")] private static void Awake_Patch() { randomTriggerPercentage = 0f; randomTriggerCurrentPercentage = 100f; isNotCalled = true; } [HarmonyPrefix] [HarmonyPatch("Start")] private static void Start_Patch(ref DialogueSegment[] ___shipLeavingEarlyDialogue) { ___shipLeavingEarlyDialogue[0].speakerText = "PILOT COMPUTER"; ___shipLeavingEarlyDialogue[0].bodyText = "WARNING!!! A major disaster is expected in the area, and the ship will leave automatically in a moment.\nThe suit has activated emergency mode. Escape immediately."; } [HarmonyPostfix] [HarmonyPatch("Update")] private static void Update_PostFix(ref float ___normalizedTimeOfDay, ref float ___shipLeaveAutomaticallyTime, ref DialogueSegment[] ___shipLeavingEarlyDialogue) { if (___normalizedTimeOfDay >= 0.3355214f && !isMessaged && EmergencyBool.canBeLeave) { randomTriggerTimer += Time.deltaTime; } if (randomTriggerTimer >= 5f && GameNetworkManager.Instance.isHostingGame) { randomTriggerPercentage += Random.Range(minimumIncrease, maximumIncrease); randomTriggerCurrentPercentage = Random.Range(2f, 100f); EmergencyTakeoffKORModBase.mls.LogInfo((object)string.Format("new emergency percentage: " + randomTriggerPercentage)); EmergencyTakeoffKORModBase.mls.LogInfo((object)string.Format("emergency percentage now: " + randomTriggerCurrentPercentage)); if (randomTriggerCurrentPercentage >= randomTriggerPercentage && !isMessaged) { EmergencyTakeoffKORModBase.mls.LogInfo((object)$"emergency leave failed"); } randomTriggerTimer = 0f; if (randomTriggerCurrentPercentage < randomTriggerPercentage && !isMessaged && GameNetworkManager.Instance.isHostingGame) { ShipEmergencyLeaveRPC(); } } normalizedTimeOfDayB = ___normalizedTimeOfDay; shipLeaveAutomaticallyTimeB = ___shipLeaveAutomaticallyTime; shipLeavingEarlyDialogueB = ___shipLeavingEarlyDialogue; if (isNotCalled) { ___shipLeaveAutomaticallyTime = ___normalizedTimeOfDay + 0.0777f; isNotCalled = false; } } [ClientRpc] public static void ShipEmergencyLeaveRPC() { HUDManager.Instance.ReadDialogue(shipLeavingEarlyDialogueB); EmergencyActivatedBool.leavingActivated = true; isMessaged = true; isNotCalled = true; if (HUDManagerPatch.isTimerEnabled) { HUDManagerPatch.isTimerActivated = true; } if ((Object)(object)Object.FindAnyObjectByType<ShipTeleporter>() != (Object)null) { ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter[] array2 = array; foreach (ShipTeleporter val in array2) { val.buttonTrigger.interactable = false; } } ((Component)Object.FindObjectOfType<ShipLights>()).GetComponent<ShipLights>().areLightsOn = false; } } }