using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 JLL.Components; 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: IgnoresAccessChecksTo("JLL")] [assembly: IgnoresAccessChecksTo("JLLItemsModule")] [assembly: IgnoresAccessChecksTo("LethalLevelLoader")] [assembly: IgnoresAccessChecksTo("LethalLevelLoader.Patcher")] [assembly: IgnoresAccessChecksTo("WesleyMoonScripts")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KenjiLib")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("KenjiLib")] [assembly: AssemblyTitle("KenjiLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 KenjiLib { [BepInPlugin("rectorado.KenjiLib", "KenjiLib", "0.7.1")] public class KenjiLib : BaseUnityPlugin { private const string modGUID = "rectorado.KenjiLib"; private const string modName = "KenjiLib"; public const string ModVersion = "0.7.1"; internal static ManualLogSource mls; private ConfigEntry logSeverityConfig; public static KenjiLib Instance { get; private set; } public void Awake() { Instance = this; mls = Logger.CreateLogSource("rectorado.KenjiLib"); logSeverityConfig = ((BaseUnityPlugin)this).Config.Bind("Logging", "Logging Output", LogSeverity.User, "Select maximum log severity to output (ImportantOnly, User, Debug, Kenji)."); KLogger.Init(((BaseUnityPlugin)this).Logger, logSeverityConfig.Value); try { ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogWarning((object)$"KenjiLib: Config loaded. Logging level set to [{logSeverityConfig.Value}]"); KLogger.Kenji("Hi, I hope you like logs."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"KenjiLib: Failed to save config on Awake: {arg}"); } KLogger.Info("KenjiLib v0.7.1 loaded successfully. :3"); logSeverityConfig.SettingChanged += delegate { KLogger.CurrentSeverity = logSeverityConfig.Value; ((BaseUnityPlugin)this).Logger.LogWarning((object)$"KenjiLib: LogSeverity changed to {KLogger.CurrentSeverity}"); }; } } public enum LogSeverity { ImportantOnly, User, Debug, Kenji } public static class KLogger { public static ManualLogSource mls; private static LogSeverity currentSeverity = LogSeverity.User; public static LogSeverity CurrentSeverity { get { return currentSeverity; } set { currentSeverity = value; } } public static void Init(ManualLogSource source, LogSeverity severity) { mls = source; currentSeverity = severity; } public static void Log(LogSeverity severity, string message) { if (mls != null && severity <= currentSeverity) { switch (severity) { case LogSeverity.ImportantOnly: mls.LogError((object)message); mls.LogWarning((object)message); break; case LogSeverity.User: mls.LogInfo((object)("[Info] " + message)); break; case LogSeverity.Debug: mls.LogInfo((object)("[Debug] " + message)); break; case LogSeverity.Kenji: mls.LogWarning((object)("[Kenji] " + message)); break; } } } public static void Error(string message) { Log(LogSeverity.ImportantOnly, message); } public static void Warning(string message) { Log(LogSeverity.ImportantOnly, message); } public static void Info(string message) { Log(LogSeverity.User, message); } public static void Debug(string message) { Log(LogSeverity.Debug, message); } public static void Kenji(string message) { Log(LogSeverity.Kenji, message); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "KenjiLib"; public const string PLUGIN_NAME = "KenjiLib"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace KenjiLib.Scripts { internal class KDestroyAroundShip : MonoBehaviour { private static readonly ManualLogSource mls = Logger.CreateLogSource("KDestroyAroundShip"); [Header("Destroy Around Ship")] [Tooltip("If Enabled, destroy objects around the designated point bellow")] public bool DestroyAroundShip = true; [Tooltip("The position of the ship, can be customized to be any other center point.")] [SerializeField] public Vector3 CheckPosition = new Vector3(0f, 0f, -14f); [Tooltip("The distance from center where objects will be destroyed.")] [SerializeField] public int Distance = 16; [Tooltip("Shows a red sphere around the affected area")] [SerializeField] public bool ShowGizmo = true; [Header("Extra")] [Tooltip("If Enabled, destroy objects around the main entrance")] public bool DestroyAroundMainEntrance = false; [Tooltip("Distance from the main entrance where the object will be destroyed")] public int MainEntranceDistance = 16; [Tooltip("If Enabled, destroy objects around the fire exit")] public bool DestroyAroundFireExit = false; [Tooltip("Distance from the fire exit where the object will be destroyed")] public int FireExitDistance = 16; private void OnDrawGizmos() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (ShowGizmo) { Gizmos.color = Color.red; Gizmos.DrawWireSphere(CheckPosition, (float)Distance); } } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport[] array = Object.FindObjectsOfType(); if (DestroyAroundShip && Vector3.Distance(((Component)this).transform.position, CheckPosition) < (float)Distance) { Object.Destroy((Object)(object)((Component)this).gameObject); KLogger.Debug($"KDestroyAroundShip: Destroyed {((Object)((Component)this).gameObject).name} because it was within {Distance} units of the designated point"); } if (DestroyAroundMainEntrance) { EntranceTeleport val = null; if (array != null && array.Length != 0) { EntranceTeleport[] array2 = array; foreach (EntranceTeleport val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } try { if (val2.entranceId == 0) { val = val2; break; } } catch { } } } if ((Object)(object)val == (Object)null) { KLogger.Error("KDestroyAroundShip: No Main Entrance was found. Skipping."); KLogger.Debug("KDestroyAroundShip: No EntranceTeleport with entranceId == 0 was found. Skipping DestroyAroundMainEntrance."); KLogger.Kenji("This should NOT happen by default on a moon that has a Main Entrance, please check or contact me."); } else { Vector3 position = ((Component)val).transform.position; if (Vector3.Distance(((Component)this).transform.position, position) < (float)MainEntranceDistance) { Object.Destroy((Object)(object)((Component)this).gameObject); KLogger.Info($"KDestroyAroundShip: Destroyed {((Object)((Component)this).gameObject).name} because it was within {MainEntranceDistance} units of the main entrance"); } } } if (!DestroyAroundFireExit) { return; } EntranceTeleport val3 = null; if (array != null && array.Length != 0) { EntranceTeleport[] array3 = array; foreach (EntranceTeleport val4 in array3) { if ((Object)(object)val4 == (Object)null) { continue; } try { if (val4.entranceId != 0) { val3 = val4; break; } } catch { } } } if ((Object)(object)val3 == (Object)null) { KLogger.Warning("KDestroyAroundShip: No Fire Exit were found. Skipping."); KLogger.Debug("KDestroyAroundShip: No EntranceTeleport with entranceId != 0 was found. Skipping DestroyAroundFireExit."); KLogger.Kenji("This is very unlikely to happen if there are Fire Exits on the moon, please check or contact me."); return; } Vector3 position2 = ((Component)val3).transform.position; if (Vector3.Distance(((Component)this).transform.position, position2) < (float)FireExitDistance) { Object.Destroy((Object)(object)((Component)this).gameObject); KLogger.Info($"KDestroyAroundShip: Destroyed {((Object)((Component)this).gameObject).name} because it was within {FireExitDistance} units of a fire exit"); } } } internal class KHealingArea : MonoBehaviour { [Header("Healing Area")] [Tooltip("When active, will heal players within the specified distance.")] public bool IsHealingAreaActive = true; [Space(3f)] [Tooltip("The distance from center where objects will be healed.")] public int Distance = 15; [Tooltip("How much health will be restored per tick.")] public float healRate = 1f; [Tooltip("The time between each healing tick in seconds. At 0, healing will occur every frame.")] public float healTickInterval = 0.5f; private float healAccumulator = 1f; [Space(3f)] [Header("Extras")] [Tooltip("If true, the HUD will flash red like the player was hurt.")] public bool hudUpdateLikeHurting = false; [Tooltip("Shows a green wireframe sphere around the healing area")] public bool ShowGizmo = true; private float tickTimer = 0f; private void OnDrawGizmos() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (ShowGizmo) { Gizmos.color = Color.green; Gizmos.DrawWireSphere(((Component)this).gameObject.transform.position, (float)Distance); } } private void Update() { //IL_0053: 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) //IL_0063: 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) EnsureValidRuntimeValues(); if (!IsHealingAreaActive) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { healAccumulator = 0f; return; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; float num = Distance; if (sqrMagnitude <= num * num) { if (healTickInterval > 0f) { tickTimer += Time.deltaTime; if (tickTimer >= healTickInterval) { UpdatePlayerHealing(val, tickTimer); tickTimer = 0f; } } else { UpdatePlayerHealing(val, Time.deltaTime); } } else { healAccumulator = 0f; tickTimer = 0f; } } private void UpdatePlayerHealing(PlayerControllerB localPlayer, float deltaTime) { if (!IsHealingAreaActive) { return; } if (!localPlayer.isPlayerDead && localPlayer.health < 100) { healAccumulator += healRate * deltaTime; KLogger.Debug($"KHealingArea: Healed player {localPlayer.playerClientId} for {healRate} health."); if (healAccumulator >= 1f) { int num = (int)healAccumulator; healAccumulator -= num; localPlayer.health = Mathf.Min(100, localPlayer.health + num); if (localPlayer.health >= 20 && (localPlayer.criticallyInjured || localPlayer.bleedingHeavily)) { localPlayer.criticallyInjured = false; localPlayer.bleedingHeavily = false; } HUDManager.Instance.UpdateHealthUI(localPlayer.health, hudUpdateLikeHurting); localPlayer.DamagePlayerServerRpc(0, localPlayer.health); } } else { healAccumulator = 0f; } } private void OnValidate() { if (Distance < 0) { KLogger.Warning($"KHealingArea: Negative Distance was set up ({Distance}), clamped to 0."); Distance = 0; } if (healRate < 0f) { KLogger.Warning($"KHealingArea: Negative healRate was set up ({healRate}), clamped to 0."); healRate = 0f; } if (healTickInterval < 0f) { KLogger.Warning($"KHealingArea: Negative healTickInterval was set up ({healTickInterval}), clamped to 0.5."); healTickInterval = 0.5f; } } private void EnsureValidRuntimeValues() { if (Distance < 0) { Distance = 0; } if (healRate < 0f) { healRate = 0f; } if (healTickInterval < 0f) { healTickInterval = 0f; } } } internal class KHelmetCondensation : MonoBehaviour { [Header("Helmet Condensation")] [Tooltip("When enabled, helmet condensation will be turned on when looking up.")] public bool onEnable = false; [Space(3f)] [Tooltip("When enabled, if there's a custom material set up it will apply it.")] [HideInInspector] public bool useCustomMaterial = false; [Tooltip("The custom material to use for the helmet condensation effect, if there's none, the default material will be used.")] [HideInInspector] public Material customHelmetCondensationMaterial; private Material originalHelmetCondensationMaterial; private bool originalMaterialStored = false; public void OnEnable() { if (onEnable) { if (!originalMaterialStored && (Object)(object)HUDManager.Instance != (Object)null) { originalHelmetCondensationMaterial = HUDManager.Instance.helmetCondensationMaterial; originalMaterialStored = true; KLogger.Debug("Stored original helmet condensation material: " + (((Object)(object)originalHelmetCondensationMaterial != (Object)null) ? ((Object)originalHelmetCondensationMaterial).name : "null")); } KLogger.Debug("Helmet Condensation is enabled."); Update(); if (useCustomMaterial) { if ((Object)(object)customHelmetCondensationMaterial != (Object)null) { ApplyCustomHelmetCondensationMaterial(); KLogger.Debug("Custom helmet condensation material applied."); } else { KLogger.Warning("Custom material is not set, using default."); } } } else { KLogger.Info("Helmet Condensation is disabled."); } } private void OnDisable() { if ((Object)(object)HUDManager.Instance != (Object)null) { KLogger.Info("Helmet Condensation is disabled."); if (originalMaterialStored) { HUDManager.Instance.helmetCondensationMaterial = originalHelmetCondensationMaterial; KLogger.Debug("Restored original helmet condensation material."); } } } private void Update() { //IL_0031: 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) if ((Object)(object)HUDManager.Instance != (Object)null && !TimeOfDay.Instance.insideLighting && Vector3.Angle(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward, Vector3.up) < 45f) { HUDManager.Instance.increaseHelmetCondensation = true; } } public void ApplyCustomHelmetCondensationMaterial() { if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)customHelmetCondensationMaterial != (Object)null) { if (!originalMaterialStored) { originalHelmetCondensationMaterial = HUDManager.Instance.helmetCondensationMaterial; originalMaterialStored = true; KLogger.Debug("Stored original helmet condensation material before applying custom one."); } HUDManager.Instance.helmetCondensationMaterial = customHelmetCondensationMaterial; KLogger.Debug("Applied custom helmet condensation material."); } else { KLogger.Warning("Cannot apply custom helmet condensation material."); } } } internal class KHudMessages : MonoBehaviour { [Header("Display Status Effect")] [Tooltip("When called, display a custom status effect.")] [SerializeField] [TextArea(2, 20)] public string customStatusEffectMessage = "VISIBILITY LOW!\n\nSteam leak detected in area"; [Space(3f)] [Header("Display Ship Message")] [Tooltip("When called, display a custom ship message.")] [SerializeField] public DialogueSegment[] customShipMessage; [Space(3f)] [Header("Extra HUD Stuff")] [Tooltip("(NOT WORKING, for now it will always be 10 seconds) When called, display the Gunkfish's slime on the visor this amount of seconds.")] public float customSlimeOnFace = 10f; private string StatusEffectMessageProperty { get { return customStatusEffectMessage; } set { customStatusEffectMessage = value; } } public void displayStatusEffect() { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayStatusEffect(customStatusEffectMessage); KLogger.Debug("Displayed status effect: " + customStatusEffectMessage); } else { KLogger.Warning("Cannot display status effect."); } } public void displayShipMessage() { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.ReadDialogue(customShipMessage); KLogger.Debug($"Displayed ship message: {customShipMessage}"); } else { KLogger.Warning("Cannot display ship message."); } } [ServerRpc(RequireOwnership = false)] public void SlimeOnFaceServerRpc(int playerId) { SlimeOnFaceClientRpc(playerId); } [ClientRpc] public void SlimeOnFaceClientRpc(int playerId) { if (playerId != (int)GameNetworkManager.Instance.localPlayerController.playerClientId) { StartOfRound.Instance.allPlayerScripts[playerId].slimeOnFace = customSlimeOnFace; ((Component)StartOfRound.Instance.allPlayerScripts[playerId].slimeOnFaceDecals[0]).gameObject.SetActive(true); ((Component)StartOfRound.Instance.allPlayerScripts[playerId].slimeOnFaceDecals[1]).gameObject.SetActive(true); KLogger.Debug($"Displayed slime on face for {customSlimeOnFace} seconds."); } else { KLogger.Warning("Cannot display slime on face for local player."); } } public void displaySlimeOnFace() { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplaySpitOnHelmet(); } else { KLogger.Warning("Cannot display slime on face."); } } } public class KLightsEvent : MonoBehaviour { public enum OnEnableTrigger { FlickerLights, PermanentPowerOff, AppyEvent, PowerBackOn } private EnemyType radMechEnemyType; private const bool skipIfAlreadyPoweredOff = true; [Header("Lights Event")] [Tooltip("Trigger the selected event when this gameobject is enabled.")] [SerializeField] private bool triggerOnEnable = false; [Tooltip("Select the event to trigger.")] [SerializeField] private OnEnableTrigger LightEvent = OnEnableTrigger.FlickerLights; [Header("Run after light events")] [Tooltip("If true, the specified Event will be triggered after the light events.")] [SerializeField] private bool triggerAfterLightEvents = false; [Tooltip("Event to trigger after the light events.")] public UnityEvent afterLightEvents; [Space(3f)] [Header("JLL Appy Event")] [Tooltip("Trigger the JLL appy event when Permanent Power Off or Appy Event is triggered. This will only work if JLL is installed.")] [SerializeField] private bool triggerJLLAppyEvent = false; [Space(3f)] [Header("Extra")] [Tooltip("If true, the permanent power off will also wake the Oldbirds.")] [SerializeField] private bool permanentPowerOffActivatesOldbirds = false; [Tooltip("If true, the Oldbirds will be awoken when this gameobject is enabled.")] [SerializeField] public bool awakeOldbirdsIfEnabled = false; private void OnEnable() { if (triggerOnEnable) { switch (LightEvent) { case OnEnableTrigger.FlickerLights: TriggerFlickerLights(); break; case OnEnableTrigger.PermanentPowerOff: TriggerPermanentPowerOffEvent(); break; case OnEnableTrigger.AppyEvent: TriggerAppyEvent(); break; case OnEnableTrigger.PowerBackOn: TriggerPowerBackOn(); break; } } } public void TriggerFlickerLights() { if ((Object)(object)RoundManager.Instance == (Object)null) { KLogger.Error("RoundManager.Instance is null. Cannot trigger Flicker Lights."); return; } RoundManager.Instance.FlickerLights(false, false); KLogger.Debug("Triggered Flicker Lights."); if (triggerAfterLightEvents) { UnityEvent obj = afterLightEvents; if (obj != null) { obj.Invoke(); } } } public void TriggerPermanentPowerOffEvent() { if ((Object)(object)RoundManager.Instance == (Object)null) { KLogger.Error("RoundManager.Instance is null. Cannot trigger Permanent Power Off."); return; } if (RoundManager.Instance.powerOffPermanently) { KLogger.Warning("Permanent Power Off is already active. Skipping trigger."); return; } ((MonoBehaviour)this).StartCoroutine(PermanentPowerOffRoutine()); KLogger.Debug("Triggered Permanent Power Off."); if (triggerAfterLightEvents) { UnityEvent obj = afterLightEvents; if (obj != null) { obj.Invoke(); } } } public void TriggerAppyEvent() { if ((Object)(object)RoundManager.Instance == (Object)null) { KLogger.Error("RoundManager.Instance is null. Cannot trigger Appy Event."); return; } if (RoundManager.Instance.powerOffPermanently) { KLogger.Warning("Permanent Power Off is already active. Skipping Appy Event trigger."); return; } ((MonoBehaviour)this).StartCoroutine(TriggerAppyEventRoutine()); KLogger.Debug("Triggered Appy Event."); if (triggerAfterLightEvents) { UnityEvent obj = afterLightEvents; if (obj != null) { obj.Invoke(); } } } public void TriggerPowerBackOn() { if ((Object)(object)RoundManager.Instance == (Object)null) { KLogger.Error("RoundManager.Instance is null. Cannot trigger Power Back On."); return; } RoundManager.Instance.SwitchPower(true); RoundManager.Instance.powerOffPermanently = false; KLogger.Debug("Triggered Power Back On."); } private void awakeOldbirdsifEnabled() { if (awakeOldbirdsIfEnabled) { awakeOldbirds(); } } public void awakeOldbirds() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RoundManager.Instance == (Object)null) { KLogger.Error("RoundManager.Instance is null. Cannot awake Oldbirds."); } else if (((NetworkBehaviour)RoundManager.Instance).IsServer && (Object)(object)radMechEnemyType != (Object)null) { EnemyAINestSpawnObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i].enemyType == (Object)(object)radMechEnemyType) { RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.outsideAINodes[0].transform.position, 0f, -1, radMechEnemyType); } } } else { KLogger.Warning("Not the server or radMechEnemyType is null. Cannot awake Oldbirds."); } } private IEnumerator PermanentPowerOffRoutine() { RoundManager.Instance.FlickerLights(false, false); yield return (object)new WaitForSeconds(2.5f); RoundManager.Instance.SwitchPower(false); RoundManager.Instance.powerOffPermanently = true; if (permanentPowerOffActivatesOldbirds && ((NetworkBehaviour)RoundManager.Instance).IsServer && (Object)(object)radMechEnemyType != (Object)null) { EnemyAINestSpawnObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int a = 0; a < array.Length; a++) { if ((Object)(object)array[a].enemyType == (Object)(object)radMechEnemyType) { RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.outsideAINodes[0].transform.position, 0f, -1, radMechEnemyType); } } } if (!triggerJLLAppyEvent) { yield break; } try { if (JLevelEventTriggers.EventTriggers != null && JLevelEventTriggers.EventTriggers.Count > 0) { for (int i = 0; i < JLevelEventTriggers.EventTriggers.Count; i++) { JLevelEventTriggers obj = JLevelEventTriggers.EventTriggers[i]; if (obj != null) { obj.InvokeApparatus(); } } KLogger.Debug("Invoked JLL AppyEvent after PermanentPowerOff."); } else { KLogger.Warning("JLevelEventTriggers.EventTriggers is null or empty; nothing to invoke."); } } catch (Exception arg) { KLogger.Error($"Exception while invoking JLL EventTriggers: {arg}"); } } private IEnumerator TriggerAppyEventRoutine() { if (((NetworkBehaviour)RoundManager.Instance).IsServer && Random.Range(0, 100) < 70 && RoundManager.Instance.minEnemiesToSpawn < 2) { RoundManager.Instance.minEnemiesToSpawn = 2; } yield return (object)new WaitForSeconds(1f); RoundManager.Instance.FlickerLights(false, false); yield return (object)new WaitForSeconds(2.5f); RoundManager.Instance.SwitchPower(false); RoundManager.Instance.powerOffPermanently = true; yield return (object)new WaitForSeconds(0.75f); HUDManager.Instance.RadiationWarningHUD(); if (!((NetworkBehaviour)RoundManager.Instance).IsServer || (Object)(object)radMechEnemyType == (Object)null) { yield break; } EnemyAINestSpawnObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); for (int a = 0; a < array.Length; a++) { if ((Object)(object)array[a].enemyType == (Object)(object)radMechEnemyType) { RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.outsideAINodes[0].transform.position, 0f, -1, radMechEnemyType); } if (!triggerJLLAppyEvent) { continue; } try { if (JLevelEventTriggers.EventTriggers != null && JLevelEventTriggers.EventTriggers.Count > 0) { for (int i = 0; i < JLevelEventTriggers.EventTriggers.Count; i++) { JLevelEventTriggers obj = JLevelEventTriggers.EventTriggers[i]; if (obj != null) { obj.InvokeApparatus(); } } KLogger.Debug("Invoked JLLAppyEvent after AppyEvent."); KLogger.Kenji("Naming everything the same thing is a bad idea, but I did it anyway. JLLAppyEvent and AppyEvent are not the same thing, but they have the same name. This is a warning to future me."); } else { KLogger.Warning("JLevelEventTriggers.EventTriggers is null or empty; nothing to invoke."); } } catch (Exception ex) { Exception ex2 = ex; KLogger.Error($"Exception while invoking JLL EventTriggers: {ex2}"); } } } } internal class KRunOnUpdate : MonoBehaviour { [Header("Run On Update")] [Tooltip("When enabled, the specified action will be executed every frame. Please be careful with this action as it may impact performance.")] public bool onEnable = false; [Space(3f)] [Tooltip("The action to execute every frame when enabled.")] public UnityEvent onUpdate; public void UpdateOnEnable() { if (onEnable && onUpdate != null) { KLogger.Debug("Attempting to execute action onUpdate."); Update(); } else { KLogger.Warning("The script is disabled or there's no action to execute, skipping."); } } public void Update() { UnityEvent obj = onUpdate; if (obj != null) { obj.Invoke(); } } } internal class KWeatherExtras : MonoBehaviour { public enum WeatherVariablesValues { Custom, WeatherRegistry, Eclipsed, Foggy, Flooded, Stormy } public enum VariableMath { Add, Multiply } [Header("Eclipse-like Weather event")] [Tooltip("When enabled, will mimic an eclipse-like extra enemy spawning.")] public bool EnableCustomEclipse = false; [Tooltip("The moon's weather variable value used for the extra enemy spawns. WeatherRegistry uses the one set on WeatherRegistry's custom weather options or by default the current weather's variables.")] public WeatherVariablesValues weatherVariablesValuesCustomEclipse = WeatherVariablesValues.Eclipsed; [Space(2f)] [Tooltip("When enabled, will apply a math operation to the weather variable value.")] public bool useVariableModifier = false; [Tooltip("The math operation to apply to the weather variable value.")] public VariableMath variableModifier = VariableMath.Multiply; [Tooltip("The value used by the modifier (added or multiplied).")] public float variableModifierValue = 1f; [Space(3f)] [Header("Flooded-like Weather object")] [Tooltip("When enabled, will mimic the flooded behaviour on a certain gameobject.")] public bool EnableCustomFlooded = false; [Tooltip("The moon's weather variables values used for the gameobjects movement. WeatherRegistry uses the one set on WeatherRegistry's custom weather options or by default the current weather's variables.")] public WeatherVariablesValues weatherVariablesValuesCustomFlooded = WeatherVariablesValues.Flooded; [Tooltip("The gameobject that will be moved when the flooded weather is enabled.")] public GameObject objectToMoveFlooded; [Tooltip("The audio source for the custom flooded weather.")] public AudioSource customFloodedAudio; private float customFloodLevelOffset; [Space(3f)] [Header("Stormy Lightnings")] [Tooltip("When enabled, will enable lightnings.")] public bool EnableCustomStormy = false; private string stormyObjectName = "Systems/GameSystems/TimeAndWeather/Stormy"; [Space(3f)] [Header("Custom Variables")] [Tooltip("Weather variable 1 used on the Custom option.")] public int customWeatherVariable1 = 0; [Tooltip("Weather variable 2 used on the Custom option.")] public int customWeatherVariable2 = 0; public static (int value1, int value2) GetWeatherValuesForLevel(SelectableLevel level, LevelWeatherType levelWeatherType) { //IL_004c: 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) Dictionary dictionary = level.randomWeathers.ToDictionary((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType, (RandomWeatherWithVariables randomWeather) => (weatherVariable: randomWeather.weatherVariable, weatherVariable2: randomWeather.weatherVariable2)); return dictionary.ContainsKey(levelWeatherType) ? dictionary[levelWeatherType] : (value1: 0, value2: 0); } private void OnEnable() { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) try { if (EnableCustomEclipse) { int weatherVariable = GetWeatherVariable(weatherVariablesValuesCustomEclipse); KLogger.Info($"KWeatherExtras: Custom Eclipse enabled. weatherVariable1 gathered from {weatherVariablesValuesCustomEclipse} = {weatherVariable}"); int num = weatherVariable; if (useVariableModifier) { num = ApplyVariableModifier(weatherVariable, variableModifier, variableModifierValue); KLogger.Debug($"KWeatherExtras: Applying modifier {variableModifier} {variableModifierValue} to the base value {weatherVariable}. Total = {num}"); } else { KLogger.Debug($"KWeatherExtras: No variable modifier used. value={weatherVariable}"); } RoundManager.Instance.minOutsideEnemiesToSpawn = num; RoundManager.Instance.minEnemiesToSpawn = num; KLogger.Debug($"KWeatherExtras: Outside enemies to spawn set to {num}"); KLogger.Debug($"KWeatherExtras: Inside enemies to spawn set to {num}"); } if (EnableCustomFlooded) { if ((Object)(object)objectToMoveFlooded == (Object)null) { KLogger.Error("KWeatherExtras: Custom Flooded is enabled but the GameObject to move is missing! Please assign a GameObject."); return; } int weatherVariable2 = GetWeatherVariable(weatherVariablesValuesCustomFlooded); int weatherVariable3 = GetWeatherVariable2(weatherVariablesValuesCustomFlooded); KLogger.Info($"KWeatherExtras: Custom Flooded enabled. weatherVariable1 gathered from {weatherVariablesValuesCustomFlooded} = {weatherVariable2}"); KLogger.Info($"KWeatherExtras: Custom Flooded enabled. weatherVariable2 gathered from {weatherVariablesValuesCustomFlooded} = {weatherVariable3}"); if ((Object)(object)TimeOfDay.Instance != (Object)null) { ((Component)this).transform.position = new Vector3(0f, (float)weatherVariable2, 0f); TimeOfDay.Instance.onTimeSync.AddListener(new UnityAction(OnGlobalTimeSync)); } if ((Object)(object)customFloodedAudio == (Object)null) { EnsureCustomFloodedAudio(); KLogger.Warning($"KWeatherExtras: Custom AudioSource is missing! Created {customFloodedAudio}"); KLogger.Debug($"KWeatherExtras: Created {((Object)((Component)customFloodedAudio).gameObject).name} in {((Component)customFloodedAudio).transform.position}."); KLogger.Kenji("KWeatherExtras: It automatically created an empty AudioSource for it to not error. PLEASE add a custom one to ensure that it works correctly."); } } if (EnableCustomStormy) { KLogger.Info("KWeatherExtras: Custom Stormy enabled. Enabling lightnings."); if ((Object)(object)TimeOfDay.Instance != (Object)null) { InvokeStormyLightnings(); } } } catch (Exception arg) { KLogger.Error($"KWeatherExtras: Error trying to enable - {arg}"); } } private void EnsureCustomFloodedAudio() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)objectToMoveFlooded != (Object)null)) { return; } Transform parent = objectToMoveFlooded.transform.parent; string text = ((Object)objectToMoveFlooded).name + "_FloodAudio"; object obj2; if (!((Object)(object)parent != (Object)null)) { GameObject obj = GameObject.Find(text); obj2 = ((obj != null) ? obj.transform : null); } else { obj2 = parent.Find(text); } Transform val = (Transform)obj2; GameObject val2; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).gameObject; } else { val2 = new GameObject(text); if ((Object)(object)parent != (Object)null) { val2.transform.SetParent(parent); } val2.transform.position = objectToMoveFlooded.transform.position; } AudioSource val3 = val2.GetComponent() ?? val2.AddComponent(); val3.playOnAwake = false; val3.loop = true; val3.spatialBlend = 1f; val3.volume = 0f; customFloodedAudio = val3; } private int ApplyVariableModifier(int baseValue, VariableMath math, float modifier) { switch (math) { case VariableMath.Add: if (modifier < 0f && baseValue + (int)modifier < 0) { KLogger.Warning($"KWeatherExtras: Applying modifier {math} {modifier} would result in a negative value. Clamping to 0."); return 0; } return baseValue + (int)modifier; case VariableMath.Multiply: if (modifier < 0f && (float)baseValue * modifier < 0f) { KLogger.Warning($"KWeatherExtras: Applying modifier {math} {modifier} would result in a negative value. Clamping to 0."); return 0; } return (int)((float)baseValue * modifier); default: return baseValue; } } public void InvokeStormyLightnings() { GameObject val = GameObject.Find(stormyObjectName); if ((Object)(object)val == (Object)null) { KLogger.Warning("KWeatherExtras: No GameObject named '" + stormyObjectName + "' found."); } else if ((Object)(object)val != (Object)null) { val.SetActive(true); KLogger.Debug("KWeatherExtras: Invoked Lightnings."); } } private int GetWeatherVariable(WeatherVariablesValues source) { switch (source) { case WeatherVariablesValues.WeatherRegistry: if ((Object)(object)TimeOfDay.Instance != (Object)null) { try { return (int)TimeOfDay.Instance.currentWeatherVariable; } catch (Exception arg) { KLogger.Error($"KWeatherExtras: Error obtaining WeatherVariable - {arg}"); return 0; } } KLogger.Warning("KWeatherExtras: TimeOfDay.Instance is null. Returning 0 as default value."); return 0; case WeatherVariablesValues.Custom: if ((Object)(object)TimeOfDay.Instance != (Object)null && customWeatherVariable1 >= 0) { return customWeatherVariable1; } KLogger.Error("KWeatherExtras: Error obtaining Custom WeatherVariable 1 or it is negative, defaulting to 0."); return 0; case WeatherVariablesValues.Eclipsed: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)5).value1; } KLogger.Error("KWeatherExtras: Error obtaining Eclipsed WeatherVariable 1, defaulting to 0."); return 0; case WeatherVariablesValues.Foggy: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)3).value1; } KLogger.Error("KWeatherExtras: Error obtaining Foggy WeatherVariable 1, defaulting to 0."); return 0; case WeatherVariablesValues.Flooded: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)4).value1; } KLogger.Error("KWeatherExtras: Error obtaining Flooded WeatherVariable 1, defaulting to 0."); return 0; case WeatherVariablesValues.Stormy: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)2).value1; } KLogger.Error("KWeatherExtras: Error obtaining Stormy WeatherVariable 1, defaulting to 0."); return 0; default: return (int)source; } } private int GetWeatherVariable2(WeatherVariablesValues source) { switch (source) { case WeatherVariablesValues.WeatherRegistry: if ((Object)(object)TimeOfDay.Instance != (Object)null) { try { return (int)TimeOfDay.Instance.currentWeatherVariable2; } catch (Exception arg) { KLogger.Error($"KWeatherExtras: Error obtaining WeatherVariable2 - {arg}"); return 0; } } KLogger.Error("KWeatherExtras: TimeOfDay.Instance is null. Returning 0 as default value."); return 0; case WeatherVariablesValues.Custom: if ((Object)(object)TimeOfDay.Instance != (Object)null && customWeatherVariable2 >= 0) { return customWeatherVariable2; } KLogger.Error("KWeatherExtras: Error obtaining Custom WeatherVariable 2 or it is negative, defaulting to 0."); return 0; case WeatherVariablesValues.Eclipsed: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)5).value2; } KLogger.Error("KWeatherExtras: Error obtaining Eclipsed WeatherVariable 2, defaulting to 0."); return 0; case WeatherVariablesValues.Foggy: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)3).value2; } KLogger.Error("KWeatherExtras: Error obtaining WeatherVariable2."); return 0; case WeatherVariablesValues.Flooded: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)4).value2; } KLogger.Error("KWeatherExtras: Error obtaining Flooded WeatherVariable 2, defaulting to 0."); return 0; case WeatherVariablesValues.Stormy: if ((Object)(object)TimeOfDay.Instance != (Object)null && (Object)(object)TimeOfDay.Instance.currentLevel != (Object)null) { return GetWeatherValuesForLevel(TimeOfDay.Instance.currentLevel, (LevelWeatherType)2).value2; } KLogger.Error("KWeatherExtras: Error obtaining Stormy WeatherVariable 2, defaulting to 0."); return 0; default: return (int)source; } } private void OnDisable() { //IL_0071: 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) //IL_005a: Expected O, but got Unknown if ((Object)(object)customFloodedAudio != (Object)null) { customFloodedAudio.volume = 0f; } customFloodLevelOffset = 0f; if ((Object)(object)TimeOfDay.Instance != (Object)null) { TimeOfDay.Instance.onTimeSync.RemoveListener(new UnityAction(OnGlobalTimeSync)); } ((Component)this).transform.position = new Vector3(0f, -50f, 0f); } private void OnGlobalTimeSync() { int weatherVariable = GetWeatherVariable2(weatherVariablesValuesCustomFlooded); customFloodLevelOffset = Mathf.Clamp(TimeOfDay.Instance.globalTime / 1080f, 0f, 100f) * (float)weatherVariable; } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_011d: 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_014c: Unknown result type (might be due to invalid IL or missing references) int weatherVariable = GetWeatherVariable(weatherVariablesValuesCustomFlooded); int weatherVariable2 = GetWeatherVariable2(weatherVariablesValuesCustomFlooded); if ((Object)(object)TimeOfDay.Instance == (Object)null && EnableCustomFlooded) { return; } ((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, new Vector3(0f, (float)weatherVariable, 0f) + Vector3.up * customFloodLevelOffset, 0.5f * Time.deltaTime); if ((Object)(object)customFloodedAudio == (Object)null) { return; } if (GameNetworkManager.Instance.localPlayerController.isInsideFactory) { customFloodedAudio.volume = 0f; return; } ((Component)customFloodedAudio).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)customFloodedAudio).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { customFloodedAudio.volume = Mathf.Lerp(customFloodedAudio.volume, 0f, 0.5f * Time.deltaTime); } else { customFloodedAudio.volume = Mathf.Lerp(customFloodedAudio.volume, 1f, 0.5f * Time.deltaTime); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }