Decompiled source of SomeTweaks v1.0.1
SomeTweaks.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak; using Photon.Pun; using Photon.Realtime; using SomeTweaks.Features; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.Serizalization; using Zorro.Settings; using Zorro.Settings.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SomeTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("SomeTweaks")] [assembly: AssemblyTitle("SomeTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SomeTweaks { [BepInPlugin("SomeTweaks", "SomeTweaks", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string Guid = "SomeTweaks"; public const string Name = "SomeTweaks"; public const string Version = "1.0.1"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("SomeTweaks"); FallDamageIndicator.Init(((BaseUnityPlugin)this).Config); JoinCodeTweaks.Init(((BaseUnityPlugin)this).Config, _harmony); GazeOfCondor.Init(((BaseUnityPlugin)this).Config, _harmony); TrashBin.Init(((BaseUnityPlugin)this).Config); BalloonPop.Init(((BaseUnityPlugin)this).Config, _harmony); Vacuuka.Init(((BaseUnityPlugin)this).Config, _harmony); EmoteTweaks.Init(((BaseUnityPlugin)this).Config, _harmony); GloomFix.Init(((BaseUnityPlugin)this).Config, _harmony); GuidebookFix.Init(((BaseUnityPlugin)this).Config, _harmony); ModConfigFloatFix.Init(((BaseUnityPlugin)this).Config, _harmony); AntiZookaFix.Init(((BaseUnityPlugin)this).Config, _harmony); VisibleWaterFall.Init(((BaseUnityPlugin)this).Config); CursorFix.Init(((BaseUnityPlugin)this).Config); BackflipItemFix.Init(((BaseUnityPlugin)this).Config, _harmony); PauseMenuScroll.Init(((BaseUnityPlugin)this).Config, _harmony); HeldItemSeeThrough.Init(((BaseUnityPlugin)this).Config, _harmony); Log.LogInfo((object)"SomeTweaks 1.0.1 loaded"); } } } namespace SomeTweaks.Features { internal static class AntiZookaFix { public enum StarMode { Vanilla, UVProjection, RemoveStars } private const string Section = "AntiZookaFix"; private const string MaterialName = "M_Scout_Star_Antizooka"; private static readonly int Triplanar2On = Shader.PropertyToID("_Triplanar2On"); private static readonly int Texture2 = Shader.PropertyToID("_Texture2"); private static ConfigEntry<StarMode> s_mode; private static Material s_material; private static float s_origTriplanar; private static Texture s_origTexture; public static void Init(ConfigFile config, Harmony harmony) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown s_mode = config.Bind<StarMode>("AntiZookaFix", "StarLayer", StarMode.UVProjection, "How the star layer on the Anti-zooka barrel is drawn.\nVanilla: unchanged (the stars are projected from 3 directions and appear to show through the barrel).\nUVProjection: only the projection is changed back to normal (the stars become a pattern on the barrel).\nRemoveStars: removes the star layer.\nCan be changed while the game is running."); s_mode.SettingChanged += delegate { Apply(); }; harmony.Patch((MethodBase)AccessTools.Method(typeof(Action_Antizooka), "OnEnable", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(AntiZookaFix), "OnEnablePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void OnEnablePostfix(Action_Antizooka __instance) { if ((Object)(object)s_material != (Object)null) { return; } Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null && ((Object)val).name.StartsWith("M_Scout_Star_Antizooka") && val.HasProperty(Triplanar2On)) { s_material = val; s_origTriplanar = val.GetFloat(Triplanar2On); s_origTexture = (val.HasProperty(Texture2) ? val.GetTexture(Texture2) : null); Apply(); return; } } } } private static void Apply() { if (!((Object)(object)s_material == (Object)null)) { switch (s_mode.Value) { case StarMode.Vanilla: s_material.SetFloat(Triplanar2On, s_origTriplanar); s_material.SetTexture(Texture2, s_origTexture); break; case StarMode.UVProjection: s_material.SetFloat(Triplanar2On, 0f); s_material.SetTexture(Texture2, s_origTexture); break; case StarMode.RemoveStars: s_material.SetFloat(Triplanar2On, 0f); s_material.SetTexture(Texture2, (Texture)(object)Texture2D.blackTexture); break; } } } } internal static class BackflipItemFix { private enum SnapMode { None, Arms, Body } private const string Section = "BackflipItemFix"; private const string BackflipEmote = "A_Scout_Emote_BackFlip"; private const float MinDelay = 0.6f; private const float Timeout = 8f; private const float ReadyTime = 0.1f; private const float CheckDelay = 0.5f; private const float MaxBlendWait = 1.5f; private const int MinBlendFrames = 3; private const int SettleFrames = 5; private static ConfigEntry<bool> s_enabled; private static readonly HashSet<BodypartType> ArmParts = new HashSet<BodypartType> { (BodypartType)25, (BodypartType)5, (BodypartType)6, (BodypartType)7, (BodypartType)29, (BodypartType)26, (BodypartType)8, (BodypartType)9, (BodypartType)10, (BodypartType)30 }; private static ConfigEntry<SnapMode> s_snap; private static ConfigEntry<bool> s_debugLog; private static Coroutine s_pending; private static MonoBehaviour s_pendingHost; private static Item s_offItem; private static int s_originalExclude; private static int s_appliedExclude; private const int ClearFrames = 3; private const float PenetrationTolerance = 0.02f; private static readonly Collider[] s_overlapHits = (Collider[])(object)new Collider[32]; public static void Init(ConfigFile config, Harmony harmony) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_009a: Expected O, but got Unknown s_enabled = config.Bind<bool>("BackflipItemFix", "Enabled", true, "While you backflip holding an item, the item's collisions are turned off, and when the backflip ends the item and arms are put back into a normal holding pose (also works in mid-air). Only affects your own screen."); s_snap = config.Bind<SnapMode>("BackflipItemFix", "Snap", SnapMode.Arms, "How much of the body is snapped back to the animation pose when the item is re-held.\nNone: don't snap (only the item and hands are moved; twisted arms may pull it out of place again).\nArms: snap only from the shoulders to the fingertips. Body momentum is kept (you keep running).\nBody: snap the whole body (same as switching items). Momentum is reset at that moment, so you briefly stop if you are running."); s_debugLog = config.Bind<bool>("BackflipItemFix", "DebugLog", false, "Logs the backflip conditions when you choose Backflip, when collisions are turned off and back on, and the re-holding results (for troubleshooting)."); harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterAnimations), "RPCA_PlayRemove", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BackflipItemFix), "PlayRemovePrefix", (Type[])null), new HarmonyMethod(typeof(BackflipItemFix), "PlayRemovePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void PlayRemovePrefix(CharacterAnimations __instance, string emoteName, bool succeeded) { if (s_debugLog.Value && !(emoteName != "A_Scout_Emote_BackFlip")) { Character character = __instance.character; if (!((Object)(object)character == (Object)null) && character.IsLocal) { CharacterData data = character.data; bool flag = !__instance.emoting && data.fallSeconds <= 0f && data.fullyConscious; Plugin.Log.LogInfo((object)($"[BackflipItemFix] backflip requested: flipRoutine={flag} " + $"(emoting={__instance.emoting}, fallSeconds={data.fallSeconds:0.00}, fullyConscious={data.fullyConscious}), " + $"grounded={data.isGrounded}, sinceGrounded={data.sinceGrounded:0.00}, succeeded={succeeded}, " + "item=" + (((Object)(object)data.currentItem != (Object)null) ? ((Object)data.currentItem).name : "none"))); } } } private static void PlayRemovePostfix(CharacterAnimations __instance, string emoteName) { if (!s_enabled.Value || emoteName != "A_Scout_Emote_BackFlip") { return; } Character character = __instance.character; if (!((Object)(object)character == (Object)null) && character.IsLocal && !((Object)(object)character.data.currentItem == (Object)null)) { CharacterItems items = character.refs.items; if (s_pending != null && (Object)(object)s_pendingHost != (Object)null) { s_pendingHost.StopCoroutine(s_pending); } CollisionsOff(character.data.currentItem); s_pendingHost = (MonoBehaviour)(object)items; s_pending = ((MonoBehaviour)items).StartCoroutine(Routine(character, __instance, character.data.currentItem)); } } private static void CollisionsOff(Item item) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s_offItem == (Object)(object)item) || !((Object)(object)item != (Object)null) || !((Object)(object)item.rig != (Object)null) || LayerMask.op_Implicit(item.rig.excludeLayers) != s_appliedExclude) { CollisionsOn("another backflip"); if (!((Object)(object)item == (Object)null) && !((Object)(object)item.rig == (Object)null)) { s_offItem = item; s_originalExclude = LayerMask.op_Implicit(item.rig.excludeLayers); s_appliedExclude = -1; item.rig.excludeLayers = LayerMask.op_Implicit(s_appliedExclude); Log($"collisions off for {((Object)item).name} (excludeLayers 0x{s_originalExclude:X} -> 0x{s_appliedExclude:X})"); } } } private static void CollisionsOn(string reason) { //IL_002a: 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) Item val = s_offItem; s_offItem = null; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.rig == (Object)null)) { if (LayerMask.op_Implicit(val.rig.excludeLayers) == s_appliedExclude) { val.rig.excludeLayers = LayerMask.op_Implicit(s_originalExclude); Log("collisions back on (" + reason + ")"); } else { Log("left collisions as they are; the game already changed them (" + reason + ")"); } } } private static IEnumerator Routine(Character c, CharacterAnimations anims, Item item) { try { IEnumerator inner = FixRoutine(c, anims, item); while (inner.MoveNext()) { yield return inner.Current; } } finally { CollisionsOn("routine ended"); } } private static IEnumerator FixRoutine(Character c, CharacterAnimations anims, Item item) { float start = Time.time; yield return (object)new WaitForSeconds(0.6f); float readyFor = 0f; while (true) { if (!StillHolding(c, item)) { Log("item changed; skipped"); s_pending = null; yield break; } if (Time.time - start > 8f) { Log($"not ready within {8f}s (fallSeconds={c.data.fallSeconds:0.00}, emoting={anims.emoting}, " + $"climbing={c.data.isClimbingAnything}, using={item.progress > 0f}); skipped"); s_pending = null; yield break; } readyFor = (IsReady(c, anims, item) ? (readyFor + Time.deltaTime) : 0f); if (readyFor >= 0.1f) { break; } yield return null; } Animator animator = c.refs.animator; float blendStart = Time.time; for (int i = 0; i < 3; i++) { yield return null; } while (Time.time - blendStart < 1.5f && (IsInTransition(animator) || IsInBackflipState(animator))) { yield return null; } float blendWait = Time.time - blendStart; if (IsInTransition(animator) || IsInBackflipState(animator)) { Log($" animation still in the backflip after {1.5f}s; fixing anyway"); } yield return (object)new WaitForFixedUpdate(); if (!StillHolding(c, item) || !IsReady(c, anims, item)) { Log("state changed while waiting for the animation; skipped"); s_pending = null; yield break; } CharacterItems items = c.refs.items; float before = HoldOffset(items, item); yield return Reattach(c, items, item); if (!StillHolding(c, item)) { s_pending = null; yield break; } Log($"re-attached {((Object)item).name} after {Time.time - start:0.00}s (waited {blendWait:0.00}s for animation blend), " + $"snap={s_snap.Value}, grounded={c.data.isGrounded} " + $"(offset from hold position: {before:0.00}m before → {HoldOffset(items, item):0.00}m right after)"); float clearStart = Time.time; for (int clearFrames = 0; clearFrames < 3; clearFrames = ((!OverlapsTerrain(item)) ? (clearFrames + 1) : 0)) { yield return (object)new WaitForFixedUpdate(); if (!StillHolding(c, item)) { s_pending = null; yield break; } } CollisionsOn($"item clear of terrain after {Time.time - clearStart:0.00}s"); if (s_debugLog.Value) { yield return (object)new WaitForSeconds(0.5f); if (StillHolding(c, item)) { Log($" {0.5f}s later: {HoldOffset(items, item):0.00}m from hold position"); } } s_pending = null; } private static bool StillHolding(Character c, Item item) { if ((Object)(object)c != (Object)null && (Object)(object)item != (Object)null) { return (Object)(object)c.data.currentItem == (Object)(object)item; } return false; } private static bool IsReady(Character c, CharacterAnimations anims, Item item) { CharacterData data = c.data; if (data.fallSeconds <= 0f && data.fullyConscious && !anims.emoting && !data.isClimbingAnything) { return item.progress <= 0f; } return false; } private static bool IsInBackflipState(Animator animator) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animator == (Object)null) { return false; } for (int i = 0; i < animator.layerCount; i++) { AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(i); if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("A_Scout_Emote_BackFlip")) { return true; } } return false; } private static bool IsInTransition(Animator animator) { if ((Object)(object)animator == (Object)null) { return false; } for (int i = 0; i < animator.layerCount; i++) { if (animator.IsInTransition(i)) { return true; } } return false; } private static float HoldOffset(CharacterItems items, Item item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(item.transform.position, items.GetItemHoldPos(item, false)); } private static bool OverlapsTerrain(Item item) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) int num = LayerMask.op_Implicit(HelperFunctions.terrainMapMask); Collider[] colliders = item.colliders; Vector3 val3 = default(Vector3); float num3 = default(float); foreach (Collider val in colliders) { if ((Object)(object)val == (Object)null || !val.enabled || val.isTrigger) { continue; } Bounds bounds = val.bounds; int num2 = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, s_overlapHits, Quaternion.identity, num, (QueryTriggerInteraction)1); for (int j = 0; j < num2; j++) { Collider val2 = s_overlapHits[j]; if (!((Object)(object)val2 == (Object)null) && Physics.ComputePenetration(val, ((Component)val).transform.position, ((Component)val).transform.rotation, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num3) && num3 > 0.02f) { return true; } } } return false; } private static IEnumerator Reattach(Character c, CharacterItems items, Item item) { Collider[] colliders = item.colliders; bool[] wasEnabled = new bool[colliders.Length]; for (int i = 0; i < colliders.Length; i++) { if ((Object)(object)colliders[i] != (Object)null) { wasEnabled[i] = colliders[i].enabled; colliders[i].enabled = false; } } items.UnAttachItem(); for (int frame = 0; frame < 5; frame++) { if ((Object)(object)c == (Object)null) { break; } if ((Object)(object)item == (Object)null) { break; } if ((Object)(object)c.data.currentItem != (Object)(object)item) { break; } c.data.sinceItemAttach = 0f; Snap(c); item.Move(items.GetItemHoldPos(item, false), items.GetItemHoldRotation(item)); yield return (object)new WaitForFixedUpdate(); } if ((Object)(object)c != (Object)null && (Object)(object)item != (Object)null && (Object)(object)c.data.currentItem == (Object)(object)item) { items.AttachItem(item); } yield return (object)new WaitForFixedUpdate(); for (int j = 0; j < colliders.Length; j++) { if ((Object)(object)colliders[j] != (Object)null && wasEnabled[j]) { colliders[j].enabled = true; } } } private static void Snap(Character c) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_00e1: Unknown result type (might be due to invalid IL or missing references) switch (s_snap.Value) { case SnapMode.Body: c.refs.ragdoll.FixedUpdate(); c.refs.ragdoll.SnapToAnimation(); break; case SnapMode.Arms: { Vector3 linearVelocity = (((Object)(object)c.refs.hip != (Object)null && (Object)(object)c.refs.hip.Rig != (Object)null) ? c.refs.hip.Rig.linearVelocity : Vector3.zero); { foreach (Bodypart part in c.refs.ragdoll.partList) { if (!((Object)(object)part == (Object)null) && ArmParts.Contains(part.partType)) { part.SnapToAnim(); if ((Object)(object)part.Rig != (Object)null && !part.Rig.isKinematic) { part.Rig.linearVelocity = linearVelocity; } } } break; } } } } private static void Log(string message) { if (s_debugLog.Value) { Plugin.Log.LogInfo((object)("[BackflipItemFix] " + message)); } } } [HarmonyPatch] public class BalloonPop : MonoBehaviour, IInteractibleConstant, IInteractible { private const string Section = "BalloonPop"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<float> s_holdTime; private TiedBalloon _balloon; private bool IsMyBalloon { get { if ((Object)(object)_balloon != (Object)null) { return ((MonoBehaviourPun)_balloon).photonView.IsMine; } return false; } } public bool holdOnFinish => false; public static void Init(ConfigFile config, Harmony harmony) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown s_enabled = config.Bind<bool>("BalloonPop", "Enabled", true, "Lets you pop a balloon tied to you by looking at it and holding E."); s_holdTime = config.Bind<float>("BalloonPop", "HoldTime", 0.6f, new ConfigDescription("How long to hold E (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); harmony.PatchAll(typeof(BalloonPop)); } [HarmonyPatch(typeof(TiedBalloon), "RPC_Init")] [HarmonyPostfix] private static void RpcInitPostfix(TiedBalloon __instance) { if (((MonoBehaviourPun)__instance).photonView.IsMine && (Object)(object)((Component)__instance).GetComponent<BalloonPop>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<BalloonPop>()._balloon = __instance; } } public bool IsInteractible(Character interactor) { if (s_enabled.Value && IsMyBalloon && (Object)(object)interactor != (Object)null) { return interactor.IsLocal; } return false; } public void Interact(Character interactor) { } public bool IsConstantlyInteractable(Character interactor) { return IsInteractible(interactor); } public float GetInteractTime(Character interactor) { return s_holdTime.Value; } public void Interact_CastFinished(Character interactor) { if (IsInteractible(interactor)) { _balloon.Pop(); } } public void CancelCast(Character interactor) { } public void ReleaseInteract(Character interactor) { } public void HoverEnter() { } public void HoverExit() { } public Vector3 Center() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_balloon != (Object)null) || !((Object)(object)_balloon.rb != (Object)null)) { return ((Component)this).transform.position; } return _balloon.rb.position; } public Transform GetTransform() { if (!((Object)(object)_balloon != (Object)null) || !((Object)(object)_balloon.rb != (Object)null)) { return ((Component)this).transform; } return ((Component)_balloon.rb).transform; } public string GetInteractionText() { return Loc.Get(Loc.Key.BalloonInteract); } public string GetName() { return Loc.Get(Loc.Key.BalloonName); } } internal static class CursorFix { private struct CURSORINFO { public int cbSize; public int flags; public IntPtr hCursor; public int x; public int y; } private class Runner : MonoBehaviour { private Coroutine _pending; private float _nextCheck; public void FixSoon(string reason) { if (_pending != null) { ((MonoBehaviour)this).StopCoroutine(_pending); } _pending = ((MonoBehaviour)this).StartCoroutine(Routine(reason)); } private IEnumerator Routine(string reason) { float[] array = new float[3] { 0.2f, 1f, 3f }; float[] array2 = array; foreach (float num in array2) { yield return (object)new WaitForSecondsRealtime(num); Fix(reason); } _pending = null; } private void Update() { //IL_0012: 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 (s_enabled.Value) { if ((int)s_key.Value != 0 && UnityInput.Current.GetKeyDown(s_key.Value)) { Fix("key", force: true); } float value = s_checkInterval.Value; if (value > 0f && Time.unscaledTime >= _nextCheck) { _nextCheck = Time.unscaledTime + value; Fix("periodic check"); } } } private void OnApplicationFocus(bool focus) { if (focus && s_enabled.Value) { FixSoon("focus"); } } } private const string Section = "CursorFix"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<KeyCode> s_key; private static ConfigEntry<float> s_checkInterval; private static ConfigEntry<bool> s_logDeviceChanges; private static Runner s_runner; private const int CURSOR_SHOWING = 1; private static bool ShouldBeHidden { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if (!Cursor.visible) { return (int)Cursor.lockState == 1; } return false; } } public static void Init(ConfigFile config) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //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_009d: Expected O, but got Unknown s_enabled = config.Bind<bool>("CursorFix", "Enabled", false, "Hides the cursor that stays visible during normal play (e.g. after a wireless mouse reconnects)."); s_key = config.Bind<KeyCode>("CursorFix", "ResetKey", (KeyCode)289, "Press to fix the cursor visibility (None to disable)."); s_checkInterval = config.Bind<float>("CursorFix", "CheckInterval", 30f, new ConfigDescription("How often (seconds) to check whether the cursor is stuck visible. 0 = never (only on the key press and when the window regains focus). The check only reads the OS cursor state, so it is cheap.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 300f), Array.Empty<object>())); s_logDeviceChanges = config.Bind<bool>("CursorFix", "LogDeviceChanges", false, "Logs input device changes (for troubleshooting)."); GameObject val = new GameObject("SomeTweaks.CursorFix"); Object.DontDestroyOnLoad((Object)val); s_runner = val.AddComponent<Runner>(); InputSystem.onDeviceChange += OnDeviceChange; } private static void OnDeviceChange(InputDevice device, InputDeviceChange change) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 if (s_logDeviceChanges.Value) { Plugin.Log.LogInfo((object)$"[CursorFix] device {change}: {((device != null) ? ((InputControl)device).displayName : null)} ({((object)device)?.GetType().Name})"); } bool flag = s_enabled.Value && device is Mouse; if (flag) { bool flag2 = (((int)change == 0 || change - 3 <= 1) ? true : false); flag = flag2; } if (flag) { s_runner.FixSoon($"mouse {change}"); } } [DllImport("user32.dll")] private static extern int ShowCursor(bool bShow); [DllImport("user32.dll")] private static extern bool GetCursorInfo(ref CURSORINFO info); private static bool IsOsCursorShowing() { CURSORINFO info = new CURSORINFO { cbSize = Marshal.SizeOf(typeof(CURSORINFO)) }; if (GetCursorInfo(ref info)) { return (info.flags & 1) != 0; } return false; } private static void Fix(string reason, bool force = false) { if (s_enabled.Value && Application.isFocused && ShouldBeHidden && (force || IsOsCursorShowing())) { int num = ShowCursor(bShow: false); int num2 = 1; while (num >= 0 && num2 < 32) { num = ShowCursor(bShow: false); num2++; } while (num < -1 && num2 < 64) { num = ShowCursor(bShow: true); num2++; } Plugin.Log.LogInfo((object)$"[CursorFix] fixed cursor display count → {num} ({reason})"); } } } internal static class EmoteTweaks { private class SegmentTint : MonoBehaviour { private Image _img; private Color _base; private Color _applied; private bool _tinted; public void Init(Image img) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) _img = img; _base = ((Graphic)img).color; } private void LateUpdate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_img == (Object)null) { return; } Color color = ((Graphic)_img).color; if (!_tinted || color != _applied) { _base = color; } if (!TintActive) { if (_tinted) { ((Graphic)_img).color = _base; _tinted = false; } } else { Color value = s_tintColor.Value; float value2 = s_tintStrength.Value; _applied = new Color(Mathf.Lerp(_base.r, value.r, value2), Mathf.Lerp(_base.g, value.g, value2), Mathf.Lerp(_base.b, value.b, value2), _base.a); ((Graphic)_img).color = _applied; _tinted = true; } } private void OnDisable() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_img != (Object)null && _tinted) { ((Graphic)_img).color = _base; _tinted = false; } } } private class Notice : MonoBehaviour { private const float FadeTime = 0.5f; private static Notice s_instance; private TextMeshProUGUI _text; private float _until; public static void Show() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (s_noticeEnabled.Value) { if ((Object)(object)s_instance == (Object)null) { GameObject val = new GameObject("SomeTweaks.EmoteNotice"); Object.DontDestroyOnLoad((Object)val); s_instance = val.AddComponent<Notice>(); s_instance.Build(); } s_instance.UseGameFont(); ((TMP_Text)s_instance._text).text = Loc.Get(Loc.Key.PlayDeadCanceled); s_instance._until = Time.unscaledTime + s_noticeDuration.Value; ((TMP_Text)s_instance._text).alpha = 1f; ((Behaviour)s_instance._text).enabled = true; } } private void UseGameFont() { TextMeshProUGUI val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.interactNameText : null); if ((Object)(object)val != (Object)null && (Object)(object)_text != (Object)null && (Object)(object)((TMP_Text)_text).font != (Object)(object)((TMP_Text)val).font) { ((TMP_Text)_text).font = ((TMP_Text)val).font; ((TMP_Text)_text).fontSharedMaterial = ((TMP_Text)val).fontSharedMaterial; } } private void Build() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00e2: 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) GameObject val = new GameObject("Canvas"); val.transform.SetParent(((Component)this).transform, false); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 5000; CanvasScaler obj2 = val.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; GameObject val2 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); RectTransform val3 = (RectTransform)val2.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 1f); val3.pivot = val4; Vector2 anchorMin = (val3.anchorMax = val4); val3.anchorMin = anchorMin; val3.anchoredPosition = new Vector2(40f, -40f); val3.sizeDelta = new Vector2(800f, 60f); _text = val2.AddComponent<TextMeshProUGUI>(); UseGameFont(); ((TMP_Text)_text).fontSize = 36f; ((TMP_Text)_text).alignment = (TextAlignmentOptions)257; ((Graphic)_text).color = new Color(1f, 0.2f, 0.2f, 1f); ((Graphic)_text).raycastTarget = false; ((Behaviour)_text).enabled = false; } private void Update() { if (!((Object)(object)_text == (Object)null) && ((Behaviour)_text).enabled) { float num = _until - Time.unscaledTime; if (num <= 0f) { ((Behaviour)_text).enabled = false; } else { ((TMP_Text)_text).alpha = Mathf.Clamp01(num / 0.5f); } } } } private const string Section = "EmoteTweaks"; private const string PlayDead = "A_Scout_Emote_PlayDead"; private const string BackFlip = "A_Scout_Emote_BackFlip"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<KeyCode> s_keepPlayDeadKey; private static ConfigEntry<bool> s_tintWheel; private static ConfigEntry<Color> s_tintColor; private static ConfigEntry<float> s_tintStrength; private static bool s_playDeadPageShown; private static ConfigEntry<bool> s_noticeEnabled; private static ConfigEntry<float> s_noticeDuration; private static bool TintActive { get { if (s_enabled.Value && s_tintWheel.Value) { return s_playDeadPageShown; } return false; } } public static void Init(ConfigFile config, Harmony harmony) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown s_enabled = config.Bind<bool>("EmoteTweaks", "PlayDeadToBackflip", true, "Choosing Play Dead while another emote is playing does a Backflip instead."); s_keepPlayDeadKey = config.Bind<KeyCode>("EmoteTweaks", "KeepPlayDeadKey", (KeyCode)122, "Hold this key while choosing Play Dead to play dead as usual, even during an emote."); BindNotice(config); s_tintWheel = config.Bind<bool>("EmoteTweaks", "TintPlayDeadPage", true, "Tints the background of the emote wheel page that contains Play Dead (only while PlayDeadToBackflip is on)."); s_tintColor = config.Bind<Color>("EmoteTweaks", "TintColor", new Color(0.75f, 0.08f, 0.08f, 1f), "Tint color (RGBA; alpha is not used)."); s_tintStrength = config.Bind<float>("EmoteTweaks", "TintStrength", 0.75f, new ConfigDescription("How far the original background color is moved toward TintColor (0 = original, 1 = TintColor itself).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterAnimations), "PlayEmote", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmoteTweaks), "PlayEmotePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EmoteWheel), "InitWheel", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(EmoteTweaks), "InitWheelPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void InitWheelPostfix(EmoteWheel __instance) { s_playDeadPageShown = false; int num = 8 * __instance.page; Image img = default(Image); for (int i = 0; i < __instance.slices.Length; i++) { int num2 = num + i; if (num2 < __instance.data.Length && (Object)(object)__instance.data[num2] != (Object)null && __instance.data[num2].anim == "A_Scout_Emote_PlayDead") { s_playDeadPageShown = true; } EmoteWheelSlice val = __instance.slices[i]; Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.Find("Segment") : null); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent<SegmentTint>() == (Object)null && ((Component)val2).TryGetComponent<Image>(ref img)) { ((Component)val2).gameObject.AddComponent<SegmentTint>().Init(img); } } } private static void PlayEmotePrefix(CharacterAnimations __instance, ref string emoteName) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (s_enabled.Value && !(emoteName != "A_Scout_Emote_PlayDead") && __instance.emoting && ((int)s_keepPlayDeadKey.Value == 0 || !UnityInput.Current.GetKey(s_keepPlayDeadKey.Value))) { emoteName = "A_Scout_Emote_BackFlip"; Notice.Show(); } } private static void BindNotice(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown s_noticeEnabled = config.Bind<bool>("EmoteTweaks", "ShowCancelNotice", true, "Shows a red notice in the top-left corner when Play Dead is replaced with a Backflip."); s_noticeDuration = config.Bind<float>("EmoteTweaks", "CancelNoticeDuration", 2f, new ConfigDescription("How long the notice is shown (seconds; it fades out during the last 0.5 s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); } } public class FallDamageIndicator : MonoBehaviour { public enum LabelMode { None, TimeToImpact, DistanceToImpact } public enum MinFallTimeMode { Total, Elapsed, Off } private struct Impact { public int Step; public float Time; public float Speed; public float SinceGrounded; public float Distance; } private struct StepState { public Vector3 Offset; public float SinceGrounded; } private static class Sim { public static float Dt; public static float Control; public static float GravityScale; public static float SinceGroundedCap; public static int BalloonCount; public static Vector3 InitialVel; private static CharacterMovement s_m; private static float s_dragMul; private static float s_dampMul; private static bool s_customGravity; private static bool s_jumping; private static float s_unityG; private static Vector3 s_moveAccel; private static Vector3 s_bodyCenter; private static float s_bodyRadius; private static float s_hipY; private static int s_mask; private static readonly List<BodyShape> s_shapes = new List<BodyShape>(); public static bool Setup(Character c) { //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_009e: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) CharacterData data = c.data; CharacterMovement movement = c.refs.movement; List<Bodypart> list = (((Object)(object)c.refs.ragdoll != (Object)null) ? c.refs.ragdoll.partList : null); if ((Object)(object)movement == (Object)null || list == null || list.Count == 0) { return false; } Vector3 val = Vector3.zero; float num = 0f; int num2 = 0; bool flag = false; s_shapes.Clear(); for (int i = 0; i < list.Count; i++) { Bodypart val2 = list[i]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.Rig == (Object)null)) { Rigidbody rig = val2.Rig; val += rig.linearVelocity; num += rig.linearDamping; flag |= rig.useGravity; num2++; CollectShapes(val2); } } if (num2 == 0 || s_shapes.Count == 0) { return false; } InitialVel = val / (float)num2; num /= (float)num2; Bounds bounds = s_shapes[0].Bounds; for (int j = 1; j < s_shapes.Count; j++) { ((Bounds)(ref bounds)).Encapsulate(s_shapes[j].Bounds); } s_bodyCenter = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; s_bodyRadius = ((Vector3)(ref extents)).magnitude + 0.05f; Rigidbody bodypartRig = c.GetBodypartRig((BodypartType)0); s_hipY = ((bodypartRig != null) ? bodypartRig.position.y : s_bodyCenter.y); s_m = movement; Dt = Time.fixedDeltaTime; Control = data.currentRagdollControll; s_dragMul = Mathf.Lerp(1f, movement.drag, Control); s_dampMul = 1f - Mathf.Min(1f, num * Dt); GravityScale = Control * movement.balloonFloatMultiplier; s_customGravity = c.CheckGravity(); s_jumping = data.isJumping; s_unityG = (flag ? Physics.gravity.y : 0f); s_moveAccel = movement.GetMovementForce() * Control * data.worldMovementInput_Lerp; BalloonCount = (((Object)(object)c.refs.balloons != (Object)null) ? c.refs.balloons.currentBalloonCount : 0); SinceGroundedCap = SinceGroundedCap(c, BalloonCount); s_mask = LayerMask.op_Implicit(HelperFunctions.terrainMapMask); return true; } public static bool Run(Vector3 offset, Vector3 vel, float sinceGrounded, float gravityScale, float sgCap, int zeroSteps, int maxSteps, List<StepState> record, out Impact impact) { //IL_0015: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) impact = default(Impact); float dt = Dt; for (int i = 0; i < maxSteps; i++) { float y = vel.y; if (sinceGrounded < 1f || vel.y < -1f) { sinceGrounded += dt; } sinceGrounded = Mathf.Min(sinceGrounded, sgCap); float num = 0f; if (s_customGravity) { float num2 = s_m.jumpGravityCurve.Evaluate(sinceGrounded * s_m.gravityCurveSpeed); num = (s_jumping ? Mathf.Lerp(s_m.jumpGravity, s_m.maxGravity, num2) : Mathf.Lerp(0f, s_m.maxGravity, num2)); } vel *= s_dragMul; vel += (new Vector3(0f, num * gravityScale + s_unityG, 0f) + s_moveAccel) * dt; vel *= s_dampMul; Vector3 val = vel * dt; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 1E-06f && Physics.CheckSphere(s_bodyCenter + offset + val * 0.5f, s_bodyRadius + magnitude * 0.5f, s_mask, (QueryTriggerInteraction)1)) { Vector3 dir = val / magnitude; bool flag = false; RaycastHit val2 = default(RaycastHit); for (int j = 0; j < s_shapes.Count; j++) { if (s_shapes[j].Cast(offset, dir, magnitude, s_mask, out var hit) && (!flag || ((RaycastHit)(ref hit)).distance < ((RaycastHit)(ref val2)).distance)) { val2 = hit; flag = true; } } if (flag) { if (Vector3.Angle(Vector3.up, ((RaycastHit)(ref val2)).normal) < 50f) { impact.Step = i; impact.Time = (float)(i + 2) * dt; impact.Speed = 0f - y; impact.SinceGrounded = Mathf.Min(sinceGrounded + dt, sgCap); impact.Distance = ((Vector3)(ref offset)).magnitude + ((RaycastHit)(ref val2)).distance; return true; } if (((RaycastHit)(ref val2)).point.y < s_hipY + offset.y) { return false; } } } offset += val; if (i < zeroSteps) { vel = Vector3.zero; } record?.Add(new StepState { Offset = offset, SinceGrounded = sinceGrounded }); } return false; } private static void CollectShapes(Bodypart part) { if (part.colliders != null && part.colliders.Count > 0) { foreach (RigCreatorCollider collider in part.colliders) { if ((Object)(object)collider != (Object)null) { AddShape((Collider)(object)collider.col); } } return; } Collider[] componentsInChildren = ((Component)part).GetComponentsInChildren<Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { AddShape(componentsInChildren[i]); } } private static void AddShape(Collider col) { if (!((Object)(object)col == (Object)null) && col.enabled && !col.isTrigger && ((Component)col).gameObject.activeInHierarchy) { s_shapes.Add(BodyShape.From(col)); } } } private struct BodyShape { private enum Kind { Sphere, Capsule, Box } private Kind _kind; private Vector3 _a; private Vector3 _b; private float _radius; private Vector3 _half; private Quaternion _rot; public Bounds Bounds; public static BodyShape From(Collider col) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)col).transform; Vector3 lossyScale = transform.lossyScale; ((Vector3)(ref lossyScale))..ctor(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)); BodyShape result = new BodyShape { Bounds = col.bounds }; SphereCollider val = (SphereCollider)(object)((col is SphereCollider) ? col : null); if (val == null) { CapsuleCollider val2 = (CapsuleCollider)(object)((col is CapsuleCollider) ? col : null); if (val2 == null) { BoxCollider val3 = (BoxCollider)(object)((col is BoxCollider) ? col : null); if (val3 != null) { result._kind = Kind.Box; result._a = transform.TransformPoint(val3.center); result._half = Vector3.Scale(val3.size, lossyScale) * 0.5f; result._rot = transform.rotation; } else { result._kind = Kind.Sphere; Bounds bounds = col.bounds; result._a = ((Bounds)(ref bounds)).center; bounds = col.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; result._radius = ((Vector3)(ref extents)).magnitude; } } else { Vector3 val4; float num; float num2; switch (val2.direction) { case 0: val4 = transform.right; num = lossyScale.x; num2 = Mathf.Max(lossyScale.y, lossyScale.z); break; case 2: val4 = transform.forward; num = lossyScale.z; num2 = Mathf.Max(lossyScale.x, lossyScale.y); break; default: val4 = transform.up; num = lossyScale.y; num2 = Mathf.Max(lossyScale.x, lossyScale.z); break; } float num3 = val2.radius * num2; float num4 = Mathf.Max(val2.height * num * 0.5f - num3, 0f); Vector3 val5 = transform.TransformPoint(val2.center); result._kind = Kind.Capsule; result._a = val5 + val4 * num4; result._b = val5 - val4 * num4; result._radius = num3; } } else { result._kind = Kind.Sphere; result._a = transform.TransformPoint(val.center); result._radius = val.radius * Mathf.Max(lossyScale.x, Mathf.Max(lossyScale.y, lossyScale.z)); } return result; } public bool Cast(Vector3 offset, Vector3 dir, float dist, int mask, out RaycastHit hit) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) return _kind switch { Kind.Capsule => Physics.CapsuleCast(_a + offset, _b + offset, _radius, dir, ref hit, dist, mask, (QueryTriggerInteraction)1), Kind.Box => Physics.BoxCast(_a + offset, _half, dir, ref hit, _rot, dist, mask, (QueryTriggerInteraction)1), _ => Physics.SphereCast(_a + offset, _radius, dir, ref hit, dist, mask, (QueryTriggerInteraction)1), }; } } private const string Section = "FallDamageIndicator"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<float> s_leadTime; private static ConfigEntry<LabelMode> s_label; private static ConfigEntry<float> s_resyncThreshold; private static ConfigEntry<float> s_minFallTime; private static ConfigEntry<MinFallTimeMode> s_minFallTimeMode; private static ConfigEntry<bool> s_debugLog; private static readonly Color GaugeColor = new Color(1f, 0.12f, 0.12f, 1f); private const float MaxStandAngle = 50f; private const float LostGrace = 0.15f; private const float OverdueGrace = 0.4f; private bool _active; private float _deadline; private float _lostTimer; private bool _wasGrounded = true; private float _airTime; private bool _droppedByCondor; private Transform _uiRoot; private Image _fill; private Image _empty; private TextMeshProUGUI _distanceText; public static void Init(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) s_enabled = config.Bind<bool>("FallDamageIndicator", "Enabled", false, "Shows a circular indicator just before a landing that will cause fall damage."); s_leadTime = config.Bind<float>("FallDamageIndicator", "LeadTime", 2f, new ConfigDescription("How many seconds before landing the indicator appears.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), Array.Empty<object>())); s_label = config.Bind<LabelMode>("FallDamageIndicator", "Label", LabelMode.None, "Number shown above the gauge. None = nothing / TimeToImpact = seconds until landing / DistanceToImpact = distance to the predicted landing point (m)."); s_resyncThreshold = config.Bind<float>("FallDamageIndicator", "ResyncThreshold", 0.1f, new ConfigDescription("If the predicted landing time shifts by this many seconds or more while the indicator is shown (e.g. you grab a balloon), the landing time is re-synced.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.03f, 1f), Array.Empty<object>())); s_minFallTime = config.Bind<float>("FallDamageIndicator", "MinFallTime", 2f, new ConfigDescription("The indicator is not shown for falls shorter than this many seconds (0 = off). How the fall is measured is set by MinFallTimeMode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); s_minFallTimeMode = config.Bind<MinFallTimeMode>("FallDamageIndicator", "MinFallTimeMode", MinFallTimeMode.Total, "How MinFallTime is measured. Total = the length of the whole fall (elapsed time + predicted time until landing); if long enough, the indicator is shown from LeadTime seconds before landing / Elapsed = shown only after you have actually been falling that long (may appear suddenly right before landing) / Off = no fall-time limit."); s_debugLog = config.Bind<bool>("FallDamageIndicator", "DebugLog", false, "Logs the difference between the predicted and actual landing times, etc. (for tuning)."); GameObject val = new GameObject("SomeTweaks.FallDamageIndicator"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<FallDamageIndicator>(); } private void Update() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!s_enabled.Value || (Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null) { Deactivate(); return; } bool isGrounded = localCharacter.data.isGrounded; if (isGrounded && !_wasGrounded && _active && s_debugLog.Value) { Plugin.Log.LogInfo((object)$"[FallDamageIndicator] landed: predicted - actual = {(_deadline - Time.time) * 1000f:F0} ms"); } _wasGrounded = isGrounded; if ((Object)(object)localCharacter.data.carrierCondor != (Object)null) { _droppedByCondor = true; _airTime = 0f; Deactivate(); return; } if (!IsEligible(localCharacter)) { _airTime = 0f; _droppedByCondor = false; Deactivate(); return; } _airTime += Time.deltaTime; MinFallTimeMode minFallTimeMode = (_droppedByCondor ? MinFallTimeMode.Off : s_minFallTimeMode.Value); bool flag = minFallTimeMode == MinFallTimeMode.Total; if (!_active && minFallTimeMode == MinFallTimeMode.Elapsed && _airTime < s_minFallTime.Value) { return; } if (!Sim.Setup(localCharacter)) { Deactivate(); return; } float value = s_leadTime.Value; Impact impact; bool flag2 = Sim.Run(Vector3.zero, Sim.InitialVel, localCharacter.data.sinceGrounded, Sim.GravityScale, Sim.SinceGroundedCap, 0, Mathf.CeilToInt((value + 1f) / Sim.Dt), null, out impact) && WouldTakeDamage(localCharacter, impact.Time, impact.Speed, impact.SinceGrounded); float num = Time.fixedTime + impact.Time; float time = Time.time; if (!_active) { bool flag3 = !flag || _airTime + (num - time) >= s_minFallTime.Value; if (flag2 && flag3 && num - time <= value) { _active = true; _deadline = num; _lostTimer = 0f; Show(); if (s_debugLog.Value) { Plugin.Log.LogInfo((object)$"[FallDamageIndicator] start: impact in {(num - time) * 1000f:F0} ms, speed {impact.Speed:F1} m/s"); } } } else { _lostTimer = (flag2 ? 0f : (_lostTimer + Time.deltaTime)); if (_lostTimer > 0.15f || time > _deadline + 0.4f) { Deactivate(); return; } if (flag2 && Mathf.Abs(num - _deadline) > s_resyncThreshold.Value) { if (s_debugLog.Value) { Plugin.Log.LogInfo((object)$"[FallDamageIndicator] resync: {(num - _deadline) * 1000f:+0;-0} ms"); } if (num - time > value) { Deactivate(); return; } _deadline = num; } } if (!_active || !EnsureUI()) { return; } _fill.fillAmount = Mathf.Clamp01(1f - (_deadline - time) / value); ((Graphic)_fill).color = GaugeColor; if ((Object)(object)_distanceText != (Object)null) { LabelMode value2 = s_label.Value; ((Behaviour)_distanceText).enabled = value2 != LabelMode.None; ((Graphic)_distanceText).color = GaugeColor; if (value2 == LabelMode.TimeToImpact) { ((TMP_Text)_distanceText).text = $"{Mathf.Max(0f, _deadline - time):F2} s"; } else if (value2 == LabelMode.DistanceToImpact && flag2) { ((TMP_Text)_distanceText).text = $"{impact.Distance:F1} m"; } } } private static bool IsEligible(Character c) { CharacterData data = c.data; if (data.dead || data.isGrounded || data.isClimbingAnything || data.isCarried) { return false; } if ((Object)(object)c.refs.balloons != (Object)null && c.refs.balloons._isParachuteOpen) { return false; } return true; } private static float SinceGroundedCap(Character c, int balloonCount) { CharacterBalloons balloons = c.refs.balloons; if (!((Object)(object)balloons != (Object)null) || balloonCount <= 0) { return float.PositiveInfinity; } return Mathf.Clamp(2f - balloons.balloonSinceGroundedCapAmount * (float)balloonCount, 0.5f, 2f); } private static float FallTimeAt(Character c, float T, float sinceGrounded) { CharacterData data = c.data; float num = data.sinceJump + T; float num2 = Mathf.Min(num, sinceGrounded); num2 = ((!(sinceGrounded - num > -0.05f)) ? (num2 - 0.125f) : (num2 - 0.375f)); float num3 = Time.time + T; if (data.lastBouncedTime + 2.25f > num3) { num2 -= data.lastBouncedTime + 2.5f - num3; } return num2; } private static bool WouldTakeDamage(Character c, float timeToImpact, float impactSpeed, float sinceGroundedAtImpact) { float fallDamageTime = c.refs.movement.fallDamageTime; float num = FallTimeAt(c, timeToImpact, sinceGroundedAtImpact); if (num <= fallDamageTime) { return false; } if (sinceGroundedAtImpact <= 0.5f) { return false; } float num2 = Mathf.Max(Mathf.Pow(Mathf.InverseLerp(fallDamageTime, 3f, num), 1.5f), 0.05f); float num3 = Mathf.Pow(Mathf.InverseLerp(10f, 20f, Mathf.Max(impactSpeed, 0f)), 1.5f); if (Mathf.Min(num2, num3) < 0.025f) { return false; } return Ascents.fallDamageMultiplier > 0f; } private bool EnsureUI() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fill != (Object)null && (Object)(object)_uiRoot != (Object)null) { return true; } _fill = null; _empty = null; _uiRoot = null; _distanceText = null; UI_UseItemProgress val = null; if ((Object)(object)GUIManager.instance != (Object)null) { val = ((Component)GUIManager.instance).GetComponentInChildren<UI_UseItemProgress>(true); } if ((Object)(object)val == (Object)null) { val = Object.FindAnyObjectByType<UI_UseItemProgress>((FindObjectsInactive)1); } if ((Object)(object)val == (Object)null || (Object)(object)val.fill == (Object)null) { return false; } GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val2).name = "SomeTweaks_FallDamageIndicator"; UI_UseItemProgress component = val2.GetComponent<UI_UseItemProgress>(); _fill = component.fill; _empty = component.empty; Object.DestroyImmediate((Object)(object)component); _uiRoot = val2.transform; _uiRoot.SetAsLastSibling(); ((Graphic)_fill).color = GaugeColor; ((Behaviour)_fill).enabled = false; if ((Object)(object)_empty != (Object)null) { ((Behaviour)_empty).enabled = false; } CreateDistanceText(); return true; } private void CreateDistanceText() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Distance", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(_uiRoot, false); Vector3 localScale = _uiRoot.localScale; _uiRoot.localScale = Vector3.one; Vector3[] array = (Vector3[])(object)new Vector3[4]; ((Graphic)_fill).rectTransform.GetWorldCorners(array); Vector3 val3 = _uiRoot.InverseTransformPoint((array[1] + array[2]) * 0.5f); _uiRoot.localScale = localScale; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0f); val2.pivot = val4; Vector2 anchorMin = (val2.anchorMax = val4); val2.anchorMin = anchorMin; val2.sizeDelta = new Vector2(300f, 40f); ((Transform)val2).localPosition = new Vector3(val3.x, val3.y + 4f, 0f); _distanceText = val.AddComponent<TextMeshProUGUI>(); TextMeshProUGUI val6 = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.interactNameText : null); if ((Object)(object)val6 != (Object)null) { ((TMP_Text)_distanceText).font = ((TMP_Text)val6).font; ((TMP_Text)_distanceText).fontSharedMaterial = ((TMP_Text)val6).fontSharedMaterial; } ((TMP_Text)_distanceText).fontSize = 28f; ((TMP_Text)_distanceText).alignment = (TextAlignmentOptions)1026; ((Graphic)_distanceText).color = GaugeColor; ((Graphic)_distanceText).raycastTarget = false; ((TMP_Text)_distanceText).text = ""; ((Behaviour)_distanceText).enabled = false; } private void Show() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (EnsureUI()) { _fill.fillAmount = 0f; ((Graphic)_fill).color = GaugeColor; ((Behaviour)_fill).enabled = true; if ((Object)(object)_empty != (Object)null) { ((Behaviour)_empty).enabled = true; } if ((Object)(object)_distanceText != (Object)null) { ((TMP_Text)_distanceText).text = ""; ((Behaviour)_distanceText).enabled = s_label.Value != LabelMode.None; } ShortcutExtensions.DOKill((Component)(object)_uiRoot, false); _uiRoot.localScale = Vector3.zero; TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(_uiRoot, 1f, 0.25f), (Ease)27); } } private void Deactivate() { _active = false; _lostTimer = 0f; if ((Object)(object)_fill != (Object)null) { ((Behaviour)_fill).enabled = false; } if ((Object)(object)_empty != (Object)null) { ((Behaviour)_empty).enabled = false; } if ((Object)(object)_distanceText != (Object)null) { ((Behaviour)_distanceText).enabled = false; } } } [HarmonyPatch] public class GazeOfCondor : MonoBehaviour { public enum EyeStyle { Condor, Human } private static class EyeTexture { private readonly struct Lens { private readonly float _corner; private readonly float _cy; private readonly float _r; public Lens(float corner, float h) { _corner = corner; _cy = (h * h - corner * corner) / (2f * h); _r = h - _cy; } public float Distance(Vector2 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return Mathf.Min(Arc(p, _cy, upper: true), Arc(p, 0f - _cy, upper: false)); } private float Arc(Vector2 p, float centerY, bool upper) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, centerY); Vector2 val2 = p - val; float magnitude = ((Vector2)(ref val2)).magnitude; float num = centerY + ((magnitude > 1E-06f) ? (val2.y / magnitude) : 1f) * _r; if (upper ? (num >= 0f) : (num <= 0f)) { return Mathf.Abs(magnitude - _r); } return Mathf.Min(Vector2.Distance(p, new Vector2(0f - _corner, 0f)), Vector2.Distance(p, new Vector2(_corner, 0f))); } } private const float UnitsX = 2.6f; private const float UnitsY = 1.3f; private const float InnerCorner = 1f; private const float InnerHeight = 0.46f; private const float OuterCorner = 1.24f; private const float OuterHeight = 0.56f; private const float IrisRadius = 0.4f; private static readonly Vector2[] Brow = (Vector2[])(object)new Vector2[4] { new Vector2(-1.05f, -0.02f), new Vector2(-0.3f, 0.3f), new Vector2(0.55f, 0.37f), new Vector2(1f, 0.16f) }; private static readonly Vector2 CondorCenter = new Vector2(0.05f, 0.02f); private const float CondorRadius = 0.42f; private const float CondorPupil = 0.17f; private static readonly Vector2 LoreStart = CondorCenter + new Vector2(-0.3906f, -0.147f); private static readonly Vector2 LoreEnd = new Vector2(-0.98f, -0.2f); private static float CondorDistance(Vector2 p) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008b: 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_0053: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; for (int i = 0; i < Brow.Length - 1; i++) { num = Mathf.Min(num, Segment(p, Brow[i], Brow[i + 1])); } if (p.y <= BrowY(p.x)) { float num2 = Vector2.Distance(p, CondorCenter); num = Mathf.Min(num, Mathf.Abs(num2 - 0.42f)); num = Mathf.Min(num, Mathf.Abs(num2 - 0.17f)); } return Mathf.Min(num, Segment(p, LoreStart, LoreEnd)); } private static float BrowY(float x) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0030: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < Brow.Length - 1; i++) { Vector2 val = Brow[i]; Vector2 val2 = Brow[i + 1]; if (x >= val.x && x <= val2.x) { return Mathf.Lerp(val.y, val2.y, (x - val.x) / (val2.x - val.x)); } } return float.MaxValue; } private static float Segment(Vector2 p, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude); return Vector2.Distance(p, a + val * num); } public static Texture2D Create(int width, float lineWidthPx, EyeStyle style) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003a: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(8, Mathf.RoundToInt((float)width * 1.3f / 2.6f)); Texture2D val = new Texture2D(width, num, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; float num2 = 2.6f / (float)width; float num3 = lineWidthPx * num2 * 0.5f; float num4 = num2; Lens lens = new Lens(1f, 0.46f); Lens lens2 = new Lens(1.24f, 0.56f); Color32[] array = (Color32[])(object)new Color32[width * num]; Vector2 p = default(Vector2); for (int i = 0; i < num; i++) { for (int j = 0; j < width; j++) { ((Vector2)(ref p))..ctor(((float)j + 0.5f - (float)width * 0.5f) * num2, ((float)i + 0.5f - (float)num * 0.5f) * num2); float num5; if (style == EyeStyle.Condor) { num5 = CondorDistance(p); } else { num5 = lens.Distance(p); num5 = Mathf.Min(num5, lens2.Distance(p)); num5 = Mathf.Min(num5, Mathf.Abs(((Vector2)(ref p)).magnitude - 0.4f)); } float num6 = 1f - Mathf.Clamp01((num5 - num3) / num4); array[i * width + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num6 * 255f)); } } val.SetPixels32(array); val.Apply(false, true); return val; } } private const string Section = "GazeOfCondor"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<bool> s_showWhileCarried; private static ConfigEntry<float> s_size; private static ConfigEntry<float> s_verticalPosition; private static ConfigEntry<float> s_lineWidth; private static ConfigEntry<string> s_color; private static ConfigEntry<float> s_opacity; private static ConfigEntry<bool> s_preview; private const float FadeInTime = 0.12f; private const float FadeOutTime = 0.4f; private static readonly HashSet<Condor> s_watching = new HashSet<Condor>(); private static GazeOfCondor s_instance; private Canvas _canvas; private RawImage _image; private float _alpha; private int _texWidth; private float _texLineWidth; private EyeStyle _texStyle; private static ConfigEntry<EyeStyle> s_style; public static void Init(ConfigFile config, Harmony harmony) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) s_enabled = config.Bind<bool>("GazeOfCondor", "Enabled", true, "Shows an eye illustration on screen when a condor targets you for a dive."); s_showWhileCarried = config.Bind<bool>("GazeOfCondor", "ShowWhileCarried", false, "Keeps showing the eyes while a condor is carrying you."); s_style = config.Bind<EyeStyle>("GazeOfCondor", "Style", EyeStyle.Condor, "Eye design. Condor = bird-of-prey eyes / Human = human eyes."); s_size = config.Bind<float>("GazeOfCondor", "Size", 220f, new ConfigDescription("Width of the eye illustration (pixels at 1920x1080).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(60f, 1920f), Array.Empty<object>())); s_verticalPosition = config.Bind<float>("GazeOfCondor", "VerticalPosition", 0.8f, new ConfigDescription("Vertical position (0 = bottom of the screen, 1 = top of the screen).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); s_lineWidth = config.Bind<float>("GazeOfCondor", "LineWidth", 2.5f, new ConfigDescription("Line width (pixels at 1920x1080).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 12f), Array.Empty<object>())); s_color = config.Bind<string>("GazeOfCondor", "Color", "#000000", "Line color (#RRGGBB, e.g. black #000000 / white #FFFFFF / purple #A060FF)."); s_opacity = config.Bind<float>("GazeOfCondor", "Opacity", 0.9f, new ConfigDescription("Opacity of the eye illustration.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); s_preview = config.Bind<bool>("GazeOfCondor", "Preview", false, "For adjusting the look: always shows the eyes, even when you are not targeted."); harmony.PatchAll(typeof(GazeOfCondor)); GameObject val = new GameObject("SomeTweaks.GazeOfCondor"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; s_instance = val.AddComponent<GazeOfCondor>(); ((Behaviour)s_instance).enabled = s_preview.Value; config.SettingChanged += delegate { Wake(); }; } private static void Wake() { if ((Object)(object)s_instance != (Object)null) { ((Behaviour)s_instance).enabled = true; } } [HarmonyPatch(typeof(Condor), "RPCA_CondorAction")] [HarmonyPostfix] private static void RpcaCondorActionPostfix(Condor __instance) { Refresh(__instance); } private static void Refresh(Condor condor) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 Character localCharacter = Character.localCharacter; if (((Object)(object)condor != (Object)null && (Object)(object)localCharacter != (Object)null && (Object)(object)condor._targetChar == (Object)(object)localCharacter && ((int)condor._state == 1 || (s_showWhileCarried.Value && (int)condor._state == 2))) ? s_watching.Add(condor) : s_watching.Remove(condor)) { Wake(); } } private static bool IsTargeted() { if (s_watching.Count > 0) { s_watching.RemoveWhere((Condor c) => (Object)(object)c == (Object)null); } return s_watching.Count > 0; } private void Update() { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) bool flag = s_enabled.Value && (s_preview.Value || IsTargeted()); float num = (flag ? 1f : 0f); float num2 = (flag ? 8.333334f : 2.5f); _alpha = Mathf.MoveTowards(_alpha, num, Time.unscaledDeltaTime * num2); if (_alpha <= 0f) { if ((Object)(object)_canvas != (Object)null) { ((Behaviour)_canvas).enabled = false; } ((Behaviour)this).enabled = false; return; } EnsureUI(); ((Behaviour)_canvas).enabled = true; int num3 = Mathf.RoundToInt(s_size.Value); float value = s_lineWidth.Value; EyeStyle value2 = s_style.Value; if (num3 != _texWidth || !Mathf.Approximately(value, _texLineWidth) || value2 != _texStyle || (Object)(object)_image.texture == (Object)null) { if ((Object)(object)_image.texture != (Object)null) { Object.Destroy((Object)(object)_image.texture); } _image.texture = (Texture)(object)EyeTexture.Create(num3, value, value2); _texWidth = num3; _texLineWidth = value; _texStyle = value2; } RectTransform rectTransform = ((Graphic)_image).rectTransform; rectTransform.sizeDelta = new Vector2((float)_image.texture.width, (float)_image.texture.height); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, s_verticalPosition.Value); rectTransform.anchorMax = val; rectTransform.anchorMin = val; float num4 = (flag ? Mathf.Lerp(1.15f, 1f, _alpha) : 1f); ((Transform)rectTransform).localScale = Vector3.one * num4; Color black = default(Color); if (!ColorUtility.TryParseHtmlString(s_color.Value?.Trim(), ref black)) { black = Color.black; } black.a = _alpha * s_opacity.Value; ((Graphic)_image).color = black; } private void EnsureUI() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_canvas != (Object)null)) { GameObject val = new GameObject("GazeOfCondorCanvas"); val.transform.SetParent(((Component)this).transform, false); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 5000; CanvasScaler obj = val.AddComponent<CanvasScaler>(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); obj.matchWidthOrHeight = 0.5f; GameObject val2 = new GameObject("Eye", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); _image = val2.AddComponent<RawImage>(); ((Graphic)_image).raycastTarget = false; RectTransform rectTransform = ((Graphic)_image).rectTransform; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = Vector2.zero; } } } internal static class GloomFix { private const string Section = "GloomFix"; private static ConfigEntry<bool> s_enabled; public static void Init(ConfigFile config, Harmony harmony) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown s_enabled = config.Bind<bool>("GloomFix", "Enabled", true, "Checks every physics frame whether your own character is in water (vanilla checks one character per frame in turn). The rules are the same as vanilla."); harmony.Patch((MethodBase)AccessTools.Method(typeof(WaterZone), "UpdateCharacters", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GloomFix), "UpdateCharactersPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void UpdateCharactersPrefix(WaterZone __instance) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!s_enabled.Value) { return; } Character localCharacter = Character.localCharacter; Dictionary<Character, InWaterState> trackedCharacters = __instance.trackedCharacters; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || !trackedCharacters.ContainsKey(localCharacter)) { return; } Bodypart bodypart = localCharacter.GetBodypart((BodypartType)13); Bodypart bodypart2 = localCharacter.GetBodypart((BodypartType)16); if (!((Object)(object)bodypart == (Object)null) && !((Object)(object)bodypart2 == (Object)null)) { if (((Bounds)(ref __instance.zoneBounds)).Contains(localCharacter.Center)) { trackedCharacters[localCharacter] = (InWaterState)2; } else if (((Bounds)(ref __instance.zoneBounds)).Contains(bodypart.transform.position) || ((Bounds)(ref __instance.zoneBounds)).Contains(bodypart2.transform.position)) { trackedCharacters[localCharacter] = (InWaterState)1; } else if (localCharacter.data.isGrounded) { trackedCharacters[localCharacter] = (InWaterState)0; } } } } internal static class GuidebookFix { public enum RenderTiming { Always, WhenViewedByMe, Never } private const string Section = "GuidebookFix"; private static ConfigEntry<bool> s_enabled; private static ConfigEntry<RenderTiming> s_mode; private static readonly Dictionary<string, RenderTexture> s_pageCache = new Dictionary<string, RenderTexture>(); private static readonly HashSet<Guid> s_viewedPages = new HashSet<Guid>(); private static bool s_skipRender; private static RenderTiming Mode => s_mode.Value; public static void Init(ConfigFile config, Harmony harmony) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_00fc: Expected O, but got Unknown //IL_00fc: Expected O, but got Unknown //IL_011b: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0151: Expected O, but got Unknown //IL_0151: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown s_enabled = config.Bind<bool>("GuidebookFix", "Enabled", true, "Makes rendering of the guidebook and pages lighter (when to render is set by RenderPages). Turning this on or off takes effect after restarting the game."); s_mode = config.Bind<RenderTiming>("GuidebookFix",