Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SnowyLib v1.3.7
Snowlance.SnowyLib.dll
Decompiled 15 hours agousing 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 TMPro; 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.3.7.0")] [assembly: AssemblyInformationalVersion("1.3.7+7e233be16691980841918623f1973f422394b3a7")] [assembly: AssemblyProduct("SnowyLib")] [assembly: AssemblyTitle("Snowlance.SnowyLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.7.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 SnowyLib { public class AutoDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TValue : new() { private readonly Func<TKey, TValue> _factory; public new TValue this[TKey key] { get { if (!TryGetValue(key, out var value)) { value = (base[key] = _factory(key)); } return value; } set { base[key] = value; } } public AutoDictionary(Func<TKey, TValue> factory) { _factory = factory; } } public static class EnemyAIExtensions { public static StatusEffectController StatusEffectController(this EnemyAI enemy) { StatusEffectController statusEffectController = default(StatusEffectController); return ((Component)enemy).gameObject.TryGetComponent<StatusEffectController>(ref statusEffectController) ? statusEffectController : ((Component)enemy).gameObject.AddComponent<StatusEffectController>(); } } public static class GameObjectExtensions { public static StatusEffectController StatusEffectController(this GameObject gameObject) { StatusEffectController statusEffectController = default(StatusEffectController); return gameObject.TryGetComponent<StatusEffectController>(ref statusEffectController) ? statusEffectController : gameObject.AddComponent<StatusEffectController>(); } public static bool TryGetComponentInChildren<T>(this GameObject go, out T? component) where T : Component { component = go.GetComponentInChildren<T>(); return (Object)(object)component != (Object)null; } } public static class IEnumerableExtensions { public static T? GetRandom<T>(this IEnumerable<T> source, Random random) where T : class { if (source is IList<T> 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<T>(this IEnumerable<T> source) where T : class { if (source is IList<T> 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<T>(this IEnumerable<T> list, Vector3 position, Func<T, Vector3> positionSelector, out float closestDistance, bool skipSqrt = false, IEnumerable<T>? excluded = null) where T : class { //IL_005b: 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_004c: 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) T result = null; closestDistance = float.PositiveInfinity; if (excluded == null) { excluded = Array.Empty<T>(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num; if (!skipSqrt) { num = Vector3.Distance(position, positionSelector(item)); } else { Vector3 val = position - positionSelector(item); num = ((Vector3)(ref val)).sqrMagnitude; } float num2 = num; if (!(num2 >= closestDistance)) { result = item; closestDistance = num2; } } } return result; } public static T? GetClosestToPosition<T>(this IEnumerable<T> list, Vector3 position, Func<T, Vector3> positionSelector, bool skipSqrt = false, IEnumerable<T>? excluded = null) where T : class { //IL_0059: 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_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_004a: 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) T result = null; float num = float.PositiveInfinity; if (excluded == null) { excluded = Array.Empty<T>(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num2; if (!skipSqrt) { num2 = Vector3.Distance(position, positionSelector(item)); } else { Vector3 val = position - positionSelector(item); num2 = ((Vector3)(ref val)).sqrMagnitude; } float num3 = num2; if (!(num3 >= num)) { result = item; num = num3; } } } return result; } public static T? GetFarthestFromPosition<T>(this IEnumerable<T> list, Vector3 position, Func<T, Vector3> positionSelector, out float farthestDistance, bool skipSqrt = false, IEnumerable<T>? excluded = null) where T : class { //IL_005b: 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_004c: 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) T result = null; farthestDistance = 0f; if (excluded == null) { excluded = Array.Empty<T>(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num; if (!skipSqrt) { num = Vector3.Distance(position, positionSelector(item)); } else { Vector3 val = position - positionSelector(item); num = ((Vector3)(ref val)).sqrMagnitude; } float num2 = num; if (!(num2 <= farthestDistance)) { result = item; farthestDistance = num2; } } } return result; } public static T? GetFarthestFromPosition<T>(this IEnumerable<T> list, Vector3 position, Func<T, Vector3> positionSelector, bool skipSqrt = false, IEnumerable<T>? excluded = null) where T : class { //IL_0059: 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_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_004a: 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) T result = null; float num = 0f; if (excluded == null) { excluded = Array.Empty<T>(); } foreach (T item in list) { if (item != null && !excluded.Contains(item)) { float num2; if (!skipSqrt) { num2 = Vector3.Distance(position, positionSelector(item)); } else { Vector3 val = position - positionSelector(item); num2 = ((Vector3)(ref val)).sqrMagnitude; } float num3 = num2; if (!(num3 <= num)) { result = item; num = num3; } } } return result; } public static IEnumerable<T> GetInRange<T>(this IEnumerable<T> list, Vector3 position, Func<T, Vector3> positionSelector, float range, IEnumerable<T>? 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<T> list2 = new List<T>(); if (excluded == null) { excluded = Array.Empty<T>(); } foreach (T item in list) { if (item != null && !excluded.Contains(item) && Vector3.Distance(position, positionSelector(item)) < range) { list2.Add(item); } } return list2; } } public static class PlayerControllerBExtensions { public static StatusEffectController StatusEffectController(this PlayerControllerB player) { StatusEffectController statusEffectController = default(StatusEffectController); return ((Component)player).gameObject.TryGetComponent<StatusEffectController>(ref statusEffectController) ? statusEffectController : ((Component)player).gameObject.AddComponent<StatusEffectController>(); } public static bool GrabGrabbableObject(this PlayerControllerB player, GrabbableObject grabbableObject) { //IL_0235: Unknown result type (might be due to invalid IL or missing references) if (player.twoHanded || player.sinkingValue > 0.73f) { return false; } player.currentlyGrabbingObject = grabbableObject; if (!GameNetworkManager.Instance.gameHasStarted && !player.currentlyGrabbingObject.itemProperties.canBeGrabbedBeforeGameStart && (Object)(object)StartOfRound.Instance.testRoom == (Object)null) { return false; } player.grabInvalidated = false; if ((Object)(object)player.currentlyGrabbingObject == (Object)null || player.inSpecialInteractAnimation || player.currentlyGrabbingObject.isHeld || player.currentlyGrabbingObject.isPocketed) { return false; } NetworkObject networkObject = ((NetworkBehaviour)player.currentlyGrabbingObject).NetworkObject; if ((Object)(object)networkObject == (Object)null || !networkObject.IsSpawned) { return false; } player.currentlyGrabbingObject.InteractItem(); if (!player.currentlyGrabbingObject.grabbable || player.FirstEmptyItemSlot(player.currentlyGrabbingObject) == -1) { return false; } player.playerBodyAnimator.SetBool("GrabInvalidated", false); player.playerBodyAnimator.SetBool("GrabValidated", false); player.playerBodyAnimator.SetBool("cancelHolding", false); player.playerBodyAnimator.ResetTrigger("Throw"); player.SetSpecialGrabAnimationBool(true, (GrabbableObject)null); player.isGrabbingObjectAnimation = true; ((Behaviour)player.cursorIcon).enabled = false; ((TMP_Text)player.cursorTip).text = ""; player.twoHanded = player.currentlyGrabbingObject.itemProperties.twoHanded; player.carryWeight = Mathf.Clamp(player.carryWeight + (player.currentlyGrabbingObject.itemProperties.weight - 1f), 1f, 10f); StartOfRound.Instance.SendChangedWeightEvent(); if (player.currentlyGrabbingObject.itemProperties.grabAnimationTime > 0f) { player.grabObjectAnimationTime = player.currentlyGrabbingObject.itemProperties.grabAnimationTime; } else { player.grabObjectAnimationTime = 0.4f; } if (!player.isTestingPlayer) { player.GrabObjectServerRpc(NetworkObjectReference.op_Implicit(networkObject)); } if (player.grabObjectCoroutine != null) { ((MonoBehaviour)player).StopCoroutine(player.grabObjectCoroutine); } player.grabObjectCoroutine = ((MonoBehaviour)player).StartCoroutine(player.GrabObject()); return true; } 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 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<RigBuilder>(); 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<AudioLowPassFilter>().lowpassResonanceQ = (muffle ? 5f : 1f); OccludeAudio component = ((Component)player.currentVoiceChatAudioSource).GetComponent<OccludeAudio>(); component.overridingLowPass = muffle; component.lowPassOverride = (muffle ? 500f : 20000f); player.voiceMuffledByEnemy = muffle; } } } 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 static class Vector3Extensions { 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 T? GetClosestGameObjectOfType<T>(this 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>(); 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 PlayerControllerB[] GetNearbyPlayers(this Vector3 position, float distance = 10f, List<PlayerControllerB>? 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<PlayerControllerB> list = new List<PlayerControllerB>(); 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(); } } [BepInPlugin("Snowlance.SnowyLib", "SnowyLib", "1.3.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal 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<bool> cfgTesting; 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<bool>("Debugging", "Testing", false, "For debugging purposes"); logger = ((BaseUnityPlugin)Instance).Logger; harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.SnowyLib v1.3.7 has loaded!"); } } public class PositionInfo(Vector3 position, bool isOutside) { public Vector3 position = position; public bool isOutside = isOutside; } public class StatusEffectController : MonoBehaviour { public enum ConflictResult { Allow, Replace, Deny } public List<StatusEffect> effects { get; private set; } = new List<StatusEffect>(); public PlayerControllerB? player => ((Component)this).gameObject.GetComponent<PlayerControllerB>(); public EnemyAI? enemy => ((Component)this).gameObject.GetComponent<EnemyAI>(); 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 statusEffect = ((!string.IsNullOrEmpty(newEffect.id)) ? effects.FirstOrDefault((StatusEffect e) => e.id == newEffect.id) : null); if (statusEffect != null) { switch (newEffect.onConflict(statusEffect, newEffect)) { default: return; case ConflictResult.Replace: statusEffect.OnRemove(); effects.Remove(statusEffect); break; case ConflictResult.Deny: return; case ConflictResult.Allow: break; } } newEffect.controller = this; newEffect.OnApply(); effects.Add(newEffect); } public void RemoveEffect<T>() 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<StatusEffect, bool> predicate) { effects.RemoveAll(delegate(StatusEffect e) { if (predicate(e)) { e.OnRemove(); return true; } return false; }); } public bool HasEffect<T>() 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult> onConflict; public Action<StatusEffect>? onRemove; public bool removeOnDeath; public bool pauseInOrbit; public bool curable; 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.source = source; this.id = id; this.duration = duration; this.onConflict = onConflict ?? ((Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>)((StatusEffect existing, StatusEffect incoming) => StatusEffectController.ConflictResult.Deny)); this.onRemove = onRemove; this.removeOnDeath = removeOnDeath; this.pauseInOrbit = pauseInOrbit; this.curable = curable; 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.randomInterval = randomInterval; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.interval = interval; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.action = action; base..ctor(source, id, duration, onConflict, null, removeOnDeath, pauseInOrbit, curable); } public override void OnRemove() { action(); } } public class TickActionEffect : StatusEffect { private Action action; public TickActionEffect(Action action, string source, string id = "", float duration = 0f, Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { chance = chancePerSecond; this.action = action; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } public override void OnTick() { if (RandomExtensions.NextFloat(Utils.randomLocal, 0f, 1f) < Mathf.Clamp01(chance) * Time.deltaTime) { action(); } } } public class ConditionalActionEffect : StatusEffect { private Func<bool> condition; private Action action; private bool removeOnTrigger; private float cooldown; private int maxTriggerCount; private float timeSinceLastTrigger; private int triggerCount; public ConditionalActionEffect(Func<bool> condition, Action action, bool removeOnTrigger, string source, float cooldown = 0f, int maxTriggerCount = 0, string id = "", float duration = 0f, Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = 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, curable); } 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<float> setter; private float startValue; private float endValue; public LerpValueEffect(Action<float> setter, float startValue, float endValue, float duration, string source, string id = "", Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.setter = setter; this.startValue = startValue; this.endValue = endValue; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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<float> onStartAction; private Action<float> tickAction; private Action onEndAction; private float timeSinceLastInterval; private float nextInterval; private float phaseTimer; public RandomIntervalPhaseActionEffect(BoundedRange randomInterval, BoundedRange randomPhaseDuration, Action<float> onStartAction, Action<float> tickAction, Action onEndAction, string source, string id = "", float duration = 0f, Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = 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, curable); } 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<float> setter; private AnimationCurve curve; public CurveValueEffect(Action<float> setter, AnimationCurve curve, float duration, string source, string id = "", Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.setter = setter; this.curve = curve; base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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<float> triggerTimes; private int currentIndex; public DistributedActionEffect(Action action, int totalActions, string source, string id = "", float duration = 0f, Func<StatusEffect, StatusEffect, StatusEffectController.ConflictResult>? onConflict = null, Action<StatusEffect>? onRemove = null, bool removeOnDeath = true, bool pauseInOrbit = true, bool curable = true) { this.totalActions = totalActions; this.action = action; triggerTimes = new List<float>(); base..ctor(source, id, duration, onConflict, onRemove, removeOnDeath, pauseInOrbit, curable); } 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 static class Utils { public enum ContentType { Item, Enemy, MapObject } public static bool DEBUG_disableSpawning = false; public static bool DEBUG_disableTime = false; public static bool localPlayerFrozen = false; public static List<GrabbableObject> spawnedItems = new List<GrabbableObject>(); public static List<EntranceTeleport> entrances = new List<EntranceTeleport>(); public static MineshaftElevatorController? elevator; public static Terminal? terminal; public static BoundedRange randomPercentage = new BoundedRange(0f, 1f); public static UnityEvent OnFinishGeneratingLevel = new UnityEvent(); public static UnityEvent OnShipLanded = 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(); internal static void SetRandoms() { randomLocal = new Random(StartOfRound.Instance.randomMapSeed); randomGlobal = new Random(StartOfRound.Instance.randomMapSeed); } 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<string, GameObject> allHazards = GetAllHazards(); { foreach (KeyValuePair<string, GameObject> 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; case "/rarities": switch (args[1]) { case "item": LogRarities(ContentType.Item); break; case "enemy": LogRarities(ContentType.Enemy); break; case "mapobject": LogRarities(ContentType.MapObject); break; } break; case "/vignette": VignetteOverlay.Instance.SetIntensity(float.Parse(args[1])); HUDManager.Instance.DisplayTip("SnowyLib", "Vignette intensity set to " + args[1], false, false, "LC_Tip1"); break; case "/spawnanim": Plugin.localPlayer.SpawnPlayerAnimation(); break; case "/time": DEBUG_disableTime = !DEBUG_disableTime; StartOfRound.Instance.currentLevel.planetHasTime = !DEBUG_disableTime; HUDManager.Instance.DisplayTip("Snowylib", "disableTime: " + DEBUG_disableTime, false, false, "LC_Tip1"); break; } } 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 LogRarities(ContentType contentType) { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { Plugin.logger.LogDebug((object)("- " + ((Object)val).name + ":")); switch (contentType) { case ContentType.Item: foreach (SpawnableItemWithRarity item in val.spawnableScrap) { Plugin.logger.LogDebug((object)$"-- {item.spawnableItem.itemName}: {item.rarity}"); } break; case ContentType.Enemy: foreach (SpawnableEnemyWithRarity enemy in val.Enemies) { Plugin.logger.LogDebug((object)$"-- {((Object)enemy.enemyType).name}: {enemy.rarity}"); } break; case ContentType.MapObject: { SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects; foreach (SpawnableMapObject val2 in spawnableMapObjects) { Plugin.logger.LogDebug((object)("-- " + ((Object)val2.prefabToSpawn).name + ":")); Debug.Log((object)string.Join("\n", val2.numberToSpawn.keys.Select((Keyframe k) => $"--- ({((Keyframe)(ref k)).time}, {((Keyframe)(ref k)).value})"))); } 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 bool FastInRange(Vector3 posA, Vector3 posB, float maxDistance) { //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) Vector3 val = posA - posB; return ((Vector3)(ref val)).sqrMagnitude <= maxDistance * maxDistance; } 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<SpawnableEnemyWithRarity> GetEnemies() { List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); return (from x in GameObject.Find("Terminal").GetComponentInChildren<Terminal>().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<SpawnableEnemyWithRarity> v) => v.First()).ToList(); } public static Dictionary<string, GameObject> GetAllHazards() { Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>(); List<SpawnableMapObject> 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<Vector3> 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<Vector3> list = new List<Vector3>(); 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<DawnEnemyInfo> key, Vector3 position, Quaternion rotation = default(Quaternion), Transform? parentTo = null, bool destroyWithScene = true) { //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<GameObject>(((Registry<DawnEnemyInfo>)(object)LethalContent.Enemies)[key].EnemyType.enemyPrefab, position, rotation, parentTo); EnemyAI component = val.GetComponent<EnemyAI>(); ((NetworkBehaviour)component).NetworkObject.Spawn(destroyWithScene); RoundManager.Instance.SpawnedEnemies.Add(component); return component; } public static GrabbableObject? SpawnItem(NamespacedKey<DawnItemInfo> key, Vector3 position, Quaternion rotation = default(Quaternion), Transform? parentTo = null, float fallTime = 0f, bool destroyWithScene = true) { //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<GameObject>(((Registry<DawnItemInfo>)(object)LethalContent.Items)[key].Item.spawnPrefab, position, rotation, parentTo); GrabbableObject component = val.GetComponent<GrabbableObject>(); component.fallTime = fallTime; ((NetworkBehaviour)component).NetworkObject.Spawn(destroyWithScene); return component; } public static SpawnableMapObject? SpawnMapObject(NamespacedKey<DawnMapObjectInfo> key, Vector3 position, Quaternion rotation = default(Quaternion), Transform? parentTo = null, bool destroyWithScene = true) { //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 (!Plugin.IsServerOrHost) { return null; } GameObject val = Object.Instantiate<GameObject>(((Registry<DawnMapObjectInfo>)(object)LethalContent.MapObjects)[key].GetMapObjectPrefab(), position, rotation, parentTo); SpawnableMapObject component = val.GetComponent<SpawnableMapObject>(); val.GetComponent<NetworkObject>().Spawn(destroyWithScene); return component; } 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<GameObject>(new GameObject("TempSoundEffectObj"), pos); AudioSource val2 = val.AddComponent<AudioSource>(); OccludeAudio val3 = val.AddComponent<OccludeAudio>(); val3.lowPassOverride = 20000f; AudioLowPassFilter val4 = val.AddComponent<AudioLowPassFilter>(); 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<GameObject>(new GameObject("TempSoundEffectObj"), pos, Quaternion.identity); AudioSource val2 = val.AddComponent<AudioSource>(); OccludeAudio val3 = val.AddComponent<OccludeAudio>(); val3.lowPassOverride = 20000f; AudioLowPassFilter val4 = val.AddComponent<AudioLowPassFilter>(); 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, string nameOfUserWhoTyped = "Server") { HUDManager.Instance.AddChatMessage(msg, nameOfUserWhoTyped, -1, false); } public static float SmartDistance(PositionInfo position1, PositionInfo position2) { //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_00c7: 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_00eb: 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) if (position1.isOutside == position2.isOutside) { return Vector3.Distance(position1.position, position2.position); } float num = float.PositiveInfinity; foreach (EntranceTeleport entrance in entrances) { if (!((Object)(object)entrance == (Object)null) && entrance.isEntranceToBuilding == position1.isOutside && (!((Object)(object)entrance.exitScript == (Object)null) || (!entrance.exitPointDoesntExist && entrance.FindExitPoint())) && !((Object)(object)entrance.exitScript == (Object)null)) { float num2 = Vector3.Distance(position1.position, ((Component)entrance).transform.position); float num3 = Vector3.Distance(((Component)entrance.exitScript).transform.position, position2.position); float num4 = num2 + num3; if (!(num4 > num)) { num = num4; } } } return num; } public static Texture2D? LoadEmbeddedTexture(string resourceName) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourceName); if (stream == null) { Plugin.logger.LogError((object)("Resource not found: " + resourceName)); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); return val; } } [HarmonyPatch] public class UtilsPatches { [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnInsideEnemiesFromVentsIfReady")] public static bool RoundManager_SpawnInsideEnemiesFromVentsIfReady_Prefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnDaytimeEnemiesOutside")] public static bool RoundManager_SpawnDaytimeEnemiesOutside_Prefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPrefix] [HarmonyPatch(typeof(RoundManager), "SpawnEnemiesOutside")] public static bool RoundManager_SpawnEnemiesOutside_Prefix() { try { if (Utils.testing && Utils.DEBUG_disableSpawning) { return false; } return true; } catch { return true; } } [HarmonyPostfix] [HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")] public static void RoundManager_FinishGeneratingLevel_Postfix() { try { Utils.elevator = null; Utils.entrances.Clear(); Utils.entrances = Object.FindObjectsOfType<EntranceTeleport>(false).ToList(); Utils.elevator = Object.FindObjectOfType<MineshaftElevatorController>(); Utils.SetRandoms(); Utils.OnFinishGeneratingLevel.Invoke(); } catch { } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")] public static void StartOfRound_OnShipLandedMiscEvents_Postfix() { try { Utils.OnShipLanded.Invoke(); } catch { } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void PlayerControllerB_ConnectClientToPlayerObject_Postfix(PlayerControllerB __instance) { try { Utils.terminal = Object.FindObjectOfType<Terminal>(); } catch { } } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] public static void HUDManager_SubmitChat_performed_Prefix(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); } } [HarmonyPostfix] [HarmonyPatch(typeof(GrabbableObject), "Start")] public static void GrabbableObject_Start_Postfix(GrabbableObject __instance) { try { Utils.spawnedItems.Add(__instance); } catch (Exception ex) { Plugin.logger.LogError((object)ex); } } [HarmonyPostfix] [HarmonyPatch(typeof(GrabbableObject), "OnDestroy")] public static void GrabbableObject_OnDestroy_Postfix(GrabbableObject __instance) { try { Utils.spawnedItems.Remove(__instance); } catch (Exception ex) { Plugin.logger.LogError((object)ex); } } } public class VignetteOverlay : MonoBehaviour { private Image image = null; private RectTransform rt = null; private Texture2D? vignetteTexture; public static VignetteOverlay Instance { get; private set; } public float intensityDecreasePerSecond { get; private set; } = 0.01f; public float currentIntensity { get; private set; } private void Awake() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00bd: 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) //IL_00df: 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_0169: 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) Plugin.logger.LogWarning((object)"VignetteOverlay Awake running"); ((Component)this).gameObject.layer = LayerMask.NameToLayer("UI"); Canvas val = ((Component)this).gameObject.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 0; val.pixelPerfect = true; CanvasScaler val2 = ((Component)this).gameObject.AddComponent<CanvasScaler>(); val2.uiScaleMode = (ScaleMode)1; ((Component)this).gameObject.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("Vignette"); val3.layer = LayerMask.NameToLayer("UI"); val3.transform.SetParent(((Component)this).gameObject.transform, false); image = val3.AddComponent<Image>(); rt = val3.GetComponent<RectTransform>(); rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; ((Graphic)image).raycastTarget = false; vignetteTexture = Utils.LoadEmbeddedTexture("SnowyLib.Embedded.vignette.png"); if ((Object)(object)vignetteTexture == (Object)null) { Plugin.logger.LogError((object)"vignetteTexture is null"); } else { image.sprite = Sprite.Create(vignetteTexture, new Rect(0f, 0f, (float)((Texture)vignetteTexture).width, (float)((Texture)vignetteTexture).height), new Vector2(0.5f, 0.5f)); } } private void Update() { if (!(currentIntensity <= 0f)) { currentIntensity = Mathf.Max(0f, currentIntensity - intensityDecreasePerSecond * Time.deltaTime); Apply(currentIntensity); } } public void SetIntensity(float intensity, float intensityDecreasePerSecond = 0.01f) { this.intensityDecreasePerSecond = intensityDecreasePerSecond; currentIntensity = Mathf.Clamp01(intensity); Plugin.logger.LogDebug((object)"Setting intensity"); Apply(currentIntensity); } private void Apply(float t) { //IL_0017: 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) ((Graphic)image).color = new Color(1f, 1f, 1f, t); float num = Mathf.Lerp(1f, 2.5f, t); ((Transform)rt).localScale = Vector3.one * num; } internal static void Init() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Plugin.logger.LogDebug((object)"Initiating VignetteOverlay"); Instance = Object.Instantiate<GameObject>(new GameObject("VignetteOverlay")).AddComponent<VignetteOverlay>(); } } [HarmonyPatch] internal class VignetteOverlayPatches { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void ConnectClientToPlayerObjectPostfix() { try { } catch { } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Snowlance.SnowyLib"; public const string PLUGIN_NAME = "SnowyLib"; public const string PLUGIN_VERSION = "1.3.7"; } } namespace SnowyLib.Extensions { internal static class ComponentExtensions { public static bool TryGetComponentInChildren<T>(this Component comp, out T? component) where T : Component { component = comp.GetComponentInChildren<T>(); return (Object)(object)component != (Object)null; } } } 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 { } }