using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Thanks.I_am_Scoutmaster")] [assembly: AssemblyDescription("Control the PEAK Scoutmaster as the local player.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Thanks")] [assembly: AssemblyProduct("I'm Scoutmaster")] [assembly: AssemblyCopyright("Copyright 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0ee091f4-9b49-4593-a95d-af67533313c8")] [assembly: AssemblyFileVersion("0.7.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.7.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ImScoutmaster { public sealed class ControlledScoutmasterVisualSync : MonoBehaviour { private Character _character; private PhotonView _view; public void Initialize(Character character, PhotonView view) { _character = (((Object)(object)character != (Object)null) ? character : ((Component)this).GetComponent()); _view = (((Object)(object)view != (Object)null) ? view : ((Component)this).GetComponent()); } private void Awake() { Initialize(_character, _view); } private void Update() { if ((Object)(object)_character == (Object)null) { _character = ((Component)this).GetComponent(); } if ((Object)(object)_character != (Object)null) { Plugin.EnsureControlledScoutmasterRegistered(_character); } } private void OnDestroy() { Plugin.UnregisterControlledScoutmasterInstance(_character, _view); } } [BepInPlugin("com.github.Thanks.ImScoutmaster", "I'm Scoutmaster", "0.7.0")] public sealed class Plugin : BaseUnityPlugin { private enum ConfigKey { ToggleKey, StaminaRefill, ThrowForce, ThrowUpBias, ThrowFallSeconds, ThirdPersonHeightOffset, ThirdPersonDistance, SourceStashDistance, RestoreAtScoutmasterPosition, RestoreGroundOffset, HideHudWhileTransformed, VerboseLogs } private readonly struct RendererVisualState { public readonly bool Enabled; public readonly bool ForceRenderingOff; public RendererVisualState(bool enabled, bool forceRenderingOff) { Enabled = enabled; ForceRenderingOff = forceRenderingOff; } } private sealed class ActiveScoutmasterSession { private readonly struct BodypartPhysicsState { public readonly Rigidbody Rig; public readonly bool IsKinematic; public readonly bool DetectCollisions; public readonly bool UseGravity; public BodypartPhysicsState(Rigidbody rig) { Rig = rig; IsKinematic = (Object)(object)rig != (Object)null && rig.isKinematic; DetectCollisions = (Object)(object)rig != (Object)null && rig.detectCollisions; UseGravity = (Object)(object)rig != (Object)null && rig.useGravity; } } [CompilerGenerated] private sealed class d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ActiveScoutmasterSession <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ActiveScoutmasterSession activeScoutmasterSession = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; activeScoutmasterSession.PreconfigureScoutmasterForLocalControl(); activeScoutmasterSession._controller = activeScoutmasterSession._scoutmasterObject.GetComponent() ?? activeScoutmasterSession._scoutmasterObject.AddComponent(); activeScoutmasterSession._controller.Initialize(activeScoutmasterSession._sourceCharacter, activeScoutmasterSession._scoutmaster, activeScoutmasterSession._scoutmasterCharacter); RegisterControlledScoutmaster(activeScoutmasterSession._scoutmaster); Character.localCharacter = activeScoutmasterSession._scoutmasterCharacter; SetGameObjectActive(activeScoutmasterSession._scoutmasterObject, active: true); activeScoutmasterSession.AlignScoutmasterBodyToSource(); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; activeScoutmasterSession.AlignScoutmasterBodyToSource(); activeScoutmasterSession.PrepareScoutmaster(); SetCameraOverride(activeScoutmasterSession._scoutmasterCharacter); _viewScoutmasterObject = activeScoutmasterSession._scoutmasterObject; UpdateScoutmasterHudState(); RestoreRendererVisibility(activeScoutmasterSession._scoutmasterObject); activeScoutmasterSession._controller.ActivateDynamicRagdollControl(); activeScoutmasterSession.HideSourceCharacter(); Character.localCharacter = activeScoutmasterSession._scoutmasterCharacter; LogVerbose("Entered Scoutmaster form."); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly Character _sourceCharacter; private readonly GameObject _scoutmasterObject; private readonly Scoutmaster _scoutmaster; private readonly Character _scoutmasterCharacter; private readonly Vector3 _sourceStartPosition; private readonly Vector3 _sourceStashPosition; private readonly Quaternion _sourceStartRotation; private readonly bool _sourceWasActive; private readonly List _sourceBodypartPhysicsStates = new List(); private PlayerScoutmasterController _controller; private bool _sourcePhysicsSuspended; public bool IsActive { get { if ((Object)(object)_sourceCharacter != (Object)null && (Object)(object)_scoutmasterObject != (Object)null && (Object)(object)_scoutmaster != (Object)null) { return (Object)(object)_scoutmasterCharacter != (Object)null; } return false; } } public ActiveScoutmasterSession(Character sourceCharacter, GameObject scoutmasterObject, Scoutmaster scoutmaster, Character scoutmasterCharacter, bool sourceWasActive) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) _sourceCharacter = sourceCharacter; _scoutmasterObject = scoutmasterObject; _scoutmaster = scoutmaster; _scoutmasterCharacter = scoutmasterCharacter; _sourceStartPosition = sourceCharacter.Center; _sourceStashPosition = _sourceStartPosition + Vector3.down * Mathf.Max(SourceStashDistance.Value, 10f); _sourceStartRotation = ((Component)sourceCharacter).transform.rotation; _sourceWasActive = sourceWasActive; } [IteratorStateMachine(typeof(d__15))] public IEnumerator Enter() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this }; } private void PreconfigureScoutmasterForLocalControl() { _scoutmasterCharacter.isScoutmaster = true; _scoutmasterCharacter.isZombie = false; EnableScoutmasterPhysics(); } private void AlignScoutmasterBodyToSource() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00f4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sourceCharacter == (Object)null || (Object)(object)_scoutmasterCharacter == (Object)null || (Object)(object)_scoutmasterObject == (Object)null) { return; } try { SetCharacterPositionImmediate(_scoutmasterCharacter, _sourceCharacter.Center, _sourceStartRotation); AlignCharacterFeetToGround(_scoutmasterCharacter, _sourceCharacter); _scoutmasterCharacter.data.currentRagdollControll = 1f; _scoutmasterCharacter.data.fallSeconds = 0f; _scoutmasterCharacter.data.isGrounded = (Object)(object)_sourceCharacter.data != (Object)null && _sourceCharacter.data.isGrounded; _scoutmasterCharacter.data.groundPos = (((Object)(object)_sourceCharacter.data != (Object)null) ? _sourceCharacter.data.groundPos : _sourceCharacter.Center); EnableScoutmasterPhysics(); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to align controlled body: " + ex.Message)); } } } private void EnableScoutmasterPhysics() { if ((Object)(object)_scoutmasterCharacter == (Object)null || _scoutmasterCharacter.refs?.ragdoll?.partList == null) { return; } try { foreach (Bodypart part in _scoutmasterCharacter.refs.ragdoll.partList) { Rigidbody val = (((Object)(object)part != (Object)null) ? part.Rig : null); if (!((Object)(object)val == (Object)null)) { val.isKinematic = false; val.detectCollisions = true; val.useGravity = true; val.WakeUp(); } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to enable controlled physics: " + ex.Message)); } } } public void Tick() { if (!IsActive) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)"[I'm Scoutmaster] Session became inactive."); } Instance?.ExitScoutmasterForm(restorePlayer: true); } else { Character.localCharacter = _scoutmasterCharacter; KeepScoutmasterAwake(); KeepSourceOutOfPlay(); } } public void Exit(bool restorePlayer) { //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_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ResolveRestorePosition(); Quaternion val = ResolveRestoreRotation(); if ((Object)(object)_controller != (Object)null) { ((Behaviour)_controller).enabled = false; } RestoreRendererVisibility(_scoutmasterObject); ClearCameraOverride(); _viewScoutmasterObject = null; RestoreHudAfterScoutmaster(); if (restorePlayer && (Object)(object)_sourceCharacter != (Object)null) { CopyLookStateForRestore(_scoutmasterCharacter, _sourceCharacter, val); RestoreSourceCharacter(position, val); ForcePlayerCharacterLookup(_sourceCharacter); Character.localCharacter = _sourceCharacter; BeginCameraRestoreAssist(_sourceCharacter); } UnregisterStashedSourceCharacter(_sourceCharacter); UnregisterControlledScoutmaster(_scoutmaster); BeginPeakStatsCleanupGraceWindow(); CleanupPeakStatsUi(aggressive: true); DestroyScoutmasterObject(_scoutmasterObject); LogVerbose("Exited Scoutmaster form."); } private Vector3 ResolveRestorePosition() { //IL_0040: 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_0057: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_scoutmasterCharacter != (Object)null) { Vector3 center = _scoutmasterCharacter.Center; if (IsFiniteVector(center)) { return center; } Vector3 position = ((Component)_scoutmasterCharacter).transform.position; if (IsFiniteVector(position)) { return position; } } return ResolveSafeRestorePosition(_sourceStartPosition, _scoutmasterCharacter, _sourceCharacter, _sourceStartPosition); } private Quaternion ResolveRestoreRotation() { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)_scoutmasterCharacter == (Object)null) { return _sourceStartRotation; } Vector3 val = Vector3.ProjectOnPlane(((Component)_scoutmasterCharacter).transform.rotation * Vector3.forward, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f && (Object)(object)_scoutmasterCharacter.data != (Object)null) { val = _scoutmasterCharacter.data.lookDirection_Flat; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f && (Object)(object)_scoutmasterCharacter.data != (Object)null) { val = Vector3.ProjectOnPlane(_scoutmasterCharacter.data.lookDirection, Vector3.up); } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { return _sourceStartRotation; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } private static Vector3 GetRestoreAnchor(Character character) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_002a: 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_008e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return Vector3.zero; } Vector3 center = character.Center; if ((Object)(object)character.data != (Object)null && IsFiniteVector(character.data.groundPos)) { Vector3 groundPos = character.data.groundPos; Vector3 val = Vector3.ProjectOnPlane(groundPos - center, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude <= 64f && Mathf.Abs(groundPos.y - center.y) <= 12f) { return groundPos; } } if (IsFiniteVector(center)) { return center; } Vector3 head = character.Head; if (!IsFiniteVector(head)) { return ((Component)character).transform.position; } return head; } private static void AlignCharacterFeetToGround(Character controlledCharacter, Character sourceCharacter) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)controlledCharacter == (Object)null) && !((Object)(object)sourceCharacter == (Object)null) && TryGetCharacterGroundY(sourceCharacter, out var groundY) && TryGetCharacterGroundY(controlledCharacter, out var groundY2)) { float num = groundY - groundY2; if (!float.IsNaN(num) && !float.IsInfinity(num) && !(Mathf.Abs(num) > 3f) && !(Mathf.Abs(num) <= 0.001f)) { SetCharacterPositionImmediate(controlledCharacter, controlledCharacter.Center + Vector3.up * num, ((Component)controlledCharacter).transform.rotation); } } } private static bool TryGetCharacterGroundY(Character character, out float groundY) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) groundY = 0f; if ((Object)(object)character == (Object)null) { return false; } Vector3 center = character.Center; if ((Object)(object)character.data != (Object)null && IsFiniteVector(character.data.groundPos)) { Vector3 groundPos = character.data.groundPos; Vector3 val = Vector3.ProjectOnPlane(groundPos - center, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude <= 64f && Mathf.Abs(groundPos.y - center.y) <= 12f) { groundY = groundPos.y; return true; } } if (TryGetCharacterColliderBottomY(character, out groundY)) { return true; } if (IsFiniteVector(center)) { groundY = center.y; return true; } Vector3 position = ((Component)character).transform.position; if (!IsFiniteVector(position)) { return false; } groundY = position.y; return true; } private static bool TryGetCharacterColliderBottomY(Character character, out float bottomY) { //IL_00f0: 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_00f5: 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_010f: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ab: Unknown result type (might be due to invalid IL or missing references) bottomY = 0f; if (character?.refs?.ragdoll?.partList == null) { return false; } bool flag = false; foreach (Bodypart part in character.refs.ragdoll.partList) { if ((Object)(object)part == (Object)null) { continue; } Collider[] componentsInChildren = ((Component)part).GetComponentsInChildren(true); if (componentsInChildren != null) { Collider[] array = componentsInChildren; foreach (Collider val in array) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 min = ((Bounds)(ref bounds)).min; if (IsFiniteVector(min) && (!flag || min.y < bottomY)) { bottomY = min.y; flag = true; } } } } Vector3 val2 = (((Object)(object)part.Rig != (Object)null) ? part.Rig.position : ((Component)part).transform.position); if (IsFiniteVector(val2) && (!flag || val2.y < bottomY)) { bottomY = val2.y; flag = true; } } return flag; } private static Vector3 ResolveSafeRestorePosition(Vector3 requestedPosition, Character scoutmasterCharacter, Character sourceCharacter, Vector3 fallbackPosition) { //IL_001a: 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_0022: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(RestoreGroundOffset.Value, 0.2f, 5f); Vector3 val = (IsFiniteVector(requestedPosition) ? requestedPosition : fallbackPosition); if (!IsFiniteVector(val)) { val = (((Object)(object)sourceCharacter != (Object)null) ? ((Component)sourceCharacter).transform.position : Vector3.zero); } if (TryFindRestoreGround(val + Vector3.up * 5f, 30f, scoutmasterCharacter, sourceCharacter, out var groundHit) || TryFindRestoreGround(val + Vector3.up * 12f, 80f, scoutmasterCharacter, sourceCharacter, out groundHit) || TryFindRestoreGround(fallbackPosition + Vector3.up * 5f, 30f, scoutmasterCharacter, sourceCharacter, out groundHit)) { return ((RaycastHit)(ref groundHit)).point + Vector3.up * num; } return val + Vector3.up * num; } private static bool TryFindRestoreGround(Vector3 origin, float distance, Character scoutmasterCharacter, Character sourceCharacter, out RaycastHit groundHit) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) groundHit = default(RaycastHit); if (!IsFiniteVector(origin)) { return false; } RaycastHit[] array; try { array = Physics.RaycastAll(origin, Vector3.down, distance, -1, (QueryTriggerInteraction)1); } catch { return false; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !((RaycastHit)(ref val)).collider.isTrigger && !(Vector3.Dot(((RaycastHit)(ref val)).normal, Vector3.up) < 0.2f) && !IsRestoreIgnoredCollider(((RaycastHit)(ref val)).collider, scoutmasterCharacter, sourceCharacter)) { groundHit = val; return true; } } return false; } private static bool IsRestoreIgnoredCollider(Collider collider, Character scoutmasterCharacter, Character sourceCharacter) { if ((Object)(object)collider == (Object)null) { return true; } Transform transform = ((Component)collider).transform; if (!IsColliderOwnedBy(transform, scoutmasterCharacter)) { return IsColliderOwnedBy(transform, sourceCharacter); } return true; } private static bool IsColliderOwnedBy(Transform colliderTransform, Character character) { if ((Object)(object)colliderTransform == (Object)null || (Object)(object)character == (Object)null) { return false; } Transform transform = ((Component)character).transform; if (!((Object)(object)colliderTransform == (Object)(object)transform)) { return colliderTransform.IsChildOf(transform); } return true; } private static bool IsFiniteVector(Vector3 value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFiniteFloat(value.x) && IsFiniteFloat(value.y)) { return IsFiniteFloat(value.z); } return false; } private static bool IsFiniteFloat(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private void PrepareScoutmaster() { ClearScoutmasterAiState(_scoutmaster); _scoutmasterCharacter.isScoutmaster = true; _scoutmasterCharacter.isZombie = false; _scoutmasterCharacter.data.isScoutmaster = true; SetCharacterDeadWithoutReconnect(_scoutmasterCharacter, dead: false); _scoutmasterCharacter.data.zombified = false; _scoutmasterCharacter.data.passedOut = false; _scoutmasterCharacter.data.fullyPassedOut = false; _scoutmasterCharacter.data.fallSeconds = 0f; _scoutmasterCharacter.data.currentRagdollControll = 1f; _scoutmasterCharacter.data.currentStamina = Mathf.Max(_scoutmasterCharacter.data.currentStamina, GetControlledStaminaFill()); _scoutmasterCharacter.data.extraStamina = 0f; ClearAssistJumpState(_scoutmasterCharacter); } private void HideSourceCharacter() { //IL_009a: 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_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sourceCharacter == (Object)null) { return; } try { RegisterStashedSourceCharacter(_sourceCharacter); _sourceCharacter.data.fallSeconds = 0f; _sourceCharacter.data.passedOut = false; _sourceCharacter.data.fullyPassedOut = false; ClearAssistJumpState(_sourceCharacter); if (_sourceWasActive && !((Component)_sourceCharacter).gameObject.activeSelf) { ((Component)_sourceCharacter).gameObject.SetActive(true); } HideSourceRenderers(((Component)_sourceCharacter).gameObject); SendSourceCharacterOutOfPlay(_sourceStashPosition); SetCharacterPositionImmediate(_sourceCharacter, _sourceStashPosition, ((Component)_sourceCharacter).transform.rotation); SuspendSourcePhysics(); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to stash source character: " + ex.Message)); } } } private void RestoreSourceCharacter(Vector3 position, Quaternion rotation) { //IL_00fb: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0144: Unknown result type (might be due to invalid IL or missing references) try { if (_sourceWasActive && !((Component)_sourceCharacter).gameObject.activeSelf) { ((Component)_sourceCharacter).gameObject.SetActive(true); } SetCharacterDeadWithoutReconnect(_sourceCharacter, dead: false); _sourceCharacter.data.zombified = false; _sourceCharacter.isZombie = false; _sourceCharacter.data.passedOut = false; _sourceCharacter.data.fullyPassedOut = false; _sourceCharacter.data.fallSeconds = 0f; _sourceCharacter.data.deathTimer = 0f; _sourceCharacter.data.currentRagdollControll = 1f; _sourceCharacter.data.isGrounded = false; _sourceCharacter.data.sinceGrounded = 0f; _sourceCharacter.data.groundedFor = 0f; _sourceCharacter.data.groundPos = position; _sourceCharacter.data.avarageVelocity = Vector3.zero; _sourceCharacter.data.avarageLastFrameVelocity = Vector3.zero; ClearAssistJumpState(_sourceCharacter); SendSourceCharacterRestore(position); SetCharacterPositionImmediate(_sourceCharacter, position, rotation); RestoreSourcePhysics(); RestoreSourceRenderers(((Component)_sourceCharacter).gameObject); UnregisterStashedSourceCharacter(_sourceCharacter); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to restore source character: " + ex.Message)); } } } private void SendSourceCharacterOutOfPlay(Vector3 stashPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SendSourceCharacterStateRpc(stashPosition, "[I'm Scoutmaster] Failed to move source character out of play: "); } private void SendSourceCharacterRestore(Vector3 restorePosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SendSourceCharacterStateRpc(restorePosition, "[I'm Scoutmaster] Failed to restore source character over network: "); } private void SendSourceCharacterStateRpc(Vector3 position, string warningPrefix) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sourceCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)_sourceCharacter).photonView == (Object)null || (!PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode)) { return; } try { PhotonView photonView = ((MonoBehaviourPun)_sourceCharacter).photonView; photonView.RPC("RPCA_UnFall", (RpcTarget)1, Array.Empty()); photonView.RPC("RPCA_Revive", (RpcTarget)1, new object[1] { false }); photonView.RPC("WarpPlayerRPC", (RpcTarget)1, new object[2] { position, false }); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)(warningPrefix + ex.Message)); } } } private void SuspendSourcePhysics() { //IL_00ab: 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) if ((Object)(object)_sourceCharacter == (Object)null || _sourceCharacter.refs?.ragdoll?.partList == null) { return; } try { if (!_sourcePhysicsSuspended) { _sourceBodypartPhysicsStates.Clear(); } foreach (Bodypart part in _sourceCharacter.refs.ragdoll.partList) { Rigidbody val = (((Object)(object)part != (Object)null) ? part.Rig : null); if (!((Object)(object)val == (Object)null)) { if (!_sourcePhysicsSuspended) { _sourceBodypartPhysicsStates.Add(new BodypartPhysicsState(val)); } if (!val.isKinematic) { val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } val.detectCollisions = false; val.useGravity = false; val.isKinematic = true; } } _sourcePhysicsSuspended = true; } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to suspend source physics: " + ex.Message)); } } } private void RestoreSourcePhysics() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!_sourcePhysicsSuspended) { return; } try { foreach (BodypartPhysicsState sourceBodypartPhysicsState in _sourceBodypartPhysicsStates) { Rigidbody rig = sourceBodypartPhysicsState.Rig; if (!((Object)(object)rig == (Object)null)) { rig.isKinematic = sourceBodypartPhysicsState.IsKinematic; if (!rig.isKinematic) { rig.linearVelocity = Vector3.zero; rig.angularVelocity = Vector3.zero; } rig.detectCollisions = sourceBodypartPhysicsState.DetectCollisions; rig.useGravity = sourceBodypartPhysicsState.UseGravity; } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to restore source physics: " + ex.Message)); } } finally { _sourceBodypartPhysicsStates.Clear(); _sourcePhysicsSuspended = false; } } private static void SetCharacterPositionImmediate(Character character, Vector3 position, Quaternion rotation) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return; } try { Transform transform = ((Component)character).transform; Vector3 center = character.Center; Quaternion rotation2 = transform.rotation; Vector3 val = position - center; Quaternion val2 = rotation * Quaternion.Inverse(rotation2); transform.SetPositionAndRotation(transform.position + val, rotation); if (character.refs?.ragdoll?.partList == null) { return; } foreach (Bodypart part in character.refs.ragdoll.partList) { if ((Object)(object)part == (Object)null) { continue; } if ((Object)(object)part.Rig != (Object)null) { part.Rig.position = position + val2 * (part.Rig.position - center); part.Rig.rotation = val2 * part.Rig.rotation; if (!part.Rig.isKinematic) { part.Rig.linearVelocity = Vector3.zero; part.Rig.angularVelocity = Vector3.zero; } } else { ((Component)part).transform.SetPositionAndRotation(position + val2 * (((Component)part).transform.position - center), val2 * ((Component)part).transform.rotation); } } } catch { ((Component)character).transform.SetPositionAndRotation(position, rotation); } } private void KeepScoutmasterAwake() { if (!((Object)(object)_scoutmasterCharacter?.data == (Object)null)) { ClearScoutmasterAiState(_scoutmaster); SetCharacterDeadWithoutReconnect(_scoutmasterCharacter, dead: false); _scoutmasterCharacter.isScoutmaster = true; _scoutmasterCharacter.isZombie = false; _scoutmasterCharacter.data.isScoutmaster = true; _scoutmasterCharacter.data.zombified = false; if (!IsControlledScoutmasterIncapacitated(_scoutmasterCharacter)) { _scoutmasterCharacter.data.passedOut = false; _scoutmasterCharacter.data.fullyPassedOut = false; _scoutmasterCharacter.data.fallSeconds = 0f; _scoutmasterCharacter.data.currentRagdollControll = 1f; _scoutmasterCharacter.data.currentStamina = Mathf.Max(_scoutmasterCharacter.data.currentStamina, GetControlledStaminaFill()); _scoutmasterCharacter.data.extraStamina = 0f; ClearAssistJumpState(_scoutmasterCharacter); } } } private void KeepSourceOutOfPlay() { if (!((Object)(object)_sourceCharacter == (Object)null) && !((Object)(object)_sourceCharacter.data == (Object)null)) { if ((Object)(object)_sourceCharacter == (Object)(object)Character.localCharacter && (Object)(object)_scoutmasterCharacter != (Object)null) { Character.localCharacter = _scoutmasterCharacter; } SetCharacterDeadWithoutReconnect(_sourceCharacter, dead: false); _sourceCharacter.data.zombified = false; _sourceCharacter.data.passedOut = false; _sourceCharacter.data.fullyPassedOut = false; _sourceCharacter.data.fallSeconds = 0f; ClearAssistJumpState(_sourceCharacter); HideSourceRenderers(((Component)_sourceCharacter).gameObject); SuspendSourcePhysics(); } } } [CompilerGenerated] private sealed class d__198 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Character 5__2; private bool 5__3; private GameObject 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__198(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0057: 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_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) int num = <>1__state; Plugin plugin = <>4__this; Scoutmaster component; Character component2; switch (num) { default: return false; case 0: { <>1__state = -1; plugin._switching = true; 5__2 = Character.localCharacter; if (!CanTransform(5__2)) { plugin._switching = false; return false; } Vector3 center = 5__2.Center; Quaternion spawnRotation = GetSpawnRotation(5__2); 5__3 = ((Component)5__2).gameObject.activeSelf; 5__4 = CreateScoutmaster(center, spawnRotation); if ((Object)(object)5__4 == (Object)null) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)"[I'm Scoutmaster] Could not create Character_Scoutmaster prefab."); plugin._switching = false; return false; } component = 5__4.GetComponent(); component2 = 5__4.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { <>2__current = null; <>1__state = 1; return true; } goto IL_0112; } case 1: <>1__state = -1; component = 5__4.GetComponent(); component2 = 5__4.GetComponent(); goto IL_0112; case 2: { <>1__state = -1; plugin._switching = false; return false; } IL_0112: if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)"[I'm Scoutmaster] Created object is missing Scoutmaster or Character."); DestroyScoutmasterObject(5__4); plugin._switching = false; return false; } if (!CanTransform(5__2)) { DestroyScoutmasterObject(5__4); plugin._switching = false; return false; } plugin._session = new ActiveScoutmasterSession(5__2, 5__4, component, component2, 5__3); <>2__current = plugin._session.Enter(); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__371 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private Transform <>2__current; private int <>l__initialThreadId; private object menuInstance; public object <>3__menuInstance; private Type menuType; public Type <>3__menuType; Transform IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__371(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { object? obj2; Transform val2; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; object obj = menuInstance; Component val = (Component)((obj is Component) ? obj : null); if (val != null) { <>2__current = val.transform; <>1__state = 1; return true; } goto IL_004d; } case 1: <>1__state = -1; goto IL_004d; case 2: { <>1__state = -1; break; } IL_004d: obj2 = menuType?.GetProperty("Content", InstanceFlags)?.GetValue(menuInstance); val2 = (Transform)((obj2 is Transform) ? obj2 : null); if (val2 != null) { <>2__current = val2; <>1__state = 2; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__371 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__371(0); } d__.menuInstance = <>3__menuInstance; d__.menuType = <>3__menuType; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__370 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private Transform <>2__current; private int <>l__initialThreadId; private object menuInstance; public object <>3__menuInstance; private Type menuType; public Type <>3__menuType; private HashSet 5__2; private IEnumerator <>7__wrap2; Transform IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__370(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = new HashSet(); <>7__wrap2 = EnumerateCandidateTransforms(menuInstance, menuType).GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap2.MoveNext()) { Transform current = <>7__wrap2.Current; if ((Object)(object)current != (Object)null && 5__2.Add(((Object)current).GetInstanceID())) { <>2__current = current; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap2 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__370 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__370(0); } d__.menuInstance = <>3__menuInstance; d__.menuType = <>3__menuType; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [CompilerGenerated] private sealed class d__350 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private ConfigDefinition <>2__current; private int <>l__initialThreadId; private ConfigKey configKey; public ConfigKey <>3__configKey; private string 5__2; private string 5__3; private string 5__4; private string 5__5; ConfigDefinition IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__350(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = GetConfigKeyName(configKey); 5__3 = GetKeyName(configKey, isChineseLanguage: true); 5__4 = GetConfigSectionName(configKey); 5__5 = GetSectionName(configKey, isChineseLanguage: true); <>2__current = new ConfigDefinition(5__4, 5__2); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = new ConfigDefinition(5__4, 5__3); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = new ConfigDefinition(5__5, 5__2); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new ConfigDefinition(5__5, 5__3); <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__350 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__350(0); } d__.configKey = <>3__configKey; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } public const string Id = "com.github.Thanks.ImScoutmaster"; public const string Name = "I'm Scoutmaster"; public const string Version = "0.7.0"; private const string ScoutmasterResourceName = "Character_Scoutmaster"; private const float ToggleHoldSeconds = 1f; private const float ManualFallShortPressMaxSeconds = 0.3f; private const float ToggleDebounceSeconds = 0.35f; private const int SimplifiedChineseLanguageIndex = 9; private const string ControlsConfigSectionName = "Controls"; private const string ScoutmasterControlConfigSectionName = "Scoutmaster Control"; private const string CameraConfigSectionName = "Camera"; private const string PlayerRestoreConfigSectionName = "Player Restore"; private const string HudConfigSectionName = "HUD"; private const string DiagnosticsConfigSectionName = "Diagnostics"; private const string ModConfigPluginGuid = "com.github.PEAKModding.PEAKLib.ModConfig"; private const float ModConfigUiLocalizationIntervalSeconds = 0.25f; private const float CameraRestoreAssistSeconds = 0.4f; private const float ThirdPersonHeadTargetLiftMin = 0.35f; private const float ThirdPersonHeadTargetLiftMax = 1.35f; private const float ThirdPersonConfiguredTargetBlend = 0.25f; private const float ThirdPersonGroundMinHeight = 1.55f; private const float ThirdPersonCrouchGroundMinHeight = 1.15f; private const float ThirdPersonBodyFrameBlendStart = 0.45f; private const float ThirdPersonBodyFrameBlendFull = 0.95f; private const float ThirdPersonBodyFrameDownMaxBlend = 0.42f; private const float ThirdPersonBodyFrameUpMaxBlend = 0.3f; private const float ThirdPersonFocusForwardMin = 1.75f; private const float ThirdPersonFocusForwardMax = 4.25f; private const float ThirdPersonDownFocusDropMax = 1.15f; private const float ThirdPersonUpFocusLiftMax = 0.8f; private const float ThirdPartyCompatibilityRetryIntervalSeconds = 1f; private const float ClearBoostReticleTimer = 10f; private const float ControlledScoutmasterJumpVelocity = 10.5f; private const float ControlledScoutmasterJumpGroundClearance = 0.12f; private const float ControlledScoutmasterManualFallSeconds = 1.25f; private const float ControlledGrabAttachPointMaxHandDistance = 3.5f; private const string ControlledScoutmasterInstantiationMarker = "ImScoutmaster.ControlledScoutmaster"; private const int ControlledScoutmasterNetworkProtocol = 1; private static readonly BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly PropertyInfo ConfigFileEntriesProperty = typeof(ConfigFile).GetProperty("Entries", InstanceFlags); private static readonly FieldInfo CharacterViewField = typeof(Character).GetField("view", InstanceFlags); private static readonly FieldInfo CharacterStartedField = typeof(Character).GetField("started", InstanceFlags); private static readonly FieldInfo CharacterSmoothedCamPosField = typeof(Character).GetField("smoothedCamPos", InstanceFlags); private static readonly MethodInfo CharacterGetBodypartMethod = typeof(Character).GetMethod("GetBodypart", InstanceFlags); private static readonly MethodInfo CharacterGetPartTypeMethod = typeof(Character).GetMethod("GetPartType", InstanceFlags); private static readonly FieldInfo CharacterDataCharacterField = typeof(CharacterData).GetField("character", InstanceFlags); private static readonly FieldInfo CharacterDataDeadField = typeof(CharacterData).GetField("_dead", InstanceFlags); private static readonly FieldInfo CharacterDataGrabbedPlayerField = typeof(CharacterData).GetField("grabbedPlayer", InstanceFlags); private static readonly MethodInfo CharacterFallMethod = typeof(Character).GetMethod("Fall", InstanceFlags, null, new Type[2] { typeof(float), typeof(float) }, null); private static readonly FieldInfo CharacterCustomizationCharacterField = typeof(CharacterCustomization).GetField("_character", InstanceFlags); private static readonly FieldInfo BodypartCharacterField = typeof(Bodypart).GetField("character", InstanceFlags); private static readonly FieldInfo ScoutmasterCurrentTargetField = typeof(Scoutmaster).GetField("_currentTarget", InstanceFlags); private static readonly FieldInfo ScoutmasterTargetForcedUntilField = typeof(Scoutmaster).GetField("targetForcedUntil", InstanceFlags); private static readonly FieldInfo ScoutmasterChillForSecondsField = typeof(Scoutmaster).GetField("chillForSeconds", InstanceFlags); private static readonly FieldInfo ScoutmasterIsThrowingField = typeof(Scoutmaster).GetField("isThrowing", InstanceFlags); private static readonly PropertyInfo MainCameraSpecCharacterProperty = typeof(MainCameraMovement).GetProperty("specCharacter", StaticFlags); private static readonly FieldInfo MainCameraIsSpectatingField = typeof(MainCameraMovement).GetField("isSpectating", InstanceFlags); private static readonly FieldInfo MainCameraRagdollCamField = typeof(MainCameraMovement).GetField("ragdollCam", InstanceFlags); private static readonly FieldInfo MainCameraCurrentForwardOffsetField = typeof(MainCameraMovement).GetField("currentForwardOffset", InstanceFlags); private static readonly FieldInfo MainCameraTargetPlayerPovPositionField = typeof(MainCameraMovement).GetField("targetPlayerPovPosition", InstanceFlags); private static readonly FieldInfo MainCameraPhysicsRotField = typeof(MainCameraMovement).GetField("physicsRot", InstanceFlags); private static readonly MethodInfo FindObjectsOfTypeByTypeMethod = typeof(Object).GetMethod("FindObjectsOfType", new Type[1] { typeof(Type) }); private static readonly MethodInfo CharacterClimbingCanClimbMethod = typeof(CharacterClimbing).GetMethod("CanClimb", InstanceFlags, null, Type.EmptyTypes, null); private static readonly MethodInfo CharacterClimbingStartClimbRpcMethod = FindCharacterClimbingStartClimbRpcMethod(); private static readonly FieldInfo CharacterClimbingClimbToggledOnField = typeof(CharacterClimbing).GetField("climbToggledOn", InstanceFlags); private static readonly FieldInfo CharacterClimbingSinceLastClimbStartedField = typeof(CharacterClimbing).GetField("sinceLastClimbStarted", InstanceFlags); private static readonly FieldInfo CharacterClimbingPlayerSlideField = typeof(CharacterClimbing).GetField("playerSlide", InstanceFlags); private static readonly MethodInfo CharacterGrabbingGrabAttachMethod = typeof(CharacterGrabbing).GetMethod("RPCA_GrabAttach", InstanceFlags); private static readonly PropertyInfo PlayerHandlerInstanceProperty = typeof(PlayerHandler).GetProperty("Instance", StaticFlags); private static readonly FieldInfo PlayerHandlerCharacterLookupField = typeof(PlayerHandler).GetField("m_playerCharacterLookup", InstanceFlags); private static readonly FieldInfo CharacterItemsCurrentSelectedSlotField = typeof(CharacterItems).GetField("currentSelectedSlot", InstanceFlags); private static readonly FieldInfo CharacterItemsLastSelectedSlotField = typeof(CharacterItems).GetField("lastSelectedSlot", InstanceFlags); private static readonly FieldInfo CharacterAfflictionsCharacterField = typeof(CharacterAfflictions).GetField("character", InstanceFlags); private static readonly object CharacterItemsNoneSlotValue = CreateOptionableNoneValue(CharacterItemsCurrentSelectedSlotField?.FieldType); private static FieldInfo PeakStatsStaminaBarsField; private static FieldInfo PeakStatsObservedCharacterField; private static FieldInfo PeakStatsAfflictionBarField; private static Type PeakStatsStaminaBarType; private static Type PeakStatsAfflictionType; private static float _peakStatsCleanupGraceUntil; private static bool _skipControlledCharacterFixedUpdate; private bool _characterFixedUpdateCompatibilityConfigured; private bool _loggedWaitingForPeakerHook; private float _nextPeakerGuardAttemptTime; private bool _peakStatsCompatibilityConfigured; private float _nextThirdPartyCompatibilityAttemptTime; private readonly Harmony _harmony = new Harmony("com.github.Thanks.ImScoutmaster"); private ActiveScoutmasterSession _session; private bool _switching; private float _lastToggleTime; private float _toggleHoldStartTime = -1f; private bool _toggleHoldTriggered; private bool _lastDetectedChineseLanguage; private bool _isRefreshingLanguage; private bool _pendingConfigFileLocalizationRefresh; private bool _pendingConfigFileLocalizationSave; private float _nextModConfigUiLocalizationTime; private static Transform _controlledScoutmasterCreationRoot; private static readonly HashSet _controlledScoutmasterInstanceIds = new HashSet(); private static readonly HashSet _controlledScoutmasterViewIds = new HashSet(); private static readonly HashSet _controlledScoutmasterCharacterInstanceIds = new HashSet(); private static readonly Dictionary _controlledScoutmasterOwnerActorNumbersByViewId = new Dictionary(); private static readonly HashSet _stashedSourceCharacterIds = new HashSet(); private static readonly Dictionary _rendererVisualStates = new Dictionary(); private static readonly Dictionary _sourceRendererVisualStates = new Dictionary(); private static Character _cameraOverrideCharacter; private static Character _cameraRestoreCharacter; private static float _cameraRestoreUntil; private static GameObject _viewScoutmasterObject; private static bool _hasSmoothedThirdPersonCameraPose; private static Vector3 _smoothedThirdPersonCameraPosition; private static Quaternion _smoothedThirdPersonCameraRotation = Quaternion.identity; private static GameObject _hudCanvasObject; private static GameObject _namesCanvasObject; private static bool _hudPreviousKnown; private static bool _namesPreviousKnown; private static bool _hudPreviousActive; private static bool _namesPreviousActive; private static bool _hudHiddenForScoutmaster; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static ConfigEntry ToggleKey { get; private set; } internal static ConfigEntry StaminaRefill { get; private set; } internal static ConfigEntry ThrowForce { get; private set; } internal static ConfigEntry ThrowUpBias { get; private set; } internal static ConfigEntry ThrowFallSeconds { get; private set; } internal static ConfigEntry ThirdPersonHeightOffset { get; private set; } internal static ConfigEntry ThirdPersonDistance { get; private set; } internal static ConfigEntry SourceStashDistance { get; private set; } internal static ConfigEntry RestoreAtScoutmasterPosition { get; private set; } internal static ConfigEntry RestoreGroundOffset { get; private set; } internal static ConfigEntry HideHudWhileTransformed { get; private set; } internal static ConfigEntry VerboseLogs { get; private set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; _lastDetectedChineseLanguage = DetectChineseLanguage(); BindConfig(_lastDetectedChineseLanguage); RegisterConfigChangeHandlers(); MarkConfigFileLocalizationDirty(saveConfigFile: true); _harmony.PatchAll(typeof(ScoutmasterHarmonyPatches).Assembly); ConfigureCharacterFixedUpdateCompatibility(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[I'm Scoutmaster] Loaded version 0.7.0."); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[I'm Scoutmaster] Config language: " + BuildLanguageDetectionSummary(_lastDetectedChineseLanguage))); } private void OnDestroy() { try { ExitScoutmasterForm(restorePlayer: true); RestoreHudAfterScoutmaster(); UnregisterConfigChangeHandlers(); _harmony.UnpatchSelf(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Cleanup failed: " + ex.Message)); } finally { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } private void Update() { if (!_characterFixedUpdateCompatibilityConfigured && Time.unscaledTime >= _nextPeakerGuardAttemptTime) { _nextPeakerGuardAttemptTime = Time.unscaledTime + 0.5f; ConfigureCharacterFixedUpdateCompatibility(); } if (!_peakStatsCompatibilityConfigured && Time.unscaledTime >= _nextThirdPartyCompatibilityAttemptTime) { _nextThirdPartyCompatibilityAttemptTime = Time.unscaledTime + 1f; ConfigureThirdPartyCompatibility(); } HandleLanguageChangeIfNeeded(); HandlePendingConfigFileLocalizationRefresh(); TryLocalizeVisibleModConfigUiThrottled(); RefreshRestoredPlayerCamera(); ActiveScoutmasterSession session = _session; if (session != null && session.IsActive) { _session.Tick(); UpdateScoutmasterHudState(); } else { RestoreHudAfterScoutmaster(); } HandleToggleHold(); } private void ConfigureCharacterFixedUpdateCompatibility() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown if (_characterFixedUpdateCompatibilityConfigured) { return; } try { Type type = FindLoadedType("PEAKER.Testing"); if (type == null) { if (!_loggedWaitingForPeakerHook) { _loggedWaitingForPeakerHook = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[I'm Scoutmaster] Waiting for PEAKER ragdoll hook; controlled Scoutmaster Character.FixedUpdate remains enabled."); } return; } MethodInfo method = type.GetMethod("PostCharacterGetTargetRagdollControll", StaticFlags, null, new Type[2] { typeof(CharacterData), typeof(float).MakeByRefType() }, null); MethodInfo methodInfo = AccessTools.Method(typeof(Plugin), "PeakerRagdollControlPostfixPrefix", (Type[])null, (Type[])null); if (method == null || methodInfo == null) { _skipControlledCharacterFixedUpdate = false; _characterFixedUpdateCompatibilityConfigured = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)"[I'm Scoutmaster] Could not install PEAKER ragdoll guard; controlled Scoutmaster Character.FixedUpdate remains enabled."); } else { _harmony.Patch((MethodBase)method, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _skipControlledCharacterFixedUpdate = false; _characterFixedUpdateCompatibilityConfigured = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[I'm Scoutmaster] Installed PEAKER ragdoll guard; controlled Scoutmaster Character.FixedUpdate enabled."); } } catch (Exception ex) { _skipControlledCharacterFixedUpdate = false; ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Failed to install PEAKER ragdoll guard; will retry while keeping controlled Scoutmaster Character.FixedUpdate enabled: " + ex.Message)); } } private static Type FindLoadedType(string fullName) { if (string.IsNullOrEmpty(fullName)) { return null; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType(fullName, throwOnError: false); if (type != null) { return type; } } } catch { } return null; } private static MethodInfo FindMethod(Type type, string name, bool preferStatic, params Type[] parameterTypes) { if (type == null || string.IsNullOrEmpty(name)) { return null; } BindingFlags bindingAttr = BindingFlags.Public | BindingFlags.NonPublic | (preferStatic ? BindingFlags.Static : BindingFlags.Instance); try { MethodInfo method = type.GetMethod(name, bindingAttr, null, parameterTypes ?? Type.EmptyTypes, null); if (method != null) { return method; } } catch { } try { MethodInfo[] methods = type.GetMethods(bindingAttr); foreach (MethodInfo methodInfo in methods) { if (methodInfo == null || methodInfo.Name != name) { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); int num = ((parameterTypes != null) ? parameterTypes.Length : 0); if (parameters.Length != num) { continue; } bool flag = true; for (int j = 0; j < num; j++) { Type type2 = parameterTypes[j]; Type parameterType = parameters[j].ParameterType; if (!(type2 == null) && !(parameterType == type2) && !string.Equals(parameterType.FullName, type2.FullName, StringComparison.Ordinal)) { flag = false; break; } } if (flag) { return methodInfo; } } } catch { } return null; } private void ConfigureThirdPartyCompatibility() { //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown if (_peakStatsCompatibilityConfigured) { return; } try { Type type = FindLoadedType("PeakStats.MonoBehaviours.ProximityStaminaManager"); Type type2 = FindLoadedType("PeakStats.MonoBehaviours.CharacterStaminaBar"); Type type3 = FindLoadedType("PeakStats.MonoBehaviours.CharacterBarAffliction"); if (type == null || type2 == null || type3 == null) { LogVerbose("[I'm Scoutmaster] PeakStats types not found yet, will retry. ProximityManager=" + (type != null) + " StaminaBar=" + (type2 != null) + " BarAffliction=" + (type3 != null)); return; } MethodInfo methodInfo = FindMethod(type, "Update", preferStatic: false, Type.EmptyTypes); MethodInfo methodInfo2 = FindMethod(type, "CreateStaminaBar", true, typeof(Character)); MethodInfo methodInfo3 = FindMethod(type2, "Update", preferStatic: false, Type.EmptyTypes); MethodInfo methodInfo4 = FindMethod(type3, "FetchReferences", preferStatic: false, Type.EmptyTypes); FieldInfo field = type.GetField("staminaBars", InstanceFlags); FieldInfo field2 = type2.GetField("_observedCharacter", InstanceFlags); FieldInfo field3 = type3.GetField("characterStaminaBar", InstanceFlags); MethodInfo methodInfo5 = AccessTools.Method(typeof(Plugin), "PeakStatsProximityManagerUpdatePrefix", (Type[])null, (Type[])null); MethodInfo methodInfo6 = AccessTools.Method(typeof(Plugin), "PeakStatsCreateStaminaBarPrefix", (Type[])null, (Type[])null); MethodInfo methodInfo7 = AccessTools.Method(typeof(Plugin), "PeakStatsCharacterStaminaBarUpdatePrefix", (Type[])null, (Type[])null); MethodInfo methodInfo8 = AccessTools.Method(typeof(Plugin), "PeakStatsCharacterBarAfflictionFetchReferencesPrefix", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo3 == null || methodInfo4 == null || field == null || field2 == null || field3 == null || methodInfo5 == null || methodInfo7 == null || methodInfo8 == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] PeakStats types found but some members missing. Update=" + (methodInfo != null) + " CreateStaminaBar=" + (methodInfo2 != null) + " StaminaBarUpdate=" + (methodInfo3 != null) + " FetchReferences=" + (methodInfo4 != null) + " staminaBars=" + (field != null) + " _observedCharacter=" + (field2 != null) + " characterStaminaBar=" + (field3 != null))); } else { PeakStatsStaminaBarsField = field; PeakStatsObservedCharacterField = field2; PeakStatsAfflictionBarField = field3; PeakStatsStaminaBarType = type2; PeakStatsAfflictionType = type3; _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo5), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (methodInfo2 != null && methodInfo6 != null) { _harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } _harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo7), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _harmony.Patch((MethodBase)methodInfo4, new HarmonyMethod(methodInfo8), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); CleanupPeakStatsUi(); _peakStatsCompatibilityConfigured = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[I'm Scoutmaster] Installed PeakStats compatibility guard for controlled Scoutmaster."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Failed to install PeakStats compatibility guard: " + ex.Message)); } } private static bool PeakerRagdollControlPostfixPrefix([HarmonyArgument("__instance")] CharacterData data, [HarmonyArgument("__result")] ref float ragdollControl) { try { object? obj = CharacterDataCharacterField?.GetValue(data); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null && (Object)(object)data != (Object)null) { val = ((Component)data).GetComponent(); } if (IsStashedSourceCharacter(val) || (IsControlledScoutmasterCharacter(val) && !IsControlledScoutmasterIncapacitated(val))) { ragdollControl = 1f; return false; } } catch { } return true; } internal static void SetCharacterDeadWithoutReconnect(Character character, bool dead) { if ((Object)(object)character?.data == (Object)null) { return; } try { if (CharacterDataDeadField != null) { CharacterDataDeadField.SetValue(character.data, dead); return; } } catch { } try { if (character.data.dead != dead) { character.data.dead = dead; } } catch { } } internal static bool ShouldSkipReconnectDataUpdate(Character character) { if ((Object)(object)character == (Object)null) { return true; } if (IsControlledScoutmasterCharacter(character) || IsStashedSourceCharacter(character) || IsCharacterInControlledCreationRoot(character)) { return true; } try { if ((Object)(object)character.data == (Object)null || character.refs == null || (Object)(object)character.refs.afflictions == (Object)null || (Object)(object)character.refs.stats == (Object)null) { return true; } return (Object)(object)character.player == (Object)null; } catch { return true; } } internal static bool ShouldSuppressSlipperyJellyfishSend(Collider other) { if ((Object)(object)other == (Object)null) { return false; } try { Character val = default(Character); if (!CharacterRagdoll.TryGetCharacterFromCollider(other, ref val)) { return false; } if (IsStashedSourceCharacter(val) || IsCharacterInControlledCreationRoot(val)) { return true; } if ((Object)(object)val == (Object)(object)Character.localCharacter && ((Object)(object)val.refs?.view == (Object)null || val.refs.view.ViewID <= 0)) { return true; } } catch { } return false; } internal static bool ShouldSkipSlipperyJellyfishTrigger(int targetID) { if (targetID <= 0) { return true; } try { PhotonView val = PhotonView.Find(targetID); if ((Object)(object)val == (Object)null) { return true; } Character component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.data == (Object)null || component.refs == null || (Object)(object)component.refs.afflictions == (Object)null) { return true; } if (IsStashedSourceCharacter(component) || IsCharacterInControlledCreationRoot(component)) { return true; } Bodypart bodypart = GetBodypart(component, (BodypartType)16); int result; if (!((Object)(object)((bodypart != null) ? bodypart.Rig : null) == (Object)null)) { Bodypart bodypart2 = GetBodypart(component, (BodypartType)13); if (!((Object)(object)((bodypart2 != null) ? bodypart2.Rig : null) == (Object)null)) { Bodypart bodypart3 = GetBodypart(component, (BodypartType)0); if (!((Object)(object)((bodypart3 != null) ? bodypart3.Rig : null) == (Object)null)) { Bodypart bodypart4 = GetBodypart(component, (BodypartType)4); result = (((Object)(object)((bodypart4 != null) ? bodypart4.Rig : null) == (Object)null) ? 1 : 0); goto IL_00e1; } } } result = 1; goto IL_00e1; IL_00e1: return (byte)result != 0; } catch { return true; } } private void LateUpdate() { RefreshControlledScoutmasterVisuals(); ActiveScoutmasterSession session = _session; if (session != null && session.IsActive) { UpdateScoutmasterHudState(); } RefreshRestoredPlayerCamera(); } private void BindConfig(bool isChineseLanguage) { ToggleKey = BindEntry(ConfigKey.ToggleKey, (KeyCode)103, isChineseLanguage); StaminaRefill = BindEntry(ConfigKey.StaminaRefill, 1f, isChineseLanguage); ThrowForce = BindEntry(ConfigKey.ThrowForce, 1500f, isChineseLanguage); ThrowUpBias = BindEntry(ConfigKey.ThrowUpBias, 0.3f, isChineseLanguage); ThrowFallSeconds = BindEntry(ConfigKey.ThrowFallSeconds, 3f, isChineseLanguage); ThirdPersonHeightOffset = BindEntry(ConfigKey.ThirdPersonHeightOffset, 1.35f, isChineseLanguage); ThirdPersonDistance = BindEntry(ConfigKey.ThirdPersonDistance, 7.5f, isChineseLanguage); SourceStashDistance = BindEntry(ConfigKey.SourceStashDistance, 30f, isChineseLanguage); RestoreAtScoutmasterPosition = BindEntry(ConfigKey.RestoreAtScoutmasterPosition, defaultValue: true, isChineseLanguage); RestoreGroundOffset = BindEntry(ConfigKey.RestoreGroundOffset, 1.2f, isChineseLanguage); HideHudWhileTransformed = BindEntry(ConfigKey.HideHudWhileTransformed, defaultValue: true, isChineseLanguage); VerboseLogs = BindEntry(ConfigKey.VerboseLogs, defaultValue: false, isChineseLanguage); MigrateLocalizedConfigEntries(); ClampConfigValues(); } private ConfigEntry BindEntry(ConfigKey configKey, T defaultValue, bool isChineseLanguage) { return ((BaseUnityPlugin)this).Config.Bind(GetSectionName(configKey, isChineseLanguage), GetKeyName(configKey, isChineseLanguage), defaultValue, CreateConfigDescription(configKey, isChineseLanguage)); } private ConfigDescription CreateConfigDescription(ConfigKey configKey, bool isChineseLanguage) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown string localizedDescription = GetLocalizedDescription(configKey, isChineseLanguage); return (ConfigDescription)(configKey switch { ConfigKey.StaminaRefill => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 1f), Array.Empty()), ConfigKey.ThrowForce => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(100f, 5000f), Array.Empty()), ConfigKey.ThrowUpBias => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty()), ConfigKey.ThrowFallSeconds => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty()), ConfigKey.ThirdPersonHeightOffset => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(-2f, 6f), Array.Empty()), ConfigKey.ThirdPersonDistance => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(2f, 16f), Array.Empty()), ConfigKey.SourceStashDistance => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(10f, 200f), Array.Empty()), ConfigKey.RestoreGroundOffset => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 5f), Array.Empty()), _ => (object)new ConfigDescription(localizedDescription, (AcceptableValueBase)null, Array.Empty()), }); } internal static float GetControlledStaminaFill() { return Mathf.Clamp(StaminaRefill?.Value ?? 1f, 0.1f, 1f); } private void ToggleScoutmasterForm() { if (!_switching) { ActiveScoutmasterSession session = _session; if (session != null && session.IsActive) { ExitScoutmasterForm(restorePlayer: true); } else { ((MonoBehaviour)this).StartCoroutine(EnterScoutmasterFormRoutine()); } } } private void HandleToggleHold() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_00bc: Unknown result type (might be due to invalid IL or missing references) KeyCode value = ToggleKey.Value; if (Input.GetKeyDown(value)) { _toggleHoldStartTime = Time.unscaledTime; _toggleHoldTriggered = false; } if (Input.GetKeyUp(value)) { float num = ((_toggleHoldStartTime >= 0f) ? (Time.unscaledTime - _toggleHoldStartTime) : 0f); bool num2 = !_toggleHoldTriggered && num > 0f && num <= 0.3f; _toggleHoldStartTime = -1f; _toggleHoldTriggered = false; if (num2) { ActiveScoutmasterSession session = _session; if (session != null && session.IsActive && Time.unscaledTime - _lastToggleTime >= 0.35f) { _lastToggleTime = Time.unscaledTime; TriggerControlledScoutmasterManualFall(); } } } else if (!Input.GetKey(value)) { _toggleHoldStartTime = -1f; _toggleHoldTriggered = false; } else if (!_toggleHoldTriggered && !(_toggleHoldStartTime < 0f) && !(Time.unscaledTime - _toggleHoldStartTime < 1f) && !(Time.unscaledTime - _lastToggleTime < 0.35f)) { _toggleHoldTriggered = true; _lastToggleTime = Time.unscaledTime; ToggleScoutmasterForm(); } } private void TriggerControlledScoutmasterManualFall() { Character controlledScoutmasterCharacter = GetControlledScoutmasterCharacter(); if (!((Object)(object)controlledScoutmasterCharacter == (Object)null)) { TriggerControlledScoutmasterManualFall(controlledScoutmasterCharacter); } } [IteratorStateMachine(typeof(d__198))] private IEnumerator EnterScoutmasterFormRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__198(0) { <>4__this = this }; } private static bool CanTransform(Character sourceCharacter) { if ((Object)(object)sourceCharacter == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)"[I'm Scoutmaster] No local character found."); } return false; } if ((Object)(object)sourceCharacter.data == (Object)null || sourceCharacter.refs == null || (Object)(object)((MonoBehaviourPun)sourceCharacter).photonView == (Object)null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)"[I'm Scoutmaster] Local character is not ready yet."); } return false; } if (IsDeadForTransform(sourceCharacter)) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogWarning((object)"[I'm Scoutmaster] Cannot transform after the player has died."); } return false; } if (IsControlledScoutmasterCharacter(sourceCharacter)) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogWarning((object)"[I'm Scoutmaster] Already controlling Scoutmaster."); } return false; } return true; } private static bool IsDeadForTransform(Character character) { if ((Object)(object)character?.data == (Object)null) { return false; } try { if (character.data.dead) { return true; } } catch { } try { return character.data.fullyPassedOut && character.data.deathTimer >= 1f; } catch { return false; } } private static Quaternion GetSpawnRotation(Character sourceCharacter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 val = sourceCharacter.data.lookDirection_Flat; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)sourceCharacter).transform.forward; } val = Vector3.ProjectOnPlane(val, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } private static GameObject CreateScoutmaster(Vector3 position, Quaternion rotation) { //IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) GameObject val = TryCreateNetworkScoutmaster("Character_Scoutmaster", position, rotation); if ((Object)(object)val != (Object)null) { return val; } return TryCreateLocalScoutmaster("Character_Scoutmaster", position, rotation); } private static GameObject TryCreateNetworkScoutmaster(string resourceName, Vector3 position, Quaternion rotation) { //IL_001a: 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) if (string.IsNullOrWhiteSpace(resourceName) || (!PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode)) { return null; } try { return PhotonNetwork.Instantiate(resourceName, position, rotation, (byte)0, BuildControlledScoutmasterInstantiationData()); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Photon instantiate failed for " + resourceName + ": " + ex.Message)); } return null; } } private static object[] BuildControlledScoutmasterInstantiationData() { int num = 0; try { Player localPlayer = Player.localPlayer; if ((Object)(object)((localPlayer != null) ? ((MonoBehaviourPun)localPlayer).photonView : null) != (Object)null) { num = ((MonoBehaviourPun)Player.localPlayer).photonView.OwnerActorNr; } else if (PhotonNetwork.LocalPlayer != null) { num = PhotonNetwork.LocalPlayer.ActorNumber; } } catch { num = 0; } return new object[3] { "ImScoutmaster.ControlledScoutmaster", 1, num }; } private static GameObject TryCreateLocalScoutmaster(string resourceName, Vector3 position, Quaternion rotation) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = Resources.Load(resourceName); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = new GameObject("ImScoutmaster_LocalScoutmaster_Staging"); val2.SetActive(false); _controlledScoutmasterCreationRoot = val2.transform; try { GameObject obj = Object.Instantiate(val, position, rotation, val2.transform); obj.SetActive(false); obj.transform.SetParent((Transform)null, true); return obj; } finally { _controlledScoutmasterCreationRoot = null; Object.Destroy((Object)(object)val2); } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Local instantiate failed for " + resourceName + ": " + ex.Message)); } return null; } } internal void ExitScoutmasterForm(bool restorePlayer) { if (_session == null) { return; } _switching = true; try { _session.Exit(restorePlayer); } finally { _session = null; ClearCameraOverride(); _viewScoutmasterObject = null; RestoreHudAfterScoutmaster(); _switching = false; } } internal static bool ShouldUseIsolatedCharacterLifecycle(Character character) { if ((Object)(object)character != (Object)null && HasScoutmasterComponent(character)) { if (!IsCharacterInControlledCreationRoot(character)) { return IsControlledScoutmasterCharacter(character); } return true; } return false; } internal static bool ShouldSkipCharacterRegistration(Character character) { if ((Object)(object)character == (Object)null || !HasScoutmasterComponent(character)) { return false; } if (!IsCharacterInControlledCreationRoot(character) && !IsControlledScoutmasterCharacter(character)) { return false; } LogVerbose("Skipped PlayerHandler registration for controlled Scoutmaster."); return true; } internal static void RunIsolatedCharacterAwake(Character character) { if ((Object)(object)character == (Object)null) { return; } try { if (!character.isBot && Character.AllCharacters != null && !Character.AllCharacters.Contains(character)) { Character.AllCharacters.Add(character); } else if (character.isBot && Character.AllBotCharacters != null && !Character.AllBotCharacters.Contains(character)) { Character.AllBotCharacters.Add(character); } CharacterViewField?.SetValue(character, ((Component)character).GetComponent()); character.InitializeRefs(); CharacterInput input = character.input; if (input != null) { input.Init(); } LogVerbose("Initialized controlled Scoutmaster character without player registration."); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Isolated Character.Awake failed: " + ex.Message)); } } } internal static void RunIsolatedCharacterStart(Character character) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return; } try { object obj = CharacterStartedField?.GetValue(character); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) == 0) { CharacterStartedField?.SetValue(character, true); if (character.refs != null) { character.refs.hip = GetBodypart(character, (BodypartType)0); character.refs.head = GetBodypart(character, (BodypartType)4); } Transform val = ResolveHeadTransform(character); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.TransformPoint(Vector3.up) : character.Head); CharacterSmoothedCamPosField?.SetValue(character, val2); LogVerbose("Started controlled Scoutmaster character without Photon owner naming."); } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Isolated Character.Start failed: " + ex.Message)); } } } internal static void RunIsolatedCharacterDataAwake(CharacterData data, Character character) { if ((Object)(object)data == (Object)null) { return; } try { CharacterDataCharacterField?.SetValue(data, character); data.isScoutmaster = true; if (data.badgeStatus == null) { data.badgeStatus = Array.Empty(); } LogVerbose("Initialized controlled Scoutmaster CharacterData without badge RPC."); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Isolated CharacterData.Awake failed: " + ex.Message)); } } } internal static bool ShouldSkipControlledScoutmasterBadgeStatus(CharacterData data) { Character character = (((Object)(object)data != (Object)null) ? ((Component)data).GetComponent() : null); if (!IsControlledScoutmasterCharacter(character)) { return IsCharacterInControlledCreationRoot(character); } return true; } internal static bool ShouldSkipControlledScoutmasterCustomization(CharacterCustomization customization) { if ((Object)(object)customization == (Object)null) { return false; } object? obj = CharacterCustomizationCharacterField?.GetValue(customization); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null) { val = ((Component)customization).GetComponent(); } if (!IsControlledScoutmasterCharacter(val)) { return IsCharacterInControlledCreationRoot(val); } return true; } internal static bool ShouldSkipThirdPartyCharacterTracking(Character character) { if (!IsControlledScoutmasterCharacter(character)) { return IsStashedSourceCharacter(character); } return true; } private static bool IsInPeakStatsCleanupGraceWindow() { return Time.unscaledTime <= _peakStatsCleanupGraceUntil; } private static void BeginPeakStatsCleanupGraceWindow() { _peakStatsCleanupGraceUntil = Time.unscaledTime + 1.25f; } private static bool IsInvalidPeakStatsCharacter(Character character) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return true; } try { if ((Object)(object)((Component)character).gameObject == (Object)null || !((Component)character).gameObject.activeInHierarchy) { return true; } } catch { return true; } try { if ((Object)(object)character.data == (Object)null || character.refs == null) { return true; } } catch { return true; } try { if (!IsFiniteVector(character.Head)) { return true; } } catch { return true; } return false; } private static bool IsFiniteVector(Vector3 value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFiniteFloat(value.x) && IsFiniteFloat(value.y)) { return IsFiniteFloat(value.z); } return false; } private static bool IsFiniteFloat(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static bool ShouldSkipPeakStatsCharacter(Character character) { if (IsInPeakStatsCleanupGraceWindow()) { return true; } if (!ShouldSkipThirdPartyCharacterTracking(character)) { return IsInvalidPeakStatsCharacter(character); } return true; } private static bool PeakStatsProximityManagerUpdatePrefix(object __instance) { PrunePeakStatsControlledScoutmasterBars(__instance); return true; } private static bool PeakStatsCreateStaminaBarPrefix(Character observedCharacter) { return !ShouldSkipPeakStatsCharacter(observedCharacter); } private static bool PeakStatsCharacterStaminaBarUpdatePrefix(object __instance) { if (!ShouldSkipPeakStatsObject(__instance)) { return true; } DisablePeakStatsComponent(__instance); return false; } private static bool PeakStatsCharacterBarAfflictionFetchReferencesPrefix(object __instance) { if (!ShouldSkipPeakStatsAffliction(__instance)) { return true; } DisablePeakStatsComponent(__instance); return false; } private static bool ShouldSkipPeakStatsObject(object instance) { if (instance == null || PeakStatsObservedCharacterField == null) { return false; } try { object? value = PeakStatsObservedCharacterField.GetValue(instance); return ShouldSkipPeakStatsCharacter((Character)((value is Character) ? value : null)); } catch { return false; } } private static bool ShouldSkipPeakStatsAffliction(object instance) { if (instance == null || PeakStatsAfflictionBarField == null) { return false; } try { return ShouldSkipPeakStatsObject(PeakStatsAfflictionBarField.GetValue(instance)); } catch { return false; } } private static void DisablePeakStatsComponent(object instance) { try { Behaviour val = (Behaviour)((instance is Behaviour) ? instance : null); if (val != null) { if (val.enabled) { val.enabled = false; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject != (Object)null && gameObject.activeSelf) { gameObject.SetActive(false); } } } catch { } } private static void CleanupPeakStatsUi(bool aggressive = false) { CleanupPeakStatsObjects(PeakStatsStaminaBarType, aggressive ? new Func(ShouldCleanupPeakStatsObjectAggressive) : new Func(ShouldSkipPeakStatsObject)); CleanupPeakStatsObjects(PeakStatsAfflictionType, aggressive ? new Func(ShouldCleanupPeakStatsAfflictionAggressive) : new Func(ShouldSkipPeakStatsAffliction)); } private static bool ShouldCleanupPeakStatsObjectAggressive(object instance) { if (instance == null || PeakStatsObservedCharacterField == null) { return true; } try { object? value = PeakStatsObservedCharacterField.GetValue(instance); return ShouldSkipPeakStatsCharacter((Character)((value is Character) ? value : null)); } catch { return true; } } private static bool ShouldCleanupPeakStatsAfflictionAggressive(object instance) { if (instance == null || PeakStatsAfflictionBarField == null) { return true; } try { return ShouldCleanupPeakStatsObjectAggressive(PeakStatsAfflictionBarField.GetValue(instance)); } catch { return true; } } private static void CleanupPeakStatsObjects(Type componentType, Func shouldRemove) { if (componentType == null || shouldRemove == null) { return; } try { Object[] array = Resources.FindObjectsOfTypeAll(componentType); if (array == null || array.Length == 0) { return; } foreach (object obj in array) { if (obj == null || !shouldRemove(obj)) { continue; } DisablePeakStatsComponent(obj); Component val = (Component)((obj is Component) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { try { Object.Destroy((Object)(object)val.gameObject); } catch { } } } } catch { } } private static void PrunePeakStatsControlledScoutmasterBars(object managerInstance) { if (managerInstance == null || PeakStatsStaminaBarsField == null) { return; } try { if (!(PeakStatsStaminaBarsField.GetValue(managerInstance) is IDictionary dictionary) || dictionary.Count == 0) { return; } List list = null; foreach (DictionaryEntry item in dictionary) { object key = item.Key; Character val = (Character)((key is Character) ? key : null); if (val != null && ShouldSkipPeakStatsCharacter(val)) { if (list == null) { list = new List(); } list.Add(item.Key); DisablePeakStatsComponent(item.Value); } } if (list != null) { for (int i = 0; i < list.Count; i++) { dictionary.Remove(list[i]); } } } catch { } } internal static bool IsControlledScoutmaster(Scoutmaster scoutmaster) { if ((Object)(object)scoutmaster == (Object)null) { return false; } if (PlayerScoutmasterController.IsControlled(scoutmaster)) { return true; } Character component = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)_cameraOverrideCharacter) { return true; } if (_controlledScoutmasterInstanceIds.Contains(((Object)scoutmaster).GetInstanceID())) { return true; } PhotonView component2 = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component2 != (Object)null && TryRegisterControlledScoutmasterFromInstantiationData(scoutmaster, component2)) { return true; } if ((Object)(object)component2 != (Object)null && component2.ViewID > 0) { return _controlledScoutmasterViewIds.Contains(component2.ViewID); } return false; } internal static bool IsControlledScoutmasterCharacter(Character character) { if ((Object)(object)character == (Object)null) { return false; } if ((Object)(object)character == (Object)(object)_cameraOverrideCharacter || _controlledScoutmasterCharacterInstanceIds.Contains(((Object)character).GetInstanceID())) { return true; } try { return IsControlledScoutmaster(((Component)character).GetComponent()); } catch { return false; } } internal static bool IsLocallyControlledScoutmasterCharacter(Character character) { if ((Object)(object)character == (Object)null) { return false; } if ((Object)(object)character == (Object)(object)_cameraOverrideCharacter) { return true; } try { return PlayerScoutmasterController.IsControlled(((Component)character).GetComponent()); } catch { return false; } } internal static Character GetControlledScoutmasterCharacter() { if (!IsValidCharacter(_cameraOverrideCharacter, requireData: true, requireRefs: true) || !IsLocallyControlledScoutmasterCharacter(_cameraOverrideCharacter)) { return null; } return _cameraOverrideCharacter; } internal static bool TryGetControlledScoutmasterForPhotonPlayer(Player photonPlayer, out Character controlledScoutmaster) { controlledScoutmaster = null; Character controlledScoutmasterCharacter = GetControlledScoutmasterCharacter(); if ((Object)(object)controlledScoutmasterCharacter == (Object)null || photonPlayer == null || (Object)(object)Player.localPlayer == (Object)null || (Object)(object)((MonoBehaviourPun)Player.localPlayer).photonView == (Object)null) { return false; } Player owner = ((MonoBehaviourPun)Player.localPlayer).photonView.Owner; if (owner == null || owner.ActorNumber != photonPlayer.ActorNumber) { return false; } controlledScoutmaster = controlledScoutmasterCharacter; return true; } private static bool IsValidCharacter(Character character, bool requireData, bool requireRefs) { if ((Object)(object)character == (Object)null) { return false; } try { if ((Object)(object)((Component)character).gameObject == (Object)null) { return false; } } catch { return false; } if (requireData && (Object)(object)character.data == (Object)null) { return false; } if (requireRefs && character.refs == null) { return false; } return true; } internal static bool IsStashedSourceCharacter(Character character) { if ((Object)(object)character != (Object)null) { return _stashedSourceCharacterIds.Contains(((Object)character).GetInstanceID()); } return false; } internal static bool ShouldDisableInventoryForCharacter(Character character) { if (!IsLocallyControlledScoutmasterCharacter(character)) { return IsStashedSourceCharacter(character); } return true; } internal static void ResetDisabledInventoryState(CharacterItems items, Character character) { if ((Object)(object)character == (Object)null && (Object)(object)items != (Object)null) { character = ((Component)items).GetComponent(); } if ((Object)(object)items == (Object)null && (Object)(object)character != (Object)null) { items = character.refs?.items ?? ((Component)character).GetComponent(); } if ((Object)(object)items != (Object)null) { items.throwChargeLevel = 0f; items.isChargingThrow = false; } if (!IsLocallyControlledScoutmasterCharacter(character)) { return; } ClearSelectedInventorySlots(items); if ((Object)(object)character?.data == (Object)null) { return; } try { Item currentItem = character.data.currentItem; if ((Object)(object)currentItem != (Object)null) { currentItem.CancelUsePrimary(); currentItem.CancelUseSecondary(); } if ((Object)(object)items != (Object)null) { items.UnAttachEquippedItem(); } else { character.data.currentItem = null; } } catch { character.data.currentItem = null; } } internal static bool ShouldSkipCharacterMovementUpdate(Character character) { return IsStashedSourceCharacter(character); } internal static bool ShouldSkipCharacterFixedUpdate(Character character) { if (!IsStashedSourceCharacter(character)) { if (_skipControlledCharacterFixedUpdate) { return IsLocallyControlledScoutmasterCharacter(character); } return false; } return true; } internal static bool ShouldSkipCharacterNetworkInterpolation(Character character) { return IsStashedSourceCharacter(character); } internal static bool ShouldSkipCharacterAfflictionWeightUpdate(CharacterAfflictions afflictions, Character fieldCharacter) { Character val = fieldCharacter; if ((Object)(object)val == (Object)null && (Object)(object)afflictions != (Object)null) { try { object? obj = CharacterAfflictionsCharacterField?.GetValue(afflictions); val = (Character)((obj is Character) ? obj : null); } catch { val = ((Component)afflictions).GetComponent(); } } if ((Object)(object)val == (Object)null || (Object)(object)val.data == (Object)null) { return true; } if (IsControlledScoutmasterCharacter(val) || IsStashedSourceCharacter(val) || IsCharacterInControlledCreationRoot(val)) { return true; } try { Player player = val.player; return (Object)(object)player == (Object)null || player.itemSlots == null || player.backpackSlot == null; } catch { return true; } } internal static bool ShouldSuppressControlledCharacterFall(Character character) { if (!IsStashedSourceCharacter(character)) { return false; } if ((Object)(object)character?.data != (Object)null) { character.data.fallSeconds = 0f; character.data.passedOut = false; character.data.fullyPassedOut = false; character.data.currentRagdollControll = 1f; } return true; } internal static bool IsControlledScoutmasterIncapacitated(Character character) { if (!IsControlledScoutmasterCharacter(character) || (Object)(object)character?.data == (Object)null) { return false; } try { return character.data.passedOut || character.data.fullyPassedOut || character.data.fallSeconds > 0.05f || character.data.currentRagdollControll < 0.95f; } catch { return false; } } internal static bool TryHandleControlledScoutmasterJump(Character character) { if (!IsLocallyControlledScoutmasterCharacter(character) || IsControlledScoutmasterIncapacitated(character)) { return false; } ApplyControlledScoutmasterLocalJump(character); return true; } internal static bool ShouldSuppressControlledScoutmasterJumpRpc(Character character) { return IsLocallyControlledScoutmasterCharacter(character); } internal static void TriggerControlledScoutmasterManualFall(Character character) { if (!IsLocallyControlledScoutmasterCharacter(character) || (Object)(object)character?.data == (Object)null || IsControlledScoutmasterIncapacitated(character)) { return; } try { object? obj = CharacterDataGrabbedPlayerField?.GetValue(character.data); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)character.data.grabJoint != (Object)null || (Object)(object)val != (Object)null || character.data.isReaching) { BroadcastControlledScoutmasterGrabUnattach(character); BroadcastControlledScoutmasterStopReaching(character); } } catch { } try { StopControlledScoutmasterClimb(character.refs?.climbing, character, 1.25f); } catch { } try { character.data.isReaching = false; character.data.isSprinting = false; if (CharacterFallMethod != null) { CharacterFallMethod.Invoke(character, new object[2] { 1.25f, 0f }); } else if ((Object)(object)character.refs?.view != (Object)null) { character.refs.view.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { 1.25f }); } ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[I'm Scoutmaster] Controlled Scoutmaster entered manual fall."); } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)("[I'm Scoutmaster] Manual fall failed: " + ex.Message)); } } } internal static bool TryHandleControlledScoutmasterStopClimb(CharacterClimbing climbing, Character character, float setFall) { if ((Object)(object)climbing == (Object)null || !IsLocallyControlledScoutmasterCharacter(character) || IsControlledScoutmasterIncapacitated(character)) { return false; } StopControlledScoutmasterClimb(climbing, character, setFall); return true; } internal static void StopControlledScoutmasterClimb(CharacterClimbing climbing, Character character, float setFall) { //IL_0077: 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_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character?.data == (Object)null) { return; } character.data.isClimbing = false; character.data.isRopeClimbing = false; character.data.isVineClimbing = false; character.data.isJumping = false; character.data.sinceGrounded = setFall; character.data.sincePressClimb = 1f; character.data.sinceCanClimb = 0f; character.data.climbNormal = Vector3.zero; if ((Object)(object)character.input != (Object)null) { character.input.usePrimaryIsPressed = false; character.input.usePrimaryWasPressed = false; character.input.usePrimaryWasReleased = true; } try { CharacterClimbingPlayerSlideField?.SetValue(climbing, Vector2.zero); CharacterClimbingClimbToggledOnField?.SetValue(climbing, false); } catch { } } private static void ApplyControlledScoutmasterLocalJump(Character character) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return; } try { if (!character.data.isGrounded && character.data.sinceGrounded > 0.25f && !character.data.isClimbing && !character.data.isRopeClimbing && !character.data.isVineClimbing) { return; } if (character.data.isGrounded || character.data.sinceGrounded <= 0.1f) { NudgeControlledScoutmasterForJump(character); } if (character.refs?.ragdoll?.partList != null) { foreach (Bodypart part in character.refs.ragdoll.partList) { Rigidbody val = (((Object)(object)part != (Object)null) ? part.Rig : null); if (!((Object)(object)val == (Object)null) && !val.isKinematic) { Vector3 linearVelocity = val.linearVelocity; if (linearVelocity.y < 10.5f) { val.linearVelocity = new Vector3(linearVelocity.x, 10.5f, linearVelocity.z); } val.WakeUp(); } } } character.data.sinceJump = 0f; character.data.isJumping = true; character.data.isGrounded = false; character.data.sinceGrounded = 0.25f; character.data.groundedFor = 0f; if ((Object)(object)character.input != (Object)null) { character.input.jumpWasPressed = false; } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Local jump failed: " + ex.Message)); } } } private static void NudgeControlledScoutmasterForJump(Character character) { //IL_000a: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return; } Vector3 val = Vector3.up * 0.12f; try { Transform transform = ((Component)character).transform; transform.position += val; if (character.refs?.ragdoll?.partList == null) { return; } foreach (Bodypart part in character.refs.ragdoll.partList) { if (!((Object)(object)part == (Object)null)) { Rigidbody rig = part.Rig; if ((Object)(object)rig != (Object)null) { rig.position += val; rig.WakeUp(); } else { Transform transform2 = ((Component)part).transform; transform2.position += val; } } } } catch { } } internal static bool TryHandleControlledScoutmasterStartWallClimb(CharacterClimbing climbing, Character character, bool forceAttempt, Vector3 overrideDirection, bool botGrab, float raycastDistance) { //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_006e: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!IsLocallyControlledScoutmasterCharacter(character) || IsControlledScoutmasterIncapacitated(character)) { return false; } if ((Object)(object)climbing == (Object)null || (Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return true; } if (character.data.isClimbing || character.data.isRopeClimbing || character.data.isVineClimbing) { return true; } if (!CanControlledScoutmasterClimb(climbing)) { return true; } Vector3 center = character.Center; Vector3 direction = overrideDirection; if (!forceAttempt || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = character.data.lookDirection; } if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = character.data.lookDirection_Flat; } if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f && (Object)(object)Camera.main != (Object)null) { direction = ((Component)Camera.main).transform.forward; } if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = ((Component)character).transform.forward; } ((Vector3)(ref direction)).Normalize(); float distance = Mathf.Clamp((raycastDistance > 0f) ? raycastDistance : 1.65f, 0.75f, 3f); if (!TryFindControlledScoutmasterClimbHit(character, center, direction, distance, out var climbHit)) { return true; } TryStartControlledScoutmasterClimb(climbing, character, ((RaycastHit)(ref climbHit)).point, ((RaycastHit)(ref climbHit)).normal, "Controlled Scoutmaster climb"); return true; } internal static bool CanControlledScoutmasterClimb(CharacterClimbing climbing) { if ((Object)(object)climbing == (Object)null) { return false; } try { if (CharacterClimbingCanClimbMethod != null) { object obj = CharacterClimbingCanClimbMethod.Invoke(climbing, null); if (obj is bool) { return (bool)obj; } } } catch { } return true; } internal static bool TryStartControlledScoutmasterClimb(CharacterClimbing climbing, Character character, Vector3 climbPos, Vector3 climbNormal, string context) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)climbing == (Object)null) { return false; } if (CharacterClimbingStartClimbRpcMethod == null) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] " + context + " start failed: StartClimbRpc method not found.")); } return false; } try { object[] array = BuildStartClimbRpcArguments(CharacterClimbingStartClimbRpcMethod, climbPos, climbNormal); if (array == null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)("[I'm Scoutmaster] " + context + " start failed: unsupported StartClimbRpc signature.")); } return false; } CharacterClimbingStartClimbRpcMethod.Invoke(climbing, array); CharacterClimbingClimbToggledOnField?.SetValue(climbing, false); CharacterClimbingSinceLastClimbStartedField?.SetValue(climbing, 0f); if ((Object)(object)character?.data != (Object)null) { character.data.sincePressClimb = 0f; character.data.sinceCanClimb = 0f; } return true; } catch (TargetInvocationException ex) { ManualLogSource log3 = Log; if (log3 != null) { log3.LogWarning((object)("[I'm Scoutmaster] " + context + " start failed: " + (ex.InnerException?.Message ?? ex.Message))); } return false; } catch (Exception ex2) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogWarning((object)("[I'm Scoutmaster] " + context + " start failed: " + ex2.Message)); } return false; } } private static MethodInfo FindCharacterClimbingStartClimbRpcMethod() { MethodInfo methodInfo = null; MethodInfo[] methods = typeof(CharacterClimbing).GetMethods(InstanceFlags); foreach (MethodInfo methodInfo2 in methods) { if (methodInfo2.Name != "StartClimbRpc") { continue; } ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length >= 2 && !(parameters[0].ParameterType != typeof(Vector3)) && !(parameters[1].ParameterType != typeof(Vector3))) { if (parameters.Length == 2) { return methodInfo2; } if ((object)methodInfo == null) { methodInfo = methodInfo2; } } } return methodInfo; } private static object[] BuildStartClimbRpcArguments(MethodInfo method, Vector3 climbPos, Vector3 climbNormal) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length < 2) { return null; } if (parameters[0].ParameterType != typeof(Vector3) || parameters[1].ParameterType != typeof(Vector3)) { return null; } object[] array = new object[parameters.Length]; array[0] = climbPos; array[1] = climbNormal; for (int i = 2; i < parameters.Length; i++) { Type parameterType = parameters[i].ParameterType; array[i] = (parameterType.IsValueType ? Activator.CreateInstance(parameterType) : null); } return array; } internal static bool TryFindControlledScoutmasterClimbHit(Character character, Vector3 origin, Vector3 direction, float distance, out RaycastHit climbHit) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) climbHit = default(RaycastHit); RaycastHit[] array; try { array = Physics.RaycastAll(origin, direction, distance, -1, (QueryTriggerInteraction)1); } catch { return false; } if (array == null || array.Length == 0) { return false; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !((RaycastHit)(ref val)).collider.isTrigger && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() == (Object)(object)character) && !(Vector3.Dot(((RaycastHit)(ref val)).normal, Vector3.up) > 0.75f)) { climbHit = val; return true; } } return false; } private static Character GetGrabbedPlayer(Character character) { if ((Object)(object)character?.data == (Object)null || CharacterDataGrabbedPlayerField == null) { return null; } try { object? value = CharacterDataGrabbedPlayerField.GetValue(character.data); return (Character)((value is Character) ? value : null); } catch { return null; } } internal static bool TryHandleControlledScoutmasterGrabbingUpdate(CharacterGrabbing grabbing, Character character) { if (!IsLocallyControlledScoutmasterCharacter(character)) { return false; } if (!((Object)(object)grabbing == (Object)null)) { _ = (Object)(object)character?.data == (Object)null; } return true; } internal static bool TryHandleControlledScoutmasterGrabAction(CharacterGrabbing grabbing, Character character, Collision collision) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Invalid comparison between Unknown and I4 //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected I4, but got Unknown //IL_013e: 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_016f: Expected I4, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) if (!IsLocallyControlledScoutmasterCharacter(character) || IsControlledScoutmasterIncapacitated(character)) { return false; } if ((Object)(object)grabbing == (Object)null || (Object)(object)character?.data == (Object)null || collision == null) { return true; } if ((Object)(object)character.data.grabJoint != (Object)null || !character.data.isReaching || character.data.sinceLetGoOfFriend < 0.35f) { return true; } if ((Object)(object)collision.rigidbody == (Object)null || (Object)(object)collision.collider == (Object)null) { return true; } Character val = default(Character); if (!CharacterRagdoll.TryGetCharacterFromCollider(collision.collider, ref val) || (Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)character) { return true; } BodypartType partType = GetPartType(val, collision.rigidbody); if ((int)partType < 0) { return true; } try { Bodypart bodypart = GetBodypart(character, (BodypartType)10); Rigidbody val2 = ((bodypart != null) ? bodypart.Rig : null); if ((Object)(object)val2 == (Object)null || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null) { return true; } Vector3 val3 = ((Component)collision.rigidbody).transform.InverseTransformPoint(((Component)val2).transform.position); SendControlledScoutmasterGrabbingRpc(character, "RPCA_StartReaching"); if (!SendControlledScoutmasterGrabbingRpc(character, "RPCA_GrabAttach", ((MonoBehaviourPun)val).photonView, (int)partType, val3)) { CharacterGrabbingGrabAttachMethod?.Invoke(grabbing, new object[3] { ((MonoBehaviourPun)val).photonView, (int)partType, val3 }); } LogVerbose("Controlled Scoutmaster grabbed " + val.characterName + "."); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Grab attach failed: " + ex.Message)); } } return true; } internal static bool TryGrabControlledScoutmasterTarget(CharacterGrabbing grabbing, Character character, Character sourceCharacter, Vector3 origin, Vector3 direction, float distance, float radius) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)grabbing == (Object)null || (Object)(object)character?.data == (Object)null || (Object)(object)character.data.grabJoint != (Object)null || !character.data.isReaching) { return false; } if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { return false; } RaycastHit[] array; try { array = Physics.SphereCastAll(origin, Mathf.Max(radius, 0.1f), ((Vector3)(ref direction)).normalized, Mathf.Max(distance, 0.25f), -1, (QueryTriggerInteraction)1); } catch { return false; } if (array == null || array.Length == 0) { return false; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; foreach (RaycastHit hit in array2) { if (TryAttachControlledScoutmasterGrab(grabbing, character, sourceCharacter, hit)) { return true; } } return false; } private static bool TryAttachControlledScoutmasterGrab(CharacterGrabbing grabbing, Character character, Character sourceCharacter, RaycastHit hit) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010e: Expected I4, but got Unknown //IL_0111: 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_0143: Expected I4, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null || ((RaycastHit)(ref hit)).collider.isTrigger) { return false; } Character val = ResolveGrabTargetCharacter(((RaycastHit)(ref hit)).collider); if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)character || (Object)(object)val == (Object)(object)sourceCharacter || IsControlledScoutmasterCharacter(val)) { return false; } Rigidbody val2 = (((Object)(object)((RaycastHit)(ref hit)).rigidbody != (Object)null) ? ((RaycastHit)(ref hit)).rigidbody : ((RaycastHit)(ref hit)).collider.attachedRigidbody); if ((Object)(object)val2 == (Object)null) { Bodypart componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); val2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.Rig : null); } if ((Object)(object)val2 == (Object)null) { return false; } BodypartType partType = GetPartType(val, val2); if ((int)partType < 0 || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null) { return false; } try { SendControlledScoutmasterGrabbingRpc(character, "RPCA_StartReaching"); Vector3 val3 = ResolveControlledGrabAttachPoint(character, val2, hit); Vector3 val4 = ((Component)val2).transform.InverseTransformPoint(val3); if (!SendControlledScoutmasterGrabbingRpc(character, "RPCA_GrabAttach", ((MonoBehaviourPun)val).photonView, (int)partType, val4)) { CharacterGrabbingGrabAttachMethod?.Invoke(grabbing, new object[3] { ((MonoBehaviourPun)val).photonView, (int)partType, val4 }); } ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[I'm Scoutmaster] Controlled Scoutmaster grabbed " + val.characterName + ".")); } return true; } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)("[I'm Scoutmaster] Direct grab failed: " + ex.Message)); } return false; } } private static Vector3 ResolveControlledGrabAttachPoint(Character character, Rigidbody targetRig, RaycastHit hit) { //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_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_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_0090: 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_007a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) Vector3 val = ResolveControlledGrabHandPosition(character); Vector3 val2 = Vector3.zero; bool flag = false; if ((Object)(object)((RaycastHit)(ref hit)).collider != (Object)null && IsFiniteVector(val)) { try { Vector3 val3 = ((RaycastHit)(ref hit)).collider.ClosestPoint(val); if (IsFiniteVector(val3) && Vector3.Distance(val3, val) <= 3.5f) { val2 = val3; flag = true; } } catch { } } if (!flag && IsFiniteVector(((RaycastHit)(ref hit)).point)) { val2 = ((RaycastHit)(ref hit)).point; flag = true; } if (!flag && IsFiniteVector(val)) { val2 = val; flag = true; } if (!flag && (Object)(object)targetRig != (Object)null) { val2 = targetRig.worldCenterOfMass; } if (!IsFiniteVector(val2)) { return Vector3.zero; } return val2; } internal static Vector3 ResolveControlledGrabHandPosition(Character character) { //IL_0024: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_006a: Unknown result type (might be due to invalid IL or missing references) Bodypart bodypart = GetBodypart(character, (BodypartType)10); Rigidbody val = ((bodypart != null) ? bodypart.Rig : null); if ((Object)(object)val != (Object)null && IsFiniteVector(((Component)val).transform.position)) { return ((Component)val).transform.position; } if ((Object)(object)character?.data != (Object)null) { Vector3 val2 = character.Center + ResolveThirdPersonLookDirection(character); if (IsFiniteVector(val2)) { return val2; } } if (!((Object)(object)character != (Object)null)) { return Vector3.zero; } return ((Component)character).transform.position; } private static bool SendControlledScoutmasterGrabbingRpc(Character character, string methodName, params object[] args) { PhotonView val = character?.refs?.view ?? ((character != null) ? ((MonoBehaviourPun)character).photonView : null); if ((Object)(object)val == (Object)null || string.IsNullOrEmpty(methodName)) { return false; } try { val.RPC(methodName, (RpcTarget)0, args ?? Array.Empty()); return true; } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Grab RPC " + methodName + " failed: " + ex.Message)); } return false; } } internal static void BroadcastControlledScoutmasterGrabUnattach(Character character) { SendControlledScoutmasterGrabbingRpc(character, "RPCA_GrabUnattach"); } internal static void BroadcastControlledScoutmasterStopReaching(Character character) { SendControlledScoutmasterGrabbingRpc(character, "RPCA_StopReaching"); } private static Character ResolveGrabTargetCharacter(Collider collider) { if ((Object)(object)collider == (Object)null) { return null; } Character val = default(Character); if (CharacterRagdoll.TryGetCharacterFromCollider(collider, ref val) && (Object)(object)val != (Object)null) { return val; } Character componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } Bodypart componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 == (Object)null || BodypartCharacterField == null) { return null; } try { object? value = BodypartCharacterField.GetValue(componentInParent2); return (Character)((value is Character) ? value : null); } catch { return null; } } internal static bool TryApplyCameraOverride(Character character, ref Vector3 cameraPosition) { //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) if ((Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)GetControlledScoutmasterCharacter()) { return false; } cameraPosition = GetThirdPersonCameraPosition(character); return true; } internal static void SetCameraOverride(Character character) { _cameraOverrideCharacter = character; ResetThirdPersonCameraSmoothing(); } internal static void ClearCameraOverride() { _cameraOverrideCharacter = null; ResetThirdPersonCameraSmoothing(); } private static void UpdateScoutmasterHudState() { ConfigEntry hideHudWhileTransformed = HideHudWhileTransformed; if (hideHudWhileTransformed != null && hideHudWhileTransformed.Value) { if (!_hudHiddenForScoutmaster) { HideHudForScoutmaster(); } else { EnforceScoutmasterHudHidden(); } } else { RestoreHudAfterScoutmaster(); } } private static void HideHudForScoutmaster() { _hudHiddenForScoutmaster = true; _hudPreviousKnown = false; _namesPreviousKnown = false; _hudCanvasObject = null; _namesCanvasObject = null; EnforceScoutmasterHudHidden(); } private static void EnforceScoutmasterHudHidden() { if (_hudHiddenForScoutmaster) { HideHudCanvas(ref _hudCanvasObject, "Canvas_HUD", ref _hudPreviousKnown, ref _hudPreviousActive); HideHudCanvas(ref _namesCanvasObject, "Canvas_Names", ref _namesPreviousKnown, ref _namesPreviousActive); } } private static void HideHudCanvas(ref GameObject canvasObject, string objectName, ref bool previousKnown, ref bool previousActive) { if ((Object)(object)canvasObject == (Object)null) { canvasObject = GameObject.Find(objectName); } if (!((Object)(object)canvasObject == (Object)null)) { if (!previousKnown) { previousActive = canvasObject.activeSelf; previousKnown = true; } if (canvasObject.activeSelf) { canvasObject.SetActive(false); } } } private static void RestoreHudAfterScoutmaster() { RestoreHudCanvas(_hudCanvasObject, _hudPreviousKnown, _hudPreviousActive); RestoreHudCanvas(_namesCanvasObject, _namesPreviousKnown, _namesPreviousActive); _hudCanvasObject = null; _namesCanvasObject = null; _hudPreviousKnown = false; _namesPreviousKnown = false; _hudPreviousActive = false; _namesPreviousActive = false; _hudHiddenForScoutmaster = false; } private static void RestoreHudCanvas(GameObject canvasObject, bool previousKnown, bool previousActive) { if (!((Object)(object)canvasObject == (Object)null) && previousKnown) { canvasObject.SetActive(previousActive); } } internal static void RefreshControlledScoutmasterCamera(object movement) { //IL_0089: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Character controlledScoutmasterCharacter = GetControlledScoutmasterCharacter(); if (movement == null || (Object)(object)controlledScoutmasterCharacter == (Object)null) { return; } GetSmoothedThirdPersonCameraPose(controlledScoutmasterCharacter, out var cameraPosition, out var cameraRotation); try { MainCameraSpecCharacterProperty?.SetValue(null, null, null); MainCameraIsSpectatingField?.SetValue(movement, false); MainCameraRagdollCamField?.SetValue(movement, 0f); MainCameraCurrentForwardOffsetField?.SetValue(movement, 0f); MainCameraTargetPlayerPovPositionField?.SetValue(movement, cameraPosition); MainCameraPhysicsRotField?.SetValue(movement, cameraRotation); Component val = (Component)((movement is Component) ? movement : null); if (val != null) { val.transform.SetPositionAndRotation(cameraPosition, cameraRotation); } } catch { } } private static Vector3 GetThirdPersonCameraPosition(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 thirdPersonCameraTarget = GetThirdPersonCameraTarget(character); Vector3 thirdPersonCameraBack = GetThirdPersonCameraBack(character); float num = Mathf.Clamp((ThirdPersonDistance != null) ? ThirdPersonDistance.Value : 7.5f, 2f, 16f); return thirdPersonCameraTarget + thirdPersonCameraBack * num; } private static void GetSmoothedThirdPersonCameraPose(Character character, out Vector3 cameraPosition, out Quaternion cameraRotation) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_007f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 val = GetThirdPersonCameraPosition(character); if (!IsFiniteVector(val)) { val = ResolveThirdPersonCenter(character); } if (!_hasSmoothedThirdPersonCameraPose || Vector3.Distance(_smoothedThirdPersonCameraPosition, val) > 12f) { _smoothedThirdPersonCameraPosition = val; _smoothedThirdPersonCameraRotation = GetThirdPersonCameraRotation(character, _smoothedThirdPersonCameraPosition); _hasSmoothedThirdPersonCameraPose = true; cameraPosition = _smoothedThirdPersonCameraPosition; cameraRotation = _smoothedThirdPersonCameraRotation; } else { float num = 14f; _smoothedThirdPersonCameraPosition = Vector3.Lerp(_smoothedThirdPersonCameraPosition, val, Mathf.Clamp01(Time.deltaTime * num)); Quaternion thirdPersonCameraRotation = GetThirdPersonCameraRotation(character, _smoothedThirdPersonCameraPosition); _smoothedThirdPersonCameraRotation = Quaternion.Slerp(_smoothedThirdPersonCameraRotation, thirdPersonCameraRotation, Mathf.Clamp01(Time.deltaTime * 18f)); cameraPosition = _smoothedThirdPersonCameraPosition; cameraRotation = _smoothedThirdPersonCameraRotation; } } private static Vector3 GetThirdPersonCameraTarget(Character character) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) if ((Object)(object)character == (Object)null) { return Vector3.zero; } Vector3 val = ResolveThirdPersonCenter(character); float num = ((ThirdPersonHeightOffset != null) ? ThirdPersonHeightOffset.Value : 1.35f); Vector3 val2 = val + Vector3.up * num; if (!TryResolveThirdPersonHead(character, out var head)) { return val2; } float num2 = Mathf.Clamp(num * 0.35f, 0.35f, 1.35f); Vector3 val3 = head + Vector3.up * num2; if (IsFiniteVector(val2) && val2.y > val3.y) { val3 = Vector3.Lerp(val3, val2, 0.25f); } if (TryResolveThirdPersonGroundY(character, val, out var groundY)) { float num3 = (((Object)(object)character.data != (Object)null && character.data.isCrouching) ? 1.15f : 1.55f); val3.y = Mathf.Max(val3.y, groundY + num3); } return val3; } private static Vector3 ResolveThirdPersonCenter(Character character) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return Vector3.zero; } try { Vector3 center = character.Center; if (IsFiniteVector(center)) { return center; } } catch { } Vector3 position = ((Component)character).transform.position; if (!IsFiniteVector(position)) { return Vector3.zero; } return position; } private static bool TryResolveThirdPersonHead(Character character, out Vector3 head) { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) head = Vector3.zero; if ((Object)(object)character == (Object)null) { return false; } try { head = character.Head; if (IsFiniteVector(head)) { return true; } } catch { } Transform val = ResolveHeadTransform(character); if ((Object)(object)val == (Object)null) { return false; } head = val.position; return IsFiniteVector(head); } private static bool TryResolveThirdPersonGroundY(Character character, Vector3 center, out float groundY) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_007f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) groundY = 0f; if ((Object)(object)character?.data == (Object)null || !IsFiniteVector(character.data.groundPos)) { return false; } Vector3 groundPos = character.data.groundPos; if (IsFiniteVector(center)) { Vector3 val = Vector3.ProjectOnPlane(groundPos - center, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude > 64f || Mathf.Abs(groundPos.y - center.y) > 20f) { return false; } } groundY = groundPos.y; return true; } private static Vector3 GetThirdPersonCameraBack(Character character) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Vector3 lookDirection = ResolveThirdPersonLookDirection(character); return -ResolveThirdPersonFlatForward(character, lookDirection); } private static Vector3 ResolveThirdPersonFlatForward(Character character, Vector3 lookDirection) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_004b: 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_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_006b: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 value = Vector3.ProjectOnPlane(lookDirection, Vector3.up); if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = (((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null) ? character.data.lookDirection_Flat : Vector3.zero); } if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = (((Object)(object)character != (Object)null) ? Vector3.ProjectOnPlane(((Component)character).transform.forward, Vector3.up) : Vector3.zero); } if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = Vector3.forward; } return ((Vector3)(ref value)).normalized; } private static Quaternion GetThirdPersonCameraRotation(Character character, Vector3 cameraPosition) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Vector3 lookDirection = ResolveThirdPersonLookDirection(character); return BuildThirdPersonLookRotation(ResolveThirdPersonFramedLookDirection(character, cameraPosition, lookDirection)); } private static Vector3 ResolveThirdPersonFramedLookDirection(Character character, Vector3 cameraPosition, Vector3 lookDirection) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00c4: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_010a: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0121: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector(cameraPosition) || !IsFiniteVector(lookDirection) || ((Vector3)(ref lookDirection)).sqrMagnitude < 0.0001f) { return lookDirection; } Vector3 thirdPersonCameraTarget = GetThirdPersonCameraTarget(character); if (!IsFiniteVector(thirdPersonCameraTarget)) { return lookDirection; } Vector3 val = ResolveThirdPersonFlatForward(character, lookDirection); float num = Mathf.Clamp(Mathf.Clamp((ThirdPersonDistance != null) ? ThirdPersonDistance.Value : 7.5f, 2f, 16f) * 0.35f, 1.75f, 4.25f); Vector3 val2 = thirdPersonCameraTarget + val * num; if (lookDirection.y < 0f) { float num2 = Mathf.InverseLerp(0.05f, 0.95f, 0f - lookDirection.y); val2 += Vector3.down * (num2 * 1.15f); } else if (lookDirection.y > 0f) { float num3 = Mathf.InverseLerp(0.05f, 0.95f, lookDirection.y); val2 += Vector3.up * (num3 * 0.8f); } Vector3 val3 = val2 - cameraPosition; if (!IsFiniteVector(val3) || ((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { return lookDirection; } ((Vector3)(ref val3)).Normalize(); float num4 = Mathf.InverseLerp(0.45f, 0.95f, Mathf.Abs(lookDirection.y)); float num5 = ((lookDirection.y < 0f) ? 0.42f : 0.3f); Vector3 value = Vector3.Slerp(((Vector3)(ref lookDirection)).normalized, val3, Mathf.Clamp01(num4 * num5)); if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { return val3; } return ((Vector3)(ref value)).normalized; } private static Vector3 ResolveThirdPersonLookDirection(Character character) { //IL_0017: 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_002a: 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_005e: 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_0064: 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_0090: 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_0096: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Vector3 value = (((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null) ? character.data.lookDirection : Vector3.zero); if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : Vector3.zero); } if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = (((Object)(object)character != (Object)null) ? ((Component)character).transform.forward : Vector3.zero); } if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = Vector3.forward; } return ((Vector3)(ref value)).normalized; } private static Quaternion BuildThirdPersonLookRotation(Vector3 lookDirection) { //IL_0000: 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_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector(lookDirection) || ((Vector3)(ref lookDirection)).sqrMagnitude < 0.0001f) { lookDirection = Vector3.forward; } ((Vector3)(ref lookDirection)).Normalize(); Vector3 val = Vector3.up; if (Mathf.Abs(Vector3.Dot(lookDirection, val)) > 0.96f) { Vector3 val2 = Vector3.Cross(Vector3.right, lookDirection); if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.Cross(Vector3.forward, lookDirection); } if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.right; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(lookDirection, val2); val = ((Vector3)(ref val3)).normalized; } return Quaternion.LookRotation(lookDirection, val); } private static void ResetThirdPersonCameraSmoothing() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) _hasSmoothedThirdPersonCameraPose = false; _smoothedThirdPersonCameraPosition = Vector3.zero; _smoothedThirdPersonCameraRotation = Quaternion.identity; } internal static bool ShouldForceShowControlledScoutmaster(HideTheBody hideTheBody, Character fallbackCharacter) { if ((Object)(object)hideTheBody == (Object)null) { return false; } Character controlledScoutmasterCharacter = GetControlledScoutmasterCharacter(); if ((Object)(object)controlledScoutmasterCharacter == (Object)null) { return false; } if ((Object)(object)fallbackCharacter != (Object)null && (Object)(object)fallbackCharacter == (Object)(object)controlledScoutmasterCharacter) { return true; } Character componentInParent = ((Component)hideTheBody).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return (Object)(object)componentInParent == (Object)(object)controlledScoutmasterCharacter; } return false; } internal static void RefreshHideTheBodyVisuals(HideTheBody hideTheBody) { if ((Object)(object)hideTheBody == (Object)null) { return; } RevealRendererMaterials((Renderer)(object)hideTheBody.body); RevealRendererMaterials(hideTheBody.headRend); RevealRendererMaterials((Renderer)(object)hideTheBody.sash); if (hideTheBody.costumes != null) { SkinnedMeshRenderer[] costumes = hideTheBody.costumes; for (int i = 0; i < costumes.Length; i++) { RevealRendererMaterials((Renderer)(object)costumes[i]); } } } internal static void RefreshControlledScoutmasterVisuals() { if ((Object)(object)_viewScoutmasterObject == (Object)null) { return; } if ((Object)(object)GetControlledScoutmasterCharacter() == (Object)null) { _viewScoutmasterObject = null; return; } RestoreRendererVisibility(_viewScoutmasterObject); HideTheBody[] componentsInChildren = _viewScoutmasterObject.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { RefreshHideTheBodyVisuals(componentsInChildren[i]); } } private static void HideSourceRenderers(GameObject obj) { if (!((Object)(object)obj == (Object)null)) { Renderer[] componentsInChildren = obj.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { HideRenderer(componentsInChildren[i], _sourceRendererVisualStates); } } } private static void RestoreSourceRenderers(GameObject obj) { if (!((Object)(object)obj == (Object)null)) { Renderer[] componentsInChildren = obj.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { RestoreRendererVisibility(componentsInChildren[i], _sourceRendererVisualStates); } } } private static void RestoreRendererVisibility(GameObject obj) { if (!((Object)(object)obj == (Object)null)) { Renderer[] componentsInChildren = obj.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { RestoreRendererVisibility(componentsInChildren[i], _rendererVisualStates); } } } private static void HideRenderer(Renderer renderer, Dictionary stateStore) { if (!((Object)(object)renderer == (Object)null)) { int instanceID = ((Object)renderer).GetInstanceID(); if (!stateStore.ContainsKey(instanceID)) { stateStore[instanceID] = new RendererVisualState(renderer.enabled, renderer.forceRenderingOff); } renderer.forceRenderingOff = true; renderer.enabled = false; } } private static void RestoreRendererVisibility(Renderer renderer, Dictionary stateStore) { if (!((Object)(object)renderer == (Object)null)) { int instanceID = ((Object)renderer).GetInstanceID(); if (stateStore.TryGetValue(instanceID, out var value)) { renderer.enabled = value.Enabled; renderer.forceRenderingOff = value.ForceRenderingOff; stateStore.Remove(instanceID); } else { renderer.enabled = true; renderer.forceRenderingOff = false; } } } private static void RevealRendererMaterials(Renderer renderer) { if (!((Object)(object)renderer == (Object)null)) { renderer.enabled = true; renderer.forceRenderingOff = false; } } private static bool HasScoutmasterComponent(Character character) { if ((Object)(object)character == (Object)null) { return false; } try { return (Object)(object)((Component)character).GetComponent() != (Object)null; } catch { return false; } } private static bool IsCharacterInControlledCreationRoot(Character character) { if ((Object)(object)_controlledScoutmasterCreationRoot == (Object)null || (Object)(object)character == (Object)null) { return false; } try { Transform transform = ((Component)character).transform; return (Object)(object)transform == (Object)(object)_controlledScoutmasterCreationRoot || transform.IsChildOf(_controlledScoutmasterCreationRoot); } catch { return false; } } private static void RegisterControlledScoutmaster(Scoutmaster scoutmaster) { if ((Object)(object)scoutmaster == (Object)null) { return; } _controlledScoutmasterInstanceIds.Add(((Object)scoutmaster).GetInstanceID()); Character component = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component != (Object)null) { _controlledScoutmasterCharacterInstanceIds.Add(((Object)component).GetInstanceID()); } PhotonView component2 = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.ViewID > 0) { _controlledScoutmasterViewIds.Add(component2.ViewID); if (TryReadControlledScoutmasterInstantiationData(component2, out var ownerActorNumber)) { _controlledScoutmasterOwnerActorNumbersByViewId[component2.ViewID] = ownerActorNumber; } } EnsureControlledScoutmasterVisualSync(scoutmaster, component, component2); } private static void UnregisterControlledScoutmaster(Scoutmaster scoutmaster) { if (!((Object)(object)scoutmaster == (Object)null)) { _controlledScoutmasterInstanceIds.Remove(((Object)scoutmaster).GetInstanceID()); Character component = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component != (Object)null) { _controlledScoutmasterCharacterInstanceIds.Remove(((Object)component).GetInstanceID()); } PhotonView component2 = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component2 != (Object)null && component2.ViewID > 0) { _controlledScoutmasterViewIds.Remove(component2.ViewID); _controlledScoutmasterOwnerActorNumbersByViewId.Remove(component2.ViewID); } } } internal static void UnregisterControlledScoutmasterInstance(Character character, PhotonView view) { if ((Object)(object)character != (Object)null) { _controlledScoutmasterCharacterInstanceIds.Remove(((Object)character).GetInstanceID()); try { Scoutmaster component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null) { _controlledScoutmasterInstanceIds.Remove(((Object)component).GetInstanceID()); } } catch { } } if ((Object)(object)view != (Object)null && view.ViewID > 0) { _controlledScoutmasterViewIds.Remove(view.ViewID); _controlledScoutmasterOwnerActorNumbersByViewId.Remove(view.ViewID); } } internal static void EnsureControlledScoutmasterRegistered(Character character) { if ((Object)(object)character == (Object)null) { return; } try { Scoutmaster component = ((Component)character).GetComponent(); if (!((Object)(object)component == (Object)null)) { PhotonView component2 = ((Component)component).GetComponent(); TryRegisterControlledScoutmasterFromInstantiationData(component, component2); } } catch { } } private static bool TryRegisterControlledScoutmasterFromInstantiationData(Scoutmaster scoutmaster, PhotonView view) { if ((Object)(object)scoutmaster == (Object)null || (Object)(object)view == (Object)null || view.ViewID <= 0) { return false; } if (!TryReadControlledScoutmasterInstantiationData(view, out var ownerActorNumber)) { return false; } _controlledScoutmasterInstanceIds.Add(((Object)scoutmaster).GetInstanceID()); Character component = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component != (Object)null) { _controlledScoutmasterCharacterInstanceIds.Add(((Object)component).GetInstanceID()); } _controlledScoutmasterViewIds.Add(view.ViewID); _controlledScoutmasterOwnerActorNumbersByViewId[view.ViewID] = ownerActorNumber; EnsureControlledScoutmasterVisualSync(scoutmaster, component, view); return true; } private static bool TryReadControlledScoutmasterInstantiationData(PhotonView view, out int ownerActorNumber) { ownerActorNumber = 0; if ((Object)(object)view == (Object)null) { return false; } object[] instantiationData; try { instantiationData = view.InstantiationData; } catch { return false; } if (instantiationData == null || instantiationData.Length < 2 || !(instantiationData[0] is string text) || text != "ImScoutmaster.ControlledScoutmaster") { return false; } if (instantiationData.Length >= 3) { try { ownerActorNumber = Convert.ToInt32(instantiationData[2], CultureInfo.InvariantCulture); } catch { ownerActorNumber = 0; } } return true; } private static void EnsureControlledScoutmasterVisualSync(Scoutmaster scoutmaster, Character character, PhotonView view) { if ((Object)(object)scoutmaster == (Object)null) { return; } try { GameObject gameObject = ((Component)scoutmaster).gameObject; (gameObject.GetComponent() ?? gameObject.AddComponent()).Initialize(character ?? gameObject.GetComponent(), view ?? gameObject.GetComponent()); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Failed to install controlled Scoutmaster visual sync: " + ex.Message)); } } } private static void RegisterStashedSourceCharacter(Character character) { if ((Object)(object)character != (Object)null) { _stashedSourceCharacterIds.Add(((Object)character).GetInstanceID()); } } private static void UnregisterStashedSourceCharacter(Character character) { if ((Object)(object)character != (Object)null) { _stashedSourceCharacterIds.Remove(((Object)character).GetInstanceID()); } } internal static void ClearAssistJumpState(Character character) { if (!((Object)(object)character == (Object)null) && !((Object)(object)character.data == (Object)null)) { character.data.sincePalJump = 10f; character.data.sinceStandOnPlayer = 10f; character.data.lastStoodOnPlayer = null; character.data.launchedByCannon = false; } } private static Transform ResolveHeadTransform(Character character) { if ((Object)(object)character == (Object)null) { return null; } try { if ((Object)(object)character.refs?.head != (Object)null) { return ((Component)character.refs.head).transform; } Bodypart bodypart = GetBodypart(character, (BodypartType)4); return ((Object)(object)bodypart != (Object)null) ? ((Component)bodypart).transform : null; } catch { return null; } } internal static Bodypart GetBodypart(Character character, BodypartType bodypartType) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || CharacterGetBodypartMethod == null) { return null; } try { object? obj = CharacterGetBodypartMethod.Invoke(character, new object[1] { bodypartType }); return (Bodypart)((obj is Bodypart) ? obj : null); } catch { return null; } } private static BodypartType GetPartType(Character character, Rigidbody rigidbody) { //IL_0052: 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_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_004d: 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) if ((Object)(object)character == (Object)null || (Object)(object)rigidbody == (Object)null || CharacterGetPartTypeMethod == null) { return (BodypartType)(-1); } try { return (BodypartType)((!(CharacterGetPartTypeMethod.Invoke(character, new object[1] { rigidbody }) is BodypartType val)) ? (-1) : ((int)val)); } catch { return (BodypartType)(-1); } } internal static void ClearScoutmasterAiState(Scoutmaster scoutmaster) { if ((Object)(object)scoutmaster == (Object)null) { return; } try { ScoutmasterTargetForcedUntilField?.SetValue(scoutmaster, 0f); ScoutmasterCurrentTargetField?.SetValue(scoutmaster, null); ScoutmasterChillForSecondsField?.SetValue(scoutmaster, 0f); ScoutmasterIsThrowingField?.SetValue(scoutmaster, false); } catch { } } private static void SetGameObjectActive(GameObject obj, bool active) { if ((Object)(object)obj != (Object)null && obj.activeSelf != active) { obj.SetActive(active); } } private static void ForcePlayerCharacterLookup(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)Player.localPlayer == (Object)null || (Object)(object)((MonoBehaviourPun)Player.localPlayer).photonView == (Object)null) { return; } try { object? obj = PlayerHandlerInstanceProperty?.GetValue(null, null); PlayerHandler val = (PlayerHandler)((obj is PlayerHandler) ? obj : null); if (val != null && PlayerHandlerCharacterLookupField?.GetValue(val) is IDictionary dictionary) { int ownerActorNr = ((MonoBehaviourPun)Player.localPlayer).photonView.OwnerActorNr; dictionary[ownerActorNr] = character; } } catch { } } private static object CreateOptionableNoneValue(Type optionableType) { if (optionableType == null) { return null; } try { PropertyInfo property = optionableType.GetProperty("None", StaticFlags); if (property != null) { return property.GetValue(null, null); } } catch { } try { return Activator.CreateInstance(optionableType); } catch { return null; } } private static void ClearSelectedInventorySlots(CharacterItems items) { if ((Object)(object)items == (Object)null || CharacterItemsNoneSlotValue == null) { return; } try { CharacterItemsCurrentSelectedSlotField?.SetValue(items, CharacterItemsNoneSlotValue); CharacterItemsLastSelectedSlotField?.SetValue(items, CharacterItemsNoneSlotValue); } catch { } } private static void CopyLookStateForRestore(Character from, Character to, Quaternion restoreRotation) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0089: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) if (!((Object)(object)from == (Object)null) && !((Object)(object)to == (Object)null) && !((Object)(object)from.data == (Object)null) && !((Object)(object)to.data == (Object)null)) { to.data.lookValues = from.data.lookValues; Vector3 val = Vector3.ProjectOnPlane(restoreRotation * Vector3.forward, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = from.data.lookDirection_Flat; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)from).transform.forward; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = from.data.lookDirection; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = val; } float num = Mathf.Clamp(val2.y, -0.95f, 0.95f); float num2 = Mathf.Sqrt(Mathf.Max(0f, 1f - num * num)); Vector3 val3 = val * num2 + Vector3.up * num; val2 = ((Vector3)(ref val3)).normalized; to.data.lookDirection = val2; to.data.lookDirection_Flat = val; CharacterData data = to.data; val3 = Vector3.Cross(Vector3.up, val2); data.lookDirection_Right = ((Vector3)(ref val3)).normalized; CharacterData data2 = to.data; val3 = Vector3.Cross(val2, to.data.lookDirection_Right); data2.lookDirection_Up = ((Vector3)(ref val3)).normalized; ((Component)to).transform.rotation = Quaternion.LookRotation(val, Vector3.up); } } private static void BeginCameraRestoreAssist(Character character) { if ((Object)(object)character == (Object)null) { _cameraRestoreCharacter = null; _cameraRestoreUntil = 0f; } else { _cameraRestoreCharacter = character; _cameraRestoreUntil = Time.unscaledTime + 0.4f; RefreshRestoredPlayerCamera(snapCamera: true); } } private static void RefreshRestoredPlayerCamera() { RefreshRestoredPlayerCamera(snapCamera: false); } private static void RefreshRestoredPlayerCamera(bool snapCamera) { if (!((Object)(object)_cameraRestoreCharacter == (Object)null)) { if ((Object)(object)_cameraOverrideCharacter != (Object)null || Time.unscaledTime > _cameraRestoreUntil) { _cameraRestoreCharacter = null; _cameraRestoreUntil = 0f; } else if (!((Object)(object)_cameraRestoreCharacter.data == (Object)null)) { Character.localCharacter = _cameraRestoreCharacter; ResetMainCameraState(_cameraRestoreCharacter, snapCamera); } } } private static void ResetMainCameraState(Character character, bool snapCamera) { //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_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_013c: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return; } try { MainCameraSpecCharacterProperty?.SetValue(null, null, null); } catch { } Vector3 val = ResolvePlayerCameraPosition(character); Quaternion val2 = ResolvePlayerCameraRotation(character); try { if (FindObjectsOfTypeByTypeMethod?.Invoke(null, new object[1] { typeof(MainCameraMovement) }) is Object[] array) { Object[] array2 = array; foreach (Object val3 in array2) { if (!(val3 == (Object)null)) { MainCameraIsSpectatingField?.SetValue(val3, false); MainCameraRagdollCamField?.SetValue(val3, 0f); MainCameraCurrentForwardOffsetField?.SetValue(val3, 0f); MainCameraTargetPlayerPovPositionField?.SetValue(val3, val); MainCameraPhysicsRotField?.SetValue(val3, val2); } } } } catch { } if (!snapCamera || !((Object)(object)Camera.main != (Object)null)) { return; } try { ((Component)Camera.main).transform.SetPositionAndRotation(val, val2); } catch { } } private static Vector3 ResolvePlayerCameraPosition(Character character) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Transform val = ResolveHeadTransform(character); if (!((Object)(object)val != (Object)null)) { return character.Head; } return val.TransformPoint(Vector3.up); } private static Quaternion ResolvePlayerCameraRotation(Character character) { //IL_0017: 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_0024: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = (((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null) ? character.data.lookDirection : Vector3.zero); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f && (Object)(object)Camera.main != (Object)null) { val = ((Component)Camera.main).transform.forward; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f && (Object)(object)character != (Object)null) { val = ((Component)character).transform.forward; } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } private static void DestroyScoutmasterObject(GameObject scoutmasterObject) { if ((Object)(object)scoutmasterObject == (Object)null) { return; } PhotonView component = scoutmasterObject.GetComponent(); if ((Object)(object)component != (Object)null && (PhotonNetwork.InRoom || PhotonNetwork.OfflineMode)) { try { if (component.ViewID > 0 && (component.IsMine || PhotonNetwork.IsMasterClient)) { PhotonNetwork.Destroy(scoutmasterObject); return; } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[I'm Scoutmaster] Photon destroy failed: " + ex.Message)); } } } Object.Destroy((Object)(object)scoutmasterObject); } private void RegisterConfigChangeHandlers() { if (((BaseUnityPlugin)this).Config != null) { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigSettingChanged; ((BaseUnityPlugin)this).Config.SettingChanged += OnConfigSettingChanged; } } private void UnregisterConfigChangeHandlers() { if (((BaseUnityPlugin)this).Config != null) { ((BaseUnityPlugin)this).Config.SettingChanged -= OnConfigSettingChanged; } } private void OnConfigSettingChanged(object sender, SettingChangedEventArgs e) { MarkConfigFileLocalizationDirty(saveConfigFile: false); } private void MarkConfigFileLocalizationDirty(bool saveConfigFile) { _pendingConfigFileLocalizationRefresh = true; _pendingConfigFileLocalizationSave |= saveConfigFile; } private void HandlePendingConfigFileLocalizationRefresh() { if (_pendingConfigFileLocalizationRefresh && !_isRefreshingLanguage) { bool pendingConfigFileLocalizationSave = _pendingConfigFileLocalizationSave; _pendingConfigFileLocalizationRefresh = false; _pendingConfigFileLocalizationSave = false; TryRefreshLocalizedConfigFile(_lastDetectedChineseLanguage, pendingConfigFileLocalizationSave); } } private void HandleLanguageChangeIfNeeded() { bool flag = DetectChineseLanguage(); if (flag != _lastDetectedChineseLanguage) { ReinitializeLocalizedConfig(flag); } } private void ReinitializeLocalizedConfig(bool isChineseLanguage) { if (_isRefreshingLanguage) { return; } _isRefreshingLanguage = true; try { _lastDetectedChineseLanguage = isChineseLanguage; ApplyLocalizedConfigMetadata(isChineseLanguage); MarkConfigFileLocalizationDirty(saveConfigFile: true); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[I'm Scoutmaster] Config language changed: " + (isChineseLanguage ? "Chinese" : "English"))); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Failed to update config language: " + ex.Message)); } finally { _isRefreshingLanguage = false; } } private void ApplyLocalizedConfigMetadata(bool isChineseLanguage) { try { ConfigEntryBase[] configEntriesSnapshot = GetConfigEntriesSnapshot(((BaseUnityPlugin)this).Config); foreach (ConfigEntryBase val in configEntriesSnapshot) { if (!(((val != null) ? val.Definition : null) == (ConfigDefinition)null) && val.Description != null && TryGetConfigKey(val.Definition.Key, out var configKey)) { string localizedDescription = GetLocalizedDescription(configKey, isChineseLanguage); if (!string.IsNullOrWhiteSpace(localizedDescription)) { SetPrivateField(val.Description, "k__BackingField", localizedDescription); } } } TryLocalizeVisibleModConfigUi(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Failed to apply localized config metadata: " + ex.Message)); } } private static ConfigEntryBase[] GetConfigEntriesSnapshot(ConfigFile configFile) { if (configFile == null || !(ConfigFileEntriesProperty?.GetValue(configFile) is IDictionary dictionary) || dictionary.Count == 0) { return Array.Empty(); } List list = new List(); foreach (DictionaryEntry item in dictionary) { object? value = item.Value; ConfigEntryBase val = (ConfigEntryBase)((value is ConfigEntryBase) ? value : null); if (val != null) { list.Add(val); } } return list.ToArray(); } private static void SetPrivateField(object target, string fieldName, object value) { if (target != null && !string.IsNullOrWhiteSpace(fieldName)) { target.GetType().GetField(fieldName, InstanceFlags)?.SetValue(target, value); } } private static bool TryGetConfigKey(string keyName, out ConfigKey configKey) { foreach (ConfigKey value in Enum.GetValues(typeof(ConfigKey))) { if (string.Equals(keyName, GetConfigKeyName(value), StringComparison.OrdinalIgnoreCase) || string.Equals(keyName, GetKeyName(value, isChineseLanguage: true), StringComparison.OrdinalIgnoreCase)) { configKey = value; return true; } } configKey = ConfigKey.ToggleKey; return false; } private void TryRefreshLocalizedConfigFile(bool isChineseLanguage, bool saveConfigFile) { try { if (((BaseUnityPlugin)this).Config != null && !string.IsNullOrWhiteSpace(((BaseUnityPlugin)this).Config.ConfigFilePath)) { if (saveConfigFile) { ((BaseUnityPlugin)this).Config.Save(); } RewriteConfigFileLocalization(((BaseUnityPlugin)this).Config.ConfigFilePath, isChineseLanguage); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[I'm Scoutmaster] Failed to refresh localized config file: " + ex.Message)); } } private static void RewriteConfigFileLocalization(string configFilePath, bool isChineseLanguage) { if (!string.IsNullOrWhiteSpace(configFilePath) && File.Exists(configFilePath)) { string[] array = File.ReadAllLines(configFilePath); string[] array2 = new string[array.Length]; bool flag = false; for (int i = 0; i < array.Length; i++) { string text = array[i] ?? string.Empty; flag |= !string.Equals(text, array2[i] = RewriteConfigFileLine(text, isChineseLanguage), StringComparison.Ordinal); } if (flag) { File.WriteAllLines(configFilePath, array2); } } } private static string RewriteConfigFileLine(string line, bool isChineseLanguage) { if (string.IsNullOrWhiteSpace(line)) { return line ?? string.Empty; } string text = line.Trim(); if (text.StartsWith("[", StringComparison.Ordinal) && text.EndsWith("]", StringComparison.Ordinal)) { if (!TryGetLocalizedSectionName(text.Substring(1, text.Length - 2).Trim(), isChineseLanguage, out var localizedSectionName)) { return line; } int num = line.IndexOf('['); int num2 = line.LastIndexOf(']'); if (num < 0 || num2 < num) { return line; } return line.Substring(0, num + 1) + localizedSectionName + line.Substring(num2); } if (text.StartsWith("#", StringComparison.Ordinal) || text.StartsWith(";", StringComparison.Ordinal)) { return line; } int num3 = line.IndexOf('='); if (num3 <= 0) { return line; } int i; for (i = 0; i < num3 && char.IsWhiteSpace(line[i]); i++) { } int num4 = num3 - 1; while (num4 >= i && char.IsWhiteSpace(line[num4])) { num4--; } if (num4 < i) { return line; } if (!TryGetConfigKey(line.Substring(i, num4 - i + 1), out var configKey)) { return line; } string keyName = GetKeyName(configKey, isChineseLanguage); return line.Substring(0, i) + keyName + line.Substring(num4 + 1); } private static bool TryGetLocalizedSectionName(string sectionName, bool isChineseLanguage, out string localizedSectionName) { if (MatchesSectionName(sectionName, "Controls", "控制")) { localizedSectionName = (isChineseLanguage ? "控制" : "Controls"); return true; } if (MatchesSectionName(sectionName, "Scoutmaster Control", "童军领队控制")) { localizedSectionName = (isChineseLanguage ? "童军领队控制" : "Scoutmaster Control"); return true; } if (MatchesSectionName(sectionName, "Camera", "相机")) { localizedSectionName = (isChineseLanguage ? "相机" : "Camera"); return true; } if (MatchesSectionName(sectionName, "Player Restore", "玩家恢复")) { localizedSectionName = (isChineseLanguage ? "玩家恢复" : "Player Restore"); return true; } if (MatchesSectionName(sectionName, "HUD", "界面")) { localizedSectionName = (isChineseLanguage ? "界面" : "HUD"); return true; } if (MatchesSectionName(sectionName, "Diagnostics", "诊断")) { localizedSectionName = (isChineseLanguage ? "诊断" : "Diagnostics"); return true; } localizedSectionName = string.Empty; return false; } private static bool MatchesSectionName(string sectionName, string englishName, string chineseName) { if (!string.Equals(sectionName, englishName, StringComparison.OrdinalIgnoreCase)) { return string.Equals(sectionName, chineseName, StringComparison.Ordinal); } return true; } private void MigrateLocalizedConfigEntries() { IDictionary orphanedEntries = GetOrphanedEntries(((BaseUnityPlugin)this).Config); if (orphanedEntries != null && orphanedEntries.Count != 0 && (false | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ToggleKey, ConfigKey.ToggleKey, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)StaminaRefill, ConfigKey.StaminaRefill, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ThrowForce, ConfigKey.ThrowForce, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ThrowUpBias, ConfigKey.ThrowUpBias, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ThrowFallSeconds, ConfigKey.ThrowFallSeconds, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ThirdPersonHeightOffset, ConfigKey.ThirdPersonHeightOffset, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)ThirdPersonDistance, ConfigKey.ThirdPersonDistance, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)SourceStashDistance, ConfigKey.SourceStashDistance, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)RestoreAtScoutmasterPosition, ConfigKey.RestoreAtScoutmasterPosition, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)RestoreGroundOffset, ConfigKey.RestoreGroundOffset, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)HideHudWhileTransformed, ConfigKey.HideHudWhileTransformed, orphanedEntries) | TryMigrateLocalizedConfigValue((ConfigEntryBase)(object)VerboseLogs, ConfigKey.VerboseLogs, orphanedEntries))) { ((BaseUnityPlugin)this).Config.Save(); } } private static bool TryMigrateLocalizedConfigValue(ConfigEntryBase entry, ConfigKey configKey, IDictionary orphanedEntries) { if (((entry != null) ? entry.Definition : null) == (ConfigDefinition)null || orphanedEntries == null) { return false; } bool flag = false; foreach (ConfigDefinition aliasDefinition in GetAliasDefinitions(configKey)) { if (DefinitionsEqual(aliasDefinition, entry.Definition) || !orphanedEntries.Contains(aliasDefinition)) { continue; } if (!flag) { object obj = orphanedEntries[aliasDefinition]; if (obj != null) { entry.SetSerializedValue(obj.ToString()); } flag = true; } orphanedEntries.Remove(aliasDefinition); } return flag; } [IteratorStateMachine(typeof(d__350))] private static IEnumerable GetAliasDefinitions(ConfigKey configKey) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__350(-2) { <>3__configKey = configKey }; } private static IDictionary GetOrphanedEntries(ConfigFile configFile) { return ((object)configFile)?.GetType().GetProperty("OrphanedEntries", InstanceFlags)?.GetValue(configFile) as IDictionary; } private static bool DefinitionsEqual(ConfigDefinition left, ConfigDefinition right) { if (string.Equals((left != null) ? left.Section : null, (right != null) ? right.Section : null, StringComparison.Ordinal)) { return string.Equals((left != null) ? left.Key : null, (right != null) ? right.Key : null, StringComparison.Ordinal); } return false; } private static void ClampConfigValues() { ClampFloat(StaminaRefill, 0.1f, 1f); ClampFloat(ThrowForce, 100f, 5000f); ClampFloat(ThrowUpBias, 0f, 2f); ClampFloat(ThrowFallSeconds, 0f, 10f); ClampFloat(ThirdPersonHeightOffset, -2f, 6f); ClampFloat(ThirdPersonDistance, 2f, 16f); ClampFloat(SourceStashDistance, 10f, 200f); ClampFloat(RestoreGroundOffset, 0.2f, 5f); } private static void ClampFloat(ConfigEntry entry, float min, float max) { if (entry != null) { entry.Value = Mathf.Clamp(entry.Value, min, max); } } private static bool DetectChineseLanguage() { bool isChineseLanguage; bool num = TryGetConfiguredGameLanguage(out isChineseLanguage); string languageName; bool flag = TryGetLocalizedTextLanguageName(out languageName); if (num && isChineseLanguage) { return true; } if (flag && IsChineseLanguageName(languageName)) { return true; } return false; } private static string BuildLanguageDetectionSummary(bool isChineseLanguage) { bool isChineseLanguage2; string languageValueText; string text = (TryGetConfiguredGameLanguage(out isChineseLanguage2, out languageValueText) ? (languageValueText + "/" + (isChineseLanguage2 ? "Chinese" : "English")) : "unknown"); string languageName; string text2 = (TryGetLocalizedTextLanguageName(out languageName) ? languageName : "unknown"); return (isChineseLanguage ? "Chinese" : "English") + " (prefs=" + text + ", runtime=" + text2 + ")"; } private static bool TryGetConfiguredGameLanguage(out bool isChineseLanguage) { string languageValueText; return TryGetConfiguredGameLanguage(out isChineseLanguage, out languageValueText); } private static bool TryGetConfiguredGameLanguage(out bool isChineseLanguage, out string languageValueText) { isChineseLanguage = false; languageValueText = string.Empty; try { if (!PlayerPrefs.HasKey("LanguageSetting")) { return false; } int result = PlayerPrefs.GetInt("LanguageSetting", int.MinValue); if (result != int.MinValue) { languageValueText = result.ToString(CultureInfo.InvariantCulture); isChineseLanguage = IsChineseLanguageIndex(result); return true; } string text = (languageValueText = PlayerPrefs.GetString("LanguageSetting", string.Empty)); if (string.IsNullOrWhiteSpace(text)) { return false; } if (int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) { isChineseLanguage = IsChineseLanguageIndex(result); return true; } isChineseLanguage = IsChineseLanguageName(text); return true; } catch { return false; } } private static bool TryGetLocalizedTextLanguageName(out string languageName) { languageName = string.Empty; try { languageName = ((object)(Language)(ref LocalizedText.CURRENT_LANGUAGE)).ToString(); return !string.IsNullOrWhiteSpace(languageName); } catch { return false; } } private static bool IsChineseLanguageName(string languageName) { if (string.IsNullOrWhiteSpace(languageName)) { return false; } if (int.TryParse(languageName.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return IsChineseLanguageIndex(result); } if (languageName.IndexOf("Chinese", StringComparison.OrdinalIgnoreCase) < 0 && languageName.IndexOf("中文", StringComparison.OrdinalIgnoreCase) < 0) { return languageName.StartsWith("zh", StringComparison.OrdinalIgnoreCase); } return true; } private static bool IsChineseLanguageIndex(int languageValue) { if (languageValue != 9) { return languageValue == 10; } return true; } private static string GetConfigSectionName(ConfigKey configKey) { return GetSectionName(configKey, isChineseLanguage: false); } private static string GetSectionName(ConfigKey configKey, bool isChineseLanguage) { switch (configKey) { case ConfigKey.ToggleKey: if (!isChineseLanguage) { return "Controls"; } return "控制"; case ConfigKey.StaminaRefill: case ConfigKey.ThrowForce: case ConfigKey.ThrowUpBias: case ConfigKey.ThrowFallSeconds: if (!isChineseLanguage) { return "Scoutmaster Control"; } return "童军领队控制"; case ConfigKey.ThirdPersonHeightOffset: case ConfigKey.ThirdPersonDistance: if (!isChineseLanguage) { return "Camera"; } return "相机"; case ConfigKey.SourceStashDistance: case ConfigKey.RestoreAtScoutmasterPosition: case ConfigKey.RestoreGroundOffset: if (!isChineseLanguage) { return "Player Restore"; } return "玩家恢复"; case ConfigKey.HideHudWhileTransformed: if (!isChineseLanguage) { return "HUD"; } return "界面"; case ConfigKey.VerboseLogs: if (!isChineseLanguage) { return "Diagnostics"; } return "诊断"; default: if (!isChineseLanguage) { return "Scoutmaster Control"; } return "童军领队控制"; } } private static string GetConfigKeyName(ConfigKey configKey) { return GetKeyName(configKey, isChineseLanguage: false); } private static string GetKeyName(ConfigKey configKey, bool isChineseLanguage) { if (isChineseLanguage) { switch (configKey) { case ConfigKey.ToggleKey: return "变身按键"; case ConfigKey.StaminaRefill: return "体力保持值"; case ConfigKey.ThrowForce: return "投掷力度"; case ConfigKey.ThrowUpBias: return "投掷向上偏移"; case ConfigKey.ThrowFallSeconds: return "投掷摔倒时间"; case ConfigKey.ThirdPersonHeightOffset: return "第三人称高度偏移"; case ConfigKey.ThirdPersonDistance: return "第三人称距离"; case ConfigKey.SourceStashDistance: return "原玩家隐藏距离"; case ConfigKey.RestoreAtScoutmasterPosition: return "恢复到童军领队位置"; case ConfigKey.RestoreGroundOffset: return "恢复离地高度"; case ConfigKey.HideHudWhileTransformed: return "变身时隐藏HUD"; case ConfigKey.VerboseLogs: return "详细日志"; } } return configKey switch { ConfigKey.ToggleKey => "ToggleKey", ConfigKey.StaminaRefill => "StaminaRefill", ConfigKey.ThrowForce => "ThrowForce", ConfigKey.ThrowUpBias => "ThrowUpBias", ConfigKey.ThrowFallSeconds => "ThrowFallSeconds", ConfigKey.ThirdPersonHeightOffset => "ThirdPersonHeightOffset", ConfigKey.ThirdPersonDistance => "ThirdPersonDistance", ConfigKey.SourceStashDistance => "SourceStashDistance", ConfigKey.RestoreAtScoutmasterPosition => "RestoreAtScoutmasterPosition", ConfigKey.RestoreGroundOffset => "RestoreGroundOffset", ConfigKey.HideHudWhileTransformed => "HideHudWhileTransformed", ConfigKey.VerboseLogs => "VerboseLogs", _ => string.Empty, }; } private static string GetLocalizedDescription(ConfigKey configKey, bool isChineseLanguage) { if (isChineseLanguage) { switch (configKey) { case ConfigKey.ToggleKey: return "长按 1 秒变成童军领队,再长按 1 秒恢复玩家。默认 G。"; case ConfigKey.StaminaRefill: return "控制童军领队时每帧保持的最低体力值,1 表示满体力。"; case ConfigKey.ThrowForce: return "童军领队投掷抓住玩家时使用的力度。"; case ConfigKey.ThrowUpBias: return "投掷方向额外增加的向上偏移。"; case ConfigKey.ThrowFallSeconds: return "被投掷玩家获得的摔倒/布娃娃时间。"; case ConfigKey.ThirdPersonHeightOffset: return "第三人称相机看向童军领队时的目标高度。"; case ConfigKey.ThirdPersonDistance: return "第三人称相机与童军领队的距离。"; case ConfigKey.SourceStashDistance: return "变身期间把原玩家身体临时移到脚下多远,避免同时看到玩家和童军领队。"; case ConfigKey.RestoreAtScoutmasterPosition: return "恢复时是否把玩家身体移动到童军领队当前位置,并使用童军领队朝向。"; case ConfigKey.RestoreGroundOffset: return "恢复玩家时,在检测到的地面上方保留的高度,避免穿过地面碰撞体。"; case ConfigKey.HideHudWhileTransformed: return "变身为童军领队时隐藏 Canvas_HUD 和 Canvas_Names,恢复玩家时恢复原状态。"; case ConfigKey.VerboseLogs: return "输出更详细的诊断日志。"; } } return configKey switch { ConfigKey.ToggleKey => "Hold for 1 second to transform into Scoutmaster, then hold again for 1 second to restore the player. Default: G.", ConfigKey.StaminaRefill => "Minimum normalized stamina maintained while controlling Scoutmaster. 1 means full stamina.", ConfigKey.ThrowForce => "Force used when Scoutmaster throws a grabbed player.", ConfigKey.ThrowUpBias => "Upward bias added to throw direction.", ConfigKey.ThrowFallSeconds => "Fall/ragdoll seconds applied to the thrown player.", ConfigKey.ThirdPersonHeightOffset => "Height of the third-person camera target.", ConfigKey.ThirdPersonDistance => "Distance behind Scoutmaster in third person.", ConfigKey.SourceStashDistance => "How far below the map the original player body is parked while transformed.", ConfigKey.RestoreAtScoutmasterPosition => "Restore the player near Scoutmaster, matching Scoutmaster facing, when leaving Scoutmaster form.", ConfigKey.RestoreGroundOffset => "Height kept above the detected ground when restoring the player, reducing ground clipping after returning from Scoutmaster form.", ConfigKey.HideHudWhileTransformed => "Hide Canvas_HUD and Canvas_Names while transformed into Scoutmaster, then restore their previous active states when returning.", ConfigKey.VerboseLogs => "Write extra control diagnostics to the BepInEx log.", _ => string.Empty, }; } private void TryLocalizeVisibleModConfigUiThrottled() { if (!(Time.unscaledTime < _nextModConfigUiLocalizationTime)) { _nextModConfigUiLocalizationTime = Time.unscaledTime + 0.25f; TryLocalizeVisibleModConfigUi(); } } private void TryLocalizeVisibleModConfigUi() { if (!TryGetModConfigMenuInstance(out var menuType, out var menuInstance)) { return; } Behaviour val = (Behaviour)((menuInstance is Behaviour) ? menuInstance : null); if (val == null || (Object)(object)val == (Object)null) { return; } try { if (!val.isActiveAndEnabled || !((Component)val).gameObject.activeInHierarchy) { return; } } catch { return; } Dictionary map = BuildModConfigUiLocalizationMap(DetectChineseLanguage()); foreach (Transform item in EnumerateModConfigUiRoots(menuInstance, menuType)) { ApplyTextLocalizationToRoot(item, map); } ApplyTextLocalizationToLoadedUi(map); } private static bool TryGetModConfigMenuInstance(out Type menuType, out object menuInstance) { menuType = null; menuInstance = null; if (!Chainloader.PluginInfos.TryGetValue("com.github.PEAKModding.PEAKLib.ModConfig", out var value) || (Object)(object)((value != null) ? value.Instance : null) == (Object)null) { return false; } Assembly assembly = ((object)value.Instance).GetType().Assembly; menuType = assembly.GetType("PEAKLib.ModConfig.Components.ModdedSettingsMenu"); menuInstance = menuType?.GetProperty("Instance", StaticFlags)?.GetValue(null); if (menuType != null) { return menuInstance != null; } return false; } [IteratorStateMachine(typeof(d__370))] private static IEnumerable EnumerateModConfigUiRoots(object menuInstance, Type menuType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__370(-2) { <>3__menuInstance = menuInstance, <>3__menuType = menuType }; } [IteratorStateMachine(typeof(d__371))] private static IEnumerable EnumerateCandidateTransforms(object menuInstance, Type menuType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__371(-2) { <>3__menuInstance = menuInstance, <>3__menuType = menuType }; } private static void ApplyTextLocalizationToRoot(Transform root, Dictionary map) { if (!((Object)(object)root == (Object)null) && map != null && map.Count != 0) { TMP_Text[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ApplyTextLocalization(componentsInChildren[i], map); } } } private static void ApplyTextLocalizationToLoadedUi(Dictionary map) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (map == null || map.Count == 0) { return; } try { TMP_Text[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_Text val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { ApplyTextLocalization(val, map); } } } } catch { } } private static void ApplyTextLocalization(TMP_Text text, Dictionary map) { if (!((Object)(object)text == (Object)null) && map != null && map.Count != 0) { string text2 = text.text?.Trim(); if (!string.IsNullOrWhiteSpace(text2) && map.TryGetValue(text2, out var value) && !string.Equals(text2, value, StringComparison.Ordinal)) { text.text = value; } } } private static Dictionary BuildModConfigUiLocalizationMap(bool isChineseLanguage) { Dictionary dictionary = new Dictionary(StringComparer.Ordinal); AddUiLocalizationPair(dictionary, "I'm Scoutmaster", GetLocalizedModDisplayName(isChineseLanguage)); AddUiLocalizationPair(dictionary, "ImScoutmaster", GetLocalizedModDisplayName(isChineseLanguage)); AddUiLocalizationPair(dictionary, "I'm Scoutmaster", GetLocalizedModDisplayName(isChineseLanguage)); AddUiLocalizationPair(dictionary, "com.github.Thanks.ImScoutmaster", GetLocalizedModDisplayName(isChineseLanguage)); foreach (ConfigKey value in Enum.GetValues(typeof(ConfigKey))) { string sectionName = GetSectionName(value, isChineseLanguage); string keyName = GetKeyName(value, isChineseLanguage); AddUiLocalizationPair(dictionary, GetConfigSectionName(value), sectionName); AddUiLocalizationPair(dictionary, GetSectionName(value, isChineseLanguage: true), sectionName); AddUiLocalizationPair(dictionary, GetConfigKeyName(value), keyName); AddUiLocalizationPair(dictionary, ToReadableName(GetConfigKeyName(value)), keyName); AddUiLocalizationPair(dictionary, GetKeyName(value, isChineseLanguage: true), keyName); AddUiLocalizationPair(dictionary, GetLocalizedDescription(value, isChineseLanguage: false), GetLocalizedDescription(value, isChineseLanguage)); AddUiLocalizationPair(dictionary, GetLocalizedDescription(value, isChineseLanguage: true), GetLocalizedDescription(value, isChineseLanguage)); } return dictionary; } private static void AddUiLocalizationPair(Dictionary map, string source, string localized) { if (map != null && !string.IsNullOrWhiteSpace(source) && !string.IsNullOrWhiteSpace(localized)) { string text = source.Trim(); string text3 = (map[text] = localized.Trim()); map[text3] = text3; string key = text.Replace(" ", string.Empty); string key2 = text3.Replace(" ", string.Empty); if (!map.ContainsKey(key)) { map[key] = text3; } if (!map.ContainsKey(key2)) { map[key2] = text3; } map[text.ToUpperInvariant()] = text3; map[text3.ToUpperInvariant()] = text3; } } private static string ToReadableName(string keyName) { if (string.IsNullOrWhiteSpace(keyName)) { return string.Empty; } List list = new List(keyName.Length + 8); for (int i = 0; i < keyName.Length; i++) { char c = keyName[i]; if (i > 0 && char.IsUpper(c) && !char.IsWhiteSpace(keyName[i - 1]) && !char.IsUpper(keyName[i - 1])) { list.Add(' '); } list.Add(c); } return new string(list.ToArray()); } private static string GetLocalizedModDisplayName(bool isChineseLanguage) { if (!isChineseLanguage) { return "I'm Scoutmaster"; } return "我是童军领队"; } internal static void LogVerbose(string message) { if (VerboseLogs != null && VerboseLogs.Value) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[I'm Scoutmaster] " + message)); } } } } public sealed class PlayerScoutmasterController : MonoBehaviour { private static readonly BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly MethodInfo ScoutmasterResetInputMethod = typeof(Scoutmaster).GetMethod("ResetInput", InstanceFlags); private static readonly MethodInfo GrabbingThrowMethod = typeof(CharacterGrabbing).GetMethod("Throw", InstanceFlags); private static readonly FieldInfo ScoutmasterCurrentTargetField = typeof(Scoutmaster).GetField("_currentTarget", InstanceFlags); private static readonly FieldInfo ScoutmasterChillForSecondsField = typeof(Scoutmaster).GetField("chillForSeconds", InstanceFlags); private static readonly FieldInfo CharacterDataGrabbedPlayerField = typeof(CharacterData).GetField("grabbedPlayer", InstanceFlags); private static readonly FieldInfo BodypartCharacterField = typeof(Bodypart).GetField("character", InstanceFlags); private static readonly FieldInfo BodypartTargetRotationField = typeof(Bodypart).GetField("targetRotation", InstanceFlags); private static readonly FieldInfo BodypartLastTargetRotationField = typeof(Bodypart).GetField("lastTargetRotation", InstanceFlags); private static readonly FieldInfo BodypartPrevRotField = typeof(Bodypart).GetField("prevRot", InstanceFlags); private static readonly BodypartType[] GroundedFootParts; private const float ClimbSurfaceProbeDistance = 2.25f; private const float GrabProbeDistance = 6.5f; private const float GrabProbeRadius = 1.15f; private const float GrabProbeRetrySeconds = 0.08f; private const float GrabProbeSuccessCooldownSeconds = 0.2f; private const float ThrowChargeMaxSeconds = 1.2f; private const float OriginalScoutmasterClimbInput = 1f; private const float MovementInputDeadzone = 0.01f; private const float HeadAngularVelocityLimit = 1.5f; private const float HeadRotationSharpness = 28f; private const float HeadRotationSnapAngle = 55f; private const float GroundedFootGroundClearance = 0.03f; private const float GroundProbeUp = 2.5f; private const float GroundProbeDistance = 9f; private const float GroundingCrouchMaxStep = 0.35f; private const float GroundingStandingMaxStep = 0.22f; private const float GroundingSharpness = 18f; private const float GroundingCrouchFloatingTolerance = 0.025f; private const float GroundingStandingFloatingTolerance = 0.055f; private bool _climbWasHeld; private bool _reachWasHeld; private int _lastReachFrame = -1; private int _pendingRemoteGrabUnattachFrame = -1; private int _lastGroundingFrame = -1; private Character _sourceCharacter; private Scoutmaster _scoutmaster; private Character _character; private float _lastThrowTime; private float _nextGrabProbeTime; private float _reachHoldStartTime; private Vector3 _lastStableLookDirection = Vector3.forward; public static bool IsControlled(Scoutmaster scoutmaster) { if ((Object)(object)scoutmaster == (Object)null) { return false; } PlayerScoutmasterController component = ((Component)scoutmaster).GetComponent(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled) { return (Object)(object)component._scoutmaster == (Object)(object)scoutmaster; } return false; } public void Initialize(Character sourceCharacter, Scoutmaster scoutmaster, Character character) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) _sourceCharacter = sourceCharacter; _scoutmaster = scoutmaster; _character = character; _lastThrowTime = 0f; _nextGrabProbeTime = 0f; _reachHoldStartTime = 0f; _climbWasHeld = false; _reachWasHeld = false; _lastReachFrame = -1; _pendingRemoteGrabUnattachFrame = -1; _lastGroundingFrame = -1; _lastStableLookDirection = ResolveInitialLookDirection(sourceCharacter, character); ((Behaviour)this).enabled = true; } internal void ActivateDynamicRagdollControl() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || _character.refs?.ragdoll?.partList == null) { return; } try { foreach (Bodypart part in _character.refs.ragdoll.partList) { Rigidbody val = (((Object)(object)part != (Object)null) ? part.Rig : null); if (!((Object)(object)val == (Object)null)) { val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; val.detectCollisions = true; val.useGravity = true; val.isKinematic = false; val.WakeUp(); } } } catch { } } private void Update() { if (IsReady()) { ControlTick(); } } private void LateUpdate() { if (IsReady()) { Character.localCharacter = _character; if (IsControlPausedByIncapacitation()) { ClearActiveControlInputs(); return; } HandleReachAndThrow(); StabilizeControlledHead(); KeepGroundedFeetAligned(); } } internal void ControlTick() { if (IsReady()) { Character.localCharacter = _character; KeepAliveAndControllable(); if (IsControlPausedByIncapacitation()) { ClearActiveControlInputs(); return; } ScoutmasterCurrentTargetField?.SetValue(_scoutmaster, null); ScoutmasterResetInputMethod?.Invoke(_scoutmaster, null); ApplyOriginalScoutmasterSprintInput(); HandleClimbInput(); EnsureClimbSurfaceStillValid(); HandleReachAndThrow(); KeepGroundedFeetAligned(); } } private bool IsReady() { if ((Object)(object)_scoutmaster != (Object)null && (Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { return _character.refs != null; } return false; } private static Vector3 ResolveInitialLookDirection(Character sourceCharacter, Character fallbackCharacter) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) Vector3 value = ResolveCharacterLookDirection(sourceCharacter); if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = ResolveCharacterLookDirection(fallbackCharacter); } if (!IsFiniteVector(value) || ((Vector3)(ref value)).sqrMagnitude < 0.0001f) { value = Vector3.forward; } return ((Vector3)(ref value)).normalized; } private static Vector3 ResolveCharacterLookDirection(Character character) { //IL_0009: 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_001d: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0066: 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_0089: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return Vector3.zero; } Vector3 val = (((Object)(object)character.data != (Object)null) ? character.data.lookDirection : Vector3.zero); if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = (((Object)(object)character.data != (Object)null) ? character.data.lookDirection_Flat : Vector3.zero); } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)character).transform.forward; } return val; } private void KeepAliveAndControllable() { bool num = IsControlPausedByIncapacitation(); _character.isScoutmaster = true; _character.isZombie = false; _character.data.isScoutmaster = true; Plugin.SetCharacterDeadWithoutReconnect(_character, dead: false); _character.data.zombified = false; if (!num) { _character.data.passedOut = false; _character.data.fullyPassedOut = false; _character.data.fallSeconds = 0f; _character.data.currentRagdollControll = 1f; _character.data.currentStamina = Mathf.Max(_character.data.currentStamina, Plugin.GetControlledStaminaFill()); _character.data.extraStamina = 0f; Plugin.ClearAssistJumpState(_character); StabilizeControlledHead(); } if ((Object)(object)_sourceCharacter != (Object)null && (Object)(object)_sourceCharacter.data != (Object)null) { Plugin.SetCharacterDeadWithoutReconnect(_sourceCharacter, dead: false); _sourceCharacter.data.zombified = false; _sourceCharacter.data.passedOut = false; _sourceCharacter.data.fullyPassedOut = false; _sourceCharacter.data.fallSeconds = 0f; Plugin.ClearAssistJumpState(_sourceCharacter); } } private bool IsControlPausedByIncapacitation() { return Plugin.IsControlledScoutmasterIncapacitated(_character); } private void ClearActiveControlInputs() { if ((Object)(object)_character == (Object)null) { return; } try { if ((Object)(object)_character.input != (Object)null) { _character.input.usePrimaryIsPressed = false; _character.input.usePrimaryWasPressed = false; _character.input.useSecondaryIsPressed = false; _character.input.useSecondaryWasPressed = false; _character.input.useSecondaryWasReleased = false; _character.input.sprintIsPressed = false; _character.input.sprintWasPressed = false; _character.input.jumpWasPressed = false; } if ((Object)(object)_character.data != (Object)null) { _character.data.isReaching = false; _character.data.isSprinting = false; } _reachHoldStartTime = 0f; _reachWasHeld = false; _climbWasHeld = false; } catch { } } private void StabilizeControlledHead() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_007c: 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_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_character == (Object)null) && !((Object)(object)_character.data == (Object)null)) { Vector3 val = ResolveStableLookDirection(); Vector3 val2 = Vector3.ProjectOnPlane(val, Vector3.up); if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.ProjectOnPlane(((Component)_character).transform.forward, Vector3.up); } if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.forward; } ((Vector3)(ref val)).Normalize(); ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(Vector3.up, val); if (!IsFiniteVector(val3) || ((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.Cross(Vector3.up, val2); } if (!IsFiniteVector(val3) || ((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.right; } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.Cross(val, val3); if (!IsFiniteVector(val4) || ((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.up; } else { ((Vector3)(ref val4)).Normalize(); } _character.data.lookDirection = val; _character.data.lookDirection_Flat = val2; _character.data.lookDirection_Right = val3; _character.data.lookDirection_Up = val4; AlignHeadToLookDirection(val, val4); } } private Vector3 ResolveStableLookDirection() { //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_0011: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _character.data.lookDirection; if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = _character.data.lookDirection_Flat; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)_character).transform.forward; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : Vector3.zero); } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = _lastStableLookDirection; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); _lastStableLookDirection = val; return val; } private void AlignHeadToLookDirection(Vector3 lookDirection, Vector3 up) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_0069: 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_007c: 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_008c: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) Bodypart val = _character.refs?.head ?? Plugin.GetBodypart(_character, (BodypartType)4); Rigidbody val2 = (((Object)(object)val != (Object)null) ? val.Rig : null); Transform val3 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null); if ((Object)(object)val2 == (Object)null && (Object)(object)val3 == (Object)null) { return; } Quaternion val4 = BuildLookRotation(lookDirection, up); if (IsFiniteQuaternion(val4)) { Quaternion val5 = (((Object)(object)val2 != (Object)null) ? val2.rotation : val3.rotation); Quaternion rotation = val4; if (IsFiniteQuaternion(val5) && Quaternion.Angle(val5, val4) <= 55f) { float num = ((Time.deltaTime > 0f) ? Mathf.Clamp01(Time.deltaTime * 28f) : 1f); rotation = Quaternion.Slerp(val5, val4, num); } if ((Object)(object)val2 != (Object)null) { val2.rotation = rotation; val2.angularVelocity = Vector3.zero; val2.maxAngularVelocity = 1.5f; val2.WakeUp(); } if ((Object)(object)val3 != (Object)null) { val3.rotation = rotation; SyncHeadAnimationRotation(val); } } } private static Quaternion BuildLookRotation(Vector3 forward, Vector3 up) { //IL_0000: 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_001b: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!IsFiniteVector(forward) || ((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); if (!IsFiniteVector(up) || ((Vector3)(ref up)).sqrMagnitude < 0.0001f) { up = Vector3.up; } ((Vector3)(ref up)).Normalize(); if (Mathf.Abs(Vector3.Dot(forward, up)) > 0.96f) { Vector3 val = Vector3.Cross(Vector3.up, forward); if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.Cross(Vector3.right, forward); } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.right; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(forward, val); up = ((Vector3)(ref val2)).normalized; } return Quaternion.LookRotation(forward, up); } private static void SyncHeadAnimationRotation(Bodypart head) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)head == (Object)null) { return; } try { Quaternion localRotation = ((Component)head).transform.localRotation; BodypartTargetRotationField?.SetValue(head, localRotation); BodypartLastTargetRotationField?.SetValue(head, localRotation); BodypartPrevRotField?.SetValue(head, ((Component)head).transform.rotation); } catch { } } private static bool IsFiniteVector(Vector3 value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) if (IsFiniteFloat(value.x) && IsFiniteFloat(value.y)) { return IsFiniteFloat(value.z); } return false; } private static bool IsFiniteQuaternion(Quaternion value) { //IL_0000: 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_001a: 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) if (IsFiniteFloat(value.x) && IsFiniteFloat(value.y) && IsFiniteFloat(value.z)) { return IsFiniteFloat(value.w); } return false; } private static bool IsFiniteFloat(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private void HandleReachAndThrow() { if (_lastReachFrame == Time.frameCount) { return; } _lastReachFrame = Time.frameCount; FlushPendingRemoteGrabUnattach(); bool flag = IsReachHeld(); bool flag2 = IsReachPressed() || (flag && !_reachWasHeld); bool flag3 = IsReachReleased() || (!flag && _reachWasHeld); bool flag4 = HasHeldTarget(); _reachWasHeld = flag; if ((Object)(object)_character.input != (Object)null) { _character.input.useSecondaryIsPressed = flag; _character.input.useSecondaryWasPressed = flag2; _character.input.useSecondaryWasReleased = flag3; } if (flag2) { _reachHoldStartTime = Time.time; _nextGrabProbeTime = 0f; } if (flag) { _character.data.isReaching = true; _character.data.sincePressReach = 0f; if (!flag4) { flag4 = TryGrabPlayerInView() || HasHeldTarget(); } } else { _character.data.isReaching = false; } if (flag3) { if (flag4) { ThrowHeldPlayer(GetThrowCharge01()); } else { Plugin.BroadcastControlledScoutmasterStopReaching(_character); } } } private bool TryGrabPlayerInView() { //IL_0088: 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) if ((Object)(object)_character?.refs?.grabbing == (Object)null || (Object)(object)_character.data == (Object)null || (Object)(object)_character.data.grabJoint != (Object)null) { return false; } if (Time.time < _nextGrabProbeTime) { return false; } ResolveGrabProbe(out var origin, out var direction); bool flag = Plugin.TryGrabControlledScoutmasterTarget(_character.refs.grabbing, _character, _sourceCharacter, origin, ((Vector3)(ref direction)).normalized, 6.5f, 1.15f); _nextGrabProbeTime = Time.time + (flag ? 0.2f : 0.08f); return flag; } private void ResolveGrabProbe(out Vector3 origin, out Vector3 direction) { //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_0012: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_007c: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) origin = Plugin.ResolveControlledGrabHandPosition(_character); if (!IsFiniteVector(origin) || ((Vector3)(ref origin)).sqrMagnitude < 0.0001f) { origin = _character.Head; } if (!IsFiniteVector(origin) || ((Vector3)(ref origin)).sqrMagnitude < 0.0001f) { origin = _character.Center + Vector3.up * 0.7f; } direction = Vector3.zero; Camera main = Camera.main; if ((Object)(object)main != (Object)null) { Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; if (IsFiniteVector(position) && IsFiniteVector(forward) && ((Vector3)(ref forward)).sqrMagnitude > 0.0001f) { float num = 6.5f + Mathf.Clamp(Plugin.ThirdPersonDistance.Value, 2f, 16f) + 2f; Vector3 val = position + ((Vector3)(ref forward)).normalized * num; direction = val - origin; } } if (!IsFiniteVector(direction) || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = _character.data.lookDirection; } if (!IsFiniteVector(direction) || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = _character.data.lookDirection_Flat; } if (!IsFiniteVector(direction) || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = ((Component)_character).transform.forward; } if (!IsFiniteVector(direction) || ((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { direction = Vector3.forward; } ((Vector3)(ref direction)).Normalize(); } private void HandleClimbInput() { bool flag = IsClimbHeld(); bool flag2 = IsClimbPressed(); bool flag3 = IsClimbReleased() || (_climbWasHeld && !flag); _climbWasHeld = flag; if ((Object)(object)_character.input != (Object)null) { if (flag2) { _character.input.usePrimaryWasPressed = true; } if (!flag && !flag2) { ClearPrimaryClimbInput(released: false); } } if (flag || flag2) { if ((Object)(object)_character.input != (Object)null) { _character.input.usePrimaryIsPressed = true; } try { if ((Object)(object)_character.data.currentItem == (Object)null) { _character.data.sincePressClimb = 0f; } } catch { } if (TryStartLocalClimb() || IsCharacterClimbing()) { ApplyOriginalScoutmasterClimbInput(); } } if (flag3) { ClearPrimaryClimbInput(released: true); if (IsCharacterClimbing()) { Plugin.StopControlledScoutmasterClimb(_character.refs?.climbing, _character, 0f); } } } private bool TryStartLocalClimb() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_013e: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null || (Object)(object)_character.refs?.climbing == (Object)null) { return false; } if (_character.data.isClimbing || _character.data.isRopeClimbing || _character.data.isVineClimbing) { return false; } if ((Object)(object)_character.data.currentItem != (Object)null) { return false; } CharacterClimbing climbing = _character.refs.climbing; if (!Plugin.CanControlledScoutmasterClimb(climbing)) { return false; } Vector3 forward = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : Vector3.zero); if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = _character.data.lookDirection; } if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = _character.data.lookDirection_Flat; } if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = ((Component)_character).transform.forward; } ((Vector3)(ref forward)).Normalize(); if (!TryFindLocalClimbHit(_character.Center, forward, 1.65f, out var climbHit)) { return false; } return Plugin.TryStartControlledScoutmasterClimb(climbing, _character, ((RaycastHit)(ref climbHit)).point, ((RaycastHit)(ref climbHit)).normal, "Local Scoutmaster climb"); } private void ApplyOriginalScoutmasterClimbInput() { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_character?.input == (Object)null) && !((Object)(object)_character.data == (Object)null)) { Vector2 movementInput = _character.input.movementInput; movementInput.y = Mathf.Max(movementInput.y, 1f); _character.input.movementInput = movementInput; _character.data.currentStamina = Mathf.Max(_character.data.currentStamina, Plugin.GetControlledStaminaFill()); } } private void ApplyOriginalScoutmasterSprintInput() { //IL_0048: 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_0072: 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_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character?.input == (Object)null || (Object)(object)_character.data == (Object)null) { return; } if (IsCharacterClimbing()) { _character.data.isSprinting = false; return; } Vector2 val = ReadCurrentMovementInput(); if (((Vector2)(ref val)).sqrMagnitude <= 0.0001f) { val = _character.input.movementInput; } bool num = IsSprintHeld(); bool flag = val.y > 0.01f; if (!num || !flag) { _character.data.isSprinting = false; return; } _character.input.sprintIsPressed = true; if (IsSprintPressed()) { _character.input.sprintWasPressed = true; } _character.data.isCrouching = false; _character.data.isSprinting = true; _character.data.currentStamina = Mathf.Max(_character.data.currentStamina, Plugin.GetControlledStaminaFill()); } private static Vector2 ReadCurrentMovementInput() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_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) //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) Vector2 val = Vector2.zero; try { if (CharacterInput.action_move != null) { val += CharacterInput.action_move.ReadValue(); } } catch { } try { if (CharacterInput.action_moveForward != null && CharacterInput.action_moveForward.IsPressed()) { val += Vector2.up; } if (CharacterInput.action_moveBackward != null && CharacterInput.action_moveBackward.IsPressed()) { val -= Vector2.up; } if (CharacterInput.action_moveRight != null && CharacterInput.action_moveRight.IsPressed()) { val += Vector2.right; } if (CharacterInput.action_moveLeft != null && CharacterInput.action_moveLeft.IsPressed()) { val -= Vector2.right; } } catch { } if (((Vector2)(ref val)).sqrMagnitude <= 0.0001f) { if (Input.GetKey((KeyCode)119) || Input.GetKey((KeyCode)273)) { val += Vector2.up; } if (Input.GetKey((KeyCode)115) || Input.GetKey((KeyCode)274)) { val -= Vector2.up; } if (Input.GetKey((KeyCode)100) || Input.GetKey((KeyCode)275)) { val += Vector2.right; } if (Input.GetKey((KeyCode)97) || Input.GetKey((KeyCode)276)) { val -= Vector2.right; } } return Vector2.ClampMagnitude(val, 1f); } private bool TryFindLocalClimbHit(Vector3 origin, Vector3 forward, float distance, out RaycastHit climbHit) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) climbHit = default(RaycastHit); RaycastHit[] array; try { array = Physics.RaycastAll(origin, forward, Mathf.Max(distance, 0.25f), -1, (QueryTriggerInteraction)1); } catch { return false; } if (array == null || array.Length == 0) { return false; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !((RaycastHit)(ref val)).collider.isTrigger) { Character val2 = ResolveHitCharacter(val); if (!((Object)(object)val2 == (Object)(object)_character) && !((Object)(object)val2 == (Object)(object)_sourceCharacter) && !(Vector3.Dot(((RaycastHit)(ref val)).normal, Vector3.up) > 0.75f)) { climbHit = val; return true; } } } return false; } private void EnsureClimbSurfaceStillValid() { //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) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!IsCharacterClimbing() || (Object)(object)_character.refs?.climbing == (Object)null) { return; } if (!IsClimbHeld()) { Plugin.StopControlledScoutmasterClimb(_character.refs.climbing, _character, 0f); } else if (!_character.data.isRopeClimbing && !_character.data.isVineClimbing) { Vector3 center = _character.Center; if (TryFindCurrentClimbSurface(center, out var _)) { _character.data.sinceCanClimb = 0f; } else { Plugin.StopControlledScoutmasterClimb(_character.refs.climbing, _character, 0f); } } } private bool TryFindCurrentClimbSurface(Vector3 origin, out RaycastHit climbHit) { //IL_0001: 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_0036: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) climbHit = default(RaycastHit); Vector3[] array = (Vector3[])(object)new Vector3[4] { -_character.data.climbNormal, _character.data.lookDirection, _character.data.lookDirection_Flat, ((Component)_character).transform.forward }; for (int i = 0; i < array.Length; i++) { Vector3 forward = array[i]; if (!(((Vector3)(ref forward)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref forward)).Normalize(); if (TryFindLocalClimbHit(origin, forward, 2.25f, out climbHit)) { return true; } } } return false; } private Character ResolveHitCharacter(RaycastHit hit) { if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { return null; } Character componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } Bodypart componentInParent2 = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent(); if ((Object)(object)componentInParent2 == (Object)null || BodypartCharacterField == null) { return null; } try { object? value = BodypartCharacterField.GetValue(componentInParent2); return (Character)((value is Character) ? value : null); } catch { return null; } } private bool IsCharacterClimbing() { if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { if (!_character.data.isClimbing && !_character.data.isRopeClimbing) { return _character.data.isVineClimbing; } return true; } return false; } private void KeepGroundedFeetAligned() { //IL_00da: 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) if (_lastGroundingFrame == Time.frameCount) { return; } _lastGroundingFrame = Time.frameCount; if ((Object)(object)_character == (Object)null || (Object)(object)_character.data == (Object)null || IsCharacterClimbing() || IsControlPausedByIncapacitation() || !IsStableGrounded() || !TryResolveControlledGroundY(out var groundY) || !TryGetControlledFootBottomY(out var footBottomY)) { return; } bool isCrouching = _character.data.isCrouching; float num = groundY + 0.03f - footBottomY; float num2 = (isCrouching ? 0.025f : 0.055f); if (!(num >= 0f - num2)) { float num3 = (isCrouching ? 0.35f : 0.22f); float num4 = Mathf.Max(num, 0f - num3); if (Time.deltaTime > 0f) { num4 *= Mathf.Clamp01(Time.deltaTime * 18f); } OffsetControlledBody(Vector3.up * num4); if (isCrouching) { _character.data.currentHeadHeight = Mathf.Max(0f, _character.data.currentHeadHeight + num4); } } } private bool IsStableGrounded() { if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { if (!_character.data.isGrounded && !(_character.data.sinceGrounded <= 0.12f)) { return _character.data.groundedFor > 0f; } return true; } return false; } private bool TryResolveControlledGroundY(out float groundY) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) groundY = 0f; if ((Object)(object)_character == (Object)null) { return false; } Vector3 center = _character.Center; if (TryRaycastControlledGroundY(center, out groundY)) { return true; } BodypartType[] groundedFootParts = GroundedFootParts; foreach (BodypartType bodypartType in groundedFootParts) { Vector3 origin = ResolveBodypartProbeOrigin(Plugin.GetBodypart(_character, bodypartType)); if (TryRaycastControlledGroundY(origin, out groundY)) { return true; } } if ((Object)(object)_character.data != (Object)null && IsFiniteVector(_character.data.groundPos)) { Vector3 groundPos = _character.data.groundPos; Vector3 val = Vector3.ProjectOnPlane(groundPos - center, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude <= 36f && Mathf.Abs(groundPos.y - center.y) <= 10f) { groundY = groundPos.y; return true; } } groundY = 0f; return false; } private bool TryRaycastControlledGroundY(Vector3 origin, out float groundY) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) groundY = 0f; if (!IsFiniteVector(origin)) { return false; } RaycastHit[] array; try { array = Physics.RaycastAll(origin + Vector3.up * 2.5f, Vector3.down, 9f, -1, (QueryTriggerInteraction)1); } catch { return false; } if (array == null || array.Length == 0) { return false; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit hit = array2[i]; if (!((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) && !((RaycastHit)(ref hit)).collider.isTrigger && !(Vector3.Dot(((RaycastHit)(ref hit)).normal, Vector3.up) < 0.2f)) { Character val = ResolveHitCharacter(hit); if (!((Object)(object)val == (Object)(object)_character) && !((Object)(object)val == (Object)(object)_sourceCharacter)) { groundY = ((RaycastHit)(ref hit)).point.y; return true; } } } return false; } private static Vector3 ResolveBodypartProbeOrigin(Bodypart part) { //IL_0009: 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_0023: 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_004f: 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) if ((Object)(object)part == (Object)null) { return Vector3.zero; } if ((Object)(object)part.Rig != (Object)null && IsFiniteVector(part.Rig.worldCenterOfMass)) { return part.Rig.worldCenterOfMass; } Vector3 position = ((Component)part).transform.position; if (!IsFiniteVector(position)) { return Vector3.zero; } return position; } private bool TryGetControlledFootBottomY(out float footBottomY) { //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) footBottomY = 0f; bool flag = false; BodypartType[] groundedFootParts = GroundedFootParts; foreach (BodypartType bodypartType in groundedFootParts) { Bodypart bodypart = Plugin.GetBodypart(_character, bodypartType); if (!((Object)(object)bodypart == (Object)null) && TryGetBodypartBottomY(bodypart, out var bottomY) && (!flag || bottomY < footBottomY)) { footBottomY = bottomY; flag = true; } } return flag; } private static bool TryGetBodypartBottomY(Bodypart part, out float bottomY) { //IL_00a8: 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_00ad: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) bottomY = 0f; if ((Object)(object)part == (Object)null) { return false; } bool flag = false; Collider[] array = null; try { array = ((Component)part).GetComponentsInChildren(true); } catch { } if (array != null) { Collider[] array2 = array; foreach (Collider val in array2) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 min = ((Bounds)(ref bounds)).min; if (IsFiniteVector(min) && (!flag || min.y < bottomY)) { bottomY = min.y; flag = true; } } } } Vector3 val2 = (((Object)(object)part.Rig != (Object)null) ? part.Rig.worldCenterOfMass : ((Component)part).transform.position); if (IsFiniteVector(val2) && (!flag || val2.y < bottomY)) { bottomY = val2.y; flag = true; } return flag; } private void OffsetControlledBody(Vector3 delta) { //IL_000e: 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_0038: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_character == (Object)null || !IsFiniteVector(delta) || ((Vector3)(ref delta)).sqrMagnitude < 1E-06f) { return; } try { Transform transform = ((Component)_character).transform; transform.position += delta; if (_character.refs?.ragdoll?.partList == null) { return; } foreach (Bodypart part in _character.refs.ragdoll.partList) { if ((Object)(object)part == (Object)null) { continue; } Rigidbody rig = part.Rig; if ((Object)(object)rig != (Object)null) { rig.position += delta; if (!rig.isKinematic) { Vector3 linearVelocity = rig.linearVelocity; if (IsFiniteVector(linearVelocity) && linearVelocity.y > 0f) { linearVelocity.y = 0f; rig.linearVelocity = linearVelocity; } } rig.WakeUp(); } else { Transform transform2 = ((Component)part).transform; transform2.position += delta; } } } catch { } } private void ClearPrimaryClimbInput(bool released) { if (!((Object)(object)_character?.input == (Object)null)) { _character.input.usePrimaryIsPressed = false; _character.input.usePrimaryWasPressed = false; if (released) { _character.input.usePrimaryWasReleased = true; } } } private static bool IsClimbHeld() { try { if (CharacterInput.action_usePrimary != null && CharacterInput.action_usePrimary.IsPressed()) { return true; } } catch { } return Input.GetKey((KeyCode)323); } private static bool IsClimbPressed() { try { if (CharacterInput.action_usePrimary != null && CharacterInput.action_usePrimary.WasPressedThisFrame()) { return true; } } catch { } return Input.GetKeyDown((KeyCode)323); } private static bool IsClimbReleased() { try { if (CharacterInput.action_usePrimary != null && CharacterInput.action_usePrimary.WasReleasedThisFrame()) { return true; } } catch { } return Input.GetKeyUp((KeyCode)323); } private static bool IsReachHeld() { try { if (CharacterInput.action_useSecondary != null && CharacterInput.action_useSecondary.IsPressed()) { return true; } } catch { } return Input.GetKey((KeyCode)324); } private static bool IsReachPressed() { try { if (CharacterInput.action_useSecondary != null && CharacterInput.action_useSecondary.WasPressedThisFrame()) { return true; } } catch { } return Input.GetKeyDown((KeyCode)324); } private static bool IsReachReleased() { try { if (CharacterInput.action_useSecondary != null && CharacterInput.action_useSecondary.WasReleasedThisFrame()) { return true; } } catch { } return Input.GetKeyUp((KeyCode)324); } private static bool IsSprintHeld() { try { if (CharacterInput.action_sprint != null && CharacterInput.action_sprint.IsPressed()) { return true; } } catch { } if (!Input.GetKey((KeyCode)304)) { return Input.GetKey((KeyCode)303); } return true; } private static bool IsSprintPressed() { try { if (CharacterInput.action_sprint != null && CharacterInput.action_sprint.WasPressedThisFrame()) { return true; } } catch { } if (!Input.GetKeyDown((KeyCode)304)) { return Input.GetKeyDown((KeyCode)303); } return true; } private void ThrowHeldPlayer(float charge01) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_017e: Unknown result type (might be due to invalid IL or missing references) if (IsControlPausedByIncapacitation() || Time.time - _lastThrowTime < 0.25f) { return; } _lastThrowTime = Time.time; Character grabbedPlayer = GetGrabbedPlayer(_character); if (!HasHeldTarget() || (Object)(object)_character.refs?.grabbing == (Object)null) { return; } Vector3 val = (((Object)(object)_character.data != (Object)null) ? (-_character.data.lookDirection) : Vector3.zero); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = (((Object)(object)_character.data != (Object)null) ? (-_character.data.lookDirection_Flat) : Vector3.zero); } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)_character).transform.forward; } val = Vector3.ProjectOnPlane(val, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.ProjectOnPlane(((Component)_character).transform.forward, Vector3.up); } if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); val.y = Plugin.ThrowUpBias.Value; Vector3 val2 = val * Plugin.ThrowForce.Value; try { GrabbingThrowMethod?.Invoke(_character.refs.grabbing, new object[2] { val2, Plugin.ThrowFallSeconds.Value }); _pendingRemoteGrabUnattachFrame = Time.frameCount + 1; _character.data.isReaching = false; _reachHoldStartTime = 0f; ScoutmasterChillForSecondsField?.SetValue(_scoutmaster, 0.5f); string text = (((Object)(object)grabbedPlayer != (Object)null) ? grabbedPlayer.characterName : "held player"); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[I'm Scoutmaster] Threw " + text + " with original Scoutmaster force.")); } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[I'm Scoutmaster] Throw failed: " + ex.Message)); } } } private void FlushPendingRemoteGrabUnattach() { if (_pendingRemoteGrabUnattachFrame >= 0 && Time.frameCount >= _pendingRemoteGrabUnattachFrame) { _pendingRemoteGrabUnattachFrame = -1; Plugin.BroadcastControlledScoutmasterGrabUnattach(_character); Plugin.BroadcastControlledScoutmasterStopReaching(_character); } } private static Character GetGrabbedPlayer(Character character) { if ((Object)(object)character?.data == (Object)null || CharacterDataGrabbedPlayerField == null) { return null; } try { object? value = CharacterDataGrabbedPlayerField.GetValue(character.data); return (Character)((value is Character) ? value : null); } catch { return null; } } private bool HasHeldTarget() { if ((Object)(object)_character != (Object)null && (Object)(object)_character.data != (Object)null) { if (!((Object)(object)_character.data.grabJoint != (Object)null)) { return (Object)(object)GetGrabbedPlayer(_character) != (Object)null; } return true; } return false; } private float GetThrowCharge01() { if (_reachHoldStartTime <= 0f) { return 0f; } return Mathf.Clamp01(Mathf.Max(0f, Time.time - _reachHoldStartTime) / 1.2f); } internal static void ApplyLookDirection(Character character, Vector3 lookDirection) { //IL_0018: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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_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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_015b: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)character == (Object)null) && !((Object)(object)character.data == (Object)null) && IsFiniteVector(lookDirection) && !(((Vector3)(ref lookDirection)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref lookDirection)).Normalize(); Vector3 val = Vector3.ProjectOnPlane(lookDirection, Vector3.up); if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = character.data.lookDirection_Flat; } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.ProjectOnPlane(((Component)character).transform.forward, Vector3.up); } if (!IsFiniteVector(val) || ((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, lookDirection); if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.Cross(Vector3.up, val); } if (!IsFiniteVector(val2) || ((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.right; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(lookDirection, val2); if (!IsFiniteVector(val3) || ((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.up; } else { ((Vector3)(ref val3)).Normalize(); } character.data.lookDirection = lookDirection; character.data.lookDirection_Flat = val; character.data.lookDirection_Right = val2; character.data.lookDirection_Up = val3; ((Component)character).transform.rotation = Quaternion.LookRotation(val, Vector3.up); } } static PlayerScoutmasterController() { BodypartType[] array = new BodypartType[4]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); GroundedFootParts = (BodypartType[])(object)array; } } [HarmonyPatch] public static class ScoutmasterHarmonyPatches { private static Character ResolveCharacter(Component component, Character fieldCharacter) { if ((Object)(object)fieldCharacter != (Object)null) { return fieldCharacter; } if (!((Object)(object)component != (Object)null)) { return null; } return component.GetComponent(); } [HarmonyPatch(typeof(PlayerHandler), "RegisterCharacter")] [HarmonyPrefix] private static bool PlayerHandlerRegisterCharacterPrefix(Character character) { return !Plugin.ShouldSkipCharacterRegistration(character); } [HarmonyPatch(typeof(ReconnectHandler), "UpdateReconnectData")] [HarmonyPrefix] private static bool ReconnectHandlerUpdateReconnectDataPrefix(Character character) { return !Plugin.ShouldSkipReconnectDataUpdate(character); } [HarmonyPatch(typeof(SlipperyJellyfish), "OnTriggerEnter")] [HarmonyPrefix] private static bool SlipperyJellyfishOnTriggerEnterPrefix(Collider other) { return !Plugin.ShouldSuppressSlipperyJellyfishSend(other); } [HarmonyPatch(typeof(SlipperyJellyfish), "Trigger")] [HarmonyPrefix] private static bool SlipperyJellyfishTriggerPrefix(int targetID) { return !Plugin.ShouldSkipSlipperyJellyfishTrigger(targetID); } [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPrefix] private static bool CharacterAwakePrefix(Character __instance) { Plugin.EnsureControlledScoutmasterRegistered(__instance); if (!Plugin.ShouldUseIsolatedCharacterLifecycle(__instance)) { return true; } Plugin.RunIsolatedCharacterAwake(__instance); return false; } [HarmonyPatch(typeof(Character), "Start")] [HarmonyPrefix] private static bool CharacterStartPrefix(Character __instance) { Plugin.EnsureControlledScoutmasterRegistered(__instance); if (!Plugin.ShouldUseIsolatedCharacterLifecycle(__instance)) { return true; } Plugin.RunIsolatedCharacterStart(__instance); return false; } [HarmonyPatch(typeof(CharacterData), "Awake")] [HarmonyPrefix] private static bool CharacterDataAwakePrefix(CharacterData __instance) { Character character = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent() : null); Plugin.EnsureControlledScoutmasterRegistered(character); if (!Plugin.ShouldUseIsolatedCharacterLifecycle(character)) { return true; } Plugin.RunIsolatedCharacterDataAwake(__instance, character); return false; } [HarmonyPatch(typeof(CharacterData), "SetBadgeStatus")] [HarmonyPrefix] private static bool CharacterDataSetBadgeStatusPrefix(CharacterData __instance) { return !Plugin.ShouldSkipControlledScoutmasterBadgeStatus(__instance); } [HarmonyPatch(typeof(CharacterCustomization), "Start")] [HarmonyPrefix] private static bool CharacterCustomizationStartPrefix(CharacterCustomization __instance) { return !Plugin.ShouldSkipControlledScoutmasterCustomization(__instance); } [HarmonyPatch(typeof(CharacterCustomization), "OnDestroy")] [HarmonyPrefix] private static bool CharacterCustomizationOnDestroyPrefix(CharacterCustomization __instance) { return !Plugin.ShouldSkipControlledScoutmasterCustomization(__instance); } [HarmonyPatch(typeof(Scoutmaster), "Update")] [HarmonyPrefix] private static bool ScoutmasterUpdatePrefix(Scoutmaster __instance) { return !Plugin.IsControlledScoutmaster(__instance); } [HarmonyPatch(typeof(Scoutmaster), "FixedUpdate")] [HarmonyPrefix] private static bool ScoutmasterFixedUpdatePrefix(Scoutmaster __instance) { return !Plugin.IsControlledScoutmaster(__instance); } [HarmonyPatch(typeof(Scoutmaster), "SetCurrentTarget")] [HarmonyPrefix] private static bool ScoutmasterSetCurrentTargetPrefix(Scoutmaster __instance) { return !Plugin.IsControlledScoutmaster(__instance); } [HarmonyPatch(typeof(Scoutmaster), "RPCA_SetCurrentTarget")] [HarmonyPrefix] private static bool ScoutmasterRpcSetCurrentTargetPrefix(Scoutmaster __instance) { return !Plugin.IsControlledScoutmaster(__instance); } [HarmonyPatch(typeof(CharacterBackpackHandler), "LateUpdate")] [HarmonyPrefix] private static bool CharacterBackpackHandlerLateUpdatePrefix(CharacterBackpackHandler __instance, Character ___character) { if (!Plugin.ShouldDisableInventoryForCharacter(ResolveCharacter((Component)(object)__instance, ___character))) { return true; } if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.backpack != (Object)null) { __instance.backpack.SetActive(false); } return false; } [HarmonyPatch(typeof(CharacterBackpackHandler), "StashInBackpack")] [HarmonyPrefix] private static bool CharacterBackpackHandlerStashInBackpackPrefix(CharacterBackpackHandler __instance, Character ___character, Character interactor) { if (!Plugin.ShouldDisableInventoryForCharacter(ResolveCharacter((Component)(object)__instance, ___character))) { return !Plugin.ShouldDisableInventoryForCharacter(interactor); } return false; } [HarmonyPatch(typeof(CharacterBackpackHandler), "RPCAddItemToCharacterBackpack")] [HarmonyPrefix] private static bool CharacterBackpackHandlerAddItemPrefix(CharacterBackpackHandler __instance, Character ___character) { return !Plugin.ShouldDisableInventoryForCharacter(ResolveCharacter((Component)(object)__instance, ___character)); } [HarmonyPatch(typeof(CharacterItems), "Update")] [HarmonyPrefix] private static bool CharacterItemsUpdatePrefix(CharacterItems __instance, Character ___character) { Character character = ResolveCharacter((Component)(object)__instance, ___character); if (!Plugin.ShouldDisableInventoryForCharacter(character)) { return true; } Plugin.ResetDisabledInventoryState(__instance, character); return false; } [HarmonyPatch(typeof(CharacterItems), "FixedUpdate")] [HarmonyPrefix] private static bool CharacterItemsFixedUpdatePrefix(CharacterItems __instance, Character ___character) { Character character = ResolveCharacter((Component)(object)__instance, ___character); if (!Plugin.ShouldDisableInventoryForCharacter(character)) { return true; } Plugin.ResetDisabledInventoryState(__instance, character); return false; } [HarmonyPatch(typeof(CharacterItems), "EquipSlot")] [HarmonyPrefix] private static bool CharacterItemsEquipSlotPrefix(CharacterItems __instance, Character ___character) { Character character = ResolveCharacter((Component)(object)__instance, ___character); if (!Plugin.ShouldDisableInventoryForCharacter(character)) { return true; } Plugin.ResetDisabledInventoryState(__instance, character); return false; } [HarmonyPatch(typeof(CharacterItems), "Equip")] [HarmonyPrefix] private static bool CharacterItemsEquipPrefix(CharacterItems __instance, Character ___character, ref Item __result) { Character character = ResolveCharacter((Component)(object)__instance, ___character); if (!Plugin.ShouldDisableInventoryForCharacter(character)) { return true; } Plugin.ResetDisabledInventoryState(__instance, character); __result = null; return false; } [HarmonyPatch(typeof(Item), "Interact")] [HarmonyPrefix] private static bool ItemInteractPrefix(Character interactor) { return !Plugin.ShouldDisableInventoryForCharacter(interactor); } [HarmonyPatch(typeof(Item), "IsInteractible")] [HarmonyPostfix] private static void ItemIsInteractiblePostfix(Character interactor, ref bool __result) { if (Plugin.ShouldDisableInventoryForCharacter(interactor)) { __result = false; } } [HarmonyPatch(typeof(CharacterMovement), "TryToJump")] [HarmonyPrefix] private static bool CharacterMovementTryToJumpPrefix(Character ___character) { return !Plugin.TryHandleControlledScoutmasterJump(___character); } [HarmonyPatch(typeof(CharacterMovement), "JumpRpc")] [HarmonyPrefix] private static bool CharacterMovementJumpRpcPrefix(Character ___character) { return !Plugin.ShouldSuppressControlledScoutmasterJumpRpc(___character); } [HarmonyPatch(typeof(CharacterClimbing), "TryToStartWallClimb")] [HarmonyPrefix] private static bool CharacterClimbingTryToStartWallClimbPrefix(CharacterClimbing __instance, Character ___character, bool forceAttempt, Vector3 overide, bool botGrab, float raycastDistance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return !Plugin.TryHandleControlledScoutmasterStartWallClimb(__instance, ___character, forceAttempt, overide, botGrab, raycastDistance); } [HarmonyPatch(typeof(CharacterClimbing), "StopClimbingRpc")] [HarmonyPrefix] private static bool CharacterClimbingStopClimbingRpcPrefix(CharacterClimbing __instance, Character ___character, float setFall) { return !Plugin.TryHandleControlledScoutmasterStopClimb(__instance, ___character, setFall); } [HarmonyPatch(typeof(CharacterGrabbing), "Update")] [HarmonyPrefix] private static bool CharacterGrabbingUpdatePrefix(CharacterGrabbing __instance, Character ___character) { return !Plugin.TryHandleControlledScoutmasterGrabbingUpdate(__instance, ResolveCharacter((Component)(object)__instance, ___character)); } [HarmonyPatch(typeof(CharacterGrabbing), "GrabAction")] [HarmonyPrefix] private static bool CharacterGrabbingGrabActionPrefix(CharacterGrabbing __instance, Character ___character, Collision collision) { return !Plugin.TryHandleControlledScoutmasterGrabAction(__instance, ResolveCharacter((Component)(object)__instance, ___character), collision); } [HarmonyPatch(typeof(Character), "GetCameraPos")] [HarmonyPostfix] private static void CharacterGetCameraPosPostfix(Character __instance, ref Vector3 __result) { Plugin.TryApplyCameraOverride(__instance, ref __result); } [HarmonyPatch(typeof(MainCameraMovement), "LateUpdate")] [HarmonyPostfix] private static void MainCameraMovementLateUpdatePostfix(MainCameraMovement __instance) { Plugin.RefreshControlledScoutmasterCamera(__instance); } [HarmonyPatch(typeof(GUIManager), "UpdateReticle")] [HarmonyPrefix] private static void GUIManagerUpdateReticlePrefix(ref Character ___character) { Character controlledScoutmasterCharacter = Plugin.GetControlledScoutmasterCharacter(); if ((Object)(object)controlledScoutmasterCharacter != (Object)null) { Character.localCharacter = controlledScoutmasterCharacter; ___character = controlledScoutmasterCharacter; } } [HarmonyPatch(typeof(CharacterMovement), "Update")] [HarmonyPrefix] private static bool CharacterMovementUpdatePrefix(Character ___character) { return !Plugin.ShouldSkipCharacterMovementUpdate(___character); } [HarmonyPatch(typeof(Character), "FixedUpdate")] [HarmonyPrefix] private static bool CharacterFixedUpdatePrefix(Character __instance) { return !Plugin.ShouldSkipCharacterFixedUpdate(__instance); } [HarmonyPatch(typeof(CharacterSyncer), "Update")] [HarmonyPrefix] private static bool CharacterSyncerUpdatePrefix(Character ___m_character) { return !Plugin.ShouldSkipCharacterNetworkInterpolation(___m_character); } [HarmonyPatch(typeof(CharacterSyncer), "FixedUpdate")] [HarmonyPrefix] private static bool CharacterSyncerFixedUpdatePrefix(Character ___m_character) { return !Plugin.ShouldSkipCharacterNetworkInterpolation(___m_character); } [HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")] [HarmonyPrefix] private static bool CharacterAfflictionsUpdateWeightPrefix(CharacterAfflictions __instance, Character ___character) { return !Plugin.ShouldSkipCharacterAfflictionWeightUpdate(__instance, ___character); } [HarmonyPatch(typeof(CharacterMovement), "CheckFallDamage")] [HarmonyPrefix] private static bool CharacterMovementCheckFallDamagePrefix(Character ___character) { return !Plugin.ShouldSuppressControlledCharacterFall(___character); } [HarmonyPatch(typeof(Character), "Fall", new Type[] { typeof(float), typeof(float) })] [HarmonyPrefix] private static bool CharacterFallPrefix(Character __instance) { return !Plugin.ShouldSuppressControlledCharacterFall(__instance); } [HarmonyPatch(typeof(Character), "RPCA_Fall")] [HarmonyPrefix] private static bool CharacterRpcFallPrefix(Character __instance) { return !Plugin.ShouldSuppressControlledCharacterFall(__instance); } [HarmonyPatch(typeof(Character), "RPCA_FallWithScreenShake")] [HarmonyPrefix] private static bool CharacterRpcFallWithScreenShakePrefix(Character __instance) { return !Plugin.ShouldSuppressControlledCharacterFall(__instance); } [HarmonyPatch(typeof(Character), "RPCA_PassOut")] [HarmonyPrefix] private static bool CharacterRpcPassOutPrefix(Character __instance) { return !Plugin.ShouldSuppressControlledCharacterFall(__instance); } [HarmonyPatch(typeof(Character), "PassOutInstantly")] [HarmonyPrefix] private static bool CharacterPassOutInstantlyPrefix(Character __instance) { return !Plugin.ShouldSuppressControlledCharacterFall(__instance); } [HarmonyPatch(typeof(Character), "get_IsLocal")] [HarmonyPrefix] private static bool CharacterIsLocalPrefix(Character __instance, ref bool __result) { if (Plugin.IsStashedSourceCharacter(__instance)) { __result = false; return false; } if (Plugin.IsLocallyControlledScoutmasterCharacter(__instance)) { __result = true; return false; } return true; } [HarmonyPatch(typeof(Character), "get_IsPlayerControlled")] [HarmonyPrefix] private static bool CharacterIsPlayerControlledPrefix(Character __instance, ref bool __result) { if (Plugin.IsStashedSourceCharacter(__instance)) { __result = false; return false; } if (Plugin.IsLocallyControlledScoutmasterCharacter(__instance)) { __result = true; return false; } return true; } [HarmonyPatch(typeof(Character), "get_IsRegisteredToPlayer")] [HarmonyPrefix] private static bool CharacterIsRegisteredToPlayerPrefix(Character __instance, ref bool __result) { if (Plugin.IsStashedSourceCharacter(__instance)) { __result = false; return false; } if (Plugin.IsLocallyControlledScoutmasterCharacter(__instance)) { __result = true; return false; } return true; } [HarmonyPatch(typeof(Character), "get_player")] [HarmonyPrefix] private static bool CharacterPlayerPrefix(Character __instance, ref Player __result) { if (Plugin.IsStashedSourceCharacter(__instance)) { __result = null; return false; } if (Plugin.IsLocallyControlledScoutmasterCharacter(__instance) && (Object)(object)Player.localPlayer != (Object)null) { __result = Player.localPlayer; return false; } return true; } [HarmonyPatch(typeof(PlayerHandler), "GetPlayer", new Type[] { typeof(Player) })] [HarmonyPrefix] private static bool PlayerHandlerGetPlayerPrefix(Player photonPlayer, ref Player __result) { if (photonPlayer != null) { return true; } __result = null; return false; } [HarmonyPatch(typeof(Player), "get_character")] [HarmonyPostfix] private static void PlayerCharacterPostfix(Player __instance, ref Character __result) { if ((Object)(object)__instance == (Object)(object)Player.localPlayer) { Character controlledScoutmasterCharacter = Plugin.GetControlledScoutmasterCharacter(); if ((Object)(object)controlledScoutmasterCharacter != (Object)null) { __result = controlledScoutmasterCharacter; } } } [HarmonyPatch(typeof(PlayerHandler), "GetPlayerCharacter")] [HarmonyPostfix] private static void PlayerHandlerGetPlayerCharacterPostfix(Player photonPlayer, ref Character __result) { if (Plugin.TryGetControlledScoutmasterForPhotonPlayer(photonPlayer, out var controlledScoutmaster)) { __result = controlledScoutmaster; } } [HarmonyPatch(typeof(HideTheBody), "SetShowing")] [HarmonyPrefix] private static void HideTheBodySetShowingPrefix(HideTheBody __instance, Character ___character, ref float x) { if (Plugin.ShouldForceShowControlledScoutmaster(__instance, ___character)) { x = 0f; } } [HarmonyPatch(typeof(HideTheBody), "SetShowing")] [HarmonyPostfix] private static void HideTheBodySetShowingPostfix(HideTheBody __instance, Character ___character, Renderer r) { if (Plugin.ShouldForceShowControlledScoutmaster(__instance, ___character)) { Plugin.RefreshHideTheBodyVisuals(__instance); } } [HarmonyPatch(typeof(HideTheBody), "Update")] [HarmonyPostfix] private static void HideTheBodyUpdatePostfix(HideTheBody __instance, Character ___character) { if (Plugin.ShouldForceShowControlledScoutmaster(__instance, ___character)) { Plugin.RefreshHideTheBodyVisuals(__instance); } } } }