Decompiled source of AutoCameraSpectator v1.2.0
BepInEx/plugins/AutoCameraSpectator/AutoCameraSpectator.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using Zorro.Core; using Zorro.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TactiKot")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Automatic PEAK spectator camera with scene-aware player selection and event framing.")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+4bb34a0c1aa9d8be7948e41ce5f03fecf1502c28")] [assembly: AssemblyProduct("AutoCameraSpectator")] [assembly: AssemblyTitle("AutoCameraSpectator")] [assembly: AssemblyVersion("1.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AutoCameraSpectator { internal static class AutoTargetSelector { private readonly struct TargetCandidate { internal PlayerSnapshot Player { get; } internal SceneScore Breakdown { get; } internal float Score => Breakdown.Final; internal TargetCandidate(PlayerSnapshot player, SceneScore breakdown) { Player = player; Breakdown = breakdown; } } private sealed class TargetHistory { internal float LastSeenTime { get; set; } internal float LastWatchedTime { get; set; } = -9999f; internal bool HasSmoothedScore { get; set; } internal float SmoothedScore { get; set; } internal float LastScoreTime { get; set; } } private const float LongWatchFadeSeconds = 8f; private const float RecentlyWatchedPenalty = 15f; private const float RecentlyWatchedPenaltySeconds = 12f; private const float HistoryPruneSeconds = 30f; private const float ScoreRiseSeconds = 0.45f; private const float ScoreFallSeconds = 1.1f; private static readonly Dictionary<int, TargetHistory> Histories = new Dictionary<int, TargetHistory>(); private static readonly List<TargetCandidate> Candidates = new List<TargetCandidate>(); private static int lastTelemetryVersion = int.MinValue; private static int currentTargetId; private static float watchStartedTime; private static float lastSwitchTime = -9999f; private static float pendingUntil = -1f; internal static bool Active { get; private set; } internal static void ToggleByUser() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!SpectatorSession.CanSelectOthers) { Plugin.Instance.ShowStatus("Player switching is available after death", Color.yellow); } else if (!Plugin.Instance.TargetSelectionEnabled.Value) { SetActive(active: false, showMessage: false, "config disabled"); Plugin.Instance.ShowStatus("Auto player selection disabled in config", Color.yellow); } else { SetActive(!Active, showMessage: true, "user toggle"); } } internal static void OnManualSwitch() { if (Active && Plugin.SpectatorControlsAllowed()) { SetActive(active: false, showMessage: true, "manual target switch"); } } internal static void Apply() { if (!CanRun()) { ResetSelectionState(); } else { if (SpectatorTelemetry.Version == lastTelemetryVersion || Time.unscaledTime < pendingUntil) { return; } lastTelemetryVersion = SpectatorTelemetry.Version; float unscaledTime = Time.unscaledTime; SyncCurrentWatch((SpectatorTelemetry.TryGet(MainCameraMovement.specCharacter, out PlayerSnapshot snapshot) ? snapshot : null)?.StableId ?? 0, unscaledTime); IReadOnlyList<PlayerSnapshot> players = SpectatorTelemetry.Players; List<TargetCandidate> candidates = Candidates; candidates.Clear(); TargetCandidate? targetCandidate = null; TargetCandidate? targetCandidate2 = null; TargetCandidate? targetCandidate3 = null; for (int i = 0; i < players.Count; i++) { PlayerSnapshot playerSnapshot = players[i]; if (playerSnapshot.IsSelectable && SpectatorTelemetry.IsSelectableNow(playerSnapshot.Character)) { TargetCandidate targetCandidate4 = CreateCandidate(playerSnapshot, currentTargetId, unscaledTime); candidates.Add(targetCandidate4); if (targetCandidate4.Player.StableId == currentTargetId) { targetCandidate = targetCandidate4; } if (!targetCandidate2.HasValue || targetCandidate4.Score > targetCandidate2.Value.Score) { targetCandidate2 = targetCandidate4; } if (!targetCandidate3.HasValue || targetCandidate4.Breakdown.Urgency > targetCandidate3.Value.Breakdown.Urgency || (targetCandidate4.Breakdown.Urgency == targetCandidate3.Value.Breakdown.Urgency && targetCandidate4.Score > targetCandidate3.Value.Score)) { targetCandidate3 = targetCandidate4; } } } if (targetCandidate3.HasValue && SelectionPolicy.IsEmergency(targetCandidate3.Value.Breakdown.Urgency, targetCandidate?.Breakdown.Urgency ?? 0f)) { targetCandidate2 = targetCandidate3; } if (targetCandidate2.HasValue && ShouldSwitch(targetCandidate, targetCandidate2.Value, unscaledTime)) { SwitchTo(targetCandidate2.Value, targetCandidate, candidates, unscaledTime); } PruneHistories(unscaledTime); } } internal static void Reset() { Active = false; EndSession(); } internal static void EndSession() { Histories.Clear(); Candidates.Clear(); lastSwitchTime = -9999f; pendingUntil = -1f; ResetSelectionState(); } private static bool CanRun() { if (Active && Plugin.Instance.TargetSelectionEnabled.Value && SpectatorSession.CanSelectOthers) { return Plugin.SpectatorControlsAllowed(); } return false; } private static TargetCandidate CreateCandidate(PlayerSnapshot player, int currentId, float now) { TargetHistory history = GetHistory(player.StableId); history.LastSeenTime = now; SceneScore evaluation = player.Evaluation; float smoothedScene = SmoothScore(history, evaluation.Scene, player.Signals, evaluation.Urgency, now); float currentBonus = ((player.StableId == currentId) ? GetCurrentTargetBonus(now) : 0f); float recentlyWatchedPenalty = ((player.StableId == currentId) ? 0f : (GetRecentlyWatchedPenalty(history, now) * 15f)); return new TargetCandidate(player, evaluation.WithFinal(smoothedScene, currentBonus, recentlyWatchedPenalty)); } private static float SmoothScore(TargetHistory history, float sceneScore, SceneSignals signals, float urgency, float now) { if (!history.HasSmoothedScore) { history.HasSmoothedScore = true; history.SmoothedScore = sceneScore; history.LastScoreTime = now; return sceneScore; } float num = Mathf.Max(0f, now - history.LastScoreTime); float num2 = ((sceneScore >= history.SmoothedScore) ? 0.45f : 1.1f); float num3 = 1f - Mathf.Exp((0f - num) / Mathf.Max(0.001f, num2)); if (urgency >= 0.65f) { num3 = Mathf.Max(num3, 0.85f); } else if (signals.ThreatAppeared > 0.5f) { num3 = Mathf.Max(num3, 0.65f); } history.SmoothedScore = Mathf.Lerp(history.SmoothedScore, sceneScore, Mathf.Clamp01(num3)); history.LastScoreTime = now; return history.SmoothedScore; } private static bool ShouldSwitch(TargetCandidate? current, TargetCandidate best, float now) { Plugin instance = Plugin.Instance; return SelectionPolicy.ShouldSwitch(current?.Player.StableId ?? 0, current?.Score ?? 0f, current?.Breakdown.Urgency ?? 0f, best.Player.StableId, best.Score, best.Breakdown.Urgency, now - lastSwitchTime, instance.TargetSwitchMinInterval.Value, Mathf.Min(instance.TargetSwitchMinInterval.Value, instance.TargetEmergencySwitchInterval.Value), instance.TargetSwitchScoreLead.Value); } private static void SwitchTo(TargetCandidate candidate, TargetCandidate? previous, List<TargetCandidate> candidates, float now) { string log = DescribeSwitch(candidate, previous, candidates); Transitions instance = Transitions.instance; if (!NeedsCut(candidate.Player.Character) || (Object)(object)instance == (Object)null) { Commit(candidate, now, log); return; } pendingUntil = now + 1.5f; try { instance.PlayTransition((TransitionType)3, (Action)delegate { pendingUntil = -1f; if (CanRun()) { Commit(candidate, Time.unscaledTime, log); } }, 5f, 5f); } catch (Exception ex) { pendingUntil = -1f; Plugin.Log.LogWarning((object)("Spectator fade unavailable, switching directly: " + ex.Message)); Commit(candidate, now, log); } } private static bool NeedsCut(Character target) { //IL_002a: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Character specCharacter = MainCameraMovement.specCharacter; float value = Plugin.Instance.TargetTransitionDistance.Value; if (!((Object)(object)specCharacter == (Object)null) && !(value <= 0f)) { return Vector3.Distance(SpectatorTelemetry.GetLivePosition(specCharacter), SpectatorTelemetry.GetLivePosition(target)) > value; } return true; } private static void Commit(TargetCandidate candidate, float now, string? log) { //IL_010c: Unknown result type (might be due to invalid IL or missing references) int num = currentTargetId; try { if (!SpectatorSession.TrySelect(candidate.Player.Character)) { return; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Automatic spectator target switch failed: " + ex.Message)); return; } if (!((Object)(object)MainCameraMovement.specCharacter != (Object)(object)candidate.Player.Character)) { if (num != 0 && num != candidate.Player.StableId && Histories.TryGetValue(num, out TargetHistory value)) { value.LastWatchedTime = now; } currentTargetId = candidate.Player.StableId; watchStartedTime = now; lastSwitchTime = now; EventFramer.Reset(); if (log != null) { Plugin.Log.LogInfo((object)log); } if (Plugin.Instance.TargetShowSwitchReason.Value) { PlayerSnapshot player = candidate.Player; string text = SceneEvaluator.Describe(player.Scene, player.Signals, candidate.Breakdown); Plugin.Instance.ShowStatus((text.Length == 0) ? player.Name : (player.Name + ": " + text), Color.white, 2f); } } } private static void SyncCurrentWatch(int id, float now) { if (currentTargetId != id) { if (currentTargetId != 0 && Histories.TryGetValue(currentTargetId, out TargetHistory value)) { value.LastWatchedTime = now; } currentTargetId = id; watchStartedTime = now; } } private static void PruneHistories(float now) { List<int> list = null; foreach (KeyValuePair<int, TargetHistory> history in Histories) { float num = Mathf.Max(history.Value.LastSeenTime, history.Value.LastWatchedTime); if (!(now - num <= 30f)) { if (list == null) { list = new List<int>(); } list.Add(history.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { Histories.Remove(list[i]); } } } private static TargetHistory GetHistory(int id) { if (!Histories.TryGetValue(id, out TargetHistory value)) { value = new TargetHistory(); Histories[id] = value; } return value; } private static float GetCurrentTargetBonus(float now) { Plugin instance = Plugin.Instance; float num = Mathf.Clamp01((Mathf.Max(0f, now - watchStartedTime) - Mathf.Max(1f, instance.TargetMaxWatchSeconds.Value)) / 8f); return Mathf.Max(0f, instance.TargetStickinessBonus.Value) * (1f - num); } private static float GetRecentlyWatchedPenalty(TargetHistory history, float now) { if (history.LastWatchedTime <= 0f) { return 0f; } return 1f - Mathf.Clamp01((now - history.LastWatchedTime) / 12f); } private static void SetActive(bool active, bool showMessage, string reason) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (Active != active) { Active = active; ResetSelectionState(); if (active) { lastSwitchTime = -9999f; } if (showMessage) { Plugin.Instance.ShowStatus(active ? "Auto player selection: ON" : "Auto player selection: OFF", active ? Color.green : Color.yellow); } Plugin.Log.LogInfo((object)("Automatic player selection " + (active ? "enabled" : "disabled") + " (" + reason + ").")); } } private static void ResetSelectionState() { currentTargetId = 0; watchStartedTime = 0f; lastTelemetryVersion = int.MinValue; } private static string? DescribeSwitch(TargetCandidate selected, TargetCandidate? previous, List<TargetCandidate> candidates) { if (!Plugin.Instance.TargetDebugScores.Value) { return null; } candidates.Sort((TargetCandidate left, TargetCandidate right) => right.Score.CompareTo(left.Score)); int num = Math.Min(3, candidates.Count); List<string> list = new List<string>(num); for (int num2 = 0; num2 < num; num2++) { list.Add(FormatCandidate(candidates[num2])); } return "Auto target switch: selected=" + FormatCandidate(selected) + "; previous=" + (previous.HasValue ? FormatCandidate(previous.Value) : "none") + "; top=" + string.Join(" | ", list); } private static string FormatCandidate(TargetCandidate candidate) { SceneScore breakdown = candidate.Breakdown; return $"{candidate.Player.Name}#{candidate.Player.StableId} " + $"final={breakdown.Final:0.0} scene={breakdown.SmoothedScene:0.0}/{breakdown.Scene:0.0} " + $"threat={breakdown.Threat:0.0} peril={breakdown.Peril:0.0} social={breakdown.Social:0.0} " + $"activity={breakdown.Activity:0.0} frame={breakdown.FramePotential:0.0} " + $"urgency={breakdown.Urgency:0.00} " + $"voice={candidate.Player.Scene.Voice:0.00} nearbySpeech={candidate.Player.Scene.NearbySpeech:0.00} " + $"damage={candidate.Player.Signals.Damage:0.00} fall={candidate.Player.Signals.Fall:0.00} " + $"collapse={candidate.Player.Signals.Collapse:0.00} rescue={candidate.Player.Signals.Rescue:0.00} " + $"sticky={breakdown.CurrentBonus:0.0} recent=-{breakdown.RecentlyWatchedPenalty:0.0}"; } } internal static class CameraConfigMigration { private static readonly string[] LegacyKeys = new string[5] { "PositionSmoothing", "RotationSmoothing", "RotationSpringSeconds", "SmoothRotationSpringSeconds", "SmoothRotationMaxSpeedDegrees" }; internal static bool Apply(ConfigFile config, string original) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown Dictionary<ConfigDefinition, string> dictionary = Parse(original); bool flag = false; string[] legacyKeys = LegacyKeys; foreach (string text in legacyKeys) { flag |= dictionary.ContainsKey(new ConfigDefinition("General", text)); } if (!flag) { return false; } string text2 = config.ConfigFilePath + ".pre-1.1.0.bak"; if (File.Exists(config.ConfigFilePath) && !File.Exists(text2)) { File.Copy(config.ConfigFilePath, text2); } if (TryNumber(dictionary, "PositionSmoothing", out var value)) { SetIfMissing(config, dictionary, "General", "InstantPosition", value <= 0f); if (value > 0f) { SetIfMissing(config, dictionary, "General", "PositionResponseSeconds", 2.302585f / value); } } float value2; bool flag2 = TryNumber(dictionary, "RotationSmoothing", out value2); float value3; bool flag3 = TryNumber(dictionary, "RotationSpringSeconds", out value3); if (flag2) { SetIfMissing(config, dictionary, "General", "InstantRotation", value2 <= 0f); } if (flag3 && value3 > 0f) { SetIfMissing(config, dictionary, "General", "RotationResponseSeconds", 2.302585f * value3); } else if (flag2 && value2 > 0f) { SetIfMissing(config, dictionary, "General", "RotationResponseSeconds", 2.302585f / value2); } if (TryNumber(dictionary, "SmoothRotationSpringSeconds", out var value4)) { SetIfMissing(config, dictionary, "Cinematic", "RotationResponseSeconds", value4); } if (TryNumber(dictionary, "SmoothRotationMaxSpeedDegrees", out var value5)) { SetIfMissing(config, dictionary, "Cinematic", "MaxSpeedDegrees", value5); } legacyKeys = LegacyKeys; foreach (string text3 in legacyKeys) { ConfigDefinition val = new ConfigDefinition("General", text3); if (dictionary.ContainsKey(val)) { config.Bind<float>(val, 0f, (ConfigDescription)null); config.Remove(val); } } return true; } private static Dictionary<ConfigDefinition, string> Parse(string text) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown Dictionary<ConfigDefinition, string> dictionary = new Dictionary<ConfigDefinition, string>(); string text2 = string.Empty; using StringReader stringReader = new StringReader(text); string text3; while ((text3 = stringReader.ReadLine()) != null) { text3 = text3.Trim(); if (text3.Length == 0 || text3.StartsWith("#", StringComparison.Ordinal)) { continue; } if (text3.StartsWith("[", StringComparison.Ordinal) && text3.EndsWith("]", StringComparison.Ordinal)) { text2 = text3.Substring(1, text3.Length - 2); continue; } int num = text3.IndexOf('='); if (num > 0) { dictionary[new ConfigDefinition(text2, text3.Substring(0, num).Trim())] = text3.Substring(num + 1).Trim(); } } return dictionary; } private static bool TryNumber(Dictionary<ConfigDefinition, string> source, string key, out float value) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown value = 0f; if (source.TryGetValue(new ConfigDefinition("General", key), out string value2) && float.TryParse(value2, NumberStyles.Float, CultureInfo.InvariantCulture, out value) && !float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static void SetIfMissing(ConfigFile config, Dictionary<ConfigDefinition, string> source, string section, string key, object value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ConfigDefinition key2 = new ConfigDefinition(section, key); if (!source.ContainsKey(key2) && ((IDictionary<ConfigDefinition, ConfigEntryBase>)config).TryGetValue(key2, out ConfigEntryBase value2)) { ConfigEntryBase obj = value2; AcceptableValueBase acceptableValues = value2.Description.AcceptableValues; obj.BoxedValue = ((acceptableValues != null) ? acceptableValues.Clamp(value) : null) ?? value; } } } internal static class CameraDirector { private const float FallShotMaxDistance = 45f; private static readonly CameraRig Rig = new CameraRig(); private static readonly CameraObstacles Obstacles = new CameraObstacles(CameraPhysics.Shared); private static readonly EventVisibility Visibility = new EventVisibility(CameraPhysics.Shared); private static readonly EventOrbitPlanner Planner = new EventOrbitPlanner(CameraPhysics.Shared); private static readonly LookIntent Look = new LookIntent(); private static readonly FallShot Fall = new FallShot(); private static readonly Func<Vector3, int, bool> CanSeeEvent = EventFramer.IsVisibleFrom; private static MainCameraMovement? outputCamera; private static Camera? renderCamera; private static Character? watched; private static int lastAppliedFrame = -1; private static bool wasEvent; private static float baseFov = 60f; private static float writtenFov; private static bool ownsLens; private static float nextFramingWarning; private static Vector3 lastAnchor; private static Vector2 writtenLook; private static bool hasWrittenLook; private static float manualUntil = -1f; private static bool manualAnnounced; internal static void Apply(MainCameraMovement cameraMovement) { //IL_0783: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Unknown result type (might be due to invalid IL or missing references) //IL_078d: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0823: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_077e: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; Character localCharacter = Character.localCharacter; Character specCharacter = MainCameraMovement.specCharacter; if (instance.LookMode == SpectatorLookMode.Off || !Plugin.SpectatorControlsAllowed() || (Object)(object)localCharacter == (Object)null || !localCharacter.data.dead || (Object)(object)specCharacter == (Object)null || (Object)(object)specCharacter == (Object)(object)localCharacter || (Object)(object)specCharacter.data == (Object)null) { ResetRotation(); return; } Vector3 right = default(Vector3); Vector3 livePosition = SpectatorTelemetry.GetLivePosition(specCharacter, right); bool flag = (Object)(object)watched != (Object)(object)specCharacter; bool flag2 = CameraContinuity.NeedsCut((Object)(object)outputCamera == (Object)(object)cameraMovement && lastAppliedFrame >= 0 && Time.frameCount - lastAppliedFrame <= 1, flag, lastAnchor, livePosition, instance.TargetTransitionDistance.Value); if (flag2) { ResetRotation(); outputCamera = cameraMovement; renderCamera = ((Component)cameraMovement).GetComponent<Camera>(); watched = specCharacter; baseFov = NativeFov(renderCamera); Rig.Reset(((Component)cameraMovement).transform.position, ((Component)cameraMovement).transform.forward, ((Object)(object)renderCamera != (Object)null) ? renderCamera.fieldOfView : baseFov); } ObserveNativeLens(); if (lastAppliedFrame == Time.frameCount) { WritePose(cameraMovement); return; } if (!flag2 && flag) { watched = specCharacter; Rig.TransitionToTarget(); ResetShotState(); } lastAppliedFrame = Time.frameCount; float unscaledDeltaTime = Time.unscaledDeltaTime; float unscaledTime = Time.unscaledTime; lastAnchor = livePosition; Vector3 position = Rig.Position; bool flag3 = DetectManualControl(localCharacter, instance, unscaledTime); bool flag4 = !flag3 && instance.LookMode == SpectatorLookMode.EventFraming && instance.EventLookEnabled.Value; if (flag4 && !wasEvent) { Rig.EnterEvent(livePosition); Planner.Reset(); } wasEvent = flag4; float num = Mathf.Clamp(localCharacter.data.spectateZoom, cameraMovement.spectateZoomMin, cameraMovement.spectateZoomMax); float aspect = (((Object)(object)renderCamera != (Object)null) ? renderCamera.aspect : 1.7777778f); float radius = ProbeRadius(instance, flag4); CharacterData data = specCharacter.data; bool flag5 = data.isClimbing || data.isRopeClimbing || data.isVineClimbing; if (!flag3 && instance.FallShot.Value) { bool falling = !data.isGrounded && !flag5 && data.avarageVelocity.y < -8f; if (Fall.Update(falling, Vector3.Distance(Rig.Position, livePosition), 45f, unscaledDeltaTime, out var released)) { Rig.BeginHold(); } if (released && Vector3.Distance(Rig.Position, livePosition) > num * 2f + 8f) { Rig.Reset(((Component)cameraMovement).transform.position, Rig.Direction, Rig.FieldOfView); ResetShotState(); wasEvent = false; position = Rig.Position; } } else { Fall.Reset(); } if (Fall.Active) { Visibility.Reset(); Rig.HoldPosition(unscaledDeltaTime); if ((instance.ObstacleAvoidance.Value || (instance.LookMode == SpectatorLookMode.EventFraming && instance.EventAvoidOcclusion.Value)) && CameraPhysics.Shared.IsClear(position, radius)) { Rig.ConstrainPosition(CameraObstacles.MoveSafely(CameraPhysics.Shared, position, Rig.Position, radius)); } Rig.AimAt(livePosition, 0.25f, 240f, unscaledDeltaTime); Rig.RestoreLens(baseFov, unscaledDeltaTime); Rig.KeepAnchorInFrame(new FramePoint(livePosition, 0.9f), aspect); } else if (flag4) { EventCameraSettings settings = new EventCameraSettings(instance.EventPositionResponseSeconds.Value, instance.EventRotationResponseSeconds.Value, instance.EventRotationMaxSpeedDegrees.Value, Mathf.Max(3f, num), instance.EventMaxDistance.Value, instance.EventLookMaxFrameAngle.Value, instance.EventMaxFieldOfView.Value, instance.EventScreenMargin.Value, instance.EventPitchDegrees.Value, instance.CameraVerticalOffset.Value, instance.EventElevationDegrees.Value, instance.EventLensResponseSeconds.Value, instance.EventLensWidenDegrees.Value); float num2 = (flag5 ? instance.EventClimbingElevationDegrees.Value : 0f); float num3 = Rig.ShotTargetYaw; if (instance.EventFindOpenSide.Value) { num3 = Planner.Plan(num3, settings.Elevation + num2, SpectatorTelemetry.GetLiveHeadPosition(specCharacter, livePosition), settings.Distance, radius, unscaledTime); } Rig.SetShotPreference(num3, num2); EventFramer.Update(Rig.Position, specCharacter, Rig.ShotDirection(settings.Elevation), aspect, Mathf.Max(baseFov, settings.MaxFov)); Rig.MoveEvent(EventFramer.Points, settings, baseFov, aspect, unscaledDeltaTime); ApplyObstacles(specCharacter, position, instance, unscaledDeltaTime, radius, instance.EventAvoidOcclusion.Value); if (instance.EventAvoidOcclusion.Value) { Vector3 actual = Visibility.Resolve(position, Rig.Position, EventFramer.Points, CanSeeEvent, radius, unscaledTime, unscaledDeltaTime, instance.EventOcclusionGraceSeconds.Value, Rig.Velocity); if (Visibility.Recovering) { Rig.OverridePosition(actual, Visibility.Velocity); } else { Rig.ConstrainPosition(actual); } if (CameraPhysics.Shared.IsClear(position, radius)) { Rig.ConstrainPosition(CameraObstacles.MoveSafely(CameraPhysics.Shared, position, Rig.Position, radius)); } } else { Visibility.Reset(); } bool flag6 = Rig.AimEvent(EventFramer.Points, settings, baseFov, aspect, unscaledDeltaTime); if (instance.EventAvoidOcclusion.Value) { int num4 = 0; while (flag6 && num4 < EventFramer.Points.Count) { flag6 = EventFramer.IsVisibleFrom(Rig.Position, num4); num4++; } } if (!flag6 && instance.TargetDebugScores.Value && unscaledTime >= nextFramingWarning) { nextFramingWarning = unscaledTime + 5f; Plugin.Log.LogInfo((object)"Event camera is still composing the shot, or the group is limited by geometry/distance/FOV; prioritizing the watched player."); } } else { Visibility.Reset(); if (flag3) { Rig.AimManual(SpectatorTelemetry.GetLiveLookDirection(localCharacter)); } else { Vector3 desired = CameraMath.WithPitchOffset(Look.Update(SpectatorTelemetry.GetLiveLookDirection(specCharacter), data.avarageVelocity, flag5, instance.LookDeadZoneDegrees.Value), instance.PlayerPitchDegrees.Value); float seconds = (instance.SmoothRotationEnabled ? instance.CinematicRotationResponseSeconds.Value : instance.RotationResponseSeconds.Value); float maxSpeed = (instance.SmoothRotationEnabled ? instance.CinematicMaxSpeedDegrees.Value : instance.RotationMaxSpeedDegrees.Value); Rig.AimPlayer(desired, seconds, maxSpeed, instance.InstantRotation.Value && !instance.SmoothRotationEnabled, unscaledDeltaTime); } Vector3 target; try { target = specCharacter.GetSpectatePosition(); } catch (Exception) { target = livePosition; } CameraMath.Basis(Rig.Direction, out right, out var up); Vector3 offset = up * 0.5f + Vector3.up * instance.CameraVerticalOffset.Value; Rig.MovePlayer(target, offset, num, instance.PositionResponseSeconds.Value, instance.InstantPosition.Value && !flag3, unscaledDeltaTime); ApplyObstacles(specCharacter, position, instance, unscaledDeltaTime, radius); Rig.RestoreLens(baseFov, unscaledDeltaTime); } WritePose(cameraMovement); if (!flag3) { SyncSpectatorGhostDirection(Rig.Direction); } writtenLook = localCharacter.data.lookValues; hasWrittenLook = true; } internal static void ResetRotation() { if (ownsLens && (Object)(object)renderCamera != (Object)null && Mathf.Abs(renderCamera.fieldOfView - writtenFov) < 0.01f) { renderCamera.fieldOfView = baseFov; } outputCamera = null; renderCamera = null; watched = null; lastAppliedFrame = -1; wasEvent = (ownsLens = false); hasWrittenLook = (manualAnnounced = false); manualUntil = -1f; ResetShotState(); } internal static void ReleaseInactiveCamera() { if (lastAppliedFrame >= 0 && Time.frameCount - lastAppliedFrame > 1) { ResetRotation(); } } private static void ResetShotState() { Obstacles.Reset(); Visibility.Reset(); Planner.Reset(); Look.Reset(); Fall.Reset(); } private static bool DetectManualControl(Character local, Plugin plugin, float now) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float value = plugin.MouseOverrideSeconds.Value; if (value <= 0f) { manualUntil = -1f; return false; } if (hasWrittenLook) { Vector2 val = local.data.lookValues - writtenLook; if (((Vector2)(ref val)).sqrMagnitude > 0.0025f) { if (!manualAnnounced) { plugin.ShowStatus("Manual camera: automatic view resumes when the mouse is idle", Color.cyan, 2f); manualAnnounced = true; } manualUntil = now + value; } } return now < manualUntil; } private static float NativeFov(Camera? camera) { try { GameHandler instance = GameHandler.Instance; FovSetting val = (((Object)(object)instance != (Object)null && instance.SettingsHandler != null) ? instance.SettingsHandler.GetSetting<FovSetting>() : null); if (val != null) { return (((FloatSetting)val).Value < 60f) ? 70f : ((FloatSetting)val).Value; } } catch (Exception) { } if (!((Object)(object)camera != (Object)null)) { return 60f; } return camera.fieldOfView; } private static void ObserveNativeLens() { if (!((Object)(object)renderCamera == (Object)null) && ownsLens) { float fieldOfView = renderCamera.fieldOfView; if (Mathf.Abs(fieldOfView - writtenFov) > 0.01f) { baseFov = fieldOfView; } } } private static void WritePose(MainCameraMovement cameraMovement) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) ((Component)cameraMovement).transform.SetPositionAndRotation(Rig.Position, Quaternion.LookRotation(Rig.Direction, Vector3.up)); if (!((Object)(object)renderCamera == (Object)null)) { writtenFov = Mathf.Clamp(Rig.FieldOfView, 1f, 179f); renderCamera.fieldOfView = writtenFov; ownsLens = true; } } private static void ApplyObstacles(Character target, Vector3 previous, Plugin plugin, float deltaTime, float radius, bool force = false) { //IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (!plugin.ObstacleAvoidance.Value && !force) { Obstacles.Reset(); return; } Vector3 liveHeadPosition = SpectatorTelemetry.GetLiveHeadPosition(target, SpectatorTelemetry.GetLivePosition(target)); Rig.ConstrainPosition(Obstacles.Resolve(liveHeadPosition, previous, Rig.Position, radius, plugin.ObstacleReturnSeconds.Value, deltaTime)); } private static float ProbeRadius(Plugin plugin, bool eventMode) { if ((Object)(object)renderCamera == (Object)null) { return plugin.ObstacleProbeRadius.Value; } float num = Mathf.Tan((eventMode ? Mathf.Max(baseFov, plugin.EventMaxFieldOfView.Value) : Mathf.Max(baseFov, Rig.FieldOfView)) * 0.5f * (MathF.PI / 180f)); float num2 = renderCamera.nearClipPlane * Mathf.Sqrt(1f + num * num * (1f + renderCamera.aspect * renderCamera.aspect)); return Mathf.Max(plugin.ObstacleProbeRadius.Value, num2); } private static void SyncSpectatorGhostDirection(Vector3 forward) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0071: 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_007d: 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_0083: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && !((Object)(object)localCharacter.data == (Object)null) && localCharacter.data.dead && !((Object)(object)MainCameraMovement.specCharacter == (Object)(object)localCharacter)) { Vector3 val = CameraMath.Angles(forward); localCharacter.data.lookValues = new Vector2(localCharacter.data.lookValues.x + Mathf.DeltaAngle(localCharacter.data.lookValues.x, val.x), 0f - val.y); Vector3 val2 = Vector3.ProjectOnPlane(forward, Vector3.up); localCharacter.data.lookDirection = forward; localCharacter.data.lookDirection_Flat = ((Vector3)(ref val2)).normalized; CharacterData data = localCharacter.data; Vector3 val3 = Vector3.Cross(Vector3.up, forward); data.lookDirection_Right = ((Vector3)(ref val3)).normalized; CharacterData data2 = localCharacter.data; val3 = Vector3.Cross(forward, localCharacter.data.lookDirection_Right); data2.lookDirection_Up = ((Vector3)(ref val3)).normalized; } } } internal static class CameraMath { internal static Vector3 Angles(Vector3 direction) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_000e: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 1E-06f) { return Vector3.zero; } ((Vector3)(ref direction)).Normalize(); return new Vector3(Mathf.Atan2(direction.x, direction.z) * 57.29578f, Mathf.Clamp((0f - Mathf.Asin(Mathf.Clamp(direction.y, -1f, 1f))) * 57.29578f, -85f, 85f), 0f); } internal static Vector3 Direction(float yawDegrees, float pitchDegrees) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) float num = yawDegrees * (MathF.PI / 180f); float num2 = pitchDegrees * (MathF.PI / 180f); float num3 = Mathf.Cos(num2); return new Vector3(Mathf.Sin(num) * num3, 0f - Mathf.Sin(num2), Mathf.Cos(num) * num3); } internal static void Basis(Vector3 forward, out Vector3 right, out Vector3 up) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_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) Vector3 val = Vector3.Cross(Vector3.up, forward); right = ((Vector3)(ref val)).normalized; if (((Vector3)(ref right)).sqrMagnitude < 1E-06f) { right = Vector3.right; } val = Vector3.Cross(forward, right); up = ((Vector3)(ref val)).normalized; } internal static Vector3 BlendDirection(Vector3 from, Vector3 to, float blend) { //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_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_003b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(Vector3.Dot(from, to), -1f, 1f); Vector3 right = to - from * num; Vector3 up; if (((Vector3)(ref right)).sqrMagnitude < 1E-06f) { if (num > 0f) { return from; } Basis(from, out right, out up); } ((Vector3)(ref right)).Normalize(); float num2 = Mathf.Acos(num) * Mathf.Clamp01(blend); up = from * Mathf.Cos(num2) + right * Mathf.Sin(num2); return ((Vector3)(ref up)).normalized; } internal static Vector3 WithPitchOffset(Vector3 direction, float degrees) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { return Vector3.forward; } ((Vector3)(ref direction)).Normalize(); float num = Mathf.Atan2(direction.x, direction.z); float num2 = Mathf.Clamp((0f - Mathf.Asin(Mathf.Clamp(direction.y, -1f, 1f))) * 57.29578f + degrees, -85f, 85f) * (MathF.PI / 180f); float num3 = Mathf.Cos(num2); return new Vector3(Mathf.Sin(num) * num3, 0f - Mathf.Sin(num2), Mathf.Cos(num) * num3); } } internal static class CameraContinuity { internal static bool NeedsCut(bool uninterrupted, bool targetChanged, Vector3 previousAnchor, Vector3 anchor, float transitionDistance) { //IL_000f: 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) if (uninterrupted && (!targetChanged || !(transitionDistance <= 0f))) { return Vector3.Distance(previousAnchor, anchor) > (targetChanged ? transitionDistance : 20f); } return true; } } internal sealed class SpringMotion { private const float ResponseFrequency = 3.88972f; internal Vector3 Value { get; private set; } internal Vector3 Velocity { get; private set; } internal void Reset(Vector3 value, Vector3 velocity = default(Vector3)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Value = value; Velocity = velocity; } internal void Track(Vector3 value, float deltaTime) { //IL_002b: 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_000b: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (deltaTime > 0f) { Velocity = Vector3.ClampMagnitude((value - Value) / deltaTime, 60f); } Value = value; } internal Vector3 Step(Vector3 target, float responseSeconds, float maxSpeed, float deltaTime, float maxAcceleration = 0f) { //IL_000a: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f1: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (deltaTime <= 0f) { return Value; } float num = 3.88972f / Mathf.Max(0.05f, responseSeconds); float num3; Vector3 val3; for (float num2 = Mathf.Min(deltaTime, 0.25f); num2 > 1E-06f; Velocity = val3, num2 -= num3) { num3 = Mathf.Min(num2, 0.004166667f); Vector3 val = Value - target; if (maxSpeed > 0f) { val = Vector3.ClampMagnitude(val, 2f * maxSpeed / num); } Vector3 val2 = Velocity + val * num; float num4 = Mathf.Exp((0f - num) * num3); val3 = (Velocity - val2 * (num * num3)) * num4; if (maxAcceleration > 0f) { Vector3 val4 = val3 - Velocity; if (((Vector3)(ref val4)).sqrMagnitude > maxAcceleration * maxAcceleration * num3 * num3) { val3 = Velocity + Vector3.ClampMagnitude(val3 - Velocity, maxAcceleration * num3); Value += (Velocity + val3) * (0.5f * num3); continue; } } Value += (val + val2 * num3) * num4 - val; } return Value; } internal void Constrain(Vector3 value) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = value - Value; if (((Vector3)(ref val)).sqrMagnitude > 1E-08f) { Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Vector3.Dot(Velocity, normalized); if (num < 0f) { Velocity -= normalized * num; } } Value = value; } internal void Translate(Vector3 offset) { //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) Value += offset; } } internal sealed class AimMotion { private readonly SpringMotion motion = new SpringMotion(); private float targetYaw; internal Vector3 Direction => CameraMath.Direction(motion.Value.x, motion.Value.y); internal Vector3 Velocity => motion.Velocity; internal void Reset(Vector3 direction) { //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_0006: 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_0016: 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) Vector3 val = CameraMath.Angles(direction); motion.Reset(val); targetYaw = val.x; } internal Vector3 Step(Vector3 direction, float responseSeconds, float maxSpeed, float deltaTime) { //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_0006: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = CameraMath.Angles(direction); targetYaw += Mathf.DeltaAngle(targetYaw, val.x); if (Mathf.Abs(targetYaw - motion.Value.x) > 190f) { targetYaw = motion.Value.x + Mathf.DeltaAngle(motion.Value.x, targetYaw); } val.x = targetYaw; float maxAcceleration = 2f * ((maxSpeed > 0f) ? maxSpeed : 360f) / Mathf.Max(0.05f, responseSeconds); motion.Step(val, responseSeconds, maxSpeed, deltaTime, maxAcceleration); if (Mathf.Abs(motion.Value.y) > 85f) { motion.Constrain(new Vector3(motion.Value.x, Mathf.Clamp(motion.Value.y, -85f, 85f), 0f)); } if (Mathf.Abs(motion.Value.x) > 3600f) { float num = Mathf.Round(motion.Value.x / 360f) * 360f; motion.Translate(new Vector3(0f - num, 0f, 0f)); targetYaw -= num; } return Direction; } internal void Constrain(Vector3 direction) { //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_0006: 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_001f: 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_0040: Unknown result type (might be due to invalid IL or missing references) Vector3 val = CameraMath.Angles(direction); val.x = motion.Value.x + Mathf.DeltaAngle(motion.Value.x, val.x); motion.Constrain(val); } } internal interface ICameraWorld { bool Sweep(Vector3 from, Vector3 to, float radius, out float distance, out Vector3 normal); bool IsClear(Vector3 position, float radius); bool TryDepenetrate(Vector3 position, float radius, out Vector3 resolved); } internal sealed class CameraObstacles { internal const float Skin = 0.03f; private readonly ICameraWorld world; private readonly SpringMotion distance = new SpringMotion(); private bool initialized; private bool returning; internal CameraObstacles(ICameraWorld world) { this.world = world; } internal void Reset() { initialized = false; returning = false; } internal Vector3 Resolve(Vector3 anchor, Vector3 previous, Vector3 desired, float radius, float returnSeconds, float deltaTime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (!world.IsClear(previous, radius)) { if (!world.TryDepenetrate(previous, radius, out previous)) { return previous; } initialized = false; } Vector3 val = desired - anchor; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 desired2 = desired; if (magnitude > 0.01f && world.TryDepenetrate(anchor, radius, out var resolved)) { val = desired - resolved; magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = ((magnitude > 0.001f) ? (val / magnitude) : Vector3.zero); float num = magnitude; float num2; Vector3 normal; bool flag = world.Sweep(resolved, desired, radius, out num2, out normal); if (flag) { num = Mathf.Max(0f, num2 - 0.03f); } if (!initialized || (!returning && !flag)) { distance.Reset(new Vector3(num, 0f, 0f)); initialized = true; } distance.Step(new Vector3(num, 0f, 0f), returnSeconds, 0f, deltaTime); if (distance.Value.x > num) { distance.Constrain(new Vector3(num, 0f, 0f)); } returning = flag || (returning && distance.Value.x < magnitude - 0.01f); desired2 = resolved + val2 * Mathf.Max(0f, distance.Value.x); } return MoveSafely(world, previous, desired2, radius); } internal static Vector3 MoveSafely(ICameraWorld world, Vector3 from, Vector3 desired, float radius) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_009b: 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_00a4: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Vector3 val = from; Vector3 val2 = desired - val; for (int i = 0; i < 3; i++) { if (!(((Vector3)(ref val2)).sqrMagnitude > 1E-10f)) { break; } if (!world.Sweep(val, val + val2, radius, out var num, out var normal)) { val += val2; break; } Vector3 val3 = ((Vector3)(ref val2)).normalized * Mathf.Max(0f, num - 0.03f); val += val3; val2 -= val3; float num2 = Vector3.Dot(val2, normal); if (num2 >= -1E-05f) { break; } val2 -= normal * num2; } if (!world.IsClear(val, radius)) { return from; } return val; } } internal sealed class CameraPhysics : ICameraWorld { private readonly struct Owner { internal bool Character { get; } internal Item? Item { get; } internal Owner(bool character, Item? item) { Character = character; Item = item; } } internal static readonly CameraPhysics Shared = new CameraPhysics(); private readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[64]; private readonly Collider[] overlaps = (Collider[])(object)new Collider[64]; private readonly Dictionary<int, Owner> owners = new Dictionary<int, Owner>(); private SphereCollider? probe; public bool Sweep(Vector3 from, Vector3 to, float radius, out float distance, out Vector3 normal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Cast(from, to, radius, null, out distance, out normal); } private bool Cast(Vector3 from, Vector3 to, float radius, Component? target, out float distance, out Vector3 normal) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; distance = ((Vector3)(ref val)).magnitude; normal = Vector3.zero; if (distance < 0.0001f) { return false; } Vector3 val2 = val / distance; int num = ((radius > 0f) ? Physics.SphereCastNonAlloc(from, radius, val2, hits, distance, -5, (QueryTriggerInteraction)1) : Physics.RaycastNonAlloc(from, val2, hits, distance, -5, (QueryTriggerInteraction)1)); RaycastHit[] array = hits; if (num == hits.Length) { array = ((radius > 0f) ? Physics.SphereCastAll(from, radius, val2, distance, -5, (QueryTriggerInteraction)1) : Physics.RaycastAll(from, val2, distance, -5, (QueryTriggerInteraction)1)); num = array.Length; } bool result = false; for (int i = 0; i < num; i++) { if (!Ignore(((RaycastHit)(ref array[i])).collider, target) && !(((RaycastHit)(ref array[i])).distance > distance)) { distance = ((RaycastHit)(ref array[i])).distance; normal = ((RaycastHit)(ref array[i])).normal; result = true; } } return result; } internal bool HasLineOfSight(Vector3 origin, Vector3 target, Component? targetComponent = null) { //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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (IsClear(origin, 0.01f)) { return HasClearRay(origin, target, targetComponent); } return false; } internal bool HasClearRay(Vector3 origin, Vector3 target, Component? targetComponent = null) { //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) float distance; Vector3 normal; return !Cast(origin, target, 0f, targetComponent, out distance, out normal); } public bool IsClear(Vector3 position, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int count; Collider[] array = Overlaps(position, radius, out count); for (int i = 0; i < count; i++) { if (!Ignore(array[i], null)) { return false; } } return true; } public bool TryDepenetrate(Vector3 position, float radius, out Vector3 resolved) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0176: Unknown result type (might be due to invalid IL or missing references) resolved = position; if (IsClear(position, radius)) { return true; } if ((Object)(object)probe == (Object)null) { GameObject val = new GameObject("AutoCameraSpectator collision query") { hideFlags = (HideFlags)61 }; probe = val.AddComponent<SphereCollider>(); ((Collider)probe).enabled = false; Object.DontDestroyOnLoad((Object)(object)val); } probe.radius = radius; Vector3 val3 = default(Vector3); float num = default(float); for (int i = 0; i < 8; i++) { int count; Collider[] array = Overlaps(resolved, radius, out count); bool flag = false; for (int j = 0; j < count; j++) { Collider val2 = array[j]; if (!Ignore(val2, null) && Physics.ComputePenetration((Collider)(object)probe, resolved, Quaternion.identity, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num)) { resolved += val3 * (num + 0.03f); flag = true; } } if (IsClear(resolved, radius)) { return true; } if (!flag) { break; } } for (int k = 1; k <= 6; k++) { for (int l = 0; l < 6; l++) { Vector3 val4 = ((l < 2) ? Vector3.right : ((l < 4) ? Vector3.up : Vector3.forward)); if ((l & 1) != 0) { val4 = -val4; } Vector3 val5 = position + val4 * ((float)k * Mathf.Max(radius, 0.15f)); if (IsClear(val5, radius)) { resolved = val5; return true; } } } resolved = position; return false; } internal void Dispose() { if ((Object)(object)probe != (Object)null) { Object.Destroy((Object)(object)((Component)probe).gameObject); } probe = null; owners.Clear(); } private Collider[] Overlaps(Vector3 position, float radius, out int count) { //IL_0001: 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) count = Physics.OverlapSphereNonAlloc(position, radius, overlaps, -5, (QueryTriggerInteraction)1); if (count < overlaps.Length) { return overlaps; } Collider[] array = Physics.OverlapSphere(position, radius, -5, (QueryTriggerInteraction)1); count = array.Length; return array; } private bool Ignore(Collider? collider, Component? target) { if ((Object)(object)collider == (Object)null || (Object)(object)collider == (Object)(object)probe || collider.isTrigger) { return true; } if ((Object)(object)target != (Object)null && ((Object)(object)((Component)collider).transform == (Object)(object)target.transform || ((Component)collider).transform.IsChildOf(target.transform))) { return true; } int instanceID = ((Object)collider).GetInstanceID(); if (!owners.TryGetValue(instanceID, out var value)) { if (owners.Count > 8192) { owners.Clear(); } value = new Owner((Object)(object)((Component)collider).GetComponentInParent<Character>() != (Object)null, ((Component)collider).GetComponentInParent<Item>()); owners[instanceID] = value; } if (value.Character) { return true; } Item item = value.Item; if ((Object)(object)item == (Object)null) { return false; } foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter != (Object)null && (Object)(object)allCharacter.data != (Object)null && (Object)(object)allCharacter.data.currentItem == (Object)(object)item) { return true; } } return false; } } internal readonly struct EventCameraSettings { internal float PositionSeconds { get; } internal float RotationSeconds { get; } internal float MaxSpeed { get; } internal float Distance { get; } internal float MaxDistance { get; } internal float FrameAngle { get; } internal float MaxFov { get; } internal float Margin { get; } internal float Pitch { get; } internal float Height { get; } internal float Elevation { get; } internal float LensSeconds { get; } internal float ComfortWiden { get; } internal EventCameraSettings(float positionSeconds, float rotationSeconds, float maxSpeed, float distance, float maxDistance, float frameAngle, float maxFov, float margin, float pitch, float height, float elevation, float lensSeconds, float comfortWiden = 15f) { PositionSeconds = positionSeconds; RotationSeconds = rotationSeconds; MaxSpeed = maxSpeed; Distance = distance; MaxDistance = maxDistance; FrameAngle = frameAngle; MaxFov = maxFov; Margin = margin; Pitch = pitch; Height = height; Elevation = elevation; LensSeconds = lensSeconds; ComfortWiden = comfortWiden; } } internal sealed class CameraRig { internal const float AnchorMargin = 0.02f; internal const float AnchorCore = 0.35f; private const float OrbitSeconds = 1.6f; private const float OrbitMaxSpeed = 40f; private const float DollyMaxSpeed = 20f; private readonly SpringMotion position = new SpringMotion(); private readonly SpringMotion pivot = new SpringMotion(); private readonly AimMotion aim = new AimMotion(); private readonly SpringMotion lens = new SpringMotion(); private readonly SpringMotion orbit = new SpringMotion(); private readonly List<FramePoint> aimingPoints = new List<FramePoint>(8); private readonly FramePoint[] anchorOnly = new FramePoint[1]; private Vector3 hold; private float orbitYaw; private float orbitElevation; private bool hasPivot; private bool transitioningPosition; private bool transitioningAim; internal Vector3 Position => position.Value; internal Vector3 Velocity => position.Velocity; internal Vector3 Direction => aim.Direction; internal Vector3 AngularVelocity => aim.Velocity; internal float FieldOfView => lens.Value.x; internal float ShotYaw => orbit.Value.x; internal float ShotTargetYaw => orbitYaw; internal void Reset(Vector3 origin, Vector3 direction, float fieldOfView) { //IL_0006: 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_000f: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) position.Reset(origin); aim.Reset(direction); lens.Reset(new Vector3(fieldOfView, 0f, 0f)); transitioningPosition = (transitioningAim = (hasPivot = false)); } internal void TransitionToTarget() { transitioningPosition = (transitioningAim = true); } internal void EnterEvent(Vector3 anchor) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) float x = CameraMath.Angles(anchor - Position).x; orbit.Reset(new Vector3(x, 0f, 0f)); orbitYaw = x; orbitElevation = 0f; hasPivot = false; } internal void SetShotPreference(float yaw, float extraElevation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) orbitYaw = orbit.Value.x + Mathf.DeltaAngle(orbit.Value.x, yaw); orbitElevation = extraElevation; } internal Vector3 ShotDirection(float elevation) { //IL_0006: 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_0031: Unknown result type (might be due to invalid IL or missing references) return CameraMath.Direction(orbit.Value.x, Mathf.Clamp(elevation + orbit.Value.y, -30f, 75f)); } internal void AimPlayer(Vector3 desired, float seconds, float maxSpeed, bool instant, float deltaTime) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) if (transitioningAim && Vector3.Angle(Direction, desired) < 0.1f) { transitioningAim = false; } if (instant && !transitioningAim) { aim.Reset(desired); } else { aim.Step(desired, seconds, maxSpeed, deltaTime); } } internal void AimManual(Vector3 direction) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) aim.Reset(direction); } internal void AimAt(Vector3 point, float seconds, float maxSpeed, float deltaTime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) aim.Step(point - Position, seconds, maxSpeed, deltaTime); } internal void MovePlayer(Vector3 target, Vector3 offset, float distance, float seconds, bool instant, float deltaTime) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0053: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!hasPivot) { pivot.Reset(Position + Direction * distance - offset); hasPivot = true; } if (transitioningPosition && Vector3.Distance(pivot.Value, target) < 0.01f) { transitioningPosition = false; } if (instant && !transitioningPosition) { pivot.Reset(target); } else { pivot.Step(target, seconds, 0f, deltaTime); } position.Track(pivot.Value + offset - Direction * distance, deltaTime); } internal void BeginHold() { //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) hold = Position; } internal void HoldPosition(float deltaTime) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) position.Step(hold, 0.5f, 0f, deltaTime); hasPivot = false; } internal void ConstrainPosition(Vector3 actual) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) position.Constrain(actual); } internal void OverridePosition(Vector3 actual, Vector3 velocity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) position.Reset(actual, velocity); hasPivot = false; } internal void RestoreLens(float baseFov, float deltaTime) { //IL_0011: 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) lens.Step(new Vector3(baseFov, 0f, 0f), 0.4f, 0f, deltaTime); } internal void MoveEvent(IReadOnlyList<FramePoint> points, EventCameraSettings settings, float baseFov, float aspect, float deltaTime) { //IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_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_0109: Unknown result type (might be due to invalid IL or missing references) if (points.Count != 0) { orbit.Step(new Vector3(orbitYaw, orbitElevation, 0f), 1.6f, 40f, deltaTime); Vector3 val = points[0].Position; Vector3 val2 = ShotDirection(settings.Elevation); Vector3 val3 = val + Vector3.up * settings.Height; float num = Mathf.Clamp(settings.Distance, 1f, settings.MaxDistance); Vector3 val4 = val3 - val2 * num; float verticalFov = Mathf.Min(Mathf.Max(baseFov, settings.MaxFov), baseFov + Mathf.Max(0f, settings.ComfortWiden)); if (!FrameGeometry.TryVisibleCenter(points, val4, verticalFov, aspect, settings.Margin, out var center)) { float num2 = FrameGeometry.RequiredRetreat(points, val4, center, verticalFov, aspect, settings.Margin); val4 -= center * Mathf.Min(num2 + 0.01f, settings.MaxDistance - num); } position.Step(val4, settings.PositionSeconds, 20f, deltaTime); } } internal bool AimEvent(IReadOnlyList<FramePoint> points, EventCameraSettings settings, float baseFov, float aspect, float deltaTime) { //IL_00a0: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(baseFov, settings.MaxFov); if (points.Count == 0) { RestoreLens(baseFov, deltaTime); return true; } aimingPoints.Clear(); for (int i = 0; i < points.Count; i++) { aimingPoints.Add(points[i]); } Vector3 center; while (aimingPoints.Count > 1 && !FrameGeometry.TryVisibleCenter(aimingPoints, Position, num, aspect, 0.02f, out center)) { aimingPoints.RemoveAt(aimingPoints.Count - 1); } FrameGeometry.TryVisibleCenter(aimingPoints, Position, Mathf.Min(baseFov, settings.FrameAngle), aspect, settings.Margin, out var center2); Vector3 preferred = CameraMath.WithPitchOffset(center2, settings.Pitch); float verticalFov = Mathf.Clamp(FrameGeometry.RequiredFov(aimingPoints, Position, center2, aspect, settings.Margin), baseFov, num); if (!FrameGeometry.ConstrainDirection(aimingPoints, Position, preferred, verticalFov, aspect, settings.Margin, out var direction)) { direction = center2; } anchorOnly[0] = points[0]; if (FrameGeometry.ConstrainDirection(anchorOnly, Position, direction, FieldOfView, aspect, 0.04f, out var direction2)) { direction = direction2; } aim.Step(direction, settings.RotationSeconds, settings.MaxSpeed, deltaTime); float num2 = Mathf.Clamp(FrameGeometry.RequiredFov(aimingPoints, Position, direction, aspect, Mathf.Min(settings.Margin, 0.08f)), baseFov, num); lens.Step(new Vector3(num2, 0f, 0f), settings.LensSeconds, 0f, deltaTime); if (lens.Value.x > num) { lens.Constrain(new Vector3(num, 0f, 0f)); } KeepAnchorInFrame(points[0], aspect); return FrameGeometry.Contains(points, Position, Direction, FieldOfView, aspect, 0.019f); } internal void KeepAnchorInFrame(FramePoint anchor, float aspect) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) anchorOnly[0] = new FramePoint(anchor.Position, anchor.Radius * 0.35f); if (!FrameGeometry.Contains(anchorOnly, Position, Direction, FieldOfView, aspect, 0f) && FrameGeometry.ConstrainDirection(anchorOnly, Position, Direction, FieldOfView, aspect, 0f, out var direction)) { aim.Constrain(direction); } } } internal sealed class LookIntent { private Vector3 reference; private bool initialized; internal void Reset() { initialized = false; } internal Vector3 Update(Vector3 look, Vector3 velocity, bool climbing, float deadZoneDegrees) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0067: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or m