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 KenjiLib v0.11.3
KenjiLib.dll
Decompiled 20 hours agousing 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using JLL.Components; using KenjiLib.NetcodePatcher; using LethalLevelLoader; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [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("Release")] [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)] [module: NetcodePatchedAssembly] 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.11.0")] public class KenjiLib : BaseUnityPlugin { private const string modGUID = "rectorado.KenjiLib"; private const string modName = "KenjiLib"; public const string ModVersion = "0.11.0"; internal static ManualLogSource mls; private ConfigEntry<LogSeverity> logSeverityConfig; public static KenjiLib Instance { get; private set; } public void Awake() { Instance = this; mls = Logger.CreateLogSource("rectorado.KenjiLib"); logSeverityConfig = ((BaseUnityPlugin)this).Config.Bind<LogSeverity>("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.11.0 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")] [Space(5f)] [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; [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; [Tooltip("Distance from the fire exit where the object will be destroyed")] public int FireExitDistance = 16; private void OnDrawGizmos() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); 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"); } } } public class KEventCounter : NetworkBehaviour { [Header("Event Count")] [Space(5f)] [Tooltip("The number of times the event has to be called to fire.")] [Min(1f)] public int numberOfCalls; public UnityEvent onCountProgress; public UnityEvent onCallCountReached; [Tooltip("When enabled, the event count will reset to 0 after reaching the required number of calls.")] public bool ResetOnCountReached; [Tooltip("When enabled, the event will only be invoked once.")] public bool onlyInvokeOnce = true; private int eventCount; private bool hasInvoked; public void Count() { if (hasInvoked && onlyInvokeOnce) { KLogger.Debug("KEventCounter: Event has already been invoked and onlyInvokeOnce is enabled. Ignoring further calls."); return; } IncrementCountRPC(eventCount + 1); if (eventCount >= numberOfCalls) { KLogger.Debug($"KEventCounter: Event count has reached the required number of calls ({numberOfCalls}). Invoking event."); UnityEvent obj = onCallCountReached; if (obj != null) { obj.Invoke(); } if (ResetOnCountReached) { KLogger.Debug("KEventCounter: Resetting event count to 0."); IncrementCountRPC(0); } if (onlyInvokeOnce) { KLogger.Debug("KEventCounter: Event will only be invoked once. Disabling further invocations."); hasInvoked = true; } } else { UnityEvent obj2 = onCountProgress; if (obj2 != null) { obj2.Invoke(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void IncrementCountRPC(int callsAmount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1181914856u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, callsAmount); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1181914856u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; eventCount = callsAmount; KLogger.Debug($"KEventCounter: Event count incremented to {eventCount}."); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1181914856u, new RpcReceiveHandler(__rpc_handler_1181914856), "IncrementCountRPC"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1181914856(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int callsAmount = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref callsAmount); target.__rpc_exec_stage = (__RpcExecStage)1; ((KEventCounter)(object)target).IncrementCountRPC(callsAmount); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "KEventCounter"; } } internal class KHealingArea : MonoBehaviour { [Header("Healing Area")] [Space(5f)] [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; [Tooltip("Shows a green wireframe sphere around the healing area")] public bool ShowGizmo = true; private float tickTimer; private void OnDrawGizmos() { //IL_0008: 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) if (ShowGizmo) { Gizmos.color = Color.green; Gizmos.DrawWireSphere(((Component)this).gameObject.transform.position, (float)Distance); } } private void Update() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) //IL_0052: 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")] [Space(5f)] [Tooltip("When enabled, helmet condensation will be turned on when looking up.")] public bool onEnable; [Space(3f)] [Tooltip("When enabled, if there's a custom material set up it will apply it.")] [HideInInspector] public bool useCustomMaterial; [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; public void Awake() { if ((Object)(object)HUDManager.Instance != (Object)null) { originalHelmetCondensationMaterial = HUDManager.Instance.helmetCondensationMaterial; originalMaterialStored = true; KLogger.Debug("KHelmetCondensation: Stored original helmet condensation material"); } } public void OnEnable() { if (onEnable) { if (!originalMaterialStored && (Object)(object)HUDManager.Instance != (Object)null) { originalHelmetCondensationMaterial = HUDManager.Instance.helmetCondensationMaterial; originalMaterialStored = true; KLogger.Debug("KHelmetCondensation: Stored original helmet condensation material"); } if (useCustomMaterial) { if ((Object)(object)customHelmetCondensationMaterial != (Object)null && originalMaterialStored) { ApplyCustomHelmetCondensationMaterial(); KLogger.Debug("Custom helmet condensation material applied."); } else { KLogger.Warning("Custom material is not set, using default."); } } KLogger.Debug("KHelmetCondensation: Helmet Condensation is enabled."); Update(); } 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_002d: 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) 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")] [Space(3f)] [Tooltip("Trigger the selected event when this gameobject is enabled.")] [SerializeField] private bool triggerOnEnable; [Tooltip("Select the event to trigger.")] [SerializeField] private OnEnableTrigger LightEvent; [Header("Run after light events")] [Tooltip("If true, the specified Event will be triggered after the light events.")] [SerializeField] private bool triggerAfterLightEvents; [Tooltip("Event to trigger after the light events.")] public UnityEvent afterLightEvents; [Space(5f)] [Header("JLL Appy Event")] [Space(3f)] [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; [Space(3f)] [Header("Extra")] [Tooltip("If true, the permanent power off will also wake the Oldbirds.")] [SerializeField] private bool permanentPowerOffActivatesOldbirds; [Tooltip("If true, the Oldbirds will be awoken when this gameobject is enabled.")] [SerializeField] public bool awakeOldbirdsIfEnabled; 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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<EnemyAINestSpawnObject>((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<EnemyAINestSpawnObject>((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); } } } if (!triggerJLLAppyEvent) { yield break; } try { if (JLevelEventTriggers.EventTriggers != null && JLevelEventTriggers.EventTriggers.Count > 0) { for (int j = 0; j < JLevelEventTriggers.EventTriggers.Count; j++) { JLevelEventTriggers obj = JLevelEventTriggers.EventTriggers[j]; 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<EnemyAINestSpawnObject>((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); } if (!triggerJLLAppyEvent) { continue; } try { if (JLevelEventTriggers.EventTriggers != null && JLevelEventTriggers.EventTriggers.Count > 0) { for (int j = 0; j < JLevelEventTriggers.EventTriggers.Count; j++) { JLevelEventTriggers obj = JLevelEventTriggers.EventTriggers[j]; 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 arg) { KLogger.Error($"Exception while invoking JLL EventTriggers: {arg}"); } } } } public class KLogUnlocker : MonoBehaviour { [Header("Log Unlocker")] [Space(5f)] [Header("StoryLog Unlocker")] public bool EnableStoryLogUnlocker = true; [Tooltip("The ID of the storylog that will be unlocked.")] public int logID; [Tooltip("The name of the moon (without the number) where the ExtendedStoryLog is registered.")] public string levelName; private ExtendedLevel level; [Space(5f)] [Header("Bestiary Entry Unlocker")] [Tooltip("Enable this to ")] public bool EnableBestiaryEntryUnlocker; [Tooltip("The name of the enemy whose bestiary entry will be unlocked.")] public string enemyName; private ExtendedEnemyType enemy; public void Awake() { if (EnableStoryLogUnlocker) { foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (string.Equals(levelName, extendedLevel.NumberlessPlanetName, StringComparison.Ordinal)) { KLogger.Debug("KLogUnlocker: Found level '" + levelName + "' in ExtendedLevels."); level = extendedLevel; break; } } if ((Object)(object)level == (Object)null) { KLogger.Error("KLogUnlocker: Level '" + levelName + "' not found or missing."); return; } foreach (ExtendedStoryLog extendedStoryLog in ((ExtendedContent)level).ExtendedMod.ExtendedStoryLogs) { if (extendedStoryLog.sceneName.Equals(level.SelectableLevel.sceneName, StringComparison.Ordinal) && logID == extendedStoryLog.storyLogID) { KLogger.Debug($"KLogUnlocker: Found story log with ID {logID} in level '{levelName}'."); logID = extendedStoryLog.newStoryLogID; return; } } } if (!EnableBestiaryEntryUnlocker) { return; } foreach (ExtendedEnemyType extendedEnemyType in PatchedContent.ExtendedEnemyTypes) { if (string.Equals(enemyName, extendedEnemyType.EnemyType.enemyName, StringComparison.Ordinal)) { KLogger.Debug($"KLogUnlocker: Found bestiary entry with ID {extendedEnemyType.EnemyID} in enemy '{enemyName}' in ExtendedEnemyTypes."); enemy = extendedEnemyType; break; } } if ((Object)(object)enemy == (Object)null) { KLogger.Error("KLogUnlocker: Enemy '" + enemyName + "' not found or missing."); } } public void UnlockStoryLog() { if (logID <= 0) { KLogger.Error("KLogUnlocker: Log ID is not set or invalid."); return; } HUDManager.Instance.GetNewStoryLogServerRpc(logID); KLogger.Debug($"KLogUnlocker: Log {logID} from {levelName} unlocked."); } public void UnlockBestiaryEntry() { if ((Object)(object)enemy == (Object)null || enemy.EnemyID < 0) { KLogger.Error("KLogUnlocker: Enemy name is not set or invalid. (" + enemyName + ")"); return; } HUDManager.Instance.AttemptScanNewCreature(enemy.EnemyID); KLogger.Debug($"KLogUnlocker: Enemy '{enemyName}' Bestiary Entry with ID '{enemy.EnemyID}' unlocked."); } } internal class KRunOnUpdate : MonoBehaviour { [Header("Run On Update")] [Space(5f)] [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; public float updateFrequency = -1f; [Space(3f)] [Tooltip("The action to execute every frame when enabled.")] public UnityEvent onUpdate; [Space(3f)] [Tooltip("If true, the action will run for `durationSeconds` when `UpdateOnEnable` or `StartDuration` is called.")] public bool runForDuration; [Tooltip("Duration in seconds to run the action when `runForDuration` is true.")] public float durationSeconds; private float _elapsed; private float _remainingDuration; private bool _isRunningDuration; public void UpdateOnEnable() { if (onEnable && onUpdate != null) { KLogger.Debug("Attempting to execute action onUpdate."); if (runForDuration && durationSeconds > 0f) { _isRunningDuration = true; _remainingDuration = durationSeconds; _elapsed = 0f; if (updateFrequency == -1f) { UnityEvent obj = onUpdate; if (obj != null) { obj.Invoke(); } } } else { UnityEvent obj2 = onUpdate; if (obj2 != null) { obj2.Invoke(); } _elapsed = 0f; } } else { KLogger.Warning("The script is disabled or there's no action to execute, skipping."); } } private void Update() { if (!onEnable || onUpdate == null) { return; } if (_isRunningDuration) { if (updateFrequency == -1f) { UnityEvent obj = onUpdate; if (obj != null) { obj.Invoke(); } } else { _elapsed += Time.deltaTime; if (_elapsed >= updateFrequency) { UnityEvent obj2 = onUpdate; if (obj2 != null) { obj2.Invoke(); } _elapsed -= updateFrequency; if (_elapsed < 0f) { _elapsed = 0f; } } } _remainingDuration -= Time.deltaTime; if (_remainingDuration <= 0f) { _isRunningDuration = false; _remainingDuration = 0f; } return; } if (updateFrequency == -1f) { UnityEvent obj3 = onUpdate; if (obj3 != null) { obj3.Invoke(); } return; } _elapsed += Time.deltaTime; if (_elapsed >= updateFrequency) { UnityEvent obj4 = onUpdate; if (obj4 != null) { obj4.Invoke(); } _elapsed -= updateFrequency; if (_elapsed < 0f) { _elapsed = 0f; } } } public void StartDuration(float seconds) { if (seconds <= 0f) { return; } _isRunningDuration = true; _remainingDuration = seconds; _elapsed = 0f; if (updateFrequency == -1f) { UnityEvent obj = onUpdate; if (obj != null) { obj.Invoke(); } } } public void StopDuration() { _isRunningDuration = false; _remainingDuration = 0f; } } public class KSignalCallSender : NetworkBehaviour { [Header("Signal Call Sender")] [Space(5f)] [Tooltip("The ID of the signal that should match the receiver.")] public int signalID; [Space(3f)] [Tooltip("When enabled, it will send the signal a limited number of times.")] public bool sendingLimiter; [Min(1f)] [Tooltip("The maximum number of times the signal can be sent when 'Sending Limiter' is enabled.")] public int maxSends = 1; [Space(3f)] [Tooltip("Event invoked when the signal is sent.")] public UnityEvent onSignalSent; private int sendCount; private bool hasSent; public void SendSignal() { KLogger.Debug($"KSignalCallSender: Attempting to send signal with ID {signalID}."); if (sendingLimiter && hasSent) { KLogger.Debug($"KSignalCallSender: Signal with ID {signalID} has already been sent and 'Sending Limiter' is enabled. Signal will not be sent again."); return; } if (!sendingLimiter || !hasSent) { KLogger.Debug($"KSignalCallSender: Invoking 'onSignalSent' event for signal with ID {signalID}."); UnityEvent obj = onSignalSent; if (obj != null) { obj.Invoke(); } } if (sendingLimiter && !hasSent) { IncrementSignalsSentRPC(sendCount + 1); KLogger.Debug($"KSignalCallSender: 'Sending Limiter' is enabled. Current send count is {sendCount}. Maximum allowed sends is {maxSends}."); } foreach (KSignalCallReceiver receiver in KSignalCallReceiver.Receivers) { if ((Object)(object)receiver != (Object)null) { KLogger.Debug($"KSignalCallSender: Sending signal with ID {signalID} to receiver {((Object)receiver).name}."); receiver.ReceiveSignal(signalID); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void IncrementSignalsSentRPC(int signalsSent) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(445221668u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, signalsSent); ((NetworkBehaviour)this).__endSendRpc(ref val2, 445221668u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; sendCount = signalsSent; if (sendCount >= maxSends) { KLogger.Debug($"KSignalCallSender: Signal with ID {signalID} has reached the maximum send limit of {maxSends}. It will not be sent again."); hasSent = true; } KLogger.Debug($"KSignalCallSender: Number of signals sent is {sendCount}."); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(445221668u, new RpcReceiveHandler(__rpc_handler_445221668), "IncrementSignalsSentRPC"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_445221668(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int signalsSent = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref signalsSent); target.__rpc_exec_stage = (__RpcExecStage)1; ((KSignalCallSender)(object)target).IncrementSignalsSentRPC(signalsSent); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "KSignalCallSender"; } } public class KSignalCallReceiver : NetworkBehaviour { [Header("Signal Call Receiver")] [Space(5f)] [Tooltip("The ID of the signal that should match the sender.")] public int signalID; [Space(3f)] [Tooltip("Event invoked after receiving the matching signal, If 'Require Signal Count' is enabled, this event will be invoked after receiving the required number of matching signals.")] public UnityEvent onSignalReceived; [Space(5f)] [Tooltip("Enable this to limit the number of times the event can be triggered.")] public bool limitEventTriggers; [Min(1f)] [Tooltip("The maximum number of times the event can be triggered when 'Limit Event Triggers' is enabled.")] public int maxTriggers = 1; [Space(5f)] [Tooltip("Enable this to wait for a specific number of matching signals before triggering the event.")] public bool requireSignalCount; [Min(1f)] [Tooltip("Number of matching signals required before triggering the event.")] public int signalsRequired = 1; private int receivedSignalCount; private int eventTriggerCount; public static HashSet<KSignalCallReceiver> Receivers { get; } = new HashSet<KSignalCallReceiver>(); private void OnEnable() { Receivers.Add(this); } private void OnDisable() { Receivers.Remove(this); } public void ReceiveSignal(int senderID) { KLogger.Debug($"KSignalCallReceiver: Received signal with ID {senderID}. Expected signal ID is {signalID}."); if (senderID != signalID) { KLogger.Debug($"KSignalCallReceiver: Signal ID ({senderID}) does not match expected ID ({signalID}). Ignoring signal."); return; } if (!requireSignalCount) { if (limitEventTriggers && eventTriggerCount >= Mathf.Max(1, maxTriggers)) { KLogger.Debug($"KSignalCallReceiver: Event trigger count {eventTriggerCount} exceeds maximum allowed triggers {maxTriggers}. Event will not be invoked."); return; } if (limitEventTriggers) { IncrementTriggersInvokedRPC(eventTriggerCount + 1); KLogger.Debug($"KSignalCallReceiver: Limit event triggers is enabled. Current event trigger count is {eventTriggerCount}/{maxTriggers}."); } KLogger.Debug($"KSignalCallReceiver: Signal ID {senderID} matches expected ID {signalID}. Invoking event."); UnityEvent obj = onSignalReceived; if (obj != null) { obj.Invoke(); } return; } if (limitEventTriggers && eventTriggerCount >= Mathf.Max(1, maxTriggers)) { KLogger.Debug($"KSignalCallReceiver: Event trigger count {eventTriggerCount} exceeds maximum allowed triggers {maxTriggers}. Event will not be invoked."); return; } IncrementReceivedSignalsRPC(receivedSignalCount + 1); KLogger.Debug($"KSignalCallReceiver: Signal ID {senderID} matches expected ID {signalID}. Received signal count is {receivedSignalCount}."); if (receivedSignalCount < Mathf.Max(1, signalsRequired)) { KLogger.Debug($"KSignalCallReceiver: Received signal count {receivedSignalCount} but it is still less than the required ({signalsRequired}). Waiting for more signals."); return; } if (limitEventTriggers) { IncrementTriggersInvokedRPC(eventTriggerCount + 1); KLogger.Debug($"KSignalCallReceiver: Limit event triggers is enabled. Current event trigger count is {eventTriggerCount}/{maxTriggers}."); } KLogger.Debug($"KSignalCallReceiver: Received required signal count {signalsRequired}. Invoking event."); IncrementReceivedSignalsRPC(0); UnityEvent obj2 = onSignalReceived; if (obj2 != null) { obj2.Invoke(); } } [Rpc(/*Could not decode attribute arguments.*/)] public void IncrementTriggersInvokedRPC(int triggersInvoked) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(4194231077u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, triggersInvoked); ((NetworkBehaviour)this).__endSendRpc(ref val2, 4194231077u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; eventTriggerCount = triggersInvoked; KLogger.Debug($"KSignalCallReceiver: Number of triggers invoked is {eventTriggerCount}."); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void IncrementReceivedSignalsRPC(int receivedSignals) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1065333624u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, receivedSignals); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1065333624u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; receivedSignalCount = receivedSignals; KLogger.Debug($"KSignalCallReceiver: Number of received signals is {receivedSignalCount}."); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4194231077u, new RpcReceiveHandler(__rpc_handler_4194231077), "IncrementTriggersInvokedRPC"); ((NetworkBehaviour)this).__registerRpc(1065333624u, new RpcReceiveHandler(__rpc_handler_1065333624), "IncrementReceivedSignalsRPC"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_4194231077(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int triggersInvoked = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref triggersInvoked); target.__rpc_exec_stage = (__RpcExecStage)1; ((KSignalCallReceiver)(object)target).IncrementTriggersInvokedRPC(triggersInvoked); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1065333624(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int receivedSignals = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref receivedSignals); target.__rpc_exec_stage = (__RpcExecStage)1; ((KSignalCallReceiver)(object)target).IncrementReceivedSignalsRPC(receivedSignals); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "KSignalCallReceiver"; } } public class KTriggerCooldownTimer : NetworkBehaviour { [Header("Cooldown Timer")] [Space(5f)] [Tooltip("The InteractTrigger that will be disabled during the cooldown.")] public InteractTrigger targetTrigger; [Tooltip("The amount of time in seconds for the cooldown.")] public float cooldownAmount = 10f; [Tooltip("The text to display during the cooldown.")] public string CooldownText = "Cooldown:"; private float cooldownTime; private void Update() { if (!targetTrigger.interactable) { if (cooldownTime <= 0f) { targetTrigger.interactable = true; return; } targetTrigger.disabledHoverTip = $"[{CooldownText} {(int)cooldownTime} sec.]"; cooldownTime -= Time.deltaTime; } } [Rpc(/*Could not decode attribute arguments.*/)] public void StartCooldownRPC() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { DeferLocal = true }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1697498862u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1697498862u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; cooldownTime = cooldownAmount; targetTrigger.interactable = false; KLogger.Debug($"KTriggerCooldownTimer: Cooldown started for {cooldownAmount} seconds."); KLogger.Kenji("KTriggerCooldownTimer: I REALLY hope this works, because I don't want to have to debug this again."); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void StartCooldownRPC(float amount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { DeferLocal = true }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(102334666u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref amount, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 102334666u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; cooldownTime = amount; targetTrigger.interactable = false; KLogger.Debug($"KTriggerCooldownTimer: Cooldown started for {amount} seconds."); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1697498862u, new RpcReceiveHandler(__rpc_handler_1697498862), "StartCooldownRPC"); ((NetworkBehaviour)this).__registerRpc(102334666u, new RpcReceiveHandler(__rpc_handler_102334666), "StartCooldownRPC"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1697498862(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((KTriggerCooldownTimer)(object)target).StartCooldownRPC(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_102334666(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_0044: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { float amount = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref amount, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((KTriggerCooldownTimer)(object)target).StartCooldownRPC(amount); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "KTriggerCooldownTimer"; } } public class KTriggerInteractableDisabler : NetworkBehaviour { [Header("Trigger Interactable Disabler")] [Space(5f)] [Tooltip("The InteractTrigger that will be disabled/enabled.")] public InteractTrigger targetTrigger; [Rpc(/*Could not decode attribute arguments.*/)] public void DisableTriggerRPC() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { DeferLocal = true }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1827205362u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1827205362u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; targetTrigger.interactable = false; KLogger.Debug("KTriggerInteractableDisabler: Trigger disabled."); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void EnableTriggerRPC() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { DeferLocal = true }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2880911275u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2880911275u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; targetTrigger.interactable = true; KLogger.Debug("KTriggerInteractableDisabler: Trigger enabled."); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1827205362u, new RpcReceiveHandler(__rpc_handler_1827205362), "DisableTriggerRPC"); ((NetworkBehaviour)this).__registerRpc(2880911275u, new RpcReceiveHandler(__rpc_handler_2880911275), "EnableTriggerRPC"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1827205362(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((KTriggerInteractableDisabler)(object)target).DisableTriggerRPC(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2880911275(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((KTriggerInteractableDisabler)(object)target).EnableTriggerRPC(); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "KTriggerInteractableDisabler"; } } internal class KWeatherExtras : MonoBehaviour { public enum WeatherVariablesValues { Custom, WeatherRegistry, Eclipsed, Foggy, Flooded, Stormy } public enum VariableMath { Add, Multiply } [Header("Weather Events")] [Space(5f)] [Header("Eclipse-like Weather event")] [Space(3f)] [Tooltip("When enabled, will mimic an eclipse-like extra enemy spawning.")] public bool EnableCustomEclipse; [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(3f)] [Tooltip("When enabled, will apply a math operation to the weather variable value.")] public bool useVariableModifier; [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(5f)] [Header("Flooded-like Weather object")] [Space(3f)] [Tooltip("When enabled, will mimic the flooded behaviour on a certain gameobject.")] public bool EnableCustomFlooded; [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(5f)] [Header("Stormy Lightnings")] [Space(5f)] [Tooltip("When enabled, will enable lightnings.")] public bool EnableCustomStormy; private string stormyObjectName = "Systems/GameSystems/TimeAndWeather/Stormy"; [Space(3f)] [Header("Custom Variables")] [Tooltip("Weather variable 1 used on the Custom option.")] public int customWeatherVariable1; [Tooltip("Weather variable 2 used on the Custom option.")] public int customWeatherVariable2; public static (int value1, int value2) GetWeatherValuesForLevel(SelectableLevel level, LevelWeatherType levelWeatherType) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Dictionary<LevelWeatherType, (int, int)> dictionary = level.randomWeathers.ToDictionary((RandomWeatherWithVariables randomWeather) => randomWeather.weatherType, (RandomWeatherWithVariables randomWeather) => (weatherVariable: randomWeather.weatherVariable, weatherVariable2: randomWeather.weatherVariable2)); if (!dictionary.ContainsKey(levelWeatherType)) { return (value1: 0, value2: 0); } return dictionary[levelWeatherType]; } private void OnEnable() { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01ff: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_009c: 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<AudioSource>() ?? val2.AddComponent<AudioSource>(); 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_003c: 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) //IL_0052: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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) { KLogger.Warning("KWeatherExtras: customFloodedAudio is null. Ensure that the AudioSource is assigned or created."); 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 KenjiLib.KenjisMoons { public class KMProgressionItemCompat : MonoBehaviour { [Header("Progression Item")] public bool active = true; public bool destroy = true; public string[] progressionMods; private void Start() { bool flag = IsAnyProgressionModLoaded(); if (flag != active) { if (destroy) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { ((Component)this).gameObject.SetActive(false); } } } private bool IsAnyProgressionModLoaded() { if (progressionMods == null) { return false; } foreach (PluginInfo value in Chainloader.PluginInfos.Values) { string[] array = progressionMods; foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text) && string.Equals(value.Metadata.GUID, text, StringComparison.InvariantCultureIgnoreCase)) { return true; } } } return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace KenjiLib.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }