using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using Photon.Voice; using REPOLib.Modules; using RepoDoppelganger.Voice; using RepoSteamNetworking.API; using RepoSteamNetworking.Networking; using RepoSteamNetworking.Networking.Serialization; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")] [assembly: IgnoresAccessChecksTo("Unity.Localization")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.ResourceManager")] [assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("REPO.Doppelganger")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.12.0")] [assembly: AssemblyInformationalVersion("0.4.12")] [assembly: AssemblyProduct("REPO.Doppelganger")] [assembly: AssemblyTitle("REPO.Doppelganger")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.12.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoDoppelganger { internal static class CompatibilityFixes { private sealed class EnemyTimerOverride { internal EnemyParent Parent; internal float OriginalTimer; } private const string BrokenSoundPatchType = "loaforcsSoundAPI.REPO.Patches.SoundPatch"; internal static IEnumerator RemoveBrokenSoundApiLoopPrefix(Harmony harmony) { MethodInfo playLoop = AccessTools.Method(typeof(Sound), "PlayLoop", (Type[])null, (Type[])null); if (playLoop == null) { yield break; } float remaining = 8f; while (remaining > 0f) { Type type = (from assembly in AppDomain.CurrentDomain.GetAssemblies() select assembly.GetType("loaforcsSoundAPI.REPO.Patches.SoundPatch", throwOnError: false)).FirstOrDefault((Type type2) => type2 != null); MethodInfo brokenPrefix = ((type == null) ? null : AccessTools.Method(type, "ResetAudioInfoFetched", (Type[])null, (Type[])null)); Patches patchInfo = Harmony.GetPatchInfo((MethodBase)playLoop); if (brokenPrefix != null && patchInfo != null && patchInfo.Prefixes.Any((Patch patch) => patch.PatchMethod == brokenPrefix)) { harmony.Unpatch((MethodBase)playLoop, brokenPrefix); Plugin.Log.LogWarning((object)"Removed loaforcsSoundAPI_REPO's null-unsafe Sound.PlayLoop prefix. Looping vehicle and enemy audio can now run without its repeated NullReferenceException."); break; } remaining -= Time.unscaledDeltaTime; yield return null; } } internal static IEnumerator InstallTimerModCompatibility(Harmony harmony) { float remaining = 8f; while (remaining > 0f) { Type type = (from assembly in AppDomain.CurrentDomain.GetAssemblies() select assembly.GetType("TimerPlugin.EnemyListUI", throwOnError: false)).FirstOrDefault((Type type2) => type2 != null); if (type != null) { MethodInfo methodInfo = AccessTools.Method(typeof(CompatibilityFixes), "TimerEnemyListPrefix", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CompatibilityFixes), "TimerEnemyListFinalizer", (Type[])null, (Type[])null); int num = 0; string[] array = new string[2] { "Fetch", "Update" }; foreach (string text in array) { MethodInfo methodInfo3 = AccessTools.Method(type, text, (Type[])null, (Type[])null); if (!(methodInfo3 == null) && !(methodInfo == null) && !(methodInfo2 == null)) { harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null); num++; } } if (num > 0) { Plugin.Log.LogInfo((object)"TimerMod compatibility enabled: its enemy panel now shows the Doppelganger head's real respawn countdown."); } break; } remaining -= Time.unscaledDeltaTime; yield return null; } } private static void TimerEnemyListPrefix(out List __state) { __state = new List(); EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance == (Object)null || instance.enemiesSpawned == null) { return; } foreach (EnemyParent item in instance.enemiesSpawned) { if (!((Object)(object)item == (Object)null) && !item.Spawned && !((Object)(object)item.Enemy == (Object)null)) { DoppelgangerController component = ((Component)item.Enemy).GetComponent(); if (!((Object)(object)component == (Object)null)) { __state.Add(new EnemyTimerOverride { Parent = item, OriginalTimer = item.DespawnedTimer }); item.DespawnedTimer = (DoppelgangerHeadController.TryGetRemainingRespawnSeconds(component.RuntimeId, out var remaining) ? remaining : Mathf.Min(item.DespawnedTimer, Plugin.RespawnSeconds.Value)); } } } } private static Exception? TimerEnemyListFinalizer(Exception? __exception, List? __state) { if (__state != null) { foreach (EnemyTimerOverride item in __state) { if ((Object)(object)item.Parent != (Object)null) { item.Parent.DespawnedTimer = item.OriginalTimer; } } } return __exception; } internal static void EnsureVehicleTumble(PlayerAvatar? player) { if ((Object)(object)player == (Object)null || (Object)(object)player.tumble == (Object)null || player.tumble.isTumbling) { return; } PlayerController instance = PlayerController.instance; bool debugNoTumble = (Object)(object)instance != (Object)null && instance.DebugNoTumble; if ((Object)(object)instance != (Object)null) { instance.DebugNoTumble = false; } try { if (SemiFunc.IsMasterClientOrSingleplayer()) { player.tumble.TumbleSet(true, false); } else if (player.isLocal) { player.tumble.TumbleRequest(true, false); } } finally { if ((Object)(object)instance != (Object)null) { instance.DebugNoTumble = debugNoTumble; } } if (player.isLocal && (Object)(object)PlayerController.instance != (Object)null) { PlayerController.instance.tumbleInputDisableTimer = Mathf.Max(PlayerController.instance.tumbleInputDisableTimer, 1f); } } } [HarmonyPatch(typeof(ItemVehicle), "SetSeatGrabber")] internal static class ItemVehicleSetSeatCompatibilityPatch { [HarmonyPostfix] private static void Postfix(ItemVehicle __instance, int _seatIndex, PlayerAvatar _playerAvatar) { CompatibilityFixes.EnsureVehicleTumble(_playerAvatar); } } [HarmonyPatch(typeof(ItemVehicle), "Update")] internal static class ItemVehicleUpdateCompatibilityPatch { [HarmonyPrefix] private static void Prefix(ItemVehicle __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 if (__instance.seats == null) { return; } VehicleSeat[] seats = __instance.seats; foreach (VehicleSeat val in seats) { PlayerAvatar val2 = val?.seatedPlayer; if (!((Object)(object)val2 == (Object)null) && (!(val.grabbedTimer <= 0f) || (int)__instance.currentState == 1)) { CompatibilityFixes.EnsureVehicleTumble(val2); if (val.reachedFirstMount && val2.isLocal && (Object)(object)val2.physGrabber != (Object)null) { val2.physGrabber.OverrideColorToGreen(0.15f); } } } } } public sealed class DoppelgangerBrain : MonoBehaviour { private enum DeliveryStage { None, Approach, Carry, Place } private const float VisionRange = 22f; private const float VisionDot = 0.574f; private const float GunDistance = 5.5f; private const float GunMaximumDistance = 20f; private const float MeleeDistance = 3f; private const float AimSettleTime = 0.45f; private const float ShotInterval = 1.5f; private const float WalkSpeed = 2.3f; private const float SprintSpeed = 5.2f; private const float PeacefulFollowDistance = 2.8f; private const float LostSightDuration = 10f; private const float HostileSearchDuration = 90f; private const float SabotageImpactTime = 0.48f; private const float SabotageAnimationTime = 1.05f; private const float HearingRange = 24f; private const float SearchPathGrace = 1.25f; private const float StuckRecoveryTime = 2.25f; private const float CautiousTraversalSpeed = 1.4f; private const float GapProbeMaximumDistance = 9f; private const float GapMaximumWidth = 6.8f; private const float GapApproachDistance = 0.55f; private const float PlayerDoubleJumpThreshold = 4.6f; private const float SafeWalkProbeDepth = 1.45f; private const float SafeWalkLookAhead = 1.35f; private const float SafeWalkHalfWidth = 0.2f; private Enemy _enemy; private EnemyParent _parent; private EnemyHealth _health; private DoppelgangerController _controller; private PlayerAvatar? _combatTarget; private PlayerAvatar? _inspectTarget; private PlayerAvatar? _peacefulTarget; private Vector3 _facing; private Vector3 _lastSeenPosition; private Vector3 _visibleTargetPoint; private Vector3 _investigatePosition; private Vector3 _roamPosition; private Vector3 _searchDestination; private Vector3 _deliveryNavigationPoint; private Vector3 _deliveryDropPoint; private Vector3 _humanMovePoint; private Vector3 _humanDestinationAnchor; private Vector3 _lastAcceptedSoundPosition; private Vector3 _lastSafeNavPosition; private Vector3 _stuckAnchorPosition; private Vector3 _stuckDestination; private Vector3 _lastIssuedDestination; private Vector3 _managedGapStart; private Vector3 _managedGapLanding; private readonly List _searchRoute = new List(); private int _searchRouteIndex; private float _visionTimer; private float _lastSeenTimer; private float _inspectTimer; private float _investigateTimer; private float _roamTimer; private float _aimTimer; private float _shotCooldown; private float _visibilityGraceTimer; private float _jumpCheckTimer; private float _peacefulInteraction; private float _peacefulInteractionLimit; private float _knownTargetTimer; private float _hostileSearchTimer; private float _searchPointTimer; private float _searchScanTimer; private float _searchYaw; private float _sabotageCooldown; private float _sabotageTimer; private float _deliveryCooldown; private float _deliveryTimer; private float _humanMoveTimer; private float _randomJumpTimer; private float _mapInspectCooldown; private float _mapInspectTimer; private float _mapLookTimer; private float _lastAcceptedSoundTime = -100f; private float _searchPathGraceTimer; private float _searchNoPathTimer; private float _safeNavSampleTimer; private float _navRecoveryCooldown; private float _stuckTimer; private float _destinationRefreshTimer; private float _dangerousTraversalTimer; private float _managedGapCooldown; private float _managedDoubleJumpTimer; private float _managedGapSafetyTimer; private float _unsafePathLogCooldown; private bool _targetVisible; private bool _wasPhysicsControlled; private bool _gunMode; private bool _searching = true; private bool _sabotageActive; private bool _sabotageImpactTriggered; private bool _mapInspectActive; private bool _hasSafeNavPosition; private bool _lastMoveSprinting; private bool _dangerousTraversal; private bool _managedGapJumpActive; private bool _managedDoubleJumpPending; private DeliveryStage _deliveryStage; private ValuableObject? _deliveryValuable; private PhysGrabObject? _deliveryObject; private PhysGrabCart? _deliveryCart; private ExtractionPoint? _deliveryExtraction; private PhysGrabCart? _ambientCartTarget; private Vector3 _mapLookPoint; private int _debugSoundSerial; internal bool CanUseAmbientGrab { get { if (!_controller.IsAggressive && !_searching && !_sabotageActive && _deliveryStage == DeliveryStage.None && (Object)(object)_ambientCartTarget == (Object)null) { return !_mapInspectActive; } return false; } } internal Vector3 DebugPosition => Position; internal string DebugState { get { if (_controller.UnderExternalPhysicsControl) { return "Tumble / física externa"; } if (_controller.IsAggressive) { if ((Object)(object)_inspectTarget != (Object)null) { return "Hostil: olhando sob obstáculo"; } if (_searching) { if (!(_investigateTimer > 0f)) { if (!(_searchScanTimer > 0f)) { return "Hostil: vasculhando salas"; } return "Hostil: escaneando sala"; } return "Hostil: investigando som"; } if (_targetVisible) { if (!_gunMode) { return "Hostil: perseguição / melee"; } return "Hostil: mirando / atirando"; } return "Hostil: última posição conhecida"; } if (_sabotageActive) { return "Pacífico: sabotagem"; } if (_mapInspectActive) { return "Pacífico: encenando mapa"; } if (_deliveryStage != DeliveryStage.None) { return $"Pacífico: entrega ({_deliveryStage})"; } if ((Object)(object)_ambientCartTarget != (Object)null) { return "Pacífico: aproximando do KART"; } if (_searching) { if (!(_investigateTimer > 0f)) { if (!(_searchScanTimer > 0f)) { return "Procurando: vasculhando salas"; } return "Procurando: escaneando sala"; } return "Procurando: investigando som"; } if (IsValidPlayer(_peacefulTarget)) { return "Pacífico: seguindo jogador"; } return "Pacífico: livre"; } } internal string DebugObjective { get { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (_deliveryStage != DeliveryStage.None) { string arg = (((Object)(object)_deliveryValuable != (Object)null) ? ((Object)_deliveryValuable).name : "valuable perdido"); string arg2 = (((Object)(object)_deliveryExtraction != (Object)null) ? "extração" : (((Object)(object)_deliveryCart != (Object)null) ? "KART" : "destino perdido")); return $"{_deliveryStage}: {arg} -> {arg2}"; } if (_mapInspectActive) { return "Olhar o mapa e arredores"; } if (_sabotageActive) { if (!_sabotageImpactTriggered) { return "Bater no chão para atrair monstros"; } return "Sabotagem disparada"; } if ((Object)(object)_ambientCartTarget != (Object)null) { return "Alcançar KART " + ((Object)_ambientCartTarget).name; } if (_investigateTimer > 0f) { return "Checar som em " + FormatVector(_investigatePosition); } if (_controller.IsAggressive && IsValidPlayer(_combatTarget)) { return "Atacar " + _combatTarget.playerName; } if (IsValidPlayer(_peacefulTarget)) { return "Seguir " + _peacefulTarget.playerName; } if (_searching) { if (!(_searchScanTimer > 0f)) { return "Ir para sala em " + FormatVector(_searchDestination); } return "Escanear " + FormatVector(_searchDestination); } return "Nenhum"; } } internal float DebugHostilityPercent { get { if (!_controller.IsAggressive) { return Mathf.Clamp01(_peacefulInteraction / Mathf.Max(0.01f, _peacefulInteractionLimit)) * 100f; } return 100f; } } internal float DebugHostilityValue => _peacefulInteraction; internal float DebugHostilityLimit => _peacefulInteractionLimit; internal float DebugLastSeenSeconds => _lastSeenTimer; internal float DebugKnownTargetSeconds => _knownTargetTimer; internal float DebugHostileSearchSeconds => _hostileSearchTimer; internal float DebugInvestigateSeconds => _investigateTimer; internal float DebugSabotageCooldown => _sabotageCooldown; internal float DebugDeliveryCooldown => _deliveryCooldown; internal float DebugMapCooldown => _mapInspectCooldown; internal bool DebugTargetVisible => _targetVisible; internal int DebugSoundSerial => _debugSoundSerial; private Vector3 Position { get { //IL_0026: 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) if (!_enemy.HasRigidbody || !((Object)(object)_enemy.Rigidbody != (Object)null)) { return ((Component)this).transform.position; } return ((Component)_enemy.Rigidbody).transform.position; } } private static string FormatVector(Vector3 value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"{value.x:0.0}, {value.y:0.0}, {value.z:0.0}"; } private void Awake() { //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) _enemy = ((Component)this).GetComponent(); _parent = ((Component)this).GetComponentInParent(); _health = ((Component)this).GetComponent(); _controller = ((Component)this).GetComponent(); _facing = ((Component)this).transform.forward; _roamTimer = Random.Range(1.5f, 3f); _peacefulInteractionLimit = Random.Range(24f, 40f); _sabotageCooldown = Random.Range(180f, 240f); _deliveryCooldown = Random.Range(45f, 100f); _randomJumpTimer = Random.Range(4.5f, 10f); _mapInspectCooldown = Random.Range(30f, 65f); } private void Start() { //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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { _enemy.NavMeshAgent.Agent.stoppingDistance = 0.3f; _enemy.NavMeshAgent.Agent.autoBraking = true; _stuckAnchorPosition = Position; RefreshSafeNavPosition(force: true); } if (_enemy.HasJump && (Object)(object)_enemy.Jump != (Object)null) { _enemy.Jump.gapJump = false; _enemy.Jump.warpAgentOnLand = true; _enemy.Jump.surfaceJump = true; _enemy.Jump.stuckJump = false; _enemy.Jump.surfaceJumpDelay = 0f; _enemy.Jump.surfaceLandDelay = 0f; _enemy.Jump.stuckJumpDelay = 0f; _enemy.Jump.stuckLandDelay = 0f; _enemy.Jump.gapJumpDelay = 0f; _enemy.Jump.gapLandDelay = 0f; } if (_enemy.HasStateInvestigate && (Object)(object)_enemy.StateInvestigate != (Object)null && _enemy.StateInvestigate.onInvestigateTriggered != null) { _enemy.StateInvestigate.onInvestigateTriggered.AddListener(new UnityAction(OnInvestigate)); } } private void Update() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || !_parent.Spawned || _health.healthCurrent <= 0 || _health.dead) { return; } if (!_controller.IsAggressive && _controller.IsBeingGrabbed) { _peacefulInteraction += Time.deltaTime * 4f; TryTriggerInteractionAggression(); } _managedGapCooldown = Mathf.Max(0f, _managedGapCooldown - Time.deltaTime); _dangerousTraversalTimer = Mathf.Max(0f, _dangerousTraversalTimer - Time.deltaTime); _unsafePathLogCooldown = Mathf.Max(0f, _unsafePathLogCooldown - Time.deltaTime); UpdateManagedGapJump(); if (_controller.UnderExternalPhysicsControl) { CancelMapInspection(); if (!_wasPhysicsControlled) { StopMoving(); _wasPhysicsControlled = true; } _gunMode = false; _aimTimer = 0f; _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, Position); return; } if (_wasPhysicsControlled) { _wasPhysicsControlled = false; if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { RecoverAgentToNavMesh("fim do Tumble/física externa", force: true); } _visionTimer = 0f; } _navRecoveryCooldown = Mathf.Max(0f, _navRecoveryCooldown - Time.deltaTime); _destinationRefreshTimer = Mathf.Max(0f, _destinationRefreshTimer - Time.deltaTime); _searchPathGraceTimer = Mathf.Max(0f, _searchPathGraceTimer - Time.deltaTime); RefreshSafeNavPosition(force: false); if (!EnsureAgentOnNavMesh()) { _gunMode = false; _aimTimer = 0f; _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, Position); return; } _shotCooldown = Mathf.Max(0f, _shotCooldown - Time.deltaTime); _visibilityGraceTimer = Mathf.Max(0f, _visibilityGraceTimer - Time.deltaTime); _investigateTimer = Mathf.Max(0f, _investigateTimer - Time.deltaTime); _jumpCheckTimer = Mathf.Max(0f, _jumpCheckTimer - Time.deltaTime); if (_deliveryStage != DeliveryStage.None) { DeliveryUpdate(); return; } if (_sabotageActive) { SabotageUpdate(); return; } if (_controller.IsAggressive) { AggressiveUpdate(); return; } _sabotageCooldown = Mathf.Max(0f, _sabotageCooldown - Time.deltaTime); _deliveryCooldown = Mathf.Max(0f, _deliveryCooldown - Time.deltaTime); _mapInspectCooldown = Mathf.Max(0f, _mapInspectCooldown - Time.deltaTime); if (_mapInspectActive) { MapInspectionUpdate(); } else if (_mapInspectCooldown <= 0f && !_controller.HasGrabTarget) { StartMapInspection(); } else if (_searching) { SearchUpdate(hostile: false); } else { PeacefulUpdate(); } } private void AggressiveUpdate() { //IL_0094: 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_00f0: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0127: 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) _lastSeenTimer = Mathf.Max(0f, _lastSeenTimer - Time.deltaTime); _visionTimer -= Time.deltaTime; if (_visionTimer <= 0f) { _visionTimer = 0.08f; ScanVision(); } if (_searching) { SearchUpdate(hostile: true); return; } if ((Object)(object)_inspectTarget != (Object)null) { _gunMode = false; InspectLowTarget(); return; } if (_targetVisible && IsValidPlayer(_combatTarget)) { _lastSeenPosition = GetTargetPoint(_combatTarget); _lastSeenTimer = 10f; _searching = false; EngageVisibleTarget(_combatTarget); return; } _aimTimer = 0f; _gunMode = false; if (IsValidPlayer(_combatTarget) && _lastSeenTimer > 0f) { if (HorizontalDistance(Position, _lastSeenPosition) > 1.1f) { Face(_lastSeenPosition); MoveTo(_lastSeenPosition, 5.2f, sprint: true); TryJump(_lastSeenPosition); _controller.SetCombatPoseHost(_lastMoveSprinting, crouching: false, gunDrawn: false, _lastSeenPosition); } else { StopMoving(); _searchYaw += Time.deltaTime * 240f; Vector3 val = Position + Quaternion.Euler(0f, _searchYaw, 0f) * Vector3.forward * 4f + Vector3.up * 0.7f; Face(val); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, val); } } else { _combatTarget = null; if (!_searching) { EnterSearch(resetHostility: true); } SearchUpdate(hostile: true); } } internal void ResetPeacefulBehaviourHost() { if (SemiFunc.IsMasterClientOrSingleplayer()) { _combatTarget = null; _inspectTarget = null; _peacefulTarget = null; _targetVisible = false; _lastSeenTimer = 0f; _aimTimer = 0f; _gunMode = false; _peacefulInteraction = 0f; _peacefulInteractionLimit = Random.Range(24f, 40f); _knownTargetTimer = 0f; _hostileSearchTimer = 0f; _sabotageActive = false; CancelMapInspection(); CancelAmbientCartApproach(); CancelDelivery(); EnterSearch(resetHostility: false); } } internal void BeginAggressionHost() { //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) //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) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } CancelMapInspection(); CancelAmbientCartApproach(); CancelDelivery(); _sabotageActive = false; _combatTarget = (IsValidPlayer(_peacefulTarget) ? _peacefulTarget : null); _peacefulTarget = null; _controller.SetPeacefulFollowTargetHost(null); _visionTimer = 0f; _hostileSearchTimer = 90f; if (IsValidPlayer(_combatTarget)) { if (TryGetVisiblePoint(_combatTarget, lowEye: false, out var visiblePoint) || TryGetVisiblePoint(_combatTarget, lowEye: true, out visiblePoint)) { _visibleTargetPoint = visiblePoint; _targetVisible = true; _visibilityGraceTimer = 0.5f; _lastSeenPosition = visiblePoint; _lastSeenTimer = 10f; _searching = false; } else { _combatTarget = null; EnterSearch(resetHostility: true); } } else { EnterSearch(resetHostility: true); } } private void PeacefulUpdate() { //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_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_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_00b1: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0160: 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_0138: Unknown result type (might be due to invalid IL or missing references) if (AmbientCartApproachUpdate()) { return; } if (!IsValidPlayer(_peacefulTarget)) { EnterSearch(resetHostility: false); return; } PlayerAvatar peacefulTarget = _peacefulTarget; Vector3 visiblePoint = Vector3.zero; bool flag = InsideFieldOfView(peacefulTarget) && (TryGetVisiblePoint(peacefulTarget, lowEye: false, out visiblePoint) || TryGetVisiblePoint(peacefulTarget, lowEye: true, out visiblePoint)); if (flag) { _lastSeenPosition = GetPlayerPhysicalPosition(peacefulTarget); _visibleTargetPoint = visiblePoint; _knownTargetTimer = 10f; } else { _knownTargetTimer = Mathf.Max(0f, _knownTargetTimer - Time.deltaTime); if (_knownTargetTimer <= 0f) { EnterSearch(resetHostility: false); return; } } Vector3 val = (flag ? GetPlayerPhysicalPosition(peacefulTarget) : _lastSeenPosition); Vector3 val2 = (flag ? _visibleTargetPoint : (_lastSeenPosition + Vector3.up * 0.6f)); float num = HorizontalDistance(Position, val); Face(val2); if (num > 3.6f) { bool flag2 = num > 10f; MoveTo(val, flag2 ? 5.2f : 2.3f, flag2); TryJump(val); _controller.SetCombatPoseHost(_lastMoveSprinting, crouching: false, gunDrawn: false, val2); } else { StopMoving(); _controller.SetCombatPoseHost(sprinting: false, peacefulTarget.isCrouching || peacefulTarget.isCrawling, gunDrawn: false, val2); } if (num <= 4.2f && flag) { float num2 = 1f; if ((Object)(object)peacefulTarget.voiceChat != (Object)null && peacefulTarget.voiceChat.isTalking) { num2 += 0.75f; } _peacefulInteraction += Time.deltaTime * num2; TryTriggerInteractionAggression(); } else { _peacefulInteraction = Mathf.Max(0f, _peacefulInteraction - Time.deltaTime * 0.15f); } if (_sabotageCooldown <= 0f) { StartSabotage(peacefulTarget); } } private void StartMapInspection() { if (_controller.IsAggressive || _controller.HasGrabTarget) { _mapInspectCooldown = Random.Range(15f, 30f); return; } _mapInspectActive = true; _mapInspectTimer = Random.Range(5.5f, 8f); _mapLookTimer = 0f; _mapInspectCooldown = Random.Range(55f, 105f); StopMoving(); _controller.SetMapInspectHost(active: true); DoppelgangerDebugOverlay.Record(_controller, "MAPA", "abriu o mapa para encenar e observar os arredores"); Plugin.Log.LogDebug((object)"Doppelganger stopped to fake checking the player map."); } private void MapInspectionUpdate() { //IL_0154: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_00a1: 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_011c: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_014d: 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_00a9: 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_00b4: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (_controller.IsAggressive || _controller.UnderExternalPhysicsControl) { CancelMapInspection(); return; } StopMoving(); _mapInspectTimer -= Time.deltaTime; _mapLookTimer -= Time.deltaTime; if (_mapLookTimer <= 0f) { _mapLookTimer = Random.Range(0.75f, 1.45f); if (Random.value < 0.58f) { Vector3 val = ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward); _mapLookPoint = Position + val * 1.15f + Vector3.up * 0.22f; } else { Vector3 val2 = Quaternion.AngleAxis(Random.Range(-105f, 105f), Vector3.up) * ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward); _mapLookPoint = Position + val2 * 4f + Vector3.up * 0.8f; } } Face(_mapLookPoint); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, _mapLookPoint); if (_mapInspectTimer <= 0f) { CancelMapInspection(); } } private void CancelMapInspection() { if (_mapInspectActive) { _mapInspectActive = false; if ((Object)(object)_controller != (Object)null) { _controller.SetMapInspectHost(active: false); DoppelgangerDebugOverlay.Record(_controller, "MAPA", "fechou o mapa"); } } } private void TryTriggerInteractionAggression() { if (!_controller.IsAggressive && _peacefulInteraction >= _peacefulInteractionLimit) { _controller.BecomeAggressiveHost("prolonged interaction with a player"); } } private void EnterSearch(bool resetHostility) { //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) bool searching = _searching; CancelAmbientCartApproach(); _searching = true; _peacefulTarget = null; _combatTarget = null; _inspectTarget = null; _targetVisible = false; _knownTargetTimer = 0f; _lastSeenTimer = 0f; _aimTimer = 0f; _gunMode = false; _controller.SetPeacefulFollowTargetHost(null); if (resetHostility && _controller.IsAggressive && !searching) { _hostileSearchTimer = 90f; DoppelgangerDebugOverlay.Record(_controller, "HOSTILIDADE", $"perdeu o alvo; busca hostil resetada para {90f:0}s"); } if (!searching || _searchRoute.Count == 0 || _searchDestination == Vector3.zero) { BuildSearchRoute(); PickNextSearchPoint(); } } internal void RequestAmbientCartApproachHost(PhysGrabCart cart) { if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)cart == (Object)null) && CanUseAmbientGrab && CartCanBeHandled(cart)) { _ambientCartTarget = cart; } } private bool AmbientCartApproachUpdate() { //IL_005e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_0099: 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_00e7: 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_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_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_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_014c: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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) PhysGrabCart ambientCartTarget = _ambientCartTarget; if ((Object)(object)ambientCartTarget == (Object)null) { return false; } if (_controller.IsAggressive || !CartCanBeHandled(ambientCartTarget)) { CancelAmbientCartApproach(); return false; } Transform val = (((Object)(object)ambientCartTarget.handlePoint != (Object)null) ? ambientCartTarget.handlePoint : ambientCartTarget.cartGrabPoint); if ((Object)(object)val == (Object)null) { CancelAmbientCartApproach(); return false; } Vector3 val2 = val.position - ((Component)ambientCartTarget).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = -((Component)ambientCartTarget).transform.forward; val2.y = 0f; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = val.position + val2 * 0.72f; NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(val3, ref val4, 1.5f, -1)) { val3 = ((NavMeshHit)(ref val4)).position; } Vector3 val5 = ((Component)ambientCartTarget).transform.position + Vector3.up * 0.45f; if (HorizontalDistance(Position, val3) > 0.7f) { Face(val5); MoveTo(val3, 2.3f, sprint: false); TryJump(val3); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, val5); return true; } StopMoving(); Face(val5); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, val5); _ambientCartTarget = null; _controller.BeginAmbientCartGrabHost(ambientCartTarget); return true; } private static bool CartCanBeHandled(PhysGrabCart cart) { PhysGrabObject val = (((Object)(object)cart != (Object)null) ? cart.physGrabObject : null); if ((Object)(object)val != (Object)null && (Object)(object)val.rb != (Object)null && !val.grabbed && !val.grabbedLocal) { return val.playerGrabbing.Count == 0; } return false; } private void CancelAmbientCartApproach() { _ambientCartTarget = null; } private void SearchUpdate(bool hostile) { //IL_00ba: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) _visionTimer -= Time.deltaTime; if (_visionTimer <= 0f) { _visionTimer = 0.08f; ScanVision(); } if ((Object)(object)_inspectTarget != (Object)null) { InspectLowTarget(); if (!hostile && _targetVisible && IsValidPlayer(_combatTarget)) { BeginPeacefulFollow(_combatTarget, _visibleTargetPoint); } return; } if (_targetVisible && IsValidPlayer(_combatTarget)) { if (hostile) { _searching = false; _lastSeenPosition = _visibleTargetPoint; _lastSeenTimer = 10f; EngageVisibleTarget(_combatTarget); } else { BeginPeacefulFollow(_combatTarget, _visibleTargetPoint); } return; } if (hostile) { _hostileSearchTimer = Mathf.Max(0f, _hostileSearchTimer - Time.deltaTime); if (_hostileSearchTimer <= 0f) { _controller.BecomePeacefulHost("its hostile search expired"); return; } } else if (_deliveryCooldown <= 0f) { _deliveryCooldown = Random.Range(70f, 130f); if (Random.value <= 0.45f && TryStartDeliveryScene()) { return; } } if (_investigateTimer > 0f) { Face(_investigatePosition); MoveTo(_investigatePosition, 5.2f, sprint: true); TryJump(_investigatePosition); _controller.SetCombatPoseHost(_lastMoveSprinting, crouching: false, gunDrawn: false, _investigatePosition); if (HorizontalDistance(Position, _investigatePosition) <= 1.3f) { _investigateTimer = 0f; } return; } bool num = HorizontalDistance(Position, _searchDestination) > 1.6f; bool flag = HasUsableNavigationPath(); if (num && _searchPathGraceTimer <= 0f && !flag) { _searchNoPathTimer += Time.deltaTime; } else { _searchNoPathTimer = 0f; } if (_searchDestination == Vector3.zero || _searchPointTimer <= 0f || _searchNoPathTimer >= 1.1f) { PickNextSearchPoint(); } _searchPointTimer -= Time.deltaTime; if (HorizontalDistance(Position, _searchDestination) > 1.35f) { _searchScanTimer = 0f; Face(_searchDestination); MoveTo(_searchDestination, 5.2f, sprint: true); TryJump(_searchDestination); _controller.SetCombatPoseHost(_lastMoveSprinting, crouching: false, gunDrawn: false, _searchDestination); return; } StopMoving(); _searchScanTimer += Time.deltaTime; _searchYaw += Time.deltaTime * 210f; Vector3 val = Position + Quaternion.Euler(0f, _searchYaw, 0f) * Vector3.forward * 4f + Vector3.up * 0.7f; Face(val); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, val); if (_searchScanTimer >= 1.7f) { PickNextSearchPoint(); } } private void BeginPeacefulFollow(PlayerAvatar target, Vector3 visiblePoint) { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) _searching = false; _peacefulTarget = target; _combatTarget = null; _inspectTarget = null; _targetVisible = false; _lastSeenPosition = GetPlayerPhysicalPosition(target); _visibleTargetPoint = visiblePoint; _knownTargetTimer = 10f; _controller.SetPeacefulFollowTargetHost(target); DoppelgangerDebugOverlay.Record(_controller, "VISÃO", "encontrou " + target.playerName + " e começou a seguir"); Plugin.Log.LogDebug((object)("Doppelganger found \"" + target.playerName + "\" naturally and began following.")); } private void BuildSearchRoute() { _searchRoute.Clear(); _searchRouteIndex = 0; if ((Object)(object)LevelGenerator.Instance == (Object)null) { return; } IEnumerable source = from point in LevelGenerator.Instance.LevelPathPoints where (Object)(object)point != (Object)null && (Object)(object)point.Room != (Object)null && !point.Room.Truck group point by point.Room into @group select @group.OrderByDescending((LevelPoint point) => (point.ConnectedPoints != null) ? point.ConnectedPoints.Count : 0).First(); _searchRoute.AddRange(source.OrderBy((LevelPoint _) => Random.value)); } private void PickNextSearchPoint() { //IL_00f8: 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_005d: 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_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_00cb: Unknown result type (might be due to invalid IL or missing references) if (_searchRoute.Count == 0 || _searchRouteIndex >= _searchRoute.Count) { BuildSearchRoute(); } NavMeshHit val2 = default(NavMeshHit); while (_searchRouteIndex < _searchRoute.Count) { LevelPoint val = _searchRoute[_searchRouteIndex++]; if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 4f, -1) && TryResolveReachableDestination(((NavMeshHit)(ref val2)).position, 0.35f, out var reachable)) { _searchDestination = reachable; _searchPointTimer = 18f; _searchScanTimer = 0f; _searchNoPathTimer = 0f; _searchPathGraceTimer = 1.25f; DoppelgangerDebugOverlay.Record(_controller, "PROCURA", "nova sala/rota: " + FormatVector(_searchDestination)); return; } } _searchDestination = Position; _searchPointTimer = 2f; } private void StartSabotage(PlayerAvatar target) { if (!IsValidPlayer(target) || _controller.IsAggressive) { _sabotageCooldown = Random.Range(30f, 60f); return; } _sabotageActive = true; _sabotageImpactTriggered = false; _sabotageTimer = 1.05f; _sabotageCooldown = Random.Range(180f, 240f); _controller.PlaySabotageVisualHost(); StopMoving(); DoppelgangerDebugOverlay.Record(_controller, "SABOTAGEM", "iniciou a encenação de queda"); Plugin.Log.LogDebug((object)"Doppelganger began a peaceful sabotage performance."); } private void SabotageUpdate() { //IL_0025: 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_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_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_00a2: 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_00d2: Unknown result type (might be due to invalid IL or missing references) if (_controller.IsAggressive) { _sabotageActive = false; return; } StopMoving(); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, Position + _facing * 2f); _sabotageTimer -= Time.deltaTime; if (!_sabotageImpactTriggered && _sabotageTimer <= 0.56999993f) { _sabotageImpactTriggered = true; if (IsValidPlayer(_peacefulTarget) && (Object)(object)EnemyDirector.instance != (Object)null) { Vector3 playerPhysicalPosition = GetPlayerPhysicalPosition(_peacefulTarget); AttractAllEnemies(_peacefulTarget, playerPhysicalPosition); DoppelgangerDebugOverlay.Record(_controller, "SABOTAGEM", "impacto: monstros atraídos para " + FormatVector(playerPhysicalPosition)); Plugin.Log.LogInfo((object)$"Doppelganger sabotage attracted enemies to {playerPhysicalPosition}."); } } if (_sabotageTimer <= 0f) { _sabotageActive = false; } } private void AttractAllEnemies(PlayerAvatar target, Vector3 lurePosition) { //IL_0005: 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) EnemyDirector.instance.SetInvestigate(lurePosition, float.MaxValue, false); EnemyParent[] array = Object.FindObjectsOfType(); foreach (EnemyParent val in array) { if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)_parent || !val.Spawned || (Object)(object)val.Enemy == (Object)null) { continue; } Enemy enemy = val.Enemy; if (!enemy.HasStateInvestigate || !((Object)(object)enemy.StateInvestigate != (Object)null)) { if (enemy.HasVision) { enemy.SetChaseTarget(target); } else if (enemy.HasNavMeshAgent && (Object)(object)enemy.NavMeshAgent != (Object)null) { enemy.NavMeshAgent.SetDestination(lurePosition); } } } } private bool TryStartDeliveryScene() { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) if (_controller.IsAggressive || !_searching) { return false; } _deliveryExtraction = (((Object)(object)RoundDirector.instance != (Object)null && RoundDirector.instance.extractionPointActive) ? RoundDirector.instance.extractionPointCurrent : null); _deliveryCart = null; if ((Object)(object)_deliveryExtraction == (Object)null) { _deliveryCart = (from cart in Object.FindObjectsOfType() where (Object)(object)cart != (Object)null && (Object)(object)cart.inCart != (Object)null && (Object)(object)cart.physGrabObject != (Object)null && (Object)(object)cart.physGrabObject.rb != (Object)null orderby HorizontalDistance(Position, ((Component)cart).transform.position) select cart).FirstOrDefault(); } if ((Object)(object)_deliveryExtraction == (Object)null && (Object)(object)_deliveryCart == (Object)null) { return false; } List list = (from valuable in Object.FindObjectsOfType().Where(delegate(ValuableObject valuable) { if ((Object)(object)valuable == (Object)null || !((Component)valuable).gameObject.activeInHierarchy) { return false; } PhysGrabObject component = ((Component)valuable).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.rb == (Object)null || component.rb.isKinematic || component.grabbed || component.grabbedLocal || component.playerGrabbing.Count > 0 || ((Object)(object)component.impactDetector != (Object)null && component.impactDetector.inCart) || (Object)(object)((Component)component).GetComponentInParent() != (Object)null) { return false; } RoomVolumeCheck component2 = ((Component)valuable).GetComponent(); return (Object)(object)component2 == (Object)null || (!component2.inExtractionPoint && !component2.inTruck); }) orderby HorizontalDistance(Position, ((Component)valuable).transform.position) select valuable).Take(12).ToList(); if (list.Count == 0) { return false; } _deliveryValuable = list[Random.Range(0, list.Count)]; _deliveryObject = ((Component)_deliveryValuable).GetComponent(); Vector3 val = ((!((Object)(object)_deliveryExtraction != (Object)null)) ? _deliveryCart.inCart.position : (((Object)(object)_deliveryExtraction.extractionArea != (Object)null) ? _deliveryExtraction.extractionArea.transform.position : ((Component)_deliveryExtraction).transform.position)); _deliveryDropPoint = val + Vector3.up * 0.25f; NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(val, ref val2, 5f, -1)) { _deliveryValuable = null; _deliveryObject = null; _deliveryCart = null; _deliveryExtraction = null; return false; } _deliveryNavigationPoint = ((NavMeshHit)(ref val2)).position; _deliveryStage = DeliveryStage.Approach; _deliveryTimer = 30f; DoppelgangerDebugOverlay.Record(_controller, "DELIVERY", "escolheu " + ((Object)_deliveryValuable).name + " para levar até " + (((Object)(object)_deliveryExtraction != (Object)null) ? "a extração" : "um KART")); Plugin.Log.LogInfo((object)("Doppelganger staged an innocent delivery of \"" + ((Object)_deliveryValuable).name + "\".")); return true; } private void DeliveryUpdate() { //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_00b4: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (_controller.IsAggressive || (Object)(object)_deliveryObject == (Object)null || (Object)(object)_deliveryObject.rb == (Object)null || (Object)(object)_deliveryValuable == (Object)null) { CancelDelivery(); return; } _deliveryTimer -= Time.deltaTime; if (_deliveryTimer <= 0f) { if (_deliveryStage == DeliveryStage.Place) { _controller.EndDirectedGrabHost(); FinishDelivery(); } else { CancelDelivery(); EnterSearch(resetHostility: false); } return; } switch (_deliveryStage) { case DeliveryStage.Approach: { Vector3 centerPoint = _deliveryObject.centerPoint; Face(centerPoint); if (HorizontalDistance(Position, centerPoint) > 1.8f) { MoveTo(centerPoint, 2.3f, sprint: false); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, centerPoint); break; } StopMoving(); if (!_controller.BeginDirectedGrabHost(_deliveryObject, 90f)) { CancelDelivery(); EnterSearch(resetHostility: false); } else { _deliveryStage = DeliveryStage.Carry; _deliveryTimer = 75f; } break; } case DeliveryStage.Carry: if ((Object)(object)_controller.CurrentGrabTarget != (Object)(object)_deliveryObject) { CancelDelivery(); EnterSearch(resetHostility: false); break; } _controller.ClearDirectedGrabPointHost(); Face(_deliveryNavigationPoint); if (HorizontalDistance(Position, _deliveryNavigationPoint) > 1.45f) { MoveTo(_deliveryNavigationPoint, 1.65f, sprint: false); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, _deliveryNavigationPoint); break; } StopMoving(); _controller.SetDirectedGrabPointHost(_deliveryDropPoint); _deliveryStage = DeliveryStage.Place; _deliveryTimer = 1.35f; break; case DeliveryStage.Place: StopMoving(); _controller.SetDirectedGrabPointHost(_deliveryDropPoint); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, _deliveryDropPoint); if (_deliveryTimer <= 0f || Vector3.Distance(_deliveryObject.rb.worldCenterOfMass, _deliveryDropPoint) <= 0.45f) { _controller.EndDirectedGrabHost(); FinishDelivery(); } break; } } private void FinishDelivery() { DoppelgangerDebugOverlay.Record(_controller, "DELIVERY", "entrega encenada concluída"); Plugin.Log.LogInfo((object)"Doppelganger completed its staged valuable delivery."); _deliveryStage = DeliveryStage.None; _deliveryValuable = null; _deliveryObject = null; _deliveryCart = null; _deliveryExtraction = null; _deliveryTimer = 0f; EnterSearch(resetHostility: false); } private void CancelDelivery() { bool num = _deliveryStage != DeliveryStage.None; if ((Object)(object)_controller != (Object)null && _controller.HasGrabTarget) { _controller.EndDirectedGrabHost(); } _deliveryStage = DeliveryStage.None; _deliveryValuable = null; _deliveryObject = null; _deliveryCart = null; _deliveryExtraction = null; _deliveryTimer = 0f; if (num && (Object)(object)_controller != (Object)null) { DoppelgangerDebugOverlay.Record(_controller, "DELIVERY", "entrega cancelada"); } } private void ScanVision() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0162: 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_0057: 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_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_00d1: 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) PlayerAvatar val = null; PlayerAvatar val2 = null; Vector3 visibleTargetPoint = Vector3.zero; Vector3 visibleTargetPoint2 = Vector3.zero; float num = float.MaxValue; float num2 = float.MaxValue; if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!IsValidPlayer(player)) { continue; } float num3 = HorizontalDistance(Position, GetPlayerPhysicalPosition(player)); if (num3 > 22f || !InsideFieldOfView(player)) { continue; } if (TryGetVisiblePoint(player, lowEye: false, out var visiblePoint)) { if (num3 < num) { val = player; num = num3; visibleTargetPoint = visiblePoint; } } else if ((player.isCrouching || player.isCrawling) && num3 <= 7f && TryGetVisiblePoint(player, lowEye: true, out visiblePoint) && num3 < num2) { val2 = player; num2 = num3; visibleTargetPoint2 = visiblePoint; } } } if ((Object)(object)val != (Object)null) { _inspectTarget = null; _combatTarget = val; _visibleTargetPoint = visibleTargetPoint; _visibilityGraceTimer = 0.4f; _targetVisible = true; } else if ((Object)(object)val2 != (Object)null) { if (!((Object)(object)_combatTarget == (Object)(object)val2) || !_targetVisible) { if ((Object)(object)_inspectTarget != (Object)(object)val2) { _inspectTarget = val2; _inspectTimer = 0.65f; } _visibleTargetPoint = visibleTargetPoint2; _targetVisible = false; } } else if (IsValidPlayer(_combatTarget) && _visibilityGraceTimer > 0f) { _targetVisible = true; } else { _targetVisible = false; _inspectTarget = null; } } private void InspectLowTarget() { //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_0037: 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_003c: 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_0053: 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_009e: 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) if (!IsValidPlayer(_inspectTarget)) { _inspectTarget = null; return; } PlayerAvatar inspectTarget = _inspectTarget; Vector3 val = ((_visibleTargetPoint != Vector3.zero) ? _visibleTargetPoint : GetLowTargetPoint(inspectTarget)); Face(val); StopMoving(); _controller.SetCombatPoseHost(sprinting: false, crouching: true, gunDrawn: false, val); _inspectTimer -= Time.deltaTime; if (!(_inspectTimer > 0f)) { if (InsideFieldOfView(inspectTarget) && TryGetVisiblePoint(inspectTarget, lowEye: true, out var visiblePoint)) { _combatTarget = inspectTarget; _targetVisible = true; _visibleTargetPoint = visiblePoint; _visibilityGraceTimer = 0.4f; _lastSeenPosition = visiblePoint; _lastSeenTimer = 10f; } _inspectTarget = null; } } private void EngageVisibleTarget(PlayerAvatar target) { //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_001b: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0076: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((_visibleTargetPoint != Vector3.zero) ? _visibleTargetPoint : GetTargetPoint(target)); float num = HorizontalDistance(Position, GetPlayerPhysicalPosition(target)); Face(val); if (num <= 3f) { _gunMode = false; StopMoving(); _aimTimer = 0f; _controller.SetCombatPoseHost(sprinting: false, target.isCrouching || target.isCrawling, gunDrawn: false, val); if (_controller.TryMeleeHost(target)) { string text = (target.isCrawling ? "crawling" : (target.isCrouching ? "crouching" : "standing")); Plugin.Log.LogDebug((object)("Doppelganger struck " + text + " target \"" + target.playerName + "\".")); } } else if (num >= 5.5f && num <= 20f) { AimAndShoot(target, val); } else { _aimTimer = 0f; _gunMode = false; MoveTo(((Component)target).transform.position, 5.2f, sprint: true); TryJump(((Component)target).transform.position); _controller.SetCombatPoseHost(_lastMoveSprinting, crouching: false, gunDrawn: false, val); } } private void AimAndShoot(PlayerAvatar target, Vector3 targetPoint) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //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_00b9: Unknown result type (might be due to invalid IL or missing references) StopMoving(); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: true, targetPoint); if (!_gunMode) { _gunMode = true; Plugin.Log.LogDebug((object)$"Doppelganger drew its handgun at {HorizontalDistance(Position, GetPlayerPhysicalPosition(target)):0.0}m."); } if (!(_shotCooldown > 0f)) { _aimTimer += Time.deltaTime; if (!(_aimTimer < 0.45f) && (TryGetVisiblePoint(target, lowEye: false, out var visiblePoint) || TryGetVisiblePoint(target, lowEye: true, out visiblePoint))) { _aimTimer = 0f; _shotCooldown = 1.5f; _visibleTargetPoint = visiblePoint; bool flag = _controller.ShootHost(target, visiblePoint); Plugin.Log.LogDebug((object)("Doppelganger fired at \"" + target.playerName + "\" and " + (flag ? "hit a player" : "missed") + ".")); } } } private void Roam() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0097: 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_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_00c2: 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) _roamTimer -= Time.deltaTime; if (_roamTimer <= 0f || HorizontalDistance(Position, _roamPosition) <= 1.2f || (_enemy.HasNavMeshAgent && !_enemy.NavMeshAgent.HasPath())) { LevelPoint val = (((Object)(object)LevelGenerator.Instance != (Object)null) ? SemiFunc.LevelPointGet(Position, 6f, 18f) : null); NavMeshHit val2 = default(NavMeshHit); if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 1.5f, ref val2, 4f, -1)) { _roamPosition = ((NavMeshHit)(ref val2)).position; _roamTimer = Random.Range(5f, 10f); } else { _roamPosition = Position; _roamTimer = 2f; } } Face(_roamPosition); MoveTo(_roamPosition, 2.3f, sprint: false); _controller.SetCombatPoseHost(sprinting: false, crouching: false, gunDrawn: false, _roamPosition); } private void MoveTo(Vector3 destination, float speed, bool sprint) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_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_00a1: 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_0068: 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_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_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_0099: 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_00ce: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) _lastMoveSprinting = false; if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null || !EnsureAgentOnNavMesh()) { return; } MonitorMovementProgress(destination); Vector3 val = GetHumanizedDestination(destination, sprint); bool forceDangerous = false; if (TryFindSafeGapTraversal(destination, out var approach, out var landing, out var jumpDistance)) { forceDangerous = true; if (HorizontalDistance(Position, approach) <= 0.72f) { if (!TryStartManagedGapJump(landing, jumpDistance)) { StopMoving(); } return; } val = approach; } if (!TryResolveReachableDestination(val, 1.75f, out var reachable)) { if (_stuckTimer >= 2.25f) { RecoverFromStuck(destination); } return; } if (!IsImmediateGroundedPath(reachable, out var unsafePoint)) { Vector3 reachable2 = destination; if (!(HorizontalDistance(val, destination) > 0.2f) || !TryResolveReachableDestination(destination, 1.25f, out reachable2) || !IsImmediateGroundedPath(reachable2, out unsafePoint)) { BlockUnsafeTraversal(destination, unsafePoint); return; } reachable = reachable2; } bool flag = UpdateTraversalRisk(reachable, forceDangerous); bool flag2 = sprint && !flag; float num = (flag ? Mathf.Min(speed, 1.4f) : speed); _lastMoveSprinting = flag2; _enemy.NavMeshAgent.UpdateAgent(num, flag2 ? 18f : (flag ? 5f : 8f)); if (_destinationRefreshTimer <= 0f || HorizontalDistance(_lastIssuedDestination, reachable) > 0.4f || !HasUsableNavigationPath()) { _enemy.NavMeshAgent.SetDestination(reachable); _lastIssuedDestination = reachable; _destinationRefreshTimer = 0.16f; } if (!flag2 && _enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) { _enemy.Rigidbody.IdleSet(0.1f); } TryJump(destination); if (!flag) { TryRandomPlayerJump(destination); } } private bool TryFindSafeGapTraversal(Vector3 destination, out Vector3 approach, out Vector3 landing, out float jumpDistance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) approach = Position; landing = Position; jumpDistance = 0f; if (_controller.HasGrabTarget || !_enemy.HasJump || (Object)(object)_enemy.Jump == (Object)null || !_enemy.HasGrounded || (Object)(object)_enemy.Grounded == (Object)null || !_enemy.Grounded.grounded || _enemy.Jump.jumping || HorizontalDistance(Position, destination) < 2f || HasReasonablePathTo(destination)) { return false; } Vector3 val = destination - Position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); float num = Mathf.Min(9f, HorizontalDistance(Position, destination) - 0.25f); float num2 = -1f; int num3 = 0; for (float num4 = 0.55f; num4 <= num; num4 += 0.4f) { bool flag = HasGroundSupport(Position + val * num4, 1.8f); if (num2 < 0f) { if (!flag) { num2 = num4; } continue; } if (!flag) { num3 = 0; continue; } num3++; if (num3 < 2) { continue; } float num5 = num4 - 0.4f; float num6 = num5 - num2; if (num6 < 0.65f) { num2 = -1f; num3 = 0; continue; } if (num6 > 6.8f) { return false; } Vector3 requested = Position + val * Mathf.Max(0.15f, num2 - 0.55f); if (!TryResolveReachableDestination(requested, 0.65f, out approach)) { return false; } if (!TryFindSafeGapLanding(Position, val, num5, out landing)) { return false; } jumpDistance = HorizontalDistance(approach, landing); if (jumpDistance > 8.3f || !IsJumpArcClear(approach, landing, jumpDistance)) { return false; } return true; } return false; } private bool TryFindSafeGapLanding(Vector3 origin, Vector3 direction, float firstLandingDistance, out Vector3 landing) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0069: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a1: 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_00c9: 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) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) landing = origin; Vector3 val = Vector3.Cross(Vector3.up, direction); Vector3 normalized = ((Vector3)(ref val)).normalized; float[] array = new float[3] { 0.35f, 0.7f, 1.05f }; float[] array2 = new float[3] { 0f, 0.45f, -0.45f }; float[] array3 = array; NavMeshHit val2 = default(NavMeshHit); foreach (float num in array3) { float[] array4 = array2; foreach (float num2 in array4) { if (NavMesh.SamplePosition(origin + direction * (firstLandingDistance + num) + normalized * num2, ref val2, 0.6f, -1) && !(Mathf.Abs(((NavMeshHit)(ref val2)).position.y - origin.y) > 1.8f) && HasOpenNavSpace(((NavMeshHit)(ref val2)).position, 0.32f) && HasGroundSupport(((NavMeshHit)(ref val2)).position, 1.4f)) { landing = ((NavMeshHit)(ref val2)).position; return true; } } } return false; } private bool TryStartManagedGapJump(Vector3 landing, float jumpDistance) { //IL_00b1: 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_00bd: 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_0133: 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_0162: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) if (_managedGapCooldown > 0f || !_enemy.HasJump || (Object)(object)_enemy.Jump == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null || !_enemy.HasGrounded || (Object)(object)_enemy.Grounded == (Object)null || !_enemy.Grounded.grounded || _enemy.Jump.jumping || _enemy.Jump.gapJumpImpulse) { return false; } StopMoving(); Vector3 val = landing - Position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val)).Normalize(); Face(landing); float num = Mathf.Lerp(5.2f, 7.1f, Mathf.InverseLerp(2f, 7.5f, jumpDistance)); float num2 = Mathf.Lerp(5.8f, 9.4f, Mathf.InverseLerp(2f, 7.5f, jumpDistance)); _enemy.Jump.gapJumpLandPosition = landing; _enemy.Jump.GapJumpOverride(0.7f, num, num2); _enemy.Jump.gapJumpImpulse = true; _managedGapLanding = landing; _managedGapStart = Position; _managedGapJumpActive = true; _managedGapSafetyTimer = 3.5f; _managedDoubleJumpPending = jumpDistance >= 4.6f || landing.y - Position.y > 0.7f; _managedDoubleJumpTimer = 0.3f; _managedGapCooldown = 2.5f; _jumpCheckTimer = 0.8f; _lastMoveSprinting = false; ResetStuckMonitor(); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "salto seguro sobre void até " + FormatVector(landing) + " " + $"({jumpDistance:0.0}m" + (_managedDoubleJumpPending ? ", double jump preparado)" : ")")); return true; } private void UpdateManagedGapJump() { //IL_0058: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (!_managedGapJumpActive || !_enemy.HasJump || (Object)(object)_enemy.Jump == (Object)null) { return; } _managedGapSafetyTimer -= Time.deltaTime; float num = Mathf.Min(_managedGapStart.y, _managedGapLanding.y); bool flag = Position.y < num - 0.75f; bool flag2 = _managedGapSafetyTimer <= 0f && !HasSafeGroundFootprint(Position); if (flag || flag2) { RecoverFailedManagedGapJump(flag ? "caiu abaixo da plataforma" : "não alcançou o piso no tempo seguro"); return; } if (_managedDoubleJumpPending && _enemy.Jump.jumping) { _managedDoubleJumpTimer -= Time.deltaTime; if (_managedDoubleJumpTimer <= 0f && _enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) { Vector3 val = _managedGapLanding - ((Component)_enemy.Rigidbody).transform.position; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 1.2f) { ((Vector3)(ref val)).Normalize(); float num2 = Mathf.Clamp(magnitude * 0.3f, 1.25f, 2.35f); _enemy.Rigidbody.rb.AddForce(val * num2 + Vector3.up * 2.4f, (ForceMode)2); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", $"double jump aplicado; destino a {magnitude:0.0}m"); } _managedDoubleJumpPending = false; } } if (!_enemy.Jump.jumping && !_enemy.Jump.gapJumpImpulse) { _managedGapJumpActive = false; _managedDoubleJumpPending = false; _managedGapSafetyTimer = 0f; } } private void RecoverFailedManagedGapJump(string reason) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_00e3: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (HasSafeGroundFootprint(_managedGapLanding) ? _managedGapLanding : (_hasSafeNavPosition ? _lastSafeNavPosition : _managedGapStart)); if (_enemy.HasJump && (Object)(object)_enemy.Jump != (Object)null) { _enemy.Jump.gapJumpImpulse = false; _enemy.Jump.JumpingDelaySet(false, (Type)0); _enemy.Jump.JumpingSet(false, (Type)0); } if (_enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null && (Object)(object)_enemy.Rigidbody.rb != (Object)null) { _enemy.Rigidbody.rb.velocity = Vector3.zero; _enemy.Rigidbody.rb.angularVelocity = Vector3.zero; } if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { _enemy.NavMeshAgent.Warp(val, true); _enemy.NavMeshAgent.ResetPath(); } _enemy.EnemyTeleported(val); _managedGapJumpActive = false; _managedDoubleJumpPending = false; _managedGapSafetyTimer = 0f; _managedGapCooldown = Mathf.Max(_managedGapCooldown, 3f); _lastSafeNavPosition = val; _hasSafeNavPosition = true; ResetStuckMonitor(); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "salto sobre void abortado com recuperação segura (" + reason + ")"); Plugin.Log.LogWarning((object)("Recovered Doppelganger from a failed managed gap jump: " + reason + ".")); } private bool HasReasonablePathTo(Vector3 destination) { //IL_0043: 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_005b: Expected O, but got Unknown //IL_005e: 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_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_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_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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; NavMeshHit val = default(NavMeshHit); if (!((Behaviour)agent).enabled || !agent.isOnNavMesh || !NavMesh.SamplePosition(destination, ref val, 1.5f, -1)) { return false; } NavMeshPath val2 = new NavMeshPath(); if (!agent.CalculatePath(((NavMeshHit)(ref val)).position, val2) || (int)val2.status != 0 || val2.corners.Length == 0) { return false; } float num = 0f; Vector3 val3 = Position; Vector3[] corners = val2.corners; foreach (Vector3 val4 in corners) { num += Vector3.Distance(val3, val4); val3 = val4; } float num2 = Vector3.Distance(Position, ((NavMeshHit)(ref val)).position); return num <= num2 + 4f; } private bool UpdateTraversalRisk(Vector3 destination, bool forceDangerous) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (forceDangerous || IsTraversalNearVoid(destination)) { _dangerousTraversalTimer = 1.2f; } bool flag = _dangerousTraversalTimer > 0f; if (flag != _dangerousTraversal) { _dangerousTraversal = flag; DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", flag ? "área perigosa detectada; sprint suspenso" : "caminho seguro novamente; sprint liberado"); } return flag; } private bool IsTraversalNearVoid(Vector3 destination) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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) //IL_004c: 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_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_0097: 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_00a8: 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) Vector3 val = destination - Position; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward)); if (!HasGroundSupport(Position + val * 0.8f, 1.8f)) { return true; } int num = 0; for (int i = 0; i < 8; i++) { Vector3 val2 = Quaternion.AngleAxis((float)i * 45f, Vector3.up) * Vector3.forward; if (!HasGroundSupport(Position + val2 * 0.72f, 2.1f)) { num++; } } return num >= 2; } private static bool HasGroundSupport(Vector3 point, float depth) { //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_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) //IL_003e: 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_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_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) if (!Physics.Raycast(point + Vector3.up * 0.55f, Vector3.down, depth + 0.55f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1)) { return false; } RaycastHit[] array = Physics.RaycastAll(point + Vector3.up * 0.55f, Vector3.down, depth + 0.55f, LayerMask.GetMask(new string[1] { "Triggers" }), (QueryTriggerInteraction)2); for (int i = 0; i < array.Length; i++) { RaycastHit val = array[i]; HurtCollider componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && componentInParent.deathPit) { return false; } } return true; } private bool IsImmediateGroundedPath(Vector3 destination, out Vector3 unsafePoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0056: 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_0073: 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_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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00c2: 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_00b6: 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_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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_010d: 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_0149: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018d: 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) unsafePoint = Position; if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; NavMeshPath val = new NavMeshPath(); if (!((Behaviour)agent).enabled || !agent.isOnNavMesh || !agent.CalculatePath(destination, val) || (int)val.status != 0 || val.corners.Length == 0) { return false; } Vector3 val2 = Position; float num = 0f; Vector3[] corners = val.corners; foreach (Vector3 val3 in corners) { Vector3 val4 = val3 - val2; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude <= 0.01f) { val2 = val3; continue; } Vector3 val5 = val4 / magnitude; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.01f) { val5 = ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward); } else { ((Vector3)(ref val5)).Normalize(); } Vector3 val6 = Vector3.Cross(Vector3.up, val5); Vector3 normalized = ((Vector3)(ref val6)).normalized; float num2 = Mathf.Min(magnitude, 1.35f - num); for (float num3 = 0.25f; num3 <= num2 + 0.01f; num3 += 0.25f) { Vector3 val7 = Vector3.Lerp(val2, val3, num3 / magnitude); if (!HasGroundSupport(val7, 1.45f) || !HasGroundSupport(val7 + normalized * 0.2f, 1.45f) || !HasGroundSupport(val7 - normalized * 0.2f, 1.45f)) { unsafePoint = val7; return false; } } num += num2; if (num >= 1.35f) { break; } val2 = val3; } return true; } private void BlockUnsafeTraversal(Vector3 requestedDestination, Vector3 unsafePoint) { //IL_0019: 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_002d: 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_007b: 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_0087: 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_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) bool flag = _deliveryStage == DeliveryStage.Carry && _controller.HasGrabTarget; UpdateTraversalRisk(requestedDestination, forceDangerous: true); StopMoving(); _lastIssuedDestination = Vector3.zero; _destinationRefreshTimer = 0f; if (_enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null && (Object)(object)_enemy.Rigidbody.rb != (Object)null) { Vector3 val = unsafePoint - Position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Vector3)(ref val)).Normalize(); Vector3 velocity = _enemy.Rigidbody.rb.velocity; float num = Vector3.Dot(velocity, val); if (num > 0f) { _enemy.Rigidbody.rb.velocity = velocity - val * num; } } } if (_deliveryStage == DeliveryStage.Carry) { CancelDelivery(); EnterSearch(resetHostility: false); } else { TrySetWideObstacleDetour(requestedDestination); } if (_unsafePathLogCooldown <= 0f) { _unsafePathLogCooldown = 2f; DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "movimento bloqueado: sem chão seguro em " + FormatVector(unsafePoint) + (flag ? "; valuable solto antes do void" : "; procurando desvio")); Plugin.Log.LogDebug((object)("Doppelganger refused an unsafe floor segment at " + FormatVector(unsafePoint) + ".")); } } private bool IsJumpArcClear(Vector3 start, Vector3 landing, float jumpDistance) { //IL_005c: 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_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_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_0087: 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_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_00a1: 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) int mask = LayerMask.GetMask(new string[4] { "Default", "PhysGrabObject", "PhysGrabObjectHinge", "PhysGrabObjectCart" }); float num = Mathf.Lerp(1.25f, 2.25f, Mathf.InverseLerp(2f, 7.5f, jumpDistance)); for (int i = 1; i < 9; i++) { float num2 = (float)i / 9f; Vector3 val = Vector3.Lerp(start, landing, num2) + Vector3.up * (0.65f + Mathf.Sin(num2 * MathF.PI) * num); Collider[] array = Physics.OverlapCapsule(val - Vector3.up * 0.28f, val + Vector3.up * 0.28f, 0.27f, mask, (QueryTriggerInteraction)1); for (int j = 0; j < array.Length; j++) { if (!((Object)(object)((Component)array[j]).GetComponentInParent() == (Object)(object)_enemy)) { return false; } } } return true; } private Vector3 GetHumanizedDestination(Vector3 destination, bool sprint) { //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_0025: 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_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_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) //IL_0023: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_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_0097: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0236: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) float num = HorizontalDistance(Position, destination); if (num <= 1.8f) { _humanDestinationAnchor = destination; _humanMovePoint = destination; return destination; } if (Mathf.Abs(destination.y - Position.y) > 0.9f || !HasOpenNavSpace(Position, 0.32f)) { _humanDestinationAnchor = destination; _humanMovePoint = destination; _humanMoveTimer = 0.35f; return destination; } _humanMoveTimer -= Time.deltaTime; bool flag = HorizontalDistance(_humanDestinationAnchor, destination) > 2.2f; bool flag2 = HorizontalDistance(Position, _humanMovePoint) <= 0.65f; if (_humanMoveTimer <= 0f || flag || flag2 || _humanMovePoint == Vector3.zero) { Vector3 val = destination - Position; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((Vector3)(ref _facing)).normalized); Vector3 val2 = Vector3.Cross(Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num2 = Mathf.Min(num, Random.Range(2.2f, sprint ? 5f : 3.8f)); float num3 = Random.Range(sprint ? (-1.25f) : (-0.8f), sprint ? 1.25f : 0.8f); if (Random.value < 0.2f) { num3 *= 0.2f; } NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(Position + val * num2 + normalized * num3, ref val3, 1.25f, -1) && Mathf.Abs(((NavMeshHit)(ref val3)).position.y - Position.y) <= 1.1f && HasOpenNavSpace(((NavMeshHit)(ref val3)).position, 0.28f) && TryResolveReachableDestination(((NavMeshHit)(ref val3)).position, 0.4f, out var reachable)) { _humanMovePoint = reachable; } else { _humanMovePoint = destination; } _humanDestinationAnchor = destination; _humanMoveTimer = Random.Range(0.55f, 1.35f); } return _humanMovePoint; } private void TryRandomPlayerJump(Vector3 destination) { //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) //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_00fc: 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_0111: 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_011b: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f3: 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_0141: 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) _randomJumpTimer -= Time.deltaTime; if (_randomJumpTimer > 0f) { return; } _randomJumpTimer = Random.Range(5f, 12f); if (!_controller.HasGrabTarget && _enemy.HasJump && !((Object)(object)_enemy.Jump == (Object)null) && !_enemy.Jump.jumping && (!_enemy.HasGrounded || !((Object)(object)_enemy.Grounded != (Object)null) || _enemy.Grounded.grounded)) { Vector3 val = destination - Position; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward)); val = Quaternion.AngleAxis(Random.Range(-12f, 12f), Vector3.up) * val; if (!IsTraversalNearVoid(Position + val * 1.3f) && TryFindSafeShortLanding(val, ascending: false, out var _)) { _enemy.Jump.SurfaceJumpOverride(0.3f, 3.8f, 1.15f); _enemy.Jump.SurfaceJumpTrigger(val); _jumpCheckTimer = 0.45f; } } } private void StopMoving() { //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) _lastMoveSprinting = false; _humanMoveTimer = 0f; _humanMovePoint = Vector3.zero; if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { _enemy.NavMeshAgent.ResetPath(); _enemy.NavMeshAgent.Stop(0.15f); } if (_enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) { _enemy.Rigidbody.IdleSet(0.15f); } } private bool EnsureAgentOnNavMesh() { if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (!((Behaviour)agent).enabled) { return false; } if (agent.isOnNavMesh) { return true; } return RecoverAgentToNavMesh("agente saiu da NavMesh", force: false); } private bool RecoverAgentToNavMesh(string reason, bool force) { //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_008e: 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_00a6: 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_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_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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_017b: Unknown result type (might be due to invalid IL or missing references) if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null || (!force && _navRecoveryCooldown > 0f)) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (!((Behaviour)agent).enabled) { return false; } if (agent.isOnNavMesh) { _enemy.NavMeshAgent.ResetPath(); _lastSafeNavPosition = ((Component)agent).transform.position; _hasSafeNavPosition = true; ResetStuckMonitor(); return true; } Vector3 val; if (_hasSafeNavPosition && HorizontalDistance(Position, _lastSafeNavPosition) <= 8f && Mathf.Abs(Position.y - _lastSafeNavPosition.y) <= 5f) { val = _lastSafeNavPosition; } else { NavMeshHit val2 = default(NavMeshHit); if (!NavMesh.SamplePosition(Position, ref val2, 5f, -1)) { _navRecoveryCooldown = 0.75f; return false; } val = ((NavMeshHit)(ref val2)).position; } _enemy.NavMeshAgent.Warp(val, true); if (!agent.isOnNavMesh) { _navRecoveryCooldown = 0.75f; return false; } _enemy.EnemyTeleported(val); _enemy.NavMeshAgent.ResetPath(); _lastSafeNavPosition = val; _hasSafeNavPosition = true; _navRecoveryCooldown = 1.5f; ResetStuckMonitor(); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "recuperado na NavMesh (" + reason + ") em " + FormatVector(val)); return true; } private void RefreshSafeNavPosition(bool force) { //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_007d: 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_0093: 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) if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return; } _safeNavSampleTimer -= Time.deltaTime; if (!force && _safeNavSampleTimer > 0f) { return; } _safeNavSampleTimer = 0.25f; NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (((Behaviour)agent).enabled && agent.isOnNavMesh) { Vector3 position = ((Component)agent).transform.position; if (HasOpenNavSpace(position, 0.2f) && HasSafeGroundFootprint(position)) { _lastSafeNavPosition = position; _hasSafeNavPosition = true; } } } private bool HasUsableNavigationPath() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (((Behaviour)agent).enabled && agent.isOnNavMesh) { if (!agent.pathPending) { if (agent.hasPath) { return (int)agent.pathStatus != 2; } return false; } return true; } return false; } private bool TryResolveReachableDestination(Vector3 requested, float sampleRadius, out Vector3 reachable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0060: Expected O, but got Unknown //IL_0063: 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_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) reachable = requested; if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (!((Behaviour)agent).enabled || !agent.isOnNavMesh) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(requested, ref val, sampleRadius, -1)) { return false; } NavMeshPath val2 = new NavMeshPath(); if (!agent.CalculatePath(((NavMeshHit)(ref val)).position, val2) || (int)val2.status != 0 || val2.corners.Length < 1) { return false; } reachable = ((NavMeshHit)(ref val)).position; return true; } private static bool HasOpenNavSpace(Vector3 point, float minimumEdgeDistance) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.FindClosestEdge(point, ref val, -1)) { return Vector3.Distance(point, ((NavMeshHit)(ref val)).position) >= minimumEdgeDistance; } return true; } private static bool HasSafeGroundFootprint(Vector3 point) { //IL_0000: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //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_0073: 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_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) if (HasGroundSupport(point, 1.45f) && HasGroundSupport(point + Vector3.forward * 0.18f, 1.45f) && HasGroundSupport(point - Vector3.forward * 0.18f, 1.45f) && HasGroundSupport(point + Vector3.right * 0.18f, 1.45f)) { return HasGroundSupport(point - Vector3.right * 0.18f, 1.45f); } return false; } private void MonitorMovementProgress(Vector3 destination) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) bool num = HorizontalDistance(_stuckDestination, destination) > 2f; bool flag = Vector3.Distance(_stuckAnchorPosition, Position) > 0.28f; if (num || flag || _stuckAnchorPosition == Vector3.zero) { _stuckDestination = destination; _stuckAnchorPosition = Position; _stuckTimer = 0f; } else if (HorizontalDistance(Position, destination) > 1.5f) { _stuckTimer += Time.deltaTime; if (_stuckTimer >= 2.25f) { RecoverFromStuck(destination); } } else { _stuckTimer = 0f; } } private void RecoverFromStuck(Vector3 destination) { //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_0023: 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_0073: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_011d: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_016a: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) if (_navRecoveryCooldown > 0f || !EnsureAgentOnNavMesh()) { return; } Vector3 val = destination - Position; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward)); if (TryJump(destination, forceStairAssist: true)) { _navRecoveryCooldown = 0.8f; ResetStuckMonitor(); } else { if (TrySetWideObstacleDetour(destination)) { return; } float[] array = new float[7] { 45f, -45f, 80f, -80f, 0f, 135f, -135f }; float[] array2 = new float[3] { 1.8f, 2.8f, 3.6f }; NavMeshHit val2 = default(NavMeshHit); foreach (float num in array2) { float[] array3 = array; foreach (float num2 in array3) { if (NavMesh.SamplePosition(Position + Quaternion.AngleAxis(num2, Vector3.up) * val * num, ref val2, 1f, -1) && !(Mathf.Abs(((NavMeshHit)(ref val2)).position.y - Position.y) > 1.5f) && HasOpenNavSpace(((NavMeshHit)(ref val2)).position, 0.3f) && TryResolveReachableDestination(((NavMeshHit)(ref val2)).position, 0.25f, out var reachable)) { _humanMovePoint = reachable; _humanDestinationAnchor = destination; _humanMoveTimer = 1.35f; _lastIssuedDestination = Vector3.zero; _destinationRefreshTimer = 0f; _navRecoveryCooldown = 1.25f; ResetStuckMonitor(); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "destravou com desvio seguro em " + FormatVector(reachable)); return; } } } if (_searching) { _searchPointTimer = 0f; _searchNoPathTimer = 0f; } else { RecoverAgentToNavMesh("sem progresso até o objetivo", force: true); } _navRecoveryCooldown = Mathf.Max(_navRecoveryCooldown, 1.25f); ResetStuckMonitor(); } } private void ResetStuckMonitor() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //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) _stuckTimer = 0f; _stuckAnchorPosition = Position; _stuckDestination = Vector3.zero; } private bool TryJump(Vector3 destination, bool forceStairAssist = false) { //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_00a4: 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_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_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_0108: 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_0118: 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_0139: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) if (_jumpCheckTimer > 0f || _controller.HasGrabTarget || !_enemy.HasJump || (Object)(object)_enemy.Jump == (Object)null || _enemy.Jump.jumping || _enemy.Jump.gapJumpImpulse || _managedGapJumpActive || !_enemy.HasGrounded || (Object)(object)_enemy.Grounded == (Object)null || !_enemy.Grounded.grounded) { return false; } Vector3 val = destination - Position; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((((Vector3)(ref _facing)).sqrMagnitude > 0.01f) ? ((Vector3)(ref _facing)).normalized : ((Component)this).transform.forward)); bool flag = Physics.Raycast(Position + Vector3.up * 0.28f, val, 0.85f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); bool flag2 = !Physics.Raycast(Position + Vector3.up * 1.05f, val, 0.85f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); bool flag3 = IsAscendingTraversal(destination); bool flag4 = flag3 && (forceStairAssist || _stuckTimer >= 0.55f); if ((!flag || !flag2) && !flag4) { if (flag && _stuckTimer >= 0.7f) { TrySetWideObstacleDetour(destination); } return false; } if (!flag2 || !TryFindSafeShortLanding(val, flag3, out var landing)) { if (_stuckTimer >= 0.7f) { TrySetWideObstacleDetour(destination); } _jumpCheckTimer = 0.3f; return false; } float num = (flag3 ? 5f : 4.35f); float num2 = (flag3 ? 2.5f : 3.2f); _enemy.Jump.SurfaceJumpOverride(0.4f, num, num2); _enemy.Jump.SurfaceJumpTrigger(val); _jumpCheckTimer = 0.65f; DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", flag3 ? ("salto de subida/escada até " + FormatVector(landing)) : ("obstáculo saltado até " + FormatVector(landing))); return true; } private bool IsAscendingTraversal(Vector3 destination) { //IL_0000: 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_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_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_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) if (destination.y - Position.y > 0.38f) { return true; } if (!_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; if (!((Behaviour)agent).enabled || !agent.isOnNavMesh || !agent.hasPath || agent.path.corners.Length < 2) { return false; } Vector3[] corners = agent.path.corners; foreach (Vector3 val in corners) { if (!(HorizontalDistance(Position, val) < 0.35f)) { return val.y - Position.y > 0.22f; } } return false; } private bool TryFindSafeShortLanding(Vector3 direction, bool ascending, out Vector3 landing) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_006c: 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_008a: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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) landing = Position; float[] array = ((!ascending) ? new float[3] { 1.1f, 1.4f, 1.7f } : new float[3] { 0.9f, 1.2f, 1.5f }); NavMeshHit val = default(NavMeshHit); foreach (float num in array) { if (NavMesh.SamplePosition(Position + direction * num, ref val, ascending ? 1.1f : 0.75f, -1) && !(((NavMeshHit)(ref val)).position.y - Position.y > 1.6f) && !(Position.y - ((NavMeshHit)(ref val)).position.y > 0.8f) && HasGroundSupport(((NavMeshHit)(ref val)).position, 1.4f) && IsJumpArcClear(Position, ((NavMeshHit)(ref val)).position, num)) { landing = ((NavMeshHit)(ref val)).position; return true; } } return false; } private bool TrySetWideObstacleDetour(Vector3 destination) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_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_00ca: 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_00db: 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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0124: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0146: 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_015b: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (_navRecoveryCooldown > 0f || !_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null || !NavMesh.SamplePosition(destination, ref val, 1.75f, -1)) { return false; } Vector3 val2 = destination - Position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref val2)).Normalize(); float[] array = new float[3] { 2.2f, 3.2f, 4f }; float[] array2 = new float[4] { 55f, -55f, 85f, -85f }; float[] array3 = array; foreach (float num in array3) { float[] array4 = array2; foreach (float num2 in array4) { Vector3 requested = Position + Quaternion.AngleAxis(num2, Vector3.up) * val2 * num; if (TryResolveReachableDestination(requested, 0.9f, out var reachable) && !(Mathf.Abs(reachable.y - Position.y) > 1.5f) && HasOpenNavSpace(reachable, 0.28f) && HasSafeGroundFootprint(reachable) && IsImmediateGroundedPath(reachable, out var _)) { NavMeshPath val3 = new NavMeshPath(); if (NavMesh.CalculatePath(reachable, ((NavMeshHit)(ref val)).position, -1, val3) && (int)val3.status == 0) { _humanMovePoint = reachable; _humanDestinationAnchor = destination; _humanMoveTimer = 1.6f; _lastIssuedDestination = Vector3.zero; _destinationRefreshTimer = 0f; _navRecoveryCooldown = 1.15f; ResetStuckMonitor(); DoppelgangerDebugOverlay.Record(_controller, "NAVEGAÇÃO", "obstáculo contornado por rota ampla em " + FormatVector(reachable)); return true; } } } } return false; } private bool InsideFieldOfView(PlayerAvatar player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //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_005e: 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_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) Vector3 val = GetTargetPoint(player) - EyePosition(low: false); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return true; } Vector3 val2 = _facing; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)this).transform.forward; } return Vector3.Dot(((Vector3)(ref val2)).normalized, ((Vector3)(ref val)).normalized) >= 0.574f; } private bool TryGetVisiblePoint(PlayerAvatar player, bool lowEye, out Vector3 visiblePoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00b5: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_00c2: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0146: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) Vector3 origin = EyePosition(lowEye); Vector3 position = ((Component)player).transform.position; if ((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController.col != (Object)null) { Bounds bounds = player.PlayerVisionTarget.PlayerController.col.bounds; Vector3 center = ((Bounds)(ref bounds)).center; if (HasClearRay(origin, center, player)) { visiblePoint = center; return true; } } if ((Object)(object)player.playerAvatarVisuals != (Object)null && (Object)(object)player.playerAvatarVisuals.headLookAtTransform != (Object)null) { Vector3 position2 = player.playerAvatarVisuals.headLookAtTransform.position; if (HasClearRay(origin, position2, player)) { visiblePoint = position2; return true; } } float[] array = ((lowEye || player.isCrawling) ? new float[3] { 0.2f, 0.38f, 0.52f } : ((!player.isCrouching) ? new float[4] { 0.92f, 0.68f, 0.42f, 1.12f } : new float[3] { 0.38f, 0.55f, 0.68f })); float[] array2 = array; foreach (float num in array2) { Vector3 val = position + Vector3.up * num; if (HasClearRay(origin, val, player)) { visiblePoint = val; return true; } } if (!lowEye && !player.isCrouching && !player.isCrawling && (Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.VisionTransform != (Object)null) { Vector3 position3 = player.PlayerVisionTarget.VisionTransform.position; if (HasClearRay(origin, position3, player)) { visiblePoint = position3; return true; } } visiblePoint = Vector3.zero; return false; } private bool HasClearRay(Vector3 origin, Vector3 targetPoint, PlayerAvatar target) { //IL_0014: 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_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_0038: 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_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 val = targetPoint - origin; float distance = ((Vector3)(ref val)).magnitude; if (distance <= 0.05f) { return true; } return Physics.RaycastAll(origin, ((Vector3)(ref val)).normalized, distance, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1).All((RaycastHit hit) => (Object)(object)((RaycastHit)(ref hit)).transform == (Object)null || ((RaycastHit)(ref hit)).transform.IsChildOf(((Component)_parent).transform) || HitBelongsToPlayer(((RaycastHit)(ref hit)).collider, target) || ((RaycastHit)(ref hit)).distance >= distance - 0.35f); } private static bool HitBelongsToPlayer(Collider collider, PlayerAvatar target) { if ((Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)target) { return true; } PlayerController componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.playerAvatarScript == (Object)(object)target) { return true; } PlayerTumble componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2.playerAvatar == (Object)(object)target) { return true; } if ((Object)(object)target.PlayerVisionTarget != (Object)null && (Object)(object)target.PlayerVisionTarget.PlayerController != (Object)null && (Object)(object)target.PlayerVisionTarget.PlayerController.col == (Object)(object)collider) { return true; } if ((Object)(object)target.tumble != (Object)null && target.tumble.colliders != null) { return target.tumble.colliders.Contains(collider); } return false; } private Vector3 EyePosition(bool low) { //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_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) return Position + Vector3.up * (low ? 0.34f : 0.95f); } private static Vector3 GetTargetPoint(PlayerAvatar player) { //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_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) float num = (player.isCrawling ? 0.24f : (player.isCrouching ? 0.5f : 0.78f)); return ((Component)player).transform.position + Vector3.up * num; } private static Vector3 GetPlayerPhysicalPosition(PlayerAvatar player) { //IL_005d: 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) if ((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController.col != (Object)null) { Bounds bounds = player.PlayerVisionTarget.PlayerController.col.bounds; return ((Bounds)(ref bounds)).center; } return ((Component)player).transform.position; } private static Vector3 GetLowTargetPoint(PlayerAvatar player) { //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_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) return ((Component)player).transform.position + Vector3.up * (player.isCrawling ? 0.2f : 0.38f); } private static bool IsValidPlayer(PlayerAvatar? player) { if ((Object)(object)player != (Object)null && ((Component)player).gameObject.activeInHierarchy && !player.isDisabled) { return !player.deadSet; } return false; } private static float HorizontalDistance(Vector3 first, Vector3 second) { //IL_0018: 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) first.y = 0f; second.y = 0f; return Vector3.Distance(first, second); } private void Face(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_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 = position - Position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { _facing = Vector3.Slerp(_facing, ((Vector3)(ref val)).normalized, Time.deltaTime * 10f); } } private void OnInvestigate() { //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_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_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_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0080: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || !_enemy.HasStateInvestigate || (Object)(object)_enemy.StateInvestigate == (Object)null) { return; } Vector3 onInvestigateTriggeredPosition = _enemy.StateInvestigate.onInvestigateTriggeredPosition; if (!(HorizontalDistance(Position, onInvestigateTriggeredPosition) < 1.5f) && !(Vector3.Distance(Position, onInvestigateTriggeredPosition) > 24f)) { float num = Time.time - _lastAcceptedSoundTime; if (!(num < 0.25f) && (!(num < 2.5f) || !(Vector3.Distance(onInvestigateTriggeredPosition, _lastAcceptedSoundPosition) < 1.25f))) { _lastAcceptedSoundTime = Time.time; _lastAcceptedSoundPosition = onInvestigateTriggeredPosition; _controller.LookAtSoundHost(onInvestigateTriggeredPosition); _investigatePosition = onInvestigateTriggeredPosition; _investigateTimer = 8f; _debugSoundSerial++; DoppelgangerDebugOverlay.Record(_controller, "SOM", "percebeu som em " + FormatVector(onInvestigateTriggeredPosition) + "; investigando por 8s"); } } } private void OnDestroy() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if ((Object)(object)_enemy != (Object)null && _enemy.HasStateInvestigate && (Object)(object)_enemy.StateInvestigate != (Object)null && _enemy.StateInvestigate.onInvestigateTriggered != null) { _enemy.StateInvestigate.onInvestigateTriggered.RemoveListener(new UnityAction(OnInvestigate)); } } } public sealed class DoppelgangerController : MonoBehaviour { internal const string PeacefulEnemyName = "\u200b"; private const float PersistentTimerFloor = 600f; private const float MeleeCooldown = 1.15f; private const float PlayerThrowAttributionSeconds = 5f; private readonly List _hiddenOriginalRenderers = new List(); private Enemy _enemy; private EnemyParent _parent; private EnemyHealth _health; private DoppelgangerBrain _brain; private EnemyStateSpawn? _stateSpawn; private PhotonView _photonView; private PlayerAvatar? _copiedPlayer; private GameObject? _visualProxy; private Animator? _proxyAnimator; private PlayerAvatarVisuals? _proxyAvatarVisuals; private PlayerAvatarRightArm? _proxyRightArm; private PlayerAvatarLeftArm? _proxyLeftArm; private PlayerAvatarTalkAnimation? _proxyTalkAnimation; private PlayerEyes? _proxyEyes; private Renderer[] _sourceRenderers = Array.Empty(); private Renderer[] _proxyRenderers = Array.Empty(); private Transform[] _sourceTransforms = Array.Empty(); private Transform[] _proxyTransforms = Array.Empty(); private TextMeshPro? _nameTag; private GameObject? _weaponVisual; private Transform? _weaponHold; private Transform? _gunMuzzle; private Sound? _gunShootSound; private Sound? _gunShootGlobalSound; private LineRenderer? _grabBeam; private GameObject? _grabPointVisual; private AudioSource? _grabLoopAudio; private AudioSource? _voicePlaybackSource; private GameObject? _mapVisualRig; private Transform? _mapVisualAnchor; private AudioSource? _mapOneShotAudio; private AudioSource? _mapLoopAudio; private Sound? _mapStartSound; private Sound? _mapStopSound; private GameObject? _flashlightLightRig; private Light? _flashlight; private GameObject? _flashlightVisualRig; private Transform? _flashlightVisualAnchor; private Transform? _flashlightHideTransform; private Transform? _flashlightClickTransform; private Renderer[] _flashlightModelRenderers = Array.Empty(); private Sound? _flashlightOnSound; private Sound? _flashlightOffSound; private PhysGrabObject? _grabTarget; private PhysGrabCart? _grabCart; private readonly List<(Collider Enemy, Collider Target)> _ignoredGrabCollisions = new List<(Collider, Collider)>(); private readonly float[] _voiceMouthSamples = new float[256]; private PlayerAvatar? _peacefulFollowTarget; private PlayerAvatar? _recentThrowingPlayer; private int _copiedPlayerViewId = -1; private int _grabTargetViewId = -1; private float _meleeCooldown; private float _meleeAnimationTimer; private float _grabSearchTimer; private float _grabTimer; private float _voiceTimer; private float _weaponRetryTimer; private float _lastPoseSyncTime; private float _footstepDistance; private float _appearanceMirrorTimer; private float _appearanceRebuildCooldown; private float _appearanceMismatchTimer; private float _heardSoundTimer; private float _eyeTalkerTimer; private float _eyeIdleTimer; private float _hurtFlashTimer; private float _grabClawLerp; private float _grabClawCycle; private float _bodyLookTimer; private float _bodyLookYaw; private float _bodyLookPitch; private float _mapOpenLerp; private float _mapRetryTimer; private float _flashlightTransition = 1f; private float _flashlightClickTimer; private float _flashlightHiddenAngle = 55f; private float _flashlightClickStrength = 8f; private float _playerThrowAttributionTimer; private float _playerThrowMotionTimer; private Vector3 _lastFootstepPosition; private Vector3 _aimPoint; private Vector3 _lastSyncedAimPoint; private Vector3 _heardSoundPosition; private Vector3 _eyeIdleTarget; private Vector3 _directedGrabPoint; private Vector3 _bodyLookPoint; private Quaternion _grabCarryRotation = Quaternion.identity; private Quaternion _mouthClosedRotation = Quaternion.identity; private Quaternion _flashlightHideBaseRotation = Quaternion.identity; private Quaternion _flashlightClickBaseRotation = Quaternion.identity; private PlayerAvatar? _eyeTalker; private bool _aiSprinting; private bool _aiCrouching; private bool _gunDrawn; private bool _mapInspectActive; private bool _hasPoseAim; private bool _footstepInitialized; private bool _visualBuiltFromReadyAppearance; private bool _visualTumbling; private bool _visualSprinting; private bool _hurtFlashApplied; private bool _aggressive; private bool _deathSequenceStarted; private bool _deathAnimationActive; private bool _sabotageAnimationActive; private bool _grabCartWasActive; private bool _grabVisualWasActive; private bool _directedGrab; private bool _hasDirectedGrabPoint; private bool _initialSpawnRelocated; private bool _nearbyTalkerWasActive; private bool _eyeFailureLogged; private bool _flashlightDesiredOn = true; private bool _flashlightInitialized; private bool _appearanceNormalizationFailureLogged; private bool _dead; internal int RuntimeId { get { if (!((Object)(object)_photonView != (Object)null) || _photonView.ViewID <= 0) { return ((Object)this).GetInstanceID(); } return _photonView.ViewID; } } internal bool IsAggressive => _aggressive; internal PlayerAvatar? PeacefulFollowTarget => _peacefulFollowTarget; internal PhysGrabObject? CurrentGrabTarget => _grabTarget; internal bool HasGrabTarget { get { if ((Object)(object)_grabTarget != (Object)null) { return _grabTimer > 0f; } return false; } } internal bool IsInspectingMap => _mapInspectActive; internal string DebugCopiedPlayerName { get { if (!((Object)(object)_copiedPlayer != (Object)null)) { return "nenhum"; } return _copiedPlayer.playerName; } } internal string DebugGrabTargetName { get { if (!((Object)(object)_grabTarget != (Object)null)) { return "nenhum"; } return ((Object)_grabTarget).name; } } internal float DebugHealthCurrent { get { if (!((Object)(object)_health != (Object)null)) { return 0f; } return _health.healthCurrent; } } internal float DebugHealthMaximum => Plugin.Health.Value; internal bool DebugGunDrawn => _gunDrawn; internal bool DebugSprinting => _aiSprinting; internal bool DebugCrouching => _aiCrouching; internal bool DebugFlashlightOn => _flashlightDesiredOn; internal bool DebugUnderPhysicsControl => UnderExternalPhysicsControl; internal DoppelgangerBrain DebugBrain => _brain; internal Transform VoiceAnchor { get { if (!((Object)(object)_proxyTalkAnimation != (Object)null) || !((Object)(object)_proxyTalkAnimation.objectToRotate != (Object)null)) { if (!((Object)(object)_visualProxy != (Object)null)) { return ((Component)this).transform; } return _visualProxy.transform; } return _proxyTalkAnimation.objectToRotate.transform; } } internal bool IsBeingGrabbed { get { if ((Object)(object)_enemy == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null) { return false; } PhysGrabObject physGrabObject = _enemy.Rigidbody.physGrabObject; if (!_enemy.Rigidbody.grabbed) { if ((Object)(object)physGrabObject != (Object)null) { if (!physGrabObject.grabbed && !physGrabObject.grabbedLocal) { return physGrabObject.playerGrabbing.Count > 0; } return true; } return false; } return true; } } internal bool UnderExternalPhysicsControl { get { if ((Object)(object)_enemy == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null) { return false; } bool flag = _enemy.HasGrounded && (Object)(object)_enemy.Grounded != (Object)null && !_enemy.Grounded.grounded && Mathf.Abs(_enemy.Rigidbody.velocity.y) > 0.2f; bool flag2 = IsNavMeshGuidedStep(); if (!IsBeingGrabbed && (!_enemy.IsStunned() || flag2) && (!_enemy.HasJump || !((Object)(object)_enemy.Jump != (Object)null) || !_enemy.Jump.jumping)) { if (flag) { return !flag2; } return false; } return true; } } internal Vector3 GunMuzzlePosition { get { //IL_0086: 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_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_006b: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_gunMuzzle != (Object)null)) { if (!((Object)(object)_visualProxy != (Object)null)) { return ((Component)this).transform.position + Vector3.up * 0.72f; } return _visualProxy.transform.position + Vector3.up * 0.72f + _visualProxy.transform.forward * 0.45f; } return _gunMuzzle.position; } } internal void RegisterVoicePlayback(AudioSource source) { _voicePlaybackSource = source; } private bool IsNavMeshGuidedStep() { //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_008a: 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_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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_enemy == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null || !_enemy.HasNavMeshAgent || (Object)(object)_enemy.NavMeshAgent == (Object)null) { return false; } NavMeshAgent agent = _enemy.NavMeshAgent.Agent; Vector3 velocity = _enemy.Rigidbody.velocity; if (!((Behaviour)agent).enabled || !agent.isOnNavMesh || !agent.hasPath || velocity.y < -2.6f || velocity.y > 1.7f) { return false; } Vector3 position = ((Component)_enemy.Rigidbody).transform.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 0.85f, -1)) { return Mathf.Abs(((NavMeshHit)(ref val)).position.y - position.y) <= 0.8f; } return false; } private void Awake() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown _enemy = ((Component)this).GetComponent(); _parent = ((Component)this).GetComponentInParent(); _health = ((Component)this).GetComponent(); _brain = ((Component)this).GetComponent(); _stateSpawn = ((Component)this).GetComponent(); _photonView = ((Component)this).GetComponent(); if ((Object)(object)_stateSpawn != (Object)null && _stateSpawn.OnSpawn != null) { _stateSpawn.OnSpawn.AddListener(new UnityAction(HandleSpawn)); } DoppelgangerRegistry.Register(this); } private IEnumerator Start() { _health.health = Plugin.Health.Value; _health.healthCurrent = Plugin.Health.Value; _health.onHurt.AddListener(new UnityAction(HandleHurt)); _health.onDeath.AddListener(new UnityAction(HandleDeath)); if (_health.onObjectHurt != null) { _health.onObjectHurt.AddListener(new UnityAction(HandleObjectHurt)); } ConfigureInstanceCombat(); while ((Object)(object)GameDirector.instance == (Object)null || GameDirector.instance.PlayerList.Count == 0) { yield return (object)new WaitForSeconds(0.1f); } if (SemiFunc.IsMasterClientOrSingleplayer()) { SelectCopiedPlayer(); if (_parent.Spawned) { RelocateInitialSpawnFarHost(); _brain.ResetPeacefulBehaviourHost(); } } ScheduleNextVoice(); } private void ConfigureInstanceCombat() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) _parent.enemyName = "\u200b"; _parent.enemyNameLocalized = null; _parent.difficulty = (Difficulty)2; _parent.SpawnedTimeMin = 86400f; _parent.SpawnedTimeMax = 86400f; _parent.DespawnedTimeMin = 86400f; _parent.DespawnedTimeMax = 86400f; HurtCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (HurtCollider obj in componentsInChildren) { ((Behaviour)obj).enabled = false; obj.playerKill = false; obj.playerDamage = Plugin.GunDamage.Value; obj.enemyHost = _enemy; } } internal void SetPeacefulFollowTargetHost(PlayerAvatar? player) { if (SemiFunc.IsMasterClientOrSingleplayer()) { _peacefulFollowTarget = player; } } internal void BecomeAggressiveHost(string reason) { if (SemiFunc.IsMasterClientOrSingleplayer() && !_aggressive) { if ((Object)(object)_grabTarget != (Object)null) { SetGrabTargetHost(null, 0f); } SetAggressiveStateHost(aggressive: true); _brain.BeginAggressionHost(); Plugin.Log.LogInfo((object)$"Doppelganger {RuntimeId} became aggressive: {reason}."); } } internal void BecomePeacefulHost(string reason) { if (SemiFunc.IsMasterClientOrSingleplayer() && _aggressive) { if ((Object)(object)_grabTarget != (Object)null) { SetGrabTargetHost(null, 0f); } ResetPeacefulStateHost(); Plugin.Log.LogInfo((object)$"Doppelganger {RuntimeId} returned to a peaceful search: {reason}."); } } private void ResetPeacefulStateHost() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SetAggressiveStateHost(aggressive: false); _peacefulFollowTarget = null; _brain.ResetPeacefulBehaviourHost(); } } private void SetAggressiveStateHost(bool aggressive) { if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SetAggressiveStateRpc", (RpcTarget)3, new object[1] { aggressive }); } else { ApplyAggressiveState(aggressive); } } [PunRPC] private void SetAggressiveStateRpc(bool aggressive, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { ApplyAggressiveState(aggressive); } } private void ApplyAggressiveState(bool aggressive) { _aggressive = aggressive; _parent.enemyNameLocalized = null; _parent.enemyName = (aggressive ? "Doppelganger" : "\u200b"); if (!aggressive) { _gunDrawn = false; } } private void SelectCopiedPlayer() { List list = GameDirector.instance.PlayerList.Where((PlayerAvatar player) => (Object)(object)player != (Object)null && !player.isDisabled && IsAppearanceReady(player)).ToList(); List list2 = ((list.Count > 0) ? list : GameDirector.instance.PlayerList.Where((PlayerAvatar player) => (Object)(object)player != (Object)null && !player.isDisabled).ToList()); if (list2.Count != 0) { PlayerAvatar val = list2[Random.Range(0, list2.Count)]; int num = (((Object)(object)val.photonView != (Object)null) ? val.photonView.ViewID : (-1)); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SetCopiedPlayerRpc", (RpcTarget)3, new object[1] { num }); } else { SetCopiedPlayer(num, val); } } } [PunRPC] private void SetCopiedPlayerRpc(int viewId, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { SetCopiedPlayer(viewId, null); } } private void SetCopiedPlayer(int viewId, PlayerAvatar? direct) { _copiedPlayerViewId = viewId; _copiedPlayer = direct ?? FindPlayer(viewId); _visualBuiltFromReadyAppearance = false; if ((Object)(object)_copiedPlayer != (Object)null) { bool flag = TryBuildVisualProxy(); _visualBuiltFromReadyAppearance = flag && IsAppearanceReady(_copiedPlayer); } ((MonoBehaviour)this).StartCoroutine(WaitForCopiedPlayerAndAppearance()); } private IEnumerator WaitForCopiedPlayerAndAppearance() { float timeout = 20f; while (timeout > 0f) { if (_copiedPlayer == null) { _copiedPlayer = FindPlayer(_copiedPlayerViewId); } if ((Object)(object)_copiedPlayer != (Object)null && (Object)(object)_visualProxy == (Object)null) { TryBuildVisualProxy(); } if ((Object)(object)_copiedPlayer != (Object)null && IsAppearanceReady(_copiedPlayer) && !_visualBuiltFromReadyAppearance) { _visualBuiltFromReadyAppearance = TryBuildVisualProxy(); yield break; } if (_visualBuiltFromReadyAppearance) { yield break; } timeout -= 0.1f; yield return (object)new WaitForSeconds(0.1f); } if ((Object)(object)_copiedPlayer == (Object)null) { Plugin.Log.LogError((object)$"Could not resolve copied player view {_copiedPlayerViewId}; the Doppelganger will retry."); } else if (!_visualBuiltFromReadyAppearance) { Plugin.Log.LogWarning((object)("Timed out waiting for " + _copiedPlayer.playerName + "'s final cosmetics; keeping the visible fallback copy.")); } } private static bool IsAppearanceReady(PlayerAvatar player) { if ((Object)(object)player == (Object)null || (Object)(object)player.playerAvatarVisuals == (Object)null) { return false; } PlayerCosmetics playerCosmetics = player.playerAvatarVisuals.playerCosmetics; if ((Object)(object)playerCosmetics != (Object)null && !playerCosmetics.firstSetup && playerCosmetics.colorsEquipped != null && playerCosmetics.colorsEquipped.Length != 0) { return playerCosmetics.colorsEquipped.All((int color) => color >= 0); } return false; } private static PlayerAvatar? FindPlayer(int viewId) { if ((Object)(object)GameDirector.instance == (Object)null) { return null; } return ((IEnumerable)GameDirector.instance.PlayerList).FirstOrDefault((Func)((PlayerAvatar player) => (Object)(object)player != (Object)null && (viewId < 0 || ((Object)(object)player.photonView != (Object)null && player.photonView.ViewID == viewId)))); } private void BuildVisualProxy() { //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_copiedPlayer == (Object)null || (Object)(object)_copiedPlayer.playerAvatarVisuals == (Object)null) { return; } DestroyVisualProxy(); GameObject gameObject = ((Component)_copiedPlayer.playerAvatarVisuals).gameObject; _visualProxy = Object.Instantiate(gameObject); ((Object)_visualProxy).name = "Doppelganger Player Visual"; _visualProxy.SetActive(false); _visualProxy.transform.SetParent(((Component)this).transform, true); MonoBehaviour[] componentsInChildren = _visualProxy.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } Collider[] componentsInChildren2 = _visualProxy.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } AudioSource[] componentsInChildren3 = _visualProxy.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } _sourceTransforms = gameObject.GetComponentsInChildren(true); _proxyTransforms = _visualProxy.GetComponentsInChildren(true); for (int j = 1; j < Mathf.Min(_sourceTransforms.Length, _proxyTransforms.Length); j++) { ((Component)_proxyTransforms[j]).gameObject.SetActive(((Component)_sourceTransforms[j]).gameObject.activeSelf); } _sourceRenderers = gameObject.GetComponentsInChildren(true); _proxyRenderers = _visualProxy.GetComponentsInChildren(true); MaterialPropertyBlock val = new MaterialPropertyBlock(); for (int k = 0; k < _proxyRenderers.Length; k++) { Renderer val2 = _proxyRenderers[k]; Renderer val3 = ((k < _sourceRenderers.Length) ? _sourceRenderers[k] : null); val2.enabled = (Object)(object)val3 != (Object)null && val3.enabled; val2.shadowCastingMode = (ShadowCastingMode)((!((Object)(object)val3 != (Object)null) || (int)val3.shadowCastingMode != 0) ? 1 : 0); val2.receiveShadows = true; if ((Object)(object)val3 != (Object)null) { val2.sharedMaterials = val3.sharedMaterials; val3.GetPropertyBlock(val); val2.SetPropertyBlock(val); val.Clear(); } } _proxyAnimator = _visualProxy.GetComponent(); if ((Object)(object)_proxyAnimator != (Object)null) { ((Behaviour)_proxyAnimator).enabled = true; } _proxyAvatarVisuals = _visualProxy.GetComponent(); if ((Object)(object)_proxyAvatarVisuals != (Object)null) { ((Behaviour)_proxyAvatarVisuals).enabled = false; } _proxyRightArm = _visualProxy.GetComponentInChildren(true); if ((Object)(object)_proxyRightArm != (Object)null) { ((Behaviour)_proxyRightArm).enabled = false; _proxyRightArm.rightArmTransform.localEulerAngles = _proxyRightArm.basePose; if ((Object)(object)_proxyRightArm.rightArmParentTransform != (Object)null) { _proxyRightArm.rightArmParentTransform.localRotation = Quaternion.identity; _proxyRightArm.rightArmParentTransform.localScale = Vector3.one; } if ((Object)(object)_proxyRightArm.grabberClawParent != (Object)null) { ((Component)_proxyRightArm.grabberClawParent).gameObject.SetActive(false); } } _proxyLeftArm = _visualProxy.GetComponentInChildren(true); if ((Object)(object)_proxyLeftArm != (Object)null) { ((Behaviour)_proxyLeftArm).enabled = false; } _proxyTalkAnimation = _visualProxy.GetComponentInChildren(true); if ((Object)(object)_proxyTalkAnimation != (Object)null && (Object)(object)_proxyTalkAnimation.objectToRotate != (Object)null) { ((Behaviour)_proxyTalkAnimation).enabled = false; _mouthClosedRotation = _proxyTalkAnimation.objectToRotate.transform.localRotation; } _proxyEyes = _visualProxy.GetComponentInChildren(true); if ((Object)(object)_proxyEyes != (Object)null) { ((Behaviour)_proxyEyes).enabled = false; } NormalizeProxyAppearance(); _visualProxy.SetActive(true); EnableActiveProxyRenderers(); HideOriginalVisuals(); CreateNameTag(); CreateWeaponVisual(); CreateGrabBeam(); CreateMapVisual(); CreateForwardFlashlight(); UpdateVisualProxy(); Plugin.Log.LogInfo((object)("Doppelganger copied player \"" + _copiedPlayer.playerName + "\" " + $"({_proxyRenderers.Count((Renderer renderer) => renderer.enabled)} active of {_proxyRenderers.Length} renderers, " + $"{_hiddenOriginalRenderers.Count} base renderers hidden).")); } private bool TryBuildVisualProxy() { try { BuildVisualProxy(); return (Object)(object)_visualProxy != (Object)null; } catch (Exception arg) { Plugin.Log.LogError((object)$"Could not build the Doppelganger player visual: {arg}"); DestroyVisualProxy(); RestoreOriginalVisuals(); return false; } } private void HideOriginalVisuals() { _hiddenOriginalRenderers.Clear(); Renderer[] componentsInChildren = ((Component)_parent).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)_visualProxy != (Object)null) || !((Component)val).transform.IsChildOf(_visualProxy.transform)) { _hiddenOriginalRenderers.Add(val); val.enabled = false; } } } private void RestoreOriginalVisuals() { foreach (Renderer hiddenOriginalRenderer in _hiddenOriginalRenderers) { if ((Object)(object)hiddenOriginalRenderer != (Object)null) { hiddenOriginalRenderer.enabled = true; } } _hiddenOriginalRenderers.Clear(); } private void CreateNameTag() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0094: 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_00b3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_copiedPlayer == (Object)null)) { GameObject val = new GameObject("Doppelganger Name Tag"); val.transform.SetParent(((Component)this).transform, true); _nameTag = val.AddComponent(); ((TMP_Text)_nameTag).text = _copiedPlayer.playerName; ((TMP_Text)_nameTag).alignment = (TextAlignmentOptions)514; ((TMP_Text)_nameTag).fontSize = 2.2f; ((TMP_Text)_nameTag).enableWordWrapping = false; ((Graphic)_nameTag).color = new Color(1f, 1f, 1f, 0f); _nameTag.transform.localScale = Vector3.one * 0.1f; TextMeshProUGUI val2 = (((Object)(object)WorldSpaceUIParent.instance != (Object)null) ? WorldSpaceUIParent.instance.playerNamePrefab.GetComponentInChildren(true) : null); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)_nameTag).font = ((TMP_Text)val2).font; ((TMP_Text)_nameTag).fontSharedMaterial = ((TMP_Text)val2).fontSharedMaterial; } } } private void CreateWeaponVisual() { //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_weaponVisual != (Object)null) { return; } Item val = (from item in StatsManager.instance?.itemDictionary?.Values where (Object)(object)item != (Object)null && !item.disabled && (int)item.itemType == 9 && item.prefab != null && (Object)(object)((PrefabRef)(object)item.prefab).Prefab != (Object)null orderby (item.itemName?.IndexOf("handgun", StringComparison.OrdinalIgnoreCase) ?? (-1)) >= 0 || (((Object)item).name?.IndexOf("handgun", StringComparison.OrdinalIgnoreCase) ?? (-1)) >= 0 descending select item).FirstOrDefault(); GameObject val2 = ((PrefabRef)(object)val?.prefab)?.Prefab; if ((Object)(object)val2 == (Object)null) { _weaponRetryTimer = 1f; return; } bool activeSelf = val2.activeSelf; val2.SetActive(false); try { _weaponVisual = Object.Instantiate(val2); } finally { val2.SetActive(activeSelf); } ((Object)_weaponVisual).name = "Doppelganger Handgun Item Visual"; ItemGun val3 = _weaponVisual.GetComponent() ?? _weaponVisual.GetComponentInChildren(true); _gunMuzzle = val3?.gunMuzzle; _gunShootSound = val3?.soundShoot; _gunShootGlobalSound = val3?.soundShootGlobal; MonoBehaviour[] componentsInChildren = _weaponVisual.GetComponentsInChildren(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } Collider[] componentsInChildren2 = _weaponVisual.GetComponentsInChildren(true); for (int num = 0; num < componentsInChildren2.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num]); } Rigidbody[] componentsInChildren3 = _weaponVisual.GetComponentsInChildren(true); for (int num = 0; num < componentsInChildren3.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[num]); } Renderer[] componentsInChildren4 = _weaponVisual.GetComponentsInChildren(true); foreach (Renderer val4 in componentsInChildren4) { if (!RendererIsVisibleInPrefab(val4, _weaponVisual.transform)) { val4.enabled = false; } else { val4.shadowCastingMode = (ShadowCastingMode)1; } } _weaponHold = new GameObject("Doppelganger Handgun Hold").transform; _weaponHold.SetParent(_visualProxy.transform, false); _weaponVisual.transform.SetParent(_weaponHold, false); _weaponVisual.transform.localPosition = Vector3.zero; _weaponVisual.transform.localRotation = Quaternion.identity; _weaponVisual.SetActive(false); Plugin.Log.LogInfo((object)("Doppelganger loaded the real handgun item visual \"" + val.itemName + "\".")); } private static bool RendererIsVisibleInPrefab(Renderer renderer, Transform root) { if (!renderer.enabled) { return false; } Transform val = ((Component)renderer).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { if (!((Component)val).gameObject.activeSelf) { return false; } val = val.parent; } return (Object)(object)val == (Object)(object)root; } private void CreateGrabBeam() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_016c: 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_0171: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Doppelganger Grab Beam"); val.transform.SetParent(((Component)this).transform, false); _grabBeam = val.AddComponent(); _grabBeam.positionCount = 20; _grabBeam.useWorldSpace = true; PhysGrabber val2 = (((Object)(object)_copiedPlayer != (Object)null) ? _copiedPlayer.physGrabber : null); LineRenderer val3 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.physGrabBeamComponent != (Object)null) ? val2.physGrabBeamComponent.lineRenderer : null); if ((Object)(object)val3 != (Object)null) { _grabBeam.widthCurve = val3.widthCurve; _grabBeam.widthMultiplier = val3.widthMultiplier; _grabBeam.textureMode = val3.textureMode; _grabBeam.alignment = val3.alignment; if ((Object)(object)((Renderer)val3).sharedMaterial != (Object)null) { ((Renderer)_grabBeam).material = new Material(((Renderer)val3).sharedMaterial); } } else { _grabBeam.startWidth = 0.025f; _grabBeam.endWidth = 0.015f; Shader val4 = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); if ((Object)(object)val4 != (Object)null) { ((Renderer)_grabBeam).material = new Material(val4); } Color val5 = (((Object)(object)_copiedPlayer != (Object)null) ? SemiFunc.PlayerGetColorMain(_copiedPlayer) : Color.cyan); _grabBeam.startColor = val5; _grabBeam.endColor = new Color(val5.r, val5.g, val5.b, 0.2f); } ((Renderer)_grabBeam).enabled = false; if ((Object)(object)val2 != (Object)null && (Object)(object)val2.physGrabPointVisual1 != (Object)null) { bool activeSelf = val2.physGrabPointVisual1.activeSelf; val2.physGrabPointVisual1.SetActive(false); try { _grabPointVisual = Object.Instantiate(val2.physGrabPointVisual1); } finally { val2.physGrabPointVisual1.SetActive(activeSelf); } ((Object)_grabPointVisual).name = "Doppelganger Grab Point Visual"; _grabPointVisual.transform.SetParent(((Component)this).transform, true); MonoBehaviour[] componentsInChildren = _grabPointVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Collider[] componentsInChildren2 = _grabPointVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } _grabPointVisual.SetActive(false); } CreateGrabLoopAudio(val, val2); } private void CreateMapVisual() { //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_00d5: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_copiedPlayer == (Object)null || (Object)(object)_mapVisualRig != (Object)null) { return; } MapToolController mapToolController = _copiedPlayer.mapToolController; if ((Object)(object)mapToolController == (Object)null || (Object)(object)mapToolController.VisualTransform == (Object)null || (Object)(object)((Component)mapToolController).transform.parent == (Object)null) { _mapRetryTimer = 1f; return; } Transform val = null; if ((Object)(object)mapToolController.FollowTransformClient != (Object)null) { int num = Array.IndexOf(_sourceTransforms, mapToolController.FollowTransformClient); if (num >= 0 && num < _proxyTransforms.Length) { val = _proxyTransforms[num]; } } if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("Doppelganger Map Anchor"); val2.transform.SetParent(_visualProxy.transform, false); val2.transform.localPosition = new Vector3(0f, 0.72f, 0.34f); val2.transform.localRotation = Quaternion.identity; val = val2.transform; } _mapVisualAnchor = val; GameObject gameObject = ((Component)((Component)mapToolController).transform.parent).gameObject; bool activeSelf = gameObject.activeSelf; gameObject.SetActive(false); try { _mapVisualRig = Object.Instantiate(gameObject, val, false); } finally { gameObject.SetActive(activeSelf); } ((Object)_mapVisualRig).name = "Doppelganger Map Visual"; MapToolController componentInChildren = _mapVisualRig.GetComponentInChildren(true); GameObject val3 = (((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.VisualTransform != (Object)null) ? ((Component)componentInChildren.VisualTransform).gameObject : null); Transform val4 = componentInChildren?.HideTransform; _mapStartSound = mapToolController.SoundStart; _mapStopSound = mapToolController.SoundStop; Sound soundLoop = mapToolController.SoundLoop; MonoBehaviour[] componentsInChildren = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } AudioLowPassFilter[] componentsInChildren2 = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } AudioSource[] componentsInChildren3 = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Rigidbody[] componentsInChildren5 = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren5.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[i]); } Renderer[] componentsInChildren6 = _mapVisualRig.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren6.Length; i++) { componentsInChildren6[i].shadowCastingMode = (ShadowCastingMode)1; } if ((Object)(object)val3 != (Object)null) { val3.SetActive(true); } if ((Object)(object)val4 != (Object)null) { val4.localRotation = Quaternion.identity; } _mapVisualRig.transform.localPosition = Vector3.zero; _mapVisualRig.transform.localRotation = Quaternion.identity; _mapVisualRig.transform.localScale = Vector3.zero; CreateMapAudioSources(soundLoop); _mapVisualRig.SetActive(false); Plugin.Log.LogInfo((object)"Doppelganger copied an independent player map visual."); } private void CreateMapAudioSources(Sound? loopSound) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if (!((Object)(object)_mapVisualRig == (Object)null)) { GameObject val = new GameObject("Doppelganger Map One Shot"); val.transform.SetParent(_mapVisualRig.transform, false); _mapOneShotAudio = val.AddComponent(); ConfigureMapAudioSource(_mapOneShotAudio, _mapStartSound, loop: false); if (loopSound != null && loopSound.Sounds != null && loopSound.Sounds.Length != 0) { GameObject val2 = new GameObject("Doppelganger Map Loop"); val2.transform.SetParent(_mapVisualRig.transform, false); _mapLoopAudio = val2.AddComponent(); ConfigureMapAudioSource(_mapLoopAudio, loopSound, loop: true); _mapLoopAudio.clip = loopSound.Sounds[Random.Range(0, loopSound.Sounds.Length)]; } } } private static void ConfigureMapAudioSource(AudioSource destination, Sound? template, bool loop) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) destination.playOnAwake = false; destination.loop = loop; destination.spatialBlend = 1f; destination.dopplerLevel = template?.Doppler ?? 0f; destination.volume = Mathf.Clamp01((template?.Volume ?? 0.5f) * 0.35f); destination.pitch = Mathf.Max(0.1f, template?.Pitch ?? 1f); destination.rolloffMode = (AudioRolloffMode)((!((Object)(object)template?.Source != (Object)null)) ? 1 : ((int)template.Source.rolloffMode)); destination.minDistance = (((Object)(object)template?.Source != (Object)null) ? template.Source.minDistance : 1f); destination.maxDistance = (((Object)(object)template?.Source != (Object)null) ? template.Source.maxDistance : 12f); if ((Object)(object)template?.Source != (Object)null) { destination.outputAudioMixerGroup = template.Source.outputAudioMixerGroup; } ((Component)destination).gameObject.AddComponent(); ((Component)destination).gameObject.AddComponent(); } private void CreateGrabLoopAudio(GameObject beamObject, PhysGrabber? copiedGrabber) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) Sound val = copiedGrabber?.loopSound; if (val != null && val.Sounds != null && val.Sounds.Length != 0) { _grabLoopAudio = beamObject.AddComponent(); _grabLoopAudio.playOnAwake = false; _grabLoopAudio.loop = true; _grabLoopAudio.clip = val.Sounds[Random.Range(0, val.Sounds.Length)]; _grabLoopAudio.volume = Mathf.Clamp01(val.Volume * 0.5f); _grabLoopAudio.pitch = Mathf.Max(0.1f, val.Pitch); _grabLoopAudio.spatialBlend = 1f; _grabLoopAudio.dopplerLevel = val.Doppler; _grabLoopAudio.rolloffMode = (AudioRolloffMode)((!((Object)(object)val.Source != (Object)null)) ? 1 : ((int)val.Source.rolloffMode)); _grabLoopAudio.minDistance = (((Object)(object)val.Source != (Object)null) ? val.Source.minDistance : 1f); _grabLoopAudio.maxDistance = (((Object)(object)val.Source != (Object)null) ? val.Source.maxDistance : 12f); if ((Object)(object)val.Source != (Object)null) { _grabLoopAudio.outputAudioMixerGroup = val.Source.outputAudioMixerGroup; } beamObject.AddComponent(); beamObject.AddComponent(); } } private void Update() { if ((Object)(object)_copiedPlayer == (Object)null && _copiedPlayerViewId != -1) { _copiedPlayer = FindPlayer(_copiedPlayerViewId); if ((Object)(object)_copiedPlayer != (Object)null && (Object)(object)_visualProxy == (Object)null && IsAppearanceReady(_copiedPlayer)) { _visualBuiltFromReadyAppearance = TryBuildVisualProxy(); } } if ((Object)(object)_visualProxy != (Object)null && (Object)(object)_weaponVisual == (Object)null) { _weaponRetryTimer -= Time.deltaTime; if (_weaponRetryTimer <= 0f) { CreateWeaponVisual(); } } if ((Object)(object)_visualProxy != (Object)null && (Object)(object)_mapVisualRig == (Object)null) { _mapRetryTimer -= Time.deltaTime; if (_mapRetryTimer <= 0f) { CreateMapVisual(); } } MirrorAppearance(); UpdateVisualProxy(); UpdateHurtFlash(); EnforceOriginalVisualsHidden(); UpdateNameTag(); UpdateGrabBeam(); if (SemiFunc.IsMasterClientOrSingleplayer()) { TrackPlayerThrowAttribution(); } if (_meleeCooldown > 0f) { _meleeCooldown -= Time.deltaTime; } if (_meleeAnimationTimer > 0f) { _meleeAnimationTimer -= Time.deltaTime; } if ((Object)(object)_health != (Object)null && _health.healthCurrent > 0 && _dead) { _dead = false; if ((Object)(object)_visualProxy != (Object)null) { _visualProxy.SetActive(true); } ScheduleNextVoice(); } if (SemiFunc.IsMasterClientOrSingleplayer() && !_dead && _parent.Spawned) { _parent.SpawnedTimer = Mathf.Max(_parent.SpawnedTimer, 600f); _parent.forceLeave = false; HostGrabLogic(); HostVoiceLogic(); } } private void TrackPlayerThrowAttribution() { _playerThrowAttributionTimer = Mathf.Max(0f, _playerThrowAttributionTimer - Time.deltaTime); _playerThrowMotionTimer = Mathf.Max(0f, _playerThrowMotionTimer - Time.deltaTime); if ((Object)(object)_enemy == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null || (Object)(object)_enemy.Rigidbody.physGrabObject == (Object)null) { _recentThrowingPlayer = null; _playerThrowAttributionTimer = 0f; _playerThrowMotionTimer = 0f; return; } PhysGrabObject physGrabObject = _enemy.Rigidbody.physGrabObject; PlayerAvatar val = null; for (int num = physGrabObject.playerGrabbing.Count - 1; num >= 0; num--) { PhysGrabber val2 = physGrabObject.playerGrabbing[num]; if ((Object)(object)val2 != (Object)null && (Object)(object)val2.playerAvatar != (Object)null) { val = val2.playerAvatar; break; } } if ((Object)(object)val != (Object)null) { _recentThrowingPlayer = val; _playerThrowAttributionTimer = 5f; } else if ((Object)(object)physGrabObject.lastPlayerGrabbing != (Object)null && physGrabObject.grabbedTimer > 0f) { _recentThrowingPlayer = physGrabObject.lastPlayerGrabbing; _playerThrowAttributionTimer = Mathf.Max(_playerThrowAttributionTimer, physGrabObject.grabbedTimer + 2f); } if ((Object)(object)_recentThrowingPlayer != (Object)null && _playerThrowAttributionTimer > 0f && (((Vector3)(ref _enemy.Rigidbody.velocity)).magnitude >= 1.1f || _enemy.IsStunned())) { _playerThrowMotionTimer = 0.8f; } if (_playerThrowAttributionTimer <= 0f) { _recentThrowingPlayer = null; } } private PlayerAvatar? GetPlayerThrowDamageSource() { if ((Object)(object)_recentThrowingPlayer != (Object)null && _playerThrowAttributionTimer > 0f && _playerThrowMotionTimer > 0f) { return _recentThrowingPlayer; } if ((Object)(object)_enemy == (Object)null || !_enemy.HasRigidbody || (Object)(object)_enemy.Rigidbody == (Object)null || (Object)(object)_enemy.Rigidbody.physGrabObject == (Object)null) { return null; } PhysGrabObject physGrabObject = _enemy.Rigidbody.physGrabObject; if (!((Object)(object)physGrabObject.lastPlayerGrabbing != (Object)null) || !(physGrabObject.grabbedTimer > 0f) || (!_enemy.IsStunned() && (!_enemy.HasGrounded || !((Object)(object)_enemy.Grounded != (Object)null) || _enemy.Grounded.grounded) && !(((Vector3)(ref _enemy.Rigidbody.velocity)).magnitude >= 0.45f))) { return null; } _recentThrowingPlayer = physGrabObject.lastPlayerGrabbing; _playerThrowAttributionTimer = Mathf.Max(_playerThrowAttributionTimer, physGrabObject.grabbedTimer + 2f); _playerThrowMotionTimer = Mathf.Max(_playerThrowMotionTimer, 0.5f); return _recentThrowingPlayer; } private void MirrorAppearance() { //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_copiedPlayer == (Object)null || (Object)(object)_copiedPlayer.playerAvatarVisuals == (Object)null) { return; } _appearanceMirrorTimer -= Time.deltaTime; _appearanceRebuildCooldown = Mathf.Max(0f, _appearanceRebuildCooldown - Time.deltaTime); if (_appearanceMirrorTimer > 0f) { return; } _appearanceMirrorTimer = 0.2f; Renderer[] componentsInChildren = ((Component)_copiedPlayer.playerAvatarVisuals).GetComponentsInChildren(true); Transform[] componentsInChildren2 = ((Component)_copiedPlayer.playerAvatarVisuals).GetComponentsInChildren(true); bool flag = !_copiedPlayer.isTumbling && !_copiedPlayer.isCrouching && !_copiedPlayer.isCrawling; if ((componentsInChildren.Length != _sourceRenderers.Length || componentsInChildren2.Length != _sourceTransforms.Length) && flag) { _appearanceMismatchTimer += 0.2f; if (_appearanceMismatchTimer >= 3f && IsAppearanceReady(_copiedPlayer) && _appearanceRebuildCooldown <= 0f) { _appearanceMismatchTimer = 0f; _appearanceRebuildCooldown = 15f; _visualBuiltFromReadyAppearance = TryBuildVisualProxy(); return; } } else { _appearanceMismatchTimer = 0f; } MaterialPropertyBlock val = new MaterialPropertyBlock(); int num = Shader.PropertyToID("_ColorOverlay"); int num2 = Shader.PropertyToID("_ColorOverlayAmount"); int num3 = Mathf.Min(componentsInChildren2.Length, _proxyTransforms.Length); if (flag) { for (int i = 1; i < num3; i++) { bool activeSelf = ((Component)componentsInChildren2[i]).gameObject.activeSelf; if ((Object)(object)_proxyTransforms[i] != (Object)null && ((Component)_proxyTransforms[i]).gameObject.activeSelf != activeSelf) { ((Component)_proxyTransforms[i]).gameObject.SetActive(activeSelf); } } } int num4 = Mathf.Min(componentsInChildren.Length, _proxyRenderers.Length); for (int j = 0; j < num4; j++) { Renderer val2 = componentsInChildren[j]; Renderer val3 = _proxyRenderers[j]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { if (flag) { val3.enabled = val2.enabled; } val3.shadowCastingMode = (ShadowCastingMode)(((int)val2.shadowCastingMode != 0) ? 1 : 0); val3.sharedMaterials = val2.sharedMaterials; val2.GetPropertyBlock(val); val.SetColor(num, Color.red); val.SetFloat(num2, 0f); val3.SetPropertyBlock(val); val.Clear(); } } NormalizeProxyAppearance(); EnableActiveProxyRenderers(); } private void NormalizeProxyAppearance() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_proxyAvatarVisuals == (Object)null) { return; } try { _proxyAvatarVisuals.currentPose = (Pose)0; if ((Object)(object)_proxyAvatarVisuals.meshParent != (Object)null) { _proxyAvatarVisuals.meshParent.SetActive(true); } PlayerCosmetics componentInChildren = _visualProxy.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return; } AccessTools.Field(typeof(PlayerCosmetics), "cosmeticPoseCurrent")?.SetValue(componentInChildren, (object)(Pose)0); if (AccessTools.Field(typeof(PlayerCosmetics), "cosmeticEquipped")?.GetValue(componentInChildren) is IList list) { list.Clear(); Cosmetic[] componentsInChildren = _visualProxy.GetComponentsInChildren(true); foreach (Cosmetic value in componentsInChildren) { list.Add(value); } } if (AccessTools.Field(typeof(PlayerCosmetics), "conditionsCustom")?.GetValue(componentInChildren) is IList list2) { list2.Clear(); } AccessTools.Method(typeof(PlayerCosmetics), "ConditionsSetup", (Type[])null, (Type[])null)?.Invoke(componentInChildren, null); } catch (Exception ex) { if (!_appearanceNormalizationFailureLogged) { _appearanceNormalizationFailureLogged = true; Plugin.Log.LogWarning((object)("Could not normalize a copied player pose; the clone will keep its last stable appearance: " + ex.Message)); } } } private void EnableActiveProxyRenderers() { Renderer[] proxyRenderers = _proxyRenderers; foreach (Renderer val in proxyRenderers) { if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy) { val.enabled = true; } } } private void UpdateVisualProxy() { //IL_0043: 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_005a: 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_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_0099: 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_0111: 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_0127: 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_012c: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_visualProxy == (Object)null) && !((Object)(object)_enemy == (Object)null)) { Vector3 val = ((_enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) ? ((Component)_enemy.Rigidbody).transform.position : ((Component)this).transform.position); bool underExternalPhysicsControl = UnderExternalPhysicsControl; bool flag = underExternalPhysicsControl || _deathAnimationActive || _sabotageAnimationActive; _visualProxy.transform.position = (underExternalPhysicsControl ? val : GetVisualGroundPosition(val)); Vector3 val2 = Vector3.zero; if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { val2 = _enemy.NavMeshAgent.AgentVelocity; } if (((Vector3)(ref val2)).sqrMagnitude < 0.01f && _enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) { val2 = _enemy.Rigidbody.velocity; } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, 0f, val2.z); Vector3 val4 = val3; Vector3 val5 = _aimPoint - _visualProxy.transform.position; val5.y = 0f; if (_hasPoseAim && ((Vector3)(ref val5)).sqrMagnitude > 0.01f) { val4 = val5; } if (underExternalPhysicsControl && (Object)(object)_enemy.Rigidbody != (Object)null) { _visualProxy.transform.rotation = ((Component)_enemy.Rigidbody).transform.rotation; } else if (((Vector3)(ref val4)).sqrMagnitude > 0.02f) { Quaternion val6 = Quaternion.LookRotation(((Vector3)(ref val4)).normalized); _visualProxy.transform.rotation = Quaternion.Slerp(_visualProxy.transform.rotation, val6, Time.deltaTime * 12f); } bool flag2 = ((Vector3)(ref val3)).magnitude > 0.08f; bool aiSprinting = _aiSprinting; bool value = _aiCrouching || flag; bool value2 = flag; bool flag3 = _enemy.HasJump && (Object)(object)_enemy.Jump != (Object)null && _enemy.Jump.jumping; bool flag4 = val2.y < -0.5f; if (flag && !_visualTumbling) { SetAnimatorTrigger("TumblingImpulse"); } _visualTumbling = flag; bool flag5 = aiSprinting && flag2 && !flag; if (flag5 && !_visualSprinting) { SetAnimatorTrigger("SprintingImpulse"); } _visualSprinting = flag5; SetAnimatorBool("Moving", flag2); SetAnimatorBool("Sprinting", flag5); SetAnimatorBool("Crouching", value); SetAnimatorBool("Crawling", value2); SetAnimatorBool("Jumping", flag3); SetAnimatorBool("Falling", flag4); SetAnimatorBool("Tumbling", flag); SetAnimatorBool("TumblingMove", flag && ((Object)(object)_enemy.Rigidbody == (Object)null || ((Vector3)(ref _enemy.Rigidbody.velocity)).magnitude > 1f || ((Vector3)(ref _enemy.Rigidbody.physGrabObject.rbAngularVelocity)).magnitude > 1f)); SetAnimatorBool("Grabbing", _meleeAnimationTimer > 0f || (Object)(object)_grabTarget != (Object)null || _mapInspectActive || _mapOpenLerp > 0.01f); if ((Object)(object)_weaponVisual != (Object)null && _weaponVisual.activeSelf != _gunDrawn) { _weaponVisual.SetActive(_gunDrawn); } UpdateFootsteps(val3, flag, flag3, flag4); } } private void UpdateHurtFlash() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null) { return; } if (_hurtFlashTimer > 0f) { _hurtFlashTimer = Mathf.Max(0f, _hurtFlashTimer - Time.deltaTime); } bool flag = _hurtFlashTimer > 0f; if (!flag && !_hurtFlashApplied) { return; } int num = Shader.PropertyToID("_ColorOverlay"); int num2 = Shader.PropertyToID("_ColorOverlayAmount"); float num3 = (flag ? Mathf.Clamp01(_hurtFlashTimer / 0.16f) : 0f); MaterialPropertyBlock val = new MaterialPropertyBlock(); Renderer[] proxyRenderers = _proxyRenderers; foreach (Renderer val2 in proxyRenderers) { if (!((Object)(object)val2 == (Object)null)) { val2.GetPropertyBlock(val); val.SetColor(num, Color.red); val.SetFloat(num2, num3); val2.SetPropertyBlock(val); val.Clear(); } } _hurtFlashApplied = flag; } private void UpdateFootsteps(Vector3 horizontalVelocity, bool physicsControlled, bool jumping, bool falling) { //IL_0028: 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_0045: 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_005f: 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_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_00f5: 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_00f7: 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_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_011f: 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_014e: 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_0153: Invalid comparison between Unknown and I4 //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_copiedPlayer == (Object)null) { return; } Vector3 position = _visualProxy.transform.position; if (!_footstepInitialized) { _lastFootstepPosition = position; _footstepInitialized = true; return; } Vector3 val = position - _lastFootstepPosition; val.y = 0f; _lastFootstepPosition = position; if (physicsControlled || jumping || falling || !(((Vector3)(ref horizontalVelocity)).magnitude > 0.1f)) { _footstepDistance = 0f; return; } _footstepDistance += ((Vector3)(ref val)).magnitude; float num = (_aiSprinting ? 0.9f : (_aiCrouching ? 0.5f : 0.68f)); if (!(_footstepDistance < num)) { _footstepDistance %= num; SoundType val2 = (SoundType)(_aiSprinting ? 2 : ((!_aiCrouching) ? 1 : 0)); Vector3 val3 = position + Vector3.up * 0.05f; if ((Object)(object)Materials.Instance != (Object)null) { Materials.Instance.Impulse(val3, Vector3.down, val2, true, true, _copiedPlayer.MaterialTrigger, (HostType)1); } if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)EnemyDirector.instance != (Object)null && (int)val2 != 0) { float num2 = (((int)val2 == 2) ? 5f : 1f); EnemyDirector.instance.SetInvestigate(val3 + Vector3.up * 0.2f, num2, false); } } } private Vector3 GetVisualGroundPosition(Vector3 position) { //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_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) //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_0066: 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_00b4: 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_008f: Unknown result type (might be due to invalid IL or missing references) RaycastHit[] array = Physics.RaycastAll(position + Vector3.up * 1.25f, Vector3.down, 4f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); float num = float.NegativeInfinity; RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val = array2[i]; if (!((RaycastHit)(ref val)).transform.IsChildOf(((Component)_parent).transform) && ((RaycastHit)(ref val)).point.y <= position.y + 0.75f && ((RaycastHit)(ref val)).point.y > num) { num = ((RaycastHit)(ref val)).point.y; } } if (!float.IsNegativeInfinity(num)) { position.y = num; } return position; } private void LateUpdate() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00bc: 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_008d: 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) if ((Object)(object)_visualProxy == (Object)null) { return; } if ((Object)(object)_proxyRightArm != (Object)null && (Object)(object)_proxyRightArm.rightArmTransform != (Object)null) { bool num = _mapInspectActive || _mapOpenLerp > 0.01f; bool flag = _gunDrawn || (Object)(object)_grabTarget != (Object)null || _meleeAnimationTimer > 0f; Vector3 val = (num ? _proxyRightArm.mapPose : (flag ? _proxyRightArm.grabberPose : _proxyRightArm.basePose)); _proxyRightArm.rightArmTransform.localRotation = Quaternion.Slerp(_proxyRightArm.rightArmTransform.localRotation, Quaternion.Euler(val), Mathf.Clamp01(Time.deltaTime * 12f)); UpdatePlayerGrabberArm((Object)(object)_grabTarget != (Object)null && _grabTimer > 0f); } UpdateMapVisual(); UpdateHeldFlashlight(); if ((Object)(object)_weaponHold != (Object)null && _gunDrawn) { Vector3 val2 = _aimPoint - _visualProxy.transform.position; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = _visualProxy.transform.forward; } ((Vector3)(ref val2)).Normalize(); float num2 = (_aiCrouching ? 0.48f : 0.76f); _weaponHold.position = _visualProxy.transform.position + Vector3.up * num2 + _visualProxy.transform.right * 0.2f + val2 * 0.24f; _weaponHold.rotation = Quaternion.LookRotation(val2, Vector3.up); } UpdateEyeMovement(); UpdateProceduralPlayerBody(); UpdateVoiceMouth(); UpdateGrabBeam(); UpdateForwardFlashlight(); } private void CreateForwardFlashlight() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_visualProxy == (Object)null) && !((Object)(object)_flashlightLightRig != (Object)null)) { CreateHeldFlashlightVisual(); _flashlightLightRig = new GameObject("Doppelganger Flashlight Beam"); _flashlightLightRig.transform.SetParent(_visualProxy.transform, false); _flashlight = _flashlightLightRig.AddComponent(); _flashlight.type = (LightType)0; _flashlight.color = new Color(0.94f, 0.97f, 1f); _flashlight.intensity = 3.4f; _flashlight.range = 22f; _flashlight.spotAngle = 58f; _flashlight.innerSpotAngle = 34f; _flashlight.shadows = (LightShadows)2; _flashlight.shadowStrength = 0.72f; _flashlight.renderMode = (LightRenderMode)0; } } private void CreateHeldFlashlightVisual() { //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_00e0: 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_00ff: 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_042a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_flashlightVisualRig != (Object)null) { return; } FlashlightController sourceFlashlight = _copiedPlayer?.flashlightController; _flashlightOnSound = sourceFlashlight?.lightOnAudio; _flashlightOffSound = sourceFlashlight?.lightOffAudio; Transform val = null; if ((Object)(object)sourceFlashlight?.FollowTransformClient != (Object)null) { int num = Array.IndexOf(_sourceTransforms, sourceFlashlight.FollowTransformClient); if (num >= 0 && num < _proxyTransforms.Length) { val = _proxyTransforms[num]; } } if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("Doppelganger Flashlight Hand Anchor"); val2.transform.SetParent(_visualProxy.transform, false); val2.transform.localPosition = new Vector3(-0.18f, 0.72f, 0.28f); val2.transform.localRotation = Quaternion.identity; val = val2.transform; } _flashlightVisualAnchor = val; if ((Object)(object)sourceFlashlight == (Object)null || (Object)(object)sourceFlashlight.mesh == (Object)null) { CreateFallbackFlashlightModel(val); return; } try { Transform val3 = ((Component)sourceFlashlight).transform; if ((Object)(object)val3 == (Object)(object)((Component)_copiedPlayer).transform || ((Component)_copiedPlayer).transform.IsChildOf(val3)) { val3 = (((Object)(object)sourceFlashlight.hideTransform != (Object)null) ? sourceFlashlight.hideTransform : ((Component)sourceFlashlight.mesh).transform); } bool activeSelf = ((Component)val3).gameObject.activeSelf; ((Component)val3).gameObject.SetActive(false); try { _flashlightVisualRig = Object.Instantiate(((Component)val3).gameObject, val, false); } finally { ((Component)val3).gameObject.SetActive(activeSelf); } ((Object)_flashlightVisualRig).name = "Doppelganger Held Player Flashlight"; _flashlightHideTransform = FindClonedTransform(val3, sourceFlashlight.hideTransform, _flashlightVisualRig.transform); _flashlightClickTransform = FindClonedTransform(val3, sourceFlashlight.clickTransform, _flashlightVisualRig.transform); Transform val4 = FindClonedTransform(val3, ((Component)sourceFlashlight.mesh).transform, _flashlightVisualRig.transform); MeshRenderer val5 = (MeshRenderer)(((Object)(object)val4 != (Object)null) ? ((object)((Component)val4).GetComponent()) : ((object)((IEnumerable)_flashlightVisualRig.GetComponentsInChildren(true)).FirstOrDefault((Func)((MeshRenderer renderer) => ((Object)renderer).name == ((Object)sourceFlashlight.mesh).name)))); MonoBehaviour[] componentsInChildren = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num2]); } AudioLowPassFilter[] componentsInChildren2 = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren2.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[num2]); } AudioSource[] componentsInChildren3 = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren3.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[num2]); } Light[] componentsInChildren4 = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren4.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[num2]); } Collider[] componentsInChildren5 = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren5.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[num2]); } Rigidbody[] componentsInChildren6 = _flashlightVisualRig.GetComponentsInChildren(true); for (int num2 = 0; num2 < componentsInChildren6.Length; num2++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[num2]); } _flashlightModelRenderers = _flashlightVisualRig.GetComponentsInChildren(true); Renderer[] flashlightModelRenderers = _flashlightModelRenderers; foreach (Renderer obj in flashlightModelRenderers) { obj.enabled = (Object)(object)obj == (Object)(object)val5; obj.shadowCastingMode = (ShadowCastingMode)1; obj.receiveShadows = true; } if ((Object)(object)val5 != (Object)null) { Transform val6 = ((Component)val5).transform; while ((Object)(object)val6 != (Object)(object)_flashlightVisualRig.transform) { ((Component)val6).gameObject.SetActive(true); val6 = val6.parent; } } _flashlightVisualRig.transform.localPosition = Vector3.zero; _flashlightVisualRig.transform.localRotation = Quaternion.identity; _flashlightVisualRig.transform.localScale = Vector3.one; if ((Object)(object)_flashlightHideTransform != (Object)null) { _flashlightHideBaseRotation = _flashlightHideTransform.localRotation; } if ((Object)(object)_flashlightClickTransform != (Object)null) { _flashlightClickBaseRotation = _flashlightClickTransform.localRotation; } _flashlightHiddenAngle = ((Mathf.Abs(sourceFlashlight.hiddenRot) > 1f) ? Mathf.Abs(sourceFlashlight.hiddenRot) : 55f); _flashlightClickStrength = ((Mathf.Abs(sourceFlashlight.clickStrength) > 0.5f) ? Mathf.Abs(sourceFlashlight.clickStrength) : 8f); _flashlightVisualRig.SetActive(true); InitializeFlashlightState(); Plugin.Log.LogInfo((object)"Doppelganger copied the player's real handheld flashlight visual."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not copy the player's flashlight visual; using the physical fallback: " + ex.Message)); if ((Object)(object)_flashlightVisualRig != (Object)null) { Object.Destroy((Object)(object)_flashlightVisualRig); _flashlightVisualRig = null; } CreateFallbackFlashlightModel(val); } } private void CreateFallbackFlashlightModel(Transform anchor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_005f: 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_012a: 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_0168: 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_00c7: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) _flashlightVisualRig = new GameObject("Doppelganger Held Flashlight Fallback"); _flashlightVisualRig.transform.SetParent(anchor, false); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "Flashlight Body"; obj.transform.SetParent(_flashlightVisualRig.transform, false); obj.transform.localPosition = new Vector3(0f, 0f, 0.13f); obj.transform.localScale = new Vector3(0.11f, 0.09f, 0.3f); Object.DestroyImmediate((Object)(object)obj.GetComponent()); Renderer component = obj.GetComponent(); Shader val = Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if ((Object)(object)val != (Object)null) { component.material = new Material(val); component.material.color = new Color(0.12f, 0.14f, 0.16f); } component.shadowCastingMode = (ShadowCastingMode)1; GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj2).name = "Flashlight Lens"; obj2.transform.SetParent(_flashlightVisualRig.transform, false); obj2.transform.localPosition = new Vector3(0f, 0f, 0.3f); obj2.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); obj2.transform.localScale = new Vector3(0.085f, 0.035f, 0.085f); Object.DestroyImmediate((Object)(object)obj2.GetComponent()); Renderer component2 = obj2.GetComponent(); if ((Object)(object)val != (Object)null) { component2.material = new Material(val); component2.material.color = new Color(0.75f, 0.82f, 0.88f); } component2.shadowCastingMode = (ShadowCastingMode)1; _flashlightModelRenderers = _flashlightVisualRig.GetComponentsInChildren(true); _flashlightVisualRig.transform.localPosition = Vector3.zero; _flashlightVisualRig.transform.localRotation = Quaternion.identity; _flashlightVisualRig.transform.localScale = Vector3.one; InitializeFlashlightState(); Plugin.Log.LogWarning((object)"Doppelganger is using its fallback handheld flashlight model."); } private void InitializeFlashlightState() { _flashlightDesiredOn = !_aiCrouching && !_visualTumbling && !_dead && _parent.Spawned; _flashlightTransition = (_flashlightDesiredOn ? 1f : 0f); _flashlightInitialized = true; } private static Transform? FindClonedTransform(Transform sourceRoot, Transform? sourceTarget, Transform clonedRoot) { if ((Object)(object)sourceTarget == (Object)null) { return null; } if ((Object)(object)sourceTarget == (Object)(object)sourceRoot) { return clonedRoot; } Stack stack = new Stack(); Transform val = sourceTarget; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)sourceRoot) { stack.Push(val.GetSiblingIndex()); val = val.parent; } if ((Object)(object)val != (Object)(object)sourceRoot) { return null; } Transform val2 = clonedRoot; while (stack.Count > 0) { int num = stack.Pop(); if (num < 0 || num >= val2.childCount) { return null; } val2 = val2.GetChild(num); } return val2; } private void UpdateHeldFlashlight() { //IL_0102: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_014b: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_visualProxy == (Object)null || (Object)(object)_flashlightVisualRig == (Object)null) { return; } bool flag = !_aiCrouching && !_visualTumbling && !_deathAnimationActive && !_dead && _parent.Spawned; if (!_flashlightInitialized) { InitializeFlashlightState(); } else if (flag != _flashlightDesiredOn) { _flashlightDesiredOn = flag; _flashlightClickTimer = 0.24f; PlayFlashlightToggleSound(flag ? _flashlightOnSound : _flashlightOffSound); } float num = (flag ? 2.5f : 3.3f); _flashlightTransition = Mathf.MoveTowards(_flashlightTransition, flag ? 1f : 0f, Time.deltaTime * num); float num2 = Mathf.SmoothStep(0f, 1f, _flashlightTransition); if (flag && !_flashlightVisualRig.activeSelf) { _flashlightVisualRig.SetActive(true); } _flashlightVisualRig.transform.localScale = Vector3.one * num2; if ((Object)(object)_flashlightHideTransform != (Object)null) { Quaternion val = _flashlightHideBaseRotation * Quaternion.Euler(0f, _flashlightHiddenAngle, 0f - _flashlightHiddenAngle); _flashlightHideTransform.localRotation = Quaternion.Slerp(val, _flashlightHideBaseRotation, num2); } if ((Object)(object)_flashlightClickTransform != (Object)null) { if (_flashlightClickTimer > 0f) { float num3 = Mathf.Sin(Mathf.Clamp01(1f - _flashlightClickTimer / 0.24f) * MathF.PI) * _flashlightClickStrength; _flashlightClickTransform.localRotation = _flashlightClickBaseRotation * Quaternion.Euler(0f, 0f - num3, 0f); _flashlightClickTimer = Mathf.Max(0f, _flashlightClickTimer - Time.deltaTime); } else { _flashlightClickTransform.localRotation = _flashlightClickBaseRotation; } } if ((Object)(object)_proxyLeftArm != (Object)null && (Object)(object)_proxyLeftArm.leftArmTransform != (Object)null) { Vector3 val2 = Vector3.Lerp(_proxyLeftArm.basePose, _proxyLeftArm.flashlightPose, num2); _proxyLeftArm.leftArmTransform.localRotation = Quaternion.Slerp(_proxyLeftArm.leftArmTransform.localRotation, Quaternion.Euler(val2), Mathf.Clamp01(Time.deltaTime * 12f)); } if (!flag && _flashlightTransition <= 0f && _flashlightVisualRig.activeSelf) { _flashlightVisualRig.SetActive(false); } } private void PlayFlashlightToggleSound(Sound? sound) { //IL_006f: 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) if (sound == null || sound.Sounds == null || sound.Sounds.Length == 0 || (Object)(object)_visualProxy == (Object)null) { return; } AudioSource source = sound.Source; float spatialBlend = sound.SpatialBlend; sound.Source = null; sound.SpatialBlend = 1f; try { sound.Play(((Object)(object)_flashlightVisualRig != (Object)null) ? _flashlightVisualRig.transform.position : _visualProxy.transform.position, 0.55f, 1f, 1f, 1f); } finally { sound.Source = source; sound.SpatialBlend = spatialBlend; } } private void UpdateForwardFlashlight() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00eb: 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_00e5: 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_00cf: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0151: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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) if ((Object)(object)_flashlightLightRig == (Object)null || (Object)(object)_flashlight == (Object)null || (Object)(object)_visualProxy == (Object)null) { return; } float num = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.42f, 1f, _flashlightTransition)); ((Behaviour)_flashlight).enabled = num > 0.01f && !_dead && _parent.Spawned && _visualProxy.activeInHierarchy; if (!((Behaviour)_flashlight).enabled) { return; } _flashlight.intensity = 3.4f * num; Vector3 val = _visualProxy.transform.forward; Vector3 val2 = _bodyLookPoint; if (_gunDrawn && _hasPoseAim) { val2 = _aimPoint; } else if (_heardSoundTimer > 0f) { val2 = _heardSoundPosition; } if (val2 != Vector3.zero) { Vector3 val3 = val2 - _visualProxy.transform.position; if (((Vector3)(ref val3)).sqrMagnitude > 0.05f) { val = ((Vector3)(ref val3)).normalized; } } Vector3 val4 = (((Object)(object)_flashlightVisualRig != (Object)null && _flashlightVisualRig.activeInHierarchy) ? (_flashlightVisualRig.transform.position + val * 0.2f) : (_visualProxy.transform.position + Vector3.up * 0.9f + val * 0.2f)); Quaternion val5 = Quaternion.LookRotation(val, Vector3.up); _flashlightLightRig.transform.position = Vector3.Lerp(_flashlightLightRig.transform.position, val4, Mathf.Clamp01(Time.deltaTime * 18f)); _flashlightLightRig.transform.rotation = Quaternion.Slerp(_flashlightLightRig.transform.rotation, val5, Mathf.Clamp01(Time.deltaTime * 12f)); } private void UpdateMapVisual() { //IL_009d: 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_00d2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_mapVisualRig == (Object)null)) { float num = (_mapInspectActive ? 2.8f : 3.4f); if (_mapInspectActive && !_mapVisualRig.activeSelf) { _mapVisualRig.SetActive(true); } _mapOpenLerp = Mathf.MoveTowards(_mapOpenLerp, _mapInspectActive ? 1f : 0f, Time.deltaTime * num); float num2 = _mapOpenLerp * _mapOpenLerp * (3f - 2f * _mapOpenLerp); _mapVisualRig.transform.localScale = Vector3.one * num2; _mapVisualRig.transform.localRotation = Quaternion.Euler(Mathf.Lerp(58f, 0f, num2), 0f, 0f); if (!_mapInspectActive && _mapOpenLerp <= 0f && _mapVisualRig.activeSelf) { _mapVisualRig.SetActive(false); } } } private void UpdatePlayerGrabberArm(bool active) { //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0345: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_proxyRightArm == (Object)null) { return; } float num = (active ? 1f : (-1f)); _grabClawLerp = Mathf.Clamp01(_grabClawLerp + num * 3f * Time.deltaTime); if ((Object)(object)_proxyRightArm.grabberClawParent != (Object)null) { bool flag = _grabClawLerp > 0.001f; if (((Component)_proxyRightArm.grabberClawParent).gameObject.activeSelf != flag) { ((Component)_proxyRightArm.grabberClawParent).gameObject.SetActive(flag); } if (flag) { _grabClawCycle = Mathf.Repeat(_grabClawCycle + Time.deltaTime, 1f); float num2 = 0.5f + Mathf.Sin(_grabClawCycle * MathF.PI * 2f) * 0.5f; float num3 = Mathf.SmoothStep(0f, 1f, _grabClawLerp); _proxyRightArm.grabberClawParent.localScale = Vector3.one * num3; _proxyRightArm.grabberClawParent.Rotate(0f, 0f, Mathf.Lerp(500f, 200f, num2) * Time.deltaTime, (Space)1); if (_proxyRightArm.grabberClawChildren != null) { Quaternion localRotation = Quaternion.Euler(Mathf.Lerp(60f, 80f, num2), 0f, 0f); Transform[] grabberClawChildren = _proxyRightArm.grabberClawChildren; foreach (Transform val in grabberClawChildren) { if ((Object)(object)val != (Object)null) { val.localRotation = localRotation; } } } if ((Object)(object)_proxyRightArm.grabberOrb != (Object)null) { _proxyRightArm.grabberOrb.localScale = Vector3.one * Mathf.Lerp(1f, 1.2f, num2); } if ((Object)(object)_proxyRightArm.grabberLight != (Object)null) { ((Behaviour)_proxyRightArm.grabberLight).enabled = active; } } } if ((Object)(object)_proxyRightArm.grabberTransform != (Object)null && (Object)(object)_proxyRightArm.grabberTransformTarget != (Object)null) { _proxyRightArm.grabberTransform.SetPositionAndRotation(_proxyRightArm.grabberTransformTarget.position, _proxyRightArm.grabberTransformTarget.rotation); _proxyRightArm.grabberTransform.localScale = _proxyRightArm.grabberTransformTarget.localScale; } if (active && (Object)(object)_grabTarget != (Object)null && (Object)(object)_proxyRightArm.rightArmParentTransform != (Object)null) { Transform rightArmParentTransform = _proxyRightArm.rightArmParentTransform; Quaternion localRotation2 = rightArmParentTransform.localRotation; rightArmParentTransform.LookAt(_grabTarget.centerPoint); Quaternion localRotation3 = rightArmParentTransform.localRotation; rightArmParentTransform.localRotation = Quaternion.Slerp(localRotation2, localRotation3, Mathf.Clamp01(Time.deltaTime * 16f)); } else if ((Object)(object)_proxyRightArm.rightArmParentTransform != (Object)null) { Transform rightArmParentTransform2 = _proxyRightArm.rightArmParentTransform; rightArmParentTransform2.localRotation = Quaternion.Slerp(rightArmParentTransform2.localRotation, Quaternion.identity, Mathf.Clamp01(Time.deltaTime * 18f)); rightArmParentTransform2.localScale = Vector3.Lerp(rightArmParentTransform2.localScale, Vector3.one, Mathf.Clamp01(Time.deltaTime * 18f)); } } private void UpdateProceduralPlayerBody() { //IL_0037: 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_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_0069: 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_0073: 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_00a1: 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_00ac: 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_011d: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_proxyAvatarVisuals == (Object)null) && !((Object)(object)_visualProxy == (Object)null)) { bool num = _visualTumbling || _deathAnimationActive || _sabotageAnimationActive; Vector3 val = GetProceduralLookPoint() - _visualProxy.transform.position; Vector3 val2 = _visualProxy.transform.InverseTransformDirection(((Vector3)(ref val)).normalized); float num2 = (num ? 0f : Mathf.Clamp(Mathf.Atan2(val2.x, val2.z) * 57.29578f, -58f, 58f)); Vector2 val3 = new Vector2(val2.x, val2.z); float magnitude = ((Vector2)(ref val3)).magnitude; float num3 = (num ? 0f : Mathf.Clamp((0f - Mathf.Atan2(val2.y, Mathf.Max(0.01f, magnitude))) * 57.29578f, -55f, 65f)); float amount = Mathf.Clamp01(Time.deltaTime * 10f); SetLocalRotation(_proxyAvatarVisuals.headUpTransform, Quaternion.Euler(num3 * 0.5f, 0f, 0f), amount); SetLocalRotation(_proxyAvatarVisuals.bodyTopUpTransform, Quaternion.Euler(num3 * 0.25f, 0f, 0f), amount); SetLocalRotation(_proxyAvatarVisuals.headSideTransform, Quaternion.Euler(0f, num2 * 0.55f, 0f), amount); SetLocalRotation(_proxyAvatarVisuals.bodyTopSideTransform, Quaternion.Euler(0f, num2 * 0.28f, 0f), amount); Vector3 val4 = Vector3.zero; if (_enemy.HasNavMeshAgent && (Object)(object)_enemy.NavMeshAgent != (Object)null) { val4 = _enemy.NavMeshAgent.AgentVelocity; } if (((Vector3)(ref val4)).sqrMagnitude < 0.01f && _enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) { val4 = _enemy.Rigidbody.velocity; } Vector3 val5 = _visualProxy.transform.InverseTransformDirection(val4); val3 = new Vector2(val5.x, val5.z); float magnitude2 = ((Vector2)(ref val3)).magnitude; float num4 = (num ? 0f : Mathf.Clamp(val5.z * 1.15f + num3 * 0.05f, -4.5f, 5.5f)); SetLocalRotation(rotation: Quaternion.Euler(num4, 0f, num ? 0f : Mathf.Clamp((0f - val5.x) * 1.4f + num2 * 0.035f, -5.5f, 5.5f)), target: _proxyAvatarVisuals.leanTransform, amount: Mathf.Clamp01(Time.deltaTime * 8f)); float num5 = ((magnitude2 > 0.1f) ? (Mathf.Sin(Time.time * (_aiSprinting ? 10f : 6f)) * (_aiSprinting ? 2.2f : 0.8f)) : 0f); SetLocalRotation(_proxyAvatarVisuals.tiltTransform, Quaternion.Euler(num5, 0f, (0f - num5) * 0.35f), Mathf.Clamp01(Time.deltaTime * 7f)); float num6 = ((num || magnitude2 <= 0.1f) ? 0f : Mathf.Clamp(Mathf.Atan2(val5.x, val5.z) * 57.29578f, -32f, 32f)); SetLocalRotation(_proxyAvatarVisuals.legTwistTransform, Quaternion.Euler(0f, num6, 0f), Mathf.Clamp01(Time.deltaTime * 8f)); } } private Vector3 GetProceduralLookPoint() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0105: 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_014e: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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) if ((Object)(object)_visualProxy == (Object)null) { return ((Component)this).transform.position + ((Component)this).transform.forward * 4f; } if (_gunDrawn && _hasPoseAim) { return _aimPoint; } if (_heardSoundTimer > 0f) { return _heardSoundPosition; } if ((Object)(object)_eyeTalker != (Object)null && _eyeTalkerTimer > 0f) { return GetTalkerLookPosition(_eyeTalker); } _bodyLookTimer -= Time.deltaTime; Vector3 val; Vector3 val2; if (_bodyLookTimer <= 0f) { _bodyLookTimer = Random.Range(0.65f, 2.1f); _bodyLookYaw = Random.Range(-38f, 38f); _bodyLookPitch = Random.Range(-22f, 28f); if (_hasPoseAim) { val = _aimPoint - _visualProxy.transform.position; if (((Vector3)(ref val)).sqrMagnitude > 0.1f) { val = _aimPoint - _visualProxy.transform.position; val2 = ((Vector3)(ref val)).normalized; goto IL_014e; } } val2 = _visualProxy.transform.forward; goto IL_014e; } goto IL_01c3; IL_01c3: if (!(_bodyLookPoint == Vector3.zero)) { return _bodyLookPoint; } return _visualProxy.transform.position + _visualProxy.transform.forward * 4f; IL_014e: Vector3 val3 = val2; Vector3 val4 = Quaternion.AngleAxis(_bodyLookYaw, Vector3.up) * val3; val = Vector3.Cross(Vector3.up, val4); Vector3 normalized = ((Vector3)(ref val)).normalized; val4 = Quaternion.AngleAxis(_bodyLookPitch, normalized) * val4; _bodyLookPoint = _visualProxy.transform.position + ((Vector3)(ref val4)).normalized * Random.Range(3f, 6f); goto IL_01c3; } private static void SetLocalRotation(Transform? target, Quaternion rotation, float amount) { //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_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)null) { target.localRotation = Quaternion.Slerp(target.localRotation, rotation, amount); } } private void UpdateVoiceMouth() { //IL_00ff: 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_011c: 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_0133: 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) if ((Object)(object)_proxyTalkAnimation == (Object)null || (Object)(object)_proxyTalkAnimation.objectToRotate == (Object)null) { return; } float num = 0f; AudioSource voicePlaybackSource = _voicePlaybackSource; if ((Object)(object)voicePlaybackSource != (Object)null && voicePlaybackSource.isPlaying && (Object)(object)voicePlaybackSource.clip != (Object)null) { try { int num2 = Mathf.Clamp(voicePlaybackSource.timeSamples, 0, Mathf.Max(0, voicePlaybackSource.clip.samples - _voiceMouthSamples.Length)); if (voicePlaybackSource.clip.GetData(_voiceMouthSamples, num2)) { float num3 = 0f; for (int i = 0; i < _voiceMouthSamples.Length; i++) { num3 += Mathf.Abs(_voiceMouthSamples[i]); } num = Mathf.Clamp01(num3 / (float)_voiceMouthSamples.Length * 7.5f); } } catch { num = 0f; } } float num4 = Mathf.Max(1f, _proxyTalkAnimation.rotationMaxAngle); Quaternion val = _mouthClosedRotation * Quaternion.Euler((0f - num4) * num, 0f, 0f); Transform transform = _proxyTalkAnimation.objectToRotate.transform; transform.localRotation = Quaternion.Slerp(transform.localRotation, val, Mathf.Clamp01(Time.deltaTime * 22f)); } private void UpdateEyeMovement() { //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_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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_014f: 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_0173: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_proxyEyes == (Object)null || (Object)(object)_proxyEyes.eyeLeft == (Object)null || (Object)(object)_proxyEyes.eyeRight == (Object)null || (Object)(object)_proxyEyes.lookAt == (Object)null || (Object)(object)_visualProxy == (Object)null) { return; } _heardSoundTimer = Mathf.Max(0f, _heardSoundTimer - Time.deltaTime); _eyeTalkerTimer = Mathf.Max(0f, _eyeTalkerTimer - Time.deltaTime); UpdateEyeTalker(); Vector3 val; if (_gunDrawn) { val = _aimPoint; } else if (_heardSoundTimer > 0f) { val = _heardSoundPosition; } else if ((Object)(object)_eyeTalker != (Object)null && _eyeTalkerTimer > 0f) { val = GetTalkerLookPosition(_eyeTalker); } else { _eyeIdleTimer -= Time.deltaTime; if (_eyeIdleTimer <= 0f) { _eyeIdleTimer = Random.Range(0.7f, 1.8f); _eyeIdleTarget = _visualProxy.transform.position + _visualProxy.transform.forward * 3f + _visualProxy.transform.right * Random.Range(-0.9f, 0.9f) + Vector3.up * Random.Range(0.45f, 1.15f); } val = _eyeIdleTarget; } Vector3 val2 = val - _proxyEyes.eyeLeft.position; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { return; } try { _proxyEyes.deltaTime = Time.deltaTime; _proxyEyes.lookAt.position = val; Transform eyeRight = _proxyEyes.eyeRight; SpringQuaternion springQuaternionRight = _proxyEyes.springQuaternionRight; _proxyEyes.EyeLookAt(ref eyeRight, ref springQuaternionRight, true, 50f, 30f); _proxyEyes.eyeRight = eyeRight; _proxyEyes.springQuaternionRight = springQuaternionRight; Transform eyeLeft = _proxyEyes.eyeLeft; SpringQuaternion springQuaternionLeft = _proxyEyes.springQuaternionLeft; _proxyEyes.EyeLookAt(ref eyeLeft, ref springQuaternionLeft, true, 50f, 30f); _proxyEyes.eyeLeft = eyeLeft; _proxyEyes.springQuaternionLeft = springQuaternionLeft; } catch (Exception ex) { if (!_eyeFailureLogged) { _eyeFailureLogged = true; Plugin.Log.LogWarning((object)("Player-style eye movement was disabled: " + ex.Message)); } _proxyEyes = null; } } private void UpdateEyeTalker() { //IL_007a: 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) PlayerAvatar val = null; float num = float.MinValue; if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)_visualProxy != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !player.isDisabled && !((Object)(object)player.voiceChat == (Object)null) && player.voiceChat.isTalking && !(Vector3.Distance(_visualProxy.transform.position, ((Component)player).transform.position) >= 6f) && player.voiceChat.isTalkingStartTime > num) { num = player.voiceChat.isTalkingStartTime; val = player; } } } if ((Object)(object)val != (Object)null) { if ((Object)(object)_eyeTalker != (Object)(object)val || _eyeTalkerTimer < 1.5f) { _eyeTalkerTimer = Random.Range(2f, 4f); } _eyeTalker = val; } else if (_eyeTalkerTimer <= 0f) { _eyeTalker = null; } } private static Vector3 GetTalkerLookPosition(PlayerAvatar talker) { //IL_002b: 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_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_0052: 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) if ((Object)(object)talker.voiceChat != (Object)null && talker.voiceChat.overridePositionTimer > 0f) { return ((Component)talker.voiceChat).transform.position; } if (talker.isLocal && (Object)(object)talker.localCamera != (Object)null) { return ((Component)talker.localCamera).transform.position; } if ((Object)(object)talker.playerAvatarVisuals != (Object)null && (Object)(object)talker.playerAvatarVisuals.headLookAtTransform != (Object)null) { return talker.playerAvatarVisuals.headLookAtTransform.position; } return ((Component)talker).transform.position + Vector3.up * 0.75f; } internal void LookAtSoundHost(Vector3 position, float duration = 1.6f) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { if (SemiFunc.IsMultiplayer()) { _photonView.RPC("LookAtSoundRpc", (RpcTarget)0, new object[2] { position, duration }); } else { ApplySoundLook(position, duration); } } } [PunRPC] private void LookAtSoundRpc(Vector3 position, float duration, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: 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) if (SemiFunc.MasterOnlyRPC(info)) { ApplySoundLook(position, duration); } } private void ApplySoundLook(Vector3 position, float duration) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _heardSoundPosition = position; _heardSoundTimer = Mathf.Max(_heardSoundTimer, duration); } private void SetAnimatorBool(string name, bool value) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 if ((Object)(object)_proxyAnimator == (Object)null) { return; } AnimatorControllerParameter[] parameters = _proxyAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { if ((int)val.type == 4 && val.name == name) { _proxyAnimator.SetBool(name, value); break; } } } private void SetAnimatorTrigger(string name) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if ((Object)(object)_proxyAnimator == (Object)null) { return; } AnimatorControllerParameter[] parameters = _proxyAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { if ((int)val.type == 9 && val.name == name) { _proxyAnimator.SetTrigger(name); break; } } } private void EnforceOriginalVisualsHidden() { foreach (Renderer hiddenOriginalRenderer in _hiddenOriginalRenderers) { if ((Object)(object)hiddenOriginalRenderer != (Object)null && hiddenOriginalRenderer.enabled) { hiddenOriginalRenderer.enabled = false; } } } private void UpdateNameTag() { //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_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_005a: 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_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_0099: 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_00a9: 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_00c9: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_016d: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_nameTag == (Object)null) && !((Object)(object)_visualProxy == (Object)null) && !((Object)(object)Camera.main == (Object)null)) { Vector3 val = _visualProxy.transform.position + Vector3.up * 1.35f; _nameTag.transform.position = val; _nameTag.transform.rotation = Quaternion.LookRotation(_nameTag.transform.position - ((Component)Camera.main).transform.position); Vector3 val2 = val - ((Component)Camera.main).transform.position; float magnitude = ((Vector3)(ref val2)).magnitude; bool flag = magnitude <= 15f && Vector3.Dot(((Component)Camera.main).transform.forward, ((Vector3)(ref val2)).normalized) > 0.975f; RaycastHit val3 = default(RaycastHit); if (flag && Physics.Raycast(((Component)Camera.main).transform.position, ((Vector3)(ref val2)).normalized, ref val3, magnitude, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { flag = (Object)(object)((RaycastHit)(ref val3)).transform == (Object)(object)((Component)this).transform || ((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform); } float num = ((flag && (Object)(object)GameplayManager.instance != (Object)null && GameplayManager.instance.playerNames) ? 0.5f : 0f); Color color = ((Graphic)_nameTag).color; color.a = Mathf.Lerp(color.a, num, Time.deltaTime * 8f); ((Graphic)_nameTag).color = color; } } internal void SetCombatPoseHost(bool sprinting, bool crouching, bool gunDrawn, Vector3 aimPoint) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_008d: 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_00c8: 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_0072: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } bool num = _aiSprinting != sprinting || _aiCrouching != crouching || _gunDrawn != gunDrawn; int num2; if (Time.time - _lastPoseSyncTime >= 0.15f) { if (_hasPoseAim) { Vector3 val = _lastSyncedAimPoint - aimPoint; num2 = ((((Vector3)(ref val)).sqrMagnitude >= 0.02f) ? 1 : 0); } else { num2 = 1; } } else { num2 = 0; } bool flag = (byte)num2 != 0; if (!num && !flag) { _aimPoint = aimPoint; _hasPoseAim = true; return; } _lastPoseSyncTime = Time.time; _lastSyncedAimPoint = aimPoint; if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SetCombatPoseRpc", (RpcTarget)0, new object[4] { sprinting, crouching, gunDrawn, aimPoint }); } else { ApplyCombatPose(sprinting, crouching, gunDrawn, aimPoint); } } [PunRPC] private void SetCombatPoseRpc(bool sprinting, bool crouching, bool gunDrawn, Vector3 aimPoint, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { ApplyCombatPose(sprinting, crouching, gunDrawn, aimPoint); } } private void ApplyCombatPose(bool sprinting, bool crouching, bool gunDrawn, Vector3 aimPoint) { //IL_0016: 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) _aiSprinting = sprinting; _aiCrouching = crouching; _gunDrawn = gunDrawn; _aimPoint = aimPoint; _hasPoseAim = true; } internal void SetMapInspectHost(bool active) { if (SemiFunc.IsMasterClientOrSingleplayer() && _mapInspectActive != active) { if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SetMapInspectRpc", (RpcTarget)0, new object[1] { active }); } else { ApplyMapInspect(active); } } } [PunRPC] private void SetMapInspectRpc(bool active, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { ApplyMapInspect(active); } } private void ApplyMapInspect(bool active) { if (_mapInspectActive == active) { return; } _mapInspectActive = active; if (active) { if ((Object)(object)_mapVisualRig == (Object)null) { CreateMapVisual(); } PlayMapOneShot(_mapStartSound); if ((Object)(object)_mapLoopAudio != (Object)null && (Object)(object)_mapLoopAudio.clip != (Object)null) { _mapLoopAudio.Play(); AudioLowPassLogic component = ((Component)_mapLoopAudio).GetComponent(); if (component != null) { component.Setup(); } } } else { if ((Object)(object)_mapLoopAudio != (Object)null) { _mapLoopAudio.Stop(); } PlayMapOneShot(_mapStopSound); } } private void PlayMapOneShot(Sound? sound) { if (!((Object)(object)_mapOneShotAudio == (Object)null) && sound != null && sound.Sounds != null && sound.Sounds.Length != 0) { _mapOneShotAudio.clip = sound.Sounds[Random.Range(0, sound.Sounds.Length)]; _mapOneShotAudio.volume = Mathf.Clamp01(sound.Volume * 0.35f); _mapOneShotAudio.pitch = Mathf.Max(0.1f, sound.Pitch + Random.Range(0f - sound.PitchRandom, sound.PitchRandom)); if ((Object)(object)sound.Source != (Object)null) { _mapOneShotAudio.outputAudioMixerGroup = sound.Source.outputAudioMixerGroup; } _mapOneShotAudio.Play(); AudioLowPassLogic component = ((Component)_mapOneShotAudio).GetComponent(); if (component != null) { component.Setup(); } } } internal void PlaySabotageVisualHost() { //IL_0029: 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) if (SemiFunc.IsMasterClientOrSingleplayer()) { if (SemiFunc.IsMultiplayer()) { _photonView.RPC("PlaySabotageVisualRpc", (RpcTarget)0, Array.Empty()); } else { PlaySabotageVisualRpc(); } } } [PunRPC] private void PlaySabotageVisualRpc(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { ((MonoBehaviour)this).StartCoroutine(SabotageVisualCoroutine()); } } private IEnumerator SabotageVisualCoroutine() { _sabotageAnimationActive = true; _gunDrawn = false; _aiSprinting = false; _aiCrouching = false; SetAnimatorTrigger("TumblingImpulse"); SetAnimatorBool("Moving", value: false); SetAnimatorBool("Sprinting", value: false); SetAnimatorBool("Tumbling", value: true); SetAnimatorBool("TumblingMove", value: true); yield return (object)new WaitForSeconds(1.05f); _sabotageAnimationActive = false; SetAnimatorBool("Tumbling", value: false); SetAnimatorBool("TumblingMove", value: false); } internal bool TryMeleeHost(PlayerAvatar victim) { //IL_0050: 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_008f: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)victim == (Object)null || victim.isDisabled || victim.deadSet || _meleeCooldown > 0f) { return false; } _meleeCooldown = 1.15f; victim.playerHealth.HurtOther(Plugin.MeleeDamage.Value, ((Component)victim).transform.position, false, SemiFunc.EnemyGetIndex(_enemy), false); if (SemiFunc.IsMultiplayer()) { _photonView.RPC("MeleeVisualRpc", (RpcTarget)0, Array.Empty()); } else { MeleeVisualRpc(); } return true; } internal bool ShootHost(PlayerAvatar victim, Vector3 hitPoint) { //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_002b: 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_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_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_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_0074: 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_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_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_00a8: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00e7: 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_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_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_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_0116: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)victim == (Object)null || victim.isDisabled || victim.deadSet) { return false; } Vector3 gunMuzzlePosition = GunMuzzlePosition; Vector3 val = hitPoint - gunMuzzlePosition; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return false; } Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(Vector3.up, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.right; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = Vector3.Cross(normalized, val2); Vector3 normalized2 = ((Vector3)(ref val3)).normalized; float num = Mathf.Lerp(0.08f, 0.55f, Mathf.InverseLerp(5.5f, 20f, magnitude)); Vector2 val4 = Random.insideUnitCircle * num; val3 = hitPoint + val2 * val4.x + normalized2 * val4.y - gunMuzzlePosition; Vector3 normalized3 = ((Vector3)(ref val3)).normalized; float num2 = Mathf.Max(25f, magnitude + 5f); Vector3 val5 = gunMuzzlePosition + normalized3 * num2; PlayerAvatar val6 = null; RaycastHit[] array = Physics.RaycastAll(gunMuzzlePosition, normalized3, num2, -5, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit first, RaycastHit second) => ((RaycastHit)(ref first)).distance.CompareTo(((RaycastHit)(ref second)).distance)); RaycastHit[] array2 = array; for (int num3 = 0; num3 < array2.Length; num3++) { RaycastHit val7 = array2[num3]; if ((Object)(object)((RaycastHit)(ref val7)).transform == (Object)null || ((RaycastHit)(ref val7)).transform.IsChildOf(((Component)_parent).transform)) { continue; } PlayerAvatar val8 = PlayerFromHitCollider(((RaycastHit)(ref val7)).collider); if ((Object)(object)val8 != (Object)null) { val5 = ((RaycastHit)(ref val7)).point; if (!val8.isDisabled && !val8.deadSet) { val6 = val8; } } else { val5 = ((RaycastHit)(ref val7)).point; } break; } if ((Object)(object)val6 != (Object)null) { val6.playerHealth.HurtOther(Plugin.GunDamage.Value, val5, false, SemiFunc.EnemyGetIndex(_enemy), false); } if (SemiFunc.IsMultiplayer()) { _photonView.RPC("ShotVisualRpc", (RpcTarget)0, new object[2] { gunMuzzlePosition, val5 }); } else { ShotVisualRpc(gunMuzzlePosition, val5); } return (Object)(object)val6 != (Object)null; } private static PlayerAvatar? PlayerFromHitCollider(Collider collider) { PlayerAvatar componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } PlayerController componentInParent2 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2.playerAvatarScript != (Object)null) { return componentInParent2.playerAvatarScript; } PlayerTumble componentInParent3 = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent3 != (Object)null && (Object)(object)componentInParent3.playerAvatar != (Object)null) { return componentInParent3.playerAvatar; } if ((Object)(object)GameDirector.instance == (Object)null) { return null; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null)) { if ((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController != (Object)null && (Object)(object)player.PlayerVisionTarget.PlayerController.col == (Object)(object)collider) { return player; } if ((Object)(object)player.tumble != (Object)null && player.tumble.colliders != null && player.tumble.colliders.Contains(collider)) { return player; } } } return null; } [PunRPC] private void ShotVisualRpc(Vector3 start, Vector3 end, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: 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_00e3: 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_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_013c: 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: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_0038: 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) if (SemiFunc.IsMultiplayer() && !SemiFunc.MasterOnlyRPC(info)) { return; } if ((Object)(object)_gunMuzzle != (Object)null) { start = _gunMuzzle.position; } try { Sound? gunShootSound = _gunShootSound; if (gunShootSound != null) { gunShootSound.Play(start, 1f, 1f, 1f, 1f); } Sound? gunShootGlobalSound = _gunShootGlobalSound; if (gunShootGlobalSound != null) { gunShootGlobalSound.Play(start, 1f, 1f, 1f, 1f); } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Handgun visual effect was unavailable: " + ex.Message)); } GameObject val = new GameObject("Doppelganger Gun Tracer"); LineRenderer val2 = val.AddComponent(); val2.positionCount = 2; val2.useWorldSpace = true; val2.startWidth = 0.035f; val2.endWidth = 0.012f; val2.startColor = new Color(1f, 0.82f, 0.22f, 1f); val2.endColor = new Color(1f, 0.2f, 0.05f, 0.1f); Shader val3 = Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); if ((Object)(object)val3 != (Object)null) { ((Renderer)val2).material = new Material(val3); } val2.SetPosition(0, start); val2.SetPosition(1, end); Plugin.StartGlobalCoroutine(DestroyTracer(val)); } private static IEnumerator DestroyTracer(GameObject tracerObject) { yield return (object)new WaitForSeconds(0.09f); if ((Object)(object)tracerObject != (Object)null) { Object.Destroy((Object)(object)tracerObject); } } [PunRPC] private void MeleeVisualRpc(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { _meleeAnimationTimer = 0.45f; } } private PlayerAvatar? GetNearestActivePlayer(float maxDistance) { //IL_004c: 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)GameDirector.instance == (Object)null) { return null; } PlayerAvatar result = null; float num = maxDistance; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !player.isDisabled && !player.deadSet) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num2 < num) { num = num2; result = player; } } } return result; } internal bool BeginDirectedGrabHost(PhysGrabObject target, float duration) { if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)target == (Object)null || (Object)(object)target.rb == (Object)null) { return false; } _directedGrab = true; _hasDirectedGrabPoint = false; if (SetGrabTargetHost(target, duration)) { return true; } _directedGrab = false; return false; } internal bool BeginAmbientCartGrabHost(PhysGrabCart cart) { if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)cart == (Object)null || (Object)(object)cart.physGrabObject == (Object)null || (Object)(object)cart.physGrabObject.rb == (Object)null) { return false; } return SetGrabTargetHost(cart.physGrabObject, Random.Range(5f, 8f)); } internal void SetDirectedGrabPointHost(Vector3 point) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && _directedGrab) { _directedGrabPoint = point; _hasDirectedGrabPoint = true; } } internal void ClearDirectedGrabPointHost() { _hasDirectedGrabPoint = false; } internal void EndDirectedGrabHost() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SetGrabTargetHost(null, 0f); } } private void HostGrabLogic() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) if (_aggressive) { if ((Object)(object)_grabTarget != (Object)null) { SetGrabTargetHost(null, 0f); } return; } int num; if ((Object)(object)_grabTarget != (Object)null) { _grabTimer -= Time.deltaTime; bool flag = _grabTarget.grabbed || _grabTarget.grabbedLocal || _grabTarget.playerGrabbing.Count > 0; if (_grabTimer <= 0f || (Object)(object)_grabTarget.rb == (Object)null || flag) { SetGrabTargetHost(null, 0f); return; } if ((Object)(object)_grabCart != (Object)null) { _grabCart.cartActive = true; _grabCart.autoTurnOffTimer = Mathf.Max(_grabCart.autoTurnOffTimer, 1f); if ((int)_grabCart.currentState != 2) { _grabCart.StateSwitch((State)2); } } if (!_grabTarget.isValuable) { num = (((Object)(object)((Component)_grabTarget).GetComponentInParent() != (Object)null) ? 1 : 0); if (num == 0) { goto IL_018d; } } else { num = 1; } _grabTarget.OverrideZeroGravity(0.2f); _grabTarget.OverrideDrag(7f, 0.2f); _grabTarget.OverrideAngularDrag(7f, 0.2f); _grabTarget.OverrideFragility(0f); _grabTarget.OverrideBreakEffects(0.2f); _grabTarget.OverrideKnockOutOfGrabDisable(0.2f); goto IL_018d; } _grabSearchTimer -= Time.deltaTime; if (_grabSearchTimer > 0f || !_brain.CanUseAmbientGrab) { return; } if ((Object)(object)(_peacefulFollowTarget ?? GetNearestActivePlayer(9f)) == (Object)null) { _grabSearchTimer = 2f; return; } _grabSearchTimer = Random.Range(4f, 8f); PhysGrabCart val = ((IEnumerable)(from cart in Object.FindObjectsOfType() where (Object)(object)cart != (Object)null && (Object)(object)cart.physGrabObject != (Object)null && (Object)(object)cart.physGrabObject.rb != (Object)null && !cart.physGrabObject.grabbed && !cart.physGrabObject.grabbedLocal && cart.physGrabObject.playerGrabbing.Count == 0 orderby Vector3.Distance(((Component)this).transform.position, ((Component)cart).transform.position) select cart)).FirstOrDefault((Func)((PhysGrabCart cart) => Vector3.Distance(((Component)this).transform.position, ((Component)cart).transform.position) <= 4f)); if ((Object)(object)val != (Object)null) { _brain.RequestAmbientCartApproachHost(val); return; } PhysGrabObject val2 = ((IEnumerable)(from item in Object.FindObjectsOfType() where (Object)(object)item != (Object)null && (Object)(object)item.rb != (Object)null && !item.rb.isKinematic && !item.grabbed && !item.grabbedLocal && item.playerGrabbing.Count == 0 && (item.isValuable || (Object)(object)((Component)item).GetComponentInParent() != (Object)null) && (Object)(object)((Component)item).GetComponentInParent() == (Object)null && (Object)(object)((Component)item).GetComponentInParent() == (Object)null orderby Vector3.Distance(((Component)this).transform.position, item.centerPoint) select item)).FirstOrDefault((Func)((PhysGrabObject item) => Vector3.Distance(((Component)this).transform.position, item.centerPoint) <= 3.2f)); if ((Object)(object)val2 != (Object)null) { SetGrabTargetHost(val2, Random.Range(3f, 5f)); } return; IL_018d: Vector3 val3 = ((!_directedGrab) ? GetFrontGrabPoint() : (_hasDirectedGrabPoint ? _directedGrabPoint : GetFrontGrabPoint())); Vector3 val4 = (((Object)(object)_grabCart != (Object)null && (Object)(object)_grabCart.cartGrabPoint != (Object)null) ? _grabCart.cartGrabPoint.position : _grabTarget.rb.worldCenterOfMass); if (num != 0 && (Object)(object)_grabCart == (Object)null) { ControlValuableHost(val3); return; } float num2 = (((Object)(object)_grabCart != (Object)null) ? 24f : 34f); float num3 = (((Object)(object)_grabCart != (Object)null) ? 8f : 10f); Vector3 val5 = (val3 - val4) * num2 - _grabTarget.rb.velocity * num3; if ((Object)(object)_grabCart != (Object)null) { _grabTarget.rb.AddForceAtPosition(val5, val4, (ForceMode)5); AlignCartInFront(); } else { _grabTarget.rb.AddForce(val5, (ForceMode)5); } float num4 = (((Object)(object)_grabCart != (Object)null) ? 3.2f : 2.4f); _grabTarget.rb.velocity = Vector3.ClampMagnitude(_grabTarget.rb.velocity, num4); Rigidbody rb = _grabTarget.rb; rb.angularVelocity *= (((Object)(object)_grabCart != (Object)null) ? 0.94f : 0.82f); } private void AlignCartInFront() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a0: 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_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_00d7: 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_00e7: 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_0101: 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_0115: 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) if (!((Object)(object)_grabCart == (Object)null) && !((Object)(object)_grabTarget == (Object)null) && !((Object)(object)_grabTarget.rb == (Object)null) && !((Object)(object)_grabCart.handlePoint == (Object)null)) { Vector3 val = ((Component)_grabCart).transform.position - _grabCart.handlePoint.position; val.y = 0f; Vector3 val2 = (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.forward : ((Component)this).transform.forward); val2.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f) && !(((Vector3)(ref val2)).sqrMagnitude < 0.01f)) { float num = Vector3.SignedAngle(val, val2, Vector3.up); Vector3 val3 = Vector3.up * num * 0.35f - Vector3.Project(_grabTarget.rb.angularVelocity, Vector3.up) * 3.5f; _grabTarget.rb.AddTorque(val3, (ForceMode)5); } } } private Vector3 GetFrontGrabPoint() { //IL_0026: 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_002b: 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_0046: 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_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_0115: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00e8: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_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) Vector3 val = (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.forward : ((Component)this).transform.forward); val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); Vector3 carryHeadPosition = GetCarryHeadPosition(); if ((Object)(object)_grabCart != (Object)null) { float num = (((Object)(object)_grabCart.cartGrabPoint != (Object)null) ? Mathf.Clamp(_grabCart.cartGrabPoint.position.y - ((Component)_grabCart).transform.position.y, 0.25f, 0.8f) : 0.45f); return (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.position : ((Component)this).transform.position) + val * 0.82f + Vector3.up * num; } float grabTargetRadius = GetGrabTargetRadius(); return carryHeadPosition + val * Mathf.Clamp(0.58f + grabTargetRadius, 0.8f, 1.55f); } private Vector3 GetCarryHeadPosition() { //IL_0090: 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_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_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_0095: 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_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_proxyAvatarVisuals != (Object)null) { if ((Object)(object)_proxyAvatarVisuals.attachPointTopHeadMiddle != (Object)null) { return _proxyAvatarVisuals.attachPointTopHeadMiddle.position - Vector3.up * 0.12f; } if ((Object)(object)_proxyAvatarVisuals.headUpTransform != (Object)null) { return _proxyAvatarVisuals.headUpTransform.position; } } return (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.position : ((Component)this).transform.position) + Vector3.up * 1.15f; } private void ControlValuableHost(Vector3 requestedCenter) { //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //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_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_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_006a: 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_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_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_00a0: 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_00a8: 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_00bf: 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_00da: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_grabTarget == (Object)null) && !((Object)(object)_grabTarget.rb == (Object)null)) { Rigidbody rb = _grabTarget.rb; Vector3 carryHeadPosition = GetCarryHeadPosition(); float radius = Mathf.Clamp(GetGrabTargetRadius() * 0.72f, 0.16f, 0.58f); Vector3 requested = ResolveCarryPoint(carryHeadPosition, requestedCenter, radius); requested = ResolveCarryPoint(rb.worldCenterOfMass, requested, radius); Vector3 val = requested - rb.worldCenterOfMass; Vector3 val2 = rb.position + val; if (((Vector3)(ref val)).sqrMagnitude > 2.25f) { rb.position = val2; } else { rb.MovePosition(val2); } rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.MoveRotation(Quaternion.Slerp(rb.rotation, _grabCarryRotation, Mathf.Clamp01(Time.deltaTime * 12f))); } } private Vector3 ResolveCarryPoint(Vector3 origin, Vector3 requested, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_001c: 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_0024: 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_0018: 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_00d0: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = requested - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.01f) { return requested; } Vector3 val2 = val / magnitude; float num = magnitude; RaycastHit[] array = Physics.SphereCastAll(origin, radius, val2, magnitude, -1, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; Collider collider = ((RaycastHit)(ref val3)).collider; if (!((Object)(object)collider == (Object)null) && (!((Object)(object)_grabTarget != (Object)null) || !((Component)collider).transform.IsChildOf(((Component)_grabTarget).transform)) && !((Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)this) && !((Object)(object)((Component)collider).GetComponentInParent() == (Object)(object)_parent)) { num = Mathf.Min(num, Mathf.Max(0.08f, ((RaycastHit)(ref val3)).distance - 0.06f)); } } return origin + val2 * num; } private float GetGrabTargetRadius() { //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_0053: 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_0067: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_grabTarget == (Object)null) { return 0.15f; } float num = 0.15f; Collider[] componentsInChildren = ((Component)_grabTarget).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.enabled && !val.isTrigger) { float num2 = num; Bounds bounds = val.bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = val.bounds; num = Mathf.Max(num2, Mathf.Max(x, ((Bounds)(ref bounds)).extents.z)); } } return Mathf.Clamp(num, 0.15f, 0.85f); } private bool SetGrabTargetHost(PhysGrabObject? target, float duration) { //IL_0108: 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_010d: Unknown result type (might be due to invalid IL or missing references) RestoreGrabCollisionIgnore(); RestoreGrabCartMode(); int num = -1; if ((Object)(object)target != (Object)null) { PhotonView val = ((Component)target).GetComponent() ?? ((Component)target).GetComponentInParent(); if (SemiFunc.IsMultiplayer() && ((Object)(object)val == (Object)null || val.ViewID <= 0)) { return false; } num = (((Object)(object)val != (Object)null) ? val.ViewID : (-1)); _grabCart = ((Component)target).GetComponentInParent(); if ((Object)(object)_grabCart != (Object)null) { _grabCartWasActive = _grabCart.cartActive; _grabCart.cartActive = true; _grabCart.StateSwitch((State)2); } } if (SemiFunc.IsMultiplayer()) { _photonView.RPC("SetGrabTargetRpc", (RpcTarget)0, new object[2] { num, duration }); } else { _grabTarget = target; _grabTargetViewId = num; _grabTimer = duration; } if ((Object)(object)target != (Object)null) { _grabCarryRotation = (((Object)(object)target.rb != (Object)null) ? target.rb.rotation : Quaternion.identity); IgnoreGrabCollisions(target); } if ((Object)(object)target == (Object)null) { _directedGrab = false; _hasDirectedGrabPoint = false; } return true; } private void IgnoreGrabCollisions(PhysGrabObject target) { if ((Object)(object)target == (Object)null) { return; } Collider[] componentsInChildren = ((Component)_parent).GetComponentsInChildren(true); Collider[] componentsInChildren2 = ((Component)target).GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)target).transform)) { continue; } Collider[] array2 = componentsInChildren2; foreach (Collider val2 in array2) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val == (Object)(object)val2)) { Physics.IgnoreCollision(val, val2, true); _ignoredGrabCollisions.Add((val, val2)); } } } } private void RestoreGrabCollisionIgnore() { foreach (var (val, val2) in _ignoredGrabCollisions) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, false); } } _ignoredGrabCollisions.Clear(); } private void RestoreGrabCartMode() { if ((Object)(object)_grabCart != (Object)null && !_grabCartWasActive) { _grabCart.cartActive = false; _grabCart.StateSwitch((State)0); } _grabCart = null; _grabCartWasActive = false; } [PunRPC] private void SetGrabTargetRpc(int viewId, float duration, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { _grabTargetViewId = viewId; _grabTimer = duration; object grabTarget; if (viewId <= 0) { grabTarget = null; } else { PhotonView obj = PhotonView.Find(viewId); grabTarget = ((obj != null) ? ((Component)obj).GetComponentInChildren(true) : null); } _grabTarget = (PhysGrabObject?)grabTarget; } } private void UpdateGrabBeam() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_010d: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_grabBeam == (Object)null) { return; } if ((Object)(object)_grabTarget == (Object)null && _grabTargetViewId > 0) { PhotonView obj = PhotonView.Find(_grabTargetViewId); _grabTarget = ((obj != null) ? ((Component)obj).GetComponentInChildren(true) : null); } bool flag = (Object)(object)_grabTarget != (Object)null && _grabTimer > 0f; ((Renderer)_grabBeam).enabled = flag; if ((Object)(object)_grabPointVisual != (Object)null && _grabPointVisual.activeSelf != flag) { _grabPointVisual.SetActive(flag); } UpdateGrabSounds(flag); if (!flag) { return; } Vector3 val = (((Object)(object)_proxyRightArm != (Object)null && (Object)(object)_proxyRightArm.grabberTransform != (Object)null) ? _proxyRightArm.grabberTransform.position : (((Object)(object)_visualProxy != (Object)null) ? (_visualProxy.transform.position + _visualProxy.transform.forward * 0.35f + Vector3.up * 0.72f) : ((Component)this).transform.position)); Vector3 val2 = (((Object)(object)_grabCart != (Object)null && (Object)(object)_grabCart.cartGrabPoint != (Object)null) ? _grabCart.cartGrabPoint.position : _grabTarget.centerPoint); Vector3 val3 = (val + val2) * 0.5f + Vector3.up * Mathf.Min(0.16f, Vector3.Distance(val, val2) * 0.05f); if ((Object)(object)_visualProxy != (Object)null) { val3 += _visualProxy.transform.right * Mathf.Sin(Time.time * 4.5f) * 0.025f; } _grabBeam.positionCount = 20; for (int i = 0; i < 20; i++) { float num = (float)i / 19f; Vector3 val4 = Mathf.Pow(1f - num, 2f) * val + 2f * (1f - num) * num * val3 + num * num * val2; _grabBeam.SetPosition(i, val4); } if ((Object)(object)((Renderer)_grabBeam).material != (Object)null) { ((Renderer)_grabBeam).material.mainTextureOffset = new Vector2(Time.time * 5f, 0f); } if ((Object)(object)_grabPointVisual != (Object)null) { _grabPointVisual.transform.position = val2; Vector3 val5 = val2 - val; if (((Vector3)(ref val5)).sqrMagnitude > 0.01f) { _grabPointVisual.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val5)).normalized, Vector3.up); } } } private void UpdateGrabSounds(bool active) { //IL_0055: 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_0067: 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_00fa: 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) if (active == _grabVisualWasActive) { return; } _grabVisualWasActive = active; PhysGrabber val = (((Object)(object)_copiedPlayer != (Object)null) ? _copiedPlayer.physGrabber : null); Vector3 position = (((Object)(object)_proxyRightArm != (Object)null && (Object)(object)_proxyRightArm.grabberTransform != (Object)null) ? _proxyRightArm.grabberTransform.position : ((Component)this).transform.position); if (active) { PlaySpatialCopiedSound(val?.startSound, position); if ((Object)(object)_grabLoopAudio != (Object)null && (Object)(object)_grabLoopAudio.clip != (Object)null) { ((Component)_grabLoopAudio).transform.position = position; _grabLoopAudio.Play(); AudioLowPassLogic component = ((Component)_grabLoopAudio).GetComponent(); if (component != null) { component.Setup(); } } } else { if ((Object)(object)_grabLoopAudio != (Object)null) { _grabLoopAudio.Stop(); } PlaySpatialCopiedSound(val?.stopSound, position); } } private static void PlaySpatialCopiedSound(Sound? sound, Vector3 position) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (sound == null) { return; } AudioSource source = sound.Source; float spatialBlend = sound.SpatialBlend; sound.Source = null; sound.SpatialBlend = 1f; try { sound.Play(position, 1f, 1f, 1f, 1f); } finally { sound.Source = source; sound.SpatialBlend = spatialBlend; } } private void ScheduleNextVoice() { float num = Mathf.Min(Plugin.VoicePlaybackMinDelay.Value, Plugin.VoicePlaybackMaxDelay.Value); float num2 = Mathf.Max(Plugin.VoicePlaybackMinDelay.Value, Plugin.VoicePlaybackMaxDelay.Value); _voiceTimer = Random.Range(num, num2); } private void HostVoiceLogic() { if (!Plugin.VoiceMimicEnabled.Value || (Object)(object)_copiedPlayer == (Object)null) { return; } bool flag = !_aggressive && (Object)(object)GameDirector.instance != (Object)null && GameDirector.instance.PlayerList.Any((PlayerAvatar player) => (Object)(object)player != (Object)null && !player.isDisabled && (Object)(object)player.voiceChat != (Object)null && player.voiceChat.isTalking && Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) <= 6f); if (flag && !_nearbyTalkerWasActive) { _voiceTimer = Mathf.Min(_voiceTimer, Random.Range(1.2f, 2.8f)); } _nearbyTalkerWasActive = flag; _voiceTimer -= Time.deltaTime; if (!(_voiceTimer > 0f)) { ScheduleNextVoice(); PhotonView photonView = _copiedPlayer.photonView; int? obj; if (photonView == null) { obj = null; } else { Player owner = photonView.Owner; obj = ((owner != null) ? new int?(owner.ActorNumber) : ((int?)null)); } int? num = obj; if (VoiceMimicService.TryGetRandomClipId(num.GetValueOrDefault(), out string clipId)) { VoiceMimicService.RequestSynchronizedPlayback(RuntimeId, clipId); } } } private void HandleSpawn() { _dead = false; _deathSequenceStarted = false; _deathAnimationActive = false; _sabotageAnimationActive = false; _hurtFlashTimer = 0f; _nearbyTalkerWasActive = false; _recentThrowingPlayer = null; _playerThrowAttributionTimer = 0f; _playerThrowMotionTimer = 0f; if ((Object)(object)_visualProxy != (Object)null) { _visualProxy.SetActive(true); } if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy)) { RelocateInitialSpawnFarHost(); _parent.SpawnedTimer = Mathf.Max(_parent.SpawnedTimer, 600f); _parent.forceLeave = false; ResetPeacefulStateHost(); Plugin.Log.LogDebug((object)$"Independent Doppelganger entity {RuntimeId} spawned."); } } private void RelocateInitialSpawnFarHost() { //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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_00ef: 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_012c: Unknown result type (might be due to invalid IL or missing references) if (_initialSpawnRelocated || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null) { return; } LevelPoint val = null; Vector3 val2 = Vector3.zero; float num = -1f; NavMeshHit val3 = default(NavMeshHit); foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints) { if ((Object)(object)levelPathPoint == (Object)null || ((Object)(object)levelPathPoint.Room != (Object)null && levelPathPoint.Room.Truck) || !NavMesh.SamplePosition(((Component)levelPathPoint).transform.position, ref val3, 3f, -1)) { continue; } float num2 = float.MaxValue; bool flag = false; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !player.isDisabled && !player.deadSet) { flag = true; num2 = Mathf.Min(num2, Vector3.Distance(((NavMeshHit)(ref val3)).position, ((Component)player).transform.position)); } } if (flag && num2 > num) { val = levelPathPoint; val2 = ((NavMeshHit)(ref val3)).position; num = num2; } } if ((Object)(object)val != (Object)null) { _initialSpawnRelocated = true; _enemy.EnemyTeleported(val2); Plugin.Log.LogInfo((object)($"Doppelganger {RuntimeId} began its first search " + $"{num:0.0}m from the nearest player.")); } } private void HandleDeath() { //IL_006b: 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) if (_deathSequenceStarted) { return; } _deathSequenceStarted = true; _dead = true; if (SemiFunc.IsMasterClientOrSingleplayer()) { if ((Object)(object)_grabTarget != (Object)null) { SetGrabTargetHost(null, 0f); } if (_mapInspectActive) { SetMapInspectHost(active: false); } if (SemiFunc.IsMultiplayer()) { _photonView.RPC("DeathVisualRpc", (RpcTarget)0, Array.Empty()); } else { DeathVisualRpc(); } Plugin.StartGlobalCoroutine(DeathSequenceHost()); } } [PunRPC] private void DeathVisualRpc(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer() || SemiFunc.MasterOnlyRPC(info)) { _deathAnimationActive = true; _hurtFlashTimer = 0.4f; _gunDrawn = false; _aiSprinting = false; _aiCrouching = false; if ((Object)(object)_visualProxy != (Object)null) { _visualProxy.SetActive(true); } SetAnimatorTrigger("TumblingImpulse"); SetAnimatorBool("Moving", value: false); SetAnimatorBool("Sprinting", value: false); SetAnimatorBool("Tumbling", value: true); SetAnimatorBool("TumblingMove", value: true); ((MonoBehaviour)this).StartCoroutine(DeathSoundCoroutine()); } } private IEnumerator DeathSoundCoroutine() { Vector3 position = (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.position : (((Object)(object)_enemy.CenterTransform != (Object)null) ? _enemy.CenterTransform.position : ((Component)this).transform.position)); if ((Object)(object)_copiedPlayer != (Object)null) { PlayCopiedSound(_copiedPlayer.deathBuildupSound, position); } yield return (object)new WaitForSeconds(0.28f); if ((Object)(object)_copiedPlayer != (Object)null && (Object)(object)_copiedPlayer.playerDeathEffects != (Object)null) { PlayCopiedSound(_copiedPlayer.playerDeathEffects.deathSound, position); } } private IEnumerator DeathSequenceHost() { yield return (object)new WaitForSeconds(0.58f); Vector3 val = (((Object)(object)_enemy.CenterTransform != (Object)null) ? _enemy.CenterTransform.position : ((Component)this).transform.position); val += Vector3.up * 0.35f; Quaternion val2 = ((_enemy.HasRigidbody && (Object)(object)_enemy.Rigidbody != (Object)null) ? ((Component)_enemy.Rigidbody).transform.rotation : ((Component)this).transform.rotation); RuntimeEnemyFactory.EnsureHeadPrefabAvailable(); if (RuntimeEnemyFactory.HeadPrefabRef != null) { int copiedPlayerViewId = _copiedPlayerViewId; object[] array = new object[6] { 1f, 1f, 1f, RuntimeId, copiedPlayerViewId, Plugin.RespawnSeconds.Value }; if (SemiFunc.IsMultiplayer()) { NetworkPrefabs.SpawnNetworkPrefab(RuntimeEnemyFactory.HeadPrefabRef, val, val2, (byte)0, array); } else { DoppelgangerHeadController.SetPendingSingleplayerData(RuntimeId, copiedPlayerViewId, Plugin.RespawnSeconds.Value); NetworkPrefabs.SpawnNetworkPrefab(RuntimeEnemyFactory.HeadPrefabRef, val, val2, (byte)0, (object[])null); } } else { Plugin.Log.LogError((object)"Doppelganger could not drop its head because the respawn-head prefab was unavailable."); } SpawnDeathRewardHost(val + val2 * new Vector3(0.48f, 0.05f, 0f)); if ((Object)(object)_visualProxy != (Object)null) { _visualProxy.SetActive(false); } _parent.Despawn(); } private void SpawnDeathRewardHost(Vector3 position) { //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) //IL_0074: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)AssetManager.instance == (Object)null) { Plugin.Log.LogError((object)"Doppelganger could not create its $10,000 Soul Orb because AssetManager was unavailable."); return; } try { GameObject val = AssetManager.instance.enemyValuableBig; if ((Object)(object)val == (Object)null) { val = AssetManager.instance.enemyValuableMedium; } if ((Object)(object)val == (Object)null) { val = AssetManager.instance.enemyValuableSmall; } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("No vanilla enemy Soul Orb prefab was available."); } GameObject obj = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, position, Quaternion.identity, (byte)0, Patches.CreateSoulRewardInstantiationData(val)) : Object.Instantiate(val, position, Quaternion.identity)); Patches.ConfigureSoulReward(obj); PhysGrabObject component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.spawnTorque = Random.insideUnitSphere * 0.05f; } Plugin.Log.LogInfo((object)"Doppelganger dropped a $10,000 Soul Orb with 7 seconds of protection."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Doppelganger could not spawn its $10,000 Soul Orb: {arg}"); } } private void HandleObjectHurt() { if (SemiFunc.IsMasterClientOrSingleplayer() && !_dead && !((Object)(object)_health == (Object)null) && !((Object)(object)_health.onObjectHurtPlayer == (Object)null)) { DoppelgangerDamageAttribution.MarkPlayerDamage(_health, _health.onObjectHurtPlayer); } } private void HandleHurt() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) _hurtFlashTimer = Mathf.Max(_hurtFlashTimer, 0.24f); if (SemiFunc.IsMasterClientOrSingleplayer() && !_dead) { bool num = DoppelgangerDamageAttribution.ConsumePlayerDamage(_health); PlayerAvatar val = (num ? null : GetPlayerThrowDamageSource()); bool flag = !num && (Object)(object)val != (Object)null; if (num || flag) { string reason = (flag ? ("it was thrown into an impact by player " + val.playerName) : "it was attacked by a player"); BecomeAggressiveHost(reason); if (flag) { _playerThrowAttributionTimer = 0f; _playerThrowMotionTimer = 0f; } } else if (!IsAggressive) { DoppelgangerDebugOverlay.Record(this, "HOSTILIDADE", "recebeu dano ambiental e permaneceu pacífico"); } } if ((Object)(object)_copiedPlayer == (Object)null || (Object)(object)_copiedPlayer.playerHealth == (Object)null) { return; } Vector3 position = (((Object)(object)_visualProxy != (Object)null) ? _visualProxy.transform.position : (((Object)(object)_enemy.CenterTransform != (Object)null) ? _enemy.CenterTransform.position : ((Component)this).transform.position)); try { PlayCopiedSound(_copiedPlayer.playerHealth.hurtOther, position); } catch (Exception ex) { Plugin.Log.LogDebug((object)("Player hurt sound was unavailable: " + ex.Message)); } } private static void PlayCopiedSound(Sound? sound, Vector3 position) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (sound == null) { return; } AudioSource source = sound.Source; sound.Source = null; try { sound.Play(position, 1f, 1f, 1f, 1f); } finally { sound.Source = source; } } internal void RespawnAt(Vector3 headPosition) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.StartGlobalCoroutine(RespawnCoroutine(headPosition)); } } private IEnumerator RespawnCoroutine(Vector3 headPosition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Vector3 safeRespawnPosition = ResolveSafeRespawnPosition(headPosition); float timeout = 10f; while (_parent.Spawned && timeout > 0f) { timeout -= Time.deltaTime; yield return null; } if (_parent.Spawned) { Plugin.Log.LogWarning((object)$"Doppelganger {RuntimeId} was still active at respawn time; forcing a despawn first."); _parent.Despawn(); yield return null; } _parent.DespawnedTimerSet(0f, false); timeout = 10f; while (!_parent.Spawned && timeout > 0f) { timeout -= Time.deltaTime; yield return null; } if (!_parent.Spawned) { Plugin.Log.LogError((object)$"Doppelganger {RuntimeId} did not reactivate after its head timer."); yield break; } _enemy.EnemyTeleported(safeRespawnPosition); Plugin.Log.LogInfo((object)$"Doppelganger {RuntimeId} respawned at its validated head position: {safeRespawnPosition}."); } private Vector3 ResolveSafeRespawnPosition(Vector3 requested) { //IL_0000: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_010d: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(requested, ref val, 8f, -1)) { return ((NavMeshHit)(ref val)).position; } LevelPoint val2 = null; float num = float.PositiveInfinity; Vector3 result; if ((Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.LevelPathPoints != null) { foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints) { if (!((Object)(object)levelPathPoint == (Object)null) && (!((Object)(object)levelPathPoint.Room != (Object)null) || !levelPathPoint.Room.Truck)) { result = ((Component)levelPathPoint).transform.position - requested; float sqrMagnitude = ((Vector3)(ref result)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val2 = levelPathPoint; } } } } if ((Object)(object)val2 != (Object)null && NavMesh.SamplePosition(((Component)val2).transform.position, ref val, 5f, -1)) { Plugin.Log.LogWarning((object)$"Head respawn point {requested} was outside the level; using nearby level point {((NavMeshHit)(ref val)).position}."); return ((NavMeshHit)(ref val)).position; } if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && !player.isDisabled && NavMesh.SamplePosition(((Component)player).transform.position, ref val, 5f, -1)) { Plugin.Log.LogWarning((object)$"Head respawn point {requested} was invalid; using a player-safe point {((NavMeshHit)(ref val)).position}."); result = ((NavMeshHit)(ref val)).position; return result; } } } Plugin.Log.LogError((object)$"No safe NavMesh point could be found for head respawn request {requested}; preserving the requested position."); return requested; } private void DestroyVisualProxy() { //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) if (_grabVisualWasActive) { UpdateGrabSounds(active: false); } if ((Object)(object)_visualProxy != (Object)null) { Object.Destroy((Object)(object)_visualProxy); } if ((Object)(object)_nameTag != (Object)null) { Object.Destroy((Object)(object)((Component)_nameTag).gameObject); } if ((Object)(object)_weaponVisual != (Object)null) { Object.Destroy((Object)(object)_weaponVisual); } if ((Object)(object)_weaponHold != (Object)null) { Object.Destroy((Object)(object)((Component)_weaponHold).gameObject); } if ((Object)(object)_mapVisualRig != (Object)null) { Object.Destroy((Object)(object)_mapVisualRig); } if ((Object)(object)_flashlightLightRig != (Object)null) { Object.Destroy((Object)(object)_flashlightLightRig); } if ((Object)(object)_flashlightVisualRig != (Object)null) { Object.Destroy((Object)(object)_flashlightVisualRig); } if ((Object)(object)_grabBeam != (Object)null) { Object.Destroy((Object)(object)((Component)_grabBeam).gameObject); } if ((Object)(object)_grabPointVisual != (Object)null) { Object.Destroy((Object)(object)_grabPointVisual); } _visualProxy = null; _nameTag = null; _weaponVisual = null; _weaponHold = null; _mapVisualRig = null; _mapVisualAnchor = null; _flashlightLightRig = null; _flashlight = null; _flashlightVisualRig = null; _flashlightVisualAnchor = null; _flashlightHideTransform = null; _flashlightClickTransform = null; _flashlightModelRenderers = Array.Empty(); _flashlightOnSound = null; _flashlightOffSound = null; _mapOneShotAudio = null; _mapLoopAudio = null; _mapStartSound = null; _mapStopSound = null; _gunMuzzle = null; _gunShootSound = null; _gunShootGlobalSound = null; _grabBeam = null; _grabPointVisual = null; _grabLoopAudio = null; _voicePlaybackSource = null; _proxyAnimator = null; _proxyAvatarVisuals = null; _proxyRightArm = null; _proxyLeftArm = null; _proxyTalkAnimation = null; _proxyEyes = null; _sourceRenderers = Array.Empty(); _proxyRenderers = Array.Empty(); _sourceTransforms = Array.Empty(); _proxyTransforms = Array.Empty(); _footstepInitialized = false; _footstepDistance = 0f; _visualTumbling = false; _visualSprinting = false; _hurtFlashApplied = false; _deathAnimationActive = false; _sabotageAnimationActive = false; _grabVisualWasActive = false; _grabClawLerp = 0f; _grabClawCycle = 0f; _bodyLookTimer = 0f; _bodyLookPoint = Vector3.zero; _mapOpenLerp = 0f; _mapRetryTimer = 0f; _flashlightTransition = 1f; _flashlightClickTimer = 0f; _flashlightDesiredOn = true; _flashlightInitialized = false; } private void OnDestroy() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown if ((Object)(object)_stateSpawn != (Object)null && _stateSpawn.OnSpawn != null) { _stateSpawn.OnSpawn.RemoveListener(new UnityAction(HandleSpawn)); } if ((Object)(object)_health != (Object)null) { _health.onHurt.RemoveListener(new UnityAction(HandleHurt)); _health.onDeath.RemoveListener(new UnityAction(HandleDeath)); if (_health.onObjectHurt != null) { _health.onObjectHurt.RemoveListener(new UnityAction(HandleObjectHurt)); } DoppelgangerDamageAttribution.Clear(_health); } RestoreGrabCollisionIgnore(); RestoreGrabCartMode(); DoppelgangerRegistry.Unregister(this); DestroyVisualProxy(); } } internal static class DoppelgangerRegistry { private static readonly Dictionary Instances = new Dictionary(); internal static IReadOnlyCollection All => (IReadOnlyCollection)(object)Instances.Values.Where((DoppelgangerController controller) => (Object)(object)controller != (Object)null).ToArray(); internal static void Register(DoppelgangerController controller) { Instances[controller.RuntimeId] = controller; } internal static void Unregister(DoppelgangerController controller) { Instances.Remove(controller.RuntimeId); } internal static DoppelgangerController? Find(int id) { if (Instances.TryGetValue(id, out DoppelgangerController value) && (Object)(object)value != (Object)null) { return value; } PhotonView obj = ((id > 0) ? PhotonView.Find(id) : null); value = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)value != (Object)null) { Instances[id] = value; } return value; } } internal sealed class DoppelgangerDebugOverlay : MonoBehaviour { private sealed class Observation { internal string State = string.Empty; internal string PendingState = string.Empty; internal float PendingStateSince; internal string Objective = string.Empty; internal int HostilityBucket = -1; internal bool Aggressive; } private readonly struct EventLine { internal string Time { get; } internal int Id { get; } internal string Category { get; } internal string Message { get; } internal EventLine(string time, int id, string category, string message) { Time = time; Id = id; Category = category; Message = message; } } private const int EventLimit = 40; private static DoppelgangerDebugOverlay? _instance; private readonly Dictionary _observations = new Dictionary(); private readonly Dictionary _lastEventTimes = new Dictionary(); private readonly List _events = new List(); private Vector2 _scroll; private float _pollTimer; private GUIStyle? _titleStyle; private GUIStyle? _headingStyle; private GUIStyle? _bodyStyle; private GUIStyle? _eventStyle; private void Awake() { _instance = this; } internal static void NotifyToggle(bool enabled) { if (!((Object)(object)_instance == (Object)null)) { if (enabled) { _instance._observations.Clear(); _instance._lastEventTimes.Clear(); _instance.AddEvent(0, "DEBUG", "telemetria completa ativada"); } else { Plugin.Log.LogInfo((object)"[Doppelganger Debug] Telemetria completa desativada."); } } } internal static void Record(DoppelgangerController? controller, string category, string message) { if (!((Object)(object)_instance == (Object)null) && Plugin.FullDebugTelemetry != null && Plugin.FullDebugTelemetry.Value) { _instance.AddEvent(((Object)(object)controller != (Object)null) ? controller.RuntimeId : 0, category, message); } } private void AddEvent(int id, string category, string message) { string key = $"{id}|{category}|{message}"; float now = Time.unscaledTime; float num = category switch { "HOSTILIDADE" => 5f, "PROCURA" => 4f, "SOM" => 2f, "NAVEGAÇÃO" => 2f, _ => 0.6f, }; if (_lastEventTimes.TryGetValue(key, out var value) && now - value < num) { return; } _lastEventTimes[key] = now; if (_lastEventTimes.Count > 512) { string[] array = (from pair in _lastEventTimes where now - pair.Value > 30f select pair.Key).ToArray(); foreach (string key2 in array) { _lastEventTimes.Remove(key2); } } EventLine item = new EventLine(DateTime.Now.ToString("HH:mm:ss"), id, category, message); _events.Add(item); while (_events.Count > 40) { _events.RemoveAt(0); } Plugin.Log.LogInfo((object)$"[Doppelganger Debug][{category}][{id}] {message}"); } private void Update() { if (Plugin.FullDebugTelemetry == null || !Plugin.FullDebugTelemetry.Value) { return; } _pollTimer -= Time.unscaledDeltaTime; if (_pollTimer > 0f) { return; } _pollTimer = 0.2f; DoppelgangerController[] array = DoppelgangerRegistry.All.Where((DoppelgangerController controller) => (Object)(object)controller != (Object)null).ToArray(); HashSet activeIds = new HashSet(array.Select((DoppelgangerController controller) => controller.RuntimeId)); int[] array2 = _observations.Keys.Where((int id) => !activeIds.Contains(id)).ToArray(); foreach (int num2 in array2) { AddEvent(num2, "CICLO", "entidade removida da cena"); _observations.Remove(num2); } DoppelgangerController[] array3 = array; foreach (DoppelgangerController doppelgangerController in array3) { DoppelgangerBrain debugBrain = doppelgangerController.DebugBrain; int runtimeId = doppelgangerController.RuntimeId; int num3 = Mathf.Clamp(Mathf.FloorToInt(debugBrain.DebugHostilityPercent / 10f) * 10, 0, 100); if (!_observations.TryGetValue(runtimeId, out Observation value)) { value = new Observation { State = debugBrain.DebugState, Objective = debugBrain.DebugObjective, HostilityBucket = num3, Aggressive = doppelgangerController.IsAggressive }; _observations[runtimeId] = value; AddEvent(runtimeId, "CICLO", "monitorando; cópia=" + doppelgangerController.DebugCopiedPlayerName + "; estado=" + debugBrain.DebugState); continue; } if (!string.Equals(value.State, debugBrain.DebugState, StringComparison.Ordinal)) { if (!string.Equals(value.PendingState, debugBrain.DebugState, StringComparison.Ordinal)) { value.PendingState = debugBrain.DebugState; value.PendingStateSince = Time.unscaledTime; } else if (Time.unscaledTime - value.PendingStateSince >= 0.6f) { AddEvent(runtimeId, "ESTADO", value.State + " -> " + debugBrain.DebugState); value.State = debugBrain.DebugState; value.PendingState = string.Empty; } } else { value.PendingState = string.Empty; } value.Objective = debugBrain.DebugObjective; if (value.HostilityBucket != num3) { string arg = ((num3 < value.HostilityBucket) ? "reset/redução" : "progresso"); AddEvent(runtimeId, "HOSTILIDADE", $"{arg}: {num3}% " + $"({debugBrain.DebugHostilityValue:0.0}/{debugBrain.DebugHostilityLimit:0.0})"); value.HostilityBucket = num3; } if (value.Aggressive != doppelgangerController.IsAggressive) { AddEvent(runtimeId, "COMBATE", doppelgangerController.IsAggressive ? "entrou em modo hostil" : "retornou ao modo pacífico"); value.Aggressive = doppelgangerController.IsAggressive; } } } private void OnGUI() { //IL_006f: 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_00ba: 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_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_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) if (Plugin.FullDebugTelemetry == null || !Plugin.FullDebugTelemetry.Value) { return; } EnsureStyles(); float num = Mathf.Clamp((float)Screen.width * 0.42f, 460f, 720f); float num2 = Mathf.Clamp((float)Screen.height - 36f, 320f, 900f); Rect val = default(Rect); ((Rect)(ref val))..ctor(18f, 18f, num, num2); GUI.depth = -1000; GUI.Box(val, GUIContent.none); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height - 16f)); _scroll = GUILayout.BeginScrollView(_scroll, Array.Empty()); GUILayout.Label("DOPPELGANGER — DEBUG COMPLETO (F6)", _titleStyle, Array.Empty()); DoppelgangerController[] array = DoppelgangerRegistry.All.Where((DoppelgangerController controller) => (Object)(object)controller != (Object)null).ToArray(); if (array.Length == 0) { GUILayout.Label("Nenhum Doppelganger ativo. A telemetria continuará aguardando um spawn.", _bodyStyle, Array.Empty()); } DoppelgangerController[] array2 = array; foreach (DoppelgangerController doppelgangerController in array2) { DoppelgangerBrain debugBrain = doppelgangerController.DebugBrain; Vector3 debugPosition = debugBrain.DebugPosition; GUILayout.Space(5f); GUILayout.Label($"#{doppelgangerController.RuntimeId} copia: {doppelgangerController.DebugCopiedPlayerName}", _headingStyle, Array.Empty()); GUILayout.Label("Estado: " + debugBrain.DebugState, _bodyStyle, Array.Empty()); GUILayout.Label("Objetivo: " + debugBrain.DebugObjective, _bodyStyle, Array.Empty()); GUILayout.Label($"Hostilidade: {debugBrain.DebugHostilityPercent:0}% " + $"({debugBrain.DebugHostilityValue:0.0}/{debugBrain.DebugHostilityLimit:0.0}) | " + "Agressivo: " + (doppelgangerController.IsAggressive ? "SIM" : "não"), _bodyStyle, Array.Empty()); GUILayout.Label("Visão: " + (debugBrain.DebugTargetVisible ? "alvo visível" : "sem alvo visível") + " | " + $"última visão: {debugBrain.DebugLastSeenSeconds:0.0}s | " + $"memória pacífica: {debugBrain.DebugKnownTargetSeconds:0.0}s | " + $"investigando som: {debugBrain.DebugInvestigateSeconds:0.0}s", _bodyStyle, Array.Empty()); GUILayout.Label($"Vida: {doppelgangerController.DebugHealthCurrent:0}/{doppelgangerController.DebugHealthMaximum:0} | " + "Grab: " + doppelgangerController.DebugGrabTargetName + " | Mapa: " + (doppelgangerController.IsInspectingMap ? "aberto" : "fechado") + " | Lanterna: " + (doppelgangerController.DebugFlashlightOn ? "ligada" : "desligada"), _bodyStyle, Array.Empty()); GUILayout.Label("Pose: sprint=" + (doppelgangerController.DebugSprinting ? "sim" : "não") + ", agachado=" + (doppelgangerController.DebugCrouching ? "sim" : "não") + ", arma=" + (doppelgangerController.DebugGunDrawn ? "sim" : "não") + ", tumble/física=" + (doppelgangerController.DebugUnderPhysicsControl ? "sim" : "não"), _bodyStyle, Array.Empty()); GUILayout.Label($"Cooldowns: sabotagem {debugBrain.DebugSabotageCooldown:0.0}s | " + $"delivery {debugBrain.DebugDeliveryCooldown:0.0}s | " + $"mapa {debugBrain.DebugMapCooldown:0.0}s | " + $"busca hostil {debugBrain.DebugHostileSearchSeconds:0.0}s", _bodyStyle, Array.Empty()); GUILayout.Label($"Posição: {debugPosition.x:0.0}, {debugPosition.y:0.0}, {debugPosition.z:0.0}", _bodyStyle, Array.Empty()); } GUILayout.Space(8f); GUILayout.Label("EVENTOS RECENTES", _headingStyle, Array.Empty()); if (_events.Count == 0) { GUILayout.Label("Aguardando eventos...", _eventStyle, Array.Empty()); } else { foreach (EventLine item in _events.Skip(Mathf.Max(0, _events.Count - 18))) { GUILayout.Label($"{item.Time} [{item.Category}] #{item.Id}: {item.Message}", _eventStyle, Array.Empty()); } } GUILayout.EndScrollView(); GUILayout.EndArea(); } private void EnsureStyles() { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00a8: 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_00b5: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown if (_titleStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 17, fontStyle = (FontStyle)1, wordWrap = true }; val.normal.textColor = new Color(0.35f, 1f, 0.72f); _titleStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, wordWrap = true }; val2.normal.textColor = new Color(1f, 0.78f, 0.25f); _headingStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 13, wordWrap = true }; val3.normal.textColor = Color.white; _bodyStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 12, wordWrap = true }; val4.normal.textColor = new Color(0.82f, 0.88f, 0.93f); _eventStyle = val4; } } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } } public sealed class DoppelgangerHeadController : MonoBehaviour { private static readonly Dictionary ActiveHeads = new Dictionary(); private static bool _hasPendingSingleplayerData; private static int _pendingEnemyId; private static int _pendingTargetViewId; private static float _pendingDelay; private PhotonView? _photonView; private int _enemyId; private int _targetViewId; private float _respawnDelay; private GameObject? _headVisual; private SphereCollider? _headCollider; private Transform? _forceGrabPoint; private PhysGrabObject? _headPhysics; private Vector3 _lastSafePosition; private bool _hasSafePosition; private float _safetyTimer; private float _remainingRespawnSeconds; private Vector3 HeadWorldPosition { get { //IL_0025: 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) if (!((Object)(object)_headPhysics != (Object)null)) { return ((Component)this).transform.position; } return ((Component)_headPhysics).transform.position; } } internal static bool TryGetRemainingRespawnSeconds(int enemyId, out float remaining) { if (ActiveHeads.TryGetValue(enemyId, out DoppelgangerHeadController value) && (Object)(object)value != (Object)null) { remaining = Mathf.Max(0f, value._remainingRespawnSeconds); return true; } remaining = 0f; return false; } internal static void SetPendingSingleplayerData(int enemyId, int targetViewId, float delay) { _hasPendingSingleplayerData = true; _pendingEnemyId = enemyId; _pendingTargetViewId = targetViewId; _pendingDelay = delay; } private void Awake() { _photonView = ((Component)this).GetComponent(); ValuableObject component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } EnemyValuable[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } _headPhysics = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); if ((Object)(object)_headPhysics != (Object)null) { _headPhysics.isValuable = false; _headPhysics.isEnemy = false; _headPhysics.isPlayer = false; NotValuableObject component2 = ((Component)_headPhysics).GetComponent(); _headPhysics.notValuableObject = component2; _headPhysics.isNonValuable = (Object)(object)component2 != (Object)null; ((Component)_headPhysics).gameObject.tag = "Phys Grab Object"; ((Component)_headPhysics).gameObject.layer = LayerMask.NameToLayer("PhysGrabObject"); if ((Object)(object)_headPhysics.rb != (Object)null) { _headPhysics.rb.mass = 2.5f; } } PhysGrabObjectImpactDetector[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (PhysGrabObjectImpactDetector obj in componentsInChildren2) { obj.destroyDisable = true; obj.playerHurtDisable = true; } PhysGrabObject? headPhysics = _headPhysics; _headCollider = ((headPhysics != null) ? ((Component)headPhysics).GetComponent() : null); PhysGrabObject? headPhysics2 = _headPhysics; _forceGrabPoint = ((headPhysics2 != null) ? ((Component)headPhysics2).transform.Find("Force Grab Point") : null); EnsureGrabSurface(); PhotonView? photonView = _photonView; object[] array = ((photonView != null) ? photonView.InstantiationData : null); if (array != null && array.Length >= 6) { _enemyId = (int)array[3]; _targetViewId = (int)array[4]; _respawnDelay = Convert.ToSingle(array[5]); } else if (array != null && array.Length >= 3) { _enemyId = (int)array[0]; _targetViewId = (int)array[1]; _respawnDelay = Convert.ToSingle(array[2]); } else if (_hasPendingSingleplayerData) { _enemyId = _pendingEnemyId; _targetViewId = _pendingTargetViewId; _respawnDelay = _pendingDelay; _hasPendingSingleplayerData = false; } else { _respawnDelay = Plugin.RespawnSeconds.Value; } _remainingRespawnSeconds = _respawnDelay; ActiveHeads[_enemyId] = this; HideOriginalRenderers(); } private IEnumerator Start() { yield return null; BuildHeadVisual(); EnsureGrabSurface(); if (SemiFunc.IsMasterClientOrSingleplayer()) { RefreshSafePositionHost(forceWideSearch: true); if ((Object)(object)_headPhysics != (Object)null && (Object)(object)_headPhysics.rb != (Object)null) { _headPhysics.rb.AddForce(Vector3.up * 0.8f, (ForceMode)1); _headPhysics.rb.AddTorque(new Vector3(0.12f, 0.2f, -0.08f), (ForceMode)1); } } while (_remainingRespawnSeconds > 0f) { if (SemiFunc.IsMasterClientOrSingleplayer()) { _safetyTimer -= Time.deltaTime; if (_safetyTimer <= 0f) { _safetyTimer = 0.2f; RefreshSafePositionHost(forceWideSearch: false); } } _remainingRespawnSeconds -= Time.deltaTime; yield return null; } _remainingRespawnSeconds = 0f; if (SemiFunc.IsMasterClientOrSingleplayer()) { DoppelgangerController doppelgangerController = DoppelgangerRegistry.Find(_enemyId); if ((Object)(object)doppelgangerController != (Object)null) { Vector3 val = ResolveRespawnPosition(); Plugin.Log.LogInfo((object)$"Doppelganger head timer completed for {_enemyId} at {val}."); doppelgangerController.RespawnAt(val); } else { Plugin.Log.LogError((object)$"Doppelganger head could not find enemy {_enemyId}; respawn was cancelled."); } if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { PhotonNetwork.Destroy(_photonView); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private void RefreshSafePositionHost(bool forceWideSearch) { //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_0018: 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_0076: 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_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_0028: 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_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_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_0127: 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_0108: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) Vector3 headWorldPosition = HeadWorldPosition; float radius = (forceWideSearch ? 8f : 2.5f); Vector3 safe; bool flag = TryFindSafeFloor(headWorldPosition, radius, out safe); if (flag && (forceWideSearch || Mathf.Abs(headWorldPosition.y - safe.y) <= 3.5f)) { _lastSafePosition = safe; _hasSafePosition = true; } if (!_hasSafePosition || flag) { return; } bool num = headWorldPosition.y < _lastSafePosition.y - 8f; Vector3 val = headWorldPosition - _lastSafePosition; bool flag2 = ((Vector3)(ref val)).sqrMagnitude > 2500f; if (!num && !flag2) { return; } Vector3 val2 = _lastSafePosition + Vector3.up * 0.45f; if ((Object)(object)_headPhysics != (Object)null) { if ((Object)(object)_headPhysics.rb != (Object)null) { _headPhysics.rb.velocity = Vector3.zero; _headPhysics.rb.angularVelocity = Vector3.zero; } _headPhysics.Teleport(val2, ((Component)_headPhysics).transform.rotation); } else { ((Component)this).transform.position = val2; } Plugin.Log.LogWarning((object)$"Recovered Doppelganger head {_enemyId} from outside the level to {_lastSafePosition}."); } private Vector3 ResolveRespawnPosition() { //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_0018: 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_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 headWorldPosition = HeadWorldPosition; if (TryFindSafeFloor(headWorldPosition, 6f, out var safe)) { _lastSafePosition = safe; _hasSafePosition = true; return safe; } if (_hasSafePosition) { return _lastSafePosition; } return headWorldPosition; } private bool TryFindSafeFloor(Vector3 origin, float radius, out Vector3 safe) { //IL_0000: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_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) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(origin, ref val, radius, -1)) { safe = ((NavMeshHit)(ref val)).position; return true; } foreach (RaycastHit item in from hit in Physics.RaycastAll(origin + Vector3.up * 2f, Vector3.down, Mathf.Max(10f, radius + 4f), LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1) orderby ((RaycastHit)(ref hit)).distance select hit) { RaycastHit current = item; if (!((Object)(object)((Component)((RaycastHit)(ref current)).collider).GetComponentInParent() == (Object)(object)this) && NavMesh.SamplePosition(((RaycastHit)(ref current)).point, ref val, Mathf.Max(2f, radius), -1)) { safe = ((NavMeshHit)(ref val)).position; return true; } } safe = Vector3.zero; return false; } private void HideOriginalRenderers() { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } private void BuildHeadVisual() { //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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) PlayerAvatar val = null; if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && (Object)(object)player.photonView != (Object)null && player.photonView.ViewID == _targetViewId) { val = player; break; } } } if ((Object)(object)val != (Object)null && (Object)(object)val.playerDeathHead != (Object)null && (Object)(object)val.playerDeathHead.meshHeadParent != (Object)null) { GameObject meshHeadParent = val.playerDeathHead.meshHeadParent; bool activeSelf = meshHeadParent.activeSelf; meshHeadParent.SetActive(false); try { _headVisual = Object.Instantiate(meshHeadParent, ((Component)this).transform); } finally { meshHeadParent.SetActive(activeSelf); } ((Object)_headVisual).name = "Copied Doppelganger Head"; MonoBehaviour[] componentsInChildren = _headVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Behaviour)componentsInChildren[i]).enabled = false; } Collider[] componentsInChildren2 = _headVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } _headVisual.transform.localPosition = Vector3.zero; _headVisual.transform.localRotation = Quaternion.identity; _headVisual.transform.localScale = Vector3.one; _headVisual.SetActive(true); Renderer[] componentsInChildren3 = _headVisual.GetComponentsInChildren(true); foreach (Renderer obj in componentsInChildren3) { obj.enabled = true; obj.shadowCastingMode = (ShadowCastingMode)1; obj.receiveShadows = true; } ConfigurePhysicalHead(val.playerDeathHead); Plugin.Log.LogInfo((object)($"Doppelganger head visual copied with {componentsInChildren3.Length} visible renderers " + "and a player-head-sized grab collider.")); } else { _headVisual = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_headVisual).name = "Fallback Doppelganger Head"; _headVisual.transform.SetParent(((Component)this).transform, false); _headVisual.transform.localScale = Vector3.one * 0.45f; _headVisual.GetComponent().enabled = false; _headVisual.GetComponent().material.color = (((Object)(object)val != (Object)null) ? SemiFunc.PlayerGetColorMain(val) : Color.cyan); ConfigureFallbackCollider(); Plugin.Log.LogWarning((object)"Doppelganger used its visible fallback head because the copied player's death head was unavailable."); } } private void ConfigurePhysicalHead(PlayerDeathHead sourceHead) { //IL_0111: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); PhysGrabObject physGrabObject = sourceHead.physGrabObject; if ((Object)(object)val != (Object)null && (Object)(object)val.rb != (Object)null && (Object)(object)physGrabObject != (Object)null && (Object)(object)physGrabObject.rb != (Object)null) { val.rb.mass = physGrabObject.rb.mass; val.rb.drag = physGrabObject.rb.drag; val.rb.angularDrag = physGrabObject.rb.angularDrag; val.rb.collisionDetectionMode = (CollisionDetectionMode)2; val.rb.interpolation = (RigidbodyInterpolation)1; } Collider val2 = sourceHead.colliders?.FirstOrDefault((Func)((Collider collider) => (Object)(object)collider != (Object)null)); if ((Object)(object)val2 != (Object)null && (Object)(object)_headCollider != (Object)null) { ((Collider)_headCollider).sharedMaterial = val2.sharedMaterial; Transform transform = sourceHead.meshHeadParent.transform; Bounds bounds = val2.bounds; Vector3 val3 = transform.InverseTransformPoint(((Bounds)(ref bounds)).center); val3.x = Mathf.Clamp(val3.x, -0.28f, 0.28f); val3.y = Mathf.Clamp(val3.y, -0.3f, 0.34f); val3.z = Mathf.Clamp(val3.z, -0.28f, 0.28f); float num = Mathf.Max(0.001f, Mathf.Max(Mathf.Abs(transform.lossyScale.x), Mathf.Max(Mathf.Abs(transform.lossyScale.y), Mathf.Abs(transform.lossyScale.z)))); bounds = val2.bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = val2.bounds; float y = ((Bounds)(ref bounds)).extents.y; bounds = val2.bounds; float num2 = Mathf.Max(x, Mathf.Max(y, ((Bounds)(ref bounds)).extents.z)) / num; _headCollider.center = val3; _headCollider.radius = Mathf.Clamp(num2, 0.2f, 0.27f); if ((Object)(object)_forceGrabPoint != (Object)null) { _forceGrabPoint.localPosition = val3; } } if ((Object)(object)_headCollider != (Object)null) { ((Collider)_headCollider).isTrigger = false; ((Collider)_headCollider).enabled = true; } PhysGrabObjectImpactDetector val4 = ((physGrabObject != null) ? ((Component)physGrabObject).GetComponentInChildren(true) : null); PhysGrabObjectImpactDetector componentInChildren = ((Component)this).GetComponentInChildren(true); if ((Object)(object)val4 != (Object)null && (Object)(object)componentInChildren != (Object)null && (Object)(object)val4.impactAudio != (Object)null) { componentInChildren.ChangePhysAudio(val4.impactAudio); componentInChildren.impactAudioPitch = val4.impactAudioPitch; } } private void ConfigureFallbackCollider() { //IL_0015: 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) if (!((Object)(object)_headCollider == (Object)null)) { _headCollider.center = Vector3.zero; _headCollider.radius = 0.23f; ((Collider)_headCollider).isTrigger = false; ((Collider)_headCollider).enabled = true; if ((Object)(object)_forceGrabPoint != (Object)null) { _forceGrabPoint.localPosition = Vector3.zero; } } } internal void EnsureGrabSurface() { if ((Object)(object)_headPhysics == (Object)null) { return; } Collider[] componentsInChildren = ((Component)_headPhysics).GetComponentsInChildren(true); _headPhysics.colliders.Clear(); int num = 0; Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val == (Object)null || val.isTrigger) { continue; } if ((Object)(object)((Component)val).gameObject != (Object)(object)((Component)_headPhysics).gameObject) { val.enabled = false; continue; } ((Component)val).gameObject.tag = "Phys Grab Object"; ((Component)val).gameObject.layer = LayerMask.NameToLayer("PhysGrabObject"); (((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent()).colliderID = num++; if (!_headPhysics.colliders.Contains(((Component)val).transform)) { _headPhysics.colliders.Add(((Component)val).transform); } } } private void OnDestroy() { if (ActiveHeads.TryGetValue(_enemyId, out DoppelgangerHeadController value) && (Object)(object)value == (Object)(object)this) { ActiveHeads.Remove(_enemyId); } } } internal static class FastTaxTokenConsumer { private const float MaximumMachineDistance = 6f; private static bool _running; internal static void TryStart() { //IL_0087: 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_009f: Unknown result type (might be due to invalid IL or missing references) if (_running) { Plugin.Log.LogInfo((object)"Fast Tax Token redemption is already running."); return; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogWarning((object)"Fast Tax Token redemption is host-only so surplus currency stays synchronized."); return; } if ((Object)(object)MetaManager.instance == (Object)null || MetaManager.instance.cosmeticTokens == null || MetaManager.instance.cosmeticTokens.Count == 0) { Plugin.Log.LogInfo((object)"There are no cosmetic Tax Tokens to redeem."); return; } CosmeticShopMachine instance = CosmeticShopMachine.instance; PlayerAvatar val = SemiFunc.PlayerGetLocal(); if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null || (int)instance.stateCurrent != 0 || Vector3.Distance(((Component)val).transform.position, ((Component)instance).transform.position) > 6f) { Plugin.Log.LogWarning((object)"Stand beside the idle cosmetic Tax Token machine before pressing the fast-redeem key."); return; } _running = true; Plugin.StartGlobalCoroutine(RedeemAll()); } private static IEnumerator RedeemAll() { MetaManager manager = MetaManager.instance; List tokens = manager.cosmeticTokens; int originalCount = tokens.Count; int unlockedCount = 0; int surplusCurrency = 0; int processedThisFrame = 0; while (tokens.Count > 0) { int index = tokens.Count - 1; Rarity val = (Rarity)tokens[index]; CosmeticAsset val2 = manager.CosmeticLockedGet(val); if ((Object)(object)val2 != (Object)null) { int num = manager.cosmeticAssets.IndexOf(val2); if (num >= 0 && !manager.cosmeticUnlocks.Contains(num)) { manager.cosmeticUnlocks.Add(num); unlockedCount++; } } else { surplusCurrency += CurrencyFor(val); } tokens.RemoveAt(index); processedThisFrame++; if (processedThisFrame >= 100) { processedThisFrame = 0; yield return null; } } if (surplusCurrency > 0) { SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + surplusCurrency); if ((Object)(object)CurrencyUI.instance != (Object)null) { CurrencyUI.instance.FetchCurrency(); } if ((Object)(object)ShopIncreaseUI.instance != (Object)null) { ShopIncreaseUI.instance.ShowIncrease(surplusCurrency, 3f); } } manager.Save(); RefreshTokenUiWithoutRemovalSpam(); Plugin.Log.LogInfo((object)($"Fast Tax Token redemption completed: {originalCount} tokens, " + $"{unlockedCount} cosmetics, {surplusCurrency} surplus currency.")); _running = false; } private static int CurrencyFor(Rarity rarity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown return (int)rarity switch { 0 => 2, 1 => 4, 2 => 8, 3 => 15, _ => 0, }; } private static void RefreshTokenUiWithoutRemovalSpam() { CosmeticTokenUI instance = CosmeticTokenUI.instance; if ((Object)(object)instance == (Object)null) { return; } foreach (CosmeticTokenUIElement tokenObject in instance.tokenObjects) { if ((Object)(object)tokenObject != (Object)null) { Object.Destroy((Object)(object)((Component)tokenObject).gameObject); } } instance.tokenObjects.Clear(); instance.Setup(); } } [HarmonyPatch] internal static class Patches { internal const int SoulRewardValue = 10000; internal const float SoulRewardProtectionSeconds = 7f; private const string SoulRewardMarker = "RepoDoppelgangerSoulRewardV1"; private static readonly FieldInfo EnemyListField = AccessTools.Field(typeof(EnemyDirector), "enemyList"); private static readonly FieldInfo TierThreeAmountField = AccessTools.Field(typeof(EnemyDirector), "amountCurve3Value"); [HarmonyPatch(typeof(EnemyDirector), "Awake")] [HarmonyPostfix] [HarmonyPriority(0)] private static void EnemyDirectorAwakePostfix(EnemyDirector __instance) { RuntimeEnemyFactory.RegisterForDirector(__instance); } [HarmonyPatch(typeof(EnemyDirector), "AmountSetup")] [HarmonyPrefix] private static void AmountSetupPrefix(EnemyDirector __instance, ref int __state) { __state = (EnemyListField.GetValue(__instance) as List)?.Count ?? 0; } [HarmonyPatch(typeof(EnemyDirector), "AmountSetup")] [HarmonyPostfix] private static void AmountSetupPostfix(EnemyDirector __instance, int __state) { EnemySetup setup = RuntimeEnemyFactory.EnemySetup; if ((Object)(object)setup == (Object)null || (Object)(object)RunManager.instance == (Object)null || RunManager.instance.levelsCompleted + 1 < Plugin.FirstLevel.Value) { return; } List list = EnemyListField.GetValue(__instance) as List; int num = ((TierThreeAmountField.GetValue(__instance) is int num2) ? num2 : 0); if (list == null || num <= 0) { return; } int num3 = Mathf.Min(list.Count, __state + num); if (num3 <= __state) { return; } for (int i = __state; i < num3; i++) { if ((Object)(object)list[i] == (Object)(object)setup) { EnemySetup val = PickNaturalFallback(__instance, setup); if ((Object)(object)val != (Object)null) { list[i] = val; } } } if (!list.Take(__state).Any((EnemySetup candidate) => (Object)(object)candidate == (Object)(object)setup) && Random.Range(0, 100) < Plugin.TierThreeChance.Value) { int num4 = Random.Range(__state, num3); list[num4] = setup; Plugin.Log.LogInfo((object)($"Doppelganger selected for natural Tier 3 slot {num4 - __state + 1}; " + "all other natural slots remain normal enemies.")); } } private static EnemySetup? PickNaturalFallback(EnemyDirector director, EnemySetup doppelganger) { int runsPlayed = (((Object)(object)DataDirector.instance != (Object)null) ? DataDirector.instance.SettingValueFetch((Setting)31) : int.MaxValue); List list = (from candidate in director.enemiesDifficulty3.Concat(director.enemiesDifficulty2).Concat(director.enemiesDifficulty1) where (Object)(object)candidate != (Object)null && (Object)(object)candidate != (Object)(object)doppelganger && IsNaturalSetupEligible(candidate, runsPlayed) select candidate).Distinct().ToList(); if (list.Count <= 0) { return null; } return list[Random.Range(0, list.Count)]; } private static bool IsNaturalSetupEligible(EnemySetup setup, int runsPlayed) { if ((Object)(object)RunManager.instance == (Object)null || runsPlayed < setup.runsPlayed) { return false; } if (setup.levelsCompletedCondition) { if (RunManager.instance.levelsCompleted >= setup.levelsCompletedMin) { if (setup.levelsCompletedMax != 0) { return RunManager.instance.levelsCompleted <= setup.levelsCompletedMax; } return true; } return false; } return true; } internal static object[] CreateSoulRewardInstantiationData(GameObject source) { //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_0014: 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_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = source.transform.localScale; return new object[6] { localScale.x, localScale.y, localScale.z, "RepoDoppelgangerSoulRewardV1", 10000, 7f }; } internal static void ConfigureSoulReward(GameObject reward) { ValuableObject obj = reward.GetComponent() ?? reward.GetComponentInChildren(true); EnemyValuable val = reward.GetComponent() ?? reward.GetComponentInChildren(true); if ((Object)(object)obj == (Object)null || (Object)(object)val == (Object)null) { throw new InvalidOperationException("The enemy Soul Orb prefab is missing its valuable components."); } obj.dollarValueOverride = 10000; val.indestructibleTimer = Mathf.Max(val.indestructibleTimer, 7f); PhysGrabObjectImpactDetector val2 = reward.GetComponent() ?? reward.GetComponentInChildren(true); if ((Object)(object)val2 != (Object)null) { val2.destroyDisable = true; val2.indestructibleSpawnTimer = Mathf.Max(val2.indestructibleSpawnTimer, 7f); } } [HarmonyPatch(typeof(EnemyValuable), "Start")] [HarmonyPostfix] [HarmonyPriority(0)] private static void EnemyValuableStartPostfix(EnemyValuable __instance) { PhotonView obj = ((Component)__instance).GetComponent() ?? ((Component)__instance).GetComponentInChildren(true); object[] array = ((obj != null) ? obj.InstantiationData : null); if (array != null && array.Length >= 4 && array[3] is string text && !(text != "RepoDoppelgangerSoulRewardV1")) { ConfigureSoulReward(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(HurtCollider), "EnemyHurt")] [HarmonyPrefix] private static void HurtColliderEnemyHurtPrefix(HurtCollider __instance, Enemy _enemy) { if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)_enemy == (Object)null) && _enemy.HasHealth && !((Object)(object)_enemy.Health == (Object)null) && _enemy.Health.healthCurrent > 0 && !((Object)(object)_enemy == (Object)(object)__instance.enemyHost) && __instance.enemyLogic && !__instance.deathPit && (__instance.enemyKill || __instance.enemyDamage > 0)) { PlayerAvatar val = __instance.playerCausingHurtOverride; if ((Object)(object)val == (Object)null) { val = __instance.playerCausingHurt; } if ((Object)(object)val != (Object)null) { DoppelgangerDamageAttribution.MarkPlayerDamage(_enemy.Health, val); } } } [HarmonyPatch(typeof(LocalVoiceFramed), "PushDataAsync")] [HarmonyPrefix] private static void LocalVoicePrefix(short[] buf) { VoiceMimicService.AcceptVoiceFrame(buf); } } internal static class DoppelgangerDamageAttribution { private static readonly Dictionary PlayerDamageUntil = new Dictionary(); internal static void MarkPlayerDamage(EnemyHealth health, PlayerAvatar player) { if (!((Object)(object)health == (Object)null) && !((Object)(object)player == (Object)null)) { PlayerDamageUntil[health] = Time.time + 1f; } } internal static bool ConsumePlayerDamage(EnemyHealth health) { if (!PlayerDamageUntil.TryGetValue(health, out var value)) { return false; } PlayerDamageUntil.Remove(health); return Time.time <= value; } internal static void Clear(EnemyHealth health) { if ((Object)(object)health != (Object)null) { PlayerDamageUntil.Remove(health); } } } [BepInPlugin("com.codex.repo.doppelganger", "Doppelganger", "0.4.12")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.codex.repo.doppelganger"; public const string PluginName = "Doppelganger"; public const string PluginVersion = "0.4.12"; private Harmony? _harmony; private VoiceMimicService? _voiceService; internal static ManualLogSource Log { get; private set; } internal static Plugin Instance { get; private set; } internal static ConfigEntry FirstLevel { get; private set; } internal static ConfigEntry TierThreeChance { get; private set; } internal static ConfigEntry Health { get; private set; } internal static ConfigEntry MeleeDamage { get; private set; } internal static ConfigEntry GunDamage { get; private set; } internal static ConfigEntry RespawnSeconds { get; private set; } internal static ConfigEntry VoiceMimicEnabled { get; private set; } internal static ConfigEntry VoicePlaybackMinDelay { get; private set; } internal static ConfigEntry VoicePlaybackMaxDelay { get; private set; } internal static ConfigEntry VoiceClipsPerPlayer { get; private set; } internal static ConfigEntry DebugSpawnKey { get; private set; } internal static ConfigEntry FullDebugTelemetry { get; private set; } internal static ConfigEntry DebugTelemetryKey { get; private set; } internal static ConfigEntry FastTaxTokenKey { get; private set; } private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; FirstLevel = ((BaseUnityPlugin)this).Config.Bind("Spawn", "First level", 3, new ConfigDescription("First numbered level where the Doppelganger can replace a Tier 3 slot.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); TierThreeChance = ((BaseUnityPlugin)this).Config.Bind("Spawn", "Tier 3 replacement chance", 70, new ConfigDescription("Chance, in percent, for each eligible Tier 3 slot to become a Doppelganger.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); Health = ((BaseUnityPlugin)this).Config.Bind("Combat", "Health", 1000, new ConfigDescription("Maximum health.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10000), Array.Empty())); MeleeDamage = ((BaseUnityPlugin)this).Config.Bind("Combat", "Melee damage", 10, new ConfigDescription("Damage dealt by the close-range strike.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 500), Array.Empty())); GunDamage = ((BaseUnityPlugin)this).Config.Bind("Combat", "Gun damage", 20, new ConfigDescription("Damage dealt by each Doppelganger handgun hit.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 500), Array.Empty())); ConfigEntry val = ((BaseUnityPlugin)this).Config.Bind("Migration", "Applied 0.4.0 damage defaults", false, "Internal one-time migration marker. Custom damage values are preserved."); if (!val.Value) { if (MeleeDamage.Value == 45) { MeleeDamage.Value = 10; } if (GunDamage.Value == 50) { GunDamage.Value = 20; } val.Value = true; ((BaseUnityPlugin)this).Config.Save(); } RespawnSeconds = ((BaseUnityPlugin)this).Config.Bind("Respawn", "Head respawn delay", 120f, new ConfigDescription("Seconds between death and respawn at the dropped head.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 900f), Array.Empty())); VoiceMimicEnabled = ((BaseUnityPlugin)this).Config.Bind("Voice", "Enabled", true, "Record short phrases from each player's outgoing in-game microphone stream and replay only the copied player's phrases. Audio stays in memory and is cleared between levels."); VoicePlaybackMinDelay = ((BaseUnityPlugin)this).Config.Bind("Voice", "Minimum playback delay", 12f, new ConfigDescription("Minimum seconds between voice replays.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 300f), Array.Empty())); VoicePlaybackMaxDelay = ((BaseUnityPlugin)this).Config.Bind("Voice", "Maximum playback delay", 28f, new ConfigDescription("Maximum seconds between voice replays.", (AcceptableValueBase)(object)new AcceptableValueRange(3f, 600f), Array.Empty())); VoiceClipsPerPlayer = ((BaseUnityPlugin)this).Config.Bind("Voice", "Clips kept per player", 8, new ConfigDescription("Maximum short phrases retained in memory for each player.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 40), Array.Empty())); DebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind("Debug", "Force spawn key", "F9", "Host-only key used in a level to spawn a Doppelganger near the local player. Set to None to disable."); FullDebugTelemetry = ((BaseUnityPlugin)this).Config.Bind("Debug", "Full telemetry overlay", false, "Shows a live in-game panel and writes detailed Doppelganger perception, objective, search, hostility, map, sabotage and delivery events to LogOutput.log."); DebugTelemetryKey = ((BaseUnityPlugin)this).Config.Bind("Debug", "Full telemetry toggle key", "F6", "Key used to show or hide the complete Doppelganger debug panel. Set to None to disable the shortcut."); FastTaxTokenKey = ((BaseUnityPlugin)this).Config.Bind("Misc", "Fast Tax Token key", "F7", "While standing near the cosmetic Tax Token machine as host, press this key to redeem every stored skin token without waiting for each reward animation. Set to None to disable."); _voiceService = ((Component)this).gameObject.AddComponent(); _voiceService.Initialize(); ((Component)this).gameObject.AddComponent(); _harmony = new Harmony("com.codex.repo.doppelganger"); _harmony.PatchAll(); ((MonoBehaviour)this).StartCoroutine(CompatibilityFixes.RemoveBrokenSoundApiLoopPrefix(_harmony)); ((MonoBehaviour)this).StartCoroutine(CompatibilityFixes.InstallTimerModCompatibility(_harmony)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Doppelganger 0.4.12 loaded."); } private void Update() { //IL_000e: 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_0011: 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_005b: 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) if (TryGetKey(DebugTelemetryKey, out var key) && (int)key != 0 && Input.GetKeyDown(key)) { FullDebugTelemetry.Value = !FullDebugTelemetry.Value; ((BaseUnityPlugin)this).Config.Save(); DoppelgangerDebugOverlay.NotifyToggle(FullDebugTelemetry.Value); } if (TryGetKey(FastTaxTokenKey, out var key2) && (int)key2 != 0 && Input.GetKeyDown(key2)) { FastTaxTokenConsumer.TryStart(); } if (TryGetKey(DebugSpawnKey, out var key3) && (int)key3 != 0 && Input.GetKeyDown(key3)) { TryDebugSpawn(); } } private static bool TryGetKey(ConfigEntry entry, out KeyCode key) { return Enum.TryParse(entry.Value?.Trim() ?? "None", ignoreCase: true, out key); } private static void TryDebugSpawn() { //IL_0042: 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_005e: 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_0098: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00ce: 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_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) if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)RuntimeEnemyFactory.EnemySetup == (Object)null || !SemiFunc.RunIsLevel() || (Object)(object)PlayerAvatar.instance == (Object)null) { Log.LogWarning((object)"Debug spawn ignored: enter a generated level as host first."); return; } Vector3 position = ((Component)PlayerAvatar.instance).transform.position; Vector3 val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : ((Component)PlayerAvatar.instance).transform.forward); val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); Vector3 val2 = position + val * 8f; NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(val2, ref val3, 8f, -1)) { val2 = ((NavMeshHit)(ref val3)).position; } List list = Enemies.SpawnEnemy(RuntimeEnemyFactory.EnemySetup, val2, Quaternion.LookRotation(-val), false); Log.LogInfo((object)((list != null && list.Count > 0) ? "Debug Doppelganger spawned." : "Debug Doppelganger spawn failed; check the log above for the REPOLib error.")); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static Coroutine StartGlobalCoroutine(IEnumerator routine) { return ((MonoBehaviour)Instance).StartCoroutine(routine); } } internal static class RuntimeEnemyFactory { private const string EnemyPrefabId = "Enemies/DoppelgangerEnemy"; private const string HeadPrefabId = "Doppelganger/RespawnHead"; private const float PersistentTimer = 86400f; private static GameObject? _enemyPrefab; private static GameObject? _headPrefab; private static GameObject? _runtimePrefabRoot; private static bool _headRegistrationDeferredLogged; internal static EnemySetup? EnemySetup { get; private set; } internal static PrefabRef? HeadPrefabRef { get; private set; } internal static void EnsureHeadPrefabAvailable() { TryCreateHeadPrefab(); } internal static void RegisterForDirector(EnemyDirector director) { try { EnsureRuntimePrefabs(director); if ((Object)(object)EnemySetup != (Object)null && !director.enemiesDifficulty3.Contains(EnemySetup)) { director.enemiesDifficulty3.Add(EnemySetup); Plugin.Log.LogInfo((object)"Doppelganger registered as a Tier 3 enemy."); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Could not register the Doppelganger: {arg}"); } } private static void EnsureRuntimePrefabs(EnemyDirector director) { PrefabRef item = EnsureEnemyPrefabRegistered(director); if ((Object)(object)EnemySetup == (Object)null) { EnemySetup = ScriptableObject.CreateInstance(); ((Object)EnemySetup).name = "Doppelganger"; EnemySetup.spawnObjects = new List { item }; EnemySetup.levelsCompletedCondition = true; EnemySetup.levelsCompletedMin = Mathf.Max(0, Plugin.FirstLevel.Value - 1); EnemySetup.levelsCompletedMax = 0; EnemySetup.runsPlayed = 0; EnemySetup.rarityPreset = ScriptableObject.CreateInstance(); ((Object)EnemySetup.rarityPreset).name = "Doppelganger Rarity"; EnemySetup.rarityPreset.chance = Plugin.TierThreeChance.Value; } TryCreateHeadPrefab(); } private static PrefabRef EnsureEnemyPrefabRegistered(EnemyDirector director) { PrefabRef result = default(PrefabRef); if (NetworkPrefabs.TryGetNetworkPrefabRef("Enemies/DoppelgangerEnemy", ref result)) { if (!NetworkPrefabs.Prefabs.TryGetValue("Enemies/DoppelgangerEnemy", out var value) || (Object)(object)value == (Object)null || (Object)(object)value.GetComponentInChildren(true) == (Object)null) { throw new InvalidOperationException("Network prefab ID \"Enemies/DoppelgangerEnemy\" is already owned by a different prefab."); } _enemyPrefab = value; return result; } if ((Object)(object)_enemyPrefab != (Object)null) { return NetworkPrefabs.RegisterNetworkPrefab("Enemies/DoppelgangerEnemy", _enemyPrefab) ?? throw new InvalidOperationException("REPOLib rejected the existing Doppelganger network prefab."); } _enemyPrefab = CloneRuntimePrefabTemplate(((PrefabRef)(object)(FindBestBaseEnemy(director) ?? throw new InvalidOperationException("No compatible vanilla enemy prefab was found.")).spawnObjects.First((PrefabRef reference) => (Object)(object)((PrefabRef)(object)reference)?.Prefab != (Object)null)).Prefab, "DoppelgangerEnemy"); ConfigureEnemyPrefab(_enemyPrefab); return NetworkPrefabs.RegisterNetworkPrefab("Enemies/DoppelgangerEnemy", _enemyPrefab) ?? throw new InvalidOperationException("REPOLib rejected the Doppelganger network prefab."); } private static EnemySetup? FindBestBaseEnemy(EnemyDirector director) { return (from setup in director.enemiesDifficulty3.Concat(director.enemiesDifficulty2).Concat(director.enemiesDifficulty1) where (Object)(object)setup != (Object)null && setup.spawnObjects != null && setup.spawnObjects.Count > 0 select (Setup: setup, Score: ScoreBaseEnemy(setup)) into candidate where candidate.Score >= 0 orderby candidate.Score descending select candidate.Setup).FirstOrDefault(); } private static int ScoreBaseEnemy(EnemySetup setup) { try { GameObject val = ((PrefabRef)(object)((IEnumerable)setup.spawnObjects).FirstOrDefault((Func)((PrefabRef reference) => (Object)(object)((PrefabRef)(object)reference)?.Prefab != (Object)null)))?.Prefab; if ((Object)(object)val == (Object)null || (Object)(object)val.GetComponentInChildren(true) == (Object)null) { return -1; } int num = 0; if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 1000; } if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 100; } if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 80; } if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 50; } if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 20; } if ((Object)(object)val.GetComponentInChildren(true) != (Object)null) { num += 20; } return num; } catch { return -1; } } private static GameObject CloneRuntimePrefabTemplate(GameObject source, string name) { bool activeSelf = source.activeSelf; source.SetActive(false); GameObject val; try { val = Object.Instantiate(source, GetRuntimePrefabRoot().transform); } finally { source.SetActive(activeSelf); } ((Object)val).name = name; val.SetActive(true); return val; } private static GameObject GetRuntimePrefabRoot() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)_runtimePrefabRoot != (Object)null) { return _runtimePrefabRoot; } _runtimePrefabRoot = new GameObject("Doppelganger Runtime Prefabs"); _runtimePrefabRoot.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_runtimePrefabRoot); return _runtimePrefabRoot; } private static void ConfigureEnemyPrefab(GameObject prefab) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) EnemyParent obj = prefab.GetComponent() ?? throw new InvalidOperationException("The selected vanilla prefab has no EnemyParent."); Enemy val = prefab.GetComponentInChildren(true) ?? throw new InvalidOperationException("The selected vanilla prefab has no Enemy component."); EnemyHealth val2 = ((Component)val).GetComponent() ?? throw new InvalidOperationException("The selected vanilla prefab has no EnemyHealth."); obj.enemyName = "\u200b"; obj.enemyNameLocalized = null; obj.difficulty = (Difficulty)2; obj.actionMultiplier = 2f; obj.SpawnedTimeMin = 86400f; obj.SpawnedTimeMax = 86400f; obj.DespawnedTimeMin = 86400f; obj.DespawnedTimeMax = 86400f; val2.health = Plugin.Health.Value; val2.spawnValuable = false; StripVanillaIdentity(prefab); ConfigurePlayerSizedPhysics(val); ConfigurePlayerTraversal(val); if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ((Component)val).gameObject.AddComponent(); } Plugin.Log.LogInfo((object)"Built the Doppelganger as an independent enemy entity; all Huntsman behaviour, visuals and attacks were removed."); } private static void ConfigurePlayerTraversal(Enemy enemy) { EnemyJump component = ((Component)enemy).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.surfaceJump = true; component.stuckJump = false; component.gapJump = false; component.warpAgentOnLand = true; component.surfaceJumpDelay = 0f; component.surfaceLandDelay = 0f; component.stuckJumpDelay = 0f; component.stuckLandDelay = 0f; component.gapJumpDelay = 0f; component.gapLandDelay = 0f; } } private static void StripVanillaIdentity(GameObject prefab) { EnemyHunter[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } EnemyHunterAnim[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } EnemyHunterAlwaysActive[] componentsInChildren3 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } HurtCollider[] componentsInChildren4 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Animator[] componentsInChildren5 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren5.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[i]); } Renderer[] componentsInChildren6 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren6.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[i]); } ParticleSystem[] componentsInChildren7 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren7.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren7[i]); } PropLight[] componentsInChildren8 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren8.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren8[i]); } AudioLowPassFilter[] componentsInChildren9 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren9.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren9[i]); } AudioSource[] componentsInChildren10 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren10.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren10[i]); } Light[] componentsInChildren11 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren11.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren11[i]); } } private static void ConfigurePlayerSizedPhysics(Enemy enemy) { //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_0071: 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_0089: 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_0099: 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_00a9: 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_00d8: Unknown result type (might be due to invalid IL or missing references) EnemyRigidbody component = ((Component)enemy).GetComponent(); if ((Object)(object)component == (Object)null) { return; } Collider[] componentsInChildren = ((Component)component).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if (!val.isTrigger) { PhysGrabObjectCollider component2 = ((Component)val).GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } Object.DestroyImmediate((Object)(object)val); } } GameObject val2 = new GameObject("Doppelganger Player Body Collider") { layer = ((Component)component).gameObject.layer }; val2.transform.SetParent(((Component)component).transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; CapsuleCollider val3 = val2.AddComponent(); val3.direction = 1; val3.radius = 0.38f; val3.height = 1.2f; val3.center = Vector3.zero; val2.AddComponent(); component.playerCollision = (Collider)(object)val3; } private static void TryCreateHeadPrefab() { if (HeadPrefabRef != null) { return; } PrefabRef headPrefabRef = default(PrefabRef); if (NetworkPrefabs.TryGetNetworkPrefabRef("Doppelganger/RespawnHead", ref headPrefabRef)) { if (!NetworkPrefabs.Prefabs.TryGetValue("Doppelganger/RespawnHead", out var value) || (Object)(object)value == (Object)null || (Object)(object)value.GetComponent() == (Object)null) { throw new InvalidOperationException("Network prefab ID \"Doppelganger/RespawnHead\" is already owned by a different prefab."); } _headPrefab = value; HeadPrefabRef = headPrefabRef; return; } GameObject val = AssetManager.instance?.enemyValuableSmall; if ((Object)(object)val == (Object)null) { if (!_headRegistrationDeferredLogged) { Plugin.Log.LogInfo((object)"Doppelganger head registration deferred until the vanilla valuable prefabs are ready."); _headRegistrationDeferredLogged = true; } return; } if ((Object)(object)_headPrefab == (Object)null) { _headPrefab = CloneRuntimePrefabTemplate(val, "DoppelgangerRespawnHead"); ConfigureHeadPrefab(_headPrefab); if ((Object)(object)_headPrefab.GetComponent() == (Object)null) { _headPrefab.AddComponent(); } } HeadPrefabRef = NetworkPrefabs.RegisterNetworkPrefab("Doppelganger/RespawnHead", _headPrefab) ?? throw new InvalidOperationException("REPOLib rejected the Doppelganger head prefab."); _headRegistrationDeferredLogged = false; Plugin.Log.LogInfo((object)"Doppelganger head prefab registered."); } private static void ConfigureHeadPrefab(GameObject prefab) { //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) ValuableObject obj = prefab.GetComponent() ?? prefab.GetComponentInChildren(true); PhysAttribute physAttributePreset = obj?.physAttributePreset; PhysAudio audioPreset = obj?.audioPreset; float audioPresetPitch = obj?.audioPresetPitch ?? 1f; Gradient val = obj?.particleColors; EnemyValuable[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } ValuableDiscoverCustom[] componentsInChildren2 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } ValuableObject[] componentsInChildren3 = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } PhysGrabObject val2 = prefab.GetComponent() ?? prefab.GetComponentInChildren(true); if ((Object)(object)val2 == (Object)null) { throw new InvalidOperationException("The head donor has no PhysGrabObject."); } val2.isValuable = false; val2.isEnemy = false; val2.isPlayer = false; NotValuableObject val3 = ((Component)val2).GetComponent() ?? ((Component)val2).gameObject.AddComponent(); val3.physAttributePreset = physAttributePreset; val3.audioPreset = audioPreset; val3.audioPresetPitch = audioPresetPitch; if (val != null) { val3.particleColors = val; } val3.durabilityPreset = null; val3.hasHealth = false; val3.healthDestroy = false; val2.notValuableObject = val3; val2.isNonValuable = true; if ((Object)(object)val2.rb != (Object)null) { val2.rb.mass = 2.5f; val2.rb.drag = 0.15f; val2.rb.angularDrag = 0.2f; val2.rb.collisionDetectionMode = (CollisionDetectionMode)2; val2.rb.interpolation = (RigidbodyInterpolation)1; } PhysGrabObjectCollider[] componentsInChildren4 = ((Component)val2).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } val2.colliders.Clear(); Collider[] componentsInChildren5 = ((Component)val2).GetComponentsInChildren(true); foreach (Collider val4 in componentsInChildren5) { if (!val4.isTrigger) { Object.DestroyImmediate((Object)(object)val4); } } ((Component)val2).gameObject.tag = "Phys Grab Object"; ((Component)val2).gameObject.layer = LayerMask.NameToLayer("PhysGrabObject"); SphereCollider obj2 = ((Component)val2).gameObject.AddComponent(); obj2.center = Vector3.zero; obj2.radius = 0.23f; ((Collider)obj2).isTrigger = false; ((Component)val2).gameObject.AddComponent(); Transform val5 = ((Component)val2).transform.Find("Force Grab Point"); if ((Object)(object)val5 == (Object)null) { val5 = new GameObject("Force Grab Point").transform; val5.SetParent(((Component)val2).transform, false); } val5.localPosition = Vector3.zero; PhysGrabObjectImpactDetector[] componentsInChildren6 = prefab.GetComponentsInChildren(true); foreach (PhysGrabObjectImpactDetector obj3 in componentsInChildren6) { obj3.destroyDisable = true; obj3.playerHurtDisable = true; } } } } namespace RepoDoppelganger.Voice { public sealed class VoiceMimicService : MonoBehaviour { private sealed class ClipData { internal int ActorNumber; internal string Id = string.Empty; internal int Rate; internal byte[] Pcm = Array.Empty(); internal AudioClip? AudioClip; } private sealed class IncomingTransmission { internal int ActorNumber; internal int Rate; internal byte[][] Chunks = Array.Empty(); internal float LastUpdate; } private const int SampleRate = 48000; private const int MaxClipSeconds = 4; private const int MinClipSamples = 16000; private const int PreSpeechSamples = 12000; private const int NetworkChunkSize = 204800; private const float VadThreshold = 0.012f; private const float VadHoldSeconds = 0.45f; private readonly Dictionary> _clipsByActor = new Dictionary>(); private readonly Dictionary _clipsById = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _incoming = new Dictionary(StringComparer.Ordinal); private readonly Queue _preSpeech = new Queue(); private readonly List _capture = new List(192000); private float _voiceHoldUntil; private bool _capturing; private bool _wasInLevel; private bool _initialized; internal static VoiceMimicService? Instance { get; private set; } internal void Initialize() { if (!_initialized) { Instance = this; RepoSteamNetwork.RegisterPacket(); RepoSteamNetwork.AddCallback((Action)OnVoiceClipPacket); RepoSteamNetwork.RegisterPacket(); RepoSteamNetwork.AddCallback((Action)OnVoicePlayPacket); _initialized = true; } } internal static void AcceptVoiceFrame(short[] samples) { if (Plugin.VoiceMimicEnabled.Value && samples != null && samples.Length != 0) { Instance?.ProcessFrame(samples); } } private void ProcessFrame(short[] samples) { if (!SemiFunc.RunIsLevel()) { return; } short[] array = samples; foreach (short item in array) { _preSpeech.Enqueue(item); while (_preSpeech.Count > 12000) { _preSpeech.Dequeue(); } } double num = 0.0; array = samples; for (int i = 0; i < array.Length; i++) { double num2 = (double)array[i] / 32768.0; num += num2 * num2; } if ((float)Math.Sqrt(num / (double)samples.Length) > 0.012f) { _voiceHoldUntil = Time.time + 0.45f; } bool flag = Time.time < _voiceHoldUntil; if (flag && !_capturing) { _capturing = true; _capture.Clear(); _capture.AddRange(_preSpeech); } if (!_capturing) { return; } if (flag) { int num3 = 192000 - _capture.Count; if (num3 > 0) { _capture.AddRange(samples.Take(num3)); } } if ((!flag && _capture.Count >= 16000) || _capture.Count >= 192000) { FinalizeCapture(); } else if (!flag) { _capture.Clear(); _capturing = false; } } private void FinalizeCapture() { if (_capture.Count < 16000) { _capture.Clear(); _capturing = false; return; } Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : 0); string text = $"{num}:{Guid.NewGuid():N}"; short[] array = _capture.ToArray(); byte[] array2 = new byte[array.Length * 2]; Buffer.BlockCopy(array, 0, array2, 0, array2.Length); _capture.Clear(); _capturing = false; AddClip(new ClipData { ActorNumber = num, Id = text, Rate = 48000, Pcm = array2 }); if (PhotonNetwork.CurrentRoom != null) { int num2 = Mathf.CeilToInt((float)array2.Length / 204800f); for (int i = 0; i < num2; i++) { int num3 = i * 204800; int num4 = Mathf.Min(204800, array2.Length - num3); byte[] array3 = new byte[num4]; Buffer.BlockCopy(array2, num3, array3, 0, num4); RepoSteamNetwork.SendPacket(new VoiceClipPacket { SenderActorNumber = num, ClipId = text, ChunkIndex = i, TotalChunks = num2, SampleRate = 48000, ChunkData = array3 }, (NetworkDestination)4); } } } private static void OnVoiceClipPacket(VoiceClipPacket packet) { Instance?.ReceiveClipPacket(packet); } private void ReceiveClipPacket(VoiceClipPacket packet) { if (string.IsNullOrWhiteSpace(packet.ClipId) || packet.TotalChunks <= 0 || packet.ChunkIndex < 0 || packet.ChunkIndex >= packet.TotalChunks || packet.ChunkData == null) { return; } if (!_incoming.TryGetValue(packet.ClipId, out IncomingTransmission value) || value.Chunks.Length != packet.TotalChunks) { value = new IncomingTransmission { ActorNumber = packet.SenderActorNumber, Rate = packet.SampleRate, Chunks = new byte[packet.TotalChunks][], LastUpdate = Time.time }; _incoming[packet.ClipId] = value; } value.Chunks[packet.ChunkIndex] = packet.ChunkData; value.LastUpdate = Time.time; if (!value.Chunks.Any((byte[] chunk) => chunk == null)) { byte[] array = new byte[value.Chunks.Sum((byte[] chunk) => chunk.Length)]; int num = 0; byte[][] chunks = value.Chunks; foreach (byte[] array2 in chunks) { Buffer.BlockCopy(array2, 0, array, num, array2.Length); num += array2.Length; } _incoming.Remove(packet.ClipId); AddClip(new ClipData { ActorNumber = value.ActorNumber, Id = packet.ClipId, Rate = value.Rate, Pcm = array }); } } private void AddClip(ClipData clip) { if (_clipsById.ContainsKey(clip.Id)) { return; } if (!_clipsByActor.TryGetValue(clip.ActorNumber, out List value)) { value = new List(); _clipsByActor[clip.ActorNumber] = value; } value.Add(clip); _clipsById[clip.Id] = clip; while (value.Count > Plugin.VoiceClipsPerPlayer.Value) { ClipData clipData = value[0]; value.RemoveAt(0); _clipsById.Remove(clipData.Id); if ((Object)(object)clipData.AudioClip != (Object)null) { Object.Destroy((Object)(object)clipData.AudioClip); } } } internal static bool TryGetRandomClipId(int actorNumber, out string? clipId) { clipId = null; if ((Object)(object)Instance == (Object)null || !Instance._clipsByActor.TryGetValue(actorNumber, out List value) || value.Count == 0) { return false; } clipId = value[Random.Range(0, value.Count)].Id; return true; } internal static void RequestSynchronizedPlayback(int enemyViewId, string clipId) { if (!((Object)(object)Instance == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { float pitch = Random.Range(0.78f, 1.08f); Instance.PlayLocal(enemyViewId, clipId, pitch); if (PhotonNetwork.CurrentRoom != null) { VoicePlayPacket voicePlayPacket = new VoicePlayPacket(); Player localPlayer = PhotonNetwork.LocalPlayer; voicePlayPacket.HostActorNumber = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); voicePlayPacket.EnemyViewId = enemyViewId; voicePlayPacket.ClipId = clipId; voicePlayPacket.Pitch = pitch; RepoSteamNetwork.SendPacket(voicePlayPacket, (NetworkDestination)1); } } } private static void OnVoicePlayPacket(VoicePlayPacket packet) { Player masterClient = PhotonNetwork.MasterClient; int num = ((masterClient != null) ? masterClient.ActorNumber : (-1)); if (packet.HostActorNumber == num) { Instance?.PlayLocal(packet.EnemyViewId, packet.ClipId, packet.Pitch); } } private void PlayLocal(int enemyViewId, string clipId, float pitch) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (!_clipsById.TryGetValue(clipId, out ClipData value)) { return; } DoppelgangerController doppelgangerController = DoppelgangerRegistry.Find(enemyViewId); if (!((Object)(object)doppelgangerController == (Object)null)) { Transform voiceAnchor = doppelgangerController.VoiceAnchor; Transform val = voiceAnchor.Find("Doppelganger Voice Source"); GameObject val2; if ((Object)(object)val == (Object)null) { val2 = new GameObject("Doppelganger Voice Source"); val2.transform.SetParent(voiceAnchor, false); } else { val2 = ((Component)val).gameObject; } AudioSource val3 = val2.GetComponent() ?? val2.AddComponent(); CopyPlayerVoiceSpatialSettings(val3); val3.clip = GetOrCreateAudioClip(value); val3.pitch = Mathf.Clamp(pitch, 0.65f, 1.2f); val3.Play(); ConfigurePlayerStyleOcclusion(val2, val3); doppelgangerController.RegisterVoicePlayback(val3); } } private static void CopyPlayerVoiceSpatialSettings(AudioSource destination) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) AudioSource val = null; if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && player.voiceChatFetched && (Object)(object)player.voiceChat != (Object)null && (Object)(object)player.voiceChat.audioSource != (Object)null) { val = player.voiceChat.audioSource; if (!player.isLocal) { break; } } } } destination.playOnAwake = false; destination.loop = false; destination.spatialBlend = 1f; destination.minDistance = ((val != null) ? val.minDistance : 1f); destination.maxDistance = ((val != null) ? val.maxDistance : 18f); destination.rolloffMode = (AudioRolloffMode)((val == null) ? 1 : ((int)val.rolloffMode)); destination.dopplerLevel = 0f; destination.volume = 1f; if ((Object)(object)val != (Object)null) { destination.outputAudioMixerGroup = val.outputAudioMixerGroup; } } private static void ConfigurePlayerStyleOcclusion(GameObject voiceObject, AudioSource source) { AudioLowPassFilter obj = voiceObject.GetComponent() ?? voiceObject.AddComponent(); ((Behaviour)obj).enabled = true; obj.cutoffFrequency = 22000f; (voiceObject.GetComponent() ?? voiceObject.AddComponent()).Setup(); } private static AudioClip GetOrCreateAudioClip(ClipData clip) { if ((Object)(object)clip.AudioClip != (Object)null) { return clip.AudioClip; } short[] array = new short[clip.Pcm.Length / 2]; Buffer.BlockCopy(clip.Pcm, 0, array, 0, clip.Pcm.Length); float[] array2 = new float[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = (float)array[i] / 32768f; } clip.AudioClip = AudioClip.Create("DoppelgangerVoice-" + clip.Id, array2.Length, 1, clip.Rate, false); clip.AudioClip.SetData(array2, 0); return clip.AudioClip; } private void Update() { bool flag = SemiFunc.RunIsLevel(); if (flag != _wasInLevel) { if (!flag) { ClearAllAudio(); } _wasInLevel = flag; } string[] array = (from pair in _incoming where Time.time - pair.Value.LastUpdate > 30f select pair.Key).ToArray(); foreach (string key in array) { _incoming.Remove(key); } } private void ClearAllAudio() { foreach (ClipData value in _clipsById.Values) { if ((Object)(object)value.AudioClip != (Object)null) { Object.Destroy((Object)(object)value.AudioClip); } } _clipsByActor.Clear(); _clipsById.Clear(); _incoming.Clear(); _capture.Clear(); _preSpeech.Clear(); _capturing = false; } private void OnDestroy() { ClearAllAudio(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public sealed class VoiceClipPacket : NetworkPacket { public int SenderActorNumber { get; set; } public string ClipId { get; set; } = string.Empty; public int ChunkIndex { get; set; } public int TotalChunks { get; set; } public int SampleRate { get; set; } public byte[] ChunkData { get; set; } = Array.Empty(); protected override void WriteData(SocketMessage message) { message.Write(SenderActorNumber); message.Write(ClipId); message.Write(ChunkIndex); message.Write(TotalChunks); message.Write(SampleRate); message.Write(ChunkData); } protected override void ReadData(SocketMessage message) { SenderActorNumber = message.Read(); ClipId = message.Read(); ChunkIndex = message.Read(); TotalChunks = message.Read(); SampleRate = message.Read(); ChunkData = message.Read(); } } public sealed class VoicePlayPacket : NetworkPacket { public int HostActorNumber { get; set; } public int EnemyViewId { get; set; } public string ClipId { get; set; } = string.Empty; public float Pitch { get; set; } = 1f; protected override void WriteData(SocketMessage message) { message.Write(HostActorNumber); message.Write(EnemyViewId); message.Write(ClipId); message.Write(Pitch); } protected override void ReadData(SocketMessage message) { HostActorNumber = message.Read(); EnemyViewId = message.Read(); ClipId = message.Read(); Pitch = message.Read(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }