using System; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Utils; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Snowlance.SnowyLib.NetcodePatcher; using SnowyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations.Rigging; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: AssemblyCompany("Snowlance.SnowyLib")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.4.0")] [assembly: AssemblyInformationalVersion("1.1.4+8a2713b842247d1db8f8617a72db957a7f44cda3")] [assembly: AssemblyProduct("SnowyLib")] [assembly: AssemblyTitle("Snowlance.SnowyLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public static class GameObjectExtensions { public static T OrNull(this T obj) where T : Object { return Object.op_Implicit((Object)(object)obj) ? obj : default(T); } public static StatusEffectController StatusEffectController(this GameObject gameObject) { StatusEffectController statusEffectController = default(StatusEffectController); return gameObject.TryGetComponent(ref statusEffectController) ? statusEffectController : gameObject.AddComponent(); } } public static class ListExtensions { private static Random rng; public static IList Shuffle(this IList list) { if (rng == null) { rng = new Random(); } int num = list.Count; while (num > 1) { num--; int num2 = rng.Next(num + 1); int index = num2; int index2 = num; T value = list[num]; T value2 = list[num2]; list[index] = value; list[index2] = value2; } return list; } } public class Preconditions { private Preconditions() { } public static T CheckNotNull(T reference) { return CheckNotNull(reference, null); } public static T CheckNotNull(T reference, string message) { object obj = reference; Object val = (Object)((obj is Object) ? obj : null); if (val != null && val.OrNull() == (Object)null) { throw new ArgumentNullException(message); } if (reference == null) { throw new ArgumentNullException(message); } return reference; } public static void CheckState(bool expression) { CheckState(expression, null); } public static void CheckState(bool expression, string messageTemplate, params object[] messageArgs) { CheckState(expression, string.Format(messageTemplate, messageArgs)); } public static void CheckState(bool expression, string message) { if (expression) { return; } throw (message == null) ? new InvalidOperationException() : new InvalidOperationException(message); } } public static class StringExtensions { public static int ComputeFNV1aHash(this string str) { uint num = 2166136261u; foreach (char c in str) { num = (num ^ c) * 16777619; } return (int)num; } } public static class Vector3Extensions { public static Vector3 With(this Vector3 vector, float? x = null, float? y = null, float? z = null) { //IL_000c: 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_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z); } } namespace SnowyLib { public static class EnemyAIExtensions { public static StatusEffectController StatusEffectController(this EnemyAI enemy) { StatusEffectController statusEffectController = default(StatusEffectController); return ((Component)enemy).gameObject.TryGetComponent(ref statusEffectController) ? statusEffectController : ((Component)enemy).gameObject.AddComponent(); } } public static class Extensions { public static void FreezePlayer(this PlayerControllerB player, bool value) { Utils.localPlayerFrozen = value; player.disableInteract = value; player.disableLookInput = value; player.disableMoveInput = value; } public static void MakePlayerInvisible(this PlayerControllerB player, bool value) { GameObject gameObject = ((Component)((Component)player).gameObject.transform.Find("ScavengerModel")).gameObject; if ((Object)(object)gameObject == (Object)null) { Plugin.logger.LogError((object)"ScavengerModel not found"); return; } ((Component)gameObject.transform.Find("LOD1")).gameObject.SetActive(!value); ((Component)gameObject.transform.Find("LOD2")).gameObject.SetActive(!value); ((Component)gameObject.transform.Find("LOD3")).gameObject.SetActive(!value); ((Component)gameObject.transform.Find("metarig/spine/spine.001/spine.002/spine.003/LevelSticker")).gameObject.SetActive(!value); ((Component)gameObject.transform.Find("metarig/spine/spine.001/spine.002/spine.003/BetaBadge")).gameObject.SetActive(!value); ((Component)player.playerBadgeMesh).gameObject.SetActive(!value); } public static T? GetClosestGameObjectOfType(Vector3 position) where T : Component { //IL_0028: 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) T[] array = Object.FindObjectsOfType(); T result = default(T); float num = float.PositiveInfinity; T[] array2 = array; foreach (T val in array2) { float num2 = Vector3.Distance(position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } return result; } public static T? GetRandom(this IEnumerable source, Random random) where T : class { if (source is IList list) { if (list.Count == 0) { return null; } return list[random.Next(list.Count)]; } T[] array = (source as T[]) ?? source.ToArray(); if (array.Length == 0) { return null; } return array[random.Next(array.Length)]; } public static T? GetRandom(this IEnumerable source) where T : class { if (source is IList list) { if (list.Count == 0) { return null; } return list[Random.Range(0, list.Count)]; } T[] array = (source as T[]) ?? source.ToArray(); if (array.Length == 0) { return null; } return array[Random.Range(0, array.Length)]; } public static T? GetClosestToPosition(this IEnumerable list, Vector3 position, Func positionSelector, IEnumerable? excluded = null) where T : class { //IL_0045: 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) T result = null; float num = float.PositiveInfinity; if (excluded == null) { excluded = Array.Empty(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num2 = Vector3.Distance(position, positionSelector(item)); if (!(num2 >= num)) { result = item; num = num2; } } } return result; } public static T? GetFarthestFromPosition(this IEnumerable list, Vector3 position, Func positionSelector, IEnumerable? excluded = null) where T : class { //IL_0045: 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) T result = null; float num = 0f; if (excluded == null) { excluded = Array.Empty(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num2 = Vector3.Distance(position, positionSelector(item)); if (!(num2 <= num)) { result = item; num = num2; } } } return result; } public static List GetInRange(this IEnumerable list, Vector3 position, Func positionSelector, float range, IEnumerable? excluded = null) where T : class { //IL_003d: 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) List list2 = new List(); if (excluded == null) { excluded = Array.Empty(); } foreach (T item in list) { if (item != null && !excluded.Contains(item) && Vector3.Distance(position, positionSelector(item)) < range) { list2.Add(item); } } return list2; } public static void RebuildRig(this PlayerControllerB player) { if ((Object)(object)player != (Object)null && (Object)(object)player.playerBodyAnimator != (Object)null) { player.playerBodyAnimator.WriteDefaultValues(); RigBuilder component = ((Component)player.playerBodyAnimator).GetComponent(); if (component != null) { component.Build(); } } } public static void MufflePlayer(this PlayerControllerB player, bool muffle) { if ((Object)(object)player.currentVoiceChatAudioSource == (Object)null) { StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects(); } if ((Object)(object)player.currentVoiceChatAudioSource != (Object)null) { ((Component)player.currentVoiceChatAudioSource).GetComponent().lowpassResonanceQ = (muffle ? 5f : 1f); OccludeAudio component = ((Component)player.currentVoiceChatAudioSource).GetComponent(); component.overridingLowPass = muffle; component.lowPassOverride = (muffle ? 500f : 20000f); player.voiceMuffledByEnemy = muffle; } } public static Vector3 GetFloorPosition(this Vector3 position, float verticalOffset = 0f) { //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_0051: 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_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_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_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_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_0055: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, -Vector3.up, ref val, 80f, 268437761, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.04f + verticalOffset * Vector3.up; } return position; } } public static class PlayerControllerBExtensions { public static StatusEffectController StatusEffectController(this PlayerControllerB player) { StatusEffectController statusEffectController = default(StatusEffectController); return ((Component)player).gameObject.TryGetComponent(ref statusEffectController) ? statusEffectController : ((Component)player).gameObject.AddComponent(); } } [BepInPlugin("Snowlance.SnowyLib", "SnowyLib", "1.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("Snowlance.SnowyLib"); public const ulong RodrigoSteamID = 76561198164429786uL; public const ulong LizzieSteamID = 76561199094139351uL; public const ulong GlitchSteamID = 76561198984467725uL; public const ulong RatSteamID = 76561199182474292uL; public const ulong XuSteamID = 76561198399127090uL; public const ulong SlayerSteamID = 76561198077184650uL; public const ulong SnowySteamID = 76561198253760639uL; public const ulong FunoSteamID = 76561198993437314uL; public static ConfigEntry cfgTesting; public static AssetBundle ModAssets; public static Plugin Instance { get; private set; } public static ManualLogSource logger { get; private set; } public static PlayerControllerB localPlayer => StartOfRound.Instance.localPlayerController; public static bool IsServerOrHost => NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost; public static PlayerControllerB? PlayerFromId(ulong id) { return StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId == id).FirstOrDefault(); } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } cfgTesting = ((BaseUnityPlugin)this).Config.Bind("Debugging", "Testing", false, "For debugging purposes"); logger = ((BaseUnityPlugin)Instance).Logger; harmony.PatchAll(); ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "snowylibassets")); InitializeNetworkBehaviours(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.SnowyLib v1.1.4 has loaded!"); } private static void InitializeNetworkBehaviours() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } logger.LogDebug((object)"Finished initializing network behaviours"); } } public static class SmartAgentNavigatorExtensions { public static bool SmartCanPathToPoint(this SmartAgentNavigator nav, Vector3 pos) { //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) return Utils.SmartCanPathToPoint(((Component)nav.agent).transform.position, pos, nav.IsAgentOutside()); } public static bool SmartCanPathToPoint(this SmartAgentNavigator nav, Vector3 startPos, Vector3 endPos) { //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) return Utils.SmartCanPathToPoint(startPos, endPos, nav.IsAgentOutside()); } public static bool CanPathToPoint(this SmartAgentNavigator nav, Vector3 pos) { //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) return nav.CanPathToPoint(((Component)nav.agent).transform.position, pos) > 0f; } } public class StatusEffectController : MonoBehaviour { public enum ConflictResult { Allow, Replace, Deny } public List effects { get; private set; } = new List(); public PlayerControllerB? player => ((Component)this).gameObject.GetComponent(); public EnemyAI? enemy => ((Component)this).gameObject.GetComponent(); private void OnDestroy() { foreach (StatusEffect effect in effects) { effect.OnRemove(); } } private void Update() { foreach (StatusEffect item in effects.ToList()) { item.Tick(); if (item.isFinished || ((Object)(object)player != (Object)null && player.isPlayerDead && item.removeOnDeath) || ((Object)(object)enemy != (Object)null && enemy.isEnemyDead && item.removeOnDeath)) { item.OnRemove(); effects.Remove(item); } } } public void ApplyEffect(StatusEffect newEffect) { StatusEffect newEffect2 = newEffect; StatusEffect statusEffect = ((!string.IsNullOrEmpty(newEffect2.id)) ? effects.FirstOrDefault((StatusEffect e) => e.id == newEffect2.id) : null); if (statusEffect != null) { switch (newEffect2.onConflict(statusEffect, newEffect2)) { default: return; case ConflictResult.Replace: statusEffect.OnRemove(); effects.Remove(statusEffect); break; case ConflictResult.Deny: return; case ConflictResult.Allow: break; } } newEffect2.controller = this; newEffect2.OnApply(); effects.Add(newEffect2); } public void RemoveEffect() where T : StatusEffect { effects.RemoveAll(delegate(StatusEffect e) { if (e is T val) { val.OnRemove(); return true; } return false; }); } public void RemoveEffect(StatusEffect effect) { effect.OnRemove(); effects.Remove(effect); } public void RemoveEffect(Func predicate) { Func predicate2 = predicate; effects.RemoveAll(delegate(StatusEffect e) { if (predicate2(e)) { e.OnRemove(); return true; } return false; }); } public bool HasEffect() where T : StatusEffect { return effects.Any((StatusEffect e) => e is T); } public void ClearAll() { foreach (StatusEffect effect in effects) { effect.OnRemove(); } effects.Clear(); } } public abstract class StatusEffect { public StatusEffectController? controller; public string source; public string id; public float duration; public Func onConflict; public Action? onRemove; public bool removeOnDeath; public bool pauseInOrbit; public bool curableBySCP500; protected float elapsedTime; public bool isFinished => duration > 0f && elapsedTime >= duration; public float timeLeft => (duration > 0f) ? (duration - elapsedTime) : float.PositiveInfinity; protected StatusEffect(string source, string id, float duration, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.source = source; this.id = id; this.duration = duration; this.onConflict = onConflict ?? ((Func)((StatusEffect existing, StatusEffect incoming) => StatusEffectController.ConflictResult.Deny)); this.onRemove = onRemove; this.removeOnDeath = removeOnDeath; this.pauseInOrbit = pauseInOrbit; this.curableBySCP500 = curableBySCP500; base..ctor(); } public void Tick() { OnTick(); if (duration > 0f && (!pauseInOrbit || !StartOfRound.Instance.inShipPhase || Utils.inTestRoom)) { elapsedTime += Time.deltaTime; } } public virtual void OnApply() { } public virtual void OnTick() { } public void Remove() { onRemove?.Invoke(this); controller?.RemoveEffect(this); } public virtual void OnRemove() { onRemove?.Invoke(this); } } public class RandomIntervalActionEffect : StatusEffect { private BoundedRange randomInterval; private Action action; private float timeSinceLastInterval; private float nextInterval; public RandomIntervalActionEffect(BoundedRange randomInterval, Action action, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.randomInterval = randomInterval; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnApply() { nextInterval = randomInterval.GetRandomInRange(Utils.randomLocal); } public override void OnTick() { timeSinceLastInterval += Time.deltaTime; if (timeSinceLastInterval > nextInterval) { timeSinceLastInterval = 0f; nextInterval = randomInterval.GetRandomInRange(Utils.randomLocal); action(); } } } public class IntervalActionEffect : StatusEffect { private float interval; private Action action; private float timeSinceLastInterval; public IntervalActionEffect(float interval, Action action, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.interval = interval; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnTick() { timeSinceLastInterval += Time.deltaTime; if (timeSinceLastInterval > interval) { timeSinceLastInterval = 0f; action(); } } } public class OnRemoveActionEffect : StatusEffect { private Action action; public OnRemoveActionEffect(Action action, string source, string id = "", float duration = 0f, Func? onConflict = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.action = action; base..ctor(source, id, duration, onConflict, null, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnRemove() { action(); } } public class TickActionEffect : StatusEffect { private Action action; public TickActionEffect(Action action, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnTick() { action(); } } public class ChanceTickActionEffect : StatusEffect { private float chance; private Action action; public ChanceTickActionEffect(float chancePerSecond, Action action, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { chance = chancePerSecond; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnTick() { if (RandomExtensions.NextFloat(Utils.randomLocal, 0f, 1f) < Mathf.Clamp01(chance) * Time.deltaTime) { action(); } } } public class ConditionalActionEffect : StatusEffect { private Func condition; private Action action; private bool removeOnTrigger; private float cooldown; private int maxTriggerCount; private float timeSinceLastTrigger; private int triggerCount; public ConditionalActionEffect(Func condition, Action action, bool removeOnTrigger, string source, float cooldown = 0f, int maxTriggerCount = 0, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.condition = condition; this.action = action; this.removeOnTrigger = removeOnTrigger; this.cooldown = cooldown; this.maxTriggerCount = maxTriggerCount; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnTick() { timeSinceLastTrigger += Time.deltaTime; if (condition() && timeSinceLastTrigger > cooldown) { timeSinceLastTrigger = 0f; triggerCount++; action(); if (removeOnTrigger || (maxTriggerCount > 0 && triggerCount >= maxTriggerCount)) { Remove(); } } } } public class LerpValueEffect : StatusEffect { private Action setter; private float startValue; private float endValue; public LerpValueEffect(Action setter, float startValue, float endValue, float duration, string source, string id = "", Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.setter = setter; this.startValue = startValue; this.endValue = endValue; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnApply() { setter(startValue); } public override void OnTick() { elapsedTime += Time.deltaTime; float num = Mathf.Clamp01(elapsedTime / duration); float obj = Mathf.Lerp(startValue, endValue, num); setter(obj); } public override void OnRemove() { setter(endValue); } } public class RandomIntervalPhaseActionEffect : StatusEffect { private BoundedRange randomInterval; private BoundedRange randomPhaseDuration; private Action onStartAction; private Action tickAction; private Action onEndAction; private float timeSinceLastInterval; private float nextInterval; private float phaseTimer; public RandomIntervalPhaseActionEffect(BoundedRange randomInterval, BoundedRange randomPhaseDuration, Action onStartAction, Action tickAction, Action onEndAction, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.randomInterval = randomInterval; this.randomPhaseDuration = randomPhaseDuration; this.onStartAction = onStartAction; this.tickAction = tickAction; this.onEndAction = onEndAction; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnApply() { nextInterval = randomInterval.GetRandomInRange(Utils.randomLocal); } public override void OnTick() { if (phaseTimer <= 0f) { timeSinceLastInterval += Time.deltaTime; } if (timeSinceLastInterval > nextInterval) { timeSinceLastInterval = 0f; nextInterval = randomInterval.GetRandomInRange(Utils.randomLocal); phaseTimer = randomPhaseDuration.GetRandomInRange(Utils.randomLocal); onStartAction(phaseTimer); } if (phaseTimer > 0f) { phaseTimer -= Time.deltaTime; if (phaseTimer <= 0f) { onEndAction(); } else { tickAction(phaseTimer); } } } } public class CurveValueEffect : StatusEffect { private Action setter; private AnimationCurve curve; public CurveValueEffect(Action setter, AnimationCurve curve, float duration, string source, string id = "", Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.setter = setter; this.curve = curve; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnApply() { setter(curve.Evaluate(0f)); } public override void OnTick() { if (!(duration <= 0f)) { elapsedTime += Time.deltaTime; float num = Mathf.Clamp01(elapsedTime / duration); float obj = curve.Evaluate(num); setter(obj); } } public override void OnRemove() { setter(curve.Evaluate(1f)); } } public class DistributedActionEffect : StatusEffect { private int totalActions; private Action action; private List triggerTimes; private int currentIndex; public DistributedActionEffect(Action action, int totalActions, string source, string id = "", float duration = 0f, Func? onConflict = null, Action? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curableBySCP500 = true) { this.totalActions = totalActions; this.action = action; triggerTimes = new List(); base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curableBySCP500); } public override void OnApply() { triggerTimes.Clear(); float num = duration / (float)totalActions; for (int i = 0; i < totalActions; i++) { float num2 = (float)i * num; float num3 = num2 + num; float item = RandomExtensions.NextFloat(Utils.randomLocal, num2, num3); triggerTimes.Add(item); } triggerTimes.Sort(); currentIndex = 0; } public override void OnTick() { while (currentIndex < triggerTimes.Count && elapsedTime >= triggerTimes[currentIndex]) { action(); currentIndex++; } } } public class TestingHUDOverlay : MonoBehaviour { [SerializeField] private GameObject toggle1Obj; [SerializeField] private Text toggle1Label; [SerializeField] private Toggle toggle1; [SerializeField] private GameObject toggle2Obj; [SerializeField] private Text toggle2Label; [SerializeField] private Toggle toggle2; [SerializeField] private Text label1; [SerializeField] private Text label2; [SerializeField] private Text label3; public static TestingHUDOverlay? Instance { get; private set; } public static void Init(GameObject prefab) { Instance = Object.Instantiate(prefab).GetComponent(); } public void Start() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public void Update() { toggle1Obj.SetActive(toggle1Label.text != ""); toggle2Obj.SetActive(toggle2Label.text != ""); } public void SetToggle1(string label, bool value) { toggle1Label.text = label; toggle1.isOn = value; } public void SetToggle2(string label, bool value) { toggle2Label.text = label; toggle2.isOn = value; } public void SetLabel1(string value) { label1.text = value; } public void SetLabel2(string value) { label2.text = value; } public void SetLabel3(string value) { label3.text = value; } } public static class Utils { public static bool DEBUG_disableSpawning = false; public static bool localPlayerFrozen = false; public static List entrances = new List(); public static MineshaftElevatorController? elevator; public static Terminal? terminal; public static BoundedRange randomPercentage = new BoundedRange(0f, 1f); public static UnityEvent OnFinishGeneratingLevel = new UnityEvent(); public static bool testing => Plugin.cfgTesting.Value; public static bool inTestRoom => (Object)(object)StartOfRound.Instance?.testRoom != (Object)null; public static GameObject[] allAINodes => insideAINodes.Concat(outsideAINodes).ToArray(); public static GameObject[] insideAINodes { get { if (RoundManager.Instance.insideAINodes != null && RoundManager.Instance.insideAINodes.Length != 0) { return RoundManager.Instance.insideAINodes; } return GameObject.FindGameObjectsWithTag("AINode"); } } public static GameObject[] outsideAINodes { get { if (RoundManager.Instance.outsideAINodes != null && RoundManager.Instance.outsideAINodes.Length != 0) { return RoundManager.Instance.outsideAINodes; } return GameObject.FindGameObjectsWithTag("OutsideAINode"); } } public static Random randomLocal { get; private set; } = new Random(); public static Random randomGlobal { get; private set; } = new Random(); public static void SetRandoms() { randomLocal = new Random(StartOfRound.Instance.randomMapSeed); randomGlobal = new Random(StartOfRound.Instance.randomMapSeed); } public static bool SmartCanPathToPoint(Vector3 startPos, Vector3 endPos, bool isOutside) { //IL_0006: 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_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_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_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_0082: 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_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_01d0: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_01ed: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0138: 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_0143: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0181: Unknown result type (might be due to invalid IL or missing references) bool flag = !isOutside; if (CanPathToPoint(startPos, endPos)) { return true; } if (entrances.Count <= 0 && (Object)(object)elevator == (Object)null) { return false; } Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; Vector3 val3 = Vector3.zero; if ((Object)(object)elevator != (Object)null) { val = elevator.elevatorTopPoint.position; val2 = elevator.elevatorBottomPoint.position; val3 = elevator.elevatorInsidePoint.position; } if (entrances != null) { foreach (EntranceTeleport entrance in entrances) { if ((flag ? (!entrance.isEntranceToBuilding) : entrance.isEntranceToBuilding) && (!((Object)(object)entrance.exitScript == (Object)null) || entrance.FindExitPoint())) { Vector3 position = entrance.entrancePoint.position; Vector3 position2 = entrance.exitScript.entrancePoint.position; if (CanPathToPoint(startPos, position) && CanPathToPoint(position2, endPos)) { return true; } if ((Object)(object)elevator != (Object)null && CanPathToPoint(startPos, val2) && CanPathToPoint(val, position) && CanPathToPoint(position2, endPos)) { return true; } } } } if ((Object)(object)elevator != (Object)null) { if (flag && Vector3.Distance(startPos, val3) < 1f) { if (CanPathToPoint(val, endPos) || CanPathToPoint(val2, endPos)) { return true; } } else { if (CanPathToPoint(startPos, val2) && CanPathToPoint(val, endPos)) { return true; } if (flag && CanPathToPoint(startPos, val) && CanPathToPoint(val2, endPos)) { return true; } } } return false; } public static bool CanPathToPoint(Vector3 startPos, Vector3 endPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0050: 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) NavMeshPath val = new NavMeshPath(); if (!NavMesh.CalculatePath(startPos, endPos, -1, val) || (int)val.status > 0) { return false; } float num = 0f; if (val.corners.Length > 1) { for (int i = 1; i < val.corners.Length; i++) { num += Vector3.Distance(val.corners[i - 1], val.corners[i]); } } return num > 0f; } public static void ChatCommand(string[] args) { if (!testing) { return; } switch (args[0]) { case "/spawning": DEBUG_disableSpawning = !DEBUG_disableSpawning; HUDManager.Instance.DisplayTip("Disable Spawning", DEBUG_disableSpawning.ToString(), false, false, "LC_Tip1"); break; case "/hazards": { Dictionary allHazards = GetAllHazards(); { foreach (KeyValuePair item in allHazards) { Plugin.logger.LogDebug((object)item); } break; } } case "/surfaces": { FootstepSurface[] footstepSurfaces = StartOfRound.Instance.footstepSurfaces; foreach (FootstepSurface val3 in footstepSurfaces) { Plugin.logger.LogDebug((object)val3.surfaceTag); } break; } case "/enemies": { foreach (SpawnableEnemyWithRarity enemy in GetEnemies()) { Plugin.logger.LogDebug((object)((Object)enemy.enemyType).name); } break; } case "/refresh": RoundManager.Instance.RefreshEnemiesList(); HoarderBugAI.RefreshGrabbableObjectsInMapList(); break; case "/levels": { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val2 in levels) { Plugin.logger.LogDebug((object)((Object)val2).name); } break; } case "/dungeon": Plugin.logger.LogDebug((object)((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name); break; case "/dungeons": { IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { Plugin.logger.LogDebug((object)((Object)val.dungeonFlow).name); } break; } case "/animations": LogAnimatorParameters(Plugin.localPlayer.playerBodyAnimator); break; } } public static void LogAnimatorParameters(Animator animator) { //IL_0016: 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_001d: 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_0020: 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_0038: Expected I4, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 AnimatorControllerParameter[] parameters = animator.parameters; foreach (AnimatorControllerParameter val in parameters) { AnimatorControllerParameterType type = val.type; AnimatorControllerParameterType val2 = type; switch (val2 - 1) { case 3: Plugin.logger.LogDebug((object)$"{val.name} (Bool) = {animator.GetBool(val.name)}"); continue; case 0: Plugin.logger.LogDebug((object)$"{val.name} (Float) = {animator.GetFloat(val.name)}"); continue; case 2: Plugin.logger.LogDebug((object)$"{val.name} (Int) = {animator.GetInteger(val.name)}"); continue; case 1: continue; } if ((int)val2 == 9) { Plugin.logger.LogDebug((object)(val.name + " (Trigger)")); } } } public static Vector3 GetBestThrowDirection(Vector3 origin, Vector3 forward, int rayCount, float maxDistance, LayerMask layerMask) { //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_0028: 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_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) //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_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_00a1: 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_0089: 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_00a6: 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_007b: Unknown result type (might be due to invalid IL or missing references) Vector3 result = forward; float num = 0f; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < rayCount; i++) { float num2 = (float)i * (360f / (float)rayCount); Vector3 val = Quaternion.Euler(0f, num2, 0f) * ((Vector3)(ref forward)).normalized; if (Physics.Raycast(origin + Vector3.up * 0.5f, val, ref val2, maxDistance, LayerMask.op_Implicit(layerMask))) { if (((RaycastHit)(ref val2)).distance > num) { result = val; num = ((RaycastHit)(ref val2)).distance; } continue; } return val; } return result; } public static List GetEnemies() { List list = new List(); return (from x in GameObject.Find("Terminal").GetComponentInChildren().moonsCatalogueList.SelectMany((SelectableLevel x) => x.Enemies.Concat(x.DaytimeEnemies).Concat(x.OutsideEnemies)) where x != null && (Object)(object)x.enemyType != (Object)null && ((Object)x.enemyType).name != null select x).GroupBy((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name, (string k, IEnumerable v) => v.First()).ToList(); } public static Dictionary GetAllHazards() { Dictionary dictionary = new Dictionary(); List list = (from x in StartOfRound.Instance.levels.SelectMany((SelectableLevel level) => level.spawnableMapObjects) group x by ((Object)x.prefabToSpawn).name into g select g.First()).ToList(); foreach (SpawnableMapObject item in list) { dictionary.Add(((Object)item.prefabToSpawn).name, item.prefabToSpawn); } return dictionary; } public static Vector3 GetRandomNavMeshPositionInAnnulus(Vector3 center, float minRadius, float maxRadius, int sampleCount = 10) { //IL_0001: 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_00b2: 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_0036: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00ae: 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_0084: 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) float y = center.y; if (minRadius >= maxRadius) { Plugin.logger.LogWarning((object)"minRadius should be less than maxRadius. Returning original position."); return center; } NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < sampleCount; i++) { Vector3 insideUnitSphere = Random.insideUnitSphere; insideUnitSphere.y = 0f; ((Vector3)(ref insideUnitSphere)).Normalize(); float num = Random.Range(minRadius, maxRadius); Vector3 val = center + insideUnitSphere * num; val.y = y; if (NavMesh.SamplePosition(val, ref val2, 2f, -1)) { return ((NavMeshHit)(ref val2)).position; } } Plugin.logger.LogWarning((object)"Unable to find valid NavMesh position in annulus. Returning original position."); return center; } public static List GetEvenlySpacedNavMeshPositions(Vector3 center, int count, float minRadius, float maxRadius) { //IL_002f: 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_0086: 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_00ad: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (count <= 0 || minRadius > maxRadius) { Plugin.logger.LogWarning((object)"Invalid parameters for turret spawn positions."); return list; } float y = center.y; float num = 360f / (float)count; Vector3 val = default(Vector3); NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < count; i++) { float num2 = (float)i * num; float num3 = num2 * (MathF.PI / 180f); float num4 = Random.Range(minRadius, maxRadius); float num5 = Mathf.Cos(num3) * num4; float num6 = Mathf.Sin(num3) * num4; ((Vector3)(ref val))..ctor(center.x + num5, y, center.z + num6); if (NavMesh.SamplePosition(val, ref val2, 2f, -1)) { list.Add(((NavMeshHit)(ref val2)).position); } else { Plugin.logger.LogWarning((object)$"Could not find valid NavMesh position for turret {i}. Skipping."); } } return list; } public static EnemyAI? SpawnEnemy(NamespacedKey key, Vector3 position, Quaternion rotation = default(Quaternion)) { //IL_0027: 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) if (!Plugin.IsServerOrHost) { return null; } GameObject val = Object.Instantiate(((Registry)(object)LethalContent.Enemies)[key].EnemyType.enemyPrefab, position, rotation); EnemyAI component = val.GetComponent(); ((NetworkBehaviour)component).NetworkObject.Spawn(false); return component; } public static GrabbableObject? SpawnItem(NamespacedKey key, Vector3 position, Quaternion rotation = default(Quaternion), Transform? parentTo = null, float fallTime = 0f) { //IL_0027: 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) if (!Plugin.IsServerOrHost) { return null; } GameObject val = Object.Instantiate(((Registry)(object)LethalContent.Items)[key].Item.spawnPrefab, position, rotation, parentTo); GrabbableObject component = val.GetComponent(); component.fallTime = fallTime; ((NetworkBehaviour)component).NetworkObject.Spawn(false); return component; } public static PlayerControllerB[] GetNearbyPlayers(Vector3 position, float distance = 10f, List? ignoredPlayers = null) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) List list = new List(); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && (ignoredPlayers == null || !ignoredPlayers.Contains(val)) && !(Vector3.Distance(position, ((Component)val).transform.position) > distance)) { list.Add(val); } } return list.ToArray(); } public static void PlaySoundAtPosition(Transform pos, AudioClip clip, float volume = 1f, bool randomizePitch = true, bool spatial3D = true, float min3DDistance = 1f, float max3DDistance = 10f, float cutoffFrequency = 22000f, int audibleNoiseID = 0) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(new GameObject("TempSoundEffectObj"), pos); AudioSource val2 = val.AddComponent(); OccludeAudio val3 = val.AddComponent(); val3.lowPassOverride = 20000f; AudioLowPassFilter val4 = val.AddComponent(); val4.cutoffFrequency = cutoffFrequency; val2.rolloffMode = (AudioRolloffMode)1; if (randomizePitch) { val2.pitch = Random.Range(0.94f, 1.06f); } val2.clip = clip; val2.volume = volume; val2.spatialBlend = (spatial3D ? 1 : 0); val2.minDistance = min3DDistance; val2.maxDistance = max3DDistance; val2.Play(); Object.Destroy((Object)(object)val, val2.clip.length); WalkieTalkie.TransmitOneShotAudio(val2, clip, 0.85f); if (spatial3D && audibleNoiseID >= 0) { RoundManager.Instance.PlayAudibleNoise(((Component)val2).transform.position, 4f * volume, volume / 2f, 0, true, audibleNoiseID); } } public static void PlaySoundAtPosition(Vector3 pos, AudioClip clip, float volume = 1f, bool randomizePitch = true, bool spatial3D = true, float min3DDistance = 1f, float max3DDistance = 10f, float cutoffFrequency = 22000f, int audibleNoiseID = 0) { //IL_0006: 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_0016: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(new GameObject("TempSoundEffectObj"), pos, Quaternion.identity); AudioSource val2 = val.AddComponent(); OccludeAudio val3 = val.AddComponent(); val3.lowPassOverride = 20000f; AudioLowPassFilter val4 = val.AddComponent(); val4.cutoffFrequency = cutoffFrequency; val2.rolloffMode = (AudioRolloffMode)1; if (randomizePitch) { val2.pitch = Random.Range(0.94f, 1.06f); } val2.clip = clip; val2.volume = volume; val2.spatialBlend = (spatial3D ? 1 : 0); val2.minDistance = min3DDistance; val2.maxDistance = max3DDistance; val2.Play(); Object.Destroy((Object)(object)val, val2.clip.length); WalkieTalkie.TransmitOneShotAudio(val2, clip, 0.85f); if (spatial3D && audibleNoiseID >= 0) { RoundManager.Instance.PlayAudibleNoise(((Component)val2).transform.position, 4f * volume, volume / 2f, 0, true, audibleNoiseID); } } public static void PlaySoundAtPosition(Transform pos, AudioClip[] clips, float volume = 1f, bool randomizePitch = true, bool spatial3D = true, float min3DDistance = 1f, float max3DDistance = 10f, float cutoffFrequency = 22000f, int audibleNoiseID = 0) { int num = Random.Range(0, clips.Length); PlaySoundAtPosition(pos, clips[num], volume, randomizePitch, spatial3D, min3DDistance, max3DDistance, cutoffFrequency, audibleNoiseID); } public static void PlaySoundAtPosition(Vector3 pos, AudioClip[] clips, float volume = 1f, bool randomizePitch = true, bool spatial3D = true, float min3DDistance = 1f, float max3DDistance = 10f, float cutoffFrequency = 22000f, int audibleNoiseID = 0) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(0, clips.Length); PlaySoundAtPosition(pos, clips[num], volume, randomizePitch, spatial3D, min3DDistance, max3DDistance, cutoffFrequency, audibleNoiseID); } public static PlayerControllerB GetRandomPlayer(Random random) { PlayerControllerB[] array = StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB p) => (Object)(object)p != (Object)null && p.isPlayerControlled).ToArray(); return (array.Length == 0) ? StartOfRound.Instance.allPlayerScripts[random.Next(StartOfRound.Instance.allPlayerScripts.Length)] : array[random.Next(array.Length)]; } public static PlayerControllerB GetRandomPlayer() { PlayerControllerB[] array = StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB p) => (Object)(object)p != (Object)null && p.isPlayerControlled).ToArray(); return (array.Length == 0) ? StartOfRound.Instance.allPlayerScripts[Random.Range(0, StartOfRound.Instance.allPlayerScripts.Length)] : array[Random.Range(0, array.Length)]; } public static void DespawnItemInSlotOnClient(int itemSlot) { ((Behaviour)HUDManager.Instance.itemSlotIcons[itemSlot]).enabled = false; Plugin.localPlayer.DestroyItemInSlotAndSync(itemSlot); } public static void LogChat(string msg) { HUDManager.Instance.AddChatMessage(msg, "Server", -1, false); } } [HarmonyPatch] public class UtilsPatches { [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnInsideEnemiesFromVentsIfReady")] public static bool SpawnInsideEnemiesFromVentsIfReadyPrefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnDaytimeEnemiesOutside")] public static bool SpawnDaytimeEnemiesOutsidePrefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnEnemiesOutside")] public static bool SpawnEnemiesOutsidePrefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")] public static void FinishGeneratingLevelPostfix() { try { Utils.elevator = null; Utils.entrances.Clear(); Utils.entrances = Object.FindObjectsOfType(false).ToList(); Utils.elevator = Object.FindObjectOfType(); Utils.SetRandoms(); Utils.OnFinishGeneratingLevel.Invoke(); } catch { } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance) { try { Utils.terminal = Object.FindObjectOfType(); } catch { } } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] public static void SubmitChat_performedPrefix(HUDManager __instance) { try { if (Utils.testing) { string text = __instance.chatTextField.text; string[] args = text.Split(" "); Utils.ChatCommand(args); } } catch (Exception ex) { Plugin.logger.LogError((object)ex); } } } public class VignetteOverlay : MonoBehaviour { [SerializeField] private Image visual = null; private Material material = null; private static readonly int InsetId = Shader.PropertyToID("_Inset"); public float intensityDecreasePerSecond = 0.01f; private float currentIntensity; public static VignetteOverlay Instance { get; private set; } = null; private void Awake() { material = ((Graphic)visual).material; } private void Update() { if (!(currentIntensity <= 0f)) { currentIntensity = Mathf.Max(0f, currentIntensity - intensityDecreasePerSecond * Time.deltaTime); material.SetFloat(InsetId, currentIntensity); } } public void SetIntensity(float intensity, float intensityDecreasePerSecond = 0.01f) { this.intensityDecreasePerSecond = intensityDecreasePerSecond; currentIntensity = Mathf.Clamp01(intensity); material.SetFloat(InsetId, currentIntensity); } public static void Init(PlayerControllerB player) { GameObject val = Plugin.ModAssets.LoadAsset("Assets/ModAssets/VignetteOverlay.prefab"); Instance = Object.Instantiate(val, ((Component)player).transform).GetComponent(); } } [HarmonyPatch] public class VignetteOverlayPatches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance) { try { VignetteOverlay.Init(__instance); } catch { } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Snowlance.SnowyLib"; public const string PLUGIN_NAME = "SnowyLib"; public const string PLUGIN_VERSION = "1.1.4"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace Snowlance.SnowyLib.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }