using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using BasedDecorPlacement.API; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BrutalCompanyMinus; using BrutalCompanyMinus.Minus; using BrutalCompanyMinus.Minus.Handlers.Modded; using Coroner; using CullFactory; using CullFactory.Extenders; using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks.CompilerServices; using Dawn; using GameNetcodeStuff; using HarmonyLib; using HatLib.Tools; using Microsoft.CodeAnalysis; using PathfindingLib.API.SmartPathfinding; using PathfindingLib.Utilities; using TMPro; using TemporalStormWeather.API; using TemporalStormWeather.Compat; using TemporalStormWeather.Compat.BCMERCompat; using TemporalStormWeather.Compat.BCMERCompat.Events.LocustSwarm; using TemporalStormWeather.Compat.BCMERCompat.Events.RusticAllItems; using TemporalStormWeather.Compat.BCMERCompat.Events.TemporalAllItems; using TemporalStormWeather.Compat.BCMERCompat.Events.WorldOfRust; using TemporalStormWeather.Enemies; using TemporalStormWeather.Hazards; using TemporalStormWeather.Items; using TemporalStormWeather.NetcodePatcher; using TemporalStormWeather.Patches; using TemporalStormWeather.TemporalStormManagers; using TemporalStormWeather.TemporalStormManagers.Helpers; using TemporalStormWeather.TemporalStormManagers.RustLightning; using TemporalStormWeather.Unlockables; using TemporalStormWeather.Utils; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.LowLevel; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TemporalStormWeather")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyInformationalVersion("0.0.1")] [assembly: AssemblyProduct("TemporalStormWeather")] [assembly: AssemblyTitle("TemporalStormWeather")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 TemporalStormWeather { internal static class ConfigManager { private static readonly DuskConfigInjector DuskConfig = new DuskConfigInjector("MrHat.TemporalStormWeather"); internal static ConfigEntry TemporalRiftSkipDisabledEnemies { get; private set; } = null; internal static ConfigEntry TemporalRiftRespectEnemyMaxCount { get; private set; } = null; internal static ConfigEntry TemporalRiftUseCurrentMoonEnemyList { get; private set; } = null; internal static ConfigEntry TemporalRiftUnrestrictEnemySpawns { get; private set; } = null; internal static ConfigEntry TemporalRiftLocustOnlyRiftChance { get; private set; } = null; internal static ConfigEntry TemporalRiftMinimumLocustSpawnCount { get; private set; } = null; internal static ConfigEntry TemporalRiftMaximumLocustSpawnCount { get; private set; } = null; internal static ConfigEntry TemporalRiftMinimumEnemyPowerBudget { get; private set; } = null; internal static ConfigEntry TemporalRiftMaximumEnemyPowerBudget { get; private set; } = null; internal static ConfigEntry TemporalRiftInsideEnemyBlacklist { get; private set; } = null; internal static ConfigEntry TemporalRiftOutsideEnemyBlacklist { get; private set; } = null; internal static ConfigEntry EntityGlitchEnabled { get; private set; } = null; internal static ConfigEntry EntityGlitchPlayerModels { get; private set; } = null; internal static ConfigEntry EntityGlitchEnemyBlacklist { get; private set; } = null; internal static ConfigEntry AudioPitchingEnabled { get; private set; } = null; internal static void BindConfigs() { TemporalRiftSkipDisabledEnemies = DuskConfig.Bind("Temporal Rift Options", "Skip disabled enemies", true, "If true, temporal rifts will not spawn enemies marked as spawning disabled"); TemporalRiftRespectEnemyMaxCount = DuskConfig.Bind("Temporal Rift Options", "Respect enemy max count", false, "If true, temporal rifts will not spawn an enemy after its max count allowed on the moon is reached"); TemporalRiftUseCurrentMoonEnemyList = DuskConfig.Bind("Temporal Rift Options", "Use current moon enemy list", true, "If true, temporal rifts can only spawn enemies from the current moon's spawnable enemy lists. This option respects 'Inside/Outside enemy blacklists'"); TemporalRiftUnrestrictEnemySpawns = DuskConfig.Bind("Temporal Rift Options", "Unrestrict enemy spawns", false, "If true and StarlancerAIFix is installed, temporal rifts ignore inside/outside enemy location restrictions. This option respects 'Use current moon enemy list' and 'Inside/Outside enemy blacklists'"); TemporalRiftLocustOnlyRiftChance = DuskConfig.Bind("Temporal Rift Options", "Locust only rift chance", 0.85f, "Chance for a temporal rift to only spawn locust enemies, e.g 0.8 = 85% chance"); TemporalRiftMinimumLocustSpawnCount = DuskConfig.Bind("Temporal Rift Options", "Min locust spawn count", 1, "Minimum number of locusts spawned at once by a locust only rift"); TemporalRiftMaximumLocustSpawnCount = DuskConfig.Bind("Temporal Rift Options", "Max locust spawn count", 3, "Maximum number of locusts spawned at once by a locust only rift"); TemporalRiftMinimumEnemyPowerBudget = DuskConfig.Bind("Temporal Rift Options", "Minimum enemy power budget", 2f, "Minimum enemy power budget assigned to a temporal rift"); TemporalRiftMaximumEnemyPowerBudget = DuskConfig.Bind("Temporal Rift Options", "Maximum enemy power budget", 4f, "Maximum enemy power budget assigned to a temporal rift"); TemporalRiftInsideEnemyBlacklist = DuskConfig.Bind("Temporal Rift Options", "Inside enemy blacklist", "lethal_company:butler_bees,lethal_company:girl", "DawnLib enemy namespaced keys that inside temporal rifts cannot spawn, separated by commas"); TemporalRiftOutsideEnemyBlacklist = DuskConfig.Bind("Temporal Rift Options", "Outside enemy blacklist", "lethal_company:red_locust_bees,lethal_company:manticoil,lethal_company:docile_locust_bees,lethal_company:feiopar,lethal_company:giantkiwi,lethal_company:bush_wolf,lethallib:sparktower,code_rebirth:tornado,code_rebirth:guardsman", "DawnLib enemy namespaced keys that outside temporal rifts cannot spawn, separated by commas"); EntityGlitchEnabled = DuskConfig.Bind("Temporal Storm Visual Options", "Entity Glitch Enabled", true, "If true, temporal instability can apply glitch materials to entities"); EntityGlitchPlayerModels = DuskConfig.Bind("Temporal Storm Visual Options", "Player models glitch", true, "If true, temporal instability can apply glitch materials to other player models"); EntityGlitchEnemyBlacklist = DuskConfig.Bind("Temporal Storm Visual Options", "Enemy Blacklist", "lethal_company:girl,lethal_company:blob,lethal_company:clay_surgeon,surfaced:mantis_shrimp,surfaced:urchin,surfaced:horse,surfaced:scary,lethallib:shrimp,lethallib:sparktower,lethallib:tourist,lethallib:tour_bus,code_rebirth:tornado,code_rebirth:mistress", "DawnLib enemy namespaced keys that cannot receive temporal glitch effects, separated by commas"); AudioPitchingEnabled = DuskConfig.Bind("Temporal Storm Audio Options", "Audio Pitching Enabled", true, "If true, temporal instability can pitch and filter active audio sources"); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("MrHat.TemporalStormWeather.Internals", "TemporalStormWeather", "0.0.1")] internal class Plugin : BaseUnityPlugin { private const string DawnLibGUID = "com.github.teamxiaolan.dawnlib"; private const string DuskGUID = "com.github.teamxiaolan.dawnlib.dusk"; private const string PathfindingLibGUID = "Zaggy1024.PathfindingLib"; private const string HatLibGUID = "MrHat.Lib"; private const string BasedDecorPlacementGUID = "MrHat.BasedDecorPlacement"; private const string CullFactoryGUID = "com.fumiko.CullFactory"; private const string BrutalCompanyMinusExtraRebornGUID = "SoftDiamond.BrutalCompanyMinusExtraReborn"; private const string StarlancerAIFixGUID = "AudioKnight.StarlancerAIFix"; private const string CoronerGUID = "com.elitemastereric.coroner"; internal const string modGUID = "MrHat.TemporalStormWeather.Internals"; internal const string modName = "TemporalStormWeather"; internal const string modVersion = "0.0.1"; internal static ManualLogSource? mls; internal static bool hasBasedDecorPlacement; internal static bool hasCullFactory; internal static bool hasBCMER; internal static bool hasStarlancerAIFix; internal static bool hasCoroner; private readonly Harmony _harmony = new Harmony("MrHat.TemporalStormWeather.Internals"); internal static Plugin? Instance { get; private set; } private void Awake() { //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) Instance = this; mls = Logger.CreateLogSource("MrHat.TemporalStormWeather.Internals"); Log.Info(" +++ +++"); Log.Info(" ++ ++++ ++++ ++"); Log.Info(" +++++ +++++++++++++++ +++++"); Log.Info(" +++++++++++++++++++++++++"); Log.Info(" ++++++++++++++++++++++++++++++++++++++"); Log.Info(" +++++++++++++++++++++++++++++++++++++"); Log.Info(" +++++++++++ ++++ +++++++++++"); Log.Info(" ++++++++++++++ ++++ ++++++++++++++"); Log.Info(" +++++++++++++ ++++ +++++++++++++"); Log.Info(" +++++++++++++ ++++++++ +++++++++++++"); Log.Info(" ++++++++ ++++++++++++++++++++++++ ++++++++"); Log.Info("+++++++++++ +++++++ ++++++ +++++++++++"); Log.Info("+++++++++++ ++++ ++++ +++++++++++"); Log.Info(" +++++++ ++++ ++++ +++++++"); Log.Info(" +++++++ ++++++ ++++++ +++++++"); Log.Info("++++++++++++ ++++++++++++++++++++++++ ++++++++++++"); Log.Info(" ++++++++++++++++ ++++++++ ++++++++++++++++"); Log.Info(" +++++++++ ++++ +++++++++"); Log.Info(" +++++++++++ ++++ ++++++++++"); Log.Info(" +++++++++++++++ ++++ +++++++++++++++"); Log.Info(" +++ ++++++++++++++++++++++++++++++++ +++"); Log.Info(" ++++++++++++++++++++++++++++++"); Log.Info(" ++++++++++++++++++++++++++++++++"); Log.Info(" ++ ++++++++++++++++++ ++"); Log.Info(" ++++ ++++ ++++"); Log.Info(" ++ ++++ ++"); if (!PlayerLoopHelper.IsInjectedUniTaskPlayerLoop()) { PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); PlayerLoopHelper.Initialize(ref currentPlayerLoop, (InjectPlayerLoopTimings)65535); } hasBasedDecorPlacement = Chainloader.PluginInfos.ContainsKey("MrHat.BasedDecorPlacement"); hasCullFactory = Chainloader.PluginInfos.ContainsKey("com.fumiko.CullFactory"); hasBCMER = Chainloader.PluginInfos.ContainsKey("SoftDiamond.BrutalCompanyMinusExtraReborn"); hasStarlancerAIFix = Chainloader.PluginInfos.ContainsKey("AudioKnight.StarlancerAIFix"); hasCoroner = Chainloader.PluginInfos.ContainsKey("com.elitemastereric.coroner"); ConfigManager.BindConfigs(); DawnSaveManager.HookItemEffectSave(); InitialiseNetworkBehaviour(typeof(BellEnemyAI)); InitialiseNetworkBehaviour(typeof(LocustEnemyBase)); InitialiseNetworkBehaviour(typeof(LocustEnemyAI)); InitialiseNetworkBehaviour(typeof(SawbladeLocustEnemyAI)); InitialiseNetworkBehaviour(typeof(CorruptLocustEnemyAI)); InitialiseNetworkBehaviour(typeof(GearPileHazard)); InitialiseNetworkBehaviour(typeof(TemporalRift)); InitialiseNetworkBehaviour(typeof(TemporalGearItem)); InitialiseNetworkBehaviour(typeof(ResonatorSurface)); InitialiseNetworkBehaviour(typeof(RustHazardManager)); InitialiseNetworkBehaviour(typeof(TemporalInstabilityManager)); Log.Info("TemporalStormWeather 0.0.1 loaded"); _harmony.PatchAll(typeof(EnemyAIPatches)); _harmony.PatchAll(typeof(FlashlightItemPatches)); _harmony.PatchAll(typeof(GameNetworkManagerPatches)); _harmony.PatchAll(typeof(GrabbableObjectPatches)); _harmony.PatchAll(typeof(HUDManagerPatches)); _harmony.PatchAll(typeof(LungPropPatches)); _harmony.PatchAll(typeof(NetworkManagerPatches)); _harmony.PatchAll(typeof(PlayerControllerBPatches)); _harmony.PatchAll(typeof(SoundManagerPatches)); _harmony.PatchAll(typeof(StartOfRoundPatches)); _harmony.PatchAll(typeof(ChatGlitchManager)); _harmony.PatchAll(typeof(TimeOfDayPatches)); if (hasBasedDecorPlacement) { Log.Debug("Running BasedDecorPlacement compatibility"); BasedDecorPlacementCompat.RegisterSurfaceExtensions(); Log.Info("BasedDecorPlacement compatibility enabled"); } if (hasCullFactory) { Log.Debug("Running CullFactory compatibility"); _harmony.PatchAll(typeof(CullFactoryCompat)); Log.Info("CullFactory compatibility enabled"); } if (hasBCMER) { Log.Debug("Running Brutal Company Minus Extra Reborn compatibility"); BCMERCompatibility.RegisterEvents(); _harmony.PatchAll(typeof(BCMERCompatibility)); Log.Info("Brutal Company Minus Extra Reborn compatibility enabled"); } if (hasCoroner) { Log.Debug("Running Coroner compatibility"); CoronerCompat.Register(); Log.Info("Coroner compatibility enabled"); } } private void InitialiseNetworkBehaviour(Type type) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TemporalStormWeather"; public const string PLUGIN_NAME = "TemporalStormWeather"; public const string PLUGIN_VERSION = "0.0.1"; } } namespace TemporalStormWeather.Utils { internal static class Keys { public const string DuskGUID = "MrHat.TemporalStormWeather"; public const string AssetBundleName = "temporalstormotherassets"; public const string TemporalInstabilityNetworkPrefabPath = "Assets/LethalCompany/Mods/plugins/TemporalStormWeather/Content/Temporal Storm/TemporalInstabilityNetwork.prefab"; public const string TemporalStormAmbienceLibraryPath = "Assets/LethalCompany/Mods/plugins/TemporalStormWeather/Content/Temporal Storm/TemporalStormAmbienceLibrary.asset"; public const string Namespace = "temporalstorm"; public const string TemporalStorm = "temporal_storm"; public const string TemporalRift = "temporal_rift"; public const string ItemEffects = "item_effects"; public const string GearsPile = "gears_pile"; public const string LargeSpikesPile = "large_spikes_pile"; public const string MediumSpikesPile = "medium_spikes_pile"; public const string SmallSpikesPile = "small_spikes_pile"; public const string SpikesOne = "spikesone"; public const string SpikesTwo = "spikestwo"; public const string SpikesThree = "spikesthree"; public const string TinySpikesPile = "tiny_spikes_pile"; public const string TemporalGear = "temporal_gear"; public const string MadnessGear = "madness_gear"; public const string LocustEnemy = "locust_enemy"; public const string SawbladeLocustEnemy = "sawblade_locust_enemy"; public const string CorruptLocustEnemy = "corrupt_locust_enemy"; public static readonly NamespacedKey TemporalStormWeather = NamespacedKey.From("temporalstorm", "temporal_storm"); public static readonly NamespacedKey TemporalRiftMapObject = NamespacedKey.From("temporalstorm", "temporal_rift"); public static readonly NamespacedKey ItemEffectsSaveData = NamespacedKey.From("temporalstorm", "item_effects"); public static readonly NamespacedKey GearsPileMapObject = NamespacedKey.From("temporalstorm", "gears_pile"); public static readonly NamespacedKey LargeSpikesPileMapObject = NamespacedKey.From("temporalstorm", "large_spikes_pile"); public static readonly NamespacedKey MediumSpikesPileMapObject = NamespacedKey.From("temporalstorm", "medium_spikes_pile"); public static readonly NamespacedKey SmallSpikesPileMapObject = NamespacedKey.From("temporalstorm", "small_spikes_pile"); public static readonly NamespacedKey SpikesOneMapObject = NamespacedKey.From("temporalstorm", "spikesone"); public static readonly NamespacedKey SpikesTwoMapObject = NamespacedKey.From("temporalstorm", "spikestwo"); public static readonly NamespacedKey SpikesThreeMapObject = NamespacedKey.From("temporalstorm", "spikesthree"); public static readonly NamespacedKey TinySpikesPileMapObject = NamespacedKey.From("temporalstorm", "tiny_spikes_pile"); public static readonly NamespacedKey TemporalGearItem = NamespacedKey.From("temporalstorm", "temporal_gear"); public static readonly NamespacedKey MadnessGearItem = NamespacedKey.From("temporalstorm", "madness_gear"); public static readonly NamespacedKey LocustEnemyInfo = NamespacedKey.From("temporalstorm", "locust_enemy"); public static readonly NamespacedKey SawbladeLocustEnemyInfo = NamespacedKey.From("temporalstorm", "sawblade_locust_enemy"); public static readonly NamespacedKey CorruptLocustEnemyInfo = NamespacedKey.From("temporalstorm", "corrupt_locust_enemy"); public static readonly NamespacedKey[] TemporalRustMapObjects = new NamespacedKey[7] { LargeSpikesPileMapObject, MediumSpikesPileMapObject, SmallSpikesPileMapObject, SpikesOneMapObject, SpikesTwoMapObject, SpikesThreeMapObject, TinySpikesPileMapObject }; } internal static class Log { public static void Debug(string message) { Write((LogLevel)32, message); } public static void Info(string message) { Write((LogLevel)16, message); } public static void Warn(string message) { Write((LogLevel)4, message); } public static void Error(string message) { Write((LogLevel)2, message); } public static void Fatal(string message) { Write((LogLevel)1, message); } private static void Write(LogLevel logLevel, string message) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Plugin.mls != null) { Plugin.mls.Log(logLevel, (object)message); } } } internal static class Utility { public static void BindPositionConstraint(PositionConstraint positionConstraint, Transform sourceTransform) { //IL_0015: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (positionConstraint.sourceCount > 0) { ConstraintSource source = positionConstraint.GetSource(0); if (!((Object)(object)((ConstraintSource)(ref source)).sourceTransform == (Object)(object)sourceTransform)) { ((ConstraintSource)(ref source)).sourceTransform = sourceTransform; positionConstraint.SetSource(0, source); } } } public static float ClampInstability(float value) { return Mathf.Clamp(value, 0f, 100f); } public static float InstabilityProgress(float temporalInstabilityLevel, float startLevel, float fullLevel) { return Mathf.InverseLerp(startLevel, fullLevel, temporalInstabilityLevel); } public static bool ShouldRunWeatherLifecycle() { return (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)RoundManager.Instance?.currentLevel != (Object)null && (Object)(object)TimeOfDay.Instance != (Object)null; } public static PlayerControllerB LocalPlayer() { return GameNetworkManager.Instance.localPlayerController; } public static Camera? LocalViewCamera() { PlayerControllerB val = LocalPlayer(); if (val != null && val.isPlayerDead && (Object)(object)StartOfRound.Instance?.spectateCamera != (Object)null) { return StartOfRound.Instance.spectateCamera; } return val?.gameplayCamera; } public static Transform? LocalViewTransform() { Camera? obj = LocalViewCamera(); return (obj != null) ? ((Component)obj).transform : null; } public static bool LocalViewIsInsideFactory() { PlayerControllerB val = LocalPlayer(); if (val != null && val.isPlayerDead && (Object)(object)val.spectatedPlayerScript != (Object)null) { return val.spectatedPlayerScript.isInsideFactory; } return val?.isInsideFactory ?? false; } public static bool IsPlayerActive(PlayerControllerB? player) { return player != null && player.isPlayerControlled && !player.isPlayerDead; } public static float RandomRange(Random random, float minimum, float maximum) { return Mathf.Lerp(minimum, maximum, (float)random.NextDouble()); } public static float RandomRange(Random random, Vector2 range) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return RandomRange(random, range.x, range.y); } } internal static class MapSpawnUtils { public static bool MatchesOutsideFloorTags(Collider collider, string[] spawnableFloorTags) { if (spawnableFloorTags == null || spawnableFloorTags.Length == 0) { return true; } for (int i = 0; i < spawnableFloorTags.Length; i++) { if (((Component)collider).CompareTag(spawnableFloorTags[i])) { return true; } } return false; } public static bool TryRaycastClosest(Vector3 origin, Vector3 direction, RaycastHit[] hits, float maxDistance, int layerMask, QueryTriggerInteraction queryTriggerInteraction, out RaycastHit closestHit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) int num = Physics.RaycastNonAlloc(origin, direction, hits, maxDistance, layerMask, queryTriggerInteraction); float num2 = float.MaxValue; closestHit = default(RaycastHit); for (int i = 0; i < num; i++) { RaycastHit val = hits[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).distance >= num2)) { num2 = ((RaycastHit)(ref val)).distance; closestHit = val; } } return (Object)(object)((RaycastHit)(ref closestHit)).collider != (Object)null; } public static bool IsDeniedOutsidePosition(Vector3 position, float objectWidth, EntranceTeleport[] entranceTeleports, Transform[] shipSpawnPathPoints, GameObject[] spawnDenialPoints, GameObject itemShipLandingNode) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0105: Unknown result type (might be due to invalid IL or missing references) Collider shipBounds = StartOfRound.Instance.shipBounds; if ((Object)(object)shipBounds != (Object)null) { float num = Mathf.Max(0f, objectWidth); Vector3 val = shipBounds.ClosestPoint(position); Vector3 val2 = val - position; if (((Vector3)(ref val2)).sqrMagnitude <= num * num) { return true; } } if (shipSpawnPathPoints != null) { for (int i = 0; i < shipSpawnPathPoints.Length; i++) { if (Vector3.Distance(shipSpawnPathPoints[i].position, position) < objectWidth + 6f) { return true; } } } for (int j = 0; j < entranceTeleports.Length; j++) { if (Vector3.Distance(((Component)entranceTeleports[j]).transform.position, position) < objectWidth + 6f) { return true; } } if (spawnDenialPoints != null) { for (int k = 0; k < spawnDenialPoints.Length; k++) { if (Vector3.Distance(spawnDenialPoints[k].transform.position, position) < objectWidth) { return true; } } } return (Object)(object)itemShipLandingNode != (Object)null && Vector3.Distance(itemShipLandingNode.transform.position, position) < objectWidth; } public static void DestroyTreesAroundOutsideObject(SpawnableOutsideObject spawnableObject, Vector3 position) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) if (!spawnableObject.destroyTrees) { return; } GameObject[] array = GameObject.FindGameObjectsWithTag("Tree"); for (int i = 0; i < array.Length; i++) { if (Vector3.Distance(array[i].transform.position, position) < (float)spawnableObject.objectWidth) { RoundManager.Instance.DestroyTreeAtPosition(array[i].transform.position, 5f); } } } } internal readonly struct OriginalMaterialPropertyIds { public readonly int Texture; public readonly int Color; public readonly int AlphaClipThreshold; public readonly int NormalTexture; public readonly int NormalScale; public readonly int Smoothness; public readonly int Metallic; public OriginalMaterialPropertyIds(int texture, int color, int alphaClipThreshold, int normalTexture, int normalScale, int smoothness, int metallic = -1) { Texture = texture; Color = color; AlphaClipThreshold = alphaClipThreshold; NormalTexture = normalTexture; NormalScale = normalScale; Smoothness = smoothness; Metallic = metallic; } } internal readonly struct EffectMaterialPropertyIds { public readonly int BaseTexture; public readonly int BaseColorTint; public readonly int AlphaClipThreshold; public readonly int NormalTexture; public readonly int NormalScale; public readonly int Smoothness; public readonly int Metallic; public EffectMaterialPropertyIds(int baseTexture, int baseColorTint, int alphaClipThreshold, int normalTexture, int normalScale, int smoothness, int metallic = -1) { BaseTexture = baseTexture; BaseColorTint = baseColorTint; AlphaClipThreshold = alphaClipThreshold; NormalTexture = normalTexture; NormalScale = normalScale; Smoothness = smoothness; Metallic = metallic; } } internal enum MaterialPropertyCopyKind { Float, Color, Texture } internal static class MaterialUtils { private static readonly int alphaCutoffEnablePropertyId = Shader.PropertyToID("_AlphaCutoffEnable"); private static readonly int emissiveColorPropertyId = Shader.PropertyToID("_EmissiveColor"); private static readonly int emissionColorPropertyId = Shader.PropertyToID("_EmissionColor"); private static readonly int surfaceTypePropertyId = Shader.PropertyToID("_SurfaceType"); private static readonly int blendModePropertyId = Shader.PropertyToID("_BlendMode"); private static readonly int zWritePropertyId = Shader.PropertyToID("_ZWrite"); private static readonly int transparentZWritePropertyId = Shader.PropertyToID("_TransparentZWrite"); private static readonly int[] copiedFloatPropertyIds = new int[35] { Shader.PropertyToID("_SurfaceType"), Shader.PropertyToID("_BlendMode"), Shader.PropertyToID("_AlphaSrcBlend"), Shader.PropertyToID("_AlphaDstBlend"), Shader.PropertyToID("_SrcBlend"), Shader.PropertyToID("_DstBlend"), Shader.PropertyToID("_ZWrite"), Shader.PropertyToID("_TransparentZWrite"), Shader.PropertyToID("_ZTest"), Shader.PropertyToID("_CullMode"), Shader.PropertyToID("_CullModeForward"), Shader.PropertyToID("_TransparentCullMode"), Shader.PropertyToID("_AlphaCutoffEnable"), Shader.PropertyToID("_DoubleSidedEnable"), Shader.PropertyToID("_TransparentDepthPrepassEnable"), Shader.PropertyToID("_TransparentDepthPostpassEnable"), Shader.PropertyToID("_TransparentWritesMotionVec"), Shader.PropertyToID("_EnableFogOnTransparent"), Shader.PropertyToID("_ReceivesSSR"), Shader.PropertyToID("_ReceivesSSRTransparent"), Shader.PropertyToID("_TransparentSortPriority"), Shader.PropertyToID("_EnableBlendModePreserveSpecularLighting"), Shader.PropertyToID("_SpecularOcclusionMode"), Shader.PropertyToID("_MaterialID"), Shader.PropertyToID("_DisplacementMode"), Shader.PropertyToID("_RefractionModel"), Shader.PropertyToID("_RefractionSSRayModel"), Shader.PropertyToID("_ReceivesDecals"), Shader.PropertyToID("_GeometricSpecularAA"), Shader.PropertyToID("_UseShadowThreshold"), Shader.PropertyToID("_PreRefractionPass"), Shader.PropertyToID("_RenderingPass"), Shader.PropertyToID("_EmissiveIntensity"), Shader.PropertyToID("_EmissiveExposureWeight"), Shader.PropertyToID("_AlbedoAffectEmissive") }; private static readonly int[] copiedColorPropertyIds = new int[1] { Shader.PropertyToID("_TransmittanceColor") }; private static readonly int[] copiedTexturePropertyIds = new int[7] { Shader.PropertyToID("_MaskMap"), Shader.PropertyToID("_BentNormalMap"), Shader.PropertyToID("_CoatMaskMap"), Shader.PropertyToID("_DetailMap"), Shader.PropertyToID("_EmissiveColorMap"), Shader.PropertyToID("_EmissionMap"), Shader.PropertyToID("_TransmittanceColorMap") }; private static readonly string[] copiedMaterialKeywords = new string[12] { "_ALPHATEST_ON", "_SURFACE_TYPE_TRANSPARENT", "_BLENDMODE_ALPHA", "_BLENDMODE_ADD", "_BLENDMODE_PRE_MULTIPLY", "_BLENDMODE_PRESERVE_SPECULAR_LIGHTING", "_ENABLE_FOG_ON_TRANSPARENT", "_ENABLE_SSR_TRANSPARENT", "_DOUBLESIDED_ON", "_NORMALMAP_TANGENT_SPACE", "_EMISSION", "_EMISSIVE_COLOR_MAP" }; public static bool IsCreatedEffectMaterial(Material? material, Material[]? originalMaterials, int materialIndex) { return (Object)(object)material != (Object)null && (originalMaterials == null || materialIndex >= originalMaterials.Length || (Object)(object)material != (Object)(object)originalMaterials[materialIndex]); } public static float CopyOriginalMaterialProperties(Material originalMaterial, Material effectMaterial, OriginalMaterialPropertyIds originalIds, EffectMaterialPropertyIds effectIds, float defaultAlphaClipThreshold) { //IL_0008: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) effectMaterial.SetColor(effectIds.BaseColorTint, Color.white); float num = defaultAlphaClipThreshold; if ((Object)(object)originalMaterial == (Object)null) { return num; } effectMaterial.renderQueue = originalMaterial.renderQueue; effectMaterial.doubleSidedGI = originalMaterial.doubleSidedGI; effectMaterial.globalIlluminationFlags = originalMaterial.globalIlluminationFlags; effectMaterial.enableInstancing = originalMaterial.enableInstancing; string tag = originalMaterial.GetTag("RenderType", false, string.Empty); if (!string.IsNullOrEmpty(tag)) { effectMaterial.SetOverrideTag("RenderType", tag); } string tag2 = originalMaterial.GetTag("Queue", false, string.Empty); if (!string.IsNullOrEmpty(tag2)) { effectMaterial.SetOverrideTag("Queue", tag2); } for (int i = 0; i < copiedMaterialKeywords.Length; i++) { string text = copiedMaterialKeywords[i]; if (originalMaterial.IsKeywordEnabled(text)) { effectMaterial.EnableKeyword(text); } else { effectMaterial.DisableKeyword(text); } } string[] shaderKeywords = originalMaterial.shaderKeywords; for (int j = 0; j < shaderKeywords.Length; j++) { effectMaterial.EnableKeyword(shaderKeywords[j]); } CopyMatchingProperties(originalMaterial, effectMaterial, copiedFloatPropertyIds, MaterialPropertyCopyKind.Float); CopyMatchingProperties(originalMaterial, effectMaterial, copiedColorPropertyIds, MaterialPropertyCopyKind.Color); CopyMatchingProperties(originalMaterial, effectMaterial, copiedTexturePropertyIds, MaterialPropertyCopyKind.Texture); CopyTextureProperties(originalMaterial, effectMaterial, originalIds.Texture, effectIds.BaseTexture, (Texture?)(object)Texture2D.whiteTexture); bool flag = (originalMaterial.HasProperty(alphaCutoffEnablePropertyId) && originalMaterial.GetFloat(alphaCutoffEnablePropertyId) > 0.5f) || originalMaterial.IsKeywordEnabled("_ALPHATEST_ON"); Color val = (originalMaterial.HasProperty(originalIds.Color) ? originalMaterial.GetColor(originalIds.Color) : Color.white); Color val2 = (originalMaterial.HasProperty(emissiveColorPropertyId) ? originalMaterial.GetColor(emissiveColorPropertyId) : (originalMaterial.HasProperty(emissionColorPropertyId) ? originalMaterial.GetColor(emissionColorPropertyId) : Color.black)); float num2 = val.r * 0.2126f + val.g * 0.7152f + val.b * 0.0722f; float num3 = val2.r * 0.2126f + val2.g * 0.7152f + val2.b * 0.0722f; bool flag2 = num2 <= 0.035f && num3 > 0.035f; if (flag2) { val2.a = val.a; val = val2; } effectMaterial.SetColor(effectIds.BaseColorTint, val); if (originalMaterial.HasProperty(originalIds.AlphaClipThreshold) && effectMaterial.HasProperty(effectIds.AlphaClipThreshold)) { num = (flag ? originalMaterial.GetFloat(originalIds.AlphaClipThreshold) : 0f); effectMaterial.SetFloat(effectIds.AlphaClipThreshold, num); } else if (effectMaterial.HasProperty(effectIds.AlphaClipThreshold)) { num = (flag ? defaultAlphaClipThreshold : 0f); effectMaterial.SetFloat(effectIds.AlphaClipThreshold, num); } if (!flag) { SetFloatIfPresent(effectMaterial, alphaCutoffEnablePropertyId, 0f); effectMaterial.DisableKeyword("_ALPHATEST_ON"); } CopyTextureProperties(originalMaterial, effectMaterial, originalIds.NormalTexture, effectIds.NormalTexture); if (originalMaterial.HasProperty(originalIds.NormalScale) && effectMaterial.HasProperty(effectIds.NormalScale)) { effectMaterial.SetFloat(effectIds.NormalScale, originalMaterial.GetFloat(originalIds.NormalScale)); } if (originalMaterial.HasProperty(originalIds.Smoothness) && effectMaterial.HasProperty(effectIds.Smoothness)) { effectMaterial.SetFloat(effectIds.Smoothness, flag2 ? 0.045f : originalMaterial.GetFloat(originalIds.Smoothness)); } if (originalIds.Metallic >= 0 && effectIds.Metallic >= 0 && originalMaterial.HasProperty(originalIds.Metallic) && effectMaterial.HasProperty(effectIds.Metallic)) { effectMaterial.SetFloat(effectIds.Metallic, flag2 ? 0f : originalMaterial.GetFloat(originalIds.Metallic)); } return num; } public static void ForceOpaqueCutout(Material material) { material.renderQueue = 2450; material.SetOverrideTag("RenderType", "TransparentCutout"); material.SetOverrideTag("Queue", "AlphaTest"); material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.DisableKeyword("_BLENDMODE_ALPHA"); material.DisableKeyword("_BLENDMODE_ADD"); material.DisableKeyword("_BLENDMODE_PRE_MULTIPLY"); SetFloatIfPresent(material, surfaceTypePropertyId, 0f); SetFloatIfPresent(material, blendModePropertyId, 0f); SetFloatIfPresent(material, zWritePropertyId, 1f); SetFloatIfPresent(material, transparentZWritePropertyId, 1f); } public static void DestroyMaterials(Material[]? materials, Material[]? originalMaterials = null) { if (materials == null) { return; } for (int i = 0; i < materials.Length; i++) { Material val = materials[i]; if (IsCreatedEffectMaterial(val, originalMaterials, i)) { Object.Destroy((Object)(object)val); } } } public static void SetFloatOnCreatedMaterials(Material[]? materials, Material[]? originalMaterials, int propertyId, float value) { if (materials == null) { return; } for (int i = 0; i < materials.Length; i++) { Material val = materials[i]; if (IsCreatedEffectMaterial(val, originalMaterials, i)) { val.SetFloat(propertyId, value); } } } public static void CopyFromFirstProperty(Material? sourceMaterial, Material targetMaterial, int[] sourcePropertyIds, int targetPropertyId, MaterialPropertyCopyKind propertyKind, Texture? defaultTexture = null) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (!targetMaterial.HasProperty(targetPropertyId)) { return; } if ((Object)(object)sourceMaterial != (Object)null) { foreach (int num in sourcePropertyIds) { if (!sourceMaterial.HasProperty(num)) { continue; } switch (propertyKind) { case MaterialPropertyCopyKind.Float: targetMaterial.SetFloat(targetPropertyId, sourceMaterial.GetFloat(num)); return; case MaterialPropertyCopyKind.Color: targetMaterial.SetColor(targetPropertyId, sourceMaterial.GetColor(num)); return; case MaterialPropertyCopyKind.Texture: { Texture texture = sourceMaterial.GetTexture(num); if ((Object)(object)texture == (Object)null) { break; } targetMaterial.SetTexture(targetPropertyId, texture); targetMaterial.SetTextureScale(targetPropertyId, sourceMaterial.GetTextureScale(num)); targetMaterial.SetTextureOffset(targetPropertyId, sourceMaterial.GetTextureOffset(num)); return; } } } } if (propertyKind == MaterialPropertyCopyKind.Texture && (Object)(object)defaultTexture != (Object)null) { targetMaterial.SetTexture(targetPropertyId, defaultTexture); } } private static void CopyTextureProperties(Material originalMaterial, Material effectMaterial, int originalPropertyId, int effectPropertyId, Texture? defaultTexture = null) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!effectMaterial.HasProperty(effectPropertyId)) { return; } Texture val = (originalMaterial.HasProperty(originalPropertyId) ? originalMaterial.GetTexture(originalPropertyId) : null); if (!((Object)(object)val == (Object)null) || !((Object)(object)defaultTexture == (Object)null)) { effectMaterial.SetTexture(effectPropertyId, val ?? defaultTexture); if (originalMaterial.HasProperty(originalPropertyId)) { effectMaterial.SetTextureScale(effectPropertyId, originalMaterial.GetTextureScale(originalPropertyId)); effectMaterial.SetTextureOffset(effectPropertyId, originalMaterial.GetTextureOffset(originalPropertyId)); } } } private static void SetFloatIfPresent(Material material, int propertyId, float value) { if (material.HasProperty(propertyId)) { material.SetFloat(propertyId, value); } } private static void CopyMatchingProperties(Material originalMaterial, Material effectMaterial, int[] propertyIds, MaterialPropertyCopyKind propertyKind) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) foreach (int num in propertyIds) { if (!originalMaterial.HasProperty(num) || !effectMaterial.HasProperty(num)) { continue; } switch (propertyKind) { case MaterialPropertyCopyKind.Float: effectMaterial.SetFloat(num, originalMaterial.GetFloat(num)); break; case MaterialPropertyCopyKind.Color: effectMaterial.SetColor(num, originalMaterial.GetColor(num)); break; case MaterialPropertyCopyKind.Texture: { Texture texture = originalMaterial.GetTexture(num); if (!((Object)(object)texture == (Object)null)) { effectMaterial.SetTexture(num, texture); effectMaterial.SetTextureScale(num, originalMaterial.GetTextureScale(num)); effectMaterial.SetTextureOffset(num, originalMaterial.GetTextureOffset(num)); } break; } } } } } internal static class ParticleUtils { public static void SetEmissionRateAndPlayback(ParticleSystem particleSystem, float rate, ParticleSystemStopBehavior stopBehavior) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) EmissionModule emission = particleSystem.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate); if (rate > 0.001f) { if (!particleSystem.isPlaying) { particleSystem.Play(true); } } else if (particleSystem.isPlaying) { particleSystem.Stop(true, stopBehavior); } } } internal enum DawnItemPersistenceMode { PersistShip, Restore } internal static class DawnConfigUtils { public static HashSet> ParseNamespacedKeySet(string configuredKeys) where TInfo : INamespaced { HashSet> hashSet = new HashSet>(); if (string.IsNullOrWhiteSpace(configuredKeys)) { return hashSet; } string[] array = configuredKeys.Split(new char[4] { ',', ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); NamespacedKey val = default(NamespacedKey); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (NamespacedKey.TryParse(text, ref val)) { hashSet.Add(val.AsTyped()); } } return hashSet; } public static bool CanUseDawnItem(GrabbableObject item, bool includeNonConductive, DawnItemPersistenceMode persistenceMode) { return (Object)(object)item?.itemProperties != (Object)null && (item.itemProperties.isConductiveMetal || includeNonConductive) && (Object)(object)((Component)item).GetComponent() == (Object)null && ItemExtensions.GetDawnInfo(item.itemProperties) != null && (persistenceMode != DawnItemPersistenceMode.PersistShip || item.isInShipRoom) && !item.isHeld && (Object)(object)item.playerHeldBy == (Object)null && !item.isHeldByEnemy; } } internal static class ItemUtils { public static bool IsHeldByLocalPlayer(GrabbableObject item) { return (Object)(object)item?.playerHeldBy != (Object)null && (Object)(object)item.playerHeldBy == (Object)(object)Utility.LocalPlayer(); } public static uint BuildItemSeed(GrabbableObject item) { ulong networkObjectId = ((NetworkBehaviour)item).NetworkObject.NetworkObjectId; uint num = 2166136261u; num = (num ^ (uint)(int)networkObjectId) * 16777619; num = (num ^ (uint)(int)(networkObjectId >> 32)) * 16777619; return (num ^ (uint)item.itemProperties.itemId) * 16777619; } public static uint Mix(uint value) { value ^= value >> 16; value *= 2246822519u; value ^= value >> 13; value *= 3266489917u; value ^= value >> 16; return value; } } internal static class TemporalMaterialUtils { public static void SetTemporalState(Renderer renderer, MaterialPropertyBlock propertyBlock, float glowStrength, float rustAmount) { renderer.GetPropertyBlock(propertyBlock); propertyBlock.SetFloat("_TemporalGlowStrength", glowStrength); propertyBlock.SetFloat("_TemporalRustAmount", rustAmount); renderer.SetPropertyBlock(propertyBlock); } } internal static class NetworkUtils { public static bool IsServer() { NetworkManager singleton = NetworkManager.Singleton; return singleton != null && singleton.IsServer; } public static bool IsServerOrNotNetworked() { NetworkManager singleton = NetworkManager.Singleton; return !singleton.IsListening || singleton.IsServer; } } internal static class AudioUtils { public static bool Configure2DAudioSource(AudioSource? audioSource, bool loop, float volume = 0f) { if ((Object)(object)audioSource == (Object)null) { return false; } audioSource.spatialBlend = 0f; audioSource.loop = loop; audioSource.playOnAwake = false; audioSource.volume = volume; return true; } public static void PlayOneShot(AudioSource? audioSource, AudioClip? audioClip, float volume) { if (!((Object)(object)audioSource == (Object)null) && !((Object)(object)audioClip == (Object)null)) { audioSource.PlayOneShot(audioClip, volume); } } public static void LoadAudioClips(params AudioClip?[] audioClips) { int num = 0; foreach (AudioClip val in audioClips) { if (AudioTools.Load(val)) { num++; } } if (num > 0) { Log.Info($"Loaded {num} audio clips"); } } public static void UnloadAudioClips(params AudioClip?[] audioClips) { int num = 0; foreach (AudioClip val in audioClips) { if (AudioTools.Unload(val)) { num++; } } if (num > 0) { Log.Info($"Unloaded {num} audio clips"); } } } internal static class WeatherUtils { public static bool IsTemporalStormWeatherSelectedOrActive(bool checkSelected = true, bool checkActive = true) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected I4, but got Unknown if ((Object)(object)TimeOfDay.Instance == (Object)null || (!checkSelected && !checkActive)) { return false; } if (checkSelected) { SelectableLevel currentLevel = TimeOfDay.Instance.currentLevel; if ((Object)(object)currentLevel == (Object)null && (Object)(object)RoundManager.Instance != (Object)null) { currentLevel = RoundManager.Instance.currentLevel; } if ((Object)(object)currentLevel != (Object)null) { int num = (int)currentLevel.currentWeather; if (num >= 0 && num < TimeOfDay.Instance.effects.Length) { WeatherEffect val = TimeOfDay.Instance.effects[num]; GameObject effectObject = val.effectObject; GameObject effectPermanentObject = val.effectPermanentObject; if ((Object)(object)((effectObject != null) ? effectObject.GetComponentInChildren(true) : null) != (Object)null || (Object)(object)((effectPermanentObject != null) ? effectPermanentObject.GetComponentInChildren(true) : null) != (Object)null) { return true; } } } } if (!checkActive) { return false; } for (int i = 0; i < TimeOfDay.Instance.effects.Length; i++) { WeatherEffect val2 = TimeOfDay.Instance.effects[i]; GameObject effectObject2 = val2.effectObject; GameObject effectPermanentObject2 = val2.effectPermanentObject; if ((val2.effectEnabled || (effectObject2 != null && effectObject2.activeInHierarchy) || (effectPermanentObject2 != null && effectPermanentObject2.activeInHierarchy)) && ((Object)(object)((effectObject2 != null) ? effectObject2.GetComponentInChildren(true) : null) != (Object)null || (Object)(object)((effectPermanentObject2 != null) ? effectPermanentObject2.GetComponentInChildren(true) : null) != (Object)null)) { return true; } } return false; } } } namespace TemporalStormWeather.Unlockables { public class ResonatorSurface : PlaceableObjectsSurface { private static readonly WaitForSeconds PlaceCheckWait = new WaitForSeconds(0.1f); private const float RestoreSearchRadius = 12f; [Header("Cylinder")] [SerializeField] private Transform cylinderPlacement = null; [SerializeField] private ScanNodeProperties scanNodeProperties = null; [SerializeField] private BoxCollider playingInteractCollider = null; [Header("Hover")] [SerializeField] private InteractTrigger resonatorStartInteractTrigger = null; private const string NoTuningCylinderHoverTip = "[No Tuning Cylinder inserted]"; private const string ResonatorActiveHoverTip = "[Resonator already active]"; private const string TemporalInstabilityShutdownHoverTip = "[Temporal instability too high]"; [Header("Animation")] [SerializeField] private Animator resonatorAnimator = null; [SerializeField] private string animationBoolName = "isPlaying"; [SerializeField] private float animationSpeedTransitionSeconds = 1f; [Header("Audio")] [SerializeField] private AudioSource resonatorAudioSource = null; [SerializeField] private AudioClip cylinderPlacedClip = null; [SerializeField] private AudioClip cylinderRemovedClip = null; [SerializeField] private AudioClip resonatorStartedClip = null; [Header("Audio Reaction")] [SerializeField] private Transform audioReactiveScaleTarget = null; [SerializeField] private float minimumAudioReactiveScale = 1f; [SerializeField] private float maximumAudioReactiveScale = 1.5f; [SerializeField] private float audioReactiveStrength = 1.5f; [SerializeField] private float audioReactiveSmoothingSeconds = 0.08f; [Header("Temporal Instability Shutdown")] [SerializeField] [Range(0f, 100f)] private float temporalInstabilityStopThreshold = 90f; [SerializeField] [Min(0.01f)] private float temporalInstabilityStopSeconds = 0.85f; private TuningCylinderItem storedCylinder = null; private DawnContractSync? cylinderSync; private Coroutine? watchCylinderCoroutine; private Coroutine? animationSpeedCoroutine; private Coroutine? resonatorStartCoroutine; private Coroutine? audioReactionCoroutine; private Coroutine? temporalInstabilityStopCoroutine; private bool resonatorPlaying; private Vector3 audioReactiveBaseScale; private readonly float[] audioSamples = new float[64]; private float audioReactiveCurrentScale; private void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) resonatorAnimator.speed = 0f; resonatorAnimator.SetBool(animationBoolName, false); audioReactiveBaseScale = audioReactiveScaleTarget.localScale; audioReactiveCurrentScale = minimumAudioReactiveScale; RefreshStartInteractTrigger(); RegisterContractSync(); } public override void OnDestroy() { DawnContractSync? obj = cylinderSync; if (obj != null) { obj.Disable(); } ((NetworkBehaviour)this).OnDestroy(); } private void RegisterContractSync() { PlaceableShipObject val = ((Component)base.parentTo).GetComponentInChildren() ?? ((Component)this).GetComponentInParent(); if ((Object)(object)val == (Object)null) { Log.Warn("Resonator could not find its ship object"); return; } UnlockableItem val2 = StartOfRound.Instance.unlockablesList.unlockables[val.unlockableID]; NamespacedKey typedKey = (NamespacedKey)(object)((DawnBaseInfo)(object)UnlockableItemExtensions.GetDawnInfo(val2)).TypedKey; cylinderSync = DawnContractSync.Register(typedKey, (Func)WriteStoredCylinderData, (Action)RestoreStoredCylinder, false); } public void StartResonator() { if (HasStoredCylinder() && !resonatorPlaying && !IsTemporalInstabilityShutdownActive()) { RequestStartResonatorRpc(); } } [Rpc(/*Could not decode attribute arguments.*/)] private void RequestStartResonatorRpc() { //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) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(4145759038u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 4145759038u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (HasStoredCylinder() && !resonatorPlaying && !IsTemporalInstabilityShutdownActive()) { ConfirmStartResonatorRpc(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void ConfirmStartResonatorRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(858130537u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 858130537u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartResonatorLocal(); } } } private void StartResonatorLocal() { if (HasStoredCylinder() && !resonatorPlaying && !IsTemporalInstabilityShutdownActive()) { resonatorPlaying = true; RefreshStartInteractTrigger(); ((Collider)playingInteractCollider).enabled = false; resonatorAnimator.SetBool(animationBoolName, true); AudioTools.PlayOneShot(resonatorAudioSource, resonatorStartedClip); CoroutineTools.Restart((MonoBehaviour)(object)this, ref resonatorStartCoroutine, StartCylinderSongAfterResonatorClip(storedCylinder)); CoroutineTools.Restart((MonoBehaviour)(object)this, ref animationSpeedCoroutine, RampAnimatorSpeed(1f, flipBoolWhenStopped: false)); } } public void PlaceObject(PlayerControllerB playerWhoTriggered) { TuningCylinderItem tuningCylinderItem = default(TuningCylinderItem); if (playerWhoTriggered != null && playerWhoTriggered.isHoldingObject && !playerWhoTriggered.isGrabbingObjectAnimation && !((Object)(object)playerWhoTriggered.currentlyHeldObjectServer == (Object)null) && ((Component)playerWhoTriggered.currentlyHeldObjectServer).TryGetComponent(ref tuningCylinderItem) && !HasStoredCylinder()) { RequestPlaceRpc((int)playerWhoTriggered.playerClientId, ((NetworkBehaviour)tuningCylinderItem).NetworkObjectId); } } internal bool CanPlaceHeldTuningCylinder(PlayerControllerB player) { int result; if (!HasStoredCylinder() && player.isHoldingObject && !player.isGrabbingObjectAnimation) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; TuningCylinderItem tuningCylinderItem = default(TuningCylinderItem); result = ((currentlyHeldObjectServer != null && ((Component)currentlyHeldObjectServer).TryGetComponent(ref tuningCylinderItem)) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } internal bool TryGetDisabledHoverTip(PlayerControllerB player, InteractTrigger trigger, out string disabledHoverTip) { if ((Object)(object)trigger == (Object)(object)base.triggerScript && !CanPlaceHeldTuningCylinder(player)) { disabledHoverTip = trigger.disabledHoverTip; return true; } disabledHoverTip = string.Empty; return false; } [Rpc(/*Could not decode attribute arguments.*/)] private void RequestPlaceRpc(int playerWhoTriggered, ulong itemNetworkId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3113508334u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerWhoTriggered); BytePacker.WriteValueBitPacked(val2, itemNetworkId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3113508334u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (base.parentTo.IsSpawned && !HasStoredCylinder()) { PlaceableShipObject componentInChildren = ((Component)base.parentTo).gameObject.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.lastTimeScrapWasPlaced = Time.realtimeSinceStartup; } ConfirmPlaceRpc(playerWhoTriggered, itemNetworkId); } } [Rpc(/*Could not decode attribute arguments.*/)] private void ConfirmPlaceRpc(int playerId, ulong itemNetworkId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2610774658u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerId); BytePacker.WriteValueBitPacked(val2, itemNetworkId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2610774658u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val4 = Utility.LocalPlayer(); if ((Object)(object)val4 != (Object)null && (int)val4.playerClientId == playerId && val4.isHoldingObject && !val4.isGrabbingObjectAnimation && (Object)(object)val4.currentlyHeldObjectServer != (Object)null) { Vector3 val5 = ((Component)base.parentTo).transform.InverseTransformPoint(cylinderPlacement.position); val4.DiscardHeldObject(true, base.parentTo, val5, false); } ((MonoBehaviour)this).StartCoroutine(WaitAndAttachPlacedCylinder(itemNetworkId)); } } private IEnumerator WaitAndAttachPlacedCylinder(ulong itemNetworkId) { NetworkManager networkManager = NetworkManager.Singleton; TuningCylinderItem cylinder = default(TuningCylinderItem); for (int i = 0; i < 60; i++) { yield return PlaceCheckWait; if (((networkManager != null) ? networkManager.SpawnManager : null) != null && networkManager.SpawnManager.SpawnedObjects.TryGetValue(itemNetworkId, out var itemNetworkObject) && !((Object)(object)itemNetworkObject == (Object)null) && ((Component)itemNetworkObject).TryGetComponent(ref cylinder) && !((GrabbableObject)cylinder).isHeld && !((Object)(object)((GrabbableObject)cylinder).playerHeldBy != (Object)null) && !((GrabbableObject)cylinder).isHeldByEnemy) { AttachCylinder(cylinder, saveItem: true, playPlacedSound: true); break; } } } private void AttachCylinder(TuningCylinderItem cylinder, bool saveItem, bool playPlacedSound) { storedCylinder = cylinder; ((GrabbableObject)cylinder).parentObject = null; ((Component)cylinder).transform.SetParent(((Component)base.parentTo).transform, true); cylinder.LoadSong(); ApplyCylinderTransform(cylinder); scanNodeProperties.subText = string.Empty; ((Collider)((Component)base.triggerScript).GetComponent()).enabled = false; if (playPlacedSound) { AudioTools.PlayOneShot(resonatorAudioSource, cylinderPlacedClip); } CoroutineTools.Restart((MonoBehaviour)(object)this, ref watchCylinderCoroutine, WatchStoredCylinder(cylinder)); RefreshStartInteractTrigger(); if (saveItem) { SaveStoredCylinder(); } } private IEnumerator WatchStoredCylinder(TuningCylinderItem cylinder) { while ((Object)(object)cylinder != (Object)null) { if (((GrabbableObject)cylinder).isHeld || (Object)(object)((GrabbableObject)cylinder).playerHeldBy != (Object)null || ((GrabbableObject)cylinder).isHeldByEnemy) { DetachCylinder(cylinder, saveItem: true); yield break; } ApplyCylinderTransform(cylinder); yield return null; } StopTemporalInstabilityShutdown(); StopResonatorAnimation(); StopAudioReaction(); scanNodeProperties.subText = string.Empty; storedCylinder = null; RefreshStartInteractTrigger(); ((Collider)((Component)base.triggerScript).GetComponent()).enabled = true; ClearStoredCylinderSave(); watchCylinderCoroutine = null; } private void DetachCylinder(TuningCylinderItem cylinder, bool saveItem) { cylinder.StopSong(); cylinder.UnloadSong(); AudioTools.PlayOneShot(resonatorAudioSource, cylinderRemovedClip); StopTemporalInstabilityShutdown(); StopResonatorAnimation(); StopAudioReaction(); scanNodeProperties.subText = string.Empty; if ((Object)(object)storedCylinder == (Object)(object)cylinder) { storedCylinder = null; } ((Collider)((Component)base.triggerScript).GetComponent()).enabled = true; watchCylinderCoroutine = null; RefreshStartInteractTrigger(); if (saveItem) { ClearStoredCylinderSave(); } } private string WriteStoredCylinderData() { if (!HasStoredCylinder()) { return string.Empty; } return ((object)FindItems.DawnKey((GrabbableObject)(object)storedCylinder))?.ToString() ?? string.Empty; } private void RestoreStoredCylinder(string rawItemKey) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (HasStoredCylinder() || string.IsNullOrWhiteSpace(rawItemKey)) { return; } NamespacedKey val = default(NamespacedKey); if (!NamespacedKey.TryParse(rawItemKey, ref val)) { if (((NetworkBehaviour)this).IsServer) { ClearStoredCylinderSave(); } Log.Warn("Resonator cylinder save data could not be read"); return; } NamespacedKey val2 = val.AsTyped(); List list = FindItems.Active((Func)((GrabbableObject item) => item is TuningCylinderItem && !item.isHeld && (Object)(object)item.playerHeldBy == (Object)null && !item.isHeldByEnemy)); GrabbableObject val3 = FindItems.ClosestTo(val2, cylinderPlacement.position, 12f, (IReadOnlyList)list, (Func)null); TuningCylinderItem cylinder = default(TuningCylinderItem); if ((Object)(object)val3 == (Object)null || !((Component)val3).TryGetComponent(ref cylinder)) { if (((NetworkBehaviour)this).IsServer) { ClearStoredCylinderSave(); } } else { AttachCylinder(cylinder, saveItem: false, playPlacedSound: false); Log.Debug("Resonator cylinder restored"); } } private void SaveStoredCylinder() { if (((NetworkBehaviour)this).IsServer && cylinderSync != null) { string value = WriteStoredCylinderData(); if (string.IsNullOrWhiteSpace(value)) { ClearStoredCylinderSave(); return; } cylinderSync.SaveAndPublish(); Log.Debug("Resonator cylinder save updated"); } } private void ClearStoredCylinderSave() { if (((NetworkBehaviour)this).IsServer && cylinderSync != null) { cylinderSync.Delete(); cylinderSync.Publish(); Log.Debug("Resonator cylinder save cleared"); } } private bool HasStoredCylinder() { TuningCylinderItem tuningCylinderItem = storedCylinder; return tuningCylinderItem != null && !((GrabbableObject)tuningCylinderItem).isHeld && (Object)(object)((GrabbableObject)storedCylinder).playerHeldBy == (Object)null && !((GrabbableObject)storedCylinder).isHeldByEnemy; } private void RefreshStartInteractTrigger() { bool flag = HasStoredCylinder(); bool flag2 = IsTemporalInstabilityShutdownActive(); bool flag3 = flag && !resonatorPlaying && !flag2; resonatorStartInteractTrigger.interactable = flag3; if (!flag3) { resonatorStartInteractTrigger.disabledHoverTip = ((!flag) ? "[No Tuning Cylinder inserted]" : (resonatorPlaying ? "[Resonator already active]" : (flag2 ? "[Temporal instability too high]" : "[No Tuning Cylinder inserted]"))); } } private void ApplyCylinderTransform(TuningCylinderItem cylinder) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005e: 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_0071: 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_007e: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)base.parentTo).transform.InverseTransformPoint(cylinderPlacement.position); Quaternion val2 = Quaternion.Inverse(((Component)base.parentTo).transform.rotation) * cylinderPlacement.rotation; Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles; eulerAngles.x = 0f; ((Component)cylinder).transform.SetLocalPositionAndRotation(val, Quaternion.Euler(eulerAngles)); ((Component)cylinder).transform.localScale = ((GrabbableObject)cylinder).originalScale; ((GrabbableObject)cylinder).targetFloorPosition = val; ((GrabbableObject)cylinder).startFallingPosition = val + Vector3.up * 0.0001f; ((GrabbableObject)cylinder).fallTime = 1f; ((GrabbableObject)cylinder).hasHitGround = true; ((GrabbableObject)cylinder).reachedFloorTarget = true; } private void StopResonatorAnimation() { resonatorPlaying = false; if (resonatorStartCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(resonatorStartCoroutine); resonatorStartCoroutine = null; } CoroutineTools.Restart((MonoBehaviour)(object)this, ref animationSpeedCoroutine, RampAnimatorSpeed(0f, flipBoolWhenStopped: true)); } private IEnumerator StartCylinderSongAfterResonatorClip(TuningCylinderItem cylinder) { yield return (object)new WaitForSeconds(resonatorStartedClip.length); if (resonatorPlaying && (Object)(object)storedCylinder == (Object)(object)cylinder && HasStoredCylinder()) { if (IsTemporalInstabilityShutdownActive()) { StopResonatorAnimation(); resonatorStartCoroutine = null; yield break; } cylinder.PlaySong(); scanNodeProperties.subText = cylinder.SongDisplayName; CoroutineTools.Restart((MonoBehaviour)(object)this, ref audioReactionCoroutine, ReactToCylinderAudio(cylinder)); } resonatorStartCoroutine = null; } private IEnumerator RampAnimatorSpeed(float targetSpeed, bool flipBoolWhenStopped) { float startSpeed = resonatorAnimator.speed; float elapsedSeconds = 0f; while (elapsedSeconds < animationSpeedTransitionSeconds) { elapsedSeconds += Time.deltaTime; resonatorAnimator.speed = Mathf.Lerp(startSpeed, targetSpeed, elapsedSeconds / animationSpeedTransitionSeconds); yield return null; } resonatorAnimator.speed = targetSpeed; if (flipBoolWhenStopped) { resonatorAnimator.SetBool(animationBoolName, false); if (temporalInstabilityStopCoroutine == null) { ((Collider)playingInteractCollider).enabled = true; } RefreshStartInteractTrigger(); } animationSpeedCoroutine = null; } private IEnumerator ReactToCylinderAudio(TuningCylinderItem cylinder) { AudioSource songAudioSource = cylinder.SongAudioSource; while (songAudioSource.isPlaying) { if (IsTemporalInstabilityShutdownActive()) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref temporalInstabilityStopCoroutine, StopForTemporalInstability(cylinder)); audioReactionCoroutine = null; yield break; } songAudioSource.GetOutputData(audioSamples, 0); float sampleTotal = 0f; for (int i = 0; i < audioSamples.Length; i++) { sampleTotal += Mathf.Abs(audioSamples[i]); } float audioScale = Mathf.Clamp01(sampleTotal / (float)audioSamples.Length * audioReactiveStrength); float targetScale = Mathf.Lerp(minimumAudioReactiveScale, maximumAudioReactiveScale, audioScale); float smoothing = 1f - Mathf.Exp((0f - Time.deltaTime) / Mathf.Max(0.001f, audioReactiveSmoothingSeconds)); audioReactiveCurrentScale = Mathf.Lerp(audioReactiveCurrentScale, targetScale, smoothing); audioReactiveScaleTarget.localScale = audioReactiveBaseScale * audioReactiveCurrentScale; yield return null; } audioReactiveScaleTarget.localScale = audioReactiveBaseScale * minimumAudioReactiveScale; audioReactiveCurrentScale = minimumAudioReactiveScale; audioReactionCoroutine = null; } private IEnumerator StopForTemporalInstability(TuningCylinderItem cylinder) { StopResonatorAnimation(); scanNodeProperties.subText = string.Empty; yield return cylinder.StopSongLikeVinyl(temporalInstabilityStopSeconds); StopAudioReaction(); ((Collider)playingInteractCollider).enabled = true; temporalInstabilityStopCoroutine = null; } private void StopTemporalInstabilityShutdown() { if (temporalInstabilityStopCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(temporalInstabilityStopCoroutine); temporalInstabilityStopCoroutine = null; } } private bool IsTemporalInstabilityShutdownActive() { float temporalInstabilityLevel; return TemporalInstabilityAPI.TryGetServerInstabilityLevel(out temporalInstabilityLevel) && temporalInstabilityLevel >= temporalInstabilityStopThreshold; } private void StopAudioReaction() { //IL_002b: 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 (audioReactionCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(audioReactionCoroutine); audioReactionCoroutine = null; } audioReactiveScaleTarget.localScale = audioReactiveBaseScale * minimumAudioReactiveScale; audioReactiveCurrentScale = minimumAudioReactiveScale; } protected override void __initializeVariables() { ((PlaceableObjectsSurface)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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4145759038u, new RpcReceiveHandler(__rpc_handler_4145759038), "RequestStartResonatorRpc"); ((NetworkBehaviour)this).__registerRpc(858130537u, new RpcReceiveHandler(__rpc_handler_858130537), "ConfirmStartResonatorRpc"); ((NetworkBehaviour)this).__registerRpc(3113508334u, new RpcReceiveHandler(__rpc_handler_3113508334), "RequestPlaceRpc"); ((NetworkBehaviour)this).__registerRpc(2610774658u, new RpcReceiveHandler(__rpc_handler_2610774658), "ConfirmPlaceRpc"); ((PlaceableObjectsSurface)this).__initializeRpcs(); } private static void __rpc_handler_4145759038(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; ((ResonatorSurface)(object)target).RequestStartResonatorRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_858130537(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; ((ResonatorSurface)(object)target).ConfirmStartResonatorRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3113508334(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerWhoTriggered = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerWhoTriggered); ulong itemNetworkId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref itemNetworkId); target.__rpc_exec_stage = (__RpcExecStage)1; ((ResonatorSurface)(object)target).RequestPlaceRpc(playerWhoTriggered, itemNetworkId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2610774658(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int playerId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref playerId); ulong itemNetworkId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref itemNetworkId); target.__rpc_exec_stage = (__RpcExecStage)1; ((ResonatorSurface)(object)target).ConfirmPlaceRpc(playerId, itemNetworkId); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ResonatorSurface"; } } } namespace TemporalStormWeather.TemporalStormManagers { internal class AudioManager : MonoBehaviour, ITemporalInstability { [Serializable] private class InstabilityLoop { public AudioSource AudioSource = null; public AudioClip AudioClip = null; } private const float CrossfadeSeconds = 1f; private static readonly NamespacedKey[] locustEnemyKeys = new NamespacedKey[3] { Keys.LocustEnemyInfo, Keys.SawbladeLocustEnemyInfo, Keys.CorruptLocustEnemyInfo }; [Header("Volume")] [SerializeField] [Range(0f, 1f)] private float maximumAudioVolume = 1f; [SerializeField] [Range(0f, 100f)] private float volumeIncreaseStartInstability = 0f; [SerializeField] [Range(0f, 100f)] private float maximumVolumeInstability = 90f; [Header("Low Instability")] [SerializeField] private InstabilityLoop lowInstability = new InstabilityLoop(); [Header("Medium Instability")] [SerializeField] private InstabilityLoop mediumInstability = new InstabilityLoop(); [Header("High Instability")] [SerializeField] private InstabilityLoop highInstability = new InstabilityLoop(); [Header("Extreme Instability")] [SerializeField] private InstabilityLoop extremeInstability = new InstabilityLoop(); private Coroutine? crossfadeCoroutine; private InstabilityLoop[] instabilityLoops = Array.Empty(); private InstabilityLoop? activeLoop; private float temporalInstabilityLevel; private bool weatherFlowActive; private bool audioSourcesReady; private void Awake() { instabilityLoops = new InstabilityLoop[4] { lowInstability, mediumInstability, highInstability, extremeInstability }; audioSourcesReady = true; for (int i = 0; i < instabilityLoops.Length; i++) { InstabilityLoop instabilityLoop = instabilityLoops[i]; if (!AudioUtils.Configure2DAudioSource(instabilityLoop.AudioSource, loop: true)) { audioSourcesReady = false; continue; } AudioTools.SwapClip(instabilityLoop.AudioSource, instabilityLoop.AudioClip, false); AudioTools.Stop(instabilityLoop.AudioSource, true); } } private void OnEnable() { if (audioSourcesReady && Utility.ShouldRunWeatherLifecycle()) { AudioUtils.LoadAudioClips(WeatherAudioClips()); weatherFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); } } private void OnDisable() { if (!weatherFlowActive) { return; } weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref crossfadeCoroutine); for (int i = 0; i < instabilityLoops.Length; i++) { AudioSource audioSource = instabilityLoops[i].AudioSource; if (!((Object)(object)audioSource == (Object)null)) { AudioTools.Stop(audioSource, true); } } activeLoop = null; temporalInstabilityLevel = 0f; AudioUtils.UnloadAudioClips(WeatherAudioClips()); } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); InstabilityLoop instabilityLoop = ((temporalInstabilityLevel < 25f) ? lowInstability : ((temporalInstabilityLevel < 55f) ? mediumInstability : ((temporalInstabilityLevel < 90f) ? highInstability : extremeInstability))); if (instabilityLoop == activeLoop) { if (activeLoop != null && crossfadeCoroutine == null) { StopInactiveLoops(activeLoop); activeLoop.AudioSource.volume = (((Object)(object)activeLoop.AudioClip != (Object)null) ? WantedVolume() : 0f); } } else { StopInactiveLoops(activeLoop, instabilityLoop); CoroutineTools.Restart((MonoBehaviour)(object)this, ref crossfadeCoroutine, CrossfadeToLoop(instabilityLoop)); } } private IEnumerator CrossfadeToLoop(InstabilityLoop newLoop) { InstabilityLoop previousLoop = activeLoop; activeLoop = newLoop; AudioSource previousSource = previousLoop?.AudioSource; AudioSource newSource = newLoop.AudioSource; float previousStartVolume = ((previousSource != null) ? previousSource.volume : 0f); float newStartVolume = ((newSource != null) ? newSource.volume : 0f); if ((Object)(object)newLoop.AudioClip != (Object)null && (Object)(object)newSource != (Object)null) { AudioTools.SwapClip(newSource, newLoop.AudioClip, false); if (!newSource.isPlaying) { newSource.time = 0f; newSource.Play(); } } float elapsedSeconds = 0f; while (elapsedSeconds < 1f) { elapsedSeconds += Time.deltaTime; float fadeAmount = Mathf.SmoothStep(0f, 1f, elapsedSeconds / 1f); if (previousSource != null) { previousSource.volume = Mathf.Lerp(previousStartVolume, 0f, fadeAmount); } if (newSource != null) { newSource.volume = (((Object)(object)newLoop.AudioClip != (Object)null) ? Mathf.Lerp(newStartVolume, WantedVolume(), fadeAmount) : 0f); } yield return null; } if ((Object)(object)previousSource != (Object)null) { AudioTools.Stop(previousSource, true); } if (newSource != null) { newSource.volume = (((Object)(object)newLoop.AudioClip != (Object)null) ? WantedVolume() : 0f); } StopInactiveLoops(newLoop); crossfadeCoroutine = null; } private float WantedVolume() { if (temporalInstabilityLevel < volumeIncreaseStartInstability) { return 0f; } float fullLevel = Mathf.Max(volumeIncreaseStartInstability + 0.01f, maximumVolumeInstability); float num = Mathf.Lerp(0.1f, 1f, Utility.InstabilityProgress(temporalInstabilityLevel, volumeIncreaseStartInstability, fullLevel)); return num * maximumAudioVolume; } private AudioClip?[] WeatherAudioClips() { WarningManager warningManager = Object.FindFirstObjectByType((FindObjectsInactive)1); ThunderlordAnimationEvents thunderlordAnimationEvents = Object.FindFirstObjectByType((FindObjectsInactive)1); List list = new List(); list.Add(lowInstability.AudioClip); list.Add(mediumInstability.AudioClip); list.Add(highInstability.AudioClip); list.Add(extremeInstability.AudioClip); list.AddRange(TemporalStormAmbience.GetAudioClips()); list.AddRange(warningManager?.AudioClips ?? Array.Empty()); list.AddRange(thunderlordAnimationEvents?.AudioClips ?? Array.Empty()); list.AddRange(RiftAudioClips()); list.AddRange(LocustAudioClips()); return list.ToArray(); } private static AudioClip?[] RiftAudioClips() { DawnMapObjectInfo val = default(DawnMapObjectInfo); if (!((Registry)(object)LethalContent.MapObjects).TryGetValue(Keys.TemporalRiftMapObject, ref val)) { return Array.Empty(); } DawnInsideMapObjectInfo insideInfo = val.InsideInfo; GameObject riftPrefab = (((Object)(object)((insideInfo != null) ? insideInfo.IndoorMapHazardType : null) != (Object)null) ? val.InsideInfo.IndoorMapHazardType.prefabToSpawn : null); DawnOutsideMapObjectInfo outsideInfo = val.OutsideInfo; GameObject riftPrefab2 = (((Object)(object)((outsideInfo != null) ? outsideInfo.SpawnableOutsideObject : null) != (Object)null) ? val.OutsideInfo.SpawnableOutsideObject.prefabToSpawn : null); AudioClip[] array = RiftAudioClips(riftPrefab); AudioClip[] array2 = RiftAudioClips(riftPrefab2); int num = 0; AudioClip[] array3 = (AudioClip[])(object)new AudioClip[array.Length + array2.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(array); readOnlySpan.CopyTo(new Span(array3).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; ReadOnlySpan readOnlySpan2 = new ReadOnlySpan(array2); readOnlySpan2.CopyTo(new Span(array3).Slice(num, readOnlySpan2.Length)); num += readOnlySpan2.Length; return array3; } private static AudioClip?[] RiftAudioClips(GameObject? riftPrefab) { return ((riftPrefab != null) ? riftPrefab.GetComponentInChildren(true) : null)?.AudioClips ?? Array.Empty(); } private static AudioClip?[] LocustAudioClips() { AudioClip[] array = LocustAudioClips(locustEnemyKeys[0]); AudioClip[] array2 = LocustAudioClips(locustEnemyKeys[1]); AudioClip[] array3 = LocustAudioClips(locustEnemyKeys[2]); int num = 0; AudioClip[] array4 = (AudioClip[])(object)new AudioClip[array.Length + array2.Length + array3.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(array); readOnlySpan.CopyTo(new Span(array4).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; ReadOnlySpan readOnlySpan2 = new ReadOnlySpan(array2); readOnlySpan2.CopyTo(new Span(array4).Slice(num, readOnlySpan2.Length)); num += readOnlySpan2.Length; ReadOnlySpan readOnlySpan3 = new ReadOnlySpan(array3); readOnlySpan3.CopyTo(new Span(array4).Slice(num, readOnlySpan3.Length)); num += readOnlySpan3.Length; return array4; } private static AudioClip?[] LocustAudioClips(NamespacedKey enemyKey) { DawnEnemyInfo val = default(DawnEnemyInfo); if (!((Registry)(object)LethalContent.Enemies).TryGetValue(enemyKey, ref val) || (Object)(object)val.EnemyType?.enemyPrefab == (Object)null) { return Array.Empty(); } return val.EnemyType.enemyPrefab.GetComponent()?.AudioClips ?? Array.Empty(); } private void StopInactiveLoops(InstabilityLoop? firstKeptLoop = null, InstabilityLoop? secondKeptLoop = null) { for (int i = 0; i < instabilityLoops.Length; i++) { InstabilityLoop instabilityLoop = instabilityLoops[i]; if (instabilityLoop != firstKeptLoop && instabilityLoop != secondKeptLoop) { AudioSource audioSource = instabilityLoop.AudioSource; if (!((Object)(object)audioSource == (Object)null)) { AudioTools.Stop(audioSource, true); } } } } } internal class ChatGlitchManager : ITemporalInstability { private const float ChatCorruptionStartInstability = 90f; private static readonly ChatGlitchManager Receiver = new ChatGlitchManager(); private static bool registered; private static bool active; public void SetTemporalInstabilityLevel(float temporalInstabilityLevel) { active = temporalInstabilityLevel >= 90f; } public static void CorruptMessage(ref string chatMessage) { Register(); if (!active || string.IsNullOrEmpty(chatMessage)) { return; } StringBuilder stringBuilder = new StringBuilder(chatMessage.Length * 2); for (int i = 0; i < chatMessage.Length; i++) { char c = chatMessage[i]; if (!char.IsWhiteSpace(c)) { stringBuilder.Append(c); stringBuilder.Append('â–¡'); } else { stringBuilder.Append(c); } } chatMessage = stringBuilder.ToString(); } public static void Reset() { TemporalInstabilityAPI.Unregister(Receiver); registered = false; active = false; } private static void Register() { if (!registered) { registered = true; TemporalInstabilityAPI.Register(Receiver, TemporalInstabilityFeed.Server); } } } [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] internal static class HUDManagerChatGlitchPatch { [HarmonyPrefix] private static void CorruptTemporalStormChat(ref string chatMessage, int playerId) { if (playerId != -1) { ChatGlitchManager.CorruptMessage(ref chatMessage); } } } [Serializable] internal class TemporalStormItemContractSaveData { public List Items = new List(); } [Serializable] internal class TemporalStormSavedItem { public string ItemNamespacedKey = string.Empty; public string ItemName = string.Empty; public Vector3 Position; public uint ItemSeed; public int ScrapValue; public float RusticLevel; public float VisualAmount; public int State; public uint TemporalRollsConsumed; public bool IncludeNonConductive; } public class DawnSaveManager : MonoBehaviour { private static DawnContractSync? itemEffectSync; internal static void HookItemEffectSave() { if (itemEffectSync == null) { itemEffectSync = DawnContractSync.Register(Keys.ItemEffectsSaveData, (Func)BuildCurrentSaveDataJson, (Action)LoadSavedItems, true); } } private static string BuildCurrentSaveDataJson() { TemporalStormItemContractSaveData temporalStormItemContractSaveData = BuildCurrentSaveData(); return (temporalStormItemContractSaveData.Items.Count == 0) ? string.Empty : JsonUtility.ToJson((object)temporalStormItemContractSaveData); } private static void LoadSavedItems(string rawSaveData) { LoadSavedItems(ReadItemContractSaveData(rawSaveData)); } private static TemporalStormItemContractSaveData BuildCurrentSaveData() { TemporalStormItemContractSaveData temporalStormItemContractSaveData = new TemporalStormItemContractSaveData(); ItemEffect[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (ItemEffect itemEffect in array) { if (itemEffect.WriteDawnSaveEntry(out TemporalStormSavedItem savedItem)) { temporalStormItemContractSaveData.Items.Add(savedItem); } } return temporalStormItemContractSaveData; } private static List GatherRestoreCandidates() { return FindItems.Active((Func)((GrabbableObject item) => DawnConfigUtils.CanUseDawnItem(item, includeNonConductive: true, DawnItemPersistenceMode.Restore))); } private static void LoadSavedItems(TemporalStormItemContractSaveData savedData) { if (savedData.Items.Count == 0) { return; } List list = GatherRestoreCandidates(); for (int i = 0; i < savedData.Items.Count; i++) { TemporalStormSavedItem temporalStormSavedItem = savedData.Items[i]; GrabbableObject val = FindClosestMatchingItem(temporalStormSavedItem, list); if (!((Object)(object)val == (Object)null)) { list.Remove(val); if (ItemEffect.Attach(val, out ItemEffect itemEffect, temporalStormSavedItem.IncludeNonConductive) && !((Object)(object)itemEffect == (Object)null)) { itemEffect.ReadDawnSaveEntry(temporalStormSavedItem); } } } } private static GrabbableObject? FindClosestMatchingItem(TemporalStormSavedItem savedItem, List candidates) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) NamespacedKey val = default(NamespacedKey); if (!NamespacedKey.TryParse(savedItem.ItemNamespacedKey, ref val)) { return null; } return FindItems.ClosestTo(val.AsTyped(), savedItem.Position, 8f, (IReadOnlyList)candidates, (Func)null); } private static TemporalStormItemContractSaveData ReadItemContractSaveData(string raw) { if (string.IsNullOrWhiteSpace(raw)) { return new TemporalStormItemContractSaveData(); } TemporalStormItemContractSaveData temporalStormItemContractSaveData = JsonUtility.FromJson(raw); return (temporalStormItemContractSaveData?.Items == null) ? new TemporalStormItemContractSaveData() : temporalStormItemContractSaveData; } } internal class EntityGlitchManager : MonoBehaviour, ITemporalInstability { private class TrackedEntity { public List Renderers = new List(); } private enum TrackedEntityKind { Enemy, Player } private class TrackedRenderer { public Renderer Renderer = null; public Material[] OriginalMaterials = null; public Material[] GlitchMaterials = null; public float[] OriginalAlphaClipThresholds = null; public uint OriginalRenderingLayerMask; } private class RendererSource { public Renderer Renderer = null; public Material[] OriginalMaterials = null; public uint OriginalRenderingLayerMask; } private class RendererGlitchWork { public Renderer Renderer = null; public Material[] OriginalMaterials = null; public float[] MaterialSeeds = null; public uint OriginalRenderingLayerMask; } private class EntityGlitchRequest { public int Version; public TrackedEntityKind Kind; public EnemyAI? Enemy; public PlayerControllerB? Player; public RendererSource[] Renderers = null; public float EntitySeed; } private class EntityGlitchWork { public int Version; public TrackedEntityKind Kind; public EnemyAI? Enemy; public PlayerControllerB? Player; public RendererGlitchWork[] Renderers = null; } [CompilerGenerated] private sealed class d__63 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public EntityGlitchRequest request; public EntityGlitchManager <>4__this; private EntityGlitchWork 5__1; private float 5__2; private Awaiter <>u__1; private Awaiter <>u__2; private void MoveNext() { //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_001f: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { Awaiter val; Awaiter val3; if (num != 0) { if (num == 1) { val = <>u__2; <>u__2 = default(Awaiter); num = (<>1__state = -1); goto IL_00f5; } SwitchToThreadPoolAwaitable val2 = UniTask.SwitchToThreadPool(); val3 = ((SwitchToThreadPoolAwaitable)(ref val2)).GetAwaiter(); if (!((Awaiter)(ref val3)).IsCompleted) { num = (<>1__state = 0); <>u__1 = val3; d__63 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__63>(ref val3, ref d__); return; } } else { val3 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref val3)).GetResult(); 5__1 = BuildEntityGlitch(request); SwitchToMainThreadAwaitable val4 = UniTask.SwitchToMainThread(default(CancellationToken)); val = ((SwitchToMainThreadAwaitable)(ref val4)).GetAwaiter(); if (!((Awaiter)(ref val)).IsCompleted) { num = (<>1__state = 1); <>u__2 = val; d__63 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__63>(ref val, ref d__); return; } goto IL_00f5; IL_00f5: ((Awaiter)(ref val)).GetResult(); if (!((Object)(object)<>4__this == (Object)null)) { <>4__this.TrackEntity(5__1); 5__2 = <>4__this.GlitchStrength(); <>4__this.PushGlitch(5__2, <>4__this.GlitchFlicker(5__2)); <>4__this.RunFullGlitchPulse(); } } catch (Exception exception) { <>1__state = -2; 5__1 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; 5__1 = null; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } private const float FullGlitchPulseFrequency = 18f; private const float FullGlitchStrengthPulse = 0.12f; private const float FullGlitchFlickerBoost = 0.35f; [Header("Material")] [SerializeField] private Material entityGlitchMaterial = null; [Header("Instability")] [SerializeField] [Range(0f, 100f)] private float glitchStartInstability = 60f; [SerializeField] [Range(0f, 100f)] private float fullGlitchInstability = 100f; [SerializeField] [Range(0f, 1f)] private float maximumGlitchStrength = 1f; [SerializeField] [Range(0f, 1f)] private float glitchFlicker = 1f; private static readonly int alphaCutoffEnablePropertyId = Shader.PropertyToID("_AlphaCutoffEnable"); private static readonly int originalTexturePropertyId = Shader.PropertyToID("_BaseColorMap"); private static readonly int originalColorPropertyId = Shader.PropertyToID("_BaseColor"); private static readonly int originalAlphaClipThresholdPropertyId = Shader.PropertyToID("_AlphaCutoff"); private static readonly int originalNormalTexturePropertyId = Shader.PropertyToID("_NormalMap"); private static readonly int originalNormalScalePropertyId = Shader.PropertyToID("_NormalScale"); private static readonly int originalSmoothnessPropertyId = Shader.PropertyToID("_Smoothness"); private static readonly int baseTexturePropertyId = Shader.PropertyToID("_BaseTexture"); private static readonly int baseColorTintPropertyId = Shader.PropertyToID("_BaseColorTint"); private static readonly int alphaClipThresholdPropertyId = Shader.PropertyToID("_TemporalAlphaClipThreshold"); private static readonly int normalTexturePropertyId = Shader.PropertyToID("_NormalMap"); private static readonly int normalScalePropertyId = Shader.PropertyToID("_NormalScale"); private static readonly int smoothnessPropertyId = Shader.PropertyToID("_Smoothness"); private static readonly int glitchStrengthPropertyId = Shader.PropertyToID("_TemporalGlitchStrength"); private static readonly int glitchFlickerPropertyId = Shader.PropertyToID("_TemporalGlitchFlicker"); private static readonly int entitySeedPropertyId = Shader.PropertyToID("_TemporalEntitySeed"); private static readonly int[] baseTextureSourcePropertyIds = new int[3] { Shader.PropertyToID("_BaseColorMap"), Shader.PropertyToID("_BaseMap"), Shader.PropertyToID("_MainTex") }; private static readonly int[] baseColorSourcePropertyIds = new int[2] { Shader.PropertyToID("_BaseColor"), Shader.PropertyToID("_Color") }; private static readonly int[] normalTextureSourcePropertyIds = new int[2] { Shader.PropertyToID("_NormalMap"), Shader.PropertyToID("_BumpMap") }; private static readonly int[] normalScaleSourcePropertyIds = new int[2] { Shader.PropertyToID("_NormalScale"), Shader.PropertyToID("_BumpScale") }; private static readonly int[] smoothnessSourcePropertyIds = new int[2] { Shader.PropertyToID("_Smoothness"), Shader.PropertyToID("_Glossiness") }; private static readonly OriginalMaterialPropertyIds originalMaterialPropertyIds = new OriginalMaterialPropertyIds(originalTexturePropertyId, originalColorPropertyId, originalAlphaClipThresholdPropertyId, originalNormalTexturePropertyId, originalNormalScalePropertyId, originalSmoothnessPropertyId); private static readonly EffectMaterialPropertyIds effectMaterialPropertyIds = new EffectMaterialPropertyIds(baseTexturePropertyId, baseColorTintPropertyId, alphaClipThresholdPropertyId, normalTexturePropertyId, normalScalePropertyId, smoothnessPropertyId); private readonly Dictionary trackedEnemies = new Dictionary(); private readonly Dictionary trackedPlayers = new Dictionary(); private readonly HashSet pendingEnemies = new HashSet(); private readonly HashSet pendingPlayers = new HashSet(); private readonly List trackedEnemiesToRemove = new List(); private static EntityGlitchManager? activeManager; private bool weatherFlowActive; private float temporalInstabilityLevel; private Coroutine? glitchAnimationCoroutine; private int trackingVersion; private float glitchAlphaClipThreshold; private void Awake() { Material obj = entityGlitchMaterial; glitchAlphaClipThreshold = ((obj != null && obj.HasProperty(alphaClipThresholdPropertyId)) ? entityGlitchMaterial.GetFloat(alphaClipThresholdPropertyId) : 0f); } private void OnEnable() { if (ConfigManager.EntityGlitchEnabled != null) { if (!ConfigManager.EntityGlitchEnabled.Value) { Object.Destroy((Object)(object)((Component)this).gameObject); } else if (Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; activeManager = this; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); } } } private void OnDisable() { if (weatherFlowActive) { weatherFlowActive = false; if ((Object)(object)activeManager == (Object)(object)this) { activeManager = null; } TemporalInstabilityAPI.Unregister(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref glitchAnimationCoroutine); RestoreAllTrackedRenderers(); temporalInstabilityLevel = 0f; } } internal static void NotifyEnemySpawned(EnemyAI? enemy) { EntityGlitchManager? entityGlitchManager = activeManager; if (entityGlitchManager != null && entityGlitchManager.weatherFlowActive && !(activeManager.GlitchStrength() <= 0.001f)) { activeManager.TrackEnemy(enemy); activeManager.RunFullGlitchPulse(); } } internal static void NotifyEnemyRemoved(EnemyAI? enemy) { activeManager?.RemoveTrackedEnemy(enemy); } public void SetTemporalInstabilityLevel(float value) { float num = GlitchStrength(); temporalInstabilityLevel = Utility.ClampInstability(value); float num2 = GlitchStrength(); if (num2 <= 0.001f) { RestoreAllTrackedRenderers(); } else if (weatherFlowActive) { if (!ConfigManager.EntityGlitchPlayerModels.Value) { RestoreTrackedPlayers(); } if (num <= 0.001f) { GlitchExistingEnemies(); } GlitchExistingPlayers(); PushGlitch(num2, GlitchFlicker(num2)); RunFullGlitchPulse(); } } private void GlitchExistingEnemies() { if (!((Object)(object)RoundManager.Instance == (Object)null)) { List spawnedEnemies = RoundManager.Instance.SpawnedEnemies; for (int i = 0; i < spawnedEnemies.Count; i++) { TrackEnemy(spawnedEnemies[i]); } } } private void GlitchExistingPlayers() { if (!ConfigManager.EntityGlitchPlayerModels.Value || (Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { PlayerControllerB val = allPlayerScripts[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Utility.LocalPlayer()) && Utility.IsPlayerActive(val) && !trackedPlayers.ContainsKey(val)) { TrackPlayer(val, i); } } } private bool TrackEnemy(EnemyAI? enemy) { if (enemy == null || enemy.isEnemyDead) { return false; } return (Object)(object)entityGlitchMaterial != (Object)null && !trackedEnemies.ContainsKey(enemy) && !pendingEnemies.Contains(enemy) && !IsEnemyBlacklisted(enemy) && QueueEnemy(enemy); } private bool QueueEnemy(EnemyAI enemy) { float entitySeed = (float)(enemy.thisEnemyIndex + 1) * 37.17f; bool flag = QueueEntity(TrackedEntityKind.Enemy, enemy, null, ((Component)enemy).GetComponentsInChildren(true), entitySeed, isPlayer: false); if (flag) { pendingEnemies.Add(enemy); } return flag; } private void TrackPlayer(PlayerControllerB player, int playerIndex) { if (!((Object)(object)entityGlitchMaterial == (Object)null) && !pendingPlayers.Contains(player)) { float entitySeed = (float)(playerIndex + 1) * 73.31f; if (QueueEntity(TrackedEntityKind.Player, null, player, ((Component)player).GetComponentsInChildren(true), entitySeed, isPlayer: true)) { pendingPlayers.Add(player); } } } private bool QueueEntity(TrackedEntityKind kind, EnemyAI? enemy, PlayerControllerB? player, Renderer[] renderers, float entitySeed, bool isPlayer) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) RendererSource[] array = ReadRenderers(renderers, isPlayer); if (array.Length == 0) { return false; } EntityGlitchRequest request = new EntityGlitchRequest { Version = trackingVersion, Kind = kind, Enemy = enemy, Player = player, Renderers = array, EntitySeed = entitySeed }; UniTaskExtensions.Forget(BuildEntityGlitchAsync(request)); return true; } private static RendererSource[] ReadRenderers(Renderer[] renderers, bool player) { List list = new List(); foreach (Renderer val in renderers) { if ((val is MeshRenderer || val is SkinnedMeshRenderer) && (player || !((Object)(object)((Component)val).GetComponentInParent(true) != (Object)null))) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials.Length != 0) { list.Add(new RendererSource { Renderer = val, OriginalMaterials = sharedMaterials, OriginalRenderingLayerMask = val.renderingLayerMask }); } } } return list.ToArray(); } private static EntityGlitchWork BuildEntityGlitch(EntityGlitchRequest request) { List list = new List(); for (int i = 0; i < request.Renderers.Length; i++) { RendererSource rendererSource = request.Renderers[i]; float[] array = new float[rendererSource.OriginalMaterials.Length]; for (int j = 0; j < array.Length; j++) { array[j] = request.EntitySeed + (float)j * 13.31f; } list.Add(new RendererGlitchWork { Renderer = rendererSource.Renderer, OriginalMaterials = rendererSource.OriginalMaterials, MaterialSeeds = array, OriginalRenderingLayerMask = rendererSource.OriginalRenderingLayerMask }); } return new EntityGlitchWork { Version = request.Version, Kind = request.Kind, Enemy = request.Enemy, Player = request.Player, Renderers = list.ToArray() }; } [AsyncStateMachine(typeof(d__63))] [DebuggerStepThrough] private UniTask BuildEntityGlitchAsync(EntityGlitchRequest request) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) d__63 d__ = new d__63(); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>4__this = this; d__.request = request; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__63>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } private void TrackEntity(EntityGlitchWork work) { if (!CanTrackEntity(work)) { UnpendEntity(work); return; } TrackedEntity trackedEntity = new TrackedEntity(); for (int i = 0; i < work.Renderers.Length; i++) { if (!CanTrackEntity(work)) { RestoreRenderers(trackedEntity.Renderers); trackedEntity.Renderers.Clear(); UnpendEntity(work); return; } TrackRenderer(work.Renderers[i], trackedEntity.Renderers); } UnpendEntity(work); if (trackedEntity.Renderers.Count != 0) { if (work.Kind == TrackedEntityKind.Enemy && (Object)(object)work.Enemy != (Object)null && !trackedEnemies.ContainsKey(work.Enemy)) { trackedEnemies.Add(work.Enemy, trackedEntity); return; } if (work.Kind == TrackedEntityKind.Player && (Object)(object)work.Player != (Object)null && !trackedPlayers.ContainsKey(work.Player)) { trackedPlayers.Add(work.Player, trackedEntity); return; } RestoreRenderers(trackedEntity.Renderers); trackedEntity.Renderers.Clear(); } } private bool CanTrackEntity(EntityGlitchWork work) { int result; if (weatherFlowActive && (Object)(object)entityGlitchMaterial != (Object)null && work.Version == trackingVersion) { if (work.Kind != TrackedEntityKind.Enemy) { result = (((Object)(object)work.Player != (Object)null && ConfigManager.EntityGlitchPlayerModels.Value && pendingPlayers.Contains(work.Player) && !trackedPlayers.ContainsKey(work.Player) && Utility.IsPlayerActive(work.Player) && (Object)(object)work.Player != (Object)(object)Utility.LocalPlayer()) ? 1 : 0); } else { EnemyAI? enemy = work.Enemy; result = ((enemy != null && !enemy.isEnemyDead && pendingEnemies.Contains(work.Enemy) && !trackedEnemies.ContainsKey(work.Enemy)) ? 1 : 0); } } else { result = 0; } return (byte)result != 0; } private void UnpendEntity(EntityGlitchWork work) { if (work.Kind == TrackedEntityKind.Enemy && (Object)(object)work.Enemy != (Object)null) { pendingEnemies.Remove(work.Enemy); } else if ((Object)(object)work.Player != (Object)null) { pendingPlayers.Remove(work.Player); } } private static bool IsEnemyBlacklisted(EnemyAI enemy) { if ((Object)(object)enemy.enemyType == (Object)null) { return false; } DawnEnemyInfo dawnInfo = EnemyTypeExtensions.GetDawnInfo(enemy.enemyType); HashSet> hashSet = DawnConfigUtils.ParseNamespacedKeySet(ConfigManager.EntityGlitchEnemyBlacklist.Value); return dawnInfo != null && hashSet.Contains(((DawnBaseInfo)(object)dawnInfo).TypedKey); } private void TrackRenderer(RendererGlitchWork work, List trackedRenderers) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (!((Object)(object)work.Renderer == (Object)null)) { Material[] array = (Material[])(object)new Material[work.OriginalMaterials.Length]; float[] array2 = new float[work.OriginalMaterials.Length]; float num = GlitchStrength(); for (int i = 0; i < work.OriginalMaterials.Length; i++) { Material val = work.OriginalMaterials[i]; Material val2 = new Material(entityGlitchMaterial); float num2 = MaterialUtils.CopyOriginalMaterialProperties(val, val2, originalMaterialPropertyIds, effectMaterialPropertyIds, glitchAlphaClipThreshold); MaterialUtils.CopyFromFirstProperty(val, val2, baseTextureSourcePropertyIds, baseTexturePropertyId, MaterialPropertyCopyKind.Texture, (Texture?)(object)Texture2D.whiteTexture); MaterialUtils.CopyFromFirstProperty(val, val2, baseColorSourcePropertyIds, baseColorTintPropertyId, MaterialPropertyCopyKind.Color); MaterialUtils.CopyFromFirstProperty(val, val2, normalTextureSourcePropertyIds, normalTexturePropertyId, MaterialPropertyCopyKind.Texture); MaterialUtils.CopyFromFirstProperty(val, val2, normalScaleSourcePropertyIds, normalScalePropertyId, MaterialPropertyCopyKind.Float); MaterialUtils.CopyFromFirstProperty(val, val2, smoothnessSourcePropertyIds, smoothnessPropertyId, MaterialPropertyCopyKind.Float); MaterialUtils.ForceOpaqueCutout(val2); EnableEntityGlitchAlphaClip(val2); val2.SetFloat(glitchStrengthPropertyId, num); val2.SetFloat(glitchFlickerPropertyId, GlitchFlicker(num)); val2.SetFloat(entitySeedPropertyId, work.MaterialSeeds[i]); val2.SetFloat(alphaClipThresholdPropertyId, AlphaClipThreshold(num2, num)); array[i] = val2; array2[i] = num2; } work.Renderer.sharedMaterials = array; work.Renderer.renderingLayerMask = 1u; trackedRenderers.Add(new TrackedRenderer { Renderer = work.Renderer, OriginalMaterials = work.OriginalMaterials, GlitchMaterials = array, OriginalAlphaClipThresholds = array2, OriginalRenderingLayerMask = work.OriginalRenderingLayerMask }); } } private static void EnableEntityGlitchAlphaClip(Material material) { material.EnableKeyword("_ALPHATEST_ON"); if (material.HasProperty(alphaCutoffEnablePropertyId)) { material.SetFloat(alphaCutoffEnablePropertyId, 1f); } } private void RemoveTrackedEnemy(EnemyAI? enemy) { if (!((Object)(object)enemy == (Object)null)) { pendingEnemies.Remove(enemy); if (trackedEnemies.TryGetValue(enemy, out TrackedEntity value)) { RestoreRenderers(value.Renderers); value.Renderers.Clear(); trackedEnemies.Remove(enemy); RunFullGlitchPulse(); } } } private void RunFullGlitchPulse() { if (!ShouldAnimateFullGlitch()) { CoroutineTools.Stop((MonoBehaviour)(object)this, ref glitchAnimationCoroutine); } else if (glitchAnimationCoroutine == null) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref glitchAnimationCoroutine, AnimateFullGlitch()); } } private IEnumerator AnimateFullGlitch() { while (ShouldAnimateFullGlitch()) { float glitchStrength = GlitchStrength(); float animationAmount = FullGlitchPulseAmount(); float pulse = Mathf.PerlinNoise(Time.time * 18f, 0.37f); float signedPulse = (pulse - 0.5f) * 2f; float animatedStrength = Mathf.Clamp01(glitchStrength + signedPulse * 0.12f * animationAmount); float animatedFlicker = Mathf.Clamp01(GlitchFlicker(glitchStrength) + pulse * 0.35f * animationAmount); PushGlitch(animatedStrength, animatedFlicker); yield return null; } glitchAnimationCoroutine = null; } private bool ShouldAnimateFullGlitch() { bool flag = trackedEnemies.Count > 0 || (ConfigManager.EntityGlitchPlayerModels.Value && trackedPlayers.Count > 0); return weatherFlowActive && flag && GlitchStrength() > 0.001f && FullGlitchPulseAmount() > 0f; } private void PushGlitch(float glitchStrength, float flicker) { trackedEnemiesToRemove.Clear(); foreach (KeyValuePair trackedEnemy in trackedEnemies) { EnemyAI key = trackedEnemy.Key; if (key == null || key.isEnemyDead) { RestoreRenderers(trackedEnemy.Value.Renderers); trackedEnemy.Value.Renderers.Clear(); trackedEnemiesToRemove.Add(trackedEnemy.Key); } else { PushGlitchToRenderers(trackedEnemy.Value.Renderers, glitchStrength, flicker); } } for (int i = 0; i < trackedEnemiesToRemove.Count; i++) { trackedEnemies.Remove(trackedEnemiesToRemove[i]); } if (!ConfigManager.EntityGlitchPlayerModels.Value) { return; } foreach (TrackedEntity value in trackedPlayers.Values) { PushGlitchToRenderers(value.Renderers, glitchStrength, flicker); } } private void PushGlitchToRenderers(List trackedRenderers, float glitchStrength, float flicker) { for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; for (int j = 0; j < trackedRenderer.GlitchMaterials.Length; j++) { Material val = trackedRenderer.GlitchMaterials[j]; if (!((Object)(object)val == (Object)null)) { val.SetFloat(glitchStrengthPropertyId, glitchStrength); val.SetFloat(glitchFlickerPropertyId, flicker); val.SetFloat(alphaClipThresholdPropertyId, AlphaClipThreshold(trackedRenderer.OriginalAlphaClipThresholds[j], glitchStrength)); } } } } private float AlphaClipThreshold(float originalAlphaClipThreshold, float glitchStrength) { float num = Mathf.Max(originalAlphaClipThreshold, glitchAlphaClipThreshold); return Mathf.Lerp(originalAlphaClipThreshold, num, glitchStrength); } private float GlitchStrength() { float num = Utility.InstabilityProgress(temporalInstabilityLevel, glitchStartInstability, fullGlitchInstability); return Mathf.Clamp01(num * maximumGlitchStrength); } private float GlitchFlicker(float glitchStrength) { return Mathf.Clamp01(glitchFlicker * glitchStrength); } private float FullGlitchPulseAmount() { return GlitchStrength(); } private void RestoreAllTrackedRenderers() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref glitchAnimationCoroutine); ClearPendingMaterials(); foreach (TrackedEntity value in trackedEnemies.Values) { RestoreRenderers(value.Renderers); value.Renderers.Clear(); } trackedEnemies.Clear(); RestoreTrackedPlayers(); } private void RestoreTrackedPlayers() { pendingPlayers.Clear(); foreach (TrackedEntity value in trackedPlayers.Values) { RestoreRenderers(value.Renderers); value.Renderers.Clear(); } trackedPlayers.Clear(); } private void ClearPendingMaterials() { trackingVersion++; pendingEnemies.Clear(); pendingPlayers.Clear(); } private static void RestoreRenderers(List trackedRenderers) { for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; if ((Object)(object)trackedRenderer.Renderer != (Object)null) { trackedRenderer.Renderer.sharedMaterials = trackedRenderer.OriginalMaterials; trackedRenderer.Renderer.renderingLayerMask = trackedRenderer.OriginalRenderingLayerMask; } MaterialUtils.DestroyMaterials(trackedRenderer.GlitchMaterials); } } } internal class ItemEffectManager : MonoBehaviour { [Serializable] internal class TemporalRollSettings { [Range(0f, 100f)] public float Instability = 70f; [Range(0f, 1f)] public float Chance = 0.01f; } [SerializeField] private TemporalRollSettings[] temporalRolls = new TemporalRollSettings[1] { new TemporalRollSettings { Instability = 70f, Chance = 0.01f } }; [Header("Visuals")] [SerializeField] private Color rustColor = new Color(0.62f, 0.24f, 0.07f, 1f); [SerializeField] private Color temporalGlowColor = new Color(0.28f, 1f, 0.48f, 1f); [SerializeField] private AnimationCurve visualProgressCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); [Header("Materials")] [SerializeField] internal Material RusticItemMaterial = null; [SerializeField] internal Material TemporalItemMaterial = null; [Header("Audio")] [SerializeField] internal AudioClip TemporalStatusClip = null; [Header("Instability")] [SerializeField] [Range(0f, 100f)] internal float RustStartInstability = 0f; [SerializeField] [Range(0f, 100f)] internal float FullRustInstability = 90f; [SerializeField] [Min(0f)] internal float TemporalGlowStrength = 1f; [SerializeField] [Min(0f)] internal float TemporalVibrationSeconds = 0.2f; [SerializeField] [Min(0f)] internal float TemporalVibrationDistance = 0.035f; [SerializeField] [Min(1f)] internal float TemporalVibrationFrequency = 55f; [Header("Scrap Value")] [SerializeField] [Min(0f)] internal float RusticScrapValueMultiplier = 0.7f; [SerializeField] [Min(0f)] internal float TemporalScrapValueMultiplier = 1.5f; [Header("Text")] [SerializeField] internal string RusticPrefix = "Rustic "; [SerializeField] internal string TemporalPrefix = "Temporal "; internal static ItemEffectManager? Current { get; private set; } internal int TemporalRollCount => temporalRolls.Length; internal Color RustColor => rustColor; internal Color TemporalGlowColor => temporalGlowColor; internal float EvaluateVisualProgress(float rustProgress) { return Mathf.Clamp01(visualProgressCurve.Evaluate(Mathf.Clamp01(rustProgress))); } internal float GetTemporalRollInstability(int index) { return Utility.ClampInstability(temporalRolls[index].Instability); } internal float GetTemporalRollChance(int index) { return Mathf.Clamp01(temporalRolls[index].Chance); } internal uint GetAllTemporalRollsConsumedMask() { uint num = 0u; int num2 = Mathf.Min(temporalRolls.Length, 32); for (int i = 0; i < num2; i++) { num |= (uint)(1 << i); } return num; } private void Awake() { Current = this; } private void OnDestroy() { if ((Object)(object)Current == (Object)(object)this) { Current = null; } } } internal class PitchManager : MonoBehaviour, ITemporalInstability { [Serializable] private class Blacklist { public AudioSource[] Sources = Array.Empty(); public string[] ExactSourceNames = new string[1] { "Rift Audio Source" }; public string[] HierarchyPathContains = new string[1] { "QuickMenu/ConfigMenuManager(Clone)/AudioManager" }; } private class TrackedSource { public float OriginalPitch; public float CurrentPitchOffset; public float WantedPitchOffset; public float RetargetSeconds; public AudioDistortionFilter DistortionFilter = null; public AudioChorusFilter ChorusFilter = null; public AudioLowPassFilter LowPassFilter = null; public AudioHighPassFilter HighPassFilter = null; public bool AddedDistortionFilter; public bool AddedChorusFilter; public bool AddedLowPassFilter; public bool AddedHighPassFilter; public bool OriginalDistortionEnabled; public bool OriginalChorusEnabled; public bool OriginalLowPassEnabled; public bool OriginalHighPassEnabled; public float OriginalDistortionLevel; public float OriginalChorusDepth; public float OriginalChorusRate; public float OriginalChorusDelay; public float OriginalChorusDryMix; public float OriginalChorusWetMix1; public float OriginalChorusWetMix2; public float OriginalChorusWetMix3; public float OriginalLowPassFrequency; public float OriginalLowPassResonance; public float OriginalHighPassFrequency; public float OriginalHighPassResonance; public uint RandomState; } private readonly struct AudioGlitchInput { public readonly AudioSource AudioSource; public readonly TrackedSource TrackedSource; public readonly float Pulse; public readonly float CurrentStrength; public readonly float OriginalPitch; public readonly float CurrentPitchOffset; public readonly float WantedPitchOffset; public readonly float RetargetSeconds; public readonly uint RandomState; public AudioGlitchInput(AudioSource audioSource, TrackedSource trackedSource, float pulse, float currentStrength, float originalPitch, float currentPitchOffset, float wantedPitchOffset, float retargetSeconds, uint randomState) { AudioSource = audioSource; TrackedSource = trackedSource; Pulse = pulse; CurrentStrength = currentStrength; OriginalPitch = originalPitch; CurrentPitchOffset = currentPitchOffset; WantedPitchOffset = wantedPitchOffset; RetargetSeconds = retargetSeconds; RandomState = randomState; } } private readonly struct AudioGlitchSettings { public readonly int Version; public readonly float ProcessInterval; public readonly float MaximumPitchOffset; public readonly float PitchMoveSpeed; public readonly float MinimumRetargetSeconds; public readonly float MaximumRetargetSeconds; public readonly float MinimumPitch; public readonly float MaximumPitch; public readonly float MaximumDistortion; public readonly float MaximumChorusDepth; public readonly float MinimumChorusRate; public readonly float MaximumChorusRate; public readonly float ChorusDelay; public readonly float MaximumChorusWetMix; public readonly float StableLowPassFrequency; public readonly float UnstableLowPassFrequency; public readonly float StableHighPassFrequency; public readonly float UnstableHighPassFrequency; public AudioGlitchSettings(int version, float processInterval, float maximumPitchOffset, float pitchMoveSpeed, float minimumRetargetSeconds, float maximumRetargetSeconds, float minimumPitch, float maximumPitch, float maximumDistortion, float maximumChorusDepth, float minimumChorusRate, float maximumChorusRate, float chorusDelay, float maximumChorusWetMix, float stableLowPassFrequency, float unstableLowPassFrequency, float stableHighPassFrequency, float unstableHighPassFrequency) { Version = version; ProcessInterval = processInterval; MaximumPitchOffset = maximumPitchOffset; PitchMoveSpeed = pitchMoveSpeed; MinimumRetargetSeconds = minimumRetargetSeconds; MaximumRetargetSeconds = maximumRetargetSeconds; MinimumPitch = minimumPitch; MaximumPitch = maximumPitch; MaximumDistortion = maximumDistortion; MaximumChorusDepth = maximumChorusDepth; MinimumChorusRate = minimumChorusRate; MaximumChorusRate = maximumChorusRate; ChorusDelay = chorusDelay; MaximumChorusWetMix = maximumChorusWetMix; StableLowPassFrequency = stableLowPassFrequency; UnstableLowPassFrequency = unstableLowPassFrequency; StableHighPassFrequency = stableHighPassFrequency; UnstableHighPassFrequency = unstableHighPassFrequency; } } private readonly struct AudioGlitchResult { public readonly AudioSource AudioSource; public readonly TrackedSource TrackedSource; public readonly float WantedPitch; public readonly float CurrentPitchOffset; public readonly float WantedPitchOffset; public readonly float RetargetSeconds; public readonly uint RandomState; public readonly float DistortionLevel; public readonly float ChorusDepth; public readonly float ChorusRate; public readonly float ChorusDelay; public readonly float ChorusDryMix; public readonly float ChorusWetMix1; public readonly float ChorusWetMix2; public readonly float ChorusWetMix3; public readonly float LowPassFrequency; public readonly float LowPassResonance; public readonly float HighPassFrequency; public readonly float HighPassResonance; public AudioGlitchResult(AudioSource audioSource, TrackedSource trackedSource, float wantedPitch, float currentPitchOffset, float wantedPitchOffset, float retargetSeconds, uint randomState, float distortionLevel, float chorusDepth, float chorusRate, float chorusDelay, float chorusDryMix, float chorusWetMix1, float chorusWetMix2, float chorusWetMix3, float lowPassFrequency, float lowPassResonance, float highPassFrequency, float highPassResonance) { AudioSource = audioSource; TrackedSource = trackedSource; WantedPitch = wantedPitch; CurrentPitchOffset = currentPitchOffset; WantedPitchOffset = wantedPitchOffset; RetargetSeconds = retargetSeconds; RandomState = randomState; DistortionLevel = distortionLevel; ChorusDepth = chorusDepth; ChorusRate = chorusRate; ChorusDelay = chorusDelay; ChorusDryMix = chorusDryMix; ChorusWetMix1 = chorusWetMix1; ChorusWetMix2 = chorusWetMix2; ChorusWetMix3 = chorusWetMix3; LowPassFrequency = lowPassFrequency; LowPassResonance = lowPassResonance; HighPassFrequency = highPassFrequency; HighPassResonance = highPassResonance; } } private readonly struct AudioGlitchBatch { public readonly int Version; public readonly AudioGlitchResult[] Results; public AudioGlitchBatch(int version, AudioGlitchResult[] results) { Version = version; Results = results; } } [CompilerGenerated] private sealed class d__49 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public AudioGlitchInput[] inputs; public AudioGlitchSettings settings; public PitchManager <>4__this; private AudioGlitchBatch 5__1; private int 5__2; private AudioGlitchResult 5__3; private TrackedSource 5__4; private Awaiter <>u__1; private Awaiter <>u__2; private void MoveNext() { //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00ec: 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_001f: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { Awaiter val; Awaiter val3; if (num != 0) { if (num == 1) { val = <>u__2; <>u__2 = default(Awaiter); num = (<>1__state = -1); goto IL_00fb; } SwitchToThreadPoolAwaitable val2 = UniTask.SwitchToThreadPool(); val3 = ((SwitchToThreadPoolAwaitable)(ref val2)).GetAwaiter(); if (!((Awaiter)(ref val3)).IsCompleted) { num = (<>1__state = 0); <>u__1 = val3; d__49 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__49>(ref val3, ref d__); return; } } else { val3 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref val3)).GetResult(); 5__1 = BuildGlitchBatch(inputs, settings); SwitchToMainThreadAwaitable val4 = UniTask.SwitchToMainThread(default(CancellationToken)); val = ((SwitchToMainThreadAwaitable)(ref val4)).GetAwaiter(); if (!((Awaiter)(ref val)).IsCompleted) { num = (<>1__state = 1); <>u__2 = val; d__49 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__49>(ref val, ref d__); return; } goto IL_00fb; IL_00fb: ((Awaiter)(ref val)).GetResult(); if (!((Object)(object)<>4__this == (Object)null)) { <>4__this.glitchBatchRunning = false; if (5__1.Version == <>4__this.glitchVersion) { 5__2 = 0; while (5__2 < 5__1.Results.Length) { 5__3 = 5__1.Results[5__2]; if (!((Object)(object)5__3.AudioSource == (Object)null) && <>4__this.trackedSources.TryGetValue(5__3.AudioSource, out 5__4) && 5__4 == 5__3.TrackedSource) { <>4__this.PushGlitchResult(5__3.AudioSource, 5__4, 5__3); 5__3 = default(AudioGlitchResult); 5__4 = null; } 5__2++; } } } } catch (Exception exception) { <>1__state = -2; 5__1 = default(AudioGlitchBatch); ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; 5__1 = default(AudioGlitchBatch); ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [Header("Blacklist")] [SerializeField] private Blacklist blacklist = new Blacklist(); [Header("Instability")] [SerializeField] [Range(0f, 100f)] private float startsAtInstability = 80f; [SerializeField] [Range(0f, 100f)] private float fullAtInstability = 100f; [Header("Pitch")] [SerializeField] private float maximumPitchOffset = 0.16f; [SerializeField] private float pitchMoveSpeed = 7f; [SerializeField] private float minimumRetargetSeconds = 0.12f; [SerializeField] private float maximumRetargetSeconds = 0.32f; [SerializeField] private float minimumPitch = 0.1f; [SerializeField] private float maximumPitch = 3f; [Header("Distortion")] [SerializeField] private float maximumDistortion = 0.035f; [Header("Chorus")] [SerializeField] private float maximumChorusDepth = 0.08f; [SerializeField] private float minimumChorusRate = 0.25f; [SerializeField] private float maximumChorusRate = 1.35f; [SerializeField] private float chorusDelay = 9f; [SerializeField] private float maximumChorusWetMix = 0.08f; [Header("Filters")] [SerializeField] private float stableLowPassFrequency = 22000f; [SerializeField] private float unstableLowPassFrequency = 13500f; [SerializeField] private float stableHighPassFrequency = 10f; [SerializeField] private float unstableHighPassFrequency = 55f; [Header("Timing")] [SerializeField] [Min(0.01f)] private float processInterval = 0.04f; [SerializeField] [Min(0.01f)] private float sourceScanInterval = 0.5f; [SerializeField] private float effectMoveSpeed = 5f; private readonly Dictionary trackedSources = new Dictionary(); private readonly HashSet manualBlacklistedSources = new HashSet(); private readonly List removeBuffer = new List(); private readonly List glitchInputBuffer = new List(); private Coroutine? audioGlitchCoroutine; private float temporalInstabilityLevel; private float currentStrength; private float sourceScanTimer; private int glitchVersion; private bool glitchBatchRunning; private bool weatherFlowActive; private void OnEnable() { if (ConfigManager.AudioPitchingEnabled != null) { if (!ConfigManager.AudioPitchingEnabled.Value) { Object.Destroy((Object)(object)((Component)this).gameObject); } else if (Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); CoroutineTools.Start((MonoBehaviour)(object)this, ref audioGlitchCoroutine, ProcessAudioGlitch()); } } } private void OnDisable() { if (weatherFlowActive) { weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref audioGlitchCoroutine); glitchVersion++; glitchBatchRunning = false; RestoreAllSources(); temporalInstabilityLevel = 0f; currentStrength = 0f; } } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); } private IEnumerator ProcessAudioGlitch() { WaitForSeconds processWait = new WaitForSeconds(processInterval); WaitForSeconds sleepWait = new WaitForSeconds(sourceScanInterval); while (true) { if (temporalInstabilityLevel < startsAtInstability) { if (trackedSources.Count > 0 || currentStrength > 0f) { currentStrength = 0f; RestoreAllSources(); } yield return sleepWait; continue; } sourceScanTimer -= processInterval; if (sourceScanTimer <= 0f) { sourceScanTimer = sourceScanInterval; manualBlacklistedSources.Clear(); for (int i = 0; i < blacklist.Sources.Length; i++) { if ((Object)(object)blacklist.Sources[i] != (Object)null) { manualBlacklistedSources.Add(blacklist.Sources[i]); } } ScanAudioSources(); } GlitchAudio(); yield return processWait; } } private void ScanAudioSources() { AudioSource[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { TrackAudioSource(array[i]); } } private void TrackAudioSource(AudioSource audioSource) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)audioSource == (Object)null)) { Scene scene = ((Component)audioSource).gameObject.scene; if (((Scene)(ref scene)).IsValid() && !trackedSources.ContainsKey(audioSource) && !IsBlacklisted(audioSource)) { trackedSources.Add(audioSource, CreateTrackedSource(audioSource)); } } } private TrackedSource CreateTrackedSource(AudioSource audioSource) { uint state = BuildRandomState(((Object)audioSource).GetInstanceID()); TrackedSource trackedSource = new TrackedSource { OriginalPitch = audioSource.pitch, CurrentPitchOffset = 0f, WantedPitchOffset = 0f, RetargetSeconds = RandomRange(ref state, minimumRetargetSeconds, maximumRetargetSeconds), DistortionFilter = ((Component)audioSource).GetComponent(), RandomState = state }; trackedSource.AddedDistortionFilter = (Object)(object)trackedSource.DistortionFilter == (Object)null; if (trackedSource.AddedDistortionFilter) { trackedSource.DistortionFilter = ((Component)audioSource).gameObject.AddComponent(); } trackedSource.ChorusFilter = ((Component)audioSource).GetComponent(); trackedSource.AddedChorusFilter = (Object)(object)trackedSource.ChorusFilter == (Object)null; if (trackedSource.AddedChorusFilter) { trackedSource.ChorusFilter = ((Component)audioSource).gameObject.AddComponent(); } trackedSource.LowPassFilter = ((Component)audioSource).GetComponent(); trackedSource.AddedLowPassFilter = (Object)(object)trackedSource.LowPassFilter == (Object)null; if (trackedSource.AddedLowPassFilter) { trackedSource.LowPassFilter = ((Component)audioSource).gameObject.AddComponent(); } trackedSource.HighPassFilter = ((Component)audioSource).GetComponent(); trackedSource.AddedHighPassFilter = (Object)(object)trackedSource.HighPassFilter == (Object)null; if (trackedSource.AddedHighPassFilter) { trackedSource.HighPassFilter = ((Component)audioSource).gameObject.AddComponent(); } StoreOriginalFilterValues(trackedSource); DisableTrackedFilters(trackedSource); return trackedSource; } private void StoreOriginalFilterValues(TrackedSource trackedSource) { trackedSource.OriginalDistortionEnabled = ((Behaviour)trackedSource.DistortionFilter).enabled; trackedSource.OriginalDistortionLevel = trackedSource.DistortionFilter.distortionLevel; trackedSource.OriginalChorusEnabled = ((Behaviour)trackedSource.ChorusFilter).enabled; trackedSource.OriginalChorusDepth = trackedSource.ChorusFilter.depth; trackedSource.OriginalChorusRate = trackedSource.ChorusFilter.rate; trackedSource.OriginalChorusDelay = trackedSource.ChorusFilter.delay; trackedSource.OriginalChorusDryMix = trackedSource.ChorusFilter.dryMix; trackedSource.OriginalChorusWetMix1 = trackedSource.ChorusFilter.wetMix1; trackedSource.OriginalChorusWetMix2 = trackedSource.ChorusFilter.wetMix2; trackedSource.OriginalChorusWetMix3 = trackedSource.ChorusFilter.wetMix3; trackedSource.OriginalLowPassEnabled = ((Behaviour)trackedSource.LowPassFilter).enabled; trackedSource.OriginalLowPassFrequency = trackedSource.LowPassFilter.cutoffFrequency; trackedSource.OriginalLowPassResonance = trackedSource.LowPassFilter.lowpassResonanceQ; trackedSource.OriginalHighPassEnabled = ((Behaviour)trackedSource.HighPassFilter).enabled; trackedSource.OriginalHighPassFrequency = trackedSource.HighPassFilter.cutoffFrequency; trackedSource.OriginalHighPassResonance = trackedSource.HighPassFilter.highpassResonanceQ; } private bool IsBlacklisted(AudioSource audioSource) { if (manualBlacklistedSources.Contains(audioSource)) { return true; } for (int i = 0; i < blacklist.ExactSourceNames.Length; i++) { if (((Object)audioSource).name == blacklist.ExactSourceNames[i]) { return true; } } string text = ((Object)((Component)audioSource).transform).name; Transform parent = ((Component)audioSource).transform.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } for (int j = 0; j < blacklist.HierarchyPathContains.Length; j++) { if (text.Contains(blacklist.HierarchyPathContains[j])) { return true; } } return (Object)(object)((Component)audioSource).GetComponentInParent() != (Object)null; } private void GlitchAudio() { //IL_029c: Unknown result type (might be due to invalid IL or missing references) float num = Utility.InstabilityProgress(temporalInstabilityLevel, startsAtInstability, fullAtInstability); currentStrength = Mathf.Lerp(currentStrength, num, effectMoveSpeed * processInterval); if (currentStrength <= 0.01f && glitchBatchRunning) { glitchVersion++; glitchBatchRunning = false; } removeBuffer.Clear(); glitchInputBuffer.Clear(); float num2 = Time.time * 3f; foreach (KeyValuePair trackedSource in trackedSources) { AudioSource key = trackedSource.Key; TrackedSource value = trackedSource.Value; if ((Object)(object)key == (Object)null) { removeBuffer.Add(key); } else if (IsBlacklisted(key)) { RestoreSource(key, value); removeBuffer.Add(key); } else if (currentStrength <= 0.01f) { RestoreGlitchValues(key, value); } else { glitchInputBuffer.Add(new AudioGlitchInput(key, value, Mathf.PerlinNoise(num2, (float)((Object)key).GetInstanceID() * 0.01f), currentStrength, value.OriginalPitch, value.CurrentPitchOffset, value.WantedPitchOffset, value.RetargetSeconds, value.RandomState)); } } for (int i = 0; i < removeBuffer.Count; i++) { trackedSources.Remove(removeBuffer[i]); } if (!(currentStrength <= 0.01f) && glitchInputBuffer.Count != 0 && !glitchBatchRunning) { AudioGlitchInput[] inputs = glitchInputBuffer.ToArray(); AudioGlitchSettings settings = new AudioGlitchSettings(++glitchVersion, processInterval, maximumPitchOffset, pitchMoveSpeed, minimumRetargetSeconds, maximumRetargetSeconds, minimumPitch, maximumPitch, maximumDistortion, maximumChorusDepth, minimumChorusRate, maximumChorusRate, chorusDelay, maximumChorusWetMix, stableLowPassFrequency, unstableLowPassFrequency, stableHighPassFrequency, unstableHighPassFrequency); glitchBatchRunning = true; UniTaskExtensions.Forget(BuildGlitchBatchAsync(inputs, settings)); } } [AsyncStateMachine(typeof(d__49))] [DebuggerStepThrough] private UniTask BuildGlitchBatchAsync(AudioGlitchInput[] inputs, AudioGlitchSettings settings) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) d__49 d__ = new d__49(); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>4__this = this; d__.inputs = inputs; d__.settings = settings; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__49>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } private static AudioGlitchBatch BuildGlitchBatch(AudioGlitchInput[] inputs, AudioGlitchSettings settings) { AudioGlitchResult[] array = new AudioGlitchResult[inputs.Length]; for (int i = 0; i < inputs.Length; i++) { AudioGlitchInput audioGlitchInput = inputs[i]; float num = Clamp01(audioGlitchInput.CurrentStrength * Lerp(0.65f, 1.1f, audioGlitchInput.Pulse)); float num2 = audioGlitchInput.RetargetSeconds - settings.ProcessInterval; float num3 = audioGlitchInput.WantedPitchOffset; uint state = audioGlitchInput.RandomState; if (num2 <= 0f) { float num4 = settings.MaximumPitchOffset * num; num3 = RandomRange(ref state, 0f - num4, num4); num2 = RandomRange(ref state, settings.MinimumRetargetSeconds, settings.MaximumRetargetSeconds); } float num5 = Lerp(audioGlitchInput.CurrentPitchOffset, num3, settings.PitchMoveSpeed * settings.ProcessInterval); float wantedPitch = Clamp(audioGlitchInput.OriginalPitch + num5, settings.MinimumPitch, settings.MaximumPitch); array[i] = new AudioGlitchResult(audioGlitchInput.AudioSource, audioGlitchInput.TrackedSource, wantedPitch, num5, num3, num2, state, settings.MaximumDistortion * num, settings.MaximumChorusDepth * num, Lerp(settings.MinimumChorusRate, settings.MaximumChorusRate, audioGlitchInput.Pulse), settings.ChorusDelay, 1f - settings.MaximumChorusWetMix * num, settings.MaximumChorusWetMix * num, settings.MaximumChorusWetMix * 0.5f * num, settings.MaximumChorusWetMix * 0.25f * num, Lerp(settings.StableLowPassFrequency, settings.UnstableLowPassFrequency, num), Lerp(1f, 1.25f, num), Lerp(settings.StableHighPassFrequency, settings.UnstableHighPassFrequency, num), Lerp(1f, 1.15f, num)); } return new AudioGlitchBatch(settings.Version, array); } private void PushGlitchResult(AudioSource audioSource, TrackedSource trackedSource, AudioGlitchResult result) { trackedSource.CurrentPitchOffset = result.CurrentPitchOffset; trackedSource.WantedPitchOffset = result.WantedPitchOffset; trackedSource.RetargetSeconds = result.RetargetSeconds; trackedSource.RandomState = result.RandomState; audioSource.pitch = result.WantedPitch; ((Behaviour)trackedSource.DistortionFilter).enabled = true; trackedSource.DistortionFilter.distortionLevel = result.DistortionLevel; ((Behaviour)trackedSource.ChorusFilter).enabled = true; trackedSource.ChorusFilter.depth = result.ChorusDepth; trackedSource.ChorusFilter.rate = result.ChorusRate; trackedSource.ChorusFilter.delay = result.ChorusDelay; trackedSource.ChorusFilter.dryMix = result.ChorusDryMix; trackedSource.ChorusFilter.wetMix1 = result.ChorusWetMix1; trackedSource.ChorusFilter.wetMix2 = result.ChorusWetMix2; trackedSource.ChorusFilter.wetMix3 = result.ChorusWetMix3; ((Behaviour)trackedSource.LowPassFilter).enabled = true; trackedSource.LowPassFilter.cutoffFrequency = result.LowPassFrequency; trackedSource.LowPassFilter.lowpassResonanceQ = result.LowPassResonance; ((Behaviour)trackedSource.HighPassFilter).enabled = true; trackedSource.HighPassFilter.cutoffFrequency = result.HighPassFrequency; trackedSource.HighPassFilter.highpassResonanceQ = result.HighPassResonance; } private void RestoreGlitchValues(AudioSource audioSource, TrackedSource trackedSource) { if (!((Object)(object)audioSource == (Object)null)) { audioSource.pitch = trackedSource.OriginalPitch; trackedSource.CurrentPitchOffset = 0f; trackedSource.WantedPitchOffset = 0f; DisableTrackedFilters(trackedSource); } } private void DisableTrackedFilters(TrackedSource trackedSource) { ((Behaviour)trackedSource.DistortionFilter).enabled = false; trackedSource.DistortionFilter.distortionLevel = 0f; ((Behaviour)trackedSource.ChorusFilter).enabled = false; trackedSource.ChorusFilter.depth = 0f; trackedSource.ChorusFilter.rate = minimumChorusRate; trackedSource.ChorusFilter.delay = chorusDelay; trackedSource.ChorusFilter.dryMix = 1f; trackedSource.ChorusFilter.wetMix1 = 0f; trackedSource.ChorusFilter.wetMix2 = 0f; trackedSource.ChorusFilter.wetMix3 = 0f; ((Behaviour)trackedSource.LowPassFilter).enabled = false; trackedSource.LowPassFilter.cutoffFrequency = stableLowPassFrequency; trackedSource.LowPassFilter.lowpassResonanceQ = 1f; ((Behaviour)trackedSource.HighPassFilter).enabled = false; trackedSource.HighPassFilter.cutoffFrequency = stableHighPassFrequency; trackedSource.HighPassFilter.highpassResonanceQ = 1f; } private void RestoreSource(AudioSource audioSource, TrackedSource trackedSource) { if (!((Object)(object)audioSource == (Object)null)) { audioSource.pitch = trackedSource.OriginalPitch; trackedSource.DistortionFilter.distortionLevel = trackedSource.OriginalDistortionLevel; ((Behaviour)trackedSource.DistortionFilter).enabled = trackedSource.OriginalDistortionEnabled; trackedSource.ChorusFilter.depth = trackedSource.OriginalChorusDepth; trackedSource.ChorusFilter.rate = trackedSource.OriginalChorusRate; trackedSource.ChorusFilter.delay = trackedSource.OriginalChorusDelay; trackedSource.ChorusFilter.dryMix = trackedSource.OriginalChorusDryMix; trackedSource.ChorusFilter.wetMix1 = trackedSource.OriginalChorusWetMix1; trackedSource.ChorusFilter.wetMix2 = trackedSource.OriginalChorusWetMix2; trackedSource.ChorusFilter.wetMix3 = trackedSource.OriginalChorusWetMix3; ((Behaviour)trackedSource.ChorusFilter).enabled = trackedSource.OriginalChorusEnabled; trackedSource.LowPassFilter.cutoffFrequency = trackedSource.OriginalLowPassFrequency; trackedSource.LowPassFilter.lowpassResonanceQ = trackedSource.OriginalLowPassResonance; ((Behaviour)trackedSource.LowPassFilter).enabled = trackedSource.OriginalLowPassEnabled; trackedSource.HighPassFilter.cutoffFrequency = trackedSource.OriginalHighPassFrequency; trackedSource.HighPassFilter.highpassResonanceQ = trackedSource.OriginalHighPassResonance; ((Behaviour)trackedSource.HighPassFilter).enabled = trackedSource.OriginalHighPassEnabled; if (trackedSource.AddedDistortionFilter) { Object.Destroy((Object)(object)trackedSource.DistortionFilter); } if (trackedSource.AddedChorusFilter) { Object.Destroy((Object)(object)trackedSource.ChorusFilter); } if (trackedSource.AddedLowPassFilter) { Object.Destroy((Object)(object)trackedSource.LowPassFilter); } if (trackedSource.AddedHighPassFilter) { Object.Destroy((Object)(object)trackedSource.HighPassFilter); } } } private static uint BuildRandomState(int sourceId) { uint num = (uint)sourceId; num ^= 0x811C9DC5u; num *= 16777619; num ^= num >> 16; num *= 2246822519u; return (num == 0) ? 1u : num; } private static float RandomRange(ref uint state, float minimum, float maximum) { return Lerp(minimum, maximum, NextRandom01(ref state)); } private static float NextRandom01(ref uint state) { state ^= state << 13; state ^= state >> 17; state ^= state << 5; return (float)(state & 0xFFFFFF) / 16777216f; } private static float Clamp(float value, float minimum, float maximum) { return (value < minimum) ? minimum : ((value > maximum) ? maximum : value); } private static float Clamp01(float value) { return Clamp(value, 0f, 1f); } private static float Lerp(float from, float to, float t) { return from + (to - from) * Clamp01(t); } private void RestoreAllSources() { glitchVersion++; glitchBatchRunning = false; foreach (KeyValuePair trackedSource in trackedSources) { RestoreSource(trackedSource.Key, trackedSource.Value); } trackedSources.Clear(); removeBuffer.Clear(); } } internal enum TemporalRiftSpawnLocation { Inside, Outside } internal class RiftManager : MonoBehaviour, ITemporalInstability { internal static RiftManager? current; private static bool temporalStormWeatherActive; [Header("Instability")] [SerializeField] [Range(0f, 100f)] private float spawnStartInstability = 45f; [SerializeField] [Range(0f, 100f)] private float fullSpawnInstability = 100f; [Header("Budget")] [SerializeField] [Min(0f)] private int maximumAliveRifts = 4; [SerializeField] [Min(0f)] private float minimumDistanceBetweenRifts = 35f; [SerializeField] [Range(0f, 1f)] private float outsideSpawnChance = 0.5f; [Header("Timing")] [SerializeField] [Min(1f)] private float processIntervalSeconds = 5f; [SerializeField] [Min(1f)] private float minimumSpawnDelaySeconds = 18f; [SerializeField] [Min(1f)] private float maximumSpawnDelaySeconds = 35f; [SerializeField] [Min(1f)] private float despawnDelaySeconds = 12f; [Header("Placement")] [SerializeField] [Min(1f)] private float insideNodeSearchRadius = 12f; [SerializeField] [Min(1f)] private float outsideNodeSearchRadius = 10f; [SerializeField] [Min(1f)] private int placementAttempts = 24; private readonly List trackedRifts = new List(); private readonly Random random = new Random(); private readonly RaycastHit[] placementHits = (RaycastHit[])(object)new RaycastHit[16]; private Coroutine? processCoroutine; private float temporalInstabilityLevel; private float nextSpawnTime; private float nextDespawnTime; private bool directorActive; private bool loggedMissingRiftInfo; private bool loggedNoSpawnLocations; public static void SetWeatherActive(bool active) { if (temporalStormWeatherActive != active) { temporalStormWeatherActive = active; TemporalInstabilityAPI.SetTemporalStormRoundActive(active); Log.Info(active ? "Temporal storm weather started" : "Temporal storm weather stopped"); } } private void OnEnable() { SetWeatherActive(active: true); if (NetworkUtils.IsServer()) { current = this; directorActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Server); CoroutineTools.Start((MonoBehaviour)(object)this, ref processCoroutine, ProcessRifts()); } } private void OnDisable() { SetWeatherActive(active: false); if (directorActive) { directorActive = false; DespawnAllTrackedRifts(); TemporalInstabilityAPI.Unregister(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref processCoroutine); if ((Object)(object)current == (Object)(object)this) { current = null; } } } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); } private IEnumerator ProcessRifts() { WaitForSeconds processWait = new WaitForSeconds(processIntervalSeconds); while (directorActive) { FindLiveRifts(); AdjustRiftCount(); yield return processWait; } } private void AdjustRiftCount() { float num = Utility.InstabilityProgress(temporalInstabilityLevel, spawnStartInstability, fullSpawnInstability); int num2 = (temporalStormWeatherActive ? Mathf.RoundToInt(Mathf.Lerp(0f, (float)maximumAliveRifts, num)) : 0); if (trackedRifts.Count < num2 && Time.time >= nextSpawnTime) { if (SpawnRift()) { nextSpawnTime = Time.time + Utility.RandomRange(random, minimumSpawnDelaySeconds, maximumSpawnDelaySeconds); } } else if (trackedRifts.Count > num2 && Time.time >= nextDespawnTime) { DespawnRift(ChooseRiftToDespawn()); nextDespawnTime = Time.time + despawnDelaySeconds; } } private bool SpawnRift() { //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) DawnMapObjectInfo val = default(DawnMapObjectInfo); if (!((Registry)(object)LethalContent.MapObjects).TryGetValue(Keys.TemporalRiftMapObject, ref val)) { if (!loggedMissingRiftInfo) { Log.Warn("Temporal rift is not registered in Dawn"); loggedMissingRiftInfo = true; } return false; } loggedMissingRiftInfo = false; bool flag = false; if (val.InsideInfo != null && RoundManager.Instance.insideAINodes.Length != 0) { IndoorMapHazardType indoorMapHazardType = val.InsideInfo.IndoorMapHazardType; flag = RoundManager.Instance.currentDungeonType != 4 || indoorMapHazardType.allowInMineshaft; } bool flag2 = val.OutsideInfo != null && RoundManager.Instance.outsideAINodes.Length != 0; if (!flag && !flag2) { if (!loggedNoSpawnLocations) { Log.Warn("Temporal rift has no usable spawn settings on this moon"); loggedNoSpawnLocations = true; } return false; } loggedNoSpawnLocations = false; TemporalRiftSpawnLocation temporalRiftSpawnLocation = TemporalRiftSpawnLocation.Inside; if (flag && flag2) { temporalRiftSpawnLocation = ((random.NextDouble() < (double)outsideSpawnChance) ? TemporalRiftSpawnLocation.Outside : TemporalRiftSpawnLocation.Inside); } else if (flag2) { temporalRiftSpawnLocation = TemporalRiftSpawnLocation.Outside; } if (temporalRiftSpawnLocation == TemporalRiftSpawnLocation.Outside) { DawnOutsideMapObjectInfo outsideInfo = val.OutsideInfo; if (outsideInfo == null || !ChooseOutsideSpawnPosition(outsideInfo, out var spawnPosition, out var surfaceNormal)) { return false; } SpawnableOutsideObject spawnableOutsideObject = outsideInfo.SpawnableOutsideObject; GameObject val2 = Object.Instantiate(spawnableOutsideObject.prefabToSpawn, spawnPosition, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform); if (outsideInfo.AlignWithTerrain) { val2.transform.up = surfaceNormal; } Vector3 eulerAngles = val2.transform.eulerAngles; eulerAngles.y = (spawnableOutsideObject.spawnFacingAwayFromWall ? RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(spawnPosition + Vector3.up * 0.2f, 25f, 6) : Utility.RandomRange(random, 0f, 360f)); val2.transform.eulerAngles = eulerAngles; Transform transform = val2.transform; transform.localEulerAngles += spawnableOutsideObject.rotationOffset; MapSpawnUtils.DestroyTreesAroundOutsideObject(spawnableOutsideObject, spawnPosition); if (!SpawnNetworkRift(val2, TemporalRiftSpawnLocation.Outside, out TemporalRift rift)) { return false; } trackedRifts.Add(rift); return true; } DawnInsideMapObjectInfo insideInfo = val.InsideInfo; if (insideInfo == null || !ChooseInsideSpawnPosition(insideInfo.IndoorMapHazardType, out var spawnPosition2)) { return false; } GameObject val3 = Object.Instantiate(insideInfo.IndoorMapHazardType.prefabToSpawn, spawnPosition2, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform); IndoorMapHazardType indoorMapHazardType2 = insideInfo.IndoorMapHazardType; float num = Utility.RandomRange(random, 0f, 360f); if (indoorMapHazardType2.spawnFacingAwayFromWall) { num = RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(spawnPosition2 + Vector3.up * 0.2f, 25f, 6); } if (indoorMapHazardType2.spawnFacingWall) { num = RoundManager.Instance.YRotationThatFacesTheNearestFromPosition(spawnPosition2 + Vector3.up * 0.2f, 25f, 6); } val3.transform.eulerAngles = new Vector3(0f, num, 0f); if (indoorMapHazardType2.spawnWithBackToWall && MapSpawnUtils.TryRaycastClosest(val3.transform.position, -val3.transform.forward, placementHits, 100f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1, out var closestHit)) { val3.transform.position = ((RaycastHit)(ref closestHit)).point; if (indoorMapHazardType2.spawnWithBackFlushAgainstWall) { val3.transform.forward = ((RaycastHit)(ref closestHit)).normal; val3.transform.eulerAngles = new Vector3(0f, val3.transform.eulerAngles.y, 0f); } } if (!SpawnNetworkRift(val3, TemporalRiftSpawnLocation.Inside, out TemporalRift rift2)) { return false; } trackedRifts.Add(rift2); return true; } private bool ChooseInsideSpawnPosition(IndoorMapHazardType hazardType, out Vector3 spawnPosition) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; EntranceTeleport[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < placementAttempts; i++) { GameObject val = insideAINodes[random.Next(0, insideAINodes.Length)]; Vector3 randomNavMeshPositionInBoxPredictable = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val.transform.position, insideNodeSearchRadius, default(NavMeshHit), random, -1, 1f); if (!RoundManager.Instance.GotNavMeshPositionResult) { continue; } if (hazardType.disallowSpawningNearEntrances) { bool flag = false; foreach (EntranceTeleport val2 in array) { if (!val2.isEntranceToBuilding && Vector3.Distance(((Component)val2.entrancePoint).transform.position, randomNavMeshPositionInBoxPredictable) < 5.5f) { flag = true; break; } } if (flag) { continue; } } if (IsTooCloseToTrackedRift(randomNavMeshPositionInBoxPredictable)) { continue; } spawnPosition = randomNavMeshPositionInBoxPredictable; return true; } spawnPosition = Vector3.zero; return false; } private bool ChooseOutsideSpawnPosition(DawnOutsideMapObjectInfo outsideInfo, out Vector3 spawnPosition, out Vector3 surfaceNormal) { //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_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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) SpawnableOutsideObject spawnableOutsideObject = outsideInfo.SpawnableOutsideObject; float num = spawnableOutsideObject.objectWidth; GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes; EntranceTeleport[] entranceTeleports = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); Transform[] shipSpawnPathPoints = RoundManager.Instance.shipSpawnPathPoints; GameObject[] spawnDenialPoints = GameObject.FindGameObjectsWithTag("SpawnDenialPoint"); GameObject itemShipLandingNode = GameObject.FindGameObjectWithTag("ItemShipLandingNode"); if (outsideAINodes.Length <= outsideInfo.MinimumAINodeSpawnRequirement) { spawnPosition = Vector3.zero; surfaceNormal = Vector3.up; return false; } for (int i = 0; i < placementAttempts; i++) { GameObject val = outsideAINodes[random.Next(0, outsideAINodes.Length)]; Vector3 origin = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val.transform.position, outsideNodeSearchRadius, default(NavMeshHit), random, -1, 1f) + Vector3.up * 2f; if (RoundManager.Instance.GotNavMeshPositionResult && MapSpawnUtils.TryRaycastClosest(origin, Vector3.down, placementHits, 100f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1, out var closestHit) && MapSpawnUtils.MatchesOutsideFloorTags(((RaycastHit)(ref closestHit)).collider, spawnableOutsideObject.spawnableFloorTags)) { Vector3 val2 = RoundManager.Instance.PositionEdgeCheck(((RaycastHit)(ref closestHit)).point, num, -1, default(Vector3)); if (!(val2 == Vector3.zero) && !MapSpawnUtils.IsDeniedOutsidePosition(val2, num, entranceTeleports, shipSpawnPathPoints, spawnDenialPoints, itemShipLandingNode) && !IsTooCloseToTrackedRift(val2)) { spawnPosition = val2; surfaceNormal = ((RaycastHit)(ref closestHit)).normal; return true; } } } spawnPosition = Vector3.zero; surfaceNormal = Vector3.up; return false; } private bool SpawnNetworkRift(GameObject spawnedRift, TemporalRiftSpawnLocation spawnLocation, out TemporalRift rift) { rift = spawnedRift.GetComponentInChildren(); if ((Object)(object)rift == (Object)null) { Log.Error("Temporal rift prefab is missing temporal rift"); Object.Destroy((Object)(object)spawnedRift); return false; } NetworkObject component = spawnedRift.GetComponent(); if ((Object)(object)component == (Object)null) { Log.Error("Temporal rift prefab needs a root network object"); Object.Destroy((Object)(object)spawnedRift); return false; } rift.SetSpawnLocation(spawnLocation); component.Spawn(true); return true; } private bool IsTooCloseToTrackedRift(Vector3 position) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) float num = minimumDistanceBetweenRifts * minimumDistanceBetweenRifts; for (int i = 0; i < trackedRifts.Count; i++) { TemporalRift temporalRift = trackedRifts[i]; if (!((Object)(object)temporalRift == (Object)null)) { Vector3 val = ((Component)temporalRift).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude < num) { return true; } } } return false; } private void FindLiveRifts() { trackedRifts.Clear(); TemporalRift[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { DawnMapObjectNamespacedKeyContainer componentInParent = ((Component)array[i]).GetComponentInParent(); if (!array[i].IsClosing && componentInParent != null && ((object)componentInParent.Value).Equals((object?)Keys.TemporalRiftMapObject)) { trackedRifts.Add(array[i]); } } } private TemporalRift ChooseRiftToDespawn() { //IL_0015: 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) TemporalRift temporalRift = trackedRifts[0]; float num = ClosestPlayerSqrDistance(((Component)temporalRift).transform.position); for (int i = 1; i < trackedRifts.Count; i++) { TemporalRift temporalRift2 = trackedRifts[i]; if (!((Object)(object)temporalRift2 == (Object)null)) { float num2 = ClosestPlayerSqrDistance(((Component)temporalRift2).transform.position); if (num2 > num) { temporalRift = temporalRift2; num = num2; } } } return temporalRift; } private float ClosestPlayerSqrDistance(Vector3 position) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) float num = float.PositiveInfinity; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Utility.IsPlayerActive(val)) { Vector3 val2 = ((Component)val).transform.position - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; } } } return num; } private void DespawnRift(TemporalRift rift) { if (!((Object)(object)rift == (Object)null)) { NetworkObject componentInParent = ((Component)rift).GetComponentInParent(); trackedRifts.Remove(rift); if (componentInParent != null && componentInParent.IsSpawned) { rift.CloseAndDespawn(); } else { Object.Destroy((Object)(object)((Component)rift).gameObject); } } } internal void DespawnAllTrackedRifts() { FindLiveRifts(); for (int num = trackedRifts.Count - 1; num >= 0; num--) { DespawnRift(trackedRifts[num]); } trackedRifts.Clear(); } } internal class RustDecalManager : MonoBehaviour, ITemporalInstability { [Serializable] private class ActivationSettings { [Range(0f, 100f)] public float StartInstability = 75f; [Range(0f, 100f)] public float FullInstability = 95f; } [Serializable] private class AngleFadeSettings { [Range(0f, 180f)] public float StartAngle = 55f; [Range(0f, 180f)] public float EndAngle = 75f; } [Header("Follow")] [SerializeField] private PositionConstraint positionConstraint = null; [Header("Activation")] [SerializeField] private ActivationSettings activation = new ActivationSettings(); [Header("Surface Rejection")] [SerializeField] private AngleFadeSettings angleFade = new AngleFadeSettings(); [Header("Shader")] [SerializeField] [Range(0f, 1f)] private float maxCoverage = 0.2f; [SerializeField] private string visibilityPropertyName = "_Visibility"; [SerializeField] private string maxCoveragePropertyName = "_MaxCoverage"; private DecalProjector? rustProjector; private Material? runtimeMaterial; private bool weatherFlowActive; private int visibilityPropertyId; private int maxCoveragePropertyId; private float latestVisibility; private void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown rustProjector = ((Component)this).GetComponent(); visibilityPropertyId = Shader.PropertyToID(visibilityPropertyName); maxCoveragePropertyId = Shader.PropertyToID(maxCoveragePropertyName); runtimeMaterial = new Material(rustProjector.material); rustProjector.material = runtimeMaterial; rustProjector.startAngleFade = angleFade.StartAngle; rustProjector.endAngleFade = angleFade.EndAngle; runtimeMaterial.SetFloat(maxCoveragePropertyId, maxCoverage); runtimeMaterial.SetFloat(visibilityPropertyId, 0f); rustProjector.fadeFactor = 0f; ((Behaviour)rustProjector).enabled = false; } private void OnEnable() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; BindToCamera(); ((UnityEvent)StartOfRound.Instance.CameraSwitchEvent).AddListener(new UnityAction(BindToCamera)); TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); } } private void OnDisable() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (weatherFlowActive) { weatherFlowActive = false; StartOfRound instance = StartOfRound.Instance; if (instance != null) { ((UnityEvent)instance.CameraSwitchEvent).RemoveListener(new UnityAction(BindToCamera)); } TemporalInstabilityAPI.Unregister(this); SetTemporalInstabilityLevel(0f); } } private void BindToCamera() { Transform val = Utility.LocalViewTransform(); if ((Object)(object)val != (Object)null) { Utility.BindPositionConstraint(positionConstraint, val); } } private void OnDestroy() { Object.Destroy((Object)(object)runtimeMaterial); } public void SetTemporalInstabilityLevel(float temporalInstabilityLevel) { float temporalInstabilityLevel2 = Utility.ClampInstability(temporalInstabilityLevel); latestVisibility = Utility.InstabilityProgress(temporalInstabilityLevel2, activation.StartInstability, activation.FullInstability); Material? obj = runtimeMaterial; if (obj != null) { obj.SetFloat(visibilityPropertyId, latestVisibility); } Material? obj2 = runtimeMaterial; if (obj2 != null) { obj2.SetFloat(maxCoveragePropertyId, maxCoverage); } DecalProjector? obj3 = rustProjector; if (obj3 != null) { obj3.startAngleFade = angleFade.StartAngle; } DecalProjector? obj4 = rustProjector; if (obj4 != null) { obj4.endAngleFade = angleFade.EndAngle; } DecalProjector? obj5 = rustProjector; if (obj5 != null) { obj5.fadeFactor = latestVisibility; } DecalProjector? obj6 = rustProjector; if (obj6 != null) { ((Behaviour)obj6).enabled = latestVisibility > 0.001f; } } } internal class RustHazardManager : NetworkBehaviour { [Header("Weather")] [SerializeField] private bool requireTemporalStormWeather = true; [Header("Spawn Count")] [SerializeField] [Min(0f)] private int minimumSpawnCount = 8; [SerializeField] [Min(0f)] private int maximumSpawnCount = 16; [Header("Placement")] [SerializeField] [Min(1f)] private float outsideNodeSearchRadius = 32f; [SerializeField] [Min(0f)] private float minimumDistanceBetweenObjects = 18f; [SerializeField] [Min(1f)] private int placementAttemptsPerObject = 24; private readonly List spawnedRustObjects = new List(); private readonly List chosenSpawnPositions = new List(); private readonly RaycastHit[] placementHits = (RaycastHit[])(object)new RaycastHit[16]; private Coroutine? clusterCoroutine; private bool clusterActive; public override void OnNetworkSpawn() { if (((NetworkBehaviour)this).IsServer) { clusterActive = true; CoroutineTools.Start((MonoBehaviour)(object)this, ref clusterCoroutine, SpawnClusterWhenReady()); } } public override void OnNetworkDespawn() { clusterActive = false; CoroutineTools.Stop((MonoBehaviour)(object)this, ref clusterCoroutine); DestroySpawnedRustObjects(); } private IEnumerator SpawnClusterWhenReady() { while (!Utility.ShouldRunWeatherLifecycle()) { yield return null; } if (requireTemporalStormWeather) { while (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { yield return null; } } if (clusterActive) { SpawnCluster(); clusterCoroutine = null; } } private void SpawnCluster() { //IL_00d0: 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_00e2: Unknown result type (might be due to invalid IL or missing references) if (requireTemporalStormWeather && !WeatherUtils.IsTemporalStormWeatherSelectedOrActive()) { return; } if (RoundManager.Instance.outsideAINodes.Length == 0) { Log.Warn("Rust object cluster found no outside AI nodes"); return; } Random random = new Random(StartOfRound.Instance.randomMapSeed); int num = Mathf.Max(0, minimumSpawnCount); int num2 = Mathf.Max(num, maximumSpawnCount); int num3 = random.Next(num, num2 + 1); int num4 = 0; int num5 = num3 * placementAttemptsPerObject; for (int i = 0; i < num5; i++) { if (num4 >= num3) { break; } if (!ChooseRustObject(random, out NamespacedKey rustObjectKey, out DawnMapObjectInfo rustObjectInfo)) { Log.Warn("Rust object cluster has no registered rust objects"); return; } if (ChooseOutsideSpawnPosition(random, rustObjectInfo, out var spawnPosition, out var surfaceNormal, out var yRotation)) { chosenSpawnPositions.Add(spawnPosition); SpawnRustObjectRpc(((object)rustObjectKey).ToString(), spawnPosition, surfaceNormal, yRotation); num4++; } } Log.Debug($"Rust object cluster spawned {num4} objects"); } private bool ChooseRustObject(Random random, out NamespacedKey rustObjectKey, out DawnMapObjectInfo rustObjectInfo) { for (int i = 0; i < Keys.TemporalRustMapObjects.Length; i++) { rustObjectKey = Keys.TemporalRustMapObjects[random.Next(0, Keys.TemporalRustMapObjects.Length)]; if (RustObjectInfo(rustObjectKey, out rustObjectInfo)) { return true; } } rustObjectKey = null; rustObjectInfo = null; return false; } private bool RustObjectInfo(NamespacedKey rustObjectKey, out DawnMapObjectInfo rustObjectInfo) { return ((Registry)(object)LethalContent.MapObjects).TryGetValue(rustObjectKey, ref rustObjectInfo) && rustObjectInfo.OutsideInfo != null; } private bool ChooseOutsideSpawnPosition(Random random, DawnMapObjectInfo rustObjectInfo, out Vector3 spawnPosition, out Vector3 surfaceNormal, out float yRotation) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) DawnOutsideMapObjectInfo outsideInfo = rustObjectInfo.OutsideInfo; if (outsideInfo == null) { spawnPosition = Vector3.zero; surfaceNormal = Vector3.up; yRotation = 0f; return false; } SpawnableOutsideObject spawnableOutsideObject = outsideInfo.SpawnableOutsideObject; EntranceTeleport[] entranceTeleports = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); Transform[] shipSpawnPathPoints = RoundManager.Instance.shipSpawnPathPoints; GameObject[] spawnDenialPoints = GameObject.FindGameObjectsWithTag("SpawnDenialPoint"); GameObject itemShipLandingNode = GameObject.FindGameObjectWithTag("ItemShipLandingNode"); for (int i = 0; i < placementAttemptsPerObject; i++) { GameObject val = RoundManager.Instance.outsideAINodes[random.Next(0, RoundManager.Instance.outsideAINodes.Length)]; Vector3 origin = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val.transform.position, outsideNodeSearchRadius, default(NavMeshHit), random, -1, 1f) + Vector3.up * 2f; if (RoundManager.Instance.GotNavMeshPositionResult && MapSpawnUtils.TryRaycastClosest(origin, Vector3.down, placementHits, 100f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1, out var closestHit) && MapSpawnUtils.MatchesOutsideFloorTags(((RaycastHit)(ref closestHit)).collider, spawnableOutsideObject.spawnableFloorTags)) { Vector3 val2 = RoundManager.Instance.PositionEdgeCheck(((RaycastHit)(ref closestHit)).point, (float)spawnableOutsideObject.objectWidth, -1, default(Vector3)); if (!(val2 == Vector3.zero) && !MapSpawnUtils.IsDeniedOutsidePosition(val2, spawnableOutsideObject.objectWidth, entranceTeleports, shipSpawnPathPoints, spawnDenialPoints, itemShipLandingNode) && !IsTooCloseToChosenSpawn(val2)) { spawnPosition = val2; surfaceNormal = ((RaycastHit)(ref closestHit)).normal; yRotation = (spawnableOutsideObject.spawnFacingAwayFromWall ? RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(val2 + Vector3.up * 0.2f, 25f, 6) : Utility.RandomRange(random, 0f, 360f)); return true; } } } spawnPosition = Vector3.zero; surfaceNormal = Vector3.up; yRotation = 0f; return false; } [Rpc(/*Could not decode attribute arguments.*/)] private void SpawnRustObjectRpc(string rustObjectKey, Vector3 spawnPosition, Vector3 surfaceNormal, float yRotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_007f: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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(79373366u, val3, val, (SendTo)7, (RpcDelivery)0); bool flag = rustObjectKey != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(rustObjectKey, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref surfaceNormal); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref yRotation, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 79373366u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; NamespacedKey val4 = default(NamespacedKey); if (!NamespacedKey.TryParse(rustObjectKey, ref val4) || !RustObjectInfo(val4.AsTyped(), out DawnMapObjectInfo rustObjectInfo)) { return; } DawnOutsideMapObjectInfo outsideInfo = rustObjectInfo.OutsideInfo; if (outsideInfo != null) { SpawnableOutsideObject spawnableOutsideObject = outsideInfo.SpawnableOutsideObject; GameObject mapObjectPrefab = rustObjectInfo.GetMapObjectPrefab(); Transform transform = RoundManager.Instance.mapPropsContainer.transform; GameObject val5 = Object.Instantiate(mapObjectPrefab, spawnPosition, Quaternion.identity, transform); if (outsideInfo.AlignWithTerrain) { val5.transform.up = surfaceNormal; } Vector3 eulerAngles = val5.transform.eulerAngles; eulerAngles.y = yRotation; val5.transform.eulerAngles = eulerAngles; Transform transform2 = val5.transform; transform2.localEulerAngles += spawnableOutsideObject.rotationOffset; MapSpawnUtils.DestroyTreesAroundOutsideObject(spawnableOutsideObject, spawnPosition); spawnedRustObjects.Add(val5); } } private bool IsTooCloseToChosenSpawn(Vector3 position) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) float num = minimumDistanceBetweenObjects * minimumDistanceBetweenObjects; for (int i = 0; i < chosenSpawnPositions.Count; i++) { Vector3 val = chosenSpawnPositions[i] - position; if (((Vector3)(ref val)).sqrMagnitude < num) { return true; } } return false; } private void DestroySpawnedRustObjects() { for (int num = spawnedRustObjects.Count - 1; num >= 0; num--) { if ((Object)(object)spawnedRustObjects[num] != (Object)null) { Object.Destroy((Object)(object)spawnedRustObjects[num]); } } spawnedRustObjects.Clear(); chosenSpawnPositions.Clear(); } 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(79373366u, new RpcReceiveHandler(__rpc_handler_79373366), "SpawnRustObjectRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_79373366(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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string rustObjectKey = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref rustObjectKey, false); } Vector3 spawnPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition); Vector3 surfaceNormal = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref surfaceNormal); float yRotation = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref yRotation, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((RustHazardManager)(object)target).SpawnRustObjectRpc(rustObjectKey, spawnPosition, surfaceNormal, yRotation); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "RustHazardManager"; } } internal class SkyboxManager : MonoBehaviour { [CompilerGenerated] private static class <>O { public static UnityAction <0>__SyncFarClipForLocalPlayer; } private static readonly HashSet activeSkies = new HashSet(); private const float FarClipRefreshSeconds = 1f; private const float VanillaInsideFarClipPlane = 400f; [Header("Camera")] [SerializeField] [Min(0.01f)] private float outsideFarClipPlane = 2000f; private Camera? localPlayerCamera; private float previousFarClipPlane; private bool hasPreviousFarClipPlane; private bool weatherFlowActive; private Coroutine? farClipRefreshCoroutine; private void OnEnable() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown if (!Utility.ShouldRunWeatherLifecycle()) { return; } Camera val = Utility.LocalViewCamera(); if (!((Object)(object)val == (Object)null)) { weatherFlowActive = true; activeSkies.Add(this); SimpleEvent cameraSwitchEvent = StartOfRound.Instance.CameraSwitchEvent; object obj = <>O.<0>__SyncFarClipForLocalPlayer; if (obj == null) { UnityAction val2 = SyncFarClipForLocalPlayer; <>O.<0>__SyncFarClipForLocalPlayer = val2; obj = (object)val2; } ((UnityEvent)cameraSwitchEvent).AddListener((UnityAction)obj); localPlayerCamera = val; if (!hasPreviousFarClipPlane) { previousFarClipPlane = localPlayerCamera.farClipPlane; hasPreviousFarClipPlane = true; } ThunderlordManager.SetThunderlordMeshesVisible(visible: true); SkyGearManager.SetTemporarySkyVisible(visible: true); RustLightningManager.SetTemporarySkyVisible(visible: true); SyncFarClipForLocalPlayer(); farClipRefreshCoroutine = ((MonoBehaviour)this).StartCoroutine(RefreshOutsideFarClip()); } } private void OnDisable() { //IL_0043: 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_004e: Expected O, but got Unknown if (!weatherFlowActive) { return; } weatherFlowActive = false; activeSkies.Remove(this); StartOfRound instance = StartOfRound.Instance; if (instance != null) { SimpleEvent cameraSwitchEvent = instance.CameraSwitchEvent; object obj = <>O.<0>__SyncFarClipForLocalPlayer; if (obj == null) { UnityAction val = SyncFarClipForLocalPlayer; <>O.<0>__SyncFarClipForLocalPlayer = val; obj = (object)val; } ((UnityEvent)cameraSwitchEvent).RemoveListener((UnityAction)obj); } StopFarClipRefresh(); RestoreLocalPlayerFarClipPlane(); ThunderlordManager.SetThunderlordMeshesVisible(visible: false); SkyGearManager.SetTemporarySkyVisible(visible: false); RustLightningManager.SetTemporarySkyVisible(visible: false); SyncFarClipForLocalPlayer(); } private void OnDestroy() { //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) //IL_0038: Expected O, but got Unknown activeSkies.Remove(this); StartOfRound instance = StartOfRound.Instance; if (instance != null) { SimpleEvent cameraSwitchEvent = instance.CameraSwitchEvent; object obj = <>O.<0>__SyncFarClipForLocalPlayer; if (obj == null) { UnityAction val = SyncFarClipForLocalPlayer; <>O.<0>__SyncFarClipForLocalPlayer = val; obj = (object)val; } ((UnityEvent)cameraSwitchEvent).RemoveListener((UnityAction)obj); } StopFarClipRefresh(); localPlayerCamera = null; previousFarClipPlane = 0f; hasPreviousFarClipPlane = false; } internal static void SyncFarClipForLocalPlayer() { SyncFarClipForLocalPlayer(logChange: true); } private static void SyncFarClipForLocalPlayer(bool logChange) { foreach (SkyboxManager activeSky in activeSkies) { if (activeSky != null && activeSky.weatherFlowActive && activeSky.hasPreviousFarClipPlane) { Camera val = Utility.LocalViewCamera(); if (!((Object)(object)val == (Object)null)) { activeSky.localPlayerCamera = val; activeSky.PushLocalPlayerFarClipPlane(activeSky.WantedFarClipPlane(), logChange); } } } } internal static void NoteLocalPlayerFarClip(float farClipPlane) { foreach (SkyboxManager activeSky in activeSkies) { if (!((Object)(object)activeSky == (Object)null)) { if (!Utility.LocalViewIsInsideFactory()) { SyncFarClipForLocalPlayer(); continue; } activeSky.previousFarClipPlane = farClipPlane; activeSky.hasPreviousFarClipPlane = true; SyncFarClipForLocalPlayer(); } } } private IEnumerator RefreshOutsideFarClip() { WaitForSeconds wait = new WaitForSeconds(1f); while (weatherFlowActive) { yield return wait; if (!Utility.LocalViewIsInsideFactory()) { SyncFarClipForLocalPlayer(logChange: false); } } } private void RestoreLocalPlayerFarClipPlane() { if (hasPreviousFarClipPlane) { float wantedFarClipPlane = previousFarClipPlane; if (Plugin.hasCullFactory && CullFactoryCompat.CullDistanceEnabled()) { wantedFarClipPlane = (Utility.LocalViewIsInsideFactory() ? CullFactoryCompat.InteriorFarClipPlane() : CullFactoryCompat.SurfaceFarClipPlane()); } PushLocalPlayerFarClipPlane(wantedFarClipPlane); localPlayerCamera = null; previousFarClipPlane = 0f; hasPreviousFarClipPlane = false; } } private float WantedFarClipPlane() { if (!Utility.LocalViewIsInsideFactory()) { return outsideFarClipPlane; } if (Plugin.hasCullFactory && CullFactoryCompat.CullDistanceEnabled()) { return CullFactoryCompat.InteriorFarClipPlane(); } return 400f; } private void PushLocalPlayerFarClipPlane(float wantedFarClipPlane, bool logChange = true) { if (!((Object)(object)localPlayerCamera == (Object)null) && !Mathf.Approximately(localPlayerCamera.farClipPlane, wantedFarClipPlane)) { localPlayerCamera.farClipPlane = wantedFarClipPlane; if (logChange) { Log.Debug($"Player camera far clip set to {wantedFarClipPlane}"); } } } private void StopFarClipRefresh() { if (farClipRefreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(farClipRefreshCoroutine); farClipRefreshCoroutine = null; } } } internal class SkyGearManager : MonoBehaviour, ITemporalInstability, ITemporalStormSkyGear { [Serializable] private class GearMaterialSettings { [Range(0f, 1f)] public float Alpha = 1f; [Range(0f, 1f)] public float HiddenFogWeight = 0.95f; [Range(0f, 1f)] public float RaisedFogWeight = 0.7f; public Color FogColor = Color.black; [Range(0f, 1f)] public float ShadowBrightness = 0.7f; [Min(0f)] public float EmissionIntensity = 0f; } [Serializable] private class TemporalStormGear { [SerializeField] private Transform gearTransform = null; [SerializeField] private float hiddenLocalY; [SerializeField] private float raisedLocalY; [SerializeField] [Range(0f, 100f)] private float riseInstability; [SerializeField] [Min(0.01f)] private float fullZRotationSeconds; [SerializeField] private bool reverseFullZRotation; [SerializeField] private bool doNotRandomiseStartingXYRotation; private float startingXRotation; private float startingYRotation; private float zRotation; private float currentRaisedAmount; private float targetRaisedAmount; private float transitionStartRaisedAmount; private float transitionElapsedSeconds; private List? raisedExclusionObjects; public bool ShouldAnimate => ((Component)gearTransform).gameObject.activeSelf && (currentRaisedAmount > 0.001f || targetRaisedAmount > 0.001f || !Mathf.Approximately(currentRaisedAmount, targetRaisedAmount)); public TemporalStormGear(float hiddenLocalY, float raisedLocalY, float riseInstability, float fullZRotationSeconds, bool reverseFullZRotation, bool doNotRandomiseStartingXYRotation) { this.hiddenLocalY = hiddenLocalY; this.raisedLocalY = raisedLocalY; this.riseInstability = riseInstability; this.fullZRotationSeconds = fullZRotationSeconds; this.reverseFullZRotation = reverseFullZRotation; this.doNotRandomiseStartingXYRotation = doNotRandomiseStartingXYRotation; base..ctor(); } public void ReadSpin() { //IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gearTransform == (Object)null)) { Vector3 localEulerAngles = gearTransform.localEulerAngles; startingXRotation = localEulerAngles.x; startingYRotation = localEulerAngles.y; zRotation = localEulerAngles.z; } } public void RaiseFromInstability(float temporalInstabilityLevel) { float num = ((temporalInstabilityLevel >= riseInstability) ? 1f : 0f); if (!Mathf.Approximately(targetRaisedAmount, num)) { targetRaisedAmount = num; transitionStartRaisedAmount = currentRaisedAmount; transitionElapsedSeconds = 0f; if (targetRaisedAmount > 0f) { ShowGear(active: true); } } } public void SnapRaiseFromInstability(float temporalInstabilityLevel) { targetRaisedAmount = ((temporalInstabilityLevel >= riseInstability) ? 1f : 0f); currentRaisedAmount = targetRaisedAmount; transitionStartRaisedAmount = currentRaisedAmount; transitionElapsedSeconds = 0f; ShowGear(currentRaisedAmount > 0.001f); MoveGear(currentRaisedAmount); } public bool MoveGear(float deltaTime, float transitionSeconds) { if (Mathf.Approximately(currentRaisedAmount, targetRaisedAmount)) { currentRaisedAmount = targetRaisedAmount; if (currentRaisedAmount <= 0.001f) { ShowGear(active: false); } return false; } transitionElapsedSeconds += deltaTime; float num = Mathf.SmoothStep(0f, 1f, transitionElapsedSeconds / Mathf.Max(0.01f, transitionSeconds)); currentRaisedAmount = Mathf.Lerp(transitionStartRaisedAmount, targetRaisedAmount, num); if (num >= 1f) { currentRaisedAmount = targetRaisedAmount; } MoveGear(currentRaisedAmount); if (currentRaisedAmount <= 0.001f && targetRaisedAmount <= 0f) { ShowGear(active: false); } return true; } public void RandomiseSpin(float xRotation, float yRotation) { if (!doNotRandomiseStartingXYRotation) { startingXRotation = xRotation; startingYRotation = yRotation; SpinGear(); } } public void Rotate(float deltaTime, float speedMultiplier) { if (ShouldAnimate) { float num = (reverseFullZRotation ? (-1f) : 1f); zRotation = Mathf.Repeat(zRotation + num * 360f * speedMultiplier * deltaTime / Mathf.Max(0.01f, fullZRotationSeconds), 360f); SpinGear(); } } public void Tint(MaterialPropertyBlock propertyBlock, int alphaPropertyId, int fogWeightPropertyId, int fogColorPropertyId, int shadowBrightnessPropertyId, int emissionIntensityPropertyId, GearMaterialSettings settings) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) Renderer[] array = (((Object)(object)gearTransform == (Object)null) ? Array.Empty() : ((Component)gearTransform).GetComponentsInChildren(true)); float num = Mathf.Lerp(settings.HiddenFogWeight, settings.RaisedFogWeight, currentRaisedAmount); foreach (Renderer val in array) { propertyBlock.Clear(); val.GetPropertyBlock(propertyBlock); propertyBlock.SetFloat(alphaPropertyId, settings.Alpha); propertyBlock.SetFloat(fogWeightPropertyId, num); propertyBlock.SetColor(fogColorPropertyId, settings.FogColor); propertyBlock.SetFloat(shadowBrightnessPropertyId, settings.ShadowBrightness); propertyBlock.SetFloat(emissionIntensityPropertyId, settings.EmissionIntensity); val.SetPropertyBlock(propertyBlock); } } public void RebuildLightningBlockers(List? exclusionColliders) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gearTransform == (Object)null) { ShowLightningBlockers(active: false); return; } BoxCollider[] componentsInChildren = ((Component)gearTransform).GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { ShowLightningBlockers(active: false); return; } float num = raisedLocalY - gearTransform.localPosition.y; Vector3 worldOffset = (((Object)(object)gearTransform.parent != (Object)null) ? gearTransform.parent.TransformVector(new Vector3(0f, num, 0f)) : (Vector3.up * num)); int num2 = 0; BoxCollider val4 = default(BoxCollider); foreach (BoxCollider val in componentsInChildren) { if (val != null && ((Collider)val).enabled && ((Collider)val).isTrigger) { if (raisedExclusionObjects == null) { raisedExclusionObjects = new List(); } List list = raisedExclusionObjects; while (list.Count <= num2) { list.Add(NewLightningBlocker(num2, val)); } GameObject val2 = list[num2]; if ((Object)(object)val2 == (Object)null) { val2 = (list[num2] = NewLightningBlocker(num2, val)); } if (!val2.TryGetComponent(ref val4)) { val4 = val2.AddComponent(); } ShapeLightningBlocker(val4, val, worldOffset, num2); exclusionColliders?.Add(val4); num2++; } } if (raisedExclusionObjects == null) { return; } for (int j = num2; j < raisedExclusionObjects.Count; j++) { GameObject obj = raisedExclusionObjects[j]; if (obj != null) { obj.SetActive(false); } } } public void ShowLightningBlockers(bool active) { if (raisedExclusionObjects == null) { return; } for (int i = 0; i < raisedExclusionObjects.Count; i++) { GameObject obj = raisedExclusionObjects[i]; if (obj != null) { obj.SetActive(active); } } } public void ShowGear(bool active) { if (!((Object)(object)gearTransform == (Object)null)) { ((Component)gearTransform).gameObject.SetActive(active); } } private void MoveGear(float raisedAmount) { //IL_0019: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gearTransform == (Object)null)) { Vector3 localPosition = gearTransform.localPosition; localPosition.y = Mathf.Lerp(hiddenLocalY, raisedLocalY, raisedAmount); gearTransform.localPosition = localPosition; } } private GameObject NewLightningBlocker(int index, BoxCollider sourceCollider) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown GameObject val = new GameObject($"{((Object)gearTransform).name}.{((Object)((Component)sourceCollider).gameObject).name}.RustLightningExclusion.{index}") { hideFlags = (HideFlags)0 }; val.SetActive(false); return val; } private void ShapeLightningBlocker(BoxCollider copiedCollider, BoxCollider sourceCollider, Vector3 worldOffset, int index) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)copiedCollider).gameObject; Transform transform = gameObject.transform; Transform transform2 = ((Component)sourceCollider).transform; ((Object)gameObject).name = $"{((Object)gearTransform).name}.{((Object)((Component)sourceCollider).gameObject).name}.RustLightningExclusion.{index}"; gameObject.layer = ((Component)sourceCollider).gameObject.layer; transform.SetParent((Transform)null, false); transform.SetPositionAndRotation(transform2.position + worldOffset, transform2.rotation); transform.localScale = transform2.lossyScale; transform.SetParent(gearTransform.parent, true); copiedCollider.center = sourceCollider.center; copiedCollider.size = sourceCollider.size; ((Collider)copiedCollider).isTrigger = true; ((Collider)copiedCollider).enabled = true; gameObject.SetActive(false); } private void SpinGear() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)gearTransform == (Object)null)) { gearTransform.localRotation = Quaternion.Euler(startingXRotation, startingYRotation, zRotation); } } } private static readonly HashSet activeGearManagers = new HashSet(); private static readonly int alphaPropertyId = Shader.PropertyToID("_GearAlpha"); private static readonly int fogWeightPropertyId = Shader.PropertyToID("_GearFogWeight"); private static readonly int fogColorPropertyId = Shader.PropertyToID("_GearFogColor"); private static readonly int shadowBrightnessPropertyId = Shader.PropertyToID("_GearShadowBrightness"); private static readonly int emissionIntensityPropertyId = Shader.PropertyToID("_GearEmissionIntensity"); private static bool temporarySkyVisible; [Header("Binding")] [SerializeField] private PositionConstraint positionConstraint = null; [Header("Gears")] [SerializeField] private float transitionSeconds = 2.5f; [SerializeField] private Vector2 randomStartingXRotationRange = new Vector2(-50f, 50f); [SerializeField] private Vector2 randomStartingYRotationRange = new Vector2(0f, 360f); [Header("Gear Material")] [SerializeField] private GearMaterialSettings gearMaterialSettings = new GearMaterialSettings(); [SerializeField] private List gears = new List(7) { new TemporalStormGear(-134.48f, 15f, 90f, 75f, reverseFullZRotation: true, doNotRandomiseStartingXYRotation: false), new TemporalStormGear(-400f, -37f, 90f, 70f, reverseFullZRotation: false, doNotRandomiseStartingXYRotation: false), new TemporalStormGear(-151.6f, 50.7f, 90f, 65f, reverseFullZRotation: false, doNotRandomiseStartingXYRotation: false), new TemporalStormGear(-1000f, 70f, 90f, 120f, reverseFullZRotation: true, doNotRandomiseStartingXYRotation: false), new TemporalStormGear(-1000f, 70f, 90f, 110f, reverseFullZRotation: false, doNotRandomiseStartingXYRotation: false), new TemporalStormGear(-3224f, 216f, 94f, 180f, reverseFullZRotation: false, doNotRandomiseStartingXYRotation: true), new TemporalStormGear(-1106f, 565f, 90f, 130f, reverseFullZRotation: true, doNotRandomiseStartingXYRotation: false) }; private MaterialPropertyBlock gearMaterialPropertyBlock = null; private bool weatherFlowActive; private float temporalInstabilityLevel; private int skyGearSeed; private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown gearMaterialPropertyBlock = new MaterialPropertyBlock(); for (int i = 0; i < gears.Count; i++) { gears[i].ReadSpin(); } TintGears(); } private void OnEnable() { activeGearManagers.Add(this); for (int i = 0; i < gears.Count; i++) { gears[i].ShowGear(temporarySkyVisible); } StartWeatherFlow(); } private void OnDisable() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown activeGearManagers.Remove(this); temporarySkyVisible = activeGearManagers.Count > 0 && temporarySkyVisible; for (int i = 0; i < gears.Count; i++) { gears[i].ShowGear(active: false); } ShowLightningBlockers(active: false); if (weatherFlowActive) { StartOfRound instance = StartOfRound.Instance; if (instance != null) { ((UnityEvent)instance.CameraSwitchEvent).RemoveListener(new UnityAction(BindToCamera)); } weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); TemporalInstabilityAPI.UnregisterSkyGear(this); } } private void Update() { if (!temporarySkyVisible) { return; } if (!weatherFlowActive) { StartWeatherFlow(); return; } float deltaTime = Time.deltaTime; bool flag = false; for (int i = 0; i < gears.Count; i++) { flag |= gears[i].ShouldAnimate; gears[i].Rotate(deltaTime, 1f); } if (flag) { MoveGears(deltaTime); } } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); for (int i = 0; i < gears.Count; i++) { gears[i].RaiseFromInstability(temporalInstabilityLevel); } } public void SetSkyGearSeed(int value) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) skyGearSeed = value; Random random = new Random(skyGearSeed); for (int i = 0; i < gears.Count; i++) { gears[i].RandomiseSpin(Utility.RandomRange(random, randomStartingXRotationRange), Utility.RandomRange(random, randomStartingYRotationRange)); } RebuildLightningBlockers(null); } internal static void SetTemporarySkyVisible(bool visible) { temporarySkyVisible = visible; foreach (SkyGearManager activeGearManager in activeGearManagers) { if (!((Object)(object)activeGearManager == (Object)null)) { for (int i = 0; i < activeGearManager.gears.Count; i++) { activeGearManager.gears[i].ShowGear(visible); } if (!visible) { activeGearManager.ShowLightningBlockers(active: false); } } } } internal static void RebuildActiveLightningBlockers(List exclusionColliders) { foreach (SkyGearManager activeGearManager in activeGearManagers) { if (activeGearManager != null && ((Behaviour)activeGearManager).isActiveAndEnabled) { activeGearManager.RebuildLightningBlockers(exclusionColliders); } } } private void StartWeatherFlow() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (!weatherFlowActive && Utility.ShouldRunWeatherLifecycle()) { BindToCamera(); weatherFlowActive = true; ((UnityEvent)StartOfRound.Instance.CameraSwitchEvent).AddListener(new UnityAction(BindToCamera)); TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); TemporalInstabilityAPI.RegisterSkyGear(this); for (int i = 0; i < gears.Count; i++) { gears[i].SnapRaiseFromInstability(temporalInstabilityLevel); } RebuildLightningBlockers(null); TintGears(); } } private void BindToCamera() { Transform val = Utility.LocalViewTransform(); if ((Object)(object)positionConstraint != (Object)null && (Object)(object)val != (Object)null) { Utility.BindPositionConstraint(positionConstraint, val); } } private void RebuildLightningBlockers(List? exclusionColliders) { for (int i = 0; i < gears.Count; i++) { gears[i].RebuildLightningBlockers(exclusionColliders); } } private void ShowLightningBlockers(bool active) { for (int i = 0; i < gears.Count; i++) { gears[i].ShowLightningBlockers(active); } } private void TintGears() { for (int i = 0; i < gears.Count; i++) { gears[i].Tint(gearMaterialPropertyBlock, alphaPropertyId, fogWeightPropertyId, fogColorPropertyId, shadowBrightnessPropertyId, emissionIntensityPropertyId, gearMaterialSettings); } } private void MoveGears(float deltaTime) { bool flag = false; for (int i = 0; i < gears.Count; i++) { flag |= gears[i].MoveGear(deltaTime, transitionSeconds); } if (flag) { TintGears(); } } } internal class TemporalInstabilityManager : NetworkBehaviour { private static GameObject? networkPrefab; private static NetworkObject? spawnedNetworkObject; private static AssetBundle networkAssetBundle = null; private static bool networkPrefabRegistered; private static bool loggedMissingNetworkPrefab; private static readonly HashSet waitingServerReceivers = new HashSet(); private static readonly HashSet waitingClientReceivers = new HashSet(); private static readonly HashSet waitingSkyGearSeedReceivers = new HashSet(); private static readonly HashSet waitingRustLightningSeedReceivers = new HashSet(); private readonly HashSet serverReceivers = new HashSet(); private readonly HashSet clientReceivers = new HashSet(); private readonly HashSet skyGearSeedReceivers = new HashSet(); private readonly HashSet rustLightningSeedReceivers = new HashSet(); private readonly Dictionary clientInstabilityAdditions = new Dictionary(); private readonly NetworkVariable syncedServerTemporalInstabilityLevel = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable syncedSkyGearSeed = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable syncedRustLightningSeed = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); [Header("Server Temporal Instability")] [SerializeField] [Range(0f, 100f)] private float serverTemporalInstabilityLevel; [Header("Moon Time Instability")] [SerializeField] private bool moonTimeInstabilityEnabled = true; [SerializeField] [Range(0f, 100f)] private float moonTimeInstabilityAmount = 40f; [SerializeField] [Range(0f, 1f)] private float moonTimeInstabilityStartNormalisedTime = 0.1f; [SerializeField] [Range(0.01f, 1f)] private float moonTimeInstabilityEndNormalisedTime = 0.65f; [Header("Server Gameplay Instability")] [SerializeField] private bool apparatusInstabilityEnabled = true; [SerializeField] [Range(0f, 100f)] private float apparatusInstabilityAmount = 20f; [SerializeField] [Min(0.01f)] private float apparatusInstabilityRampupSeconds = 5f; [SerializeField] private bool playerFacilityInstabilityEnabled = true; [SerializeField] [Min(0f)] private float facilityInstabilityBasePerSecond = 0.08f; [SerializeField] [Min(0f)] private float facilityInstabilityPerPlayerPerSecond = 0.01f; [SerializeField] private bool playerInsanityInstabilityEnabled = true; [SerializeField] [Range(0f, 100f)] private float playerInsanityThreshold = 40f; [SerializeField] [Min(0f)] private float playerInsanityInstabilityPerSecond = 0.01f; private Coroutine? clientTransitionCoroutine; private Coroutine? moonTimeInstabilityCoroutine; private Coroutine? playerFacilityServerInstabilityCoroutine; private float clientTemporalInstabilityLevel; private float wantedClientTemporalInstabilityLevel; private float moonTimeInstabilityAppliedAmount; private bool temporalStormRoundActive; public static TemporalInstabilityManager Current { get; private set; } = null; private void Awake() { Current = this; serverTemporalInstabilityLevel = Utility.ClampInstability(serverTemporalInstabilityLevel); ClampMoonTimeInstabilitySettings(); apparatusInstabilityAmount = Utility.ClampInstability(apparatusInstabilityAmount); wantedClientTemporalInstabilityLevel = WantedClientInstability(); clientTemporalInstabilityLevel = wantedClientTemporalInstabilityLevel; serverReceivers.UnionWith(waitingServerReceivers); clientReceivers.UnionWith(waitingClientReceivers); skyGearSeedReceivers.UnionWith(waitingSkyGearSeedReceivers); rustLightningSeedReceivers.UnionWith(waitingRustLightningSeedReceivers); waitingServerReceivers.Clear(); waitingClientReceivers.Clear(); waitingSkyGearSeedReceivers.Clear(); waitingRustLightningSeedReceivers.Clear(); NotifyServerReceivers(); NotifyClientReceivers(); NotifySkyGearSeedReceivers(); NotifyRustLightningSeedReceivers(); } private void OnValidate() { serverTemporalInstabilityLevel = Utility.ClampInstability(serverTemporalInstabilityLevel); ClampMoonTimeInstabilitySettings(); apparatusInstabilityAmount = Utility.ClampInstability(apparatusInstabilityAmount); if (!Application.isPlaying || (Object)(object)Current != (Object)(object)this) { return; } if (!((NetworkBehaviour)this).IsSpawned) { PushServerInstability(serverTemporalInstabilityLevel, instantClient: true); SnapClientInstability(); return; } if (((NetworkBehaviour)this).IsServer) { SetTemporalInstabilityLevel(serverTemporalInstabilityLevel); } SnapClientInstability(); } private void ClampMoonTimeInstabilitySettings() { moonTimeInstabilityAmount = Utility.ClampInstability(moonTimeInstabilityAmount); moonTimeInstabilityStartNormalisedTime = Mathf.Clamp(moonTimeInstabilityStartNormalisedTime, 0f, 0.99f); moonTimeInstabilityEndNormalisedTime = Mathf.Clamp(moonTimeInstabilityEndNormalisedTime, moonTimeInstabilityStartNormalisedTime + 0.01f, 1f); } public override void OnDestroy() { if ((Object)(object)Current == (Object)(object)this) { waitingServerReceivers.UnionWith(serverReceivers); waitingClientReceivers.UnionWith(clientReceivers); waitingSkyGearSeedReceivers.UnionWith(skyGearSeedReceivers); waitingRustLightningSeedReceivers.UnionWith(rustLightningSeedReceivers); Current = null; } CoroutineTools.Stop((MonoBehaviour)(object)this, ref moonTimeInstabilityCoroutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref playerFacilityServerInstabilityCoroutine); if ((Object)(object)spawnedNetworkObject == (Object)(object)((NetworkBehaviour)this).NetworkObject) { spawnedNetworkObject = null; } } private void OnDisable() { RunTemporalStormRound(active: false); SetTemporalInstabilityLevel(0f); ResetClientTemporalInstabilityLevelInternal(); ChatGlitchManager.Reset(); } public static bool RegisterNetworkPrefab() { if (networkPrefabRegistered) { return true; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return false; } networkPrefab = LoadTemporalInstabilityPrefab(); if ((Object)(object)networkPrefab == (Object)null) { if ((Object)(object)networkAssetBundle != (Object)null && !loggedMissingNetworkPrefab) { loggedMissingNetworkPrefab = true; Log.Error("Temporal storm network prefab is missing"); } return false; } singleton.PrefabHandler.AddNetworkPrefab(networkPrefab); networkPrefabRegistered = true; loggedMissingNetworkPrefab = false; Log.Debug("Loaded network prefab"); return true; } public static TemporalInstabilityManager? SpawnServerNetworkObject() { if ((Object)(object)spawnedNetworkObject != (Object)null) { return ((Component)spawnedNetworkObject).GetComponent(); } if ((Object)(object)networkPrefab == (Object)null && (!RegisterNetworkPrefab() || (Object)(object)networkPrefab == (Object)null)) { return null; } GameObject val = Object.Instantiate(networkPrefab); TemporalInstabilityManager component = val.GetComponent(); NetworkObject component2 = val.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Log.Error("Temporal storm network prefab is missing its manager or network object component"); Object.Destroy((Object)(object)val); return null; } spawnedNetworkObject = component2; component2.Spawn(false); Log.Info("Spawned temporal storm network object"); return component; } public override void OnNetworkSpawn() { NetworkVariable obj = syncedServerTemporalInstabilityLevel; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedServerTemporalInstabilityChanged)); NetworkVariable obj2 = syncedSkyGearSeed; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedSkyGearSeedChanged)); NetworkVariable obj3 = syncedRustLightningSeed; obj3.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedRustLightningSeedChanged)); if (((NetworkBehaviour)this).IsServer) { spawnedNetworkObject = ((NetworkBehaviour)this).NetworkObject; syncedServerTemporalInstabilityLevel.Value = Utility.ClampInstability(serverTemporalInstabilityLevel); } PushServerInstability(syncedServerTemporalInstabilityLevel.Value, instantClient: true); NotifySkyGearSeedReceivers(); NotifyRustLightningSeedReceivers(); } public override void OnNetworkDespawn() { NetworkVariable obj = syncedServerTemporalInstabilityLevel; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedServerTemporalInstabilityChanged)); NetworkVariable obj2 = syncedSkyGearSeed; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedSkyGearSeedChanged)); NetworkVariable obj3 = syncedRustLightningSeed; obj3.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnSyncedRustLightningSeedChanged)); CoroutineTools.Stop((MonoBehaviour)(object)this, ref moonTimeInstabilityCoroutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref playerFacilityServerInstabilityCoroutine); if ((Object)(object)spawnedNetworkObject == (Object)(object)((NetworkBehaviour)this).NetworkObject) { spawnedNetworkObject = null; } } public static GameObject? LoadTemporalInstabilityPrefab() { return LoadAsset("Assets/LethalCompany/Mods/plugins/TemporalStormWeather/Content/Temporal Storm/TemporalInstabilityNetwork.prefab"); } public static TemporalStormAmbienceLibrary? LoadTemporalStormAmbienceLibrary() { return LoadAsset("Assets/LethalCompany/Mods/plugins/TemporalStormWeather/Content/Temporal Storm/TemporalStormAmbienceLibrary.asset"); } private static T? LoadAsset(string assetPath) where T : Object { return (!LoadNetworkAssetBundle()) ? default(T) : networkAssetBundle.LoadAsset(assetPath); } private static bool LoadNetworkAssetBundle() { if ((Object)(object)networkAssetBundle != (Object)null) { return true; } Plugin? instance = Plugin.Instance; string text = Path.Combine(Path.GetDirectoryName((instance != null) ? ((BaseUnityPlugin)instance).Info.Location : null), "temporalstormotherassets"); networkAssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)networkAssetBundle == (Object)null) { Log.Error("Could not load temporal storm asset bundle"); return false; } return true; } private void OnSyncedServerTemporalInstabilityChanged(float previousValue, float currentValue) { PushServerInstability(currentValue, instantClient: false); } private void OnSyncedSkyGearSeedChanged(int previousValue, int currentValue) { NotifySkyGearSeedReceivers(); } private void OnSyncedRustLightningSeedChanged(int previousValue, int currentValue) { NotifyRustLightningSeedReceivers(); } [Rpc(/*Could not decode attribute arguments.*/)] private void PlayTemporalAmbienceRpc(int category, int clipIndex, float volume) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0075: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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(626863508u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, category); BytePacker.WriteValueBitPacked(val2, clipIndex); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref volume, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 626863508u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; TemporalStormAmbience.PlayTemporalAmbienceLocal(category, clipIndex, volume); } } } public static void Register(ITemporalInstability receiver, TemporalInstabilityFeed feed) { if ((Object)(object)Current == (Object)null) { if (feed == TemporalInstabilityFeed.Client) { waitingClientReceivers.Add(receiver); } else { waitingServerReceivers.Add(receiver); } } else { Current.AddReceiver(receiver, feed); } } public static void Unregister(ITemporalInstability receiver) { waitingServerReceivers.Remove(receiver); waitingClientReceivers.Remove(receiver); if (!((Object)(object)Current == (Object)null)) { Current.serverReceivers.Remove(receiver); Current.clientReceivers.Remove(receiver); } } public static void RegisterSkyGearSeedReceiver(ITemporalStormSkyGear receiver) { if ((Object)(object)Current == (Object)null) { waitingSkyGearSeedReceivers.Add(receiver); return; } Current.skyGearSeedReceivers.Add(receiver); receiver.SetSkyGearSeed(Current.syncedSkyGearSeed.Value); } public static void UnregisterSkyGearSeedReceiver(ITemporalStormSkyGear receiver) { waitingSkyGearSeedReceivers.Remove(receiver); if (!((Object)(object)Current == (Object)null)) { Current.skyGearSeedReceivers.Remove(receiver); } } public static void RegisterRustLightningSeedReceiver(ITemporalStormRustLightning receiver) { if ((Object)(object)Current == (Object)null) { waitingRustLightningSeedReceivers.Add(receiver); return; } Current.rustLightningSeedReceivers.Add(receiver); receiver.SetRustLightningSeed(Current.syncedRustLightningSeed.Value); } public static void UnregisterRustLightningSeedReceiver(ITemporalStormRustLightning receiver) { waitingRustLightningSeedReceivers.Remove(receiver); if (!((Object)(object)Current == (Object)null)) { Current.rustLightningSeedReceivers.Remove(receiver); } } public static void SetServerInstabilityLevel(float temporalInstabilityLevel) { Current.SetTemporalInstabilityLevel(temporalInstabilityLevel); } public static void ReduceServerInstability(float amount) { if (!((Object)(object)Current == (Object)null)) { Current.ReduceServerInstabilityInternal(amount); } } public static void IncreaseServerInstability(float amount) { if (!((Object)(object)Current == (Object)null)) { Current.AddServerInstability(amount); } } public static void SetClientInstabilityAddition(object source, float temporalInstabilityAddition) { Current.AddClientInstability(source, temporalInstabilityAddition); } public static void ClearClientInstabilityAddition(object source) { Current.ClearClientInstability(source); } public static void SetTemporalStormRoundActive(bool active) { if (!((Object)(object)Current == (Object)null)) { Current.RunTemporalStormRound(active); } } public static void RegenerateRustLightningSeed() { TemporalInstabilityManager current = Current; if (current != null && ((NetworkBehaviour)current).IsServer) { Current.syncedRustLightningSeed.Value = Random.Range(1, int.MaxValue); Current.NotifyRustLightningSeedReceivers(); } } public static void AddApparatusInstability() { if (!((Object)(object)Current == (Object)null)) { Current.AddApparatusInstabilityInternal(); } } public static bool TryGetClientInstabilityLevel(out float temporalInstabilityLevel) { if ((Object)(object)Current == (Object)null) { temporalInstabilityLevel = 0f; return false; } temporalInstabilityLevel = Current.clientTemporalInstabilityLevel; return true; } public static bool TryGetServerInstabilityLevel(out float temporalInstabilityLevel) { if ((Object)(object)Current == (Object)null) { temporalInstabilityLevel = 0f; return false; } temporalInstabilityLevel = Current.serverTemporalInstabilityLevel; return true; } public static bool TrySendTemporalAmbience(int category, int clipIndex, float volume) { TemporalInstabilityManager current = Current; if (current == null || !((NetworkBehaviour)current).IsSpawned || !((NetworkBehaviour)Current).IsServer) { return false; } Current.PlayTemporalAmbienceRpc(category, clipIndex, volume); return true; } public static void ResetTemporalInstabilityLevels() { Current.RunTemporalStormRound(active: false); Current.SetTemporalInstabilityLevel(0f); Current.ResetClientTemporalInstabilityLevelInternal(); } public void SetTemporalInstabilityLevel(float value) { float value2 = Utility.ClampInstability(value); if (!((NetworkBehaviour)this).IsSpawned) { PushServerInstability(value2, instantClient: true); } else if (((NetworkBehaviour)this).IsServer) { syncedServerTemporalInstabilityLevel.Value = value2; PushServerInstability(value2, instantClient: false); } } private void AddReceiver(ITemporalInstability receiver, TemporalInstabilityFeed feed) { if (feed == TemporalInstabilityFeed.Client) { clientReceivers.Add(receiver); receiver.SetTemporalInstabilityLevel(clientTemporalInstabilityLevel); } else { serverReceivers.Add(receiver); receiver.SetTemporalInstabilityLevel(serverTemporalInstabilityLevel); } } private void PushServerInstability(float value, bool instantClient) { serverTemporalInstabilityLevel = Utility.ClampInstability(value); NotifyServerReceivers(); if (instantClient) { SnapClientInstability(); } else { StartClientTransitionToTarget(); } } private void AddClientInstability(object source, float temporalInstabilityAddition) { float num = Utility.ClampInstability(temporalInstabilityAddition); if (num <= 0f) { ClearClientInstability(source); return; } clientInstabilityAdditions[source] = num; StartClientTransitionToTarget(); } private void ClearClientInstability(object source) { clientInstabilityAdditions.Remove(source); StartClientTransitionToTarget(); } private void RunTemporalStormRound(bool active) { if (temporalStormRoundActive == active) { return; } temporalStormRoundActive = active; if (!((NetworkBehaviour)this).IsServer) { return; } if (active) { syncedSkyGearSeed.Value = Random.Range(1, int.MaxValue); syncedRustLightningSeed.Value = Random.Range(1, int.MaxValue); NotifySkyGearSeedReceivers(); NotifyRustLightningSeedReceivers(); StartMoonTimeInstability(); StartPlayerFacilityServerInstability(); } else { if (((NetworkBehaviour)this).IsServer) { syncedRustLightningSeed.Value = 0; NotifyRustLightningSeedReceivers(); } CoroutineTools.Stop((MonoBehaviour)(object)this, ref moonTimeInstabilityCoroutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref playerFacilityServerInstabilityCoroutine); } } private void StartMoonTimeInstability() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref moonTimeInstabilityCoroutine); if (moonTimeInstabilityEnabled) { moonTimeInstabilityAppliedAmount = 0f; CoroutineTools.Start((MonoBehaviour)(object)this, ref moonTimeInstabilityCoroutine, RunMoonTimeInstability()); } } private IEnumerator RunMoonTimeInstability() { WaitForSeconds wait = new WaitForSeconds(1f); while (temporalStormRoundActive && ((NetworkBehaviour)this).IsServer) { TimeOfDay timeOfDay = TimeOfDay.Instance; if (timeOfDay == null || !timeOfDay.timeHasStarted) { yield return wait; continue; } float timeProgress = Mathf.InverseLerp(moonTimeInstabilityStartNormalisedTime, moonTimeInstabilityEndNormalisedTime, timeOfDay.normalizedTimeOfDay); float targetAppliedAmount = moonTimeInstabilityAmount * timeProgress; float remainingAmount = Mathf.Max(0f, moonTimeInstabilityAmount - moonTimeInstabilityAppliedAmount); float amountToAdd = Mathf.Clamp(targetAppliedAmount - moonTimeInstabilityAppliedAmount, 0f, remainingAmount); if (amountToAdd > 0f) { moonTimeInstabilityAppliedAmount += amountToAdd; AddServerInstability(amountToAdd); } if (timeProgress >= 1f) { break; } yield return wait; } moonTimeInstabilityCoroutine = null; } private void StartPlayerFacilityServerInstability() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref playerFacilityServerInstabilityCoroutine); bool flag = playerFacilityInstabilityEnabled && (facilityInstabilityBasePerSecond > 0f || facilityInstabilityPerPlayerPerSecond > 0f); bool flag2 = playerInsanityInstabilityEnabled && playerInsanityInstabilityPerSecond > 0f; if (flag || flag2) { CoroutineTools.Start((MonoBehaviour)(object)this, ref playerFacilityServerInstabilityCoroutine, RunPlayerGameplayInstability()); } } private IEnumerator RunPlayerGameplayInstability() { WaitForSeconds wait = new WaitForSeconds(1f); float previousTime = Time.time; while (temporalStormRoundActive && ((NetworkBehaviour)this).IsServer) { yield return wait; float currentTime = Time.time; float elapsedSeconds = Mathf.Max(0f, currentTime - previousTime); previousTime = currentTime; float instabilityPerSecond = PlayerGameplayInstabilityPerSecond(); if (instabilityPerSecond > 0f) { AddServerInstability(instabilityPerSecond * elapsedSeconds); } } playerFacilityServerInstabilityCoroutine = null; } private float PlayerGameplayInstabilityPerSecond() { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; int num = 0; int num2 = 0; foreach (PlayerControllerB val in allPlayerScripts) { if (Utility.IsPlayerActive(val)) { if (playerFacilityInstabilityEnabled && val.isInsideFactory) { num++; } if (playerInsanityInstabilityEnabled && val.insanityLevel > playerInsanityThreshold) { num2++; } } } float num3 = 0f; if (playerFacilityInstabilityEnabled && num > 0) { num3 = facilityInstabilityBasePerSecond + facilityInstabilityPerPlayerPerSecond * (float)num; } if (playerInsanityInstabilityEnabled) { num3 += (float)num2 * playerInsanityInstabilityPerSecond; } return num3; } private void AddApparatusInstabilityInternal() { if (temporalStormRoundActive && ((NetworkBehaviour)this).IsServer && apparatusInstabilityEnabled && !(apparatusInstabilityAmount <= 0f)) { ((MonoBehaviour)this).StartCoroutine(AddServerInstabilityOverTime(apparatusInstabilityAmount, apparatusInstabilityRampupSeconds)); Log.Debug("Apparatus removal is raising temporal instability"); } } private IEnumerator AddServerInstabilityOverTime(float amount, float seconds) { float duration = Mathf.Max(0.01f, seconds); float elapsedSeconds = 0f; float appliedAmount = 0f; while (temporalStormRoundActive && ((NetworkBehaviour)this).IsServer && elapsedSeconds < duration) { float deltaSeconds = Mathf.Min(Time.deltaTime, duration - elapsedSeconds); float addedAmount = amount * deltaSeconds / duration; elapsedSeconds += deltaSeconds; appliedAmount += addedAmount; AddServerInstability(addedAmount); yield return null; } if (temporalStormRoundActive && ((NetworkBehaviour)this).IsServer && appliedAmount < amount) { AddServerInstability(amount - appliedAmount); } } private void AddServerInstability(float amount) { if (!(amount <= 0f)) { SetTemporalInstabilityLevel(serverTemporalInstabilityLevel + amount); } } private void ReduceServerInstabilityInternal(float amount) { if (!(amount <= 0f) && (!((NetworkBehaviour)this).IsSpawned || ((NetworkBehaviour)this).IsServer)) { SetTemporalInstabilityLevel(serverTemporalInstabilityLevel - amount); } } private void ResetClientTemporalInstabilityLevelInternal() { clientInstabilityAdditions.Clear(); SnapClientInstability(); } private void StartClientTransitionToTarget() { wantedClientTemporalInstabilityLevel = WantedClientInstability(); CoroutineTools.Start((MonoBehaviour)(object)this, ref clientTransitionCoroutine, TransitionClientTemporalInstability()); } private void SnapClientInstability() { wantedClientTemporalInstabilityLevel = WantedClientInstability(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref clientTransitionCoroutine); PushClientInstability(wantedClientTemporalInstabilityLevel); } private IEnumerator TransitionClientTemporalInstability() { while (!Mathf.Approximately(clientTemporalInstabilityLevel, wantedClientTemporalInstabilityLevel)) { PushClientInstability(Mathf.MoveTowards(clientTemporalInstabilityLevel, wantedClientTemporalInstabilityLevel, 100f * Time.deltaTime)); yield return null; } PushClientInstability(wantedClientTemporalInstabilityLevel); clientTransitionCoroutine = null; } private float WantedClientInstability() { float num = 0f; foreach (float value in clientInstabilityAdditions.Values) { num += value; } return Mathf.Clamp(serverTemporalInstabilityLevel + num, serverTemporalInstabilityLevel, 100f); } private void PushClientInstability(float value) { clientTemporalInstabilityLevel = Mathf.Clamp(value, serverTemporalInstabilityLevel, 100f); NotifyClientReceivers(); } private void NotifyServerReceivers() { foreach (ITemporalInstability serverReceiver in serverReceivers) { serverReceiver.SetTemporalInstabilityLevel(serverTemporalInstabilityLevel); } } private void NotifyClientReceivers() { foreach (ITemporalInstability clientReceiver in clientReceivers) { clientReceiver.SetTemporalInstabilityLevel(clientTemporalInstabilityLevel); } } private void NotifySkyGearSeedReceivers() { foreach (ITemporalStormSkyGear skyGearSeedReceiver in skyGearSeedReceivers) { skyGearSeedReceiver.SetSkyGearSeed(syncedSkyGearSeed.Value); } } private void NotifyRustLightningSeedReceivers() { foreach (ITemporalStormRustLightning rustLightningSeedReceiver in rustLightningSeedReceivers) { rustLightningSeedReceiver.SetRustLightningSeed(syncedRustLightningSeed.Value); } } protected override void __initializeVariables() { if (syncedServerTemporalInstabilityLevel == null) { throw new Exception("TemporalInstabilityManager.syncedServerTemporalInstabilityLevel cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)syncedServerTemporalInstabilityLevel).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)syncedServerTemporalInstabilityLevel, "syncedServerTemporalInstabilityLevel"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)syncedServerTemporalInstabilityLevel); if (syncedSkyGearSeed == null) { throw new Exception("TemporalInstabilityManager.syncedSkyGearSeed cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)syncedSkyGearSeed).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)syncedSkyGearSeed, "syncedSkyGearSeed"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)syncedSkyGearSeed); if (syncedRustLightningSeed == null) { throw new Exception("TemporalInstabilityManager.syncedRustLightningSeed cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)syncedRustLightningSeed).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)syncedRustLightningSeed, "syncedRustLightningSeed"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)syncedRustLightningSeed); ((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(626863508u, new RpcReceiveHandler(__rpc_handler_626863508), "PlayTemporalAmbienceRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_626863508(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int category = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref category); int clipIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex); float volume = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref volume, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((TemporalInstabilityManager)(object)target).PlayTemporalAmbienceRpc(category, clipIndex, volume); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "TemporalInstabilityManager"; } } internal class TemporalScreenWarpPass : CustomPass { private static readonly int screenWarpSourceId = Shader.PropertyToID("_TemporalScreenWarpSource"); private static readonly int screenWarpBufferId = Shader.PropertyToID("_TemporalScreenWarpBuffer"); private static readonly int warpAmountId = Shader.PropertyToID("_TemporalWarpAmount"); private static readonly int warningWarpAmountId = Shader.PropertyToID("_TemporalWarningWarpAmount"); private static readonly int warpPixelsId = Shader.PropertyToID("_TemporalWarpPixels"); private static readonly int splitPixelsId = Shader.PropertyToID("_TemporalSplitPixels"); private static readonly int warpTimeId = Shader.PropertyToID("_TemporalWarpTime"); private static readonly int splitPulseTimeId = Shader.PropertyToID("_TemporalSplitPulseTime"); private static readonly int lineJitterTimeId = Shader.PropertyToID("_TemporalLineJitterTime"); [SerializeField] private Shader screenWarpShader = null; [SerializeField] [Range(0f, 100f)] private float startInstability = 0f; [SerializeField] [Range(0f, 100f)] private float fullInstability = 100f; [SerializeField] [Min(0f)] private float maxWarpPixels = 6f; [SerializeField] [Min(0f)] private float maxSplitPixels = 28f; [SerializeField] [Range(0f, 1f)] private float warningWarpBoost = 0.45f; [SerializeField] [Min(0f)] private float warpSpeed = 1f; [SerializeField] [Min(0f)] private float splitPulseSpeed = 1f; [SerializeField] [Min(0f)] private float lineJitterSpeed = 1f; private Material? screenWarpMaterial; private RTHandle? screenWarpBuffer; protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)screenWarpShader == (Object)null) { Log.Error("Temporal screen warp shader is not assigned"); return; } screenWarpBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, (DepthBits)0, (GraphicsFormat)74, (FilterMode)0, (TextureWrapMode)0, TextureXR.dimension, false, false, true, false, 1, 0f, (MSAASamples)1, false, true, (RenderTextureMemoryless)0, (VRTextureUsage)0, "Temporal Screen Warp Buffer"); screenWarpMaterial = CoreUtils.CreateEngineMaterial(screenWarpShader); } protected override void Execute(CustomPassContext ctx) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)screenWarpMaterial == (Object)null || screenWarpBuffer == null || !Utility.ShouldRunWeatherLifecycle()) { return; } Camera val = Utility.LocalViewCamera(); if (!((Object)(object)val == (Object)null) && !((Object)(object)ctx.hdCamera.camera != (Object)(object)val) && TemporalInstabilityAPI.TryGetClientInstabilityLevel(out var temporalInstabilityLevel)) { float num = Mathf.SmoothStep(0f, 1f, Utility.InstabilityProgress(temporalInstabilityLevel, startInstability, fullInstability)); float num2 = Mathf.Clamp01(WarningManager.ScreenWarpAmount); float num3 = Mathf.Clamp01(num + num2 * warningWarpBoost); if (!(num3 <= 0f) || !(num2 <= 0f)) { ctx.propertyBlock.SetTexture(screenWarpSourceId, RTHandle.op_Implicit(ctx.cameraColorBuffer), (RenderTextureSubElement)0); ctx.propertyBlock.SetFloat(warpAmountId, num3); ctx.propertyBlock.SetFloat(warningWarpAmountId, num2); ctx.propertyBlock.SetFloat(warpPixelsId, Mathf.Max(0f, maxWarpPixels)); ctx.propertyBlock.SetFloat(splitPixelsId, Mathf.Max(0f, maxSplitPixels)); ctx.propertyBlock.SetFloat(warpTimeId, Time.time * warpSpeed); ctx.propertyBlock.SetFloat(splitPulseTimeId, Time.time * splitPulseSpeed); ctx.propertyBlock.SetFloat(lineJitterTimeId, Time.time * lineJitterSpeed); CoreUtils.SetRenderTarget(ctx.cmd, screenWarpBuffer, (ClearFlag)7, 0, (CubemapFace)(-1), -1); CoreUtils.DrawFullScreen(ctx.cmd, screenWarpMaterial, ctx.propertyBlock, screenWarpMaterial.FindPass("ReadColor")); ctx.propertyBlock.SetTexture(screenWarpBufferId, RTHandle.op_Implicit(screenWarpBuffer)); CoreUtils.SetRenderTarget(ctx.cmd, ctx.cameraColorBuffer, (ClearFlag)0, 0, (CubemapFace)(-1), -1); CoreUtils.DrawFullScreen(ctx.cmd, screenWarpMaterial, ctx.propertyBlock, screenWarpMaterial.FindPass("WriteColor")); } } } protected override void Cleanup() { CoreUtils.Destroy((Object)(object)screenWarpMaterial); RTHandle? obj = screenWarpBuffer; if (obj != null) { obj.Release(); } screenWarpMaterial = null; screenWarpBuffer = null; } } [CreateAssetMenu(menuName = "TemporalStorm/TemporalStormAmbience", order = 3)] public class TemporalStormAmbienceLibrary : ScriptableObject { [Header("Inside Ambience Temporal Instability")] public RandomAudioClip[]? insideAmbienceTemporalInstability; [Space(15f)] [Header("Ship Ambience Temporal Instability")] public RandomAudioClip[]? shipAmbienceTemporalInstability; [Space(15f)] [Header("Outside Ambience Temporal Instability")] public RandomAudioClip[]? outsideAmbienceTemporalInstability; } public class ThunderlordAnimationEvents : MonoBehaviour { [SerializeField] private AudioSource audioSource = null; [SerializeField] private AudioClip stepClipOne = null; [SerializeField] private AudioClip stepClipTwo = null; [SerializeField] private AudioClip stepClipThree = null; [SerializeField] [Range(0f, 1f)] private float maximumStepAudioVolume = 1f; [SerializeField] [Range(0f, 1f)] private float insideStepAudioVolumeMultiplier = 0.45f; [SerializeField] [Range(0f, 1f)] private float insideStepCameraShakeMultiplier = 0.35f; [SerializeField] [Min(0f)] private float maximumStepCameraShakeMagnitude = 0.08f; [SerializeField] [Min(0.01f)] private float stepCameraShakeDurationSeconds = 0.2f; private ThunderlordManager? thunderlordManager; private Coroutine? stepCameraShakeCoroutine; private Transform? cameraShakeTransform; private Vector3 appliedCameraShakeOffset; private Vector3 stepCameraShakeOffset; private PlayerControllerB? localPlayer; internal AudioClip?[] AudioClips => (AudioClip?[])(object)new AudioClip[3] { stepClipOne, stepClipTwo, stepClipThree }; internal void Bind(ThunderlordManager manager) { thunderlordManager = manager; } public void PlayStepSoundOne() { PlayStepSound(stepClipOne); } public void PlayStepSoundTwo() { PlayStepSound(stepClipTwo); } public void PlayStepSoundThree() { PlayStepSound(stepClipThree); } private void OnDisable() { localPlayer = null; CoroutineTools.Stop((MonoBehaviour)(object)this, ref stepCameraShakeCoroutine); RestoreCameraShakePosition(); } private float GetInstabilityAmount() { float temporalInstabilityLevel; return TemporalInstabilityAPI.TryGetClientInstabilityLevel(out temporalInstabilityLevel) ? Utility.InstabilityProgress(temporalInstabilityLevel, thunderlordManager?.thunderlordRiseStartInstability ?? 70f, thunderlordManager?.thunderlordRiseEndInstability ?? 100f) : 0f; } private void StartStepCameraShake() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)thunderlordManager == (Object)null || maximumStepCameraShakeMagnitude <= 0f) { return; } float num = GetInstabilityAmount(); if (num <= 0.001f) { return; } localPlayer = Utility.LocalPlayer(); if (!((Object)(object)localPlayer?.gameplayCamera == (Object)null)) { if (localPlayer.isInsideFactory) { num *= insideStepCameraShakeMultiplier; } CoroutineTools.Stop((MonoBehaviour)(object)this, ref stepCameraShakeCoroutine); stepCameraShakeOffset = Vector3.zero; CoroutineTools.Start((MonoBehaviour)(object)this, ref stepCameraShakeCoroutine, RunStepCameraShake(maximumStepCameraShakeMagnitude * num)); } } private IEnumerator RunStepCameraShake(float magnitude) { if (!((Object)(object)localPlayer?.gameplayCamera == (Object)null)) { Camera camera = localPlayer.gameplayCamera; Transform cameraTransform = ((Component)camera).transform; float elapsedSeconds = 0f; float seedX = Random.value * 100f; float seedY = Random.value * 100f; while (elapsedSeconds < stepCameraShakeDurationSeconds) { elapsedSeconds += Time.deltaTime; float shakeProgress = Mathf.Clamp01(elapsedSeconds / stepCameraShakeDurationSeconds); float envelopeAmount = Mathf.Sin(shakeProgress * MathF.PI); float noiseTime = elapsedSeconds * 24f; float xOffset = (Mathf.PerlinNoise(seedX, noiseTime) * 2f - 1f) * magnitude * envelopeAmount; float yOffset = (Mathf.PerlinNoise(seedY, noiseTime) * 2f - 1f) * magnitude * envelopeAmount; stepCameraShakeOffset = new Vector3(xOffset, yOffset, 0f); ApplyCameraShakeOffset(cameraTransform); yield return null; } stepCameraShakeOffset = Vector3.zero; ApplyCameraShakeOffset(cameraTransform); stepCameraShakeCoroutine = null; } } private void ApplyCameraShakeOffset(Transform cameraTransform) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cameraShakeTransform != (Object)null && (Object)(object)cameraShakeTransform != (Object)(object)cameraTransform) { RestoreCameraShakePosition(); } cameraShakeTransform = cameraTransform; Vector3 val = cameraTransform.localPosition - appliedCameraShakeOffset; appliedCameraShakeOffset = stepCameraShakeOffset; cameraTransform.localPosition = val + appliedCameraShakeOffset; } private void RestoreCameraShakePosition() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cameraShakeTransform == (Object)null)) { Transform? obj = cameraShakeTransform; obj.localPosition -= appliedCameraShakeOffset; cameraShakeTransform = null; appliedCameraShakeOffset = Vector3.zero; stepCameraShakeOffset = Vector3.zero; } } private void PlayStepSound(AudioClip audioClip) { if (!Utility.ShouldRunWeatherLifecycle()) { return; } float num = GetInstabilityAmount() * maximumStepAudioVolume; localPlayer = Utility.LocalPlayer(); if (!((Object)(object)localPlayer == (Object)null)) { if (localPlayer.isInsideFactory) { num *= insideStepAudioVolumeMultiplier; } AudioUtils.PlayOneShot(audioSource, audioClip, num); StartStepCameraShake(); } } } internal class ThunderlordManager : MonoBehaviour, ITemporalInstability { private static readonly HashSet activeThunderlords = new HashSet(); [Header("Binding")] [SerializeField] private PositionConstraint positionConstraint = null; [Header("Thunderlord")] [SerializeField] private Transform thunderlordOrbitRoot = null; [SerializeField] private Transform thunderlordTransform = null; [SerializeField] [Range(0f, 100f)] internal float thunderlordRiseStartInstability = 70f; [SerializeField] [Range(0f, 100f)] internal float thunderlordRiseEndInstability = 100f; [SerializeField] [Min(0.01f)] private float thunderlordTransitionSeconds = 2f; [SerializeField] private float thunderlordHiddenDistance = 1900f; [SerializeField] private float thunderlordRaisedDistance = 475f; [SerializeField] private float thunderlordHiddenLocalY = -240f; [SerializeField] private float thunderlordRaisedLocalY = -50f; [SerializeField] private float thunderlordMinimumOrbitDegreesPerSecond = 0.1f; [SerializeField] private float thunderlordMaximumOrbitDegreesPerSecond = 1.3f; [SerializeField] [Min(0.001f)] private float thunderlordSmoothStopRange = 0.08f; [SerializeField] [Min(0.01f)] private float thunderlordSmoothStopTime = 0.3f; [SerializeField] private ThunderlordAnimationEvents thunderlordAnimationEvents = null; private readonly List thunderlordRenderers = new List(); private static bool thunderlordMeshesVisible; private Coroutine? thunderlordMotionCoroutine; private bool weatherFlowActive; private bool thunderlordRenderersCached; private bool thunderlordMeshVisible = true; private float temporalInstabilityLevel; private float currentThunderlordRaisedAmount; private float targetThunderlordRaisedAmount; private float thunderlordOrbitDegrees; private float thunderlordRaisedVelocity; private PlayerControllerB? localPlayer; private void Awake() { thunderlordAnimationEvents?.Bind(this); } private void OnEnable() { activeThunderlords.Add(this); CacheThunderlordRenderers(); SetThunderlordMeshVisible(visible: false); SetThunderlordGameObjectActive(active: false); TryStartWeatherFlow(); } private void OnDisable() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown activeThunderlords.Remove(this); localPlayer = null; if (weatherFlowActive) { weatherFlowActive = false; StartOfRound instance = StartOfRound.Instance; if (instance != null) { ((UnityEvent)instance.CameraSwitchEvent).RemoveListener(new UnityAction(RefreshPositionConstraint)); } TemporalInstabilityAPI.Unregister(this); } CoroutineTools.Stop((MonoBehaviour)(object)this, ref thunderlordMotionCoroutine); SetThunderlordMeshVisible(visible: false); SetThunderlordGameObjectActive(active: false); thunderlordRenderers.Clear(); thunderlordRenderersCached = false; } private void Update() { if (!weatherFlowActive) { TryStartWeatherFlow(); } } private void OnDestroy() { activeThunderlords.Remove(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref thunderlordMotionCoroutine); } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); targetThunderlordRaisedAmount = Utility.InstabilityProgress(temporalInstabilityLevel, thunderlordRiseStartInstability, thunderlordRiseEndInstability); if (targetThunderlordRaisedAmount >= 0.001f || currentThunderlordRaisedAmount >= 0.001f) { SetThunderlordGameObjectActive(active: true); UpdateThunderlordMeshVisibility(); StartThunderlordMotion(); } else { SetThunderlordMeshVisible(visible: false); SetThunderlordGameObjectActive(active: false); } } private void TryStartWeatherFlow() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (!weatherFlowActive && Utility.ShouldRunWeatherLifecycle()) { PlayerControllerB val = Utility.LocalPlayer(); if (!((Object)(object)val?.gameplayCamera == (Object)null)) { localPlayer = val; UpdateThunderlordMeshVisibility(); RefreshPositionConstraint(); weatherFlowActive = true; ((UnityEvent)StartOfRound.Instance.CameraSwitchEvent).AddListener(new UnityAction(RefreshPositionConstraint)); TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); targetThunderlordRaisedAmount = Utility.InstabilityProgress(temporalInstabilityLevel, thunderlordRiseStartInstability, thunderlordRiseEndInstability); currentThunderlordRaisedAmount = targetThunderlordRaisedAmount; ApplyThunderlordState(0f); UpdateThunderlordMeshVisibility(); StartThunderlordMotion(); } } } private void CacheThunderlordRenderers() { if (!thunderlordRenderersCached) { thunderlordRenderers.Clear(); if ((Object)(object)thunderlordTransform != (Object)null) { thunderlordRenderers.AddRange(((Component)thunderlordTransform).GetComponentsInChildren(true)); } thunderlordRenderersCached = true; } } private void SetThunderlordMeshVisible(bool visible) { if (thunderlordMeshVisible == visible && thunderlordRenderersCached) { return; } CacheThunderlordRenderers(); thunderlordMeshVisible = visible; for (int i = 0; i < thunderlordRenderers.Count; i++) { Renderer val = thunderlordRenderers[i]; if ((Object)(object)val != (Object)null) { val.enabled = visible; } } } private void UpdateThunderlordMeshVisibility() { if (Utility.ShouldRunWeatherLifecycle()) { PlayerControllerB val = Utility.LocalPlayer(); if ((Object)(object)val != (Object)null) { localPlayer = val; } bool flag = targetThunderlordRaisedAmount > 0.001f || currentThunderlordRaisedAmount > 0.001f; SetThunderlordMeshVisible(thunderlordMeshesVisible && flag && !Utility.LocalViewIsInsideFactory()); } } private void RefreshPositionConstraint() { Transform val = Utility.LocalViewTransform(); if ((Object)(object)positionConstraint != (Object)null && (Object)(object)val != (Object)null) { Utility.BindPositionConstraint(positionConstraint, val); } } private void SetThunderlordGameObjectActive(bool active) { if ((Object)(object)thunderlordOrbitRoot != (Object)null && (Object)(object)thunderlordOrbitRoot != (Object)(object)((Component)this).transform && !((Component)this).transform.IsChildOf(thunderlordOrbitRoot)) { ((Component)thunderlordOrbitRoot).gameObject.SetActive(active); } if ((Object)(object)thunderlordTransform != (Object)null && (Object)(object)thunderlordTransform != (Object)(object)((Component)this).transform) { ((Component)thunderlordTransform).gameObject.SetActive(active); } } internal static void SetThunderlordMeshesVisible(bool visible) { thunderlordMeshesVisible = visible; foreach (ThunderlordManager activeThunderlord in activeThunderlords) { if (!((Object)(object)activeThunderlord == (Object)null)) { activeThunderlord.UpdateThunderlordMeshVisibility(); } } } private void StartThunderlordMotion() { if (thunderlordMotionCoroutine == null && (!(targetThunderlordRaisedAmount <= 0.001f) || !(currentThunderlordRaisedAmount <= 0.001f))) { CoroutineTools.Start((MonoBehaviour)(object)this, ref thunderlordMotionCoroutine, AnimateThunderlord()); } } private IEnumerator AnimateThunderlord() { while (true) { targetThunderlordRaisedAmount = Utility.InstabilityProgress(temporalInstabilityLevel, thunderlordRiseStartInstability, thunderlordRiseEndInstability); float difference = Mathf.Abs(targetThunderlordRaisedAmount - currentThunderlordRaisedAmount); if (difference > thunderlordSmoothStopRange) { currentThunderlordRaisedAmount = Mathf.MoveTowards(currentThunderlordRaisedAmount, targetThunderlordRaisedAmount, Time.deltaTime / Mathf.Max(0.01f, thunderlordTransitionSeconds)); thunderlordRaisedVelocity = 0f; } else { currentThunderlordRaisedAmount = Mathf.SmoothDamp(currentThunderlordRaisedAmount, targetThunderlordRaisedAmount, ref thunderlordRaisedVelocity, thunderlordSmoothStopTime, float.PositiveInfinity, Time.deltaTime); } if (Mathf.Abs(targetThunderlordRaisedAmount - currentThunderlordRaisedAmount) <= 0.0001f) { currentThunderlordRaisedAmount = targetThunderlordRaisedAmount; thunderlordRaisedVelocity = 0f; } ApplyThunderlordState(Time.deltaTime); UpdateThunderlordMeshVisibility(); if (targetThunderlordRaisedAmount <= 0.001f && currentThunderlordRaisedAmount <= 0.001f) { break; } yield return null; } SetThunderlordMeshVisible(visible: false); SetThunderlordGameObjectActive(active: false); thunderlordMotionCoroutine = null; } private void ApplyThunderlordState(float deltaTime) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_0091: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)thunderlordOrbitRoot == (Object)null) && !((Object)(object)thunderlordTransform == (Object)null)) { bool flag = targetThunderlordRaisedAmount > 0.001f || currentThunderlordRaisedAmount > 0.001f; SetThunderlordGameObjectActive(flag); if (!flag) { Vector3 localPosition = thunderlordTransform.localPosition; localPosition.x = thunderlordHiddenDistance; localPosition.y = thunderlordHiddenLocalY; localPosition.z = 0f; thunderlordTransform.localPosition = localPosition; } else { float num = Mathf.Lerp(thunderlordMinimumOrbitDegreesPerSecond, thunderlordMaximumOrbitDegreesPerSecond, currentThunderlordRaisedAmount); thunderlordOrbitDegrees += num * deltaTime; thunderlordOrbitRoot.localRotation = Quaternion.Euler(0f, thunderlordOrbitDegrees, 0f); Vector3 localPosition2 = thunderlordTransform.localPosition; localPosition2.x = Mathf.Lerp(thunderlordHiddenDistance, thunderlordRaisedDistance, currentThunderlordRaisedAmount); localPosition2.y = Mathf.Lerp(thunderlordHiddenLocalY, thunderlordRaisedLocalY, currentThunderlordRaisedAmount); localPosition2.z = 0f; thunderlordTransform.localPosition = localPosition2; } } } } internal class VisualManager : MonoBehaviour, ITemporalInstability { [Serializable] private class VolumeSettings { [Range(0f, 100f)] public float StartLevel = 0f; [Range(0f, 100f)] public float FullLevel = 70f; [Range(0f, 1f)] public float StartWeight = 0.01f; [Range(0f, 1f)] public float FullWeight = 0.5f; [Min(0.01f)] public float TransitionSeconds = 1f; } [Serializable] private class ParticleSettings { [Range(0f, 100f)] public float StartLevel = 46f; [Range(0f, 100f)] public float FullLevel = 100f; [Min(0f)] public float StartRate = 2f; [Min(0f)] public float FullRate = 30f; [Min(0f)] public float StartSpeed = 4f; [Min(0f)] public float FullSpeed = 10f; [Min(0f)] public float StartSize = 0.1f; [Min(0f)] public float FullSize = 0.5f; [Min(0.01f)] public float TransitionSeconds = 1f; } private static bool fogVolumeComponentExists; [Header("Follow")] [SerializeField] private PositionConstraint positionConstraint = null; [Header("Volume")] [SerializeField] private Volume temporalStormVolume = null; [SerializeField] private bool disableLevelFog = true; [SerializeField] private VolumeSettings volume = new VolumeSettings(); [Header("Particles")] [SerializeField] private ParticleSystem blackAirParticles = null; [SerializeField] private ParticleSettings particles = new ParticleSettings(); private Coroutine? visualTransitionCoroutine; private bool weatherFlowActive; private float temporalInstabilityLevel; private float currentVolumeWeight; private float currentParticleRate; private float currentParticleSpeed; private float currentParticleSize; private float wantedVolumeWeight; private float wantedParticleRate; private float wantedParticleSpeed; private float wantedParticleSize; private void Awake() { AimVisuals(); SnapVisuals(); blackAirParticles.Stop(true, (ParticleSystemStopBehavior)0); } private void OnEnable() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; EnableVanillaSun(enabled: false); BindToCamera(); ((UnityEvent)StartOfRound.Instance.CameraSwitchEvent).AddListener(new UnityAction(BindToCamera)); AimVisuals(); SnapVisuals(); if (disableLevelFog) { EnableVanillaVolumeFog(enabled: false, ref fogVolumeComponentExists); } TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); } } private void OnDisable() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (weatherFlowActive) { weatherFlowActive = false; StartOfRound instance = StartOfRound.Instance; if (instance != null) { ((UnityEvent)instance.CameraSwitchEvent).RemoveListener(new UnityAction(BindToCamera)); } TemporalInstabilityAPI.Unregister(this); EnableVanillaSun(enabled: true); CoroutineTools.Stop((MonoBehaviour)(object)this, ref visualTransitionCoroutine); temporalInstabilityLevel = 0f; AimVisuals(); SnapVisuals(); blackAirParticles.Stop(true, (ParticleSystemStopBehavior)0); if (disableLevelFog) { EnableVanillaVolumeFog(enabled: true, ref fogVolumeComponentExists); } } } private void BindToCamera() { Transform val = Utility.LocalViewTransform(); if ((Object)(object)val != (Object)null) { Utility.BindPositionConstraint(positionConstraint, val); } } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); AimVisuals(); if (!VisualsDone()) { CoroutineTools.Start((MonoBehaviour)(object)this, ref visualTransitionCoroutine, SmoothVisuals()); } } private IEnumerator SmoothVisuals() { while (weatherFlowActive && !VisualsDone()) { float volumeMoveAmount = Time.deltaTime / Mathf.Max(0.01f, volume.TransitionSeconds); float particleMoveAmount = Time.deltaTime / Mathf.Max(0.01f, particles.TransitionSeconds); SetVolumeWeight(Mathf.MoveTowards(currentVolumeWeight, wantedVolumeWeight, volumeMoveAmount)); SetParticleValues(Mathf.MoveTowards(currentParticleRate, wantedParticleRate, particles.FullRate * particleMoveAmount), Mathf.MoveTowards(currentParticleSpeed, wantedParticleSpeed, Mathf.Max(particles.StartSpeed, particles.FullSpeed) * particleMoveAmount), Mathf.MoveTowards(currentParticleSize, wantedParticleSize, Mathf.Max(particles.StartSize, particles.FullSize) * particleMoveAmount)); yield return null; } if (weatherFlowActive) { SetVolumeWeight(wantedVolumeWeight); SetParticleValues(wantedParticleRate, wantedParticleSpeed, wantedParticleSize); } visualTransitionCoroutine = null; } private bool VisualsDone() { return Mathf.Approximately(currentVolumeWeight, wantedVolumeWeight) && Mathf.Approximately(currentParticleRate, wantedParticleRate) && Mathf.Approximately(currentParticleSpeed, wantedParticleSpeed) && Mathf.Approximately(currentParticleSize, wantedParticleSize); } private void AimVisuals() { if (temporalInstabilityLevel < volume.StartLevel) { wantedVolumeWeight = 0f; } else { float num = Utility.InstabilityProgress(temporalInstabilityLevel, volume.StartLevel, volume.FullLevel); wantedVolumeWeight = Mathf.Lerp(volume.StartWeight, volume.FullWeight, num); } float num2 = Utility.InstabilityProgress(temporalInstabilityLevel, particles.StartLevel, particles.FullLevel); wantedParticleRate = Mathf.Lerp(0f, particles.FullRate, num2); wantedParticleSpeed = Mathf.Lerp(particles.StartSpeed, particles.FullSpeed, num2); wantedParticleSize = Mathf.Lerp(particles.StartSize, particles.FullSize, num2); } private void SnapVisuals() { SetVolumeWeight(wantedVolumeWeight); SetParticleValues(wantedParticleRate, wantedParticleSpeed, wantedParticleSize); } private void SetVolumeWeight(float weight) { currentVolumeWeight = Mathf.Clamp01(weight); temporalStormVolume.weight = currentVolumeWeight; } private void SetParticleValues(float rate, float speed, float size) { //IL_003a: 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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) currentParticleRate = Mathf.Max(0f, rate); currentParticleSpeed = Mathf.Max(0f, speed); currentParticleSize = Mathf.Max(0f, size); MainModule main = blackAirParticles.main; ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(currentParticleSpeed); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(currentParticleSize); ParticleUtils.SetEmissionRateAndPlayback(blackAirParticles, currentParticleRate, (ParticleSystemStopBehavior)0); } private static void EnableVanillaSun(bool enabled) { animatedSun val = Object.FindObjectOfType(); if (!((Object)(object)val == (Object)null)) { Transform val2 = ((Component)val).transform.Find("SunTexture"); Transform val3 = ((Component)val).transform.Find("EclipseObject"); if (val2 != null) { ((Component)val2).gameObject.SetActive(enabled); } if (val3 != null) { ((Component)val3).gameObject.SetActive(enabled); } } } private static void EnableVanillaVolumeFog(bool enabled, ref bool fogVolumeComponentExists) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (enabled && !fogVolumeComponentExists) { return; } string sceneName = RoundManager.Instance.currentLevel.sceneName; Volume[] array = Object.FindObjectsOfType(); foreach (Volume val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val.profile == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).name != sceneName) { continue; } for (int j = 0; j < val.profile.components.Count; j++) { VolumeComponent val2 = val.profile.components[j]; if (val2.active && val2 is Fog) { val2.active = enabled; fogVolumeComponentExists = !enabled; } } } } } internal class WarningManager : MonoBehaviour, ITemporalInstability { private enum WarningTier { Quiet, Approaching, Imminent, LowStability } [Serializable] private class WarningAudioSources { public AudioSource WarningSource = null; public AudioSource BellSource = null; public AudioSource BassSourceA = null; public AudioSource BassSourceB = null; } [Serializable] private class WarningEventSettings { [Range(0f, 100f)] public float EnterLevel; public AudioClip WarningClip = null; [Range(0f, 1f)] public float WarningVolume = 1f; [Range(0f, 1f)] public float WarningVolumeWeight = 1f; [Min(0f)] public float CameraShakeMagnitude = 0.03f; public bool PlayBellTolls = false; [Min(0f)] public int BellCount = 1; public bool PlayBassPulses = false; [Min(0f)] public int BassPulseCount = 0; } [Serializable] private class WaningEventSettings { public AudioClip WaningBellClip = null; [Range(0f, 1f)] public float WaningBellVolume = 1f; } [Serializable] private class BellSettings { public AudioClip BellClip = null; [Range(0f, 1f)] public float BellVolume = 1f; [Min(0f)] public float StartDelaySeconds = 5f; [Min(0.01f)] public float SpacingSeconds = 3f; } [Serializable] private class BassSettings { public AudioClip BassClipA = null; public AudioClip BassClipB = null; [Range(0f, 1f)] public float BassVolume = 1f; [Min(0f)] public float StartDelaySeconds = 6.5f; [Min(0.01f)] public float SpacingSeconds = 3f; } [Serializable] private class EnvelopeSettings { [Min(0.01f)] public float DurationSeconds = 28f; [Min(0.01f)] public float FadeSeconds = 10f; } [Header("Sources")] [SerializeField] private WarningAudioSources sources = new WarningAudioSources(); [Header("Warning Volume")] [SerializeField] private Volume warningVolume = null; [SerializeField] private EnvelopeSettings envelope = new EnvelopeSettings(); [Header("Approaching")] [SerializeField] private WarningEventSettings approaching = new WarningEventSettings { EnterLevel = 20f, WarningVolume = 1f, WarningVolumeWeight = 0.35f, CameraShakeMagnitude = 0.03f, PlayBellTolls = true, BellCount = 1, PlayBassPulses = false, BassPulseCount = 0 }; [Header("Imminent")] [SerializeField] private WarningEventSettings imminent = new WarningEventSettings { EnterLevel = 46f, WarningVolume = 1f, WarningVolumeWeight = 0.7f, CameraShakeMagnitude = 0.06f, PlayBellTolls = true, BellCount = 2, PlayBassPulses = true, BassPulseCount = 2 }; [Header("Low Stability")] [SerializeField] private WarningEventSettings lowStability = new WarningEventSettings { EnterLevel = 70f, WarningVolume = 1f, WarningVolumeWeight = 1f, CameraShakeMagnitude = 0.1f, PlayBellTolls = true, BellCount = 3, PlayBassPulses = true, BassPulseCount = 3 }; [Header("Waning")] [SerializeField] private WaningEventSettings waning = new WaningEventSettings(); [Header("Bells")] [SerializeField] private BellSettings bells = new BellSettings(); [Header("Bass Pulses")] [SerializeField] private BassSettings bass = new BassSettings(); private Coroutine? warningCoroutine; private Coroutine? fadeOutCoroutine; private Coroutine? cameraShakeCoroutine; private Transform? cameraShakeTransform; private Vector3 cameraShakeOffset; private bool weatherFlowActive; private bool audioSourcesReady; private WarningTier currentTier = WarningTier.Quiet; private float baseWarningVolumeWeight; internal static bool IsWarningActive { get; private set; } internal static float ScreenWarpAmount { get; private set; } internal AudioClip?[] AudioClips => (AudioClip?[])(object)new AudioClip[7] { approaching.WarningClip, imminent.WarningClip, lowStability.WarningClip, waning.WaningBellClip, bells.BellClip, bass.BassClipA, bass.BassClipB }; private void Awake() { audioSourcesReady = AudioUtils.Configure2DAudioSource(sources.WarningSource, loop: false) && AudioUtils.Configure2DAudioSource(sources.BellSource, loop: false) && AudioUtils.Configure2DAudioSource(sources.BassSourceA, loop: false) && AudioUtils.Configure2DAudioSource(sources.BassSourceB, loop: false) && (Object)(object)warningVolume != (Object)null; Volume obj = warningVolume; if (obj != null) { obj.weight = 0f; } } private void OnEnable() { if (audioSourcesReady && Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Server); } } public void SetTemporalInstabilityLevel(float value) { float num = Utility.ClampInstability(value); WarningTier warningTier = ((num >= lowStability.EnterLevel) ? WarningTier.LowStability : ((num >= imminent.EnterLevel) ? WarningTier.Imminent : ((num >= approaching.EnterLevel) ? WarningTier.Approaching : WarningTier.Quiet))); if (warningTier == currentTier) { return; } WarningTier warningTier2 = currentTier; currentTier = warningTier; if (warningTier > warningTier2) { if (1 == 0) { } WarningEventSettings warningEventSettings = warningTier switch { WarningTier.LowStability => lowStability, WarningTier.Imminent => imminent, _ => approaching, }; if (1 == 0) { } WarningEventSettings settings = warningEventSettings; StartWarningEvent(settings); LocustEnemyBase.WakeForWarningLevel((int)warningTier); } else { StopActiveWarning(); FadeOutWarningVolume(); if (warningTier == WarningTier.Quiet) { AudioTools.Stop(sources.BellSource, false); AudioTools.SwapClip(sources.BellSource, waning.WaningBellClip, false); sources.BellSource.volume = waning.WaningBellVolume; sources.BellSource.time = 0f; sources.BellSource.Play(); } } } private void StartWarningEvent(WarningEventSettings settings) { StopActiveWarning(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref fadeOutCoroutine); IsWarningActive = true; CoroutineTools.Start((MonoBehaviour)(object)this, ref warningCoroutine, RunWarningEvent(settings)); } private void StopActiveWarning() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref warningCoroutine); IsWarningActive = false; ScreenWarpAmount = 0f; StopCameraShake(); AudioTools.StopMany(false, (AudioSource[])(object)new AudioSource[4] { sources.WarningSource, sources.BellSource, sources.BassSourceA, sources.BassSourceB }); } private IEnumerator RunWarningEvent(WarningEventSettings settings) { AudioTools.Stop(sources.WarningSource, false); AudioTools.SwapClip(sources.WarningSource, settings.WarningClip, false); sources.WarningSource.volume = settings.WarningVolume; sources.WarningSource.time = 0f; sources.WarningSource.Play(); CoroutineTools.Start((MonoBehaviour)(object)this, ref cameraShakeCoroutine, RunCameraShake(settings.CameraShakeMagnitude)); float elapsedSeconds = 0f; float startWeight = baseWarningVolumeWeight; int bellsPlayed = 0; int bassPulsesPlayed = 0; float nextBellTime = NextBellTime(settings, bellsPlayed); float nextBassTime = NextBassTime(settings, bassPulsesPlayed); bool bassSourceToggle = false; while (elapsedSeconds < envelope.DurationSeconds) { elapsedSeconds += Time.deltaTime; float envelopeAmount = EnvelopeAmount(elapsedSeconds); ScreenWarpAmount = settings.WarningVolumeWeight * envelopeAmount; PushWarningVolume((elapsedSeconds < envelope.FadeSeconds) ? Mathf.Lerp(startWeight, settings.WarningVolumeWeight, envelopeAmount) : (settings.WarningVolumeWeight * envelopeAmount)); if (settings.PlayBellTolls && bellsPlayed < settings.BellCount && elapsedSeconds >= nextBellTime) { sources.BellSource.volume = bells.BellVolume; AudioTools.PlayOneShot(sources.BellSource, bells.BellClip); bellsPlayed++; nextBellTime = NextBellTime(settings, bellsPlayed); } if (settings.PlayBassPulses && bassPulsesPlayed < settings.BassPulseCount && elapsedSeconds >= nextBassTime) { bassSourceToggle = !bassSourceToggle; AudioSource bassSource = (bassSourceToggle ? sources.BassSourceA : sources.BassSourceB); AudioTools.Stop(bassSource, false); AudioTools.SwapClip(bassSource, bassSourceToggle ? bass.BassClipA : bass.BassClipB, false); bassSource.volume = bass.BassVolume; bassSource.time = 0f; bassSource.Play(); bassPulsesPlayed++; nextBassTime = NextBassTime(settings, bassPulsesPlayed); } yield return null; } StopCameraShake(); warningCoroutine = null; IsWarningActive = false; ScreenWarpAmount = 0f; FadeOutWarningVolume(); } private void FadeOutWarningVolume() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref fadeOutCoroutine); CoroutineTools.Start((MonoBehaviour)(object)this, ref fadeOutCoroutine, FadeOutWarningVolumeRoutine()); } private IEnumerator FadeOutWarningVolumeRoutine() { float startWeight = baseWarningVolumeWeight; float elapsedSeconds = 0f; float duration = envelope.FadeSeconds; while (elapsedSeconds < duration) { elapsedSeconds += Time.deltaTime; PushWarningVolume(Mathf.Lerp(startWeight, 0f, elapsedSeconds / duration)); yield return null; } PushWarningVolume(0f); fadeOutCoroutine = null; } private void PushWarningVolume(float baseWeight) { baseWarningVolumeWeight = Mathf.Clamp01(baseWeight); warningVolume.weight = baseWarningVolumeWeight; } private float EnvelopeAmount(float elapsedSeconds) { float num = Mathf.Clamp01(elapsedSeconds / envelope.FadeSeconds); float num2 = Mathf.Clamp01((envelope.DurationSeconds - elapsedSeconds) / envelope.FadeSeconds); return Mathf.Min(num, num2); } private float NextBellTime(WarningEventSettings settings, int bellsPlayed) { return (!settings.PlayBellTolls || bellsPlayed >= settings.BellCount) ? float.PositiveInfinity : (bells.StartDelaySeconds + bells.SpacingSeconds * (float)bellsPlayed); } private float NextBassTime(WarningEventSettings settings, int bassPulsesPlayed) { return (!settings.PlayBassPulses || bassPulsesPlayed >= settings.BassPulseCount) ? float.PositiveInfinity : (bass.StartDelaySeconds + bass.SpacingSeconds * (float)bassPulsesPlayed); } private IEnumerator RunCameraShake(float magnitude) { Camera camera = Utility.LocalPlayer().gameplayCamera; Transform cameraTransform = (cameraShakeTransform = ((Component)camera).transform); cameraShakeOffset = Vector3.zero; float elapsedSeconds = 0f; float seedX = Random.value * 100f; float seedY = Random.value * 100f; while (elapsedSeconds < envelope.DurationSeconds) { elapsedSeconds += Time.deltaTime; float envelopeAmount = EnvelopeAmount(elapsedSeconds); float noiseTime = elapsedSeconds * 24f; float xOffset = (Mathf.PerlinNoise(seedX, noiseTime) * 2f - 1f) * magnitude * envelopeAmount; float yOffset = (Mathf.PerlinNoise(seedY, noiseTime) * 2f - 1f) * magnitude * envelopeAmount; Vector3 neutralPosition = cameraTransform.localPosition - cameraShakeOffset; cameraShakeOffset = new Vector3(xOffset, yOffset, 0f); cameraTransform.localPosition = neutralPosition + cameraShakeOffset; yield return null; } RestoreCameraShakePosition(); cameraShakeCoroutine = null; } private void StopCameraShake() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref cameraShakeCoroutine); RestoreCameraShakePosition(); } private void RestoreCameraShakePosition() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cameraShakeTransform == (Object)null)) { Transform? obj = cameraShakeTransform; obj.localPosition -= cameraShakeOffset; cameraShakeTransform = null; cameraShakeOffset = Vector3.zero; } } private void OnDisable() { if (weatherFlowActive) { weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); StopActiveWarning(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref fadeOutCoroutine); baseWarningVolumeWeight = 0f; ScreenWarpAmount = 0f; warningVolume.weight = 0f; currentTier = WarningTier.Quiet; } } } } namespace TemporalStormWeather.TemporalStormManagers.RustLightning { [RequireComponent(typeof(MeshFilter))] [RequireComponent(typeof(MeshRenderer))] public class RustLightningBolt : MonoBehaviour { internal struct LightningPointData { public Vector3 Position; public Vector3 ForwardAxis; public Vector3 RightAxis; public Vector3 UpAxis; public bool SupportsNextGenerations; } internal struct LightningBranchData { public int StartIndex; public int PointCount; public float StartVisibility; public float WidthMultiplier; public float AlphaMultiplier; } private class RustLightningBoltGenerator { private readonly RustLightningBoltSettings settings; private readonly int branchLayoutSeed; private readonly Vector3 worldPosition; private readonly RustLightningExclusionBox[] exclusionBoxes; private readonly List lightningPoints = new List(); private List branchScratchPoints = new List(); private List branchScratchBuffer = new List(); private readonly List lightningBranches = new List(); private readonly List branchPoints = new List(); private readonly Vector3[] basePathPoints = Array.Empty(); public RustLightningBoltGenerator(int seed, RustLightningBoltSettings settings, Vector3 worldPosition, RustLightningExclusionBox[] exclusionBoxes) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) this.settings = settings; this.worldPosition = worldPosition; this.exclusionBoxes = exclusionBoxes; branchLayoutSeed = seed + 1442695041; Random random = new Random(seed); int num = Mathf.Max(settings.StackedSegmentCount, 1); basePathPoints = (Vector3[])(object)new Vector3[num + 1]; Vector3 val = Vector3.up; float minimum = Mathf.Max(Mathf.Min(settings.MinHeight, settings.MaxHeight), 0.01f); float maximum = Mathf.Max(Mathf.Max(settings.MinHeight, settings.MaxHeight), 0.01f); float minimum2 = ((settings.TargetAngleMin < settings.TargetAngleMax) ? settings.TargetAngleMin : settings.TargetAngleMax); float maximum2 = ((settings.TargetAngleMin < settings.TargetAngleMax) ? settings.TargetAngleMax : settings.TargetAngleMin); for (int i = 1; i < basePathPoints.Length; i++) { float num2 = Utility.RandomRange(random, minimum2, maximum2); float num3 = (float)random.NextDouble() * MathF.PI * 2f; (Vector3, Vector3) tuple = CreateOrthogonalAxes(val); Vector3 item = tuple.Item1; Vector3 item2 = tuple.Item2; Vector3 val2 = Normalize(item * Mathf.Cos(num3) + item2 * Mathf.Sin(num3)); val = Normalize(Quaternion.AngleAxis(num2, val2) * val); float num4 = Utility.RandomRange(random, minimum, maximum); Vector3 val3 = basePathPoints[i - 1]; Vector3 val4 = val3 + val * num4; for (int j = 0; j < 8; j++) { if (exclusionBoxes.Length == 0) { break; } Vector3 val5 = Vector3.zero; int num5 = 0; for (int k = 0; k < exclusionBoxes.Length; k++) { if (exclusionBoxes[k].TryGetSegmentDiversion(worldPosition + val3, worldPosition + val4, settings.Width, out var direction)) { val5 += direction; num5++; } } if (num5 == 0) { break; } val = Normalize(val * 0.35f + Normalize(val5) * (0.8f + (float)j * 0.25f) + Vector3.up * 0.2f); val4 = val3 + val * num4; } basePathPoints[i] = val4; } } public RustLightningBoltGeneratedData Generate() { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0080: 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_008a: Unknown result type (might be due to invalid IL or missing references) lightningPoints.Clear(); if (basePathPoints.Length >= 2) { if (lightningPoints.Capacity < basePathPoints.Length) { lightningPoints.Capacity = basePathPoints.Length; } for (int i = 0; i < basePathPoints.Length; i++) { Vector3 forwardAxis = ((i <= 0) ? Normalize(basePathPoints[1] - basePathPoints[0]) : ((i >= basePathPoints.Length - 1) ? Normalize(basePathPoints[^1] - basePathPoints[^2]) : Normalize(basePathPoints[i + 1] - basePathPoints[i - 1]))); var (rightAxis, upAxis) = CreateOrthogonalAxes(forwardAxis); lightningPoints.Add(new LightningPointData { Position = basePathPoints[i], ForwardAxis = forwardAxis, RightAxis = rightAxis, UpAxis = upAxis, SupportsNextGenerations = true }); } } GenerateBranches(); return new RustLightningBoltGeneratedData(lightningPoints.ToArray(), lightningBranches.ToArray(), branchPoints.ToArray()); } private void GenerateLightningShape(ref List points, ref List buffer, int generations, float displacementHeight, int seedOffset) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i <= generations; i++) { float generationOffset = displacementHeight * 0.05f * Mathf.Pow(0.533f, (float)(i - 1)); buffer.Clear(); int num = points.Count * 2 - 1; if (buffer.Capacity < num) { buffer.Capacity = num; } for (int j = 0; j < points.Count - 1; j++) { LightningPointData currentPoint = points[j]; LightningPointData nextPoint = points[j + 1]; Vector3 position = Vector3.Lerp(currentPoint.Position, nextPoint.Position, 0.5f); bool flag = currentPoint.SupportsNextGenerations || nextPoint.SupportsNextGenerations; LightningPointData midpoint = new LightningPointData { Position = position, ForwardAxis = currentPoint.ForwardAxis, RightAxis = currentPoint.RightAxis, UpAxis = currentPoint.UpAxis, SupportsNextGenerations = flag }; if (flag) { DisplaceMidPoint(ref currentPoint, nextPoint, ref midpoint, generationOffset, j, i, seedOffset); } buffer.Add(currentPoint); buffer.Add(midpoint); } List obj = buffer; List obj2 = points; obj.Add(obj2[obj2.Count - 1]); List list = buffer; List list2 = points; points = list; buffer = list2; } } private void GenerateBranches() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) lightningBranches.Clear(); branchPoints.Clear(); if (settings.BranchCount <= 0 || lightningPoints.Count < 3) { return; } int branchGenerations = Mathf.Clamp(settings.BranchGenerations, 0, 6); float minHeight = Mathf.Max(Mathf.Min(settings.MinHeight, settings.MaxHeight), 0.01f); float maxHeight = Mathf.Max(Mathf.Max(settings.MinHeight, settings.MaxHeight), 0.01f); float widthMultiplier = Mathf.Max(settings.BranchWidthMultiplier, 0.01f); float alphaMultiplier = Clamp01(settings.BranchAlphaMultiplier); for (int i = 0; i < settings.BranchCount; i++) { int seed = branchLayoutSeed + i * 668265263; int num = 1 + Mathf.FloorToInt(Hash01(seed) * (float)(lightningPoints.Count - 2)); num = Mathf.Clamp(num, 1, lightningPoints.Count - 2); LightningPointData spawnPoint = lightningPoints[num]; Vector3 parentDirection = Vector3.up; if (basePathPoints.Length >= 2 && lightningPoints.Count >= 2) { float num2 = (float)num / Mathf.Max((float)lightningPoints.Count - 1f, 1f); int num3 = Mathf.Clamp(Mathf.FloorToInt(num2 * (float)(basePathPoints.Length - 1)), 0, basePathPoints.Length - 2); parentDirection = Normalize(basePathPoints[num3 + 1] - basePathPoints[num3]); } float startVisibility = (float)num / Mathf.Max((float)lightningPoints.Count - 1f, 1f); GenerateBranch(spawnPoint, parentDirection, startVisibility, 1f, widthMultiplier, alphaMultiplier, 0, seed, branchGenerations, minHeight, maxHeight); } } private void GenerateBranch(LightningPointData spawnPoint, Vector3 parentDirection, float startVisibility, float lengthScale, float widthMultiplier, float alphaMultiplier, int depth, int seed, int branchGenerations, float minHeight, float maxHeight) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) int num = seed + 374761393; float minimum = ((settings.BranchAngleMin < settings.BranchAngleMax) ? settings.BranchAngleMin : settings.BranchAngleMax); float maximum = ((settings.BranchAngleMin < settings.BranchAngleMax) ? settings.BranchAngleMax : settings.BranchAngleMin); float num2 = RandomRange(num, minimum, maximum); float num3 = Hash01(num + 1013904223) * MathF.PI * 2f; (Vector3, Vector3) tuple = CreateOrthogonalAxes(parentDirection); Vector3 item = tuple.Item1; Vector3 item2 = tuple.Item2; Vector3 val = Normalize(item * Mathf.Cos(num3) + item2 * Mathf.Sin(num3)); Vector3 val2 = Normalize(Quaternion.AngleAxis(num2, val) * parentDirection); float num4 = RandomRange(seed + 1274126177, minHeight, maxHeight) * Mathf.Max(settings.BranchLengthMultiplier, 0.01f) * lengthScale; float worldPadding = settings.Width * Mathf.Max(widthMultiplier, 0.01f); for (int i = 0; i < 8; i++) { branchScratchPoints.Clear(); var (rightAxis, upAxis) = CreateOrthogonalAxes(val2); branchScratchPoints.Add(new LightningPointData { Position = spawnPoint.Position, ForwardAxis = val2, RightAxis = rightAxis, UpAxis = upAxis, SupportsNextGenerations = true }); branchScratchPoints.Add(new LightningPointData { Position = spawnPoint.Position + val2 * num4, ForwardAxis = val2, RightAxis = rightAxis, UpAxis = upAxis, SupportsNextGenerations = true }); GenerateLightningShape(ref branchScratchPoints, ref branchScratchBuffer, branchGenerations, num4, seed + i); if (exclusionBoxes.Length == 0) { break; } Vector3 val3 = Vector3.zero; int num5 = 0; int num6 = branchScratchPoints.Count - 1; for (int j = 0; j < num6; j++) { Vector3 worldStart = worldPosition + branchScratchPoints[j].Position; Vector3 worldEnd = worldPosition + branchScratchPoints[j + 1].Position; for (int k = 0; k < exclusionBoxes.Length; k++) { if (exclusionBoxes[k].TryGetSegmentDiversion(worldStart, worldEnd, worldPadding, out var direction)) { val3 += direction; num5++; } } } if (num5 == 0) { break; } val2 = Normalize(val2 * 0.25f + Normalize(val3) * (0.9f + (float)i * 0.3f) + parentDirection * 0.15f); } LightningBranchData item3 = new LightningBranchData { StartIndex = branchPoints.Count, PointCount = branchScratchPoints.Count, StartVisibility = startVisibility, WidthMultiplier = widthMultiplier, AlphaMultiplier = alphaMultiplier }; branchPoints.AddRange(branchScratchPoints); lightningBranches.Add(item3); if (depth < Mathf.Max(settings.BranchContinuationDepth, 0) && branchScratchPoints.Count >= 3 && !(Hash01(seed + 915488749) > settings.BranchContinuationChance)) { int num7 = Mathf.Max(1, branchScratchPoints.Count / 2); int num8 = branchScratchPoints.Count - 2; if (num7 <= num8) { int seed2 = seed + 1013904223 + depth * 374761393; int num9 = num7 + Mathf.FloorToInt(Hash01(seed2) * (float)(num8 - num7 + 1)); num9 = Mathf.Clamp(num9, num7, num8); LightningPointData spawnPoint2 = branchScratchPoints[num9]; float startVisibility2 = Mathf.Lerp(startVisibility, 1f, (float)num9 / Mathf.Max((float)branchScratchPoints.Count - 1f, 1f)); float num10 = Mathf.Clamp(settings.BranchContinuationScale, 0.1f, 1f); GenerateBranch(spawnPoint2, spawnPoint2.ForwardAxis, startVisibility2, lengthScale * num10, widthMultiplier * num10, alphaMultiplier * num10, depth + 1, seed2, branchGenerations, minHeight, maxHeight); } } } private void DisplaceMidPoint(ref LightningPointData currentPoint, LightningPointData nextPoint, ref LightningPointData midpoint, float generationOffset, int pointIndex, int currentGeneration, int seedOffset) { //IL_0052: 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_005e: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_007f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0102: Unknown result type (might be due to invalid IL or missing references) int num = seedOffset + pointIndex * 73856093 + currentGeneration * 19349663 + Mathf.RoundToInt(((Vector3)(ref midpoint.Position)).sqrMagnitude * 1000f); float num2 = RandomRange(num, 0f - generationOffset, generationOffset); float num3 = RandomRange(num + 83492791, 0f - generationOffset, generationOffset); ref Vector3 position = ref midpoint.Position; position += midpoint.RightAxis * num2 + midpoint.UpAxis * num3; Vector3 forwardAxis = Normalize(midpoint.Position - currentPoint.Position); (Vector3, Vector3) tuple = CreateOrthogonalAxes(forwardAxis); Vector3 item = tuple.Item1; Vector3 item2 = tuple.Item2; currentPoint.ForwardAxis = forwardAxis; currentPoint.RightAxis = item; currentPoint.UpAxis = item2; Vector3 forwardAxis2 = Normalize(nextPoint.Position - midpoint.Position); (Vector3, Vector3) tuple2 = CreateOrthogonalAxes(forwardAxis2); Vector3 item3 = tuple2.Item1; Vector3 item4 = tuple2.Item2; midpoint.ForwardAxis = forwardAxis2; midpoint.RightAxis = item3; midpoint.UpAxis = item4; } } private const float branchMiddlePointDisplacement = 0.05f; private const float branchDisplacementDecreaseMultiplierByGeneration = 0.533f; private static readonly int rustBaseColorPropertyId = Shader.PropertyToID("_RustLightningBaseColor"); private static readonly int rustEmissionColorPropertyId = Shader.PropertyToID("_RustLightningEmissionColor"); private static readonly int rustEmissionIntensityPropertyId = Shader.PropertyToID("_RustLightningEmissionIntensity"); private static readonly int rustAlphaMultiplierPropertyId = Shader.PropertyToID("_RustLightningAlphaMultiplier"); private static readonly int rustEdgeSoftnessPropertyId = Shader.PropertyToID("_RustLightningEdgeSoftness"); private readonly List lightningPoints = new List(); private readonly List lightningBranches = new List(); private readonly List branchPoints = new List(); private readonly List vertices = new List(); private readonly List uvs = new List(); private readonly List colors = new List(); private readonly List triangles = new List(); private Mesh mesh = null; private MeshFilter meshFilter = null; private MeshRenderer meshRenderer = null; private MaterialPropertyBlock materialPropertyBlock = null; private RustLightningBoltSettings? settings; private float controlledVisibilityProgress = -1f; private bool requestedMeshVisibility = true; private void Awake() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0043: Expected O, but got Unknown meshFilter = ((Component)this).GetComponent(); meshRenderer = ((Component)this).GetComponent(); materialPropertyBlock = new MaterialPropertyBlock(); mesh = new Mesh { name = "RustLightningTubeMesh", hideFlags = (HideFlags)0 }; mesh.MarkDynamic(); meshFilter.sharedMesh = mesh; } internal static RustLightningBoltGeneratedData GenerateData(int seed, RustLightningBoltSettings boltSettings, Vector3 worldPosition, RustLightningExclusionBox[] exclusionBoxes) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return new RustLightningBoltGenerator(seed, boltSettings, worldPosition, exclusionBoxes).Generate(); } internal void ApplyGeneratedData(Vector3 worldPosition, RustLightningBoltSettings boltSettings, RustLightningBoltGeneratedData generatedData) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) settings = boltSettings; ((Component)this).transform.position = worldPosition; controlledVisibilityProgress = -1f; lightningPoints.Clear(); lightningBranches.Clear(); branchPoints.Clear(); lightningPoints.AddRange(generatedData.LightningPoints); lightningBranches.AddRange(generatedData.LightningBranches); branchPoints.AddRange(generatedData.BranchPoints); mesh.Clear(); if ((Object)(object)settings.LightningMaterial != (Object)null) { ((Renderer)meshRenderer).sharedMaterial = settings.LightningMaterial; } SetControlledProgress(0f); } internal void ClearGeneratedData() { controlledVisibilityProgress = -1f; settings = null; lightningPoints.Clear(); lightningBranches.Clear(); branchPoints.Clear(); vertices.Clear(); uvs.Clear(); colors.Clear(); triangles.Clear(); Mesh obj = mesh; if (obj != null) { obj.Clear(); } SetMeshVisible(visible: false); } internal void SetMeshVisible(bool visible) { requestedMeshVisibility = visible; if ((Object)(object)meshRenderer != (Object)null) { MeshRenderer obj = meshRenderer; int enabled; if (visible) { Mesh obj2 = mesh; enabled = ((obj2 != null && obj2.vertexCount > 0) ? 1 : 0); } else { enabled = 0; } ((Renderer)obj).enabled = (byte)enabled != 0; } } internal void SetControlledProgress(float visibilityProgress) { if (settings != null) { visibilityProgress = Clamp01(visibilityProgress); if (Mathf.Approximately(controlledVisibilityProgress, visibilityProgress)) { ApplyMaterialProperties((visibilityProgress > 0f) ? 1f : 0f); SetMeshVisible(requestedMeshVisibility); return; } controlledVisibilityProgress = visibilityProgress; float fade = ((visibilityProgress > 0f) ? 1f : 0f); ApplyMaterialProperties(fade); BuildTubeMesh(visibilityProgress, fade); } } internal void UpdateMaterialSettings(Color baseColor, Color emissionColor, float emissionIntensity, float edgeSoftness, float alpha) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (settings != null) { settings.BaseColor = baseColor; settings.EmissionColor = emissionColor; settings.EmissionIntensity = emissionIntensity; settings.EdgeSoftness = edgeSoftness; settings.Alpha = alpha; ApplyMaterialProperties((controlledVisibilityProgress > 0f) ? 1f : 0f); } } private void OnDestroy() { if ((Object)(object)mesh != (Object)null) { Object.Destroy((Object)(object)mesh); } } private void BuildTubeMesh(float visibilityProgress, float fade) { vertices.Clear(); uvs.Clear(); colors.Clear(); triangles.Clear(); if (settings == null) { return; } int segmentResolution = Mathf.Clamp(settings.SegmentResolution, 3, 32); if (visibilityProgress > 0f) { AddTubeMesh(lightningPoints, 0, lightningPoints.Count, Clamp01(visibilityProgress), fade, segmentResolution, 1f, 1f, taperEnd: false); for (int i = 0; i < lightningBranches.Count; i++) { LightningBranchData lightningBranchData = lightningBranches[i]; float num = Mathf.Max(0f, lightningBranchData.StartVisibility - Mathf.Max(settings.BranchVisibilityLead, 0f)); float num2 = Mathf.InverseLerp(num, 1f, visibilityProgress); if (num2 > 0f) { AddTubeMesh(branchPoints, lightningBranchData.StartIndex, lightningBranchData.PointCount, Clamp01(num2), fade, segmentResolution, lightningBranchData.WidthMultiplier, lightningBranchData.AlphaMultiplier, taperEnd: true); } } } mesh.Clear(); if (vertices.Count == 0 || triangles.Count == 0) { SetMeshVisible(visible: false); return; } mesh.indexFormat = (IndexFormat)(vertices.Count > 65535); mesh.SetVertices(vertices); mesh.SetUVs(0, uvs); mesh.SetColors(colors); mesh.SetTriangles(triangles, 0, false); mesh.RecalculateBounds(); SetMeshVisible(requestedMeshVisibility); } private void AddTubeMesh(List points, int startIndex, int pointCount, float progress, float fade, int segmentResolution, float widthMultiplier, float alphaMultiplier, bool taperEnd) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) int num = pointCount - 1; if (settings == null || num <= 0) { return; } float num2 = progress * (float)num; int num3 = Mathf.Clamp(Mathf.FloorToInt(num2), 0, num); float num4 = Clamp01(num2 - (float)num3); int num5 = num3 + 1; if (num3 < num && num4 > 0f) { num5++; } if (num5 < 2) { return; } int count = vertices.Count; float num6 = Mathf.Max(settings.Width * widthMultiplier, 0.0001f); Color baseColor = settings.BaseColor; baseColor.a = fade * alphaMultiplier; for (int i = 0; i < num5; i++) { LightningPointData lightningPointData = ((i < pointCount) ? points[startIndex + i] : points[startIndex + pointCount - 1]); if (i == num5 - 1 && num3 < num && num4 > 0f) { LightningPointData lightningPointData2 = points[startIndex + num3]; LightningPointData lightningPointData3 = points[startIndex + num3 + 1]; lightningPointData = new LightningPointData { Position = Vector3.Lerp(lightningPointData2.Position, lightningPointData3.Position, num4), ForwardAxis = Normalize(Vector3.Lerp(lightningPointData2.ForwardAxis, lightningPointData3.ForwardAxis, num4)), RightAxis = Normalize(Vector3.Lerp(lightningPointData2.RightAxis, lightningPointData3.RightAxis, num4)), UpAxis = Normalize(Vector3.Lerp(lightningPointData2.UpAxis, lightningPointData3.UpAxis, num4)), SupportsNextGenerations = (lightningPointData2.SupportsNextGenerations || lightningPointData3.SupportsNextGenerations) }; } float num7 = (float)i / Mathf.Max((float)num5 - 1f, 1f); float num8 = ((taperEnd && i == num5 - 1) ? 0f : num6); for (int j = 0; j < segmentResolution; j++) { float num9 = MathF.PI * 2f * ((float)j / (float)segmentResolution); Vector3 val = lightningPointData.RightAxis * (Mathf.Cos(num9) * num8) + lightningPointData.UpAxis * (Mathf.Sin(num9) * num8); vertices.Add(lightningPointData.Position + val); uvs.Add(new Vector2(alphaMultiplier, num7)); colors.Add(baseColor); } if (i > 0) { int num10 = count + (i - 1) * segmentResolution; int num11 = count + i * segmentResolution; for (int k = 0; k < segmentResolution; k++) { int num12 = (k + 1) % segmentResolution; int item = num10 + k; int item2 = num10 + num12; int item3 = num11 + k; int item4 = num11 + num12; triangles.Add(item); triangles.Add(item4); triangles.Add(item3); triangles.Add(item); triangles.Add(item2); triangles.Add(item4); } } } } private void ApplyMaterialProperties(float fade) { //IL_0036: 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) if (settings != null) { ((Renderer)meshRenderer).GetPropertyBlock(materialPropertyBlock); materialPropertyBlock.SetColor(rustBaseColorPropertyId, settings.BaseColor); materialPropertyBlock.SetColor(rustEmissionColorPropertyId, settings.EmissionColor); materialPropertyBlock.SetFloat(rustEmissionIntensityPropertyId, settings.EmissionIntensity); materialPropertyBlock.SetFloat(rustAlphaMultiplierPropertyId, settings.Alpha * fade); materialPropertyBlock.SetFloat(rustEdgeSoftnessPropertyId, settings.EdgeSoftness); ((Renderer)meshRenderer).SetPropertyBlock(materialPropertyBlock); } } private static (Vector3, Vector3) CreateOrthogonalAxes(Vector3 forwardAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) //IL_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) ? val; if (Mathf.Approximately(Mathf.Abs(forwardAxis.y), 1f)) { val = ((forwardAxis.y > 0f) ? Vector3.right : Vector3.left); } else { Vector3 val2 = Vector3.Cross(Vector3.up, forwardAxis); val = ((Vector3)(ref val2)).normalized; } Vector3 val3 = (Vector3)val; Vector3 item = Vector3.Cross(forwardAxis, val3); return (val3, item); } private static float RandomRange(int seed, float minimum, float maximum) { return Mathf.Lerp(minimum, maximum, Hash01(seed)); } private static float Hash01(int seed) { uint num = (uint)seed; num ^= num >> 16; num *= 2246822519u; num ^= num >> 13; num *= 3266489917u; num ^= num >> 16; return (float)(num & 0xFFFFFF) / 16777215f; } private static float Clamp01(float value) { return (value < 0f) ? 0f : ((value > 1f) ? 1f : value); } private static Vector3 Normalize(Vector3 value) { //IL_0018: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) float magnitude = ((Vector3)(ref value)).magnitude; return (magnitude > 1E-05f) ? (value / magnitude) : Vector3.up; } } internal class RustLightningBoltGeneratedData(RustLightningBolt.LightningPointData[] lightningPoints, RustLightningBolt.LightningBranchData[] lightningBranches, RustLightningBolt.LightningPointData[] branchPoints) { public RustLightningBolt.LightningPointData[] LightningPoints = lightningPoints; public RustLightningBolt.LightningBranchData[] LightningBranches = lightningBranches; public RustLightningBolt.LightningPointData[] BranchPoints = branchPoints; } internal readonly struct RustLightningExclusionBox { private readonly Matrix4x4 worldToLocal; private readonly Vector3 center; private readonly Vector3 extents; private readonly Vector3 localPaddingPerWorldUnit; private readonly Vector3 worldCenter; private RustLightningExclusionBox(Matrix4x4 worldToLocal, Vector3 center, Vector3 extents, Vector3 localPaddingPerWorldUnit, Vector3 worldCenter) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) this.worldToLocal = worldToLocal; this.center = center; this.extents = extents; this.localPaddingPerWorldUnit = localPaddingPerWorldUnit; this.worldCenter = worldCenter; } public static RustLightningExclusionBox FromCollider(BoxCollider collider) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_007c: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)collider).transform; Vector3 lossyScale = transform.lossyScale; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(1f / Mathf.Max(Mathf.Abs(lossyScale.x), 0.0001f), 1f / Mathf.Max(Mathf.Abs(lossyScale.y), 0.0001f), 1f / Mathf.Max(Mathf.Abs(lossyScale.z), 0.0001f)); Matrix4x4 val2 = Matrix4x4.TRS(transform.position, transform.rotation, lossyScale); return new RustLightningExclusionBox(((Matrix4x4)(ref val2)).inverse, collider.center, collider.size * 0.5f, val, transform.TransformPoint(collider.center)); } public bool TryGetSegmentDiversion(Vector3 worldStart, Vector3 worldEnd, float worldPadding, out Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00ea: Unknown result type (might be due to invalid IL or missing references) if (!IntersectsSegment(worldStart, worldEnd, worldPadding)) { direction = default(Vector3); return false; } Vector3 val = worldEnd - worldStart; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = ((sqrMagnitude > 1E-06f) ? Mathf.Clamp01(Vector3.Dot(worldCenter - worldStart, val) / sqrMagnitude) : 0f); Vector3 val2 = worldStart + val * num; Vector3 val3 = val2 - worldCenter; direction = new Vector3(val3.x, 0f, val3.z); if (((Vector3)(ref direction)).sqrMagnitude > 1E-06f) { ((Vector3)(ref direction)).Normalize(); return true; } direction = Vector3.Cross(Vector3.up, val); if (((Vector3)(ref direction)).sqrMagnitude <= 1E-06f) { direction = Vector3.right; } ((Vector3)(ref direction)).Normalize(); return true; } public bool IntersectsSegment(Vector3 worldStart, Vector3 worldEnd, float worldPadding) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0053: 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_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) Matrix4x4 val = worldToLocal; Vector3 val2 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(worldStart); val = worldToLocal; Vector3 val3 = ((Matrix4x4)(ref val)).MultiplyPoint3x4(worldEnd); Vector3 val4 = extents + localPaddingPerWorldUnit * Mathf.Max(worldPadding, 0f); Vector3 min = center - val4; Vector3 max = center + val4; return ContainsLocal(val2, min, max) || ContainsLocal(val3, min, max) || IntersectsLocalSegment(val2, val3, min, max); } private static bool ContainsLocal(Vector3 point, Vector3 min, Vector3 max) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) //IL_0047: 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) return point.x >= min.x && point.x <= max.x && point.y >= min.y && point.y <= max.y && point.z >= min.z && point.z <= max.z; } private static bool IntersectsLocalSegment(Vector3 start, Vector3 end, Vector3 min, Vector3 max) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) Vector3 val = end - start; float enter = 0f; float exit = 1f; return ClipSegmentAxis(start.x, val.x, min.x, max.x, ref enter, ref exit) && ClipSegmentAxis(start.y, val.y, min.y, max.y, ref enter, ref exit) && ClipSegmentAxis(start.z, val.z, min.z, max.z, ref enter, ref exit); } private static bool ClipSegmentAxis(float start, float direction, float min, float max, ref float enter, ref float exit) { if (Mathf.Abs(direction) <= 1E-06f) { return start >= min && start <= max; } float num = 1f / direction; float num2 = (min - start) * num; float num3 = (max - start) * num; if (num2 > num3) { float num4 = num3; num3 = num2; num2 = num4; } enter = Mathf.Max(enter, num2); exit = Mathf.Min(exit, num3); return enter <= exit; } } internal class RustLightningBoltSettings { public Material LightningMaterial = null; public Color BaseColor = new Color(0.28f, 0.09f, 0.025f, 1f); public Color EmissionColor = new Color(0.28f, 0.09f, 0.025f, 1f); public float EmissionIntensity = 1f; public float EdgeSoftness = 0.03f; public float MinHeight = 1f; public float MaxHeight = 8f; public int StackedSegmentCount = 20; public float Width = 0.035f; public int SegmentResolution = 6; public float TargetAngleMin; public float TargetAngleMax = 30f; public int BranchCount = 33; public float BranchLengthMultiplier = 1f; public float BranchWidthMultiplier = 1f; public float BranchAlphaMultiplier = 1f; public float BranchVisibilityLead = 0.25f; public float BranchContinuationChance = 0.886f; public int BranchContinuationDepth = 4; public float BranchContinuationScale = 1f; public float BranchAngleMin = 25f; public float BranchAngleMax = 70f; public int BranchGenerations = 6; public float Alpha = 1f; } public class RustLightningManager : MonoBehaviour, ITemporalInstability, ITemporalStormRustLightning { private struct BoltPlacementInput { public int Seed; public Vector3 Position; public RustLightningBoltSettings Settings; } private struct BoltPlacementResult { public Vector3 Position; public RustLightningBoltSettings Settings; public RustLightningBoltGeneratedData GeneratedData; } private static readonly HashSet managers = new HashSet(); private static bool temporarySkyVisible; [Header("Binding")] [SerializeField] private PositionConstraint positionConstraint = null; [Header("Prefab")] [SerializeField] private RustLightningBolt boltPrefab = null; [SerializeField] private Material lightningMaterial = null; [Header("Orbit")] [SerializeField] [Min(0f)] private int boltCount = 12; [SerializeField] [Min(0f)] private float minDistance = 600f; [SerializeField] [Min(0f)] private float maxDistance = 1200f; [SerializeField] private float orbitJitterDegrees = 12f; [Header("Ground")] [SerializeField] private float groundSearchHeight = 40f; [SerializeField] private float groundSearchDepth = 90f; [SerializeField] private float missingGroundY = -50f; [Header("Instability")] [SerializeField] [Range(0f, 100f)] private float minInstability = 25f; [SerializeField] [Range(0f, 100f)] private float maxInstability = 100f; [Header("Distance Multipliers")] [SerializeField] private float nearHeightMultiplier = 1f; [SerializeField] private float farHeightMultiplier = 3f; [SerializeField] private float nearWidthMultiplier = 1f; [SerializeField] private float farWidthMultiplier = 2f; [Header("Material")] [SerializeField] [ColorUsage(true, false)] private Color baseColor = new Color(0.28f, 0.09f, 0.025f, 1f); [SerializeField] [ColorUsage(true, true)] private Color emissionColor = new Color(0.28f, 0.09f, 0.025f, 1f); [SerializeField] private float emissionIntensity = 1f; [SerializeField] private float edgeSoftness = 0.03f; [SerializeField] private float alpha = 1f; [Header("Path")] [SerializeField] private float minHeight = 1f; [SerializeField] private float maxHeight = 8f; [SerializeField] [Min(1f)] private int stackedSegmentCount = 20; [SerializeField] private float width = 0.035f; [SerializeField] [Range(3f, 32f)] private int segmentResolution = 6; [SerializeField] private float targetAngleMin = 0f; [SerializeField] private float targetAngleMax = 30f; [Header("Branches")] [SerializeField] [Min(0f)] private int branchCount = 33; [SerializeField] private float branchLengthMultiplier = 1f; [SerializeField] private float branchWidthMultiplier = 1f; [SerializeField] private float branchAlphaMultiplier = 1f; [SerializeField] [Range(0f, 1f)] private float branchVisibilityLead = 0.25f; [SerializeField] [Range(0f, 1f)] private float branchContinuationChance = 0.886f; [SerializeField] [Min(0f)] private int branchContinuationDepth = 4; [SerializeField] [Range(0.1f, 1f)] private float branchContinuationScale = 1f; [SerializeField] private float branchAngleMin = 25f; [SerializeField] private float branchAngleMax = 70f; [SerializeField] [Range(0f, 6f)] private int branchGenerations = 6; private readonly RaycastHit[] groundHits = (RaycastHit[])(object)new RaycastHit[16]; private readonly List bolts = new List(); private readonly List activeBoltSlots = new List(); private readonly List gearExclusionColliders = new List(); private float latestVisibilityProgress; private int latestRustLightningSeed; private int generationVersion; private bool hasRustLightningSeed; private bool hasSpawnPoints; private bool generatedThisRound; private bool generationInProgress; private bool meshVisibilityEnabled; private bool weatherFlowActive; private void Awake() { managers.Add(this); } private void OnEnable() { meshVisibilityEnabled = temporarySkyVisible; StartWeatherFlow(); } private void Update() { if (!weatherFlowActive) { StartWeatherFlow(); } } private void StartWeatherFlow() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (!weatherFlowActive && Utility.ShouldRunWeatherLifecycle()) { BindToCamera(); weatherFlowActive = true; ((UnityEvent)StartOfRound.Instance.CameraSwitchEvent).AddListener(new UnityAction(BindToCamera)); TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Server); TemporalInstabilityAPI.RegisterRustLightning(this); ShowBolts(); BuildLightning(force: false); } } private void OnDisable() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown meshVisibilityEnabled = false; CleanupGeneratedLightning(); if (weatherFlowActive) { weatherFlowActive = false; StartOfRound instance = StartOfRound.Instance; if (instance != null) { ((UnityEvent)instance.CameraSwitchEvent).RemoveListener(new UnityAction(BindToCamera)); } TemporalInstabilityAPI.Unregister(this); TemporalInstabilityAPI.UnregisterRustLightning(this); } } private void OnDestroy() { generationVersion++; managers.Remove(this); } private void BindToCamera() { Transform val = Utility.LocalViewTransform(); if ((Object)(object)positionConstraint != (Object)null && (Object)(object)val != (Object)null) { Utility.BindPositionConstraint(positionConstraint, val); } } public void SetTemporalInstabilityLevel(float temporalInstabilityLevel) { float startLevel = Mathf.Min(minInstability, maxInstability); float fullLevel = Mathf.Max(minInstability, maxInstability); latestVisibilityProgress = Utility.InstabilityProgress(temporalInstabilityLevel, startLevel, fullLevel); ShowBolts(); } public void SetRustLightningSeed(int rustLightningSeed) { if (rustLightningSeed <= 0) { hasRustLightningSeed = false; latestRustLightningSeed = 0; return; } bool force = latestRustLightningSeed != rustLightningSeed; latestRustLightningSeed = rustLightningSeed; hasRustLightningSeed = true; if (((Behaviour)this).isActiveAndEnabled) { BuildLightning(force); } } internal static void SetTemporarySkyVisible(bool visible) { temporarySkyVisible = visible; foreach (RustLightningManager manager in managers) { if (!((Object)(object)manager == (Object)null)) { manager.meshVisibilityEnabled = visible; manager.ShowBolts(); } } } private void CleanupGeneratedLightning() { generationVersion++; generationInProgress = false; generatedThisRound = false; hasSpawnPoints = false; hasRustLightningSeed = false; latestRustLightningSeed = 0; for (int i = 0; i < activeBoltSlots.Count; i++) { activeBoltSlots[i] = false; } for (int j = 0; j < bolts.Count; j++) { bolts[j].ClearGeneratedData(); ((Component)bolts[j]).gameObject.SetActive(false); } } private void BuildLightning(bool force) { if (hasRustLightningSeed && latestRustLightningSeed > 0 && !((Object)(object)boltPrefab == (Object)null) && (!generationInProgress || force) && (!generatedThisRound || force)) { GenerateLightningAsync(latestRustLightningSeed); } } private async void GenerateLightningAsync(int rustLightningSeed) { int version = ++generationVersion; generationInProgress = true; generatedThisRound = true; hasSpawnPoints = false; for (int i = 0; i < bolts.Count; i++) { bolts[i].SetMeshVisible(visible: false); } int activeBoltCount = Mathf.Max(0, boltCount); PlayerControllerB player = Utility.LocalPlayer(); if ((Object)(object)player == (Object)null || activeBoltCount == 0) { for (int j = 0; j < bolts.Count; j++) { bolts[j].SetControlledProgress(0f); bolts[j].SetMeshVisible(visible: false); } generationInProgress = false; return; } while (bolts.Count < activeBoltCount) { RustLightningBolt bolt = Object.Instantiate(boltPrefab, ((Component)this).transform); ((Object)((Component)bolt).gameObject).name = string.Format("{0}.OuterOrbitLightning.{1}", "TemporalStormWeather", bolts.Count); ((Object)((Component)bolt).gameObject).hideFlags = (HideFlags)0; ((Component)bolt).gameObject.SetActive(false); bolts.Add(bolt); activeBoltSlots.Add(item: false); } gearExclusionColliders.Clear(); SkyGearManager.RebuildActiveLightningBlockers(gearExclusionColliders); RustLightningExclusionBox[] exclusionBoxes = new RustLightningExclusionBox[gearExclusionColliders.Count]; for (int k = 0; k < gearExclusionColliders.Count; k++) { exclusionBoxes[k] = RustLightningExclusionBox.FromCollider(gearExclusionColliders[k]); } float effectiveMinDistance = Mathf.Max(0f, Mathf.Min(minDistance, maxDistance)); float effectiveMaxDistance = Mathf.Max(effectiveMinDistance, Mathf.Max(minDistance, maxDistance)); Vector3 center = ((Component)player).transform.position; Random random = new Random(rustLightningSeed); float startingAngle = Utility.RandomRange(random, 0f, 360f); float angleStep = 360f / (float)activeBoltCount; BoltPlacementInput[] generationInputs = new BoltPlacementInput[activeBoltCount]; BoltPlacementResult[] results = new BoltPlacementResult[activeBoltCount]; for (int l = 0; l < activeBoltCount; l++) { float baseAngleDegrees = startingAngle + angleStep * (float)l; float angle = (baseAngleDegrees + Utility.RandomRange(random, 0f - orbitJitterDegrees, orbitJitterDegrees)) * (MathF.PI / 180f); double minSquared = effectiveMinDistance * effectiveMinDistance; double maxSquared = effectiveMaxDistance * effectiveMaxDistance; float distance = Mathf.Sqrt((float)(minSquared + random.NextDouble() * (maxSquared - minSquared))); Vector3 strikePosition = center + new Vector3(Mathf.Cos(angle) * distance, 0f, Mathf.Sin(angle) * distance); Vector3 origin = strikePosition + Vector3.up * Mathf.Max(0f, groundSearchHeight); float rayDistance = Mathf.Max(0f, groundSearchHeight) + Mathf.Max(0f, groundSearchDepth); if ((Object)(object)StartOfRound.Instance != (Object)null) { int hitCount = Physics.RaycastNonAlloc(origin, Vector3.down, groundHits, rayDistance, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); if (hitCount > 0) { int closestIndex = 0; float closestDistance = ((RaycastHit)(ref groundHits[0])).distance; for (int hitIndex = 1; hitIndex < hitCount && hitIndex < groundHits.Length; hitIndex++) { if (!(((RaycastHit)(ref groundHits[hitIndex])).distance >= closestDistance)) { closestIndex = hitIndex; closestDistance = ((RaycastHit)(ref groundHits[hitIndex])).distance; } } strikePosition = ((RaycastHit)(ref groundHits[closestIndex])).point; } else { strikePosition.y = missingGroundY; } } else { strikePosition.y = missingGroundY; } float distanceProgress = Mathf.InverseLerp(effectiveMinDistance, effectiveMaxDistance, distance); float heightScale = Mathf.Lerp(nearHeightMultiplier, farHeightMultiplier, distanceProgress); float widthScale = Mathf.Lerp(nearWidthMultiplier, farWidthMultiplier, distanceProgress); int boltSeed = random.Next(1, int.MaxValue); Vector3 boltPosition = strikePosition; RustLightningBoltSettings boltSettings = new RustLightningBoltSettings { LightningMaterial = lightningMaterial, BaseColor = baseColor, EmissionColor = emissionColor, EmissionIntensity = emissionIntensity, EdgeSoftness = edgeSoftness, MinHeight = minHeight * heightScale, MaxHeight = maxHeight * heightScale, StackedSegmentCount = stackedSegmentCount, Width = width * widthScale, SegmentResolution = segmentResolution, TargetAngleMin = targetAngleMin, TargetAngleMax = targetAngleMax, BranchCount = branchCount, BranchLengthMultiplier = branchLengthMultiplier, BranchWidthMultiplier = branchWidthMultiplier, BranchAlphaMultiplier = branchAlphaMultiplier, BranchVisibilityLead = branchVisibilityLead, BranchContinuationChance = branchContinuationChance, BranchContinuationDepth = branchContinuationDepth, BranchContinuationScale = branchContinuationScale, BranchAngleMin = branchAngleMin, BranchAngleMax = branchAngleMax, BranchGenerations = branchGenerations, Alpha = alpha }; generationInputs[l] = new BoltPlacementInput { Seed = boltSeed, Position = boltPosition, Settings = boltSettings }; } await Task.Run(delegate { Parallel.For(0, generationInputs.Length, delegate(int num) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) BoltPlacementInput boltPlacementInput = generationInputs[num]; results[num] = new BoltPlacementResult { Position = boltPlacementInput.Position, Settings = boltPlacementInput.Settings, GeneratedData = RustLightningBolt.GenerateData(boltPlacementInput.Seed, boltPlacementInput.Settings, boltPlacementInput.Position, exclusionBoxes) }; }); }); if (!((Object)(object)this == (Object)null) && version == generationVersion) { for (int i2 = 0; i2 < activeBoltCount; i2++) { RustLightningBolt bolt2 = bolts[i2]; BoltPlacementResult result = results[i2]; activeBoltSlots[i2] = true; ((Component)bolt2).gameObject.SetActive(true); bolt2.ApplyGeneratedData(result.Position, result.Settings, result.GeneratedData); } for (int i3 = activeBoltCount; i3 < bolts.Count; i3++) { activeBoltSlots[i3] = false; bolts[i3].SetControlledProgress(0f); bolts[i3].SetMeshVisible(visible: false); } generationInProgress = false; hasSpawnPoints = true; ShowBolts(); } } private void ShowBolts() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (!hasSpawnPoints) { return; } int num = Mathf.Min(Mathf.Max(0, boltCount), bolts.Count); for (int i = 0; i < num; i++) { RustLightningBolt rustLightningBolt = bolts[i]; if ((Object)(object)rustLightningBolt == (Object)null) { continue; } if (!activeBoltSlots[i] || latestVisibilityProgress <= 0f) { rustLightningBolt.SetControlledProgress(0f); rustLightningBolt.SetMeshVisible(visible: false); continue; } if (!((Component)rustLightningBolt).gameObject.activeSelf) { ((Component)rustLightningBolt).gameObject.SetActive(true); } rustLightningBolt.UpdateMaterialSettings(baseColor, emissionColor, emissionIntensity, edgeSoftness, alpha); rustLightningBolt.SetControlledProgress(latestVisibilityProgress); rustLightningBolt.SetMeshVisible(meshVisibilityEnabled); } } } } namespace TemporalStormWeather.TemporalStormManagers.Helpers { internal enum TemporalStormAmbienceCategory { Inside, Outside, Ship } internal static class TemporalStormAmbience { private static TemporalStormAmbienceLibrary? temporalStormLevelAmbience; private static bool triedLoadingTemporalStormAmbience; private static bool loggedMissingTemporalStormAmbience; public static AudioClip?[] GetAudioClips() { LoadTemporalStormAmbience(); AudioClip[] array = Array.ConvertAll(GetClips(TemporalStormAmbienceCategory.Inside), (RandomAudioClip clip) => clip.audioClip); AudioClip[] array2 = Array.ConvertAll(GetClips(TemporalStormAmbienceCategory.Ship), (RandomAudioClip clip) => clip.audioClip); AudioClip[] array3 = Array.ConvertAll(GetClips(TemporalStormAmbienceCategory.Outside), (RandomAudioClip clip) => clip.audioClip); int num = 0; AudioClip[] array4 = (AudioClip[])(object)new AudioClip[array.Length + array2.Length + array3.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(array); readOnlySpan.CopyTo(new Span(array4).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; ReadOnlySpan readOnlySpan2 = new ReadOnlySpan(array2); readOnlySpan2.CopyTo(new Span(array4).Slice(num, readOnlySpan2.Length)); num += readOnlySpan2.Length; ReadOnlySpan readOnlySpan3 = new ReadOnlySpan(array3); readOnlySpan3.CopyTo(new Span(array4).Slice(num, readOnlySpan3.Length)); num += readOnlySpan3.Length; return array4; } public static bool TryPlayTemporalInstabilityAmbience(SoundManager soundManager, bool syncedForAllPlayers) { if (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { return false; } LoadTemporalStormAmbience(); if ((Object)(object)temporalStormLevelAmbience == (Object)null) { return false; } TemporalStormAmbienceCategory category = ((!soundManager.localPlayer.isInsideFactory) ? ((!soundManager.localPlayer.isInHangarShipRoom) ? TemporalStormAmbienceCategory.Outside : TemporalStormAmbienceCategory.Ship) : TemporalStormAmbienceCategory.Inside); RandomAudioClip[] clips = GetClips(category); if (!TryChooseClipIndex(clips, out var clipIndex)) { return false; } float volume = ((Random.Range(0f, 1f) < 0.4f) ? Random.Range(0.3f, 0.8f) : Random.Range(0.7f, 0.9f)); return syncedForAllPlayers ? TemporalInstabilityAPI.TrySendTemporalAmbience((int)category, clipIndex, volume) : PlayTemporalAmbienceLocal((int)category, clipIndex, volume); } public static bool PlayTemporalAmbienceLocal(int category, int clipIndex, float volume) { LoadTemporalStormAmbience(); if ((Object)(object)temporalStormLevelAmbience == (Object)null) { return false; } RandomAudioClip[] clips = GetClips((TemporalStormAmbienceCategory)category); if (clips == null || clipIndex < 0 || clipIndex >= clips.Length) { return false; } AudioClip audioClip = clips[clipIndex].audioClip; if ((Object)(object)audioClip == (Object)null) { return false; } SoundManager.Instance.PlaySoundAroundLocalPlayer(audioClip, volume); return true; } private static RandomAudioClip[] GetClips(TemporalStormAmbienceCategory category) { TemporalStormAmbienceLibrary temporalStormAmbienceLibrary = temporalStormLevelAmbience; if ((Object)(object)temporalStormAmbienceLibrary == (Object)null) { return Array.Empty(); } if (1 == 0) { } RandomAudioClip[] array = category switch { TemporalStormAmbienceCategory.Inside => temporalStormAmbienceLibrary.insideAmbienceTemporalInstability, TemporalStormAmbienceCategory.Ship => temporalStormAmbienceLibrary.shipAmbienceTemporalInstability, _ => temporalStormAmbienceLibrary.outsideAmbienceTemporalInstability, }; if (1 == 0) { } return array ?? Array.Empty(); } private static bool TryChooseClipIndex(RandomAudioClip[] clips, out int clipIndex) { clipIndex = -1; if (clips == null || clips.Length == 0) { return false; } int num = 0; for (int i = 0; i < clips.Length; i++) { num += Mathf.Max(0, clips[i].chance); } if (num <= 0) { return false; } int num2 = Random.Range(0, num); int num3 = 0; for (int j = 0; j < clips.Length; j++) { num3 += Mathf.Max(0, clips[j].chance); if (num2 < num3) { clipIndex = j; return true; } } return false; } private static void LoadTemporalStormAmbience() { if (!triedLoadingTemporalStormAmbience) { triedLoadingTemporalStormAmbience = true; temporalStormLevelAmbience = TemporalInstabilityManager.LoadTemporalStormAmbienceLibrary(); if ((Object)(object)temporalStormLevelAmbience == (Object)null && !loggedMissingTemporalStormAmbience) { loggedMissingTemporalStormAmbience = true; Log.Warn("Temporal Storm ambience library is missing"); } } } } } namespace TemporalStormWeather.Patches { [HarmonyPatch(typeof(EnemyAI))] internal static class EnemyAIPatches { private const float EnemyNoiseRange = 4f; [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix(EnemyAI __instance) { EntityGlitchManager.NotifyEnemySpawned(__instance); } [HarmonyPostfix] [HarmonyPatch("KillEnemy")] private static void KillEnemyPostfix(EnemyAI __instance) { if (__instance.isEnemyDead) { EntityGlitchManager.NotifyEnemyRemoved(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")] private static void MaskedStartPostfix(MaskedPlayerEnemy __instance) { EntityGlitchManager.NotifyEnemySpawned((EnemyAI?)(object)__instance); } [HarmonyPrefix] [HarmonyPatch("OnDestroy")] private static void OnDestroyPrefix(EnemyAI __instance) { EntityGlitchManager.NotifyEnemyRemoved(__instance); } [HarmonyPostfix] [HarmonyPatch("SetItemInElevatorNonPlayer")] private static void SetItemInElevatorNonPlayerPostfix(GrabbableObject gObject) { ItemEffect.SyncShipRoom(gObject); } [HarmonyPrefix] [HarmonyPatch(typeof(MouthDogAI), "OnCollideWithEnemy")] private static bool MouthDogCollideEnemyPrefix(EnemyAI? collidedEnemy) { return !(collidedEnemy is LocustEnemyBase); } [HarmonyPrefix] [HarmonyPatch(typeof(MouthDogAI), "DetectNoise")] private static bool MouthDogDetectNoisePrefix(Vector3 noisePosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !NoiseSitsOnEnemy(noisePosition, locustOnly: true); } [HarmonyPrefix] [HarmonyPatch(typeof(LocustEnemyBase), "DetectNoise")] private static bool LocustDetectNoisePrefix(Vector3 noisePosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !NoiseSitsOnEnemy(noisePosition, locustOnly: false); } private static bool NoiseSitsOnEnemy(Vector3 noisePosition, bool locustOnly) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RoundManager.Instance == (Object)null) { return false; } float num = 16f; for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { EnemyAI val = RoundManager.Instance.SpawnedEnemies[i]; if (val != null && !val.isEnemyDead && (!locustOnly || val is LocustEnemyBase)) { Vector3 val2 = ((Component)val).transform.position - noisePosition; if (((Vector3)(ref val2)).sqrMagnitude <= num) { return true; } } } return false; } } [HarmonyPatch(typeof(GameNetworkManager))] internal static class GameNetworkManagerPatches { [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix() { PlayerControllerBPatches.RememberFlashlightColours(); } } [HarmonyPatch(typeof(GrabbableObject))] internal static class GrabbableObjectPatches { [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix(GrabbableObject __instance) { if (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive()) { return; } CoroutineTools.NextFrame((MonoBehaviour)(object)__instance, (Action)delegate { GrabbableObject obj = __instance; if (obj != null && !obj.isInShipRoom) { ItemEffect.Attach(__instance, out ItemEffect _); } }); } [HarmonyPostfix] [HarmonyPatch("OnBroughtToShip")] private static void OnBroughtToShipPostfix(GrabbableObject __instance) { ItemEffect.SyncShipRoom(__instance); } [HarmonyPostfix] [HarmonyPatch("SetScrapValue")] private static void SetScrapValuePostfix(GrabbableObject __instance, int setValueTo) { ItemEffect itemEffect = default(ItemEffect); if (((Component)__instance).TryGetComponent(ref itemEffect)) { itemEffect.SyncOriginalScrapValue(setValueTo); } } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDManagerPatches { private class ScrapDisplayState { public string? CollectedHudName; public int BoxIndex; } [HarmonyPostfix] [HarmonyPatch("ChangeControlTipMultiple")] private static void ChangeControlTipMultiplePostfix(bool holdingItem, Item itemProperties, HUDManager __instance) { if (!holdingItem || (Object)(object)itemProperties == (Object)null) { return; } PlayerControllerB val = Utility.LocalPlayer(); if ((Object)(object)val == (Object)null) { return; } GrabbableObject val2 = val.currentlyHeldObjectServer; if ((Object)(object)val2 == (Object)null && val.ItemSlots != null && val.currentItemSlot >= 0 && val.currentItemSlot < val.ItemSlots.Length) { val2 = val.ItemSlots[val.currentItemSlot]; } ItemEffect itemEffect = default(ItemEffect); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.itemProperties != (Object)(object)itemProperties || !((Component)val2).TryGetComponent(ref itemEffect)) { return; } string currentHeldTooltipName = itemEffect.CurrentHeldTooltipName; for (int i = 0; i < __instance.controlTipLines.Length; i++) { TextMeshProUGUI val3 = __instance.controlTipLines[i]; if (!((Object)(object)val3 == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)val3).text) && ((TMP_Text)val3).text.Contains(itemProperties.itemName) && !((TMP_Text)val3).text.Contains(currentHeldTooltipName)) { ((TMP_Text)val3).text = ((TMP_Text)val3).text.Replace(itemProperties.itemName, currentHeldTooltipName); } } } [HarmonyPrefix] [HarmonyPatch("DisplayNewScrapFound")] private static void DisplayNewScrapFoundPrefix(HUDManager __instance, int ___nextBoxIndex, out ScrapDisplayState? __state) { __state = null; if (__instance.itemsToBeDisplayed.Count != 0) { GrabbableObject val = __instance.itemsToBeDisplayed[0]; ItemEffect itemEffect = default(ItemEffect); if (!((Object)(object)val == (Object)null) && ((Component)val).TryGetComponent(ref itemEffect)) { __state = new ScrapDisplayState { CollectedHudName = itemEffect.CurrentCollectedHudName, BoxIndex = ___nextBoxIndex }; } } } [HarmonyPostfix] [HarmonyPatch("DisplayNewScrapFound")] private static void DisplayNewScrapFoundPostfix(HUDManager __instance, ScrapDisplayState? __state) { if (__state != null && __state.BoxIndex >= 0 && __state.BoxIndex < __instance.ScrapItemBoxes.Length) { ScrapItemHUDDisplay val = __instance.ScrapItemBoxes[__state.BoxIndex]; ((TMP_Text)val.headerText).text = __state.CollectedHudName; } } } [HarmonyPatch(typeof(LungProp))] internal static class LungPropPatches { [HarmonyPrefix] [HarmonyPatch("EquipItem")] private static void CaptureDockedState(LungProp __instance, out bool __state) { __state = __instance.isLungDocked; } [HarmonyPostfix] [HarmonyPatch("EquipItem")] private static void AddInstabilityWhenApparatusIsRemoved(LungProp __instance, bool __state) { if (__state && !__instance.isLungDocked && ((NetworkBehaviour)__instance).IsServer) { TemporalInstabilityAPI.AddApparatusInstability(); } } } [HarmonyPatch(typeof(NetworkManager))] internal static class NetworkManagerPatches { [HarmonyPostfix] [HarmonyPatch("SetSingleton")] private static void RegisterTemporalInstabilityPrefab() { TemporalInstabilityManager.RegisterNetworkPrefab(); } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerBPatches { private static readonly Dictionary originalHelmetLightColours = new Dictionary(); internal static void RememberFlashlightColours() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) originalHelmetLightColours.Clear(); FlashlightItem[] array = Resources.FindObjectsOfTypeAll(); foreach (FlashlightItem val in array) { if ((Object)(object)val?.flashlightBulb != (Object)null) { originalHelmetLightColours[val.flashlightTypeID] = val.flashlightBulb.color; } } } [HarmonyPostfix] [HarmonyPatch("ChangeHelmetLight")] private static void ChangeHelmetLightPostfix(PlayerControllerB __instance, int lightNumber) { TintHelmetLight(__instance, lightNumber); } internal static void TintHelmetLight(PlayerControllerB player, int lightNumber, FlashlightItem? flashlight = null) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) Light val = player.allHelmetLights[lightNumber]; if (!originalHelmetLightColours.ContainsKey(lightNumber)) { originalHelmetLightColours[lightNumber] = val.color; } FlashlightItem val2 = flashlight; if ((Object)(object)val2 == (Object)null || val2.flashlightTypeID != lightNumber || !((GrabbableObject)val2).isBeingUsed) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; val2 = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null); } if ((Object)(object)val2 == (Object)null || val2.flashlightTypeID != lightNumber || !((GrabbableObject)val2).isBeingUsed) { GrabbableObject pocketedFlashlight = player.pocketedFlashlight; val2 = (FlashlightItem)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null); } if ((Object)(object)val2 != (Object)null && val2.flashlightTypeID == lightNumber && ((GrabbableObject)val2).isBeingUsed && ItemEffect.FlashlightLightColor(val2, out var color)) { val.color = color; } else { val.color = originalHelmetLightColours[lightNumber]; } } [HarmonyPostfix] [HarmonyPatch("SetSpectatedPlayerEffects")] private static void SyncSkyboxAfterSpectate() { SkyboxManager.SyncFarClipForLocalPlayer(); } [HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")] [HarmonyPostfix] private static void ShowNoTuningCylinderHover(PlayerControllerB __instance) { InteractTrigger hoveringOverTrigger = __instance.hoveringOverTrigger; if ((Object)(object)hoveringOverTrigger == (Object)null) { return; } ResonatorSurface componentInParent = ((Component)hoveringOverTrigger).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { Collider val = default(Collider); string disabledHoverTip; if ((Object)(object)hoveringOverTrigger == (Object)(object)((PlaceableObjectsSurface)componentInParent).triggerScript && (!((Component)hoveringOverTrigger).gameObject.activeInHierarchy || !((Component)hoveringOverTrigger).TryGetComponent(ref val) || !val.enabled)) { ((Behaviour)__instance.cursorIcon).enabled = false; ((TMP_Text)__instance.cursorTip).text = string.Empty; __instance.previousHoveringOverTrigger = hoveringOverTrigger; __instance.hoveringOverTrigger = null; } else if (componentInParent.TryGetDisabledHoverTip(__instance, hoveringOverTrigger, out disabledHoverTip)) { __instance.cursorIcon.sprite = hoveringOverTrigger.disabledHoverIcon; ((Behaviour)__instance.cursorIcon).enabled = (Object)(object)hoveringOverTrigger.disabledHoverIcon != (Object)null; ((TMP_Text)__instance.cursorTip).text = disabledHoverTip; } } } [HarmonyPostfix] [HarmonyPatch("SetItemInElevator")] private static void SyncShipItemEffect(GrabbableObject gObject) { ItemEffect.SyncShipRoom(gObject); } } [HarmonyPatch(typeof(FlashlightItem))] internal static class FlashlightItemPatches { [HarmonyPostfix] [HarmonyPatch("SwitchFlashlight")] private static void SwitchFlashlightPostfix(FlashlightItem __instance) { if ((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null) { PlayerControllerBPatches.TintHelmetLight(((GrabbableObject)__instance).playerHeldBy, __instance.flashlightTypeID, __instance); } } } [HarmonyPatch(typeof(SoundManager))] internal static class SoundManagerPatches { [HarmonyPrefix] [HarmonyPatch("PlayAmbientSound")] private static bool PlayTemporalInstabilityAmbience(SoundManager __instance, bool syncedForAllPlayers) { return !TemporalStormAmbience.TryPlayTemporalInstabilityAmbience(__instance, syncedForAllPlayers); } [HarmonyPrefix] [HarmonyPatch("PlayRandomOutsideMusic")] [HarmonyPatch("SetOutsideMusicValues")] private static bool StopVanillaOutsideMusic() { if (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { return true; } if (SoundManager.Instance.musicSource.isPlaying) { AudioTools.Stop(SoundManager.Instance.musicSource, false); } if (TimeOfDay.Instance.TimeOfDayMusic.isPlaying) { AudioTools.Stop(TimeOfDay.Instance.TimeOfDayMusic, false); } return false; } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatches { [HarmonyPostfix] [HarmonyPatch("Start")] private static void StartPostfix() { if (NetworkUtils.IsServer()) { TemporalInstabilityManager.SpawnServerNetworkObject(); } } [HarmonyPostfix] [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyPatch("ShipHasLeft")] private static void LoadShipGrabbableItemsShipHasLeftPostfix() { ItemEffect.SyncAllShipRoomItems(); } [HarmonyPostfix] [HarmonyPatch("EndOfGameClientRpc")] [HarmonyPatch("OnDestroy")] [HarmonyPatch("OnLocalDisconnect")] private static void Postfix4Cleanup() { TemporalGearRagdoll.Clear(); } } [HarmonyPatch(typeof(TimeOfDay))] internal static class TimeOfDayPatches { [HarmonyPrefix] [HarmonyPatch("PlayTimeMusicDelayed")] [HarmonyPatch("playSoundDelayed")] private static bool StopVanillaTimeMusic() { if (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { return true; } if (SoundManager.Instance.musicSource.isPlaying) { AudioTools.Stop(SoundManager.Instance.musicSource, false); } if (TimeOfDay.Instance.TimeOfDayMusic.isPlaying) { AudioTools.Stop(TimeOfDay.Instance.TimeOfDayMusic, false); } return false; } } } namespace TemporalStormWeather.Items { internal enum TemporalStormItemMode { None, Rustic, Temporal } internal class ItemEffect : MonoBehaviour, ITemporalInstability { private class TrackedRenderer { public Renderer Renderer = null; public Material[] OriginalMaterials = null; public Material[]? RustMaterials; public Material[]? TemporalMaterials; public TemporalStormItemMode ShownMaterialMode = (TemporalStormItemMode)(-1); public float ShownRustAmount = -1f; public float ShownTemporalAmount = -1f; public float ShownTemporalGlowStrength = -1f; public float ShownVisualActive = -1f; } private class TrackedLight { public Light Light = null; public Color OriginalColor; } [CompilerGenerated] private sealed class d__72 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public int version; public bool[][] effectMaterialSlots; public ItemEffect <>4__this; private int 5__1; private TrackedRenderer 5__2; private Awaiter <>u__1; private void MoveNext() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_01ad: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { UniTask val4; Awaiter val3; Awaiter val2; Awaiter val; TrackedRenderer trackedRenderer; switch (num) { default: val4 = UniTask.NextFrame(); val3 = ((UniTask)(ref val4)).GetAwaiter(); if (!((Awaiter)(ref val3)).IsCompleted) { num = (<>1__state = 0); <>u__1 = val3; d__72 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__72>(ref val3, ref d__); return; } goto IL_0082; case 0: val3 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_0082; case 1: val2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_01e6; case 2: { val = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_02dc; } IL_01e6: ((Awaiter)(ref val2)).GetResult(); if ((Object)(object)<>4__this == (Object)null || (Object)(object)<>4__this.Grabbable == (Object)null || version != <>4__this.materialCreationVersion) { break; } trackedRenderer = 5__2; if (trackedRenderer.TemporalMaterials == null) { trackedRenderer.TemporalMaterials = <>4__this.NewMaterials(5__2.OriginalMaterials, <>4__this.settings.TemporalItemMaterial, TemporalStormItemMode.Temporal, effectMaterialSlots[5__1]); } val4 = UniTask.NextFrame(); val = ((UniTask)(ref val4)).GetAwaiter(); if (!((Awaiter)(ref val)).IsCompleted) { num = (<>1__state = 2); <>u__1 = val; d__72 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__72>(ref val, ref d__); return; } goto IL_02dc; IL_0082: ((Awaiter)(ref val3)).GetResult(); if ((Object)(object)<>4__this == (Object)null || (Object)(object)<>4__this.Grabbable == (Object)null || version != <>4__this.materialCreationVersion) { break; } 5__1 = 0; goto IL_02fe; IL_02fe: if (5__1 >= <>4__this.trackedRenderers.Count || 5__1 >= effectMaterialSlots.Length || (Object)(object)<>4__this == (Object)null || (Object)(object)<>4__this.Grabbable == (Object)null || version != <>4__this.materialCreationVersion) { break; } 5__2 = <>4__this.trackedRenderers[5__1]; trackedRenderer = 5__2; if (trackedRenderer.RustMaterials == null) { trackedRenderer.RustMaterials = <>4__this.NewMaterials(5__2.OriginalMaterials, <>4__this.settings.RusticItemMaterial, TemporalStormItemMode.Rustic, effectMaterialSlots[5__1]); } val4 = UniTask.NextFrame(); val2 = ((UniTask)(ref val4)).GetAwaiter(); if (!((Awaiter)(ref val2)).IsCompleted) { num = (<>1__state = 1); <>u__1 = val2; d__72 d__ = this; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompletedd__72>(ref val2, ref d__); return; } goto IL_01e6; IL_02dc: ((Awaiter)(ref val)).GetResult(); 5__2 = null; 5__1++; goto IL_02fe; } } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } private static readonly Dictionary itemEffectsByNetworkObjectId = new Dictionary(); private static readonly Dictionary preRoundPickupBlockCounts = new Dictionary(); private static readonly Dictionary originalPreRoundPickupValues = new Dictionary(); private static readonly int OriginalTexturePropertyId = Shader.PropertyToID("_BaseColorMap"); private static readonly int OriginalColorPropertyId = Shader.PropertyToID("_BaseColor"); private static readonly int OriginalAlphaClipThresholdPropertyId = Shader.PropertyToID("_AlphaCutoff"); private static readonly int OriginalNormalTexturePropertyId = Shader.PropertyToID("_NormalMap"); private static readonly int OriginalNormalScalePropertyId = Shader.PropertyToID("_NormalScale"); private static readonly int OriginalSmoothnessPropertyId = Shader.PropertyToID("_Smoothness"); private static readonly int OriginalMetallicPropertyId = Shader.PropertyToID("_Metallic"); private static readonly int BaseTexturePropertyId = Shader.PropertyToID("_BaseTexture"); private static readonly int BaseColorTintPropertyId = Shader.PropertyToID("_BaseColorTint"); private static readonly int AlphaClipThresholdPropertyId = Shader.PropertyToID("_AlphaCutoff"); private static readonly int NormalTexturePropertyId = Shader.PropertyToID("_NormalMap"); private static readonly int NormalScalePropertyId = Shader.PropertyToID("_NormalScale"); private static readonly int SmoothnessPropertyId = Shader.PropertyToID("_Smoothness"); private static readonly int MetallicPropertyId = Shader.PropertyToID("_Metallic"); private static readonly int RustAmountPropertyId = Shader.PropertyToID("_TemporalRustAmount"); private static readonly int RustColorPropertyId = Shader.PropertyToID("_TemporalRustColor"); private static readonly int TemporalGlowStrengthPropertyId = Shader.PropertyToID("_TemporalGlowStrength"); private static readonly int TemporalGlowColorPropertyId = Shader.PropertyToID("_TemporalGlowColor"); private static readonly int VisualActivePropertyId = Shader.PropertyToID("_TemporalItemVisualActive"); private static readonly int ItemSeedPropertyId = Shader.PropertyToID("_TemporalItemSeed"); private static readonly OriginalMaterialPropertyIds OriginalMaterialIds = new OriginalMaterialPropertyIds(OriginalTexturePropertyId, OriginalColorPropertyId, OriginalAlphaClipThresholdPropertyId, OriginalNormalTexturePropertyId, OriginalNormalScalePropertyId, OriginalSmoothnessPropertyId, OriginalMetallicPropertyId); private static readonly EffectMaterialPropertyIds EffectMaterialIds = new EffectMaterialPropertyIds(BaseTexturePropertyId, BaseColorTintPropertyId, AlphaClipThresholdPropertyId, NormalTexturePropertyId, NormalScalePropertyId, SmoothnessPropertyId, MetallicPropertyId); private readonly List trackedRenderers = new List(); private readonly List trackedLights = new List(); private ItemEffectManager settings = null; private ScanNodeProperties scanNodeProperties = null; private AudioSource? itemAudioSource; private Coroutine? temporalVibrationCoroutine; private TemporalStormItemMode itemMode; private float latestTemporalInstabilityLevel; private float itemInstabilityBuildupLevel; private float itemVisualProgress; private int originalScrapValue; private string originalHeaderText = string.Empty; private string originalCustomGrabTooltip = string.Empty; private uint itemSeed; private bool itemFlowActive; private bool itemPausedInShip; private uint temporalRollsConsumed; private int materialCreationVersion; private bool preRoundPickupBlocked; internal GrabbableObject Grabbable { get; private set; } = null; internal bool IncludeNonConductive { get; private set; } internal bool DawnReady => (Object)(object)Grabbable != (Object)null && (Object)(object)scanNodeProperties != (Object)null; internal string CurrentHeldTooltipName => PrefixedText(Grabbable.itemProperties.itemName, (itemMode == TemporalStormItemMode.Temporal) ? settings.TemporalPrefix : ((itemMode == TemporalStormItemMode.Rustic) ? settings.RusticPrefix : string.Empty)); internal string CurrentCollectedHudName => CurrentHeldTooltipName + " collected!"; private static string PrefixedText(string text, string prefix) { return string.IsNullOrWhiteSpace(text) ? prefix.Trim() : (prefix + text); } internal static bool SyncShipRoom(GrabbableObject item) { ItemEffect itemEffect = default(ItemEffect); return (Object)(object)item != (Object)null && ((Component)item).TryGetComponent(ref itemEffect) && itemEffect.SyncShipRoom(); } internal static bool FlashlightLightColor(FlashlightItem flashlight, out Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) color = default(Color); ItemEffect itemEffect = default(ItemEffect); if ((Object)(object)flashlight == (Object)null || !((Component)flashlight).TryGetComponent(ref itemEffect) || itemEffect.itemMode != TemporalStormItemMode.Temporal) { return false; } color = itemEffect.settings.TemporalGlowColor; return true; } internal static void SyncAllShipRoomItems() { foreach (ItemEffect value in itemEffectsByNetworkObjectId.Values) { value.SyncShipRoom(); } } internal static bool Attach(GrabbableObject item, out ItemEffect? itemEffect, bool includeNonConductive = false) { itemEffect = null; ItemEffectManager current = ItemEffectManager.Current; if ((Object)(object)current == (Object)null) { return false; } if ((Object)(object)((Component)item).GetComponentInChildren(true) == (Object)null) { return false; } if (!CanAttach(item, includeNonConductive)) { return false; } if (!((Component)item).TryGetComponent(ref itemEffect)) { itemEffect = ((Component)item).gameObject.AddComponent(); itemEffect.Initialise(item, current, includeNonConductive); } else if (includeNonConductive) { itemEffect.IncludeNonConductive = true; } return itemEffect?.DawnReady ?? false; } private static bool CanAttach(GrabbableObject item, bool includeNonConductive) { return (Object)(object)item.itemProperties != (Object)null && (Object)(object)((Component)item).GetComponent() == (Object)null && (item.itemProperties.isConductiveMetal || includeNonConductive); } private void OnDestroy() { if (itemFlowActive) { TemporalInstabilityAPI.Unregister(this); } if ((Object)(object)Grabbable == (Object)null) { return; } ReleasePreRoundPickupBlock(); ulong networkObjectId = ((NetworkBehaviour)Grabbable).NetworkObject.NetworkObjectId; if (itemEffectsByNetworkObjectId.TryGetValue(networkObjectId, out ItemEffect value) && (Object)(object)value == (Object)(object)this) { itemEffectsByNetworkObjectId.Remove(networkObjectId); } CoroutineTools.Stop((MonoBehaviour)(object)this, ref temporalVibrationCoroutine); materialCreationVersion++; for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; if ((Object)(object)trackedRenderer.Renderer != (Object)null) { trackedRenderer.Renderer.sharedMaterials = trackedRenderer.OriginalMaterials; } MaterialUtils.DestroyMaterials(trackedRenderer.RustMaterials, trackedRenderer.OriginalMaterials); MaterialUtils.DestroyMaterials(trackedRenderer.TemporalMaterials, trackedRenderer.OriginalMaterials); } trackedRenderers.Clear(); RestoreOriginalLightColors(); trackedLights.Clear(); } internal void Initialise(GrabbableObject grabbableObject, ItemEffectManager itemEffectSettings, bool allowNonConductive = false) { //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) settings = itemEffectSettings; Grabbable = grabbableObject; IncludeNonConductive = allowNonConductive; scanNodeProperties = ((Component)Grabbable).GetComponentInChildren(true); itemAudioSource = ((Component)Grabbable).GetComponent(); originalScrapValue = Grabbable.scrapValue; originalHeaderText = scanNodeProperties.headerText; originalCustomGrabTooltip = Grabbable.customGrabTooltip; itemSeed = ItemUtils.BuildItemSeed(Grabbable); itemPausedInShip = Grabbable.isInShipRoom; if (itemPausedInShip && (Object)(object)Grabbable.radarIcon != (Object)null) { Object.Destroy((Object)(object)((Component)Grabbable.radarIcon).gameObject); Grabbable.radarIcon = null; } itemEffectsByNetworkObjectId[((NetworkBehaviour)Grabbable).NetworkObject.NetworkObjectId] = this; Renderer[] componentsInChildren = ((Component)Grabbable).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((val is MeshRenderer || val is SkinnedMeshRenderer) && !IsScanNodeRenderer(val)) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials.Length != 0) { trackedRenderers.Add(new TrackedRenderer { Renderer = val, OriginalMaterials = sharedMaterials }); } } } Light[] componentsInChildren2 = ((Component)Grabbable).GetComponentsInChildren(true); foreach (Light val2 in componentsInChildren2) { trackedLights.Add(new TrackedLight { Light = val2, OriginalColor = val2.color }); } SetVisualActive(!itemPausedInShip); itemMode = TemporalStormItemMode.None; itemInstabilityBuildupLevel = 0f; itemVisualProgress = 0f; temporalRollsConsumed = 0u; SwapMaterials(TemporalStormItemMode.None); SetScrapValue(originalScrapValue); RestoreOriginalLightColors(); WriteScanText(); BuildMaterials(); itemFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Server); } public void SetTemporalInstabilityLevel(float value) { latestTemporalInstabilityLevel = Utility.ClampInstability(value); if (itemFlowActive && !itemPausedInShip) { FeedInstability(latestTemporalInstabilityLevel); } } internal bool WriteDawnSaveEntry(out TemporalStormSavedItem savedItem) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) savedItem = null; if (!DawnReady || !DawnConfigUtils.CanUseDawnItem(Grabbable, IncludeNonConductive, DawnItemPersistenceMode.PersistShip) || (itemMode != TemporalStormItemMode.Temporal && (itemMode != TemporalStormItemMode.Rustic || itemInstabilityBuildupLevel < settings.RustStartInstability))) { return false; } savedItem = new TemporalStormSavedItem { ItemNamespacedKey = ((object)FindItems.DawnKey(Grabbable)).ToString(), ItemName = Grabbable.itemProperties.itemName, Position = ((Component)Grabbable).transform.position, ItemSeed = itemSeed, ScrapValue = Grabbable.scrapValue, RusticLevel = itemInstabilityBuildupLevel, VisualAmount = itemVisualProgress, State = (int)itemMode, TemporalRollsConsumed = temporalRollsConsumed, IncludeNonConductive = IncludeNonConductive }; return true; } internal void ReadDawnSaveEntry(TemporalStormSavedItem savedItem) { itemSeed = savedItem.ItemSeed; itemInstabilityBuildupLevel = Utility.ClampInstability(savedItem.RusticLevel); TemporalStormItemMode temporalStormItemMode = (itemMode = (TemporalStormItemMode)savedItem.State); UpdatePreRoundPickupBlock(); temporalRollsConsumed = ((itemMode == TemporalStormItemMode.Temporal) ? settings.GetAllTemporalRollsConsumedMask() : savedItem.TemporalRollsConsumed); itemVisualProgress = Mathf.Clamp01(savedItem.VisualAmount); float value = ShaderSeed(); for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; MaterialUtils.SetFloatOnCreatedMaterials(trackedRenderer.RustMaterials, trackedRenderer.OriginalMaterials, ItemSeedPropertyId, value); MaterialUtils.SetFloatOnCreatedMaterials(trackedRenderer.TemporalMaterials, trackedRenderer.OriginalMaterials, ItemSeedPropertyId, value); } SetScrapValue((temporalStormItemMode == TemporalStormItemMode.None) ? originalScrapValue : savedItem.ScrapValue); ShowSavedItem(); } private void BuildMaterials() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) materialCreationVersion++; bool[][] array = new bool[trackedRenderers.Count][]; for (int i = 0; i < trackedRenderers.Count; i++) { Material[] originalMaterials = trackedRenderers[i].OriginalMaterials; bool[] array2 = new bool[originalMaterials.Length]; for (int j = 0; j < originalMaterials.Length; j++) { Material val = originalMaterials[j]; int num = j; object obj; if (val == null) { obj = null; } else { Shader shader = val.shader; obj = ((shader != null) ? ((Object)shader).name : null); } array2[num] = (string?)obj == "HDRP/Lit"; } array[i] = array2; } int version = materialCreationVersion; UniTaskExtensions.Forget(BuildMaterialsAsync(version, array)); } [AsyncStateMachine(typeof(d__72))] [DebuggerStepThrough] private UniTask BuildMaterialsAsync(int version, bool[][] effectMaterialSlots) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) d__72 d__ = new d__72(); d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); d__.<>4__this = this; d__.version = version; d__.effectMaterialSlots = effectMaterialSlots; d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Start<d__72>(ref d__); return ((AsyncUniTaskMethodBuilder)(ref d__.<>t__builder)).Task; } private Material[] NewMaterials(Material[] originalMaterials, Material templateMaterial, TemporalStormItemMode itemMode, bool[]? effectMaterialSlots = null) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) Material[] array = (Material[])(object)new Material[originalMaterials.Length]; bool flag = effectMaterialSlots?.Length == originalMaterials.Length; for (int i = 0; i < originalMaterials.Length; i++) { Material val = originalMaterials[i]; if ((Object)(object)val == (Object)null) { array[i] = null; continue; } int num; if (!flag) { Shader shader = val.shader; num = ((((shader != null) ? ((Object)shader).name : null) == "HDRP/Lit") ? 1 : 0); } else { num = (effectMaterialSlots[i] ? 1 : 0); } if (num == 0) { array[i] = val; continue; } Material val2 = new Material(templateMaterial); MaterialUtils.CopyOriginalMaterialProperties(val, val2, OriginalMaterialIds, EffectMaterialIds, 0f); MaterialUtils.ForceOpaqueCutout(val2); val2.SetColor(RustColorPropertyId, settings.RustColor); val2.SetColor(TemporalGlowColorPropertyId, settings.TemporalGlowColor); val2.SetFloat(ItemSeedPropertyId, ShaderSeed()); val2.SetFloat(VisualActivePropertyId, VisualActiveFor(itemMode)); if (itemMode == TemporalStormItemMode.Temporal) { val2.SetFloat(TemporalGlowStrengthPropertyId, settings.TemporalGlowStrength); } else { val2.SetFloat(RustAmountPropertyId, 0f); } array[i] = val2; } return array; } private bool IsScanNodeRenderer(Renderer renderer) { int num = LayerMask.NameToLayer("ScanNode"); if (num < 0) { return false; } Transform val = ((Component)renderer).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)Grabbable).transform) { if (((Component)val).gameObject.layer == num) { return true; } val = val.parent; } return ((Component)renderer).gameObject.layer == num; } private Material[] RustMaterials(TrackedRenderer trackedRenderer) { if (trackedRenderer.RustMaterials == null) { trackedRenderer.RustMaterials = NewMaterials(trackedRenderer.OriginalMaterials, settings.RusticItemMaterial, TemporalStormItemMode.Rustic); } return trackedRenderer.RustMaterials; } private Material[] TemporalMaterials(TrackedRenderer trackedRenderer) { if (trackedRenderer.TemporalMaterials == null) { trackedRenderer.TemporalMaterials = NewMaterials(trackedRenderer.OriginalMaterials, settings.TemporalItemMaterial, TemporalStormItemMode.Temporal); } return trackedRenderer.TemporalMaterials; } private float ShaderSeed() { uint num = ItemUtils.Mix(itemSeed); return (float)(num & 0xFFFFF) / 1024f; } private float VisualActiveFor(TemporalStormItemMode itemMode) { return (itemMode == TemporalStormItemMode.Temporal || !itemPausedInShip) ? 1f : 0f; } private void FeedInstability(float instabilityLevel) { if (itemMode == TemporalStormItemMode.Temporal) { return; } float num = Mathf.Max(itemInstabilityBuildupLevel, Utility.ClampInstability(instabilityLevel)); if (num < settings.RustStartInstability) { SwapMaterials(TemporalStormItemMode.None); return; } if (itemMode == TemporalStormItemMode.None) { itemMode = TemporalStormItemMode.Rustic; UpdatePreRoundPickupBlock(); SetScrapValue(Mathf.RoundToInt((float)originalScrapValue * settings.RusticScrapValueMultiplier)); RestoreOriginalLightColors(); WriteScanText(); } if (Mathf.Approximately(num, itemInstabilityBuildupLevel)) { ShowRust(itemVisualProgress); return; } itemInstabilityBuildupLevel = num; itemVisualProgress = Mathf.Max(itemVisualProgress, settings.EvaluateVisualProgress(Utility.InstabilityProgress(itemInstabilityBuildupLevel, settings.RustStartInstability, settings.FullRustInstability))); int num2 = Mathf.Min(settings.TemporalRollCount, 32); for (int i = 0; i < num2; i++) { if ((temporalRollsConsumed & (uint)(1 << i)) == 0 && !(itemInstabilityBuildupLevel < settings.GetTemporalRollInstability(i))) { temporalRollsConsumed |= (uint)(1 << i); uint num3 = ItemUtils.Mix(itemSeed ^ 0xBADCAFE ^ (uint)(i * 1597334677)); float num4 = (float)(num3 & 0xFFFFFF) / 16777216f; if (num4 < settings.GetTemporalRollChance(i)) { MakeTemporal(); return; } } } ShowRust(itemVisualProgress); } internal bool ForceTemporal() { if (!DawnReady) { return false; } if (itemMode == TemporalStormItemMode.Temporal) { return true; } itemInstabilityBuildupLevel = settings.FullRustInstability; itemVisualProgress = Mathf.Lerp(0.3f, 1f, (float)(ItemUtils.Mix(itemSeed ^ 0xDCB1C81) & 0xFFFFFF) / 16777216f); temporalRollsConsumed = settings.GetAllTemporalRollsConsumedMask(); MakeTemporal(); return true; } internal bool ForceRustic() { if (!DawnReady) { return false; } itemMode = TemporalStormItemMode.Rustic; itemInstabilityBuildupLevel = settings.FullRustInstability; itemVisualProgress = settings.EvaluateVisualProgress(1f); temporalRollsConsumed = settings.GetAllTemporalRollsConsumedMask(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref temporalVibrationCoroutine); UpdatePreRoundPickupBlock(); SetScrapValue(Mathf.RoundToInt((float)originalScrapValue * settings.RusticScrapValueMultiplier)); RestoreOriginalLightColors(); WriteScanText(); SwapMaterials(TemporalStormItemMode.Rustic); ShowRust(itemVisualProgress); return true; } internal bool ForceTemporalForDebug() { if (!DawnReady) { ItemEffectManager current = ItemEffectManager.Current; GrabbableObject component = ((Component)this).GetComponent(); if ((Object)(object)current == (Object)null || (Object)(object)component == (Object)null) { return false; } Initialise(component, current); } return ForceTemporal(); } private void MakeTemporal() { itemMode = TemporalStormItemMode.Temporal; UpdatePreRoundPickupBlock(); SetScrapValue(Mathf.RoundToInt((float)originalScrapValue * settings.TemporalScrapValueMultiplier)); SwapMaterials(TemporalStormItemMode.Temporal); ShowTemporal(); SetTemporalLights(); WriteScanText(); if (temporalVibrationCoroutine == null && settings.TemporalVibrationSeconds > 0f && settings.TemporalVibrationDistance > 0f) { CoroutineTools.Start((MonoBehaviour)(object)this, ref temporalVibrationCoroutine, TemporalVibration()); } AudioTools.PlayOneShot(itemAudioSource, settings.TemporalStatusClip); } internal void SyncOriginalScrapValue(int value) { originalScrapValue = Mathf.Max(0, value); if (itemMode == TemporalStormItemMode.Temporal) { SetScrapValue(Mathf.RoundToInt((float)originalScrapValue * settings.TemporalScrapValueMultiplier)); } else if (itemMode == TemporalStormItemMode.Rustic) { SetScrapValue(Mathf.RoundToInt((float)originalScrapValue * settings.RusticScrapValueMultiplier)); } else { SetScrapValue(originalScrapValue); } } private void SetScrapValue(int value) { int num = Mathf.Max(0, value); Grabbable.scrapValue = num; scanNodeProperties.scrapValue = num; scanNodeProperties.subText = $"Value: ${num}"; } private void WriteScanText() { string prefix = ((itemMode == TemporalStormItemMode.Temporal) ? settings.TemporalPrefix : ((itemMode == TemporalStormItemMode.Rustic) ? settings.RusticPrefix : string.Empty)); scanNodeProperties.headerText = PrefixedText(originalHeaderText, prefix); Grabbable.customGrabTooltip = originalCustomGrabTooltip; } private void ShowSavedItem() { UpdatePreRoundPickupBlock(); if (itemMode == TemporalStormItemMode.Temporal) { SwapMaterials(TemporalStormItemMode.Temporal); ShowTemporal(); SetTemporalLights(); WriteScanText(); } else if (itemMode == TemporalStormItemMode.None) { SwapMaterials(TemporalStormItemMode.None); RestoreOriginalLightColors(); WriteScanText(); } else { SwapMaterials(TemporalStormItemMode.Rustic); ShowRust(itemVisualProgress); RestoreOriginalLightColors(); WriteScanText(); } } private void UpdatePreRoundPickupBlock() { if (itemMode == TemporalStormItemMode.Rustic || itemMode == TemporalStormItemMode.Temporal) { if (!preRoundPickupBlocked && !((Object)(object)Grabbable.itemProperties == (Object)null)) { Item itemProperties = Grabbable.itemProperties; if (!originalPreRoundPickupValues.ContainsKey(itemProperties)) { originalPreRoundPickupValues[itemProperties] = itemProperties.canBeGrabbedBeforeGameStart; } preRoundPickupBlockCounts.TryGetValue(itemProperties, out var value); preRoundPickupBlockCounts[itemProperties] = value + 1; itemProperties.canBeGrabbedBeforeGameStart = false; preRoundPickupBlocked = true; } } else { ReleasePreRoundPickupBlock(); } } private void ReleasePreRoundPickupBlock() { if (!preRoundPickupBlocked || (Object)(object)Grabbable.itemProperties == (Object)null) { preRoundPickupBlocked = false; return; } Item itemProperties = Grabbable.itemProperties; if (!preRoundPickupBlockCounts.TryGetValue(itemProperties, out var value)) { preRoundPickupBlocked = false; return; } value--; if (value > 0) { preRoundPickupBlockCounts[itemProperties] = value; preRoundPickupBlocked = false; return; } preRoundPickupBlockCounts.Remove(itemProperties); if (originalPreRoundPickupValues.TryGetValue(itemProperties, out var value2)) { itemProperties.canBeGrabbedBeforeGameStart = value2; originalPreRoundPickupValues.Remove(itemProperties); } preRoundPickupBlocked = false; } private void SwapMaterials(TemporalStormItemMode itemMode) { for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; if (trackedRenderer.ShownMaterialMode != itemMode) { Renderer renderer = trackedRenderer.Renderer; if (1 == 0) { } Material[] sharedMaterials = itemMode switch { TemporalStormItemMode.Rustic => RustMaterials(trackedRenderer), TemporalStormItemMode.Temporal => TemporalMaterials(trackedRenderer), TemporalStormItemMode.None => trackedRenderer.OriginalMaterials, _ => trackedRenderer.OriginalMaterials, }; if (1 == 0) { } renderer.sharedMaterials = sharedMaterials; trackedRenderer.ShownMaterialMode = itemMode; } } } private void ShowRust(float rustAmount) { for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; float num = VisualActiveFor(TemporalStormItemMode.Rustic); Material[] array = RustMaterials(trackedRenderer); if (trackedRenderer.ShownMaterialMode != TemporalStormItemMode.Rustic) { trackedRenderer.Renderer.sharedMaterials = array; trackedRenderer.ShownMaterialMode = TemporalStormItemMode.Rustic; } if (Mathf.Approximately(trackedRenderer.ShownRustAmount, rustAmount) && Mathf.Approximately(trackedRenderer.ShownVisualActive, num)) { continue; } for (int j = 0; j < array.Length; j++) { Material val = array[j]; if (MaterialUtils.IsCreatedEffectMaterial(val, trackedRenderer.OriginalMaterials, j)) { val.SetFloat(RustAmountPropertyId, rustAmount); val.SetFloat(VisualActivePropertyId, num); } } trackedRenderer.ShownRustAmount = rustAmount; trackedRenderer.ShownVisualActive = num; } } private void ShowTemporal() { float num = itemVisualProgress; float num2 = Mathf.Max(0f, settings.TemporalGlowStrength); for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; float num3 = VisualActiveFor(TemporalStormItemMode.Temporal); Material[] array = TemporalMaterials(trackedRenderer); if (trackedRenderer.ShownMaterialMode != TemporalStormItemMode.Temporal) { trackedRenderer.Renderer.sharedMaterials = array; trackedRenderer.ShownMaterialMode = TemporalStormItemMode.Temporal; } if (Mathf.Approximately(trackedRenderer.ShownTemporalAmount, num) && Mathf.Approximately(trackedRenderer.ShownTemporalGlowStrength, num2) && Mathf.Approximately(trackedRenderer.ShownVisualActive, num3)) { continue; } for (int j = 0; j < array.Length; j++) { Material val = array[j]; if (MaterialUtils.IsCreatedEffectMaterial(val, trackedRenderer.OriginalMaterials, j)) { val.SetFloat(RustAmountPropertyId, num); val.SetFloat(TemporalGlowStrengthPropertyId, num2); val.SetFloat(VisualActivePropertyId, num3); } } trackedRenderer.ShownTemporalAmount = num; trackedRenderer.ShownTemporalGlowStrength = num2; trackedRenderer.ShownVisualActive = num3; } } private void SetTemporalLights() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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) Color temporalGlowColor = settings.TemporalGlowColor; for (int i = 0; i < trackedLights.Count; i++) { trackedLights[i].Light.color = temporalGlowColor; } } private void RestoreOriginalLightColors() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < trackedLights.Count; i++) { TrackedLight trackedLight = trackedLights[i]; if ((Object)(object)trackedLight.Light != (Object)null) { trackedLight.Light.color = trackedLight.OriginalColor; } } } private void SetVisualActive(bool active) { float value = (active ? 1f : 0f); for (int i = 0; i < trackedRenderers.Count; i++) { TrackedRenderer trackedRenderer = trackedRenderers[i]; MaterialUtils.SetFloatOnCreatedMaterials(trackedRenderer.RustMaterials, trackedRenderer.OriginalMaterials, VisualActivePropertyId, value); MaterialUtils.SetFloatOnCreatedMaterials(trackedRenderer.TemporalMaterials, trackedRenderer.OriginalMaterials, VisualActivePropertyId, 1f); trackedRenderer.ShownVisualActive = -1f; } } private bool SyncShipRoom() { bool isInShipRoom = Grabbable.isInShipRoom; if (itemPausedInShip == isInShipRoom) { return false; } itemPausedInShip = isInShipRoom; if (isInShipRoom) { if ((Object)(object)Grabbable.radarIcon != (Object)null) { Object.Destroy((Object)(object)((Component)Grabbable.radarIcon).gameObject); Grabbable.radarIcon = null; } SetVisualActive(active: false); return true; } SetVisualActive(active: true); FeedInstability(latestTemporalInstabilityLevel); return true; } private IEnumerator TemporalVibration() { if (settings.TemporalVibrationSeconds <= 0f || settings.TemporalVibrationDistance <= 0f || (Object)(object)Grabbable == (Object)null) { temporalVibrationCoroutine = null; yield break; } Transform target = ((Component)Grabbable).transform; Vector3 baseLocalPosition = target.localPosition; float duration = Mathf.Max(0.01f, settings.TemporalVibrationSeconds); float elapsedSeconds = 0f; while (elapsedSeconds < duration) { elapsedSeconds += Time.deltaTime; float progress = Mathf.Clamp01(elapsedSeconds / duration); float envelope = Mathf.Sin(progress * MathF.PI); float distance = settings.TemporalVibrationDistance * envelope; float time = Time.time * settings.TemporalVibrationFrequency; target.localPosition = baseLocalPosition + new Vector3((Mathf.PerlinNoise(time, 0f) - 0.5f) * 2f, (Mathf.PerlinNoise(11.37f, time * 1.31f) - 0.5f) * 2f, (Mathf.PerlinNoise(time * 1.73f, 23.91f) - 0.5f) * 2f) * distance; yield return null; } target.localPosition = baseLocalPosition; temporalVibrationCoroutine = null; } } public class TemporalGearItem : GrabbableObject { private const float DrainTickSeconds = 0.2f; [Header("Temporal Drain")] [SerializeField] private bool requireTemporalStormWeatherForEffects = true; [SerializeField] private float instabilityDrainPerSecond = 3f; [SerializeField] [Range(0f, 1f)] private float fullSpinDrainThreshold = 0.98f; [SerializeField] [Min(0f)] private float fullSpinBreakSeconds = 3f; [SerializeField] [Min(0f)] private int fullSpinHealthDamage = 30; [Header("Gear Motion")] [SerializeField] private Transform gearSpinTransform = null; [SerializeField] private float maximumSpinDegreesPerSecond = 1440f; [SerializeField] [Min(0f)] private float spinAccelerationDegreesPerSecond = 900f; [SerializeField] [Min(0f)] private float spinDecelerationDegreesPerSecond = 2600f; [Header("Gear Particles")] [SerializeField] private ParticleSystem[] spinParticles = Array.Empty(); [SerializeField] [Min(0f)] private float minimumParticleRate = 0f; [SerializeField] [Min(0f)] private float maximumParticleRate = 70f; [Header("Gear Shader")] [SerializeField] private Renderer[] spinMaterialRenderers = Array.Empty(); [SerializeField] [Min(0f)] private float idleGlowStrength = 1f; [SerializeField] [Min(0f)] private float maximumGlowStrength = 4f; [SerializeField] [Range(0f, 1f)] private float minimumRustAmount = 0.1f; [SerializeField] [Range(0f, 1f)] private float maximumRustAmount = 1f; [SerializeField] private AnimationCurve spinVisualCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); [Header("Gear Audio")] [SerializeField] private AudioSource gearAudioSource = null; [SerializeField] private AudioClip gearWindUpClip = null; [SerializeField] [Range(0f, 1f)] private float minimumAudioVolume = 0f; [SerializeField] [Range(0f, 1f)] private float maximumAudioVolume = 1f; [SerializeField] [Min(0f)] private float minimumAudioPitch = 0.45f; [SerializeField] [Min(0f)] private float maximumAudioPitch = 2.4f; [SerializeField] private AudioDistortionFilter gearDistortionFilter = null; [SerializeField] [Range(0f, 1f)] private float minimumDistortionLevel = 0f; [SerializeField] [Range(0f, 1f)] private float maximumDistortionLevel = 0.7f; [SerializeField] private AudioHighPassFilter gearHighPassFilter = null; [SerializeField] [Min(10f)] private float minimumHighPassFrequency = 10f; [SerializeField] [Min(10f)] private float maximumHighPassFrequency = 1800f; [Header("Gear Break")] [SerializeField] private TemporalGearRagdoll gearRagdollPrefab = null; [Header("Text")] [SerializeField] private string idleTooltipText = "Stabilise"; [SerializeField] private string drainingTooltipText = "Stabilising"; [Header("Player Animator")] [SerializeField] private PlayerAnimatorControllerReplacement playerAnimator = new PlayerAnimatorControllerReplacement(); private Coroutine? drainCoroutine; private Coroutine? gearSpinCoroutine; private readonly PlayerAnimatorTools playerAnimatorTools = new PlayerAnimatorTools(); private MaterialPropertyBlock gearPropertyBlock = null; private float currentSpinDegreesPerSecond; private float fullSpinServerSeconds; private bool draining; private bool gearSpinActive; private bool gearBroken; private bool serverDraining; public override void Start() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown ((GrabbableObject)this).Start(); if (base.isInShipRoom && (Object)(object)base.radarIcon != (Object)null) { Object.Destroy((Object)(object)((Component)base.radarIcon).gameObject); base.radarIcon = null; } gearPropertyBlock = new MaterialPropertyBlock(); AudioTools.SwapClip(gearAudioSource, gearWindUpClip, false); gearAudioSource.loop = true; gearAudioSource.playOnAwake = false; } public override void SetControlTipsForItem() { if (ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this)) { UpdateTooltip(); ((GrabbableObject)this).SetControlTipsForItem(); } } public override void EquipItem() { ((GrabbableObject)this).EquipItem(); if ((Object)(object)base.playerHeldBy != (Object)null) { base.playerHeldBy.equippedUsableItemQE = true; playerAnimatorTools.ApplyHeld(base.playerHeldBy, playerAnimator); Animator playerBodyAnimator = base.playerHeldBy.playerBodyAnimator; if ((Object)(object)playerBodyAnimator != (Object)null && !string.IsNullOrWhiteSpace(base.itemProperties.useAnim) && playerBodyAnimator.GetBool(base.itemProperties.useAnim)) { playerBodyAnimator.SetBool(base.itemProperties.useAnim, false); } } if (ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this)) { ((GrabbableObject)this).SetControlTipsForItem(); } } public override void GrabItem() { if ((Object)(object)base.playerHeldBy != (Object)null) { playerAnimatorTools.ApplyHeld(base.playerHeldBy, playerAnimator); } ((GrabbableObject)this).GrabItem(); } public override void PocketItem() { StopDraining(); if ((Object)(object)base.playerHeldBy?.playerBodyAnimator != (Object)null && !string.IsNullOrWhiteSpace(base.itemProperties.useAnim)) { base.playerHeldBy.playerBodyAnimator.SetBool(base.itemProperties.useAnim, false); } ((GrabbableObject)this).PocketItem(); playerAnimatorTools.Restore(); } public override void DiscardItem() { StopDraining(); if ((Object)(object)base.playerHeldBy?.playerBodyAnimator != (Object)null && !string.IsNullOrWhiteSpace(base.itemProperties.useAnim)) { base.playerHeldBy.playerBodyAnimator.SetBool(base.itemProperties.useAnim, false); } ((GrabbableObject)this).DiscardItem(); playerAnimatorTools.Restore(); } public override void ItemActivate(bool used, bool buttonDown = true) { bool flag = used && buttonDown && !gearBroken; Animator playerBodyAnimator = base.playerHeldBy.playerBodyAnimator; if ((Object)(object)playerBodyAnimator != (Object)null && !string.IsNullOrWhiteSpace(base.itemProperties.useAnim) && playerBodyAnimator.GetBool(base.itemProperties.useAnim) != flag) { playerBodyAnimator.SetBool(base.itemProperties.useAnim, flag); } if (!ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this)) { return; } if (flag) { if (!draining) { draining = true; ShowDraining(active: true); SendServerDrain(active: true); ((GrabbableObject)this).SetControlTipsForItem(); } } else { StopDraining(); } } private void StopDraining() { if (draining) { draining = false; CoroutineTools.Stop((MonoBehaviour)(object)this, ref drainCoroutine); ShowDraining(active: false); SendServerDrain(active: false); if (ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this)) { ((GrabbableObject)this).SetControlTipsForItem(); } } } private void SendServerDrain(bool active) { if (((NetworkBehaviour)this).IsServer) { RunServerDrain(active); ShowDrainingRpc(active); } else { RequestDrainRpc(active); } } private void RunServerDrain(bool active) { if (active) { if (!serverDraining && !((Object)(object)base.playerHeldBy == (Object)null)) { StartOfRound instance = StartOfRound.Instance; if ((instance == null || !instance.inShipPhase) && (!requireTemporalStormWeatherForEffects || WeatherUtils.IsTemporalStormWeatherSelectedOrActive())) { serverDraining = true; CoroutineTools.Restart((MonoBehaviour)(object)this, ref drainCoroutine, DrainTemporalInstabilityServer()); } } } else if (serverDraining) { serverDraining = false; fullSpinServerSeconds = 0f; CoroutineTools.Stop((MonoBehaviour)(object)this, ref drainCoroutine); } } private IEnumerator DrainTemporalInstabilityServer() { WaitForSeconds wait = new WaitForSeconds(0.2f); while (serverDraining && (Object)(object)base.playerHeldBy != (Object)null && !gearBroken) { if ((StartOfRound.Instance?.inShipPhase ?? false) || (requireTemporalStormWeatherForEffects && !WeatherUtils.IsTemporalStormWeatherSelectedOrActive())) { fullSpinServerSeconds = 0f; yield return wait; continue; } if (!Mathf.Approximately(maximumSpinDegreesPerSecond, 0f) && Mathf.Abs(currentSpinDegreesPerSecond) / Mathf.Abs(maximumSpinDegreesPerSecond) >= fullSpinDrainThreshold) { float instabilityChange = instabilityDrainPerSecond * 0.2f; if (instabilityChange > 0f) { TemporalInstabilityAPI.ReduceServerInstability(instabilityChange); } else if (instabilityChange < 0f) { TemporalInstabilityAPI.IncreaseServerInstability(0f - instabilityChange); } fullSpinServerSeconds += 0.2f; if (fullSpinServerSeconds >= fullSpinBreakSeconds) { if (!gearBroken) { float breakVisualAmount = (Mathf.Approximately(maximumSpinDegreesPerSecond, 0f) ? 0f : Mathf.Clamp01(spinVisualCurve.Evaluate(Mathf.Abs(currentSpinDegreesPerSecond) / Mathf.Abs(maximumSpinDegreesPerSecond)))); BreakGearRpc(breakVisualAmount); } yield break; } } else { fullSpinServerSeconds = 0f; } yield return wait; } serverDraining = false; drainCoroutine = null; } private void ShowDraining(bool active) { gearSpinActive = active; if (active || Mathf.Abs(currentSpinDegreesPerSecond) > 0.01f) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref gearSpinCoroutine, SpinGear()); } else { SpinVisuals(0f); } } private IEnumerator SpinGear() { while (gearSpinActive || Mathf.Abs(currentSpinDegreesPerSecond) > 0.01f) { float deltaSeconds = Time.deltaTime; float wantedSpeed = (gearSpinActive ? maximumSpinDegreesPerSecond : 0f); float acceleration = (gearSpinActive ? spinAccelerationDegreesPerSecond : spinDecelerationDegreesPerSecond); currentSpinDegreesPerSecond = Mathf.MoveTowards(currentSpinDegreesPerSecond, wantedSpeed, acceleration * deltaSeconds); Vector3 localEulerAngles = gearSpinTransform.localEulerAngles; localEulerAngles.y = Mathf.Repeat(localEulerAngles.y + currentSpinDegreesPerSecond * deltaSeconds, 360f); gearSpinTransform.localEulerAngles = localEulerAngles; SpinVisuals(Mathf.Approximately(maximumSpinDegreesPerSecond, 0f) ? 0f : Mathf.Clamp01(spinVisualCurve.Evaluate(Mathf.Abs(currentSpinDegreesPerSecond) / Mathf.Abs(maximumSpinDegreesPerSecond)))); yield return null; } currentSpinDegreesPerSecond = 0f; SpinVisuals(0f); gearSpinCoroutine = null; } private void SpinVisuals(float visualAmount) { float rate = Mathf.Lerp(minimumParticleRate, maximumParticleRate, visualAmount); for (int i = 0; i < spinParticles.Length; i++) { ParticleUtils.SetEmissionRateAndPlayback(spinParticles[i], rate, (ParticleSystemStopBehavior)1); } float glowStrength = Mathf.Lerp(idleGlowStrength, maximumGlowStrength, visualAmount); float rustAmount = Mathf.Lerp(minimumRustAmount, maximumRustAmount, visualAmount); for (int j = 0; j < spinMaterialRenderers.Length; j++) { TemporalMaterialUtils.SetTemporalState(spinMaterialRenderers[j], gearPropertyBlock, glowStrength, rustAmount); } float num = Mathf.Lerp(minimumAudioVolume, maximumAudioVolume, visualAmount); gearAudioSource.volume = num; gearAudioSource.pitch = Mathf.Lerp(minimumAudioPitch, maximumAudioPitch, visualAmount); gearDistortionFilter.distortionLevel = Mathf.Lerp(minimumDistortionLevel, maximumDistortionLevel, visualAmount); gearHighPassFilter.cutoffFrequency = Mathf.Lerp(minimumHighPassFrequency, maximumHighPassFrequency, visualAmount); if (num > 0.001f) { if (!gearAudioSource.isPlaying) { gearAudioSource.Play(); } } else if (gearAudioSource.isPlaying) { AudioTools.Stop(gearAudioSource, false); } } private void UpdateTooltip() { string text = (gearBroken ? "Broken" : (draining ? (drainingTooltipText + " : [LMB]") : (idleTooltipText + " : [LMB]"))); if (base.itemProperties.toolTips == null || base.itemProperties.toolTips.Length == 0) { base.itemProperties.toolTips = new string[1] { text }; } else { base.itemProperties.toolTips[0] = text; } } [Rpc(/*Could not decode attribute arguments.*/)] private void RequestDrainRpc(bool active) { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1315449781u, val3, val, (SendTo)2, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref active, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1315449781u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; RunServerDrain(active); ShowDrainingRpc(active); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void ShowDrainingRpc(bool active) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(4008286308u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref active, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 4008286308u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this)) { ShowDraining(active); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void BreakGearRpc(float breakVisualAmount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3855392111u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref breakVisualAmount, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3855392111u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (gearBroken) { return; } PlayerControllerB playerHeldBy = base.playerHeldBy; bool flag = ItemUtils.IsHeldByLocalPlayer((GrabbableObject)(object)this); Vector3 val4 = default(Vector3); Quaternion val5 = default(Quaternion); gearSpinTransform.GetPositionAndRotation(ref val4, ref val5); Vector3 lossyScale = gearSpinTransform.lossyScale; float glowStrength = Mathf.Lerp(idleGlowStrength, maximumGlowStrength, breakVisualAmount); float rustAmount = Mathf.Lerp(minimumRustAmount, maximumRustAmount, breakVisualAmount); gearBroken = true; draining = false; serverDraining = false; gearSpinActive = false; currentSpinDegreesPerSecond = 0f; fullSpinServerSeconds = 0f; base.itemUsedUp = true; if ((Object)(object)playerHeldBy?.playerBodyAnimator != (Object)null && !string.IsNullOrWhiteSpace(base.itemProperties.useAnim) && playerHeldBy.playerBodyAnimator.GetBool(base.itemProperties.useAnim)) { playerHeldBy.playerBodyAnimator.SetBool(base.itemProperties.useAnim, false); } playerAnimatorTools.Restore(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref gearSpinCoroutine); SpinVisuals(0f); AudioTools.Stop(gearAudioSource, false); gearAudioSource.pitch = 1f; TemporalGearRagdoll temporalGearRagdoll = Object.Instantiate(gearRagdollPrefab, val4, val5); ((Component)temporalGearRagdoll).transform.localScale = lossyScale; temporalGearRagdoll.BreakOpen(val4, glowStrength, rustAmount); if (flag && (Object)(object)playerHeldBy != (Object)null) { playerHeldBy.DespawnHeldObject(); if (fullSpinHealthDamage > 0) { playerHeldBy.DamagePlayer(fullSpinHealthDamage, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); if (Plugin.hasCoroner) { CoronerCompat.SetTemporalGearDeathIfKilled(playerHeldBy); } } for (int i = 0; i < HUDManager.Instance.controlTipLines.Length; i++) { ((TMP_Text)HUDManager.Instance.controlTipLines[i]).text = string.Empty; } } UpdateTooltip(); } protected override void __initializeVariables() { ((GrabbableObject)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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1315449781u, new RpcReceiveHandler(__rpc_handler_1315449781), "RequestDrainRpc"); ((NetworkBehaviour)this).__registerRpc(4008286308u, new RpcReceiveHandler(__rpc_handler_4008286308), "ShowDrainingRpc"); ((NetworkBehaviour)this).__registerRpc(3855392111u, new RpcReceiveHandler(__rpc_handler_3855392111), "BreakGearRpc"); ((GrabbableObject)this).__initializeRpcs(); } private static void __rpc_handler_1315449781(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) { bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref active, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((TemporalGearItem)(object)target).RequestDrainRpc(active); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4008286308(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) { bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref active, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((TemporalGearItem)(object)target).ShowDrainingRpc(active); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3855392111(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 breakVisualAmount = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref breakVisualAmount, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((TemporalGearItem)(object)target).BreakGearRpc(breakVisualAmount); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "TemporalGearItem"; } } public class TemporalGearRagdoll : MonoBehaviour { private static readonly HashSet ActiveRagdolls = new HashSet(); [Header("Audio")] [SerializeField] private AudioClip breakClip = null; private AudioSource breakAudioSource = null; private Rigidbody[] breakPieces = null; private Renderer[] materialRenderers = null; private MaterialPropertyBlock propertyBlock = null; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ActiveRagdolls.Add(this); breakAudioSource = ((Component)this).GetComponentInChildren(); breakPieces = ((Component)this).GetComponentsInChildren(); materialRenderers = ((Component)this).GetComponentsInChildren(); propertyBlock = new MaterialPropertyBlock(); } private void OnDestroy() { ActiveRagdolls.Remove(this); } public static void Clear() { foreach (TemporalGearRagdoll activeRagdoll in ActiveRagdolls) { if ((Object)(object)activeRagdoll != (Object)null) { Object.Destroy((Object)(object)((Component)activeRagdoll).gameObject); } } ActiveRagdolls.Clear(); } public void BreakOpen(Vector3 origin, float glowStrength, float rustAmount) { //IL_0046: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) ShowBreakGlow(glowStrength, rustAmount); breakAudioSource.pitch = 1f; AudioTools.PlayOneShot(breakAudioSource, breakClip); for (int i = 0; i < breakPieces.Length; i++) { Rigidbody val = breakPieces[i]; Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(); Vector3 val2 = val.worldCenterOfMass; if (componentsInChildren.Length != 0) { Bounds bounds = componentsInChildren[0].bounds; for (int j = 1; j < componentsInChildren.Length; j++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[j].bounds); } val2 = ((Bounds)(ref bounds)).center; } Vector3 val3 = val2 - origin; val3.y += 0.2f; Transform[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(true); for (int k = 0; k < componentsInChildren2.Length; k++) { ((Component)componentsInChildren2[k]).gameObject.layer = ((Component)this).gameObject.layer; } Collider[] componentsInChildren3 = ((Component)val).GetComponentsInChildren(); for (int l = 0; l < componentsInChildren3.Length; l++) { componentsInChildren3[l].isTrigger = false; } val.isKinematic = false; val.useGravity = true; val.collisionDetectionMode = (CollisionDetectionMode)2; val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; val.WakeUp(); val.AddForce(((Vector3)(ref val3)).normalized * 14f, (ForceMode)1); val.AddTorque(Random.insideUnitSphere * 32f, (ForceMode)1); } ((MonoBehaviour)this).StartCoroutine(PulseGlow(glowStrength, rustAmount)); } private IEnumerator PulseGlow(float glowStrength, float rustAmount) { while (true) { float pulse = Mathf.Sin(Time.time / 1.4f * MathF.PI * 2f) * 0.5f + 0.5f; ShowBreakGlow(glowStrength + 0.35f * pulse, rustAmount); yield return null; } } private void ShowBreakGlow(float glowStrength, float rustAmount) { for (int i = 0; i < materialRenderers.Length; i++) { TemporalMaterialUtils.SetTemporalState(materialRenderers[i], propertyBlock, glowStrength, rustAmount); } } } public class TuningCylinderItem : GrabbableObject { [SerializeField] private AudioClip songClip = null; [SerializeField] private float songFadeInSeconds = 0.75f; private Coroutine? songFadeCoroutine; private float songVolume; [Header("Music")] [Tooltip("Does thing")] [SerializeField] internal AudioSource SongAudioSource = null; [SerializeField] internal string SongDisplayName = string.Empty; private void Awake() { songVolume = SongAudioSource.volume; SongAudioSource.loop = true; } internal void PlaySong() { SongAudioSource.pitch = 1f; SongAudioSource.volume = 0f; AudioTools.SwapClip(SongAudioSource, songClip, true); CoroutineTools.Restart((MonoBehaviour)(object)this, ref songFadeCoroutine, FadeSongVolume()); } internal void LoadSong() { songClip.LoadAudioData(); } internal void StopSong() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref songFadeCoroutine); AudioTools.Stop(SongAudioSource, false); AudioTools.SwapClip(SongAudioSource, (AudioClip)null, false); SongAudioSource.pitch = 1f; SongAudioSource.volume = songVolume; } internal void UnloadSong() { songClip.UnloadAudioData(); } internal IEnumerator StopSongLikeVinyl(float seconds) { CoroutineTools.Stop((MonoBehaviour)(object)this, ref songFadeCoroutine); float startPitch = SongAudioSource.pitch; float startVolume = SongAudioSource.volume; float elapsedSeconds = 0f; while (elapsedSeconds < seconds) { elapsedSeconds += Time.deltaTime; float progress = Mathf.SmoothStep(0f, 1f, elapsedSeconds / seconds); SongAudioSource.pitch = Mathf.Lerp(startPitch, 0f, progress); SongAudioSource.volume = Mathf.Lerp(startVolume, 0f, progress); yield return null; } StopSong(); } private IEnumerator FadeSongVolume() { float elapsedSeconds = 0f; while (elapsedSeconds < songFadeInSeconds) { elapsedSeconds += Time.deltaTime; SongAudioSource.volume = Mathf.Lerp(0f, songVolume, elapsedSeconds / songFadeInSeconds); yield return null; } SongAudioSource.volume = songVolume; songFadeCoroutine = null; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } protected internal override string __getTypeName() { return "TuningCylinderItem"; } } } namespace TemporalStormWeather.Hazards { internal class GearPileHazard : NetworkBehaviour, ITemporalInstability { [Serializable] private class GearSpawnPoint { public Transform SpawnPoint = null; private bool gearItemSpawned; private NamespacedKey? gearItemKey; private float yRotation; private GameObject? spawnedObject; private GrabbableObject? spawnedGrabbableObject; private NetworkObject? spawnedNetworkObject; private bool controlledByGearPile; private bool spawnedGearVisible; public bool ShouldSpawnGearItem => gearItemKey != null && !gearItemSpawned; public NamespacedKey? GearItemKey => gearItemKey; public Quaternion SpawnRotation => Quaternion.Euler(0f, yRotation, 0f); public void RollGearItem(Random random, float spawnChance, float madnessGearChance) { gearItemKey = ((!(random.NextDouble() <= (double)spawnChance)) ? null : ((random.NextDouble() < (double)madnessGearChance) ? Keys.MadnessGearItem : Keys.TemporalGearItem)); yRotation = Utility.RandomRange(random, 0f, 360f); } public void StoreSpawnedGearItem(GameObject gameObject, GrabbableObject grabbableObject, NetworkObject networkObject) { spawnedObject = gameObject; spawnedGrabbableObject = grabbableObject; spawnedNetworkObject = networkObject; gearItemSpawned = true; controlledByGearPile = true; spawnedGearVisible = true; } public bool GearVisibilityChanged(bool groupActive, out NetworkObjectReference networkObjectReference, out bool visible) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) networkObjectReference = default(NetworkObjectReference); visible = groupActive; if (!gearItemSpawned || (Object)(object)spawnedObject == (Object)null || (Object)(object)spawnedGrabbableObject == (Object)null || (Object)(object)spawnedNetworkObject == (Object)null) { return false; } if (!controlledByGearPile) { return false; } if (spawnedGrabbableObject.hasBeenHeld) { controlledByGearPile = false; spawnedGearVisible = true; return false; } if (!spawnedNetworkObject.IsSpawned) { return false; } if (spawnedGrabbableObject.isHeld || (Object)(object)spawnedGrabbableObject.playerHeldBy != (Object)null || spawnedGrabbableObject.isHeldByEnemy) { return false; } if (spawnedGearVisible == visible) { return false; } spawnedGearVisible = visible; networkObjectReference = NetworkObjectReference.op_Implicit(spawnedNetworkObject); return true; } public void ShowPlaceholder(bool groupActive) { bool enabled = groupActive && gearItemKey == null; Renderer[] componentsInChildren = ((Component)SpawnPoint).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = enabled; } } } [Serializable] private class MeshGroup { public Transform Root = null; [Range(0f, 100f)] public float StartInstability; [Range(0f, 1f)] public float GearSpawnChance = 1f; public BoxCollider[] BoxColliders = Array.Empty(); public GearSpawnPoint[] GearSpawnPoints = Array.Empty(); private bool active = true; public bool Active => active; public void ShowGroup(bool value) { if (active != value) { active = value; Renderer[] componentsInChildren = ((Component)Root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = active; } for (int j = 0; j < BoxColliders.Length; j++) { ((Collider)BoxColliders[j]).enabled = active; } for (int k = 0; k < GearSpawnPoints.Length; k++) { GearSpawnPoints[k].ShowPlaceholder(active); } } } public void RollGearItems(Random random, float madnessGearChance) { for (int i = 0; i < GearSpawnPoints.Length; i++) { GearSpawnPoints[i].RollGearItem(random, GearSpawnChance, madnessGearChance); } } public void ShowForInstability(float temporalInstabilityLevel) { ShowGroup(temporalInstabilityLevel >= StartInstability); } } [Header("Weather")] [SerializeField] private bool requireTemporalStormWeather = true; [Header("Spawn Roll")] [SerializeField] [Range(0f, 1f)] private float madnessGearChance = 0.5f; [Header("Groups")] [SerializeField] private MeshGroup[] meshGroups = new MeshGroup[4] { new MeshGroup { StartInstability = 0f, GearSpawnChance = 1f }, new MeshGroup { StartInstability = 20f, GearSpawnChance = 1f }, new MeshGroup { StartInstability = 55f, GearSpawnChance = 1f }, new MeshGroup { StartInstability = 90f, GearSpawnChance = 1f } }; private Coroutine? gearPileCoroutine; private bool weatherFlowActive; private bool gearItemsRolled; private float temporalInstabilityLevel; private void Awake() { for (int i = 0; i < meshGroups.Length; i++) { meshGroups[i].ShowGroup(value: false); } } private void Start() { CoroutineTools.Restart((MonoBehaviour)(object)this, ref gearPileCoroutine, StartWhenAllowed()); } private void OnDisable() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref gearPileCoroutine); if (weatherFlowActive) { weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); } } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); ShowForInstability(); SpawnActiveGearItems(); SyncSpawnedGearItemVisibility(); } private IEnumerator StartWhenAllowed() { while (!Utility.ShouldRunWeatherLifecycle()) { yield return null; } if (requireTemporalStormWeather) { while (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { yield return null; } } weatherFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); RollGearItems(); ShowForInstability(); SpawnActiveGearItems(); SyncSpawnedGearItemVisibility(); gearPileCoroutine = null; } private void ShowForInstability() { for (int i = 0; i < meshGroups.Length; i++) { meshGroups[i].ShowForInstability(temporalInstabilityLevel); } } private void RollGearItems() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!gearItemsRolled) { gearItemsRolled = true; int randomMapSeed = StartOfRound.Instance.randomMapSeed; Vector3 position = ((Component)this).transform.position; randomMapSeed = randomMapSeed * 31 + Mathf.RoundToInt(position.x * 100f); randomMapSeed = randomMapSeed * 31 + Mathf.RoundToInt(position.y * 100f); randomMapSeed = randomMapSeed * 31 + Mathf.RoundToInt(position.z * 100f); Random random = new Random(randomMapSeed); for (int i = 0; i < meshGroups.Length; i++) { meshGroups[i].RollGearItems(random, madnessGearChance); } } } private void SpawnActiveGearItems() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) if (!gearItemsRolled || !NetworkUtils.IsServer()) { return; } DawnItemInfo val = default(DawnItemInfo); for (int i = 0; i < meshGroups.Length; i++) { MeshGroup meshGroup = meshGroups[i]; if (!meshGroup.Active) { continue; } for (int j = 0; j < meshGroup.GearSpawnPoints.Length; j++) { GearSpawnPoint gearSpawnPoint = meshGroup.GearSpawnPoints[j]; if (gearSpawnPoint.ShouldSpawnGearItem) { NamespacedKey gearItemKey = gearSpawnPoint.GearItemKey; if (gearItemKey == null || !((Registry)(object)LethalContent.Items).TryGetValue(gearItemKey, ref val)) { Log.Warn("Gear pile could not find registered gear item"); continue; } Transform spawnPoint = gearSpawnPoint.SpawnPoint; Quaternion spawnRotation = gearSpawnPoint.SpawnRotation; GameObject val2 = Object.Instantiate(val.Item.spawnPrefab, spawnPoint.position, spawnRotation); GrabbableObject component = val2.GetComponent(); val2.transform.SetPositionAndRotation(spawnPoint.position, spawnRotation); PlaceSpawnedGear(component, spawnPoint.position, spawnRotation); NetworkObject component2 = val2.GetComponent(); component2.Spawn(false); PlaceSpawnedGearAfterSpawnRpc(NetworkObjectReference.op_Implicit(component2), spawnPoint.position, spawnRotation); gearSpawnPoint.StoreSpawnedGearItem(val2, component, component2); } } } } private void SyncSpawnedGearItemVisibility() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!gearItemsRolled || !NetworkUtils.IsServer()) { return; } for (int i = 0; i < meshGroups.Length; i++) { MeshGroup meshGroup = meshGroups[i]; for (int j = 0; j < meshGroup.GearSpawnPoints.Length; j++) { GearSpawnPoint gearSpawnPoint = meshGroup.GearSpawnPoints[j]; if (gearSpawnPoint.GearVisibilityChanged(meshGroup.Active, out var networkObjectReference, out var visible)) { SetSpawnedGearItemVisibleRpc(networkObjectReference, visible); } } } } [Rpc(/*Could not decode attribute arguments.*/)] private void SetSpawnedGearItemVisibleRpc(NetworkObjectReference itemReference, bool visible) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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(2497988874u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref itemReference, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref visible, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2497988874u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); if (((NetworkObjectReference)(ref itemReference)).TryGet(ref val4, (NetworkManager)null)) { ((Component)val4).gameObject.SetActive(visible); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void PlaceSpawnedGearAfterSpawnRpc(NetworkObjectReference itemReference, Vector3 spawnPosition, Quaternion spawnRotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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(3306580448u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref itemReference, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnRotation); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3306580448u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; NetworkObject val4 = default(NetworkObject); GrabbableObject grabbableObject = default(GrabbableObject); if (((NetworkObjectReference)(ref itemReference)).TryGet(ref val4, (NetworkManager)null) && ((Component)val4).TryGetComponent(ref grabbableObject)) { ((MonoBehaviour)this).StartCoroutine(PlaceSpawnedGearAfterStart(grabbableObject, spawnPosition, spawnRotation)); } } } private IEnumerator PlaceSpawnedGearAfterStart(GrabbableObject grabbableObject, Vector3 spawnPosition, Quaternion spawnRotation) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) yield return null; yield return null; PlaceSpawnedGear(grabbableObject, spawnPosition, spawnRotation); } private void PlaceSpawnedGear(GrabbableObject grabbableObject, Vector3 spawnPosition, Quaternion spawnRotation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) ((Component)grabbableObject).transform.SetPositionAndRotation(spawnPosition, spawnRotation); grabbableObject.hasHitGround = true; grabbableObject.reachedFloorTarget = true; grabbableObject.startFallingPosition = spawnPosition; grabbableObject.targetFloorPosition = spawnPosition; grabbableObject.fallTime = 1f; } 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(2497988874u, new RpcReceiveHandler(__rpc_handler_2497988874), "SetSpawnedGearItemVisibleRpc"); ((NetworkBehaviour)this).__registerRpc(3306580448u, new RpcReceiveHandler(__rpc_handler_3306580448), "PlaceSpawnedGearAfterSpawnRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2497988874(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_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference itemReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemReference, default(ForNetworkSerializable)); bool visible = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref visible, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((GearPileHazard)(object)target).SetSpawnedGearItemVisibleRpc(itemReference, visible); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3306580448(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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0071: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference itemReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref itemReference, default(ForNetworkSerializable)); Vector3 spawnPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPosition); Quaternion spawnRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnRotation); target.__rpc_exec_stage = (__RpcExecStage)1; ((GearPileHazard)(object)target).PlaceSpawnedGearAfterSpawnRpc(itemReference, spawnPosition, spawnRotation); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "GearPileHazard"; } } internal class RustHazard : MonoBehaviour, ITemporalInstability { [Serializable] private class MeshGroup { public Transform Root = null; [Range(0f, 100f)] public float StartInstability; [Min(0f)] public int Damage; public bool SlowPlayerMovement; private bool active = true; public void ShowForInstability(float temporalInstabilityLevel) { Show(temporalInstabilityLevel >= StartInstability); } public void Show(bool value, bool force = false) { if (force || active != value) { active = value; Renderer[] componentsInChildren = ((Component)Root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = active; } } } } [Header("Damage")] [SerializeField] private bool canDamagePlayer = true; [SerializeField] private Collider damageCollider = null; [Header("Movement Slow")] [SerializeField] [Range(0.01f, 1f)] private float movementSlowMultiplier = 0.5f; [Header("Groups")] [SerializeField] private MeshGroup[] meshGroups = new MeshGroup[4] { new MeshGroup { StartInstability = 0f, Damage = 0, SlowPlayerMovement = false }, new MeshGroup { StartInstability = 20f, Damage = 3, SlowPlayerMovement = false }, new MeshGroup { StartInstability = 55f, Damage = 6, SlowPlayerMovement = false }, new MeshGroup { StartInstability = 90f, Damage = 10, SlowPlayerMovement = false } }; private bool weatherFlowActive; private bool localPlayerDamageTriggerActive; private float temporalInstabilityLevel; private readonly HashSet localPlayerDamageCollidersInside = new HashSet(); private readonly HashSet detectedLocalPlayerDamageColliders = new HashSet(); private readonly List localPlayerDamageCollidersToRemove = new List(); private readonly Collider[] damageColliderOverlapResults = (Collider[])(object)new Collider[32]; [Header("Weather")] [SerializeField] private bool RequiresTemporalStormWeather = true; private static readonly HashSet localPlayerSlowHazards = new HashSet(); private static readonly List localPlayerSlowHazardsToRemove = new List(); private static PlayerControllerB? sharedSlowedPlayer; private static float sharedOriginalMovementSpeed; private static bool sharedMovementSlowApplied; private bool localPlayerSlowActive; private void Awake() { for (int i = 0; i < meshGroups.Length; i++) { meshGroups[i].Show(value: false, force: true); } if (RequiresTemporalStormWeather && !WeatherUtils.IsTemporalStormWeatherSelectedOrActive()) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { if (!canDamagePlayer || (Object)(object)damageCollider == (Object)null) { return; } damageCollider.isTrigger = true; if (!Utility.ShouldRunWeatherLifecycle()) { if (!RequiresTemporalStormWeather) { ShowForInstability(); } } else { ((MonoBehaviour)this).StartCoroutine(StartWhenAllowed()); } } } private void OnDestroy() { if (weatherFlowActive) { weatherFlowActive = false; TemporalInstabilityAPI.Unregister(this); } temporalInstabilityLevel = 0f; PlayerControllerB player = Utility.LocalPlayer(); if (localPlayerSlowActive) { localPlayerSlowActive = false; localPlayerSlowHazards.Remove(this); SyncSharedSlow(player); } localPlayerDamageCollidersInside.Clear(); localPlayerDamageTriggerActive = false; } private void FixedUpdate() { //IL_00fb: 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_0103: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) if (!canDamagePlayer || (Object)(object)damageCollider == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null) { return; } PlayerControllerB val = Utility.LocalPlayer(); if ((Object)(object)val == (Object)null) { return; } if (val.isInHangarShipRoom) { if (localPlayerDamageCollidersInside.Count > 0) { localPlayerDamageCollidersInside.Clear(); localPlayerDamageTriggerActive = false; SyncPlayerSlow(val); } return; } if (!damageCollider.enabled || !((Component)damageCollider).gameObject.activeInHierarchy) { if (localPlayerDamageCollidersInside.Count > 0) { localPlayerDamageCollidersInside.Clear(); localPlayerDamageTriggerActive = false; SyncPlayerSlow(val); } return; } detectedLocalPlayerDamageColliders.Clear(); Bounds bounds = damageCollider.bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, damageColliderOverlapResults, Quaternion.identity, StartOfRound.Instance.playersMask, (QueryTriggerInteraction)2); Vector3 val3 = default(Vector3); float num2 = default(float); for (int i = 0; i < num; i++) { Collider val2 = damageColliderOverlapResults[i]; if (!((Object)(object)val2 == (Object)null) && LocalPlayerCollider.Matches(val2) && Physics.ComputePenetration(damageCollider, ((Component)damageCollider).transform.position, ((Component)damageCollider).transform.rotation, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num2)) { detectedLocalPlayerDamageColliders.Add(val2); if (!localPlayerDamageCollidersInside.Contains(val2)) { DamagePlayer(val2); } } } localPlayerDamageCollidersToRemove.Clear(); foreach (Collider item in localPlayerDamageCollidersInside) { if ((Object)(object)item == (Object)null) { localPlayerDamageCollidersToRemove.Add(item); } else if (!detectedLocalPlayerDamageColliders.Contains(item)) { localPlayerDamageCollidersToRemove.Add(item); } } for (int j = 0; j < localPlayerDamageCollidersToRemove.Count; j++) { Collider val4 = localPlayerDamageCollidersToRemove[j]; if ((Object)(object)val4 == (Object)null) { localPlayerDamageCollidersInside.Remove(val4); } else { ClearPlayerDamageTrigger(val4); } } localPlayerDamageTriggerActive = localPlayerDamageCollidersInside.Count > 0; } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); ShowForInstability(); } private void DamagePlayer(Collider other) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = Utility.LocalPlayer(); if (val == null || val.isInHangarShipRoom || !LocalPlayerCollider.Matches(other)) { return; } localPlayerDamageCollidersInside.Add(other); SyncPlayerSlow(val); if (!canDamagePlayer || localPlayerDamageTriggerActive) { return; } localPlayerDamageTriggerActive = true; int num = 0; float num2 = -1f; for (int i = 0; i < meshGroups.Length; i++) { MeshGroup meshGroup = meshGroups[i]; if (!(temporalInstabilityLevel < meshGroup.StartInstability) && !(meshGroup.StartInstability < num2)) { num2 = meshGroup.StartInstability; num = meshGroup.Damage; } } if (num > 0) { val.DamagePlayer(num, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); if (Plugin.hasCoroner) { CoronerCompat.SetRustHazardDeathIfKilled(val); } } } private void ClearPlayerDamageTrigger(Collider other) { PlayerControllerB val = Utility.LocalPlayer(); if (!((Object)(object)val == (Object)null) && LocalPlayerCollider.Matches(other)) { localPlayerDamageCollidersInside.Remove(other); if (localPlayerDamageCollidersInside.Count == 0) { localPlayerDamageTriggerActive = false; } SyncPlayerSlow(val); } } private void ShowForInstability() { for (int i = 0; i < meshGroups.Length; i++) { meshGroups[i].ShowForInstability(temporalInstabilityLevel); } if (localPlayerDamageCollidersInside.Count > 0) { SyncPlayerSlow(Utility.LocalPlayer()); } } private IEnumerator StartWhenAllowed() { if (RequiresTemporalStormWeather) { while (!WeatherUtils.IsTemporalStormWeatherSelectedOrActive(checkSelected: false)) { yield return null; } } weatherFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Client); ShowForInstability(); } private void SyncPlayerSlow(PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return; } bool flag = false; float num = -1f; for (int i = 0; i < meshGroups.Length; i++) { MeshGroup meshGroup = meshGroups[i]; if (!(temporalInstabilityLevel < meshGroup.StartInstability) && !(meshGroup.StartInstability < num)) { num = meshGroup.StartInstability; flag = meshGroup.SlowPlayerMovement; } } bool flag2 = !player.isInHangarShipRoom && localPlayerDamageCollidersInside.Count > 0 && flag; if (localPlayerSlowActive == flag2) { SyncSharedSlow(player); return; } localPlayerSlowActive = flag2; if (!flag2) { localPlayerSlowHazards.Remove(this); } else { localPlayerSlowHazards.Add(this); } SyncSharedSlow(player); } private static void SyncSharedSlow(PlayerControllerB? player) { localPlayerSlowHazardsToRemove.Clear(); foreach (RustHazard localPlayerSlowHazard in localPlayerSlowHazards) { if ((Object)(object)localPlayerSlowHazard == (Object)null) { localPlayerSlowHazardsToRemove.Add(localPlayerSlowHazard); } } for (int i = 0; i < localPlayerSlowHazardsToRemove.Count; i++) { localPlayerSlowHazards.Remove(localPlayerSlowHazardsToRemove[i]); } PlayerControllerB val = player ?? sharedSlowedPlayer; if ((Object)(object)val == (Object)null) { return; } if (localPlayerSlowHazards.Count == 0) { if (sharedMovementSlowApplied) { val.movementSpeed = sharedOriginalMovementSpeed; sharedMovementSlowApplied = false; sharedSlowedPlayer = null; } return; } if (!sharedMovementSlowApplied || (Object)(object)sharedSlowedPlayer != (Object)(object)val) { sharedOriginalMovementSpeed = val.movementSpeed; sharedSlowedPlayer = val; sharedMovementSlowApplied = true; } float num = 1f; foreach (RustHazard localPlayerSlowHazard2 in localPlayerSlowHazards) { if ((Object)(object)localPlayerSlowHazard2 != (Object)null) { num = Mathf.Min(num, localPlayerSlowHazard2.movementSlowMultiplier); } } val.movementSpeed = sharedOriginalMovementSpeed * num; } } internal class TemporalRift : NetworkBehaviour, ITemporalInstability { private class WeightedEnemy { public EnemyType EnemyType = null; public int Weight; public float MinimumInstability; public bool IgnoreRiftConfigs; } private static readonly int RiftIndexPropertyId = Shader.PropertyToID("_RiftIndex"); private static readonly int CounterPropertyId = Shader.PropertyToID("_Counter"); private static readonly int CounterSmoothPropertyId = Shader.PropertyToID("_CounterSmooth"); private const float CounterRandomJumpChance = 0.012f; private const float CounterRandomJumpMaximum = 20f; private const float CounterSmoothBaseValue = 200f; private const float CounterSmoothAmplitude = 100f; private const float CounterSmoothMillisecondsDivisor = 24000f; private const int EnemyPoolWeight = 1; private static readonly NamespacedKey UnimplementedTag = NamespacedKey.From("lethal_company", "unimplemented"); private static readonly List activeRifts = new List(); private static TemporalRift? shaderTimingOwner; private static Coroutine? sharedShaderTimeCoroutine; private static int nextShaderRiftIndex = 1; private static float sharedShaderCounter; private static float sharedShaderCounterSmooth = 200f; private static readonly (NamespacedKey EnemyKey, float MinimumInstability)[] LocustRiftEnemies = new(NamespacedKey, float)[3] { (Keys.LocustEnemyInfo, 50f), (Keys.SawbladeLocustEnemyInfo, 80f), (Keys.CorruptLocustEnemyInfo, 65f) }; [Header("Trigger")] [SerializeField] private Collider boundsCollider = null; [Header("Client Instability Gain")] [SerializeField] [Min(0f)] private float clientInstabilityGainDelaySeconds = 0.6f; [SerializeField] [Min(0.01f)] private float clientInstabilityGainDurationSeconds = 3f; [SerializeField] [Range(0f, 100f)] private float maximumClientInstabilityAddition = 100f; [SerializeField] private AnimationCurve clientInstabilityGainCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); [Header("Visual Randomisation")] [SerializeField] private Renderer[] temporalStormRiftRenderers = Array.Empty(); [SerializeField] private Renderer[] temporalStormGalaxyRenderers = Array.Empty(); [Header("Particle Scale")] [SerializeField] private GameObject[] particleScaleObjects = Array.Empty(); [SerializeField] [Range(0.05f, 1f)] private float minimumParticleScale = 0.3f; [SerializeField] [Min(0.01f)] private float particleScaleSmoothSeconds = 0.75f; [SerializeField] private AnimationCurve powerScaleCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f); [SerializeField] private AnimationCurve closeScaleCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); [Header("Audio")] [SerializeField] private AudioSource riftAudioSource = null; [SerializeField] private AudioSource closeAudioSource = null; [SerializeField] private AudioClip closeAudioClip = null; [Header("Light")] [SerializeField] private Light riftLight = null; [SerializeField] [Min(0.01f)] private float closeSeconds = 1.5f; [Header("Locust Rifts")] [SerializeField] [Range(0f, 100f)] private float locustOnlyRiftStartInstability = 50f; [Header("Instability")] [SerializeField] [Range(0f, 100f)] private float spawnStartInstability = 50f; [SerializeField] [Range(0f, 100f)] private float fullSpawnInstability = 100f; [Header("Enemy Spawn Timing")] [SerializeField] [Min(0f)] private float minimumInitialDelaySeconds = 60f; [SerializeField] [Min(0f)] private float maximumInitialDelaySeconds = 110f; [SerializeField] [Min(0.1f)] private float minimumSpawnIntervalSeconds = 37f; [SerializeField] [Min(0.1f)] private float maximumSpawnIntervalSeconds = 70f; [SerializeField] private AnimationCurve initialDelayCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); [SerializeField] private AnimationCurve spawnIntervalCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); [SerializeField] private AnimationCurve spawnChanceCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); [SerializeField] [Range(0f, 1f)] private float spawnChanceAtStart = 0f; [SerializeField] [Range(0f, 1f)] private float spawnChanceAtFull = 0.7f; [Header("Rift Budget")] [SerializeField] private AnimationCurve enemyPowerBudgetCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); [Header("Placement")] [SerializeField] [Min(0f)] private float spawnRadius = 2f; [SerializeField] [Min(0f)] private float minimumDistanceFromPlayer = 8f; [SerializeField] [Min(0f)] private float maximumDistanceFromPlayer = 80f; private readonly List enemyPool = new List(); private readonly List locustEnemyPool = new List(); private readonly List enemyCandidates = new List(); private readonly NetworkVariable syncedEnemyPowerBudget = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable syncedRemainingEnemyPower = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private MaterialPropertyBlock shaderPropertyBlock = null; private Random spawnRandom = null; private bool localPlayerInside; private bool weatherFlowActive; private bool enemySpawnFlowActive; private TemporalRiftSpawnLocation spawnLocation; private bool closingRift; private bool locustOnlyRift; private int shaderRiftIndex; private float currentInstabilityAddition; private float currentParticleScale = 1f; private float startingAudioVolume; private float startingLightIntensity; private float spentEnemyPower; private float enemyPowerBudget; private float temporalInstabilityLevel; private float boundsCapsuleColliderRadius; private float boundsCapsuleColliderHeight; private Coroutine? instabilityCoroutine; private Coroutine? particleScaleCoroutine; private Coroutine? spawnCoroutine; private Coroutine? closeCoroutine; private LocalPlayerTrigger? localPlayerTrigger; private CapsuleCollider? boundsCapsuleCollider; private Vector3[] particleBaseLocalScales = Array.Empty(); public float StartingPower { get; private set; } = 1f; public float RemainingPower { get; private set; } = 1f; public float CloseDespawnSeconds => Mathf.Max(closeSeconds, closeAudioClip.length); public bool IsClosing { get; private set; } internal AudioClip?[] AudioClips { get { AudioClip[] obj = new AudioClip[3] { closeAudioClip, default(AudioClip), default(AudioClip) }; AudioSource obj2 = riftAudioSource; obj[1] = ((obj2 != null) ? obj2.clip : null); AudioSource obj3 = closeAudioSource; obj[2] = ((obj3 != null) ? obj3.clip : null); return (AudioClip?[])(object)obj; } } private void Awake() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) shaderPropertyBlock = new MaterialPropertyBlock(); sharedShaderCounterSmooth = 200f; startingAudioVolume = riftAudioSource.volume; startingLightIntensity = riftLight.intensity; ref CapsuleCollider? reference = ref boundsCapsuleCollider; Collider obj = boundsCollider; reference = (CapsuleCollider?)(object)((obj is CapsuleCollider) ? obj : null); if ((Object)(object)boundsCapsuleCollider != (Object)null) { boundsCapsuleColliderRadius = boundsCapsuleCollider.radius; boundsCapsuleColliderHeight = boundsCapsuleCollider.height; } particleBaseLocalScales = (Vector3[])(object)new Vector3[particleScaleObjects.Length]; for (int i = 0; i < particleScaleObjects.Length; i++) { particleBaseLocalScales[i] = particleScaleObjects[i].transform.localScale; } int num = nextShaderRiftIndex; if ((num < 1 || num > 4096) ? true : false) { nextShaderRiftIndex = 1; } shaderRiftIndex = nextShaderRiftIndex; nextShaderRiftIndex++; if (nextShaderRiftIndex > 4096) { nextShaderRiftIndex = 1; } PushShaderValues(); } public override void OnNetworkSpawn() { NetworkVariable obj = syncedEnemyPowerBudget; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnEnemyPowerBudgetChanged)); NetworkVariable obj2 = syncedRemainingEnemyPower; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnRemainingEnemyPowerChanged)); if (!((NetworkBehaviour)this).IsServer) { SetPowerVisuals(Mathf.Max(0f, syncedEnemyPowerBudget.Value), syncedRemainingEnemyPower.Value, instant: true); return; } if (!Utility.ShouldRunWeatherLifecycle()) { SetPowerVisuals(Mathf.Max(0f, syncedEnemyPowerBudget.Value), syncedRemainingEnemyPower.Value, instant: true); return; } int seed = StartOfRound.Instance.randomMapSeed + (int)(((NetworkBehaviour)this).NetworkObjectId % 1000000) + 61357; spawnRandom = new Random(seed); spentEnemyPower = 0f; closingRift = false; enemySpawnFlowActive = true; TemporalInstabilityAPI.Register(this, TemporalInstabilityFeed.Server); enemyPool.Clear(); locustEnemyPool.Clear(); FillEnemyPool(EnemyBlacklist()); float num = Mathf.Max(0f, ConfigManager.TemporalRiftMinimumEnemyPowerBudget.Value); float num2 = Mathf.Max(num, ConfigManager.TemporalRiftMaximumEnemyPowerBudget.Value); float num3 = (float)spawnRandom.NextDouble(); float num4 = Mathf.Clamp01(enemyPowerBudgetCurve.Evaluate(num3)); enemyPowerBudget = Mathf.Lerp(num, num2, num4); float num5 = Mathf.Clamp01(ConfigManager.TemporalRiftLocustOnlyRiftChance.Value); locustOnlyRift = num5 > 0f && temporalInstabilityLevel >= locustOnlyRiftStartInstability && HasUsableEnemy(locustEnemyPool, enemyPowerBudget) && spawnRandom.NextDouble() <= (double)num5; syncedEnemyPowerBudget.Value = enemyPowerBudget; syncedRemainingEnemyPower.Value = enemyPowerBudget; SetPowerVisuals(enemyPowerBudget, enemyPowerBudget, instant: true); CoroutineTools.Start((MonoBehaviour)(object)this, ref spawnCoroutine, ProcessSpawns()); } public override void OnNetworkDespawn() { NetworkVariable obj = syncedEnemyPowerBudget; obj.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnEnemyPowerBudgetChanged)); NetworkVariable obj2 = syncedRemainingEnemyPower; obj2.OnValueChanged = (OnValueChangedDelegate)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate(OnRemainingEnemyPowerChanged)); StopSpawner(); } private void OnEnable() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (Utility.ShouldRunWeatherLifecycle()) { weatherFlowActive = true; localPlayerTrigger = LocalPlayerTrigger.Arm(boundsCollider); if ((Object)(object)localPlayerTrigger != (Object)null) { localPlayerTrigger.Entered += OnLocalPlayerEntered; localPlayerTrigger.Exited += OnLocalPlayerExited; } if (!activeRifts.Contains(this)) { activeRifts.Add(this); } if ((Object)(object)shaderTimingOwner == (Object)null) { shaderTimingOwner = this; CoroutineTools.Restart((MonoBehaviour)(object)this, ref sharedShaderTimeCoroutine, DriveSharedShaderTiming()); } PushShaderValues(); Vector3 position = ((Component)Utility.LocalPlayer()).transform.position; Vector3 val = boundsCollider.ClosestPoint(position); Vector3 val2 = val - position; localPlayerInside = ((Vector3)(ref val2)).sqrMagnitude < 0.0001f; if (localPlayerInside) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref instabilityCoroutine, RampInstability()); } } } private void OnDisable() { if ((Object)(object)localPlayerTrigger != (Object)null) { localPlayerTrigger.Entered -= OnLocalPlayerEntered; localPlayerTrigger.Exited -= OnLocalPlayerExited; localPlayerTrigger = null; } StopSpawner(); if (!weatherFlowActive) { return; } weatherFlowActive = false; activeRifts.Remove(this); if ((Object)(object)shaderTimingOwner == (Object)(object)this) { CoroutineTools.Stop((MonoBehaviour)(object)this, ref sharedShaderTimeCoroutine); shaderTimingOwner = null; if (activeRifts.Count > 0) { shaderTimingOwner = activeRifts[0]; CoroutineTools.Restart((MonoBehaviour)(object)shaderTimingOwner, ref sharedShaderTimeCoroutine, shaderTimingOwner.DriveSharedShaderTiming()); } } CoroutineTools.Stop((MonoBehaviour)(object)this, ref instabilityCoroutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref particleScaleCoroutine); TemporalInstabilityAPI.ClearClientInstabilityAddition(this); currentInstabilityAddition = 0f; localPlayerInside = false; } public void SetSpawnLocation(TemporalRiftSpawnLocation value) { spawnLocation = value; } public void SetTemporalInstabilityLevel(float value) { temporalInstabilityLevel = Utility.ClampInstability(value); } public void CloseAndDespawn() { if (((NetworkBehaviour)this).IsServer && !closingRift) { closingRift = true; CoroutineTools.Stop((MonoBehaviour)(object)this, ref spawnCoroutine); BeginRiftCloseRpc(); CoroutineTools.Start((MonoBehaviour)(object)this, ref closeCoroutine, DespawnAfterClose()); } } public void SetPowerVisuals(float newStartingPower, float newRemainingPower, bool instant) { IsClosing = false; riftAudioSource.volume = startingAudioVolume; riftLight.intensity = startingLightIntensity; StartingPower = Mathf.Max(1f, newStartingPower); RemainingPower = Mathf.Clamp(newRemainingPower, 0f, StartingPower); float num = Mathf.InverseLerp(1f, StartingPower, RemainingPower); float num2 = Mathf.Clamp01(powerScaleCurve.Evaluate(num)); float num3 = Mathf.Lerp(minimumParticleScale, 1f, num2); float num4 = (instant ? 0f : particleScaleSmoothSeconds); if (num4 <= 0f) { CoroutineTools.Stop((MonoBehaviour)(object)this, ref particleScaleCoroutine); ScaleParticles(num3); } else { CoroutineTools.Restart((MonoBehaviour)(object)this, ref particleScaleCoroutine, ScaleParticleObjects(currentParticleScale, num3, num4, powerScaleCurve)); } } public void BeginPowerClose() { if (!IsClosing) { IsClosing = true; AudioTools.PlayOneShot(closeAudioSource, closeAudioClip); if (closeSeconds <= 0f) { CoroutineTools.Stop((MonoBehaviour)(object)this, ref particleScaleCoroutine); ScaleParticles(0f); AudioTools.Stop(riftAudioSource, true); riftLight.intensity = 0f; } else { CoroutineTools.Restart((MonoBehaviour)(object)this, ref particleScaleCoroutine, CloseParticleObjects(currentParticleScale)); } } } private void StopSpawner() { if (enemySpawnFlowActive) { enemySpawnFlowActive = false; TemporalInstabilityAPI.Unregister(this); CoroutineTools.Stop((MonoBehaviour)(object)this, ref spawnCoroutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref closeCoroutine); enemyCandidates.Clear(); enemyPool.Clear(); locustEnemyPool.Clear(); locustOnlyRift = false; } } private IEnumerator ProcessSpawns() { float spawnAmount = SpawnPressure(); yield return (object)new WaitForSeconds(Mathf.Lerp(maximumInitialDelaySeconds, minimumInitialDelaySeconds, Mathf.Clamp01(initialDelayCurve.Evaluate(spawnAmount)))); while (enemySpawnFlowActive) { SpawnEnemy(); spawnAmount = SpawnPressure(); yield return (object)new WaitForSeconds(Mathf.Lerp(maximumSpawnIntervalSeconds, minimumSpawnIntervalSeconds, Mathf.Clamp01(spawnIntervalCurve.Evaluate(spawnAmount)))); } } private void SpawnEnemy() { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) float num = SpawnPressure(); if (num <= 0f) { return; } if (Mathf.Max(0f, enemyPowerBudget - spentEnemyPower) <= 0f) { CloseAndDespawn(); } else { if (!HasPlayerInRange()) { return; } float num2 = Mathf.Lerp(spawnChanceAtStart, spawnChanceAtFull, Mathf.Clamp01(spawnChanceCurve.Evaluate(num))); if (spawnRandom.NextDouble() > (double)num2) { return; } int num3 = Mathf.Max(1, ConfigManager.TemporalRiftMinimumLocustSpawnCount.Value); int num4 = Mathf.Max(num3, ConfigManager.TemporalRiftMaximumLocustSpawnCount.Value); int num5 = ((!locustOnlyRift) ? 1 : spawnRandom.Next(num3, num4 + 1)); NetworkObject val2 = default(NetworkObject); for (int i = 0; i < num5; i++) { if (!ChooseEnemy(out EnemyType enemyType)) { CloseAndDespawn(); break; } if (!ChooseSpawnPosition(enemyType, out var spawnPosition)) { break; } float num6 = Utility.RandomRange(spawnRandom, 0f, 360f); NetworkObjectReference val = RoundManager.Instance.SpawnEnemyGameObject(spawnPosition, num6, -1, enemyType); if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null)) { EnemyAI val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInChildren(); if ((Object)(object)val3 != (Object)null) { SpendEnemyPower(enemyType.PowerLevel); continue; } Log.Warn("Rift enemy " + enemyType.enemyName + " spawned without enemy AI"); break; } Log.Warn("Rift enemy " + enemyType.enemyName + " did not return a network object"); break; } } } private bool ChooseEnemy(out EnemyType enemyType) { enemyCandidates.Clear(); float remainingPower = Mathf.Max(0f, enemyPowerBudget - spentEnemyPower); if (locustOnlyRift) { AddEnemyPool(locustEnemyPool, remainingPower); } else { AddEnemyPool(enemyPool, remainingPower); } return PickWeightedEnemy(out enemyType); } private bool PickWeightedEnemy(out EnemyType enemyType) { enemyType = null; int num = 0; for (int i = 0; i < enemyCandidates.Count; i++) { num += enemyCandidates[i].Weight; } if (num <= 0) { return false; } int num2 = spawnRandom.Next(0, num); for (int j = 0; j < enemyCandidates.Count; j++) { num2 -= enemyCandidates[j].Weight; if (num2 <= 0) { enemyType = enemyCandidates[j].EnemyType; return true; } } List list = enemyCandidates; enemyType = list[list.Count - 1].EnemyType; return true; } private void FillEnemyPool(HashSet> enemyBlacklist) { SelectableLevel val = null; if (ConfigManager.TemporalRiftUseCurrentMoonEnemyList.Value) { SelectableLevel val2 = RoundManager.Instance?.currentLevel; DawnMoonInfo val3 = ((val2 != null) ? SelectableLevelExtensions.GetDawnInfo(val2) : null); val = ((val3 != null) ? val3.Level : null); } foreach (KeyValuePair, DawnEnemyInfo> item in (Registry)(object)LethalContent.Enemies) { NamespacedKey key = item.Key; DawnEnemyInfo value = item.Value; if (((DawnBaseInfo)(object)value).HasTag(UnimplementedTag)) { continue; } EnemyType enemyType = value.EnemyType; if ((Object)(object)enemyType == (Object)null) { continue; } if (LocustMinimumInstability(key, out var minimumInstability)) { locustEnemyPool.Add(new WeightedEnemy { EnemyType = enemyType, Weight = 1, MinimumInstability = minimumInstability, IgnoreRiftConfigs = true }); } if (enemyBlacklist.Contains(key) || !CanSpawnInRiftLocation(value)) { continue; } if (ConfigManager.TemporalRiftUseCurrentMoonEnemyList.Value) { if ((Object)(object)val == (Object)null) { continue; } bool num; if (!Plugin.hasStarlancerAIFix || !ConfigManager.TemporalRiftUnrestrictEnemySpawns.Value) { if (spawnLocation != TemporalRiftSpawnLocation.Outside) { num = MoonListContainsEnemy(val.Enemies, enemyType); } else { if (MoonListContainsEnemy(val.OutsideEnemies, enemyType)) { goto IL_01b7; } num = MoonListContainsEnemy(val.DaytimeEnemies, enemyType); } } else { if (MoonListContainsEnemy(val.Enemies, enemyType) || MoonListContainsEnemy(val.OutsideEnemies, enemyType)) { goto IL_01b7; } num = MoonListContainsEnemy(val.DaytimeEnemies, enemyType); } if (!num) { continue; } } goto IL_01b7; IL_01b7: enemyPool.Add(new WeightedEnemy { EnemyType = enemyType, Weight = 1 }); } } private HashSet> EnemyBlacklist() { string configuredKeys = ((spawnLocation == TemporalRiftSpawnLocation.Outside) ? ConfigManager.TemporalRiftOutsideEnemyBlacklist.Value : ConfigManager.TemporalRiftInsideEnemyBlacklist.Value); return DawnConfigUtils.ParseNamespacedKeySet(configuredKeys); } private bool CanSpawnInRiftLocation(DawnEnemyInfo enemyInfo) { if (Plugin.hasStarlancerAIFix && ConfigManager.TemporalRiftUnrestrictEnemySpawns.Value) { return enemyInfo.Inside != null || enemyInfo.Outside != null || enemyInfo.Daytime != null; } return (spawnLocation != TemporalRiftSpawnLocation.Outside) ? (enemyInfo.Inside != null) : (enemyInfo.Outside != null || enemyInfo.Daytime != null); } private static bool MoonListContainsEnemy(List spawnableEnemies, EnemyType enemyType) { for (int i = 0; i < spawnableEnemies.Count; i++) { if ((Object)(object)spawnableEnemies[i].enemyType == (Object)(object)enemyType) { return true; } } return false; } private static bool LocustMinimumInstability(NamespacedKey enemyKey, out float minimumInstability) { for (int i = 0; i < LocustRiftEnemies.Length; i++) { var (val, value) = LocustRiftEnemies[i]; if (((object)val).Equals((object?)enemyKey)) { minimumInstability = Utility.ClampInstability(value); return true; } } minimumInstability = 0f; return false; } private void AddEnemyPool(List enemyPool, float remainingPower) { for (int i = 0; i < enemyPool.Count; i++) { WeightedEnemy weightedEnemy = enemyPool[i]; if (CanUseEnemy(weightedEnemy, remainingPower)) { enemyCandidates.Add(weightedEnemy); } } } private bool HasUsableEnemy(List enemyPool, float remainingPower) { for (int i = 0; i < enemyPool.Count; i++) { if (CanUseEnemy(enemyPool[i], remainingPower)) { return true; } } return false; } private bool CanUseEnemy(WeightedEnemy weightedEnemy, float remainingPower) { EnemyType enemyType = weightedEnemy.EnemyType; return temporalInstabilityLevel >= weightedEnemy.MinimumInstability && (weightedEnemy.IgnoreRiftConfigs || !ConfigManager.TemporalRiftSkipDisabledEnemies.Value || !enemyType.spawningDisabled) && (weightedEnemy.IgnoreRiftConfigs || !ConfigManager.TemporalRiftRespectEnemyMaxCount.Value || enemyType.numberSpawned < enemyType.MaxCount) && enemyType.PowerLevel > 0f && enemyType.PowerLevel <= remainingPower; } private bool ChooseSpawnPosition(EnemyType enemyType, out Vector3 spawnPosition) { //IL_0045: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (spawnRadius <= 0f) { spawnPosition = ((Component)this).transform.position; return true; } int layermaskForEnemySizeLimit = RoundManager.Instance.GetLayermaskForEnemySizeLimit(enemyType, false, -1); spawnPosition = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(((Component)this).transform.position, spawnRadius, default(NavMeshHit), spawnRandom, layermaskForEnemySizeLimit, 1f); return RoundManager.Instance.GotNavMeshPositionResult; } private bool HasPlayerInRange() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) float num = minimumDistanceFromPlayer * minimumDistanceFromPlayer; float num2 = maximumDistanceFromPlayer * maximumDistanceFromPlayer; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Utility.IsPlayerActive(val)) { Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude >= num && sqrMagnitude <= num2) { return true; } } } return false; } private void SpendEnemyPower(float enemyPower) { spentEnemyPower += Mathf.Max(0f, enemyPower); float num = Mathf.Max(0f, enemyPowerBudget - spentEnemyPower); syncedRemainingEnemyPower.Value = num; SetPowerVisuals(Mathf.Max(0f, syncedEnemyPowerBudget.Value), num, instant: false); if (num <= 0f) { CloseAndDespawn(); } } private void OnEnemyPowerBudgetChanged(float previousPower, float currentPower) { enemyPowerBudget = Mathf.Max(0f, currentPower); SetPowerVisuals(Mathf.Max(0f, syncedEnemyPowerBudget.Value), syncedRemainingEnemyPower.Value, instant: true); } private void OnRemainingEnemyPowerChanged(float previousPower, float currentPower) { SetPowerVisuals(Mathf.Max(0f, syncedEnemyPowerBudget.Value), currentPower, instant: false); } [Rpc(/*Could not decode attribute arguments.*/)] private void BeginRiftCloseRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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(2687883115u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2687883115u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; BeginPowerClose(); } } } private IEnumerator DespawnAfterClose() { yield return (object)new WaitForSeconds(CloseDespawnSeconds); if (((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } closeCoroutine = null; } private float SpawnPressure() { return Utility.InstabilityProgress(temporalInstabilityLevel, spawnStartInstability, fullSpawnInstability); } private IEnumerator DriveSharedShaderTiming() { while ((Object)(object)shaderTimingOwner == (Object)(object)this && activeRifts.Count > 0) { sharedShaderCounter += Time.deltaTime; if (Random.value < 0.012f) { sharedShaderCounter += 20f * Random.value; } sharedShaderCounterSmooth = 200f + Mathf.Sin(Time.time * 1000f / 24000f) * 100f; for (int i = 0; i < activeRifts.Count; i++) { activeRifts[i].PushShaderValues(); } sharedShaderCounter = Mathf.Repeat(sharedShaderCounter + Time.deltaTime, MathF.PI * 200f); yield return null; } sharedShaderTimeCoroutine = null; } private void PushShaderValues() { PushShaderValues(temporalStormRiftRenderers); PushShaderValues(temporalStormGalaxyRenderers); } private void PushShaderValues(Renderer[] renderers) { for (int i = 0; i < renderers.Length; i++) { renderers[i].GetPropertyBlock(shaderPropertyBlock); shaderPropertyBlock.SetFloat(RiftIndexPropertyId, (float)shaderRiftIndex); shaderPropertyBlock.SetFloat(CounterPropertyId, sharedShaderCounter); shaderPropertyBlock.SetFloat(CounterSmoothPropertyId, sharedShaderCounterSmooth); renderers[i].SetPropertyBlock(shaderPropertyBlock); shaderPropertyBlock.Clear(); } } private void OnLocalPlayerEntered(Collider other) { if (weatherFlowActive && !localPlayerInside) { localPlayerInside = true; CoroutineTools.Restart((MonoBehaviour)(object)this, ref instabilityCoroutine, RampInstability()); } } private void OnLocalPlayerExited(Collider other) { if (weatherFlowActive && localPlayerInside) { localPlayerInside = false; CoroutineTools.Stop((MonoBehaviour)(object)this, ref instabilityCoroutine); TemporalInstabilityAPI.ClearClientInstabilityAddition(this); currentInstabilityAddition = 0f; } } private IEnumerator RampInstability() { currentInstabilityAddition = 0f; TemporalInstabilityAPI.SetClientInstabilityAddition(this, currentInstabilityAddition); yield return (object)new WaitForSeconds(clientInstabilityGainDelaySeconds); float elapsedSeconds = 0f; while (localPlayerInside && elapsedSeconds < clientInstabilityGainDurationSeconds) { elapsedSeconds += Time.deltaTime; float curveTime = Mathf.Clamp01(elapsedSeconds / clientInstabilityGainDurationSeconds); float curveValue = Mathf.Clamp01(clientInstabilityGainCurve.Evaluate(curveTime)); currentInstabilityAddition = maximumClientInstabilityAddition * curveValue; TemporalInstabilityAPI.SetClientInstabilityAddition(this, currentInstabilityAddition); yield return null; } currentInstabilityAddition = maximumClientInstabilityAddition * Mathf.Clamp01(clientInstabilityGainCurve.Evaluate(1f)); TemporalInstabilityAPI.SetClientInstabilityAddition(this, currentInstabilityAddition); instabilityCoroutine = null; } private IEnumerator ScaleParticleObjects(float startScale, float wantedScale, float seconds, AnimationCurve scaleCurve) { float elapsedSeconds = 0f; while (elapsedSeconds < seconds) { elapsedSeconds += Time.deltaTime; float progress = Mathf.Clamp01(elapsedSeconds / seconds); float curvedProgress = Mathf.Clamp01(scaleCurve.Evaluate(progress)); ScaleParticles(Mathf.Lerp(startScale, wantedScale, curvedProgress)); yield return null; } ScaleParticles(wantedScale); particleScaleCoroutine = null; } private IEnumerator CloseParticleObjects(float startScale) { float elapsedSeconds = 0f; float startVolume = riftAudioSource.volume; float startIntensity = riftLight.intensity; while (elapsedSeconds < closeSeconds) { elapsedSeconds += Time.deltaTime; float progress = Mathf.Clamp01(elapsedSeconds / closeSeconds); float remainingScale = Mathf.Clamp01(closeScaleCurve.Evaluate(progress)); ScaleParticles(startScale * remainingScale); riftAudioSource.volume = startVolume * remainingScale; riftLight.intensity = startIntensity * remainingScale; yield return null; } ScaleParticles(0f); AudioTools.Stop(riftAudioSource, true); riftLight.intensity = 0f; particleScaleCoroutine = null; } private void ScaleParticles(float scaleAmount) { //IL_002a: 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) currentParticleScale = Mathf.Max(0f, scaleAmount); for (int i = 0; i < particleScaleObjects.Length; i++) { particleScaleObjects[i].transform.localScale = particleBaseLocalScales[i] * currentParticleScale; } if ((Object)(object)boundsCapsuleCollider != (Object)null) { boundsCapsuleCollider.radius = boundsCapsuleColliderRadius * currentParticleScale; boundsCapsuleCollider.height = boundsCapsuleColliderHeight * currentParticleScale; } } protected override void __initializeVariables() { if (syncedEnemyPowerBudget == null) { throw new Exception("TemporalRift.syncedEnemyPowerBudget cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)syncedEnemyPowerBudget).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)syncedEnemyPowerBudget, "syncedEnemyPowerBudget"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)syncedEnemyPowerBudget); if (syncedRemainingEnemyPower == null) { throw new Exception("TemporalRift.syncedRemainingEnemyPower cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)syncedRemainingEnemyPower).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)syncedRemainingEnemyPower, "syncedRemainingEnemyPower"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)syncedRemainingEnemyPower); ((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(2687883115u, new RpcReceiveHandler(__rpc_handler_2687883115), "BeginRiftCloseRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2687883115(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; ((TemporalRift)(object)target).BeginRiftCloseRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "TemporalRift"; } } } namespace TemporalStormWeather.Enemies { public class BellAnimationEvents : MonoBehaviour { private BellEnemyAI? bellEnemy; private void Awake() { bellEnemy = ((Component)this).GetComponentInParent(); } public void Listen() { bellEnemy?.ListenSoundFromAnimationEvent(); } public void ListenFinished() { bellEnemy?.ListenFinishedFromAnimationEvent(); } public void HideFinished() { bellEnemy?.HideFinishedFromAnimationEvent(); } public void UnhideFinished() { bellEnemy?.UnhideFinishedFromAnimationEvent(); } } public class BellEnemyAI : EnemyAI, ISmartAI { private enum BellState { None = -1, Idle, Wander, Listen, Hide, Hidden, Unhide, Alarm } private static readonly int WalkHash = Animator.StringToHash("walk"); private static readonly int UnhideHash = Animator.StringToHash("unhide"); private static readonly int IdleHash = Animator.StringToHash("idle"); private static readonly int ListenHash = Animator.StringToHash("listen"); private static readonly int HideHash = Animator.StringToHash("hide"); private static readonly int DieHash = Animator.StringToHash("die"); private static readonly int AlarmHash = Animator.StringToHash("alarm"); private static bool loggedMissingAgent; private static bool loggedMissingNodes; [Header("Bell")] [SerializeField] private Collider bodyCollider = null; [SerializeField] private AudioSource alarmLoopSource = null; [SerializeField] private AudioClip alarmClip = null; [SerializeField] private AudioClip listenClip = null; [SerializeField] private AudioClip hurtClip = null; [SerializeField] private AudioClip walkClip = null; [Header("Alarm")] [SerializeField] private float seekingRange = 10f; [SerializeField] [Min(0f)] private float closeAwarenessRange = 3f; [SerializeField] private float alarmMemoryTime = 4f; [SerializeField] [Min(0f)] private float alarmInstabilityPerSecond = 0.2f; [SerializeField] [Min(0f)] private float locustWakeRange = 30f; [Header("Movement")] [SerializeField] private float wanderSpeed = 1.6f; [SerializeField] private float hideChance = 0.01f; [SerializeField] private float listenChance = 0.5f; [SerializeField] private float minDecisionTime = 2f; [SerializeField] private float maxDecisionTime = 10f; [SerializeField] private float minHideTime = 20f; [SerializeField] private float maxHideTime = 80f; private BellState bellState = BellState.None; private float decisionTimer; private float hideTimer; private float alarmLostTimer; private float alarmMinimumTimer; private float perceptionTimer; private readonly SmartPathTask wanderPathTask = new SmartPathTask(); private readonly SmartPathTask directPathTask = new SmartPathTask(); private readonly List wanderCandidatePositions = new List(); private readonly RaycastHit[] lineOfSightHits = (RaycastHit[])(object)new RaycastHit[1]; private PlayerControllerB? cachedTarget; private bool wanderPathRequested; private bool directPathRequested; private bool ignoreWanderPathResult; public override void Start() { ((EnemyAI)this).Start(); if ((Object)(object)base.agent == (Object)null) { if (!loggedMissingAgent) { loggedMissingAgent = true; Log.Error("Bell enemy is missing a nav mesh agent"); } ((Behaviour)this).enabled = false; return; } SmartPathfinding.RegisterSmartAgent(base.agent); base.ventAnimationFinished = true; if ((Object)(object)alarmClip != (Object)null) { AudioTools.SwapClip(alarmLoopSource, alarmClip, false); } if ((Object)(object)walkClip != (Object)null) { AudioTools.SwapClip(base.creatureSFX, walkClip, false); } alarmLoopSource.loop = true; base.creatureSFX.loop = true; base.agent.speed = wanderSpeed; base.agent.avoidancePriority = 30 + base.thisEnemyIndex % 40; decisionTimer = Random.Range(minDecisionTime, maxDecisionTime); perceptionTimer = Random.Range(0f, 0.22f); SetState(BellState.Idle); } public override void OnDestroy() { if ((Object)(object)base.agent != (Object)null) { SmartPathfinding.UnregisterSmartAgent(base.agent); } wanderPathTask.Dispose(); directPathTask.Dispose(); ((EnemyAI)this).OnDestroy(); } public override void DoAIInterval() { if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead) { return; } if (!((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; return; } perceptionTimer -= base.AIIntervalTime; if (base.stunNormalizedTimer > 0f) { base.agent.isStopped = true; ((EnemyAI)this).DoAIInterval(); return; } ProcessWanderPathTask(); ProcessDirectPathTask(); switch (bellState) { case BellState.Idle: DoIdleInterval(); break; case BellState.Wander: DoWanderInterval(); break; case BellState.Listen: if (TrySetTarget(seekingRange)) { BeginAlarm(); } break; case BellState.Hide: case BellState.Unhide: if (TrySetTarget(10f)) { BeginAlarm(); } break; case BellState.Hidden: DoHiddenInterval(); break; case BellState.Alarm: DoAlarmInterval(); break; } ((EnemyAI)this).DoAIInterval(); } public override void OnCollideWithPlayer(Collider other) { ((EnemyAI)this).OnCollideWithPlayer(other); if (((NetworkBehaviour)this).IsOwner) { PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { base.targetPlayer = val; BeginAlarm(); } } } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && bellState != BellState.Alarm && !(noiseLoudness < 0.65f) && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh && (!directPathRequested || directPathTask.IsComplete)) { SetState(BellState.Idle); directPathTask.Dispose(); ignoreWanderPathResult = true; directPathRequested = true; directPathTask.StartPathTask(base.agent, AgentExtensions.GetPathOrigin(base.agent), noisePosition, (SmartPathfindingLinkFlags)0); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, false, hitID); if (!base.isEnemyDead && ((NetworkBehaviour)this).IsOwner) { base.enemyHP -= force; AudioTools.PlayOneShot(base.creatureVoice, hurtClip); if (((NetworkBehaviour)this).IsServer) { PlayHurtSoundClientRpc(); } else { PlayHurtSoundServerRpc(); } if (base.enemyHP <= 0) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } else { BeginAlarm(); } } } public override void KillEnemy(bool destroy = false) { Collider obj = bodyCollider; if (obj != null) { obj.enabled = false; } StopWalkLoop(); StopAlarmLoop(); ((EnemyAI)this).KillEnemy(destroy); if (!destroy) { base.creatureAnimator.speed = 1f; base.creatureAnimator.CrossFadeInFixedTime(DieHash, 0.1f, 0, 0f); } } public override Transform GetRadarHeadTransform() { return base.eye; } private void DoIdleInterval() { if (TrySetTarget(seekingRange)) { BeginAlarm(); return; } decisionTimer -= base.AIIntervalTime; if (!(decisionTimer > 0f)) { float value = Random.value; if (value < hideChance) { hideTimer = Random.Range(minHideTime, maxHideTime); SetState(BellState.Hide); } else if (value < hideChance + listenChance) { SetState(BellState.Listen); } else { StartWanderPathTask(); } } } private void DoWanderInterval() { //IL_004a: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (TrySetTarget(seekingRange)) { BeginAlarm(); } else if (!wanderPathRequested && !directPathRequested) { float num = base.agent.stoppingDistance + 0.6f; Vector3 val = ((Component)this).transform.position - base.destination; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { BeginIdle(); } } } private void DoHiddenInterval() { if (TrySetTarget(10f)) { BeginAlarm(); return; } hideTimer -= base.AIIntervalTime; if (hideTimer <= 0f) { SetState(BellState.Unhide); } } private void DoAlarmInterval() { base.agent.isStopped = true; base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; alarmMinimumTimer -= base.AIIntervalTime; if (((NetworkBehaviour)this).IsServer) { TemporalInstabilityAPI.IncreaseServerInstability(alarmInstabilityPerSecond * base.AIIntervalTime); } if (TrySetTarget(seekingRange)) { alarmLostTimer = alarmMemoryTime; return; } alarmLostTimer -= base.AIIntervalTime; if (alarmLostTimer <= 0f && alarmMinimumTimer <= 0f) { BeginIdle(); } } private void BeginAlarm() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) bool flag = bellState == BellState.Alarm; alarmLostTimer = alarmMemoryTime; alarmMinimumTimer = 10f; SetState(BellState.Alarm); if (!flag) { LocustEnemyBase.WakeNearbyLocusts(((Component)this).transform.position, locustWakeRange); } } private void BeginIdle() { decisionTimer = Random.Range(minDecisionTime, maxDecisionTime); SetState(BellState.Idle); } private void SetState(BellState nextState) { if (bellState != nextState) { bellState = nextState; ApplyState(nextState); if (((NetworkBehaviour)this).IsServer) { SyncBellStateClientRpc((int)nextState); } else { SyncBellStateServerRpc((int)nextState); } } } private void ApplyState(BellState nextState) { base.creatureAnimator.speed = 1f; switch (nextState) { case BellState.Idle: if (((NetworkBehaviour)this).IsOwner) { wanderPathTask.Dispose(); directPathTask.Dispose(); wanderPathRequested = false; directPathRequested = false; ignoreWanderPathResult = false; base.agent.isStopped = true; base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; } StopWalkLoop(); StopAlarmLoop(); base.creatureAnimator.CrossFadeInFixedTime(IdleHash, 0.1f, 0, 0f); break; case BellState.Wander: if (((NetworkBehaviour)this).IsOwner) { base.agent.speed = wanderSpeed; } StopAlarmLoop(); if ((Object)(object)base.creatureSFX.clip != (Object)null && !base.creatureSFX.isPlaying) { base.creatureSFX.Play(); } base.creatureAnimator.CrossFadeInFixedTime(WalkHash, 0.1f, 0, 0f); break; case BellState.Listen: if (((NetworkBehaviour)this).IsOwner) { base.agent.isStopped = true; base.moveTowardsDestination = false; } StopWalkLoop(); StopAlarmLoop(); base.creatureAnimator.CrossFadeInFixedTime(ListenHash, 0.1f, 0, 0f); break; case BellState.Hide: if (((NetworkBehaviour)this).IsOwner) { base.agent.isStopped = true; base.moveTowardsDestination = false; } StopWalkLoop(); StopAlarmLoop(); base.creatureAnimator.CrossFadeInFixedTime(HideHash, 0.1f, 0, 0f); break; case BellState.Hidden: if (((NetworkBehaviour)this).IsOwner) { base.agent.isStopped = true; base.moveTowardsDestination = false; } StopWalkLoop(); StopAlarmLoop(); base.creatureAnimator.Play(HideHash, 0, 1f); base.creatureAnimator.speed = 0f; break; case BellState.Unhide: if (((NetworkBehaviour)this).IsOwner) { base.agent.isStopped = true; base.moveTowardsDestination = false; } StopWalkLoop(); StopAlarmLoop(); base.creatureAnimator.CrossFadeInFixedTime(UnhideHash, 0.1f, 0, 0f); break; case BellState.Alarm: if (((NetworkBehaviour)this).IsOwner) { wanderPathTask.Dispose(); directPathTask.Dispose(); wanderPathRequested = false; directPathRequested = false; ignoreWanderPathResult = false; base.agent.isStopped = true; base.moveTowardsDestination = false; } StopWalkLoop(); if ((Object)(object)alarmLoopSource.clip != (Object)null && !alarmLoopSource.isPlaying) { alarmLoopSource.Play(); } base.creatureAnimator.CrossFadeInFixedTime(AlarmHash, 0.1f, 0, 0f); break; } } private void StartWanderPathTask() { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if ((wanderPathRequested && !wanderPathTask.IsComplete) || directPathRequested) { return; } wanderPathTask.Dispose(); wanderCandidatePositions.Clear(); if (base.allAINodes == null || base.allAINodes.Length == 0) { if (!loggedMissingNodes) { loggedMissingNodes = true; Log.Warn("Bell enemy has no AI nodes for wandering"); } BeginIdle(); return; } int num = Mathf.Min(4, base.allAINodes.Length); for (int i = 0; i < num; i++) { wanderCandidatePositions.Add(base.allAINodes[Random.Range(0, base.allAINodes.Length)].transform.position); } ignoreWanderPathResult = false; wanderPathRequested = true; wanderPathTask.StartPathTask(base.agent, AgentExtensions.GetPathOrigin(base.agent), wanderCandidatePositions, (SmartPathfindingLinkFlags)0); } private void ProcessDirectPathTask() { //IL_0059: 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) if (directPathRequested && directPathTask.IsComplete) { directPathRequested = false; SmartPathDestination? result = directPathTask.GetResult(0); if (result.HasValue && bellState == BellState.Idle) { SetState(BellState.Wander); GoToSmartPathDestination(result.Value); } directPathTask.Dispose(); } } private void ProcessWanderPathTask() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if (!wanderPathRequested || !wanderPathTask.IsComplete) { return; } wanderPathRequested = false; if (bellState != BellState.Idle || directPathRequested || ignoreWanderPathResult) { ignoreWanderPathResult = false; wanderPathTask.Dispose(); return; } int num = -1; float num2 = float.MinValue; for (int i = 0; i < wanderCandidatePositions.Count; i++) { if (wanderPathTask.PathSucceeded(i)) { float num3 = wanderPathTask.GetPathLength(i) + Random.Range(0f, 8f); if (!(num3 <= num2)) { num2 = num3; num = i; } } } if (num < 0) { wanderPathTask.Dispose(); BeginIdle(); return; } SmartPathDestination? result = wanderPathTask.GetResult(num); if (result.HasValue) { SetState(BellState.Wander); GoToSmartPathDestination(result.Value); } wanderPathTask.Dispose(); } public void GoToSmartPathDestination(in SmartPathDestination pathDestination) { //IL_001d: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) base.agent.isStopped = false; base.moveTowardsDestination = true; base.movingTowardsTargetPlayer = false; Vector3 position = ((SmartPathDestination)(ref pathDestination)).Position; Vector2 val = Random.insideUnitCircle * 1.5f; Vector3 val2 = position + new Vector3(val.x, 0f, val.y); Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 2f, base.agentMask); ((EnemyAI)this).SetDestinationToPosition(navMeshPosition, false); } private PlayerControllerB? FindTarget(float range) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cachedTarget != (Object)null) { Vector3 playerCenter = GetPlayerCenter(cachedTarget); float num = range * range; Vector3 val = playerCenter - base.eye.position; if (!(((Vector3)(ref val)).sqrMagnitude <= num)) { if (!cachedTarget.isCrouching) { val = ((Component)cachedTarget).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= closeAwarenessRange * closeAwarenessRange) { goto IL_00a4; } } cachedTarget = null; } } goto IL_00a4; IL_00a4: if ((Object)(object)cachedTarget != (Object)null) { if (perceptionTimer > 0f) { return cachedTarget; } if (IsTargetVisible(cachedTarget, range)) { ResetPerceptionTimer(); return cachedTarget; } } cachedTarget = null; if (perceptionTimer > 0f) { return null; } ResetPerceptionTimer(); cachedTarget = FindVisibleTarget(range); return cachedTarget; } private bool TrySetTarget(float range) { PlayerControllerB val = FindTarget(range); if ((Object)(object)val == (Object)null) { return false; } base.targetPlayer = val; return true; } private void ResetPerceptionTimer() { perceptionTimer = 0.22f + Random.Range(0f, 0.077f); } private PlayerControllerB? FindVisibleTarget(float range) { //IL_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; float num = range * range; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; int num2 = Mathf.Min(allPlayerScripts.Length, StartOfRound.Instance.connectedPlayersAmount + 1); for (int i = 0; i < num2; i++) { PlayerControllerB val = allPlayerScripts[i]; if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { Vector3 playerCenter = GetPlayerCenter(val); Vector3 val2 = playerCenter - base.eye.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num) && IsTargetVisible(val, range)) { num = sqrMagnitude; result = val; } } } return result; } private bool IsTargetVisible(PlayerControllerB player, float range) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) Vector3 playerCenter = GetPlayerCenter(player); Vector3 val = playerCenter - base.eye.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = range * range; if (!player.isCrouching) { Vector3 val2 = ((Component)player).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= closeAwarenessRange * closeAwarenessRange) { goto IL_00cd; } } if (sqrMagnitude > num) { return false; } float num2 = Vector3.Dot(base.eye.forward, val); float num3 = Mathf.Cos(1.2217305f); if (num2 <= 0f || num2 * num2 < num3 * num3 * sqrMagnitude) { return false; } goto IL_00cd; IL_00cd: float num4 = Mathf.Sqrt(sqrMagnitude); return num4 <= 0.001f || Physics.RaycastNonAlloc(base.eye.position, val / num4, lineOfSightHits, num4, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) == 0; } private Vector3 GetPlayerCenter(PlayerControllerB player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return ((Component)player.gameplayCamera).transform.position; } private void StopAlarmLoop() { if (alarmLoopSource.isPlaying) { AudioTools.Stop(alarmLoopSource, false); } } private void StopWalkLoop() { if (base.creatureSFX.isPlaying) { AudioTools.Stop(base.creatureSFX, false); } } public void ListenSoundFromAnimationEvent() { AudioTools.PlayOneShot(base.creatureVoice, listenClip); } public void ListenFinishedFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && bellState == BellState.Listen) { BeginIdle(); } } public void HideFinishedFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && bellState == BellState.Hide) { SetState(BellState.Hidden); } } public void UnhideFinishedFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && bellState == BellState.Unhide) { BeginIdle(); } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncBellStateServerRpc(int state) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0076: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2228455540u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, state); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2228455540u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; SyncBellStateClientRpc(state); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncBellStateClientRpc(int state) { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3955167070u, val3, val, (SendTo)1, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, state); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3955167070u, val3, val, (SendTo)1, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; bellState = (BellState)state; ApplyState(bellState); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void PlayHurtSoundServerRpc() { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2386642904u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2386642904u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayHurtSoundClientRpc(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void PlayHurtSoundClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(3622038914u, val3, val, (SendTo)1, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 3622038914u, val3, val, (SendTo)1, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; AudioTools.PlayOneShot(base.creatureVoice, hurtClip); } } } void ISmartAI.GoToSmartPathDestination(in SmartPathDestination destination) { GoToSmartPathDestination(in destination); } protected override void __initializeVariables() { ((EnemyAI)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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2228455540u, new RpcReceiveHandler(__rpc_handler_2228455540), "SyncBellStateServerRpc"); ((NetworkBehaviour)this).__registerRpc(3955167070u, new RpcReceiveHandler(__rpc_handler_3955167070), "SyncBellStateClientRpc"); ((NetworkBehaviour)this).__registerRpc(2386642904u, new RpcReceiveHandler(__rpc_handler_2386642904), "PlayHurtSoundServerRpc"); ((NetworkBehaviour)this).__registerRpc(3622038914u, new RpcReceiveHandler(__rpc_handler_3622038914), "PlayHurtSoundClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2228455540(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 state = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref state); target.__rpc_exec_stage = (__RpcExecStage)1; ((BellEnemyAI)(object)target).SyncBellStateServerRpc(state); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3955167070(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 state = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref state); target.__rpc_exec_stage = (__RpcExecStage)1; ((BellEnemyAI)(object)target).SyncBellStateClientRpc(state); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2386642904(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; ((BellEnemyAI)(object)target).PlayHurtSoundServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3622038914(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; ((BellEnemyAI)(object)target).PlayHurtSoundClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "BellEnemyAI"; } } public class CorruptLocustEnemyAI : LocustEnemyBase { [Header("Audio")] [SerializeField] private LocustAudioLibrary audioProfile = null; [Header("Attack")] [SerializeField] [Min(0f)] private float attackRange = 2.25f; [SerializeField] [Min(0.01f)] private float leapMoveSeconds = 0.25f; [SerializeField] [Min(0f)] private float drillDamageIntervalSeconds = 0.65f; [SerializeField] [Min(0f)] private int drillDamage = 5; [SerializeField] [Min(0f)] private float attackCooldownSeconds = 8f; [Header("Face Grab")] [SerializeField] private Vector3 faceLocalPosition = new Vector3(0f, -1.15f, 1.35f); [SerializeField] private Vector3 faceLocalEulerAngles = new Vector3(0f, 180f, 0f); private PlayerControllerB? grabbedPlayer; private PlayerControllerB? releasedPlayer; private PlayerControllerB? leapTarget; private ulong grabbedPlayerClientId; private Vector3 leapStartPosition; private Vector3 leapTargetPosition; private Quaternion leapStartRotation; private Quaternion leapTargetRotation; private float leapMoveTimer; private float drillDamageTimer; private bool movingToGrab; private bool landingFromGrab; private bool agentDisabledByGrab; private bool drillActive; protected override string EnemyLogName => "Corrupt Locust"; protected override LocustAudioLibrary AudioProfile => audioProfile; protected override bool UsesHurtState => true; protected override float AttackRange => attackRange; protected override float AttackCooldownSeconds => attackCooldownSeconds; protected override bool RotateTowardTargetThisFrame => (Object)(object)grabbedPlayer == (Object)null && !movingToGrab && (locustState == LocustState.Attack || (locustState == LocustState.Chase && attackCooldownTimer <= 0f)); protected override float TargetTurnDegreesPerSecond => (locustState == LocustState.Attack) ? 540f : 360f; public override void Update() { if ((Object)(object)grabbedPlayer == (Object)null) { base.Update(); UpdateLeapMovement(); return; } UpdateGrabPosition(); if (!((NetworkBehaviour)this).IsOwner) { return; } if (!CanStayAttachedToPlayer(grabbedPlayer)) { CancelGrab(); } else { if (!drillActive) { return; } drillDamageTimer -= Time.deltaTime; if (!(drillDamageTimer > 0f)) { drillDamageTimer = drillDamageIntervalSeconds; if (((NetworkBehaviour)this).IsServer) { DamageGrabbedPlayerClientRpc(grabbedPlayerClientId); } else { DamageGrabbedPlayerServerRpc(grabbedPlayerClientId); } } } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { if (((NetworkBehaviour)this).IsOwner && ((Object)(object)grabbedPlayer != (Object)null || movingToGrab || landingFromGrab)) { CancelGrab(); } base.HitEnemy(force, playerWhoHit, playHitSFX, hitID); } public override void KillEnemy(bool destroy = false) { if ((Object)(object)grabbedPlayer != (Object)null || movingToGrab || landingFromGrab) { if (((NetworkBehaviour)this).IsOwner) { if (((NetworkBehaviour)this).IsServer) { StopGrabClientRpc(); } else { StopGrabServerRpc(); } } StopGrabLocal(); } base.KillEnemy(destroy); } protected override bool CanStartAttack(PlayerControllerB player, Vector3 flatDirectionToPlayer) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return (Object)(object)grabbedPlayer == (Object)null && !landingFromGrab && base.CanStartAttack(player, flatDirectionToPlayer); } protected override bool ShouldHoldChasePosition(PlayerControllerB player) { return (attackCooldownTimer > 0f) ? base.ShouldHoldChasePosition(player) : (IsInAttackRange(player) && HasSightToTarget(player)); } protected override Vector3 GetChaseDestination(PlayerControllerB player) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (attackCooldownTimer <= 0f) { return ((Component)player).transform.position; } Vector3 val = ((Component)this).transform.position - ((Component)player).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { val = -((Component)player).transform.forward; val.y = 0f; } return (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) ? ((Component)player).transform.position : (((Component)player).transform.position + ((Vector3)(ref val)).normalized * attackRange); } protected override void OnStartingAttack(PlayerControllerB player) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) FaceTarget(((Component)player).transform.position); } protected override void UpdateAttack(float deltaTime) { if (!((Object)(object)grabbedPlayer != (Object)null) && !landingFromGrab && !movingToGrab && baseAnimationFinished) { if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true)) { SetState(LocustState.Chase); MoveToCurrentTarget(); } else { ((EnemyAI)this).targetPlayer = null; BeginIdle(); } } } protected override void OnAttackAnimationHit() { if ((Object)(object)leapTarget != (Object)null) { StartGrabForPlayer(leapTarget); } } protected override void OnAttackAnimationFinished() { if (!((Object)(object)leapTarget != (Object)null) || !StartGrabForPlayer(leapTarget)) { movingToGrab = false; leapTarget = null; if (!((Object)(object)grabbedPlayer != (Object)null) && !landingFromGrab) { base.OnAttackAnimationFinished(); } } } private void StartLeapMovement() { //IL_004b: 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: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsOwner && !((Object)(object)((EnemyAI)this).targetPlayer == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true)) { Vector3 val = ((Component)this).transform.position + Vector3.up * 0.45f; int num = Mathf.CeilToInt(attackRange + 2f); if (((EnemyAI)this).targetPlayer.HasLineOfSightToPosition(val, 70f, num, -1f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) { leapTarget = ((EnemyAI)this).targetPlayer; GetFaceGrabPose(leapTarget, out leapTargetPosition, out leapTargetRotation); BeginLeapMovement(((Component)this).transform.position, ((Component)this).transform.rotation, leapTargetPosition, leapTargetRotation); StartLeapMovementClientRpc(leapStartPosition, leapStartRotation, leapTargetPosition, leapTargetRotation); } } } private void BeginLeapMovement(Vector3 startPosition, Quaternion startRotation, Vector3 targetPosition, Quaternion targetRotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) leapStartPosition = startPosition; leapStartRotation = startRotation; leapTargetPosition = targetPosition; leapTargetRotation = targetRotation; leapMoveTimer = 0f; movingToGrab = true; } private void UpdateLeapMovement() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!movingToGrab) { return; } leapMoveTimer += Time.deltaTime; float num = Mathf.SmoothStep(0f, 1f, leapMoveTimer / leapMoveSeconds); ((Component)this).transform.SetPositionAndRotation(Vector3.Lerp(leapStartPosition, leapTargetPosition, num), Quaternion.Slerp(leapStartRotation, leapTargetRotation, num)); if (num >= 1f) { movingToGrab = false; if (((NetworkBehaviour)this).IsOwner && (Object)(object)leapTarget != (Object)null) { StartGrabForPlayer(leapTarget); } } } private bool StartGrabForPlayer(PlayerControllerB player) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsOwner) { return false; } if ((Object)(object)grabbedPlayer != (Object)null) { return false; } if (landingFromGrab) { return false; } if (!((EnemyAI)this).PlayerIsTargetable(player, false, false, true)) { return false; } Vector3 val = (((Object)(object)leapTarget == (Object)(object)player) ? (leapStartPosition + Vector3.up * 0.45f) : (((Component)this).transform.position + Vector3.up * 0.45f)); int num = Mathf.CeilToInt(attackRange + 2f); if (!player.HasLineOfSightToPosition(val, 70f, num, -1f, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) { return false; } if (LocustEnemyBase.PlayerHasAnotherAttachedLocust(player.playerClientId, this)) { return false; } ((EnemyAI)this).targetPlayer = player; grabbedPlayerClientId = player.playerClientId; attackDamageDone = true; if (((NetworkBehaviour)this).IsServer) { StartGrabClientRpc(grabbedPlayerClientId); return true; } StartGrabServerRpc(grabbedPlayerClientId); return true; } private bool CanStayAttachedToPlayer(PlayerControllerB player) { return !((EnemyAI)this).isEnemyDead && ((EnemyAI)this).stunNormalizedTimer <= 0f && player.isPlayerControlled && !player.isPlayerDead && player.shipTeleporterId <= 0 && player.sinkingValue < 0.73f; } private void StartGrab(ulong playerClientId) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return; } int num = (int)playerClientId; if (num < 0 || num >= StartOfRound.Instance.allPlayerScripts.Length) { return; } if (LocustEnemyBase.PlayerHasAnotherAttachedLocust(playerClientId, this)) { movingToGrab = false; leapTarget = null; if (((NetworkBehaviour)this).IsOwner) { attackCooldownTimer = attackCooldownSeconds; SetState(LocustState.Chase); } return; } LocustEnemyBase.AttachLocustToPlayer(playerClientId, this); grabbedPlayer = StartOfRound.Instance.allPlayerScripts[num]; grabbedPlayerClientId = playerClientId; releasedPlayer = null; movingToGrab = false; landingFromGrab = false; leapTarget = null; drillDamageTimer = 0f; drillActive = false; NavMeshAgent agent = ((EnemyAI)this).agent; agentDisabledByGrab = agent != null && ((Behaviour)agent).enabled; NavMeshAgent agent2 = ((EnemyAI)this).agent; if (agent2 != null) { ((Behaviour)agent2).enabled = false; } Collider obj = bodyCollider; if (obj != null) { obj.enabled = false; } ((EnemyAI)this).moveTowardsDestination = false; ((EnemyAI)this).movingTowardsTargetPlayer = false; StartBaseAnimation(LocustState.Attack, "grab", 0f, AnimationPlayback.Event, restart: true, 0f); UpdateGrabPosition(); AudioTools.PlayOneShot(((EnemyAI)this).creatureSFX, AudioProfile?.grab); } private void StartGrabLanding() { if (!((Object)(object)grabbedPlayer == (Object)null)) { if (((NetworkBehaviour)this).IsServer) { StartGrabLandingClientRpc(); } else { StartGrabLandingServerRpc(); } } } private void StartGrabLandingLocal() { if (!((Object)(object)grabbedPlayer == (Object)null)) { drillActive = false; StopDrillSound(); landingFromGrab = true; releasedPlayer = grabbedPlayer; StartBaseAnimation(LocustState.Attack, "grabland", 0f, AnimationPlayback.Event, restart: true, 0f); } } private void DetachFromGrab() { if (((NetworkBehaviour)this).IsServer) { DetachFromGrabClientRpc(); } else { DetachFromGrabServerRpc(); } } private void DetachFromGrabLocal() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)grabbedPlayer != (Object)null || landingFromGrab; ulong playerClientId = grabbedPlayerClientId; Vector3 val = (((Object)(object)grabbedPlayer == (Object)null) ? ((Component)this).transform.position : ((Component)grabbedPlayer).transform.position); grabbedPlayer = null; drillActive = false; movingToGrab = false; StopDrillSound(); if (flag) { LocustEnemyBase.ClearAttachedLocust(playerClientId, this); } Collider obj = bodyCollider; if (obj != null) { obj.enabled = !((EnemyAI)this).isEnemyDead; } NavMeshAgent agent = ((EnemyAI)this).agent; if (agent != null && !((Behaviour)agent).enabled && agentDisabledByGrab) { if ((Object)(object)RoundManager.Instance != (Object)null) { ((Component)this).transform.position = RoundManager.Instance.GetNavMeshPosition(val, RoundManager.Instance.navHit, 12f, ((EnemyAI)this).agentMask); } ((Behaviour)((EnemyAI)this).agent).enabled = true; if (((EnemyAI)this).agent.isOnNavMesh) { ((EnemyAI)this).agent.isStopped = true; } else { ((Behaviour)((EnemyAI)this).agent).enabled = false; } agentDisabledByGrab = false; } } private void CancelGrab() { PlayerControllerB? obj = grabbedPlayer; int num; if (obj == null || !obj.isPlayerDead) { PlayerControllerB? obj2 = grabbedPlayer; if ((obj2 == null || obj2.shipTeleporterId <= 0) && !((Object)(object)grabbedPlayer == (Object)null)) { num = ((!CanStayAttachedToPlayer(grabbedPlayer)) ? 1 : 0); goto IL_004c; } } num = 1; goto IL_004c; IL_004c: bool flag = (byte)num != 0; if (((NetworkBehaviour)this).IsServer) { StopGrabClientRpc(); } else { StopGrabServerRpc(); } StopGrabLocal(); attackCooldownTimer = attackCooldownSeconds; if (!((Behaviour)((EnemyAI)this).agent).enabled || !((EnemyAI)this).agent.isOnNavMesh) { ((EnemyAI)this).targetPlayer = null; locustState = LocustState.Idle; return; } if (flag) { ((EnemyAI)this).targetPlayer = null; BeginIdle(); return; } if ((Object)(object)releasedPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(releasedPlayer, false, false, true)) { ((EnemyAI)this).targetPlayer = releasedPlayer; } if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true)) { SetState(LocustState.Chase); } else { BeginIdle(); } } private void StopGrabLocal() { DetachFromGrabLocal(); releasedPlayer = null; landingFromGrab = false; StopBaseAnimation(); } private void FinishGrabLanding() { if (((EnemyAI)this).isEnemyDead || locustState != LocustState.Attack || !landingFromGrab) { return; } landingFromGrab = false; baseAnimationActive = false; baseAnimationFinished = true; attackCooldownTimer = attackCooldownSeconds; if (((NetworkBehaviour)this).IsOwner) { if ((Object)(object)releasedPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(releasedPlayer, false, false, true)) { ((EnemyAI)this).targetPlayer = releasedPlayer; SetState(LocustState.Chase); } else { ((EnemyAI)this).targetPlayer = null; BeginIdle(); } } } private void UpdateGrabPosition() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)grabbedPlayer == (Object)null)) { GetFaceGrabPose(grabbedPlayer, out var rootPosition, out var rootRotation); ((Component)this).transform.SetPositionAndRotation(rootPosition, rootRotation); } } private void GetFaceGrabPose(PlayerControllerB player, out Vector3 rootPosition, out Quaternion rootRotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)player == (Object)(object)Utility.LocalPlayer()) ? ((Component)player.gameplayCamera).transform : player.playerGlobalHead); rootRotation = val.rotation * Quaternion.Euler(faceLocalEulerAngles); rootPosition = val.TransformPoint(faceLocalPosition); } public void LeapStartFromAnimationEvent() { StartLeapMovement(); } public void DrillStartFromAnimationEvent() { if (!((EnemyAI)this).isEnemyDead && !((Object)(object)grabbedPlayer == (Object)null)) { drillActive = true; drillDamageTimer = 0f; AudioTools.PlayOneShot(((EnemyAI)this).creatureSFX, AudioProfile?.drillPierce); } } public void DrillEndFromAnimationEvent() { drillActive = false; } public void DrillSoundFromAnimationEvent() { AudioClip val = AudioProfile?.drill; if (!((Object)(object)((EnemyAI)this).creatureSFX == (Object)null) && !((Object)(object)val == (Object)null)) { ((EnemyAI)this).creatureSFX.loop = false; AudioTools.SwapClip(((EnemyAI)this).creatureSFX, val, true); } } private void StopDrillSound() { if (!((Object)(object)((EnemyAI)this).creatureSFX == (Object)null) && !((Object)(object)((EnemyAI)this).creatureSFX.clip != (Object)(object)AudioProfile?.drill)) { AudioTools.Stop(((EnemyAI)this).creatureSFX, false); } } public void GrabFinishedFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !((Object)(object)grabbedPlayer == (Object)null)) { StartGrabLanding(); } } public void GrabDetachFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !((Object)(object)grabbedPlayer == (Object)null)) { DetachFromGrab(); } } public void GrabLandFinishedFromAnimationEvent() { FinishGrabLanding(); } [Rpc(/*Could not decode attribute arguments.*/)] private void StartLeapMovementClientRpc(Vector3 startPosition, Quaternion startRotation, Vector3 targetPosition, Quaternion targetRotation) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(223574849u, val3, val, (SendTo)1, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref startPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref startRotation); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref targetRotation); ((NetworkBehaviour)this).__endSendRpc(ref val2, 223574849u, val3, val, (SendTo)1, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; BeginLeapMovement(startPosition, startRotation, targetPosition, targetRotation); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartGrabClientRpc(ulong playerClientId) { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1134667613u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerClientId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1134667613u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartGrab(playerClientId); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartGrabLandingClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2465832142u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2465832142u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartGrabLandingLocal(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DetachFromGrabClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(754663448u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 754663448u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; DetachFromGrabLocal(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StopGrabClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1195781029u, val3, val, (SendTo)7, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1195781029u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StopGrabLocal(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DamageGrabbedPlayerClientRpc(ulong playerClientId) { //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) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(399237183u, val3, val, (SendTo)7, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerClientId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 399237183u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!drillActive) { return; } PlayerControllerB? obj = grabbedPlayer; if (obj == null || obj.playerClientId != playerClientId) { return; } PlayerControllerB val4 = Utility.LocalPlayer(); if (val4.playerClientId == playerClientId && ((EnemyAI)this).PlayerIsTargetable(val4, false, false, true)) { val4.DamagePlayer(drillDamage, true, true, (CauseOfDeath)14, 0, false, default(Vector3)); if (Plugin.hasCoroner) { CoronerCompat.SetCorruptLocustDeathIfKilled(val4); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DamageGrabbedPlayerServerRpc(ulong playerClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0076: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2575025392u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerClientId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2575025392u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; DamageGrabbedPlayerClientRpc(playerClientId); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartGrabServerRpc(ulong playerClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0076: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2024131520u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, playerClientId); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2024131520u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartGrabClientRpc(playerClientId); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StartGrabLandingServerRpc() { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1010694055u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1010694055u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartGrabLandingClientRpc(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DetachFromGrabServerRpc() { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(216947674u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 216947674u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; DetachFromGrabClientRpc(); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void StopGrabServerRpc() { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1881922031u, val3, val, (SendTo)2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1881922031u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StopGrabClientRpc(); } } } protected override void __initializeVariables() { base.__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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(223574849u, new RpcReceiveHandler(__rpc_handler_223574849), "StartLeapMovementClientRpc"); ((NetworkBehaviour)this).__registerRpc(1134667613u, new RpcReceiveHandler(__rpc_handler_1134667613), "StartGrabClientRpc"); ((NetworkBehaviour)this).__registerRpc(2465832142u, new RpcReceiveHandler(__rpc_handler_2465832142), "StartGrabLandingClientRpc"); ((NetworkBehaviour)this).__registerRpc(754663448u, new RpcReceiveHandler(__rpc_handler_754663448), "DetachFromGrabClientRpc"); ((NetworkBehaviour)this).__registerRpc(1195781029u, new RpcReceiveHandler(__rpc_handler_1195781029), "StopGrabClientRpc"); ((NetworkBehaviour)this).__registerRpc(399237183u, new RpcReceiveHandler(__rpc_handler_399237183), "DamageGrabbedPlayerClientRpc"); ((NetworkBehaviour)this).__registerRpc(2575025392u, new RpcReceiveHandler(__rpc_handler_2575025392), "DamageGrabbedPlayerServerRpc"); ((NetworkBehaviour)this).__registerRpc(2024131520u, new RpcReceiveHandler(__rpc_handler_2024131520), "StartGrabServerRpc"); ((NetworkBehaviour)this).__registerRpc(1010694055u, new RpcReceiveHandler(__rpc_handler_1010694055), "StartGrabLandingServerRpc"); ((NetworkBehaviour)this).__registerRpc(216947674u, new RpcReceiveHandler(__rpc_handler_216947674), "DetachFromGrabServerRpc"); ((NetworkBehaviour)this).__registerRpc(1881922031u, new RpcReceiveHandler(__rpc_handler_1881922031), "StopGrabServerRpc"); base.__initializeRpcs(); } private static void __rpc_handler_223574849(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 startPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref startPosition); Quaternion startRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref startRotation); Vector3 targetPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref targetPosition); Quaternion targetRotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref targetRotation); target.__rpc_exec_stage = (__RpcExecStage)1; ((CorruptLocustEnemyAI)(object)target).StartLeapMovementClientRpc(startPosition, startRotation, targetPosition, targetRotation); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1134667613(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) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((CorruptLocustEnemyAI)(object)target).StartGrabClientRpc(playerClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2465832142(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; ((CorruptLocustEnemyAI)(object)target).StartGrabLandingClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_754663448(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; ((CorruptLocustEnemyAI)(object)target).DetachFromGrabClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1195781029(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; ((CorruptLocustEnemyAI)(object)target).StopGrabClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_399237183(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) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((CorruptLocustEnemyAI)(object)target).DamageGrabbedPlayerClientRpc(playerClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2575025392(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) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((CorruptLocustEnemyAI)(object)target).DamageGrabbedPlayerServerRpc(playerClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2024131520(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) { ulong playerClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((CorruptLocustEnemyAI)(object)target).StartGrabServerRpc(playerClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1010694055(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; ((CorruptLocustEnemyAI)(object)target).StartGrabLandingServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_216947674(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; ((CorruptLocustEnemyAI)(object)target).DetachFromGrabServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1881922031(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; ((CorruptLocustEnemyAI)(object)target).StopGrabServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "CorruptLocustEnemyAI"; } } public class LocustAnimationEvents : MonoBehaviour { private LocustEnemyBase? locustEnemy; private void Awake() { locustEnemy = ((Component)this).GetComponentInParent(); } public void AttackHit() { locustEnemy?.AttackHitFromAnimationEvent(); } public void LeapStart() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.LeapStartFromAnimationEvent(); } } public void AttackFinished() { locustEnemy?.AttackFinishedFromAnimationEvent(); } public void Saw() { locustEnemy?.SawSoundFromAnimationEvent(); } public void DrillStart() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.DrillStartFromAnimationEvent(); } } public void DrillEnd() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.DrillEndFromAnimationEvent(); } } public void DrillSound() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.DrillSoundFromAnimationEvent(); } } public void GrabFinished() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.GrabFinishedFromAnimationEvent(); } } public void GrabDetach() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.GrabDetachFromAnimationEvent(); } } public void GrabLandFinished() { if (locustEnemy is CorruptLocustEnemyAI corruptLocustEnemyAI) { corruptLocustEnemyAI.GrabLandFinishedFromAnimationEvent(); } } public void Hurt() { locustEnemy?.HurtSoundFromAnimationEvent(); } public void HurtFinished() { locustEnemy?.HurtFinishedFromAnimationEvent(); } public void Death() { } public void Idle() { locustEnemy?.IdleSoundFromAnimationEvent(); } public void WakeFinished() { locustEnemy?.WakeFinishedFromAnimationEvent(); } public void InvestigateFinished() { locustEnemy?.InvestigateFinishedFromAnimationEvent(); } } [CreateAssetMenu(menuName = "TemporalStorm/LocustAudioLibrary")] public class LocustAudioLibrary : ScriptableObject { public AudioClip hurt = null; public AudioClip idle = null; public AudioClip saw = null; public AudioClip drill = null; public AudioClip grab = null; public AudioClip drillPierce = null; } public class LocustEnemyAI : LocustEnemyBase { [Header("Audio")] [SerializeField] private LocustAudioLibrary audioProfile = null; [Header("Attack")] [SerializeField] [Min(0f)] private float attackRange = 2.25f; [SerializeField] [Min(0f)] private float attackDamageRange = 1.25f; [SerializeField] [Min(0f)] private float attackCooldownSeconds = 1.2f; [SerializeField] [Min(0f)] private int attackDamage = 7; private readonly RaycastHit[] attackHits = (RaycastHit[])(object)new RaycastHit[1]; protected override string EnemyLogName => "Locust"; protected override LocustAudioLibrary AudioProfile => audioProfile; protected override bool UsesHurtState => true; protected override float AttackRange => attackRange; protected override float AttackCooldownSeconds => attackCooldownSeconds; protected override bool RotateTowardTargetThisFrame { get { LocustState locustState = base.locustState; if ((uint)(locustState - 5) <= 1u) { return true; } return false; } } protected override float TargetTurnDegreesPerSecond => (locustState == LocustState.Attack) ? 540f : 360f; protected override bool ShouldHoldChasePosition(PlayerControllerB player) { return IsInAttackRange(player) && HasSightToTarget(player); } protected override void UpdateAttack(float deltaTime) { if (baseAnimationFinished) { if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true)) { SetState(LocustState.Chase); MoveToCurrentTarget(); } else { ((EnemyAI)this).targetPlayer = null; BeginIdle(); } } } protected override void OnAttackAnimationHit() { //IL_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((EnemyAI)this).targetPlayer == (Object)null)) { Vector3 position = ((Component)this).transform.position; Vector3 forward = ((Component)this).transform.forward; if (((NetworkBehaviour)this).IsServer) { DamagePlayersInAttackRangeClientRpc(position, forward); } else { DamagePlayersInAttackRangeServerRpc(position, forward); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DamagePlayersInAttackRangeServerRpc(Vector3 attackPosition, Vector3 attackForward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(977193497u, val3, val, (SendTo)2, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackForward); ((NetworkBehaviour)this).__endSendRpc(ref val2, 977193497u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; DamagePlayersInAttackRangeClientRpc(attackPosition, attackForward); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DamagePlayersInAttackRangeClientRpc(Vector3 attackPosition, Vector3 attackForward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1801569850u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackForward); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1801569850u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val4 = Utility.LocalPlayer(); Vector3 val5 = attackForward; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude <= 0.0001f) { return; } ((Vector3)(ref val5)).Normalize(); Vector3 val6 = attackPosition + val5 * 0.85f + Vector3.up * 0.45f; float num = attackDamageRange * attackDamageRange; float num2 = (attackRange + attackDamageRange) * (attackRange + attackDamageRange); if (!((EnemyAI)this).PlayerIsTargetable(val4, false, false, true)) { return; } Vector3 playerCenter = GetPlayerCenter(val4); Vector3 val7 = ((Component)val4).transform.position - attackPosition; val7.y = 0f; Vector3 val8 = playerCenter - val6; if (((Vector3)(ref val8)).sqrMagnitude > num && ((Vector3)(ref val7)).sqrMagnitude > num2) { return; } Vector3 val9 = playerCenter - val6; float magnitude = ((Vector3)(ref val9)).magnitude; if (!(magnitude > 0.001f) || Physics.RaycastNonAlloc(val6, val9 / magnitude, attackHits, magnitude, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) <= 0) { int num3 = attackDamage; val8 = default(Vector3); val4.DamagePlayer(num3, true, true, (CauseOfDeath)6, 0, false, val8); if (Plugin.hasCoroner) { CoronerCompat.SetLocustDeathIfKilled(val4); } } } protected override void __initializeVariables() { base.__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(977193497u, new RpcReceiveHandler(__rpc_handler_977193497), "DamagePlayersInAttackRangeServerRpc"); ((NetworkBehaviour)this).__registerRpc(1801569850u, new RpcReceiveHandler(__rpc_handler_1801569850), "DamagePlayersInAttackRangeClientRpc"); base.__initializeRpcs(); } private static void __rpc_handler_977193497(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 attackPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackPosition); Vector3 attackForward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackForward); target.__rpc_exec_stage = (__RpcExecStage)1; ((LocustEnemyAI)(object)target).DamagePlayersInAttackRangeServerRpc(attackPosition, attackForward); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1801569850(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 attackPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackPosition); Vector3 attackForward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackForward); target.__rpc_exec_stage = (__RpcExecStage)1; ((LocustEnemyAI)(object)target).DamagePlayersInAttackRangeClientRpc(attackPosition, attackForward); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "LocustEnemyAI"; } } public enum LocustState { None = -1, Sleep, Wake, Idle, Wander, Investigate, Chase, Attack, Hurt } public enum AnimationPlayback { Timed, Once, Event, Loop } public abstract class LocustEnemyBase : EnemyAI, ISmartAI { private static readonly int InSpawningAnimationHash = Animator.StringToHash("inSpawningAnimation"); private static readonly HashSet loggedMissingAgents = new HashSet(); private static readonly HashSet loggedMissingNodes = new HashSet(); private static readonly RaycastHit[] sightHits = (RaycastHit[])(object)new RaycastHit[12]; private static readonly Dictionary attachedLocustsByPlayer = new Dictionary(); private const int ShipDenRolls = 8; private const float ShipDenMinRange = 28f; private const float ShipDenMaxRange = 42f; private const float ShipDenNavRadius = 6f; private static int activeInsideLocustCount; private static int activeOutsideLocustCount; private static bool insideGroupHomeSet; private static bool outsideGroupHomeSet; private static Vector3 insideGroupHomePosition; private static Vector3 outsideGroupHomePosition; private static float lastInsideGroupPlayerSeenTime = -1000f; private static float lastOutsideGroupPlayerSeenTime = -1000f; [Header("Death")] [SerializeField] protected Collider bodyCollider = null; [SerializeField] private Light locustLight = null; [SerializeField] private MeshRenderer[] deadFlickerMeshRenderers = Array.Empty(); [SerializeField] [Min(0f)] private float deadLightFlickerIntensity = 0.18f; [SerializeField] [Min(0f)] private float deadEmissionFlickerIntensity = 1f; protected float seekingRange = 14f; protected float closeAwarenessRange = 3.4f; protected float viewWidth = 70f; protected float crouchDetectionMultiplier = 0.55f; protected float targetMemorySeconds = 3f; protected float walkSpeed = 3f; protected float sleepChance = 0.06f; protected float minSleepTime = 10f; protected float maxSleepTime = 26f; protected float minWanderDistance = 4f; protected float maxWanderDistance = 18f; protected float safeSpaceRange = 18f; protected float bodyInvestigationRange = 30f; protected float safeSpaceHeightTolerance = 2.25f; protected float sleepSpacing = 4.5f; protected float runSpeed = 5.5f; protected float dieAnimationSeconds = 1.25f; protected float idleAnimationSeconds = 4f; protected float sleepAnimationSeconds = 1.75f; protected float animationCrossFadeSeconds = 0.1f; protected float safeSleepSeconds = 20f; protected float attackHeightTolerance = 1.15f; protected LocustState locustState = LocustState.None; protected float aiTimer; protected float sleepTimer; protected float targetLostTimer; protected float attackCooldownTimer; protected bool attackDamageDone; protected float stuckTimer; protected float stuckRepathTimer; protected Vector3 stuckPosition; protected Vector3 networkVelocity; protected float networkTargetYaw; protected float lastSyncedYaw; protected bool baseAnimationActive; protected bool baseAnimationFinished = true; protected LocustState baseAnimationState = LocustState.None; protected string baseAnimationName = string.Empty; protected int baseAnimationHash; protected int baseAnimationLayer = -1; protected float baseAnimationSeconds = 1f; protected float baseAnimationElapsedSeconds; protected float baseAnimationCrossFadeTimer; protected AnimationPlayback baseAnimationPlayback; protected Coroutine? baseAnimationRoutine; private MaterialPropertyBlock deadEmissionPropertyBlock = null; private int emissiveColorPropertyId; private readonly SmartPathTask movementPathTask = new SmartPathTask(); private readonly List movementPathPositions = new List(); private readonly List movementPathScores = new List(); private Coroutine? deadVisualFlickerRoutine; private Coroutine? idleGlowRoutine; private float normalLightIntensity; private bool relocatingToSleepSpot; private bool investigateAnimationStarted; private float investigateAnimationDelayTimer; private bool movementPathRequested; private bool smartPathfindingRegistered; private float idleTimer; private float movementPathRequestTimer; private LocustState movementPathState = LocustState.None; private LocustState stateBeforeHurt = LocustState.Idle; private Vector3 safeRestOffset; protected abstract string EnemyLogName { get; } protected virtual bool UsesHurtState => false; protected virtual bool RotateTowardTargetThisFrame => locustState == LocustState.Chase; protected virtual float TargetTurnDegreesPerSecond => 360f; protected virtual LocustAudioLibrary? AudioProfile => null; internal AudioClip?[] AudioClips => (AudioClip?[])(object)new AudioClip[6] { AudioProfile?.hurt, AudioProfile?.idle, AudioProfile?.saw, AudioProfile?.drill, AudioProfile?.grab, AudioProfile?.drillPierce }; protected virtual float AttackRange => 0f; protected virtual float AttackAngleDegrees => 24f; protected virtual bool HoldsAttackRangeDuringCooldown => false; protected virtual float AttackCooldownSeconds => 0f; private int ActiveLocustCount { get { return base.isOutside ? activeOutsideLocustCount : activeInsideLocustCount; } set { if (base.isOutside) { activeOutsideLocustCount = value; } else { activeInsideLocustCount = value; } } } private bool GroupHomeSet { get { return base.isOutside ? outsideGroupHomeSet : insideGroupHomeSet; } set { if (base.isOutside) { outsideGroupHomeSet = value; } else { insideGroupHomeSet = value; } } } private Vector3 GroupHomePosition { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return base.isOutside ? outsideGroupHomePosition : insideGroupHomePosition; } set { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (base.isOutside) { outsideGroupHomePosition = value; } else { insideGroupHomePosition = value; } } } private float LastGroupPlayerSeenTime { get { return base.isOutside ? lastOutsideGroupPlayerSeenTime : lastInsideGroupPlayerSeenTime; } set { if (base.isOutside) { lastOutsideGroupPlayerSeenTime = value; } else { lastInsideGroupPlayerSeenTime = value; } } } protected static bool PlayerHasAnotherAttachedLocust(ulong playerClientId, LocustEnemyBase locust) { LocustEnemyBase value; return attachedLocustsByPlayer.TryGetValue(playerClientId, out value) && (Object)(object)value != (Object)(object)locust; } protected static void AttachLocustToPlayer(ulong playerClientId, LocustEnemyBase locust) { attachedLocustsByPlayer[playerClientId] = locust; } protected static void ClearAttachedLocust(ulong playerClientId, LocustEnemyBase locust) { if (attachedLocustsByPlayer.TryGetValue(playerClientId, out LocustEnemyBase value) && (Object)(object)value == (Object)(object)locust) { attachedLocustsByPlayer.Remove(playerClientId); } } internal static void WakeNearbyLocusts(Vector3 position, float range) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RoundManager.Instance == (Object)null) { return; } float num = range * range; for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { if (RoundManager.Instance.SpawnedEnemies[i] is LocustEnemyBase locustEnemyBase && locustEnemyBase.CanWakeFromExternalStimulus()) { Vector3 val = ((Component)locustEnemyBase).transform.position - position; if (!(((Vector3)(ref val)).sqrMagnitude > num)) { locustEnemyBase.BeginWander(); } } } } internal static void WakeForWarningLevel(int warningLevel) { if ((Object)(object)RoundManager.Instance == (Object)null) { return; } if (1 == 0) { } float num = ((warningLevel >= 3) ? 0.85f : (warningLevel switch { 1 => 0.25f, 2 => 0.55f, _ => 0f, })); if (1 == 0) { } float num2 = num; if (num2 <= 0f) { return; } for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { if (RoundManager.Instance.SpawnedEnemies[i] is LocustEnemyBase locustEnemyBase && locustEnemyBase.CanWakeFromExternalStimulus() && Random.value < num2) { locustEnemyBase.BeginWander(); } } } public override void Start() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Start(); deadEmissionPropertyBlock = new MaterialPropertyBlock(); emissiveColorPropertyId = Shader.PropertyToID("_EmissiveColor"); Light obj = locustLight; normalLightIntensity = ((obj != null) ? obj.intensity : 0f); if ((Object)(object)base.agent == (Object)null) { if (loggedMissingAgents.Add(EnemyLogName)) { Log.Error(EnemyLogName + " is missing a nav mesh agent"); } ((Behaviour)this).enabled = false; return; } if (((NetworkBehaviour)this).IsOwner) { SmartPathfinding.RegisterSmartAgent(base.agent); smartPathfindingRegistered = true; } if (!GroupHomeSet) { GroupHomeSet = true; if (base.isOutside) { Vector3 position = StartOfRound.Instance.shipLandingPosition.position; Vector3 groupHomePosition = position; Vector3 val = default(Vector3); for (int i = 0; i < 8; i++) { float num = Random.Range(0f, MathF.PI * 2f); float num2 = Random.Range(28f, 42f); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2); groupHomePosition = RoundManager.Instance.GetNavMeshPosition(position + val, RoundManager.Instance.navHit, 6f, base.agentMask); if (RoundManager.Instance.GotNavMeshPositionResult) { break; } } GroupHomePosition = groupHomePosition; } else { GroupHomePosition = ((Component)this).transform.position; } LastGroupPlayerSeenTime = Time.time; } float num3 = Mathf.Max(minWanderDistance, Mathf.Min(safeSpaceRange, maxWanderDistance)); float num4 = Random.Range(0f, MathF.PI * 2f); float num5 = Random.Range(minWanderDistance, num3); safeRestOffset = new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * num5; ActiveLocustCount++; base.ventAnimationFinished = true; base.agent.speed = walkSpeed; base.agent.avoidancePriority = 40 + base.thisEnemyIndex % 40; base.updatePositionThreshold = 0.45f; base.syncMovementSpeed = 0.1f; aiTimer = Random.Range(0f, base.AIIntervalTime); stuckPosition = ((Component)this).transform.position; networkTargetYaw = ((Component)this).transform.eulerAngles.y; lastSyncedYaw = networkTargetYaw; Animator creatureAnimator = base.creatureAnimator; baseAnimationLayer = ((creatureAnimator == null || creatureAnimator.layerCount <= 0) ? (-1) : 0); Animator creatureAnimator2 = base.creatureAnimator; if (creatureAnimator2 != null) { creatureAnimator2.speed = 0f; } if (!((NetworkBehaviour)this).IsOwner) { locustState = LocustState.Idle; ApplyRemoteState(locustState); return; } SetState(LocustState.Idle); if (ShouldReturnHome()) { BeginWander(); } } public override void OnDestroy() { if ((Object)(object)base.agent != (Object)null && smartPathfindingRegistered) { SmartPathfinding.UnregisterSmartAgent(base.agent); } ActiveLocustCount = Mathf.Max(0, ActiveLocustCount - 1); if (ActiveLocustCount == 0) { GroupHomeSet = false; LastGroupPlayerSeenTime = -1000f; } movementPathTask.Dispose(); StopBaseAnimation(); CoroutineTools.Stop((MonoBehaviour)(object)this, ref deadVisualFlickerRoutine); CoroutineTools.Stop((MonoBehaviour)(object)this, ref idleGlowRoutine); ((EnemyAI)this).OnDestroy(); } public override void Update() { //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (base.isEnemyDead) { return; } if (!((NetworkBehaviour)this).IsOwner) { if (base.isClientCalculatingAI) { ((EnemyAI)this).SetClientCalculatingAI(false); } UpdateRemoteMotion(); return; } if (!base.isClientCalculatingAI && (Object)(object)base.agent != (Object)null) { ((EnemyAI)this).SetClientCalculatingAI(true); } if (!base.ventAnimationFinished) { base.ventAnimationFinished = true; Animator creatureAnimator = base.creatureAnimator; if (creatureAnimator != null) { creatureAnimator.SetBool(InSpawningAnimationHash, false); } } UpdateStunTimers(); aiTimer -= Time.deltaTime; if (aiTimer <= 0f) { ((EnemyAI)this).DoAIInterval(); aiTimer = base.AIIntervalTime + Random.Range(-0.015f, 0.015f); } if (RotateTowardTargetThisFrame && (Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { RotateToward(((Component)base.targetPlayer).transform.position, TargetTurnDegreesPerSecond, Time.deltaTime); } SyncRotationIfNeeded(); } public override void DoAIInterval() { if (!((NetworkBehaviour)this).IsOwner || base.isEnemyDead) { return; } if (!((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; return; } if (base.stunNormalizedTimer > 0f) { base.agent.isStopped = true; base.moveTowardsDestination = false; ((EnemyAI)this).DoAIInterval(); return; } if (attackCooldownTimer > 0f) { attackCooldownTimer -= base.AIIntervalTime; } if (stuckRepathTimer > 0f) { stuckRepathTimer -= base.AIIntervalTime; } ProcessMovementPathTask(); UpdateTargetMemory(); switch (locustState) { case LocustState.Sleep: DoSleepInterval(); break; case LocustState.Wake: if (baseAnimationFinished) { BeginIdle(); } break; case LocustState.Idle: DoIdleInterval(); break; case LocustState.Wander: DoWanderInterval(); break; case LocustState.Investigate: DoInvestigateInterval(); break; case LocustState.Chase: DoChaseInterval(); break; case LocustState.Attack: UpdateAttack(base.AIIntervalTime); break; case LocustState.Hurt: UpdateHurt(); break; } HandleStuck(); ((EnemyAI)this).DoAIInterval(); } public override void OnCollideWithPlayer(Collider other) { ((EnemyAI)this).OnCollideWithPlayer(other); if (!((NetworkBehaviour)this).IsOwner || locustState == LocustState.Sleep) { return; } PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if (!((Object)(object)val == (Object)null)) { relocatingToSleepSpot = false; base.targetPlayer = val; targetLostTimer = targetMemorySeconds; AlertGroup(); if (locustState != LocustState.Attack && (!UsesHurtState || locustState != LocustState.Hurt)) { InterruptSleepForTarget(); SetState(LocustState.Chase); } } } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && !(noiseLoudness < 0.65f) && locustState != LocustState.Sleep && locustState != LocustState.Investigate && locustState != LocustState.Chase && locustState != LocustState.Attack && (!UsesHurtState || locustState != LocustState.Hurt)) { relocatingToSleepSpot = false; SetState(LocustState.Wander); StartMovementPathTask(LocustState.Wander, noisePosition); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, false, hitID); if (!base.isEnemyDead && ((NetworkBehaviour)this).IsOwner) { base.enemyHP -= force; if (base.enemyHP <= 0) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } else { OnLocustHit(playerWhoHit); } } } public override void KillEnemy(bool destroy = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; CancelPathTasks(); StopBaseAnimation(); base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; base.targetPlayer = null; Collider obj = bodyCollider; if (obj != null) { obj.enabled = false; } CoroutineTools.Stop((MonoBehaviour)(object)this, ref idleGlowRoutine); ((EnemyAI)this).KillEnemy(destroy); if (!destroy) { StartBaseAnimation(LocustState.None, "die", dieAnimationSeconds, AnimationPlayback.Timed, restart: true, 0f); if ((Object)(object)locustLight != (Object)null || deadFlickerMeshRenderers.Length != 0) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref deadVisualFlickerRoutine, FlickerDeadVisuals()); } if (((NetworkBehaviour)this).IsOwner) { AlertLocustsToBody(position); } } } public override Transform GetRadarHeadTransform() { return base.eye; } protected abstract void UpdateAttack(float deltaTime); protected virtual void UpdateHurt() { if (baseAnimationFinished) { if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { SetState(LocustState.Chase); } else { SetState((stateBeforeHurt == LocustState.Sleep) ? LocustState.Idle : stateBeforeHurt); } } } protected virtual void OnLocustHit(PlayerControllerB? playerWhoHit) { if (UsesHurtState) { if ((Object)(object)playerWhoHit != (Object)null) { base.targetPlayer = playerWhoHit; targetLostTimer = targetMemorySeconds; } if (locustState != LocustState.Hurt) { stateBeforeHurt = locustState; } SetState(LocustState.Hurt); return; } if (locustState == LocustState.Sleep && (Object)(object)playerWhoHit == (Object)null) { SetState(LocustState.Wake); } if (!((Object)(object)playerWhoHit == (Object)null)) { base.targetPlayer = playerWhoHit; targetLostTimer = targetMemorySeconds; InterruptSleepForTarget(); if (locustState != LocustState.Attack) { SetState(LocustState.Chase); } } } protected virtual void OnLeavingIdle() { } protected virtual void ApplyChaseState(bool restartAnimation) { CancelPathTasks(); base.agent.speed = runSpeed; base.agent.isStopped = false; base.moveTowardsDestination = true; StartBaseAnimation(LocustState.Chase, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restartAnimation, 0f); } protected virtual void ApplyAttackState() { CancelPathTasks(); base.agent.isStopped = true; base.moveTowardsDestination = false; StartBaseAnimation(LocustState.Attack, "attack", 0f, AnimationPlayback.Event, restart: true, 0f); } protected virtual void ApplyHurtState() { CancelPathTasks(); base.agent.isStopped = true; base.moveTowardsDestination = false; StartBaseAnimation(LocustState.Hurt, "hurt", 0f, AnimationPlayback.Event, restart: true, 0f); } public void AttackHitFromAnimationEvent() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && locustState == LocustState.Attack && !attackDamageDone) { attackDamageDone = true; OnAttackAnimationHit(); } } protected virtual void OnAttackAnimationHit() { } public void AttackFinishedFromAnimationEvent() { if (!base.isEnemyDead && locustState == LocustState.Attack) { OnAttackAnimationFinished(); } } protected virtual void OnAttackAnimationFinished() { attackCooldownTimer = AttackCooldownSeconds; baseAnimationActive = false; baseAnimationFinished = true; } public void HurtFinishedFromAnimationEvent() { if (!base.isEnemyDead && locustState == LocustState.Hurt) { baseAnimationActive = false; baseAnimationFinished = true; } } public void WakeFinishedFromAnimationEvent() { if (!base.isEnemyDead && locustState == LocustState.Wake) { baseAnimationActive = false; baseAnimationFinished = true; if (((NetworkBehaviour)this).IsOwner) { BeginIdle(); } } } public void HurtSoundFromAnimationEvent() { if (!base.isEnemyDead) { AudioTools.PlayOneShot(base.creatureVoice, AudioProfile?.hurt); } } public void SawSoundFromAnimationEvent() { if (!base.isEnemyDead) { OnSawSoundFromAnimationEvent(); } } protected virtual void OnSawSoundFromAnimationEvent() { } public void IdleSoundFromAnimationEvent() { if (base.isEnemyDead || locustState != LocustState.Idle || Random.value >= 0.1f) { return; } AudioClip val = AudioProfile?.idle; if (!((Object)(object)val == (Object)null)) { AudioTools.PlayOneShot(base.creatureVoice, val); Light obj = locustLight; if (obj != null) { ((Behaviour)obj).enabled = true; } if ((Object)(object)locustLight != (Object)null || deadFlickerMeshRenderers.Length != 0) { CoroutineTools.Restart((MonoBehaviour)(object)this, ref idleGlowRoutine, GlowForIdleSound(val.length)); } } } public void InvestigateFinishedFromAnimationEvent() { if (!base.isEnemyDead && locustState == LocustState.Investigate && investigateAnimationStarted) { baseAnimationActive = false; baseAnimationFinished = true; if (((NetworkBehaviour)this).IsOwner) { BeginIdle(); } } } protected void BeginIdle() { SetState(LocustState.Idle); } protected void BeginWander() { relocatingToSleepSpot = false; SetState(LocustState.Wander); ChooseWanderDestination(); } private bool CanWakeFromExternalStimulus() { bool flag = ((NetworkBehaviour)this).IsOwner && !base.isEnemyDead; bool flag2 = flag; if (flag2) { LocustState locustState = this.locustState; bool flag3 = (uint)(locustState - 5) <= 1u; flag2 = !flag3; } return flag2 && (!UsesHurtState || this.locustState != LocustState.Hurt); } protected void InterruptSleepForTarget() { LocustState locustState = this.locustState; if (locustState == LocustState.Sleep || locustState == LocustState.Wake) { StopBaseAnimation(); } } protected void ResetAttack() { attackDamageDone = false; } protected void StartTravelAnimation(LocustState animationState) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!base.agent.pathPending) { Vector3 velocity = base.agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.04f) { StartBaseAnimation(animationState, "walk", 1f, AnimationPlayback.Loop, restart: false, 0f); return; } } StartBaseAnimation(animationState, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); } private void StartMovementPathTask(LocustState pathState, Vector3 position) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) movementPathPositions.Clear(); movementPathScores.Clear(); movementPathPositions.Add(position); movementPathScores.Add(0f); StartMovementPathTask(pathState); } private void StartMovementPathTask(LocustState pathState) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (movementPathPositions.Count != 0) { movementPathTask.Dispose(); movementPathRequested = true; movementPathRequestTimer = 0f; movementPathState = pathState; base.agent.isStopped = true; base.moveTowardsDestination = false; base.movingTowardsTargetPlayer = false; movementPathTask.StartPathTask(base.agent, AgentExtensions.GetPathOrigin(base.agent), movementPathPositions, (SmartPathfindingLinkFlags)0); } } private void ProcessMovementPathTask() { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) if (!movementPathRequested) { return; } if (!movementPathTask.IsComplete) { movementPathRequestTimer += base.AIIntervalTime; if (!(movementPathRequestTimer <= 1.25f)) { movementPathTask.Dispose(); movementPathPositions.Clear(); movementPathScores.Clear(); movementPathRequested = false; movementPathRequestTimer = 0f; movementPathState = LocustState.None; BeginIdle(); } return; } movementPathRequested = false; movementPathRequestTimer = 0f; LocustState locustState = movementPathState; movementPathState = LocustState.None; if (this.locustState != locustState) { movementPathTask.Dispose(); movementPathPositions.Clear(); movementPathScores.Clear(); return; } int num = -1; float num2 = float.MinValue; for (int i = 0; i < movementPathPositions.Count; i++) { if (movementPathTask.PathSucceeded(i)) { float num3 = movementPathScores[i] - movementPathTask.GetPathLength(i) * 0.05f; if (!(num3 <= num2)) { num2 = num3; num = i; } } } SmartPathDestination? val = ((num >= 0) ? movementPathTask.GetResult(num) : ((SmartPathDestination?)null)); movementPathTask.Dispose(); movementPathPositions.Clear(); movementPathScores.Clear(); if (val.HasValue) { GoToSmartPathDestination(val.Value); } else { BeginIdle(); } } public void GoToSmartPathDestination(in SmartPathDestination pathDestination) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0054: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)RoundManager.Instance == (Object)null)) { base.agent.isStopped = false; base.moveTowardsDestination = true; base.movingTowardsTargetPlayer = false; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(((SmartPathDestination)(ref pathDestination)).Position, RoundManager.Instance.navHit, 2f, base.agentMask); ((EnemyAI)this).SetDestinationToPosition(navMeshPosition, false); StartTravelAnimation(locustState); } } protected bool IsTargetBlockedByWall(PlayerControllerB player) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = GetPlayerCenter(player) - base.eye.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.001f) { return false; } int num = Physics.RaycastNonAlloc(base.eye.position, val / magnitude, sightHits, magnitude, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); float num2 = float.MaxValue; Transform val2 = null; for (int i = 0; i < num; i++) { RaycastHit val3 = sightHits[i]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform) && !(((RaycastHit)(ref val3)).distance >= num2)) { num2 = ((RaycastHit)(ref val3)).distance; val2 = ((RaycastHit)(ref val3)).transform; } } return (Object)(object)val2 != (Object)null; } protected bool HasSightToTarget(PlayerControllerB player) { return !IsTargetBlockedByWall(player); } protected bool IsWithinAngle(Vector3 forward, Vector3 direction, float angleDegrees) { //IL_001d: 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) float sqrMagnitude = ((Vector3)(ref direction)).sqrMagnitude; if (sqrMagnitude <= 0.0001f) { return true; } float num = Vector3.Dot(forward, direction); float num2 = Mathf.Cos(angleDegrees * (MathF.PI / 180f)); return num >= num2 * Mathf.Sqrt(sqrMagnitude); } protected Vector3 GetPlayerCenter(PlayerControllerB player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) return ((Component)player.gameplayCamera).transform.position - Vector3.up * 0.15f; } protected void RotateToward(Vector3 worldPosition, float degreesPerSecond, float deltaTime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) Vector3 val = worldPosition - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude <= 0.0001f)) { Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val2, degreesPerSecond * deltaTime); } } protected void FaceTarget(Vector3 worldPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Vector3 val = worldPosition - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude <= 0.0001f)) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } } protected void SetState(LocustState nextState) { if (base.isEnemyDead) { return; } if (locustState == nextState) { ApplyState(nextState, restartAnimation: false); return; } if (nextState != LocustState.Idle) { OnLeavingIdle(); } locustState = nextState; ApplyState(nextState, restartAnimation: true); if (((NetworkBehaviour)this).IsServer) { SyncStateClientRpc((int)nextState); } else { SyncStateServerRpc((int)nextState); } } protected void StartBaseAnimation(LocustState animationState, string animationName, float animationSeconds, AnimationPlayback playback, bool restart, float normalizedStart) { if ((base.isEnemyDead && animationState != LocustState.None) || (!restart && baseAnimationActive && baseAnimationState == animationState && baseAnimationName == animationName && baseAnimationPlayback == playback)) { return; } if ((Object)(object)base.creatureAnimator == (Object)null || baseAnimationLayer < 0 || baseAnimationLayer >= base.creatureAnimator.layerCount || string.IsNullOrEmpty(animationName)) { ClearBaseAnimation(); return; } int num = Animator.StringToHash(base.creatureAnimator.GetLayerName(baseAnimationLayer) + "." + animationName); if (!base.creatureAnimator.HasState(baseAnimationLayer, num)) { ClearBaseAnimation(); return; } string text = baseAnimationName; bool flag = playback != AnimationPlayback.Loop && animationCrossFadeSeconds > 0f && text.Length > 0 && text != animationName; baseAnimationActive = true; baseAnimationFinished = false; baseAnimationState = animationState; baseAnimationName = animationName; baseAnimationHash = num; baseAnimationSeconds = animationSeconds; baseAnimationElapsedSeconds = Mathf.Clamp01(normalizedStart) * animationSeconds; baseAnimationCrossFadeTimer = animationCrossFadeSeconds; baseAnimationPlayback = playback; base.creatureAnimator.speed = 1f; switch (playback) { case AnimationPlayback.Loop: baseAnimationCrossFadeTimer = 0f; base.creatureAnimator.Play(baseAnimationHash, baseAnimationLayer, Mathf.Clamp01(normalizedStart)); break; case AnimationPlayback.Timed: baseAnimationCrossFadeTimer = 0f; if (flag) { base.creatureAnimator.CrossFadeInFixedTime(baseAnimationHash, animationCrossFadeSeconds, baseAnimationLayer, Mathf.Clamp01(normalizedStart)); } else { base.creatureAnimator.Play(baseAnimationHash, baseAnimationLayer, Mathf.Clamp01(normalizedStart)); } break; default: base.creatureAnimator.CrossFadeInFixedTime(baseAnimationHash, animationCrossFadeSeconds, baseAnimationLayer, 0f); break; } CoroutineTools.Restart((MonoBehaviour)(object)this, ref baseAnimationRoutine, BaseAnimationRoutine()); } protected void StopBaseAnimation() { CoroutineTools.Stop((MonoBehaviour)(object)this, ref baseAnimationRoutine); ClearBaseAnimation(); } protected Vector3 BlendLocustDestination(Vector3 destination) { //IL_0012: 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) //IL_020a: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RoundManager.Instance == (Object)null) { return destination; } if (ActiveLocustCount >= 5 && base.thisEnemyIndex % 5 == 0) { return destination; } Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; Vector3 position = ((Component)this).transform.position; int num = 0; for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { EnemyAI val3 = RoundManager.Instance.SpawnedEnemies[i]; if ((Object)(object)val3 == (Object)null || (Object)(object)val3 == (Object)(object)this || val3.isEnemyDead || !(val3 is LocustEnemyBase locustEnemyBase) || ((EnemyAI)locustEnemyBase).isOutside != base.isOutside) { continue; } Vector3 val4 = ((Component)locustEnemyBase).transform.position - position; if (Mathf.Abs(val4.y) > safeSpaceHeightTolerance) { continue; } val4.y = 0f; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (!(sqrMagnitude > 144f)) { float num2 = sleepSpacing * 1.6f; if (sqrMagnitude > 0.01f && sqrMagnitude < num2 * num2) { float num3 = Mathf.Sqrt(sqrMagnitude); val2 -= val4 / num3 * (num2 - num3); } val += ((Component)locustEnemyBase).transform.position; num++; } } if (num == 0) { return destination; } val /= (float)num; val.y = destination.y; Vector3 val5 = (destination + val) * 0.5f; val5 += val2 * 0.7f; val5.y = destination.y; return Vector3.Lerp(destination, val5, 0.2f); } protected virtual bool CanAttackTargetAtCurrentHeight(PlayerControllerB player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(((Component)player).transform.position.y - ((Component)this).transform.position.y) <= attackHeightTolerance; } protected bool IsInAttackRange(PlayerControllerB player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude <= AttackRange * AttackRange && CanAttackTargetAtCurrentHeight(player); } protected virtual bool ShouldHoldChasePosition(PlayerControllerB player) { return HoldsAttackRangeDuringCooldown && attackCooldownTimer > 0f && IsInAttackRange(player) && HasSightToTarget(player); } protected virtual bool CanStartAttack(PlayerControllerB player, Vector3 flatDirectionToPlayer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) return attackCooldownTimer <= 0f && IsInAttackRange(player) && IsWithinAngle(((Component)this).transform.forward, flatDirectionToPlayer, AttackAngleDegrees) && HasSightToTarget(player); } protected virtual void OnStartingAttack(PlayerControllerB player) { } protected virtual Vector3 GetChaseDestination(PlayerControllerB player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ((Component)player).transform.position; } protected virtual bool MoveToCurrentTarget() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { return false; } base.agent.isStopped = false; base.moveTowardsDestination = true; base.movingTowardsTargetPlayer = false; ((EnemyAI)this).SetDestinationToPosition(GetChaseDestination(base.targetPlayer), false); return true; } protected bool HasTargetToChase() { return (Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true); } protected virtual void DoChaseInterval() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.targetPlayer != (Object)null) { if (!((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { base.targetPlayer = null; BeginIdle(); return; } Vector3 flatDirectionToPlayer = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position; flatDirectionToPlayer.y = 0f; if (CanStartAttack(base.targetPlayer, flatDirectionToPlayer)) { ResetAttack(); OnStartingAttack(base.targetPlayer); SetState(LocustState.Attack); return; } if (ShouldHoldChasePosition(base.targetPlayer)) { base.agent.isStopped = true; base.moveTowardsDestination = false; RotateToward(((Component)base.targetPlayer).transform.position, 360f, base.AIIntervalTime); StartBaseAnimation(LocustState.Chase, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); return; } base.agent.speed = runSpeed; base.agent.isStopped = false; base.moveTowardsDestination = true; MoveToCurrentTarget(); if (!base.agent.pathPending) { Vector3 velocity = base.agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.04f) { StartBaseAnimation(LocustState.Chase, "run", 1f, AnimationPlayback.Loop, restart: false, 0f); return; } } StartBaseAnimation(LocustState.Chase, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); } else { BeginIdle(); } } private bool ShouldReturnHome() { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!GroupHomeSet) { return false; } Vector3 val = ((Component)this).transform.position - GroupHomePosition; if (Mathf.Abs(val.y) > safeSpaceHeightTolerance) { return true; } val.y = 0f; float num = safeSpaceRange + 1f; return ((Vector3)(ref val)).sqrMagnitude > num * num; } private bool IsSafeToSleep() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (!GroupHomeSet || Time.time - LastGroupPlayerSeenTime < safeSleepSeconds || (Object)(object)RoundManager.Instance == (Object)null) { return false; } float num = sleepSpacing * sleepSpacing; for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { if (!(RoundManager.Instance.SpawnedEnemies[i] is LocustEnemyBase locustEnemyBase) || (Object)(object)locustEnemyBase == (Object)(object)this || ((EnemyAI)locustEnemyBase).isEnemyDead || ((EnemyAI)locustEnemyBase).isOutside != base.isOutside || locustEnemyBase.locustState != LocustState.Sleep) { continue; } Vector3 val = ((Component)locustEnemyBase).transform.position - ((Component)this).transform.position; if (!(Mathf.Abs(val.y) > safeSpaceHeightTolerance)) { val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < num) { return false; } } } return IsNearSafeSpace(((Component)this).transform.position); } private void SetHomeDestination() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = GroupHomePosition + safeRestOffset; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val, RoundManager.Instance.navHit, 3f, base.agentMask); Vector3 position = ((Mathf.Abs(navMeshPosition.y - GroupHomePosition.y) <= safeSpaceHeightTolerance) ? navMeshPosition : GroupHomePosition); StartMovementPathTask(LocustState.Wander, position); } private bool IsNearSafeSpace(Vector3 position) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references) if (!GroupHomeSet) { return false; } Vector3 val = position - GroupHomePosition; if (Mathf.Abs(val.y) > safeSpaceHeightTolerance) { return false; } val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude <= safeSpaceRange * safeSpaceRange; } private bool IsNearBodyInvestigationRange(Vector3 position) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references) if (!GroupHomeSet) { return false; } Vector3 val = position - GroupHomePosition; if (Mathf.Abs(val.y) > safeSpaceHeightTolerance) { return false; } val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude <= bodyInvestigationRange * bodyInvestigationRange; } private void AlertLocustsToBody(Vector3 bodyPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0121: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (!IsNearBodyInvestigationRange(bodyPosition) || (Object)(object)RoundManager.Instance == (Object)null) { return; } for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { LocustEnemyBase locustEnemyBase = RoundManager.Instance.SpawnedEnemies[i] as LocustEnemyBase; bool flag = locustEnemyBase == null || (Object)(object)locustEnemyBase == (Object)(object)this || !((NetworkBehaviour)locustEnemyBase).IsOwner || ((EnemyAI)locustEnemyBase).isEnemyDead || ((EnemyAI)locustEnemyBase).isOutside != base.isOutside; bool flag2 = flag; if (!flag2) { LocustState locustState = locustEnemyBase.locustState; bool flag3 = (uint)locustState <= 3u; flag2 = !flag3; } if (!flag2) { locustEnemyBase.CancelPathTasks(); ((EnemyAI)locustEnemyBase).targetPlayer = null; locustEnemyBase.targetLostTimer = 0f; locustEnemyBase.investigateAnimationStarted = false; locustEnemyBase.investigateAnimationDelayTimer = 0f; ((EnemyAI)locustEnemyBase).agent.speed = locustEnemyBase.walkSpeed; Vector3 val = ((Component)locustEnemyBase).transform.position - bodyPosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.01f) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; ((Vector3)(ref val))..ctor(normalized.x, 0f, normalized.y); } Vector3 val2 = bodyPosition + ((Vector3)(ref val)).normalized * 1.25f; Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val2, RoundManager.Instance.navHit, 5f, ((EnemyAI)locustEnemyBase).agentMask); locustEnemyBase.StopBaseAnimation(); locustEnemyBase.SetState(LocustState.Investigate); locustEnemyBase.StartMovementPathTask(LocustState.Investigate, navMeshPosition); break; } } } private void AlertGroup() { LastGroupPlayerSeenTime = Time.time; if ((Object)(object)RoundManager.Instance == (Object)null) { return; } for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++) { if (RoundManager.Instance.SpawnedEnemies[i] is LocustEnemyBase locustEnemyBase && (Object)(object)locustEnemyBase != (Object)(object)this && ((EnemyAI)locustEnemyBase).isOutside == base.isOutside) { locustEnemyBase.WakeFromGroupAlert(); } } } private void WakeFromGroupAlert() { if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && locustState == LocustState.Sleep) { SetState(LocustState.Wake); } } private void UpdateTargetMemory() { bool isEnemyDead = base.isEnemyDead; bool flag = isEnemyDead; if (!flag) { LocustState locustState = this.locustState; bool flag2 = (((uint)locustState <= 1u || locustState == LocustState.Attack) ? true : false); flag = flag2; } if (flag || (UsesHurtState && this.locustState == LocustState.Hurt)) { return; } if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true) && IsTargetVisible(base.targetPlayer, seekingRange)) { relocatingToSleepSpot = false; targetLostTimer = targetMemorySeconds; AlertGroup(); if (this.locustState != LocustState.Chase) { SetState(LocustState.Chase); } return; } PlayerControllerB val = FindVisibleTarget(seekingRange); if ((Object)(object)val != (Object)null) { relocatingToSleepSpot = false; base.targetPlayer = val; targetLostTimer = targetMemorySeconds; AlertGroup(); InterruptSleepForTarget(); if (this.locustState != LocustState.Chase) { SetState(LocustState.Chase); } } else { if ((Object)(object)base.targetPlayer == (Object)null) { return; } targetLostTimer -= base.AIIntervalTime; if (!(targetLostTimer > 0f) || !((Object)(object)base.targetPlayer != (Object)null) || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { base.targetPlayer = null; if (this.locustState == LocustState.Chase) { BeginIdle(); } } } } private void DoSleepInterval() { sleepTimer -= base.AIIntervalTime; if (sleepTimer <= 0f) { SetState(LocustState.Wake); } } private void DoIdleInterval() { if (HasTargetToChase()) { relocatingToSleepSpot = false; SetState(LocustState.Chase); return; } if (ShouldReturnHome()) { BeginWander(); return; } idleTimer -= base.AIIntervalTime; if (idleTimer <= 0f) { if (IsSafeToSleep() || Random.value < sleepChance) { sleepTimer = Random.Range(Mathf.Max(minSleepTime, 45f), Mathf.Max(maxSleepTime, 90f)); relocatingToSleepSpot = true; SetState(LocustState.Wander); SetHomeDestination(); } else { BeginWander(); } } } private void DoWanderInterval() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (HasTargetToChase()) { relocatingToSleepSpot = false; SetState(LocustState.Chase); return; } if (movementPathRequested) { StartTravelAnimation(LocustState.Wander); return; } float num = base.agent.stoppingDistance + 0.35f; if (!base.agent.pathPending) { Vector3 val = ((Component)this).transform.position - base.destination; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { if (relocatingToSleepSpot) { relocatingToSleepSpot = false; SetState(LocustState.Sleep); } else { BeginIdle(); } return; } } StartTravelAnimation(LocustState.Wander); } private void DoInvestigateInterval() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (HasTargetToChase()) { relocatingToSleepSpot = false; SetState(LocustState.Chase); } else if (movementPathRequested) { StartTravelAnimation(LocustState.Investigate); } else if (!investigateAnimationStarted) { float num = base.agent.stoppingDistance + 0.35f; if (!base.agent.pathPending) { Vector3 val = ((Component)this).transform.position - base.destination; if (((Vector3)(ref val)).sqrMagnitude <= num * num) { base.agent.isStopped = true; base.moveTowardsDestination = false; investigateAnimationDelayTimer += base.AIIntervalTime; StartBaseAnimation(LocustState.Investigate, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); if (!(investigateAnimationDelayTimer < 0.5f)) { investigateAnimationStarted = true; StartBaseAnimation(LocustState.Investigate, "investigate", 0f, AnimationPlayback.Event, restart: true, 0f); SyncInvestigateAnimationClientRpc(); } return; } } investigateAnimationDelayTimer = 0f; StartTravelAnimation(LocustState.Investigate); } else if (baseAnimationFinished) { BeginIdle(); } } private void ChooseWanderDestination() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) if (base.allAINodes == null || base.allAINodes.Length == 0) { if (loggedMissingNodes.Add(EnemyLogName)) { Log.Warn(EnemyLogName + " has no AI nodes for wandering"); } BeginIdle(); return; } int num = Mathf.Min(8, base.allAINodes.Length); float num2 = minWanderDistance * minWanderDistance; float num3 = maxWanderDistance * maxWanderDistance; float num4 = safeSpaceRange * safeSpaceRange; bool flag = ShouldReturnHome(); movementPathPositions.Clear(); movementPathScores.Clear(); for (int i = 0; i < num; i++) { GameObject val = base.allAINodes[Random.Range(0, base.allAINodes.Length)]; Vector3 position = val.transform.position; Vector3 val2 = position - ((Component)this).transform.position; Vector3 val3 = position - GroupHomePosition; if (Mathf.Abs(val3.y) > safeSpaceHeightTolerance) { continue; } val2.y = 0f; val3.y = 0f; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; float sqrMagnitude2 = ((Vector3)(ref val3)).sqrMagnitude; if (!(sqrMagnitude2 > num4)) { Vector3 val4 = ((Component)this).transform.position - GroupHomePosition; val4.y = 0f; if ((!flag || !(sqrMagnitude2 >= ((Vector3)(ref val4)).sqrMagnitude)) && (flag || (!(sqrMagnitude < num2) && !(sqrMagnitude > num3)))) { float item = (flag ? (0f - sqrMagnitude2) : (sqrMagnitude + Random.Range(0f, 36f))); movementPathPositions.Add(BlendLocustDestination(position)); movementPathScores.Add(item); } } } if (movementPathPositions.Count == 0) { if (flag) { SetHomeDestination(); } else { BeginIdle(); } } else { StartMovementPathTask(LocustState.Wander); } } protected void CancelPathTasks() { movementPathRequested = false; movementPathRequestTimer = 0f; movementPathState = LocustState.None; movementPathTask.Dispose(); movementPathPositions.Clear(); movementPathScores.Clear(); } private PlayerControllerB? FindVisibleTarget(float range) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; int num2 = Mathf.Min(allPlayerScripts.Length, StartOfRound.Instance.connectedPlayersAmount + 1); for (int i = 0; i < num2; i++) { PlayerControllerB val = allPlayerScripts[i]; if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true) && IsTargetWithinRange(val, range)) { Vector3 playerCenter = GetPlayerCenter(val); Vector3 val2 = playerCenter - base.eye.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num) && IsTargetVisible(val, range)) { num = sqrMagnitude; result = val; } } } return result; } private bool IsTargetWithinRange(PlayerControllerB player, float range) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = (player.isCrouching ? (range * crouchDetectionMultiplier) : range); float num2 = num * num; float num3 = closeAwarenessRange * closeAwarenessRange; return sqrMagnitude <= num2 || (!player.isCrouching && sqrMagnitude <= num3); } private bool IsTargetVisible(PlayerControllerB player, float range) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) Vector3 playerCenter = GetPlayerCenter(player); Vector3 direction = playerCenter - base.eye.position; float num = (player.isCrouching ? (range * crouchDetectionMultiplier) : range); float num2 = num * num; float num3 = closeAwarenessRange * closeAwarenessRange; if (!player.isCrouching) { Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= num3) { goto IL_00c2; } } if (((Vector3)(ref direction)).sqrMagnitude > num2) { return false; } if (!IsWithinAngle(base.eye.forward, direction, viewWidth)) { return false; } goto IL_00c2; IL_00c2: return HasSightToTarget(player); } private void HandleStuck() { //IL_0074: 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) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)base.agent).enabled || base.agent.isStopped || !base.moveTowardsDestination || locustState == LocustState.Idle || locustState == LocustState.Sleep || locustState == LocustState.Wake || locustState == LocustState.Attack || (UsesHurtState && locustState == LocustState.Hurt)) { stuckTimer = 0f; stuckPosition = ((Component)this).transform.position; return; } stuckTimer += base.AIIntervalTime; if (stuckTimer < 0.45f) { return; } Vector3 val = ((Component)this).transform.position - stuckPosition; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; stuckTimer = 0f; stuckPosition = ((Component)this).transform.position; if (!(sqrMagnitude > 0.0064f) && !(stuckRepathTimer > 0f)) { stuckRepathTimer = 0.8f; if (locustState == LocustState.Chase && HasTargetToChase()) { MoveToCurrentTarget(); } else if (locustState == LocustState.Investigate) { investigateAnimationStarted = false; investigateAnimationDelayTimer = 0f; base.destination = ((Component)this).transform.position; base.agent.isStopped = true; base.moveTowardsDestination = false; StartBaseAnimation(LocustState.Investigate, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); } else if (locustState == LocustState.Wander) { BeginWander(); } } } private void ApplyRemoteState(LocustState state) { if (!base.isEnemyDead) { switch (state) { case LocustState.Sleep: StartBaseAnimation(LocustState.Sleep, "sleep", sleepAnimationSeconds, AnimationPlayback.Timed, restart: true, 0f); break; case LocustState.Wake: StartBaseAnimation(LocustState.Wake, "wake", 0f, AnimationPlayback.Event, restart: true, 0f); break; case LocustState.Idle: investigateAnimationStarted = false; StartBaseAnimation(LocustState.Idle, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: true, 0f); break; case LocustState.Wander: investigateAnimationStarted = false; StartBaseAnimation(LocustState.Wander, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: true, 0f); break; case LocustState.Investigate: investigateAnimationStarted = false; investigateAnimationDelayTimer = 0f; StartBaseAnimation(LocustState.Investigate, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: true, 0f); break; case LocustState.Chase: StartBaseAnimation(LocustState.Chase, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: true, 0f); break; case LocustState.Attack: StartBaseAnimation(LocustState.Attack, "attack", 0f, AnimationPlayback.Event, restart: true, 0f); break; case LocustState.Hurt: StartBaseAnimation(LocustState.Hurt, "hurt", 0f, AnimationPlayback.Event, restart: true, 0f); break; } } } private void ApplyState(LocustState state, bool restartAnimation) { if (base.isEnemyDead) { return; } switch (state) { case LocustState.Sleep: CancelPathTasks(); base.agent.isStopped = true; base.moveTowardsDestination = false; StartBaseAnimation(LocustState.Sleep, "sleep", sleepAnimationSeconds, AnimationPlayback.Timed, restartAnimation, 0f); break; case LocustState.Wake: CancelPathTasks(); base.agent.isStopped = true; base.moveTowardsDestination = false; StartBaseAnimation(LocustState.Wake, "wake", 0f, AnimationPlayback.Event, restart: true, 0f); break; case LocustState.Idle: CancelPathTasks(); base.agent.isStopped = true; base.moveTowardsDestination = false; if (restartAnimation || baseAnimationState != LocustState.Idle) { idleTimer = idleAnimationSeconds; StartBaseAnimation(LocustState.Idle, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restartAnimation, 0f); } break; case LocustState.Wander: base.agent.speed = walkSpeed; base.agent.isStopped = false; base.moveTowardsDestination = true; StartTravelAnimation(LocustState.Wander); break; case LocustState.Investigate: base.agent.speed = walkSpeed; base.agent.isStopped = false; base.moveTowardsDestination = true; if (restartAnimation) { investigateAnimationStarted = false; investigateAnimationDelayTimer = 0f; } StartTravelAnimation(LocustState.Investigate); break; case LocustState.Chase: ApplyChaseState(restartAnimation); break; case LocustState.Attack: ApplyAttackState(); break; case LocustState.Hurt: ApplyHurtState(); break; } } private IEnumerator GlowForIdleSound(float clipLength) { float elapsed = 0f; float duration = Mathf.Max(clipLength, 0.15f); float brightLightIntensity = Mathf.Max(normalLightIntensity + 0.8f, normalLightIntensity * 1.8f); while (!base.isEnemyDead && elapsed < duration) { elapsed += Time.deltaTime; float pulse = Mathf.Sin(Mathf.Clamp01(elapsed / duration) * MathF.PI); Light obj = locustLight; if (obj != null) { obj.intensity = Mathf.Lerp(normalLightIntensity, brightLightIntensity, pulse); } SetMeshEmissionMultiplier(Mathf.Lerp(1f, 1.8f, pulse)); yield return null; } if (!base.isEnemyDead) { Light obj2 = locustLight; if (obj2 != null) { obj2.intensity = normalLightIntensity; } SetMeshEmissionMultiplier(1f); } idleGlowRoutine = null; } private IEnumerator FlickerDeadVisuals() { while (true) { bool hasOutput = false; float lightIntensity = Random.Range(0f, deadLightFlickerIntensity); float emissionIntensity = Random.Range(0f, deadEmissionFlickerIntensity); if ((Object)(object)locustLight != (Object)null) { locustLight.intensity = lightIntensity; hasOutput = true; } for (int i = 0; i < deadFlickerMeshRenderers.Length; i++) { MeshRenderer meshRenderer = deadFlickerMeshRenderers[i]; if ((Object)(object)meshRenderer == (Object)null) { continue; } Material[] materials = ((Renderer)meshRenderer).sharedMaterials; for (int materialIndex = 0; materialIndex < materials.Length; materialIndex++) { Material material = materials[materialIndex]; if (material != null && material.HasProperty(emissiveColorPropertyId)) { deadEmissionPropertyBlock.Clear(); ((Renderer)meshRenderer).GetPropertyBlock(deadEmissionPropertyBlock, materialIndex); deadEmissionPropertyBlock.SetVector(emissiveColorPropertyId, new Vector4(emissionIntensity, emissionIntensity, emissionIntensity, emissionIntensity)); ((Renderer)meshRenderer).SetPropertyBlock(deadEmissionPropertyBlock, materialIndex); hasOutput = true; } } } if (!hasOutput) { break; } yield return (object)new WaitForSeconds(Random.Range(0.04f, 0.12f)); } deadVisualFlickerRoutine = null; } private void SetMeshEmissionMultiplier(float multiplier) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < deadFlickerMeshRenderers.Length; i++) { MeshRenderer val = deadFlickerMeshRenderers[i]; if ((Object)(object)val == (Object)null) { continue; } Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (val2 != null && val2.HasProperty(emissiveColorPropertyId)) { deadEmissionPropertyBlock.Clear(); ((Renderer)val).GetPropertyBlock(deadEmissionPropertyBlock, j); deadEmissionPropertyBlock.SetVector(emissiveColorPropertyId, val2.GetVector(emissiveColorPropertyId) * multiplier); ((Renderer)val).SetPropertyBlock(deadEmissionPropertyBlock, j); } } } } private IEnumerator BaseAnimationRoutine() { while (baseAnimationActive) { if (baseAnimationState != LocustState.None && (base.isEnemyDead || locustState != baseAnimationState)) { ClearBaseAnimation(); baseAnimationRoutine = null; yield break; } UpdateBaseAnimation(Time.deltaTime); yield return null; } baseAnimationRoutine = null; } private void UpdateBaseAnimation(float deltaTime) { if (!baseAnimationActive) { return; } if (baseAnimationState != LocustState.None && locustState != baseAnimationState) { StopBaseAnimation(); return; } baseAnimationElapsedSeconds += deltaTime; baseAnimationCrossFadeTimer -= deltaTime; if (baseAnimationPlayback == AnimationPlayback.Loop) { return; } if (baseAnimationPlayback == AnimationPlayback.Timed) { if (!(baseAnimationElapsedSeconds < baseAnimationSeconds)) { baseAnimationActive = false; baseAnimationFinished = true; } } else if (baseAnimationPlayback != AnimationPlayback.Event) { AnimationPlayback animationPlayback = baseAnimationPlayback; if (1 == 0) { } bool flag = animationPlayback == AnimationPlayback.Once && baseAnimationElapsedSeconds >= baseAnimationSeconds; if (1 == 0) { } if (flag) { baseAnimationActive = false; baseAnimationFinished = true; } } } private void ClearBaseAnimation() { baseAnimationActive = false; baseAnimationFinished = true; baseAnimationState = LocustState.None; baseAnimationName = string.Empty; baseAnimationHash = 0; Animator creatureAnimator = base.creatureAnimator; if (creatureAnimator != null) { creatureAnimator.speed = 1f; } } private void UpdateStunTimers() { if (base.stunnedIndefinitely > 0) { return; } if (base.stunNormalizedTimer >= 0f) { base.stunNormalizedTimer -= Time.deltaTime / base.enemyType.stunTimeMultiplier; return; } base.stunnedByPlayer = null; if (base.postStunInvincibilityTimer >= 0f) { base.postStunInvincibilityTimer -= Time.deltaTime * 5f; } } private void UpdateRemoteMotion() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; if (base.serverPosition != Vector3.zero) { ((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, base.serverPosition, ref networkVelocity, base.syncMovementSpeed); } ((Component)this).transform.eulerAngles = new Vector3(((Component)this).transform.eulerAngles.x, Mathf.LerpAngle(((Component)this).transform.eulerAngles.y, networkTargetYaw, 15f * Time.deltaTime), ((Component)this).transform.eulerAngles.z); UpdateRemoteTravelAnimation(position); base.timeSinceSpawn += Time.deltaTime; } private void UpdateRemoteTravelAnimation(Vector3 previousPosition) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) LocustState locustState = this.locustState; bool flag = (((uint)locustState <= 1u || (uint)(locustState - 6) <= 1u) ? true : false); if (!flag && (this.locustState != LocustState.Investigate || !investigateAnimationStarted)) { float num; if (!(Time.deltaTime > 0f)) { num = 0f; } else { Vector3 val = ((Component)this).transform.position - previousPosition; num = ((Vector3)(ref val)).sqrMagnitude / (Time.deltaTime * Time.deltaTime); } float num2 = num; switch (this.locustState) { case LocustState.Chase: StartBaseAnimation(LocustState.Chase, (num2 > 0.04f) ? "run" : "idle", (num2 > 0.04f) ? 1f : idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); break; case LocustState.Wander: case LocustState.Investigate: StartBaseAnimation(this.locustState, (num2 > 0.04f) ? "walk" : "idle", (num2 > 0.04f) ? 1f : idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); break; case LocustState.Idle: StartBaseAnimation(LocustState.Idle, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: false, 0f); break; } } } private void SyncRotationIfNeeded() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) float y = ((Component)this).transform.eulerAngles.y; if (!(Mathf.Abs(Mathf.DeltaAngle(lastSyncedYaw, y)) <= 6f)) { lastSyncedYaw = y; SyncRotationClientRpc((short)y); } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncRotationClientRpc(short rotationY) { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1253919435u, val3, val, (SendTo)5, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, rotationY); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1253919435u, val3, val, (SendTo)5, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; networkTargetYaw = rotationY; } } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncInvestigateAnimationClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(2152267684u, val3, val, (SendTo)1, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendRpc(ref val2, 2152267684u, val3, val, (SendTo)1, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (locustState == LocustState.Investigate) { investigateAnimationStarted = true; investigateAnimationDelayTimer = 0f; StartBaseAnimation(LocustState.Investigate, "investigate", 0f, AnimationPlayback.Event, restart: true, 0f); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncStateServerRpc(int state) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0076: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1730912339u, val3, val, (SendTo)2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, state); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1730912339u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; SyncStateClientRpc(state); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void SyncStateClientRpc(int state) { //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)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(138420932u, val3, val, (SendTo)1, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, state); ((NetworkBehaviour)this).__endSendRpc(ref val2, 138420932u, val3, val, (SendTo)1, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; locustState = (LocustState)state; ApplyRemoteState(locustState); } } } void ISmartAI.GoToSmartPathDestination(in SmartPathDestination destination) { GoToSmartPathDestination(in destination); } protected override void __initializeVariables() { ((EnemyAI)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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1253919435u, new RpcReceiveHandler(__rpc_handler_1253919435), "SyncRotationClientRpc"); ((NetworkBehaviour)this).__registerRpc(2152267684u, new RpcReceiveHandler(__rpc_handler_2152267684), "SyncInvestigateAnimationClientRpc"); ((NetworkBehaviour)this).__registerRpc(1730912339u, new RpcReceiveHandler(__rpc_handler_1730912339), "SyncStateServerRpc"); ((NetworkBehaviour)this).__registerRpc(138420932u, new RpcReceiveHandler(__rpc_handler_138420932), "SyncStateClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_1253919435(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) { short rotationY = default(short); ByteUnpacker.ReadValueBitPacked(reader, ref rotationY); target.__rpc_exec_stage = (__RpcExecStage)1; ((LocustEnemyBase)(object)target).SyncRotationClientRpc(rotationY); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2152267684(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; ((LocustEnemyBase)(object)target).SyncInvestigateAnimationClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1730912339(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 state = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref state); target.__rpc_exec_stage = (__RpcExecStage)1; ((LocustEnemyBase)(object)target).SyncStateServerRpc(state); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_138420932(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 state = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref state); target.__rpc_exec_stage = (__RpcExecStage)1; ((LocustEnemyBase)(object)target).SyncStateClientRpc(state); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "LocustEnemyBase"; } } public class SawbladeLocustEnemyAI : LocustEnemyBase { [Header("Audio")] [SerializeField] private LocustAudioLibrary audioProfile = null; [Header("Attack")] [SerializeField] [Min(0f)] private float attackRange = 3.45f; [SerializeField] [Min(0f)] private float attackDamageRange = 0.95f; [SerializeField] [Min(0f)] private float attackCooldownSeconds = 1.5f; [SerializeField] [Min(0f)] private int attackDamage = 15; private readonly RaycastHit[] attackHits = (RaycastHit[])(object)new RaycastHit[1]; protected override string EnemyLogName => "Sawblade Locust"; protected override LocustAudioLibrary AudioProfile => audioProfile; protected override bool UsesHurtState => true; protected override float AttackRange => attackRange; protected override float AttackAngleDegrees => 18f; protected override bool HoldsAttackRangeDuringCooldown => true; protected override float AttackCooldownSeconds => attackCooldownSeconds; public override void KillEnemy(bool destroy = false) { AudioTools.Stop(((EnemyAI)this).creatureSFX, false); base.KillEnemy(destroy); } protected override void OnLocustHit(PlayerControllerB? playerWhoHit) { if (locustState == LocustState.Attack) { AudioTools.Stop(((EnemyAI)this).creatureSFX, false); } base.OnLocustHit(playerWhoHit); } protected override void OnSawSoundFromAnimationEvent() { AudioTools.PlayOneShot(((EnemyAI)this).creatureSFX, AudioProfile?.saw); } protected override bool CanStartAttack(PlayerControllerB player, Vector3 flatDirectionToPlayer) { return attackCooldownTimer <= 0f && IsInAttackRange(player) && HasSightToTarget(player); } protected override void UpdateAttack(float deltaTime) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!baseAnimationFinished) { return; } if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true) && attackCooldownTimer <= 0f && IsInAttackRange(((EnemyAI)this).targetPlayer) && HasSightToTarget(((EnemyAI)this).targetPlayer)) { ResetAttack(); FaceTarget(((Component)((EnemyAI)this).targetPlayer).transform.position); SetState(LocustState.Attack); } else if ((Object)(object)((EnemyAI)this).targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(((EnemyAI)this).targetPlayer, false, false, true)) { SetState(LocustState.Chase); if (ShouldHoldChasePosition(((EnemyAI)this).targetPlayer)) { ((EnemyAI)this).agent.isStopped = true; ((EnemyAI)this).moveTowardsDestination = false; StartBaseAnimation(LocustState.Chase, "idle", idleAnimationSeconds, AnimationPlayback.Loop, restart: true, 0f); } else { MoveToCurrentTarget(); } } else { ((EnemyAI)this).targetPlayer = null; BeginIdle(); } } protected override void OnAttackAnimationHit() { //IL_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((EnemyAI)this).targetPlayer == (Object)null)) { Vector3 position = ((Component)this).transform.position; Vector3 forward = ((Component)this).transform.forward; if (((NetworkBehaviour)this).IsServer) { DamagePlayersInSawVolumeClientRpc(position, forward); } else { DamagePlayersInSawVolumeServerRpc(position, forward); } } } protected override void OnStartingAttack(PlayerControllerB player) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) FaceTarget(((Component)player).transform.position); } [Rpc(/*Could not decode attribute arguments.*/)] private void DamagePlayersInSawVolumeServerRpc(Vector3 attackPosition, Vector3 attackForward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(659278292u, val3, val, (SendTo)2, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackForward); ((NetworkBehaviour)this).__endSendRpc(ref val2, 659278292u, val3, val, (SendTo)2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; DamagePlayersInSawVolumeClientRpc(attackPosition, attackForward); } } } [Rpc(/*Could not decode attribute arguments.*/)] private void DamagePlayersInSawVolumeClientRpc(Vector3 attackPosition, Vector3 attackForward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { RpcAttributeParams val = default(RpcAttributeParams); RpcParams val3 = default(RpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendRpc(1785357752u, val3, val, (SendTo)7, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref attackForward); ((NetworkBehaviour)this).__endSendRpc(ref val2, 1785357752u, val3, val, (SendTo)7, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val4 = Utility.LocalPlayer(); Vector3 val5 = attackForward; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude <= 0.0001f) { return; } ((Vector3)(ref val5)).Normalize(); Vector3 val6 = attackPosition + val5 * 2.1f + Vector3.up * 0.45f; float num = attackDamageRange * attackDamageRange; float num2 = attackRange * attackRange; if (!((EnemyAI)this).PlayerIsTargetable(val4, false, false, true)) { return; } Vector3 playerCenter = GetPlayerCenter(val4); Vector3 val7 = ((Component)val4).transform.position - attackPosition; val7.y = 0f; Vector3 val8 = playerCenter - val6; if (((Vector3)(ref val8)).sqrMagnitude > num && ((Vector3)(ref val7)).sqrMagnitude > num2) { return; } Vector3 val9 = playerCenter - val6; float magnitude = ((Vector3)(ref val9)).magnitude; if (!(magnitude > 0.001f) || Physics.RaycastNonAlloc(val6, val9 / magnitude, attackHits, magnitude, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) <= 0) { int num3 = attackDamage; val8 = default(Vector3); val4.DamagePlayer(num3, true, true, (CauseOfDeath)17, 0, false, val8); if (Plugin.hasCoroner) { CoronerCompat.SetSawbladeLocustDeathIfKilled(val4); } } } protected override void __initializeVariables() { base.__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(659278292u, new RpcReceiveHandler(__rpc_handler_659278292), "DamagePlayersInSawVolumeServerRpc"); ((NetworkBehaviour)this).__registerRpc(1785357752u, new RpcReceiveHandler(__rpc_handler_1785357752), "DamagePlayersInSawVolumeClientRpc"); base.__initializeRpcs(); } private static void __rpc_handler_659278292(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 attackPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackPosition); Vector3 attackForward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackForward); target.__rpc_exec_stage = (__RpcExecStage)1; ((SawbladeLocustEnemyAI)(object)target).DamagePlayersInSawVolumeServerRpc(attackPosition, attackForward); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1785357752(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 attackPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackPosition); Vector3 attackForward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref attackForward); target.__rpc_exec_stage = (__RpcExecStage)1; ((SawbladeLocustEnemyAI)(object)target).DamagePlayersInSawVolumeClientRpc(attackPosition, attackForward); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "SawbladeLocustEnemyAI"; } } } namespace TemporalStormWeather.Compat { internal static class BasedDecorPlacementCompat { internal static void RegisterSurfaceExtensions() { PlaceableObjectsSurfaceRegistry.Register("MrHat.TemporalStormWeather.Internals", false); } } internal static class CoronerCompat { private const string LocustLanguageKey = "DeathEnemyLocust"; private const string CorruptLocustLanguageKey = "DeathEnemyCorruptLocust"; private const string SawbladeLocustLanguageKey = "DeathEnemySawbladeLocust"; private const string RustHazardLanguageKey = "DeathHazardRustHazard"; private const string TemporalGearLanguageKey = "DeathPlayerTemporalGear"; internal static void SetLocustDeathIfKilled(PlayerControllerB player) { SetCauseOfDeathIfKilled(player, "DeathEnemyLocust"); } internal static void SetCorruptLocustDeathIfKilled(PlayerControllerB player) { SetCauseOfDeathIfKilled(player, "DeathEnemyCorruptLocust"); } internal static void SetSawbladeLocustDeathIfKilled(PlayerControllerB player) { SetCauseOfDeathIfKilled(player, "DeathEnemySawbladeLocust"); } internal static void SetRustHazardDeathIfKilled(PlayerControllerB player) { SetCauseOfDeathIfKilled(player, "DeathHazardRustHazard"); } internal static void SetTemporalGearDeathIfKilled(PlayerControllerB player) { SetCauseOfDeathIfKilled(player, "DeathPlayerTemporalGear"); } internal static void Register() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) API.Register("DeathEnemyLocust"); API.Register("DeathEnemyCorruptLocust"); API.Register("DeathEnemySawbladeLocust"); API.Register("DeathHazardRustHazard"); API.Register("DeathPlayerTemporalGear"); } private static void SetCauseOfDeathIfKilled(PlayerControllerB player, string languageKey) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (player.isPlayerDead) { AdvancedCauseOfDeath? val = AdvancedCauseOfDeath.Fetch(languageKey); if (val.HasValue) { API.SetCauseOfDeath(player, val.Value); } } } } internal static class CullFactoryCompat { internal static bool CullDistanceEnabled() { return Config.CullDistanceEnabled.Value; } internal static float InteriorFarClipPlane() { return Config.CullDistance.Value; } internal static float SurfaceFarClipPlane() { return Config.SurfaceCullDistance.Value; } [HarmonyPostfix] [HarmonyPatch(typeof(TeleportExtender), "SetInitialFarClipPlane")] private static void SetInitialFarClipPlanePostfix() { PlayerControllerB val = Utility.LocalPlayer(); if (!((Object)(object)val?.gameplayCamera == (Object)null)) { SkyboxManager.NoteLocalPlayerFarClip(val.gameplayCamera.farClipPlane); } } [HarmonyPostfix] [HarmonyPatch(typeof(TeleportExtender), "UpdateFarPlane")] private static void UpdateFarPlanePostfix(PlayerControllerB player) { if (!((Object)(object)player != (Object)(object)Utility.LocalPlayer()) && !((Object)(object)player.gameplayCamera == (Object)null)) { SkyboxManager.NoteLocalPlayerFarClip(player.gameplayCamera.farClipPlane); } } } } namespace TemporalStormWeather.Compat.BCMERCompat { internal static class BCMERCompatibility { internal static void RegisterEvents() { RegisterEvent(EventManager.moddedEvents, (MEvent)(object)new RusticAllItems()); RegisterEvent(EventManager.moddedEvents, (MEvent)(object)new LocustSwarm()); RegisterEvent(EventManager.moddedEvents, (MEvent)(object)new WorldOfRust()); RegisterEvent(EventManager.moddedEvents, (MEvent)(object)new TemporalAllItems()); } private static void RegisterEvent(List moddedEvents, MEvent moddedEvent) { string eventName = moddedEvent.Name(); if (!moddedEvents.Any((MEvent registeredEvent) => registeredEvent.Name() == eventName)) { moddedEvents.Add(moddedEvent); Log.Info("BCMER " + eventName + " modded event registered"); } } internal static void SetActive(MEvent moddedEvent, bool active) { moddedEvent.Active = active; } internal static void SetExecuted(MEvent moddedEvent, bool executed) { moddedEvent.Executed = executed; } internal static bool IsTemporalStormSelectedOnRoutedMoon() { return ((object)((DawnBaseInfo)(object)SelectableLevelExtensions.GetDawnInfo(Manager.currentLevel).GetCurrentWeather())?.TypedKey).Equals((object?)Keys.TemporalStormWeather) ?? false; } [HarmonyPatch(typeof(GrabbableObject), "Start")] [HarmonyPostfix] private static void Postfix(GrabbableObject __instance) { RusticAllItemsBehaviour.AttachItem(__instance); TemporalAllItemsBehaviour.TemporaliseItem(__instance); } } } namespace TemporalStormWeather.Compat.BCMERCompat.Events.WorldOfRust { internal class WorldOfRust : MEvent { public override string Name() { return "WorldOfRust"; } public override void Initalize() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown base.Weight = 1; base.Descriptions = new List(1) { "Temporal Symphony" }; base.ColorHex = "#2C1507"; base.Type = (EventType)0; base.EventsToSpawnWith = new List(2) { "RusticAllItems", "LocustSwarm" }; base.EventsToRemove = new List(13) { "AllWeather", "BloodMoon", "Forsaken", "Gloomy", "Hallowed", "Heatwave", "HeavyRain", "Hurricane", "MajoraMoon", "MeteorShower", "Raining", "SolarFlare", "Windy" }; base.Aliases = new List(1) { "WorldOfRust" }; base.showTip = true; base.TipTitle = new List(1) { "A Temporal Symphony" }; base.TipMessages = new List(1) { "This moon has collapsed to the World of Rust" }; base.isWarning = true; base.ScaleList.Add((ScaleType)7, new Scale(1.2f, 0.003f, 1.2f, 1.5f)); base.ScaleList.Add((ScaleType)8, new Scale(1.15f, 0.003f, 1.15f, 1.45f)); base.scrapTransmutationEvent = new ScrapTransmutationEvent(new Scale(0.08f, 0.0012f, 0.08f, 0.2f), (SpawnableItemWithRarity[])(object)new SpawnableItemWithRarity[2] { new SpawnableItemWithRarity(Assets.GetItem("Temporal Gear"), 10), new SpawnableItemWithRarity(Assets.GetItem("Madness Gear"), 7) }); } public override bool AddEventIfOnly() { return BCMERCompatibility.IsTemporalStormSelectedOnRoutedMoon(); } public override void Execute() { BCMERCompatibility.SetExecuted((MEvent)(object)this, executed: true); BCMERCompatibility.SetActive((MEvent)(object)this, active: true); CustomWeather.SetCustomWeather("Temporal Storm"); TemporalInstabilityAPI.SetTemporalStormRoundActive(active: true); TemporalInstabilityAPI.SetServerInstabilityLevel(100f); Log.Debug("WorldOfRust event started"); } public override void OnShipLeave() { StopEvent(); } public override void OnGameStart() { StopEvent(); } public override void OnLocalDisconnect() { StopEvent(); } private void StopEvent() { BCMERCompatibility.SetActive((MEvent)(object)this, active: false); TemporalInstabilityAPI.SetTemporalStormRoundActive(active: false); } } } namespace TemporalStormWeather.Compat.BCMERCompat.Events.TemporalAllItems { internal class TemporalAllItems : MEvent { public override string Name() { return "TemporalAllItems"; } public override void Initalize() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) base.Weight = 2; base.Descriptions = new List(1) { "Temporal energy flows through every item" }; base.ColorHex = "#19B476"; base.Type = (EventType)6; base.Aliases = new List(1) { "TemporalAllItems" }; base.EventsToRemove = new List(2) { "WorldOfRust", "RusticAllItems" }; } public override void Execute() { BCMERCompatibility.SetExecuted((MEvent)(object)this, executed: true); BCMERCompatibility.SetActive((MEvent)(object)this, active: true); TemporalAllItemsBehaviour.StartFor((MEvent)(object)this); Log.Debug("TemporalAllItems event started"); } public override void OnShipLeave() { StopEvent(); } public override void OnGameStart() { StopEvent(); } public override void OnLocalDisconnect() { StopEvent(); } private void StopEvent() { BCMERCompatibility.SetActive((MEvent)(object)this, active: false); TemporalAllItemsBehaviour.StopFor((MEvent)(object)this); } } internal class TemporalAllItemsBehaviour : MonoBehaviour { private static TemporalAllItemsBehaviour? current; private MEvent? activeEvent; internal static bool IsActive => current?.activeEvent != null && API.IsEventActive(current.activeEvent); internal static void StartFor(MEvent customEvent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)current == (Object)null) { GameObject val = new GameObject("TemporalStormWeather.TemporalAllItems"); current = val.AddComponent(); } current.Begin(customEvent); } internal static void StopFor(MEvent customEvent) { if (!((Object)(object)current == (Object)null) && current.activeEvent == customEvent) { Object.Destroy((Object)(object)((Component)current).gameObject); } } private void Begin(MEvent customEvent) { activeEvent = customEvent; TemporaliseExistingItems(); } internal static bool TemporaliseItem(GrabbableObject item) { ItemEffect itemEffect; return IsActive && NetworkUtils.IsServerOrNotNetworked() && !item.isInShipRoom && ItemEffect.Attach(item, out itemEffect, includeNonConductive: true) && (itemEffect?.ForceTemporal() ?? false); } private static void TemporaliseExistingItems() { if (!NetworkUtils.IsServerOrNotNetworked()) { return; } foreach (GrabbableObject item in FindItems.Active((Func)null)) { TemporaliseItem(item); } } private void OnDestroy() { if ((Object)(object)current == (Object)(object)this) { current = null; } } } } namespace TemporalStormWeather.Compat.BCMERCompat.Events.RusticAllItems { internal class RusticAllItems : MEvent { public override string Name() { return "RusticAllItems"; } public override void Initalize() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) base.Weight = 2; base.Descriptions = new List(1) { "Rust spreads through every item" }; base.ColorHex = "#FF0000"; base.Type = (EventType)2; base.EventsToRemove = new List(13) { "AllWeather", "BloodMoon", "Forsaken", "Gloomy", "Hallowed", "Heatwave", "HeavyRain", "Hurricane", "MajoraMoon", "MeteorShower", "Raining", "SolarFlare", "Windy" }; base.Aliases = new List(1) { "RusticAllItems" }; } public override bool AddEventIfOnly() { return BCMERCompatibility.IsTemporalStormSelectedOnRoutedMoon(); } public override void Execute() { BCMERCompatibility.SetExecuted((MEvent)(object)this, executed: true); BCMERCompatibility.SetActive((MEvent)(object)this, active: true); TemporalInstabilityAPI.SetTemporalStormRoundActive(active: true); RusticAllItemsBehaviour.StartFor((MEvent)(object)this); Log.Debug("RusticAllItems event started"); } public override void OnShipLeave() { StopEvent(); } public override void OnGameStart() { StopEvent(); } public override void OnLocalDisconnect() { StopEvent(); } private void StopEvent() { BCMERCompatibility.SetActive((MEvent)(object)this, active: false); RusticAllItemsBehaviour.StopFor((MEvent)(object)this); TemporalInstabilityAPI.SetTemporalStormRoundActive(active: false); } } internal class RusticAllItemsBehaviour : MonoBehaviour { private static RusticAllItemsBehaviour? current; private MEvent? activeEvent; internal static bool IsActive => current?.activeEvent != null && API.IsEventActive(current.activeEvent); internal static void StartFor(MEvent customEvent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)current == (Object)null) { GameObject val = new GameObject("TemporalStormWeather.RusticAllItems"); current = val.AddComponent(); } current.Begin(customEvent); } internal static void StopFor(MEvent customEvent) { if (!((Object)(object)current == (Object)null) && current.activeEvent == customEvent) { Object.Destroy((Object)(object)((Component)current).gameObject); } } private void Begin(MEvent customEvent) { activeEvent = customEvent; AttachExistingItems(); } internal static bool AttachItem(GrabbableObject item) { ItemEffect itemEffect; return IsActive && NetworkUtils.IsServerOrNotNetworked() && !item.isInShipRoom && ItemEffect.Attach(item, out itemEffect, includeNonConductive: true) && (itemEffect?.ForceRustic() ?? false); } private static void AttachExistingItems() { if (!NetworkUtils.IsServerOrNotNetworked()) { return; } foreach (GrabbableObject item in FindItems.Active((Func)null)) { AttachItem(item); } } private void OnDestroy() { if ((Object)(object)current == (Object)(object)this) { current = null; } } } } namespace TemporalStormWeather.Compat.BCMERCompat.Events.LocustSwarm { internal class LocustSwarm : MEvent { private static readonly string[] LocustEnemyNames = new string[3] { "LocustEnemy", "SawbladeLocustEnemy", "CorruptLocustEnemy" }; private static readonly Scale NoSpawn = new Scale(0f, 0f, 0f, 0f); private static readonly Scale InsideRarity = new Scale(50f, 0.5f, 50f, 100f); private static readonly Scale LocustMin = new Scale(5f, 0.06f, 5f, 11f); private static readonly Scale LocustMax = new Scale(8f, 0.13f, 8f, 21f); private static readonly Scale SawbladeLocustMin = new Scale(2f, 0.025f, 2f, 4f); private static readonly Scale SawbladeLocustMax = new Scale(4f, 0.05f, 4f, 9f); private static readonly Scale CorruptLocustMin = new Scale(2f, 0.025f, 2f, 4f); private static readonly Scale CorruptLocustMax = new Scale(4f, 0.055f, 4f, 9f); public override string Name() { return "LocustSwarm"; } public override void Initalize() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown base.Weight = 2; base.Descriptions = new List(1) { "Locusts are swarming the facility" }; base.ColorHex = "#B87333"; base.Type = (EventType)2; base.Aliases = new List(1) { "LocustSwarm" }; base.monstersToSpawn = new List(3) { new MonsterEvent(LocustEnemyNames[0], InsideRarity, NoSpawn, LocustMin, LocustMax, NoSpawn, NoSpawn), new MonsterEvent(LocustEnemyNames[1], InsideRarity, NoSpawn, SawbladeLocustMin, SawbladeLocustMax, NoSpawn, NoSpawn), new MonsterEvent(LocustEnemyNames[2], InsideRarity, NoSpawn, CorruptLocustMin, CorruptLocustMax, NoSpawn, NoSpawn) }; } public override bool AddEventIfOnly() { for (int i = 0; i < LocustEnemyNames.Length; i++) { if (!Assets.EnemyList.ContainsKey(LocustEnemyNames[i])) { return false; } } return true; } public override void Execute() { ((MEvent)this).ExecuteAllMonsterEvents(); Log.Debug("LocustSwarm event started"); } } } namespace TemporalStormWeather.API { public enum TemporalInstabilityFeed { Server, Client } public interface ITemporalInstability { void SetTemporalInstabilityLevel(float temporalInstabilityLevel); } public interface ITemporalStormSkyGear { void SetSkyGearSeed(int skyGearSeed); } public interface ITemporalStormRustLightning { void SetRustLightningSeed(int rustLightningSeed); } public static class TemporalInstabilityAPI { public static void Register(ITemporalInstability receiver, TemporalInstabilityFeed feed) { TemporalInstabilityManager.Register(receiver, feed); } public static void Unregister(ITemporalInstability receiver) { TemporalInstabilityManager.Unregister(receiver); } public static void RegisterSkyGear(ITemporalStormSkyGear receiver) { TemporalInstabilityManager.RegisterSkyGearSeedReceiver(receiver); } public static void UnregisterSkyGear(ITemporalStormSkyGear receiver) { TemporalInstabilityManager.UnregisterSkyGearSeedReceiver(receiver); } public static void RegisterRustLightning(ITemporalStormRustLightning receiver) { TemporalInstabilityManager.RegisterRustLightningSeedReceiver(receiver); } public static void UnregisterRustLightning(ITemporalStormRustLightning receiver) { TemporalInstabilityManager.UnregisterRustLightningSeedReceiver(receiver); } public static void RegenerateRustLightning() { TemporalInstabilityManager.RegenerateRustLightningSeed(); } public static void SetServerInstabilityLevel(float temporalInstabilityLevel) { TemporalInstabilityManager.SetServerInstabilityLevel(temporalInstabilityLevel); } public static void ReduceServerInstability(float amount) { TemporalInstabilityManager.ReduceServerInstability(amount); } public static void IncreaseServerInstability(float amount) { TemporalInstabilityManager.IncreaseServerInstability(amount); } public static void SetClientInstabilityAddition(object source, float temporalInstabilityAddition) { TemporalInstabilityManager.SetClientInstabilityAddition(source, temporalInstabilityAddition); } public static void ClearClientInstabilityAddition(object source) { TemporalInstabilityManager.ClearClientInstabilityAddition(source); } public static void SetTemporalStormRoundActive(bool active) { TemporalInstabilityManager.SetTemporalStormRoundActive(active); } public static void AddApparatusInstability() { TemporalInstabilityManager.AddApparatusInstability(); } public static bool TryGetClientInstabilityLevel(out float temporalInstabilityLevel) { return TemporalInstabilityManager.TryGetClientInstabilityLevel(out temporalInstabilityLevel); } public static bool TryGetServerInstabilityLevel(out float temporalInstabilityLevel) { return TemporalInstabilityManager.TryGetServerInstabilityLevel(out temporalInstabilityLevel); } public static bool TrySendTemporalAmbience(int category, int clipIndex, float volume) { return TemporalInstabilityManager.TrySendTemporalAmbience(category, clipIndex, volume); } public static void ResetTemporalInstabilityLevels() { TemporalInstabilityManager.ResetTemporalInstabilityLevels(); } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace TemporalStormWeather.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }