Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Mimic v1.0.1
Mimic.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using TMPro; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Mimic")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6582a25c34576debbec9bf7169a79da036691677")] [assembly: AssemblyProduct("Mimic")] [assembly: AssemblyTitle("Mimic")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 Mimic { public class MimicEnemy : MonoBehaviour { private enum Mode { Roam, Investigate, Follow } private enum Phase { Waiting, Item, Body, Dead } private GrabForce grabImpossible; private GrabForce grabFree; private Vector3 bodyHome; private PlayerAvatar target; private bool charging; private bool exhausted; private bool strikeRunning; private float chargeSpeed = 5f; private float stamina = 999f; private float attackCooldown; private float speakTimer; private float repathTimer; private float isolatedTimer; private float keepAliveTimer; private int lastHealth; private int hitsTaken; private bool bodyFleeing; private bool bodyAwake; private bool targetReachable = true; private Vector3 reachPoint; private float reachTimer; private PlayerAvatar reachFor; private NavMeshPath reachPathCache; private Mode mode; private Vector3 investigatePos; private Vector3 glanceDir = Vector3.forward; private Vector3 lastSeenPos; private float investigateTime; private float senseTimer; private float lostSight; private float followTime; private bool inSight; private readonly List<Vector3> searchPoints = new List<Vector3>(); private int searchIndex; private float pointTime; private float pauseTime; private float glanceTimer; private bool pausing; private const float SearchRadius = 4f; private const int SearchSpots = 4; private const float PausePerSpot = 1.4f; private const float MaxSearchTime = 20f; private PlayerAvatar noticing; private float noticeTime; private const float NoticeDelay = 0.6f; private const float CloseRange = 2.5f; private const float FieldOfView = 130f; private const float GiveUpSearch = 8f; private int formViewID; private float healthShare = 1f; private int bodyMax = 100; private const float ChargeStrikeRange = 1.6f; private Phase phase; private bool busy; private EnemyParent enemyParent; private Enemy enemy; private EnemyHealth enemyHealth; private PhotonView view; private MimicSkin skin; private GameObject item; private PhysGrabObject itemGrab; private Rigidbody itemRb; private bool destroyingItem; private bool fleeing; private float itemCooldown; private string lastLook; private Vector3 BodyPos { get { //IL_0033: 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) if (!Object.op_Implicit((Object)(object)enemy.Rigidbody)) { return ((Component)enemy).transform.position; } return ((Component)enemy.Rigidbody).transform.position; } } private NavMeshPath reachPath { get { //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: Expected O, but got Unknown //IL_0017: Expected O, but got Unknown NavMeshPath obj = reachPathCache; if (obj == null) { NavMeshPath val = new NavMeshPath(); NavMeshPath val2 = val; reachPathCache = val; obj = val2; } return obj; } } private Vector3 Eye { get { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)enemy.Vision) || !Object.op_Implicit((Object)(object)enemy.Vision.VisionTransform)) { return BodyPos + Vector3.up * 1.3f; } return enemy.Vision.VisionTransform.position; } } private static bool Host => SemiFunc.IsMasterClientOrSingleplayer(); private Vector3 ItemCenter { get { //IL_0024: 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) if (!Object.op_Implicit((Object)(object)itemRb)) { return item.transform.position; } return itemRb.worldCenterOfMass; } } private bool ItemHeld { get { if (Object.op_Implicit((Object)(object)itemGrab)) { return itemGrab.playerGrabbing.Any((PhysGrabber g) => Object.op_Implicit((Object)(object)g) && Object.op_Implicit((Object)(object)g.playerAvatar)); } return false; } } private void Reveal(Vector3 floor, PlayerAvatar form) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) bodyMax = MaxHealthOf(form); if (Object.op_Implicit((Object)(object)enemyHealth)) { enemyHealth.health = bodyMax; } formViewID = form.photonView.ViewID; chargeSpeed = SprintSpeedOf(form); Plugin.Log.LogInfo((object)$"Mimic form: {form.playerName}, {bodyMax} max health, runs at {chargeSpeed:0.0} like them."); Send("SetFormRPC", (RpcTarget)3, formViewID); phase = Phase.Body; attackCooldown = Plugin.AttackCooldown.Value; speakTimer = Random.Range(3f, 6f); lastHealth = -1; hitsTaken = 0; bodyAwake = false; bodyFleeing = false; target = null; mode = Mode.Roam; noticing = null; ((MonoBehaviour)this).StartCoroutine(WakeBody(floor)); } private IEnumerator WakeBody(Vector3 floor) { //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) bodyHome = floor; ((Component)enemy).transform.position = floor; if (Object.op_Implicit((Object)(object)enemy.Rigidbody)) { ((Component)enemy.Rigidbody).transform.position = floor + (enemy.Rigidbody.followTarget.position - ((Component)enemy).transform.position); } float t = 0f; while (!enemyParent.Spawned && t < 10f) { enemyParent.DespawnedTimer = Mathf.Min(enemyParent.DespawnedTimer, 0.05f); t += Time.deltaTime; yield return null; } yield return null; if (Object.op_Implicit((Object)(object)enemyHealth)) { enemyHealth.healthCurrent = Mathf.Max(1, Mathf.RoundToInt(healthShare * (float)bodyMax)); } lastHealth = -1; bodyAwake = true; if (enemyParent.Spawned) { enemy.EnemyTeleported(bodyHome); enemy.CurrentState = (EnemyState)2; Plugin.Log.LogInfo((object)$"Mimic body awake at {bodyHome}."); } else { Plugin.Log.LogWarning((object)"Mimic body did not spawn."); } } private void BodyTick() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)enemyHealth) && (enemyHealth.dead || (enemyParent.Spawned && enemyHealth.healthCurrent <= 0))) { Died("its body ran out of health"); return; } keepAliveTimer -= Time.deltaTime; if (keepAliveTimer <= 0f) { keepAliveTimer = 1f; enemyParent.SpawnedTimerPause(600f); if (!enemyParent.Spawned) { enemyParent.DespawnedTimer = Mathf.Min(enemyParent.DespawnedTimer, 0.5f); } } if (!enemyParent.Spawned || !Object.op_Implicit((Object)(object)enemy.Rigidbody)) { return; } if (enemy.TeleportedTimer <= 0f) { bodyHome = ((Component)enemy).transform.position; } if ((int)enemy.CurrentState == 11) { enemy.CurrentState = (EnemyState)2; } PhysGrabObject physGrabObject = enemy.Rigidbody.physGrabObject; float num = (Object.op_Implicit((Object)(object)physGrabObject) ? physGrabObject.playerGrabbing.Where((PhysGrabber g) => Object.op_Implicit((Object)(object)g)).Sum((PhysGrabber g) => g.grabStrength) : 0f); enemy.Rigidbody.grabForceNeeded = ((num >= Plugin.BodyStrength.Value - 0.01f) ? grabFree : grabImpossible); if (Object.op_Implicit((Object)(object)enemyHealth) && bodyAwake) { int healthCurrent = enemyHealth.healthCurrent; if (lastHealth >= 0 && healthCurrent < lastHealth) { hitsTaken++; Plugin.Log.LogInfo((object)$"Mimic body hit ({healthCurrent} HP left, hit {hitsTaken})."); } lastHealth = healthCurrent; int value = Plugin.FleeAfterHits.Value; if (value > 0 && hitsTaken >= value && !bodyFleeing && !busy) { ((MonoBehaviour)this).StartCoroutine(BodyFlee()); } } if (bodyFleeing || (busy && strikeRunning && !enemy.IsStunned() && !enemy.Rigidbody.grabbed)) { return; } if (busy || enemy.IsStunned() || enemy.Rigidbody.grabbed) { if (Object.op_Implicit((Object)(object)enemy.NavMeshAgent)) { enemy.NavMeshAgent.Stop(0.2f); } } else { Stalk(Time.deltaTime); } } private float Dist(PlayerAvatar p) { //IL_0006: 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) return Vector3.Distance(((Component)p).transform.position, BodyPos); } private void UpdateReach(float dt) { //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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00bb: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011b: 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) if (!Object.op_Implicit((Object)(object)target)) { targetReachable = true; reachFor = null; } else { if ((Object)(object)target == (Object)(object)reachFor && (reachTimer -= dt) > 0f) { return; } reachTimer = 0.5f; reachFor = target; Vector3 position = ((Component)target).transform.position; bool num = targetReachable; targetReachable = false; reachPoint = BodyPos; if (Spots.OnNav(BodyPos, 2f, out var hit)) { NavMeshHit val = default(NavMeshHit); bool flag = NavMesh.SamplePosition(position, ref val, 1.2f, Spots.Filter()); Vector3 val2 = (flag ? ((NavMeshHit)(ref val)).position : position); if (NavMesh.CalculatePath(hit, val2, Spots.Filter(), reachPath) && reachPath.corners.Length != 0) { Vector3 val3 = position - (reachPoint = reachPath.corners[reachPath.corners.Length - 1]); float num2 = Mathf.Abs(val3.y); val3.y = 0f; targetReachable = flag && (int)reachPath.status == 0 && ((Vector3)(ref val3)).magnitude < 1.2f && num2 < 1.3f; } } if (num && !targetReachable) { Plugin.Log.LogInfo((object)("Mimic can't reach " + target.playerName + " and waits below.")); } if (!targetReachable && charging) { charging = false; repathTimer = 0f; } } } private float FlatDist(PlayerAvatar p) { //IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)p).transform.position - BodyPos; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private void Stalk(float dt) { //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) List<PlayerAvatar> list = Spots.Living(); EnemyNavMeshAgent navMeshAgent = enemy.NavMeshAgent; if (!Object.op_Implicit((Object)(object)navMeshAgent)) { return; } attackCooldown -= dt; repathTimer -= dt; speakTimer -= dt; Sense(list, dt); bool flag = Object.op_Implicit((Object)(object)target) && list.All((PlayerAvatar o) => (Object)(object)o == (Object)(object)target || Vector3.Distance(((Component)o).transform.position, ((Component)target).transform.position) > Plugin.IsolationRadius.Value); UpdateReach(dt); if (Object.op_Implicit((Object)(object)target) && inSight) { followTime += dt; } bool flag2 = followTime >= Mathf.Max(0f, Plugin.TrustTime.Value); bool num = Object.op_Implicit((Object)(object)target) && attackCooldown <= 0f && flag && inSight && targetReachable && flag2; float num2 = Mathf.Max(0.5f, Plugin.ChargeStamina.Value); stamina = Mathf.Min(stamina, num2); if (charging) { stamina -= dt; } else { stamina = Mathf.Min(num2, stamina + dt * num2 / Mathf.Max(0.5f, Plugin.StaminaRecovery.Value)); } if (stamina <= 0f && !exhausted) { exhausted = true; Plugin.Log.LogInfo((object)"Mimic is out of breath."); } if (exhausted && stamina >= num2 * 0.6f) { exhausted = false; } bool flag3 = num && !exhausted; if (flag3 && !charging) { Plugin.Log.LogInfo((object)("Mimic sees its chance and runs at " + target.playerName + ".")); repathTimer = 0f; } charging = flag3; navMeshAgent.OverrideAgent(charging ? chargeSpeed : Plugin.MoveSpeed.Value, charging ? 30f : 12f, 0.2f); if (charging) { enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 2f, -1f); } if (repathTimer <= 0f) { repathTimer = (charging ? 0.1f : 0.3f); if (Object.op_Implicit((Object)(object)target)) { Vector3 val = ((lostSight > 0.5f) ? lastSeenPos : ((Component)target).transform.position); float num3 = ((lostSight > 0.5f) ? 0.5f : (charging ? 0f : Plugin.FollowDistance.Value)); if (!targetReachable && lostSight <= 0.5f) { val = reachPoint; num3 = 0f; } Vector3 val2 = val - ((Component)enemy).transform.position; val2.y = 0f; if (charging) { navMeshAgent.SetDestination(val); } else if (!targetReachable && lostSight <= 0.5f) { if (((Vector3)(ref val2)).magnitude > 0.8f) { navMeshAgent.SetDestination(val); } else { navMeshAgent.ResetPath(); } } else if (((Vector3)(ref val2)).magnitude > num3 + (navMeshAgent.HasPath() ? 0f : 0.8f)) { navMeshAgent.SetDestination(val - ((Vector3)(ref val2)).normalized * num3); } else { navMeshAgent.ResetPath(); } } else if (mode == Mode.Investigate) { SearchStep(navMeshAgent, 0.3f); } else if (!navMeshAgent.HasPath()) { List<LevelPoint> list2 = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null); if (list2 != null && list2.Count > 0) { LevelPoint val3 = list2[Random.Range(0, list2.Count)]; if (Object.op_Implicit((Object)(object)val3)) { navMeshAgent.SetDestination(((Component)val3).transform.position); } } } } if (mode == Mode.Investigate) { investigateTime += dt; } Vector3 agentVelocity = navMeshAgent.AgentVelocity; agentVelocity.y = 0f; Vector3 point = ((((Vector3)(ref agentVelocity)).sqrMagnitude > 0.05f) ? (BodyPos + agentVelocity) : (Object.op_Implicit((Object)(object)target) ? ((Component)target).transform.position : (Object.op_Implicit((Object)(object)noticing) ? ((Component)noticing).transform.position : ((mode == Mode.Investigate) ? (BodyPos + glanceDir) : (BodyPos + enemy.Rigidbody.followTarget.forward))))); Face(point, (mode == Mode.Investigate && !Object.op_Implicit((Object)(object)target) && !Object.op_Implicit((Object)(object)noticing) && ((Vector3)(ref agentVelocity)).sqrMagnitude <= 0.05f) ? 140f : 360f); if (speakTimer <= 0f) { speakTimer = Random.Range(Plugin.SpeakIntervalMin.Value, Mathf.Max(Plugin.SpeakIntervalMin.Value, Plugin.SpeakIntervalMax.Value)); if (list.Any((PlayerAvatar p) => Dist(p) <= Plugin.SpeakRadius.Value)) { Send("SpeakRPC", (RpcTarget)0, Random.Range(0, int.MaxValue)); } } float num4 = (charging ? 1.6f : Plugin.AttackRange.Value); if (Object.op_Implicit((Object)(object)target) && attackCooldown <= 0f && flag2 && FlatDist(target) <= num4 && targetReachable && flag && inSight && CanSee(target)) { isolatedTimer += dt; if (charging || isolatedTimer >= 0.8f) { isolatedTimer = 0f; ((MonoBehaviour)this).StartCoroutine(BodyStrike(target, charging)); charging = false; } } else { isolatedTimer = 0f; } } private bool CanSee(PlayerAvatar p) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00ab: 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_00b0: 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_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) if (!Object.op_Implicit((Object)(object)p)) { return false; } float num = Plugin.DetectionRadius.Value * ((p.isCrouching || p.isCrawling) ? 0.5f : 1f); Vector3 val = p.PlayerVisionTarget.VisionTransform.position - Eye; if (((Vector3)(ref val)).magnitude > num) { return false; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); Vector3 val3 = (Object.op_Implicit((Object)(object)enemy.Rigidbody.followTarget) ? enemy.Rigidbody.followTarget.forward : ((Component)enemy).transform.forward); if (((Vector3)(ref val)).magnitude > 2.5f && Vector3.Angle(val3, val2) > 65f) { return false; } return SemiFunc.PlayerVisionCheck(Eye, num, p, false); } private void Sense(List<PlayerAvatar> living, float dt) { //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_017b: 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_01f2: 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) if (Object.op_Implicit((Object)(object)target) && (target.deadSet || target.isDisabled)) { target = null; mode = Mode.Roam; } if ((senseTimer -= dt) > 0f) { return; } float num = 0.2f - senseTimer; senseTimer = 0.2f; if (Object.op_Implicit((Object)(object)target)) { inSight = CanSee(target); if (inSight) { lostSight = 0f; lastSeenPos = ((Component)target).transform.position; } else if ((lostSight += num) >= 8f) { Plugin.Log.LogInfo((object)("Mimic lost track of " + target.playerName + ".")); target = null; Investigate(lastSeenPos); } return; } PlayerAvatar val = living.Where(CanSee).OrderBy(Dist).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)val)) { noticing = null; noticeTime = 0f; return; } if ((Object)(object)val != (Object)(object)noticing) { noticing = val; noticeTime = 0f; } noticeTime += num; Face(((Component)val).transform.position); if (!(noticeTime < 0.6f) || !(Dist(val) > 2.5f)) { Plugin.Log.LogInfo((object)("Mimic spotted " + val.playerName + " and follows them.")); target = val; followTime = 0f; mode = Mode.Follow; lostSight = 0f; inSight = true; lastSeenPos = ((Component)val).transform.position; noticing = null; repathTimer = 0f; } } private void Investigate(Vector3 pos) { //IL_0008: 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_0017: 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_003d: 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_004d: Expected O, but got Unknown //IL_0117: 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_0123: 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_013f: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_014d: 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_00c9: 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_00e6: Unknown result type (might be due to invalid IL or missing references) mode = Mode.Investigate; investigatePos = (Spots.OnNav(pos, 3f, out var hit) ? hit : pos); investigateTime = 0f; searchPoints.Clear(); searchPoints.Add(investigatePos); NavMeshPath val = new NavMeshPath(); for (int i = 0; i < 20; i++) { if (searchPoints.Count >= 4) { break; } Vector2 val2 = Random.insideUnitCircle * 4f; if (Spots.OnNav(investigatePos + new Vector3(val2.x, 0f, val2.y), 1.5f, out var spot) && !searchPoints.Any((Vector3 q) => Vector3.Distance(q, spot) < 1.5f) && NavMesh.CalculatePath(investigatePos, spot, Spots.Filter(), val) && (int)val.status == 0) { searchPoints.Add(spot); } } searchIndex = 0; BeginMove(); Vector3 val3 = pos - BodyPos; val3.y = 0f; glanceDir = ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val3)).normalized : Vector3.forward); repathTimer = 0f; } private void BeginMove() { pausing = false; pointTime = 0f; pauseTime = 0f; } private void SearchStep(EnemyNavMeshAgent agent, float step) { //IL_0042: 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_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_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_0126: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e4: Unknown result type (might be due to invalid IL or missing references) investigateTime += step; if (searchIndex >= searchPoints.Count || investigateTime >= 20f) { mode = Mode.Roam; return; } Vector3 val = searchPoints[searchIndex]; if (!pausing) { pointTime += step; Vector3 agentVelocity = agent.AgentVelocity; agentVelocity.y = 0f; bool num = Vector3.Distance(BodyPos, val) < 1.5f; bool flag = pointTime > 1f && ((Vector3)(ref agentVelocity)).sqrMagnitude < 0.05f && Vector3.Distance(BodyPos, val) < 3.5f; if (num || flag || pointTime > 6f) { pausing = true; agent.ResetPath(); glanceTimer = 0f; } else { agent.SetDestination(val); } return; } pauseTime += step; if ((glanceTimer -= step) <= 0f) { glanceTimer = Random.Range(0.6f, 0.9f); Vector3 val2 = val - investigatePos; val2.y = 0f; Vector3 val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.25f) ? ((Vector3)(ref val2)).normalized : glanceDir); glanceDir = Quaternion.Euler(0f, Random.Range(-75f, 75f), 0f) * val3; } if (pauseTime >= 1.4f) { searchIndex++; BeginMove(); } } private void Hear(Vector3 pos) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (phase == Phase.Body && !bodyFleeing && !Object.op_Implicit((Object)(object)target) && enemyParent.Spawned && (mode != Mode.Investigate || !(Vector3.Distance(pos, investigatePos) <= 4f))) { Plugin.Log.LogInfo((object)"Mimic heard something and goes to look."); Investigate(pos); } } private IEnumerator BodyFlee() { bodyFleeing = true; target = null; Plugin.Log.LogInfo((object)"Mimic was found out and runs."); Vector3? dest = Spots.FindSpot(startRoom: false, awayFromPlayers: true); float t = 0f; float unseen = 0f; float look = 0f; float repath = 0f; while (phase == Phase.Body) { float deltaTime = Time.deltaTime; t += deltaTime; look -= deltaTime; repath -= deltaTime; EnemyNavMeshAgent navMeshAgent = enemy.NavMeshAgent; if (Object.op_Implicit((Object)(object)navMeshAgent) && enemyParent.Spawned && !enemy.IsStunned() && !enemy.Rigidbody.grabbed) { navMeshAgent.OverrideAgent(Plugin.FleeSpeed.Value, 20f, 0.2f); if (repath <= 0f) { repath = 0.5f; if (!dest.HasValue || Vector3.Distance(BodyPos, dest.Value) < 2f) { dest = Spots.FindSpot(startRoom: false, awayFromPlayers: true); } if (dest.HasValue) { navMeshAgent.SetDestination(dest.Value); } } Vector3 agentVelocity = navMeshAgent.AgentVelocity; agentVelocity.y = 0f; if (((Vector3)(ref agentVelocity)).sqrMagnitude > 0.05f) { Face(BodyPos + agentVelocity); } } if (look <= 0f) { look = 0.2f; unseen = (Spots.SeenByAnyone(BodyPos + Vector3.up * 1f) ? 0f : (unseen + 0.2f)); } if (unseen >= 1f && t >= 1f) { Spots.ItemSpot? spot = Spots.FindItemSpot(startRoom: false, awayFromPlayers: true); if (spot.HasValue) { Plugin.Log.LogInfo((object)"Mimic shed its disguise and is hiding as an item again."); Hide(); yield return null; SpawnItem(spot.Value); yield break; } t = 0f; } yield return null; } bodyFleeing = false; } private static int MaxHealthOf(PlayerAvatar p) { if (!Object.op_Implicit((Object)(object)p) || !Object.op_Implicit((Object)(object)p.playerHealth)) { return 100; } return Mathf.Max(1, p.playerHealth.maxHealth); } private static float SprintSpeedOf(PlayerAvatar p) { PlayerController instance = PlayerController.instance; float num = (Object.op_Implicit((Object)(object)instance) ? (instance.playerOriginalSprintSpeed - instance.SprintSpeedUpgrades) : 0f); if (num <= 0.5f) { num = 5f; } int value = 0; if (Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)StatsManager.instance) && p.steamID != null) { StatsManager.instance.playerUpgradeSpeed.TryGetValue(p.steamID, out value); } return num + (float)value; } private void Hide() { if (Object.op_Implicit((Object)(object)enemyHealth) && enemyHealth.healthCurrent > 0) { healthShare = Mathf.Clamp01((float)enemyHealth.healthCurrent / (float)bodyMax); } phase = Phase.Waiting; if (enemyParent.Spawned) { enemyParent.Despawn(); } bodyFleeing = false; } private void Face(Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Face(point, 360f); } private void Face(Vector3 point, float degreesPerSecond) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Transform followTarget = enemy.Rigidbody.followTarget; if (Object.op_Implicit((Object)(object)followTarget)) { Vector3 val = point - BodyPos; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { followTarget.rotation = Quaternion.RotateTowards(followTarget.rotation, Quaternion.LookRotation(val), degreesPerSecond * Time.deltaTime); } } } private IEnumerator BodyStrike(PlayerAvatar victim, bool running) { busy = true; strikeRunning = running; Face(((Component)victim).transform.position); Send("LungeRPC", (RpcTarget)0); float windup = (running ? 0.12f : 0.45f); for (float t = 0f; t < windup; t += Time.deltaTime) { if (!Object.op_Implicit((Object)(object)victim)) { break; } if (running && Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.NavMeshAgent)) { enemy.NavMeshAgent.OverrideAgent(chargeSpeed, 30f, 0.2f); enemy.NavMeshAgent.SetDestination(((Component)victim).transform.position); enemy.Rigidbody.OverrideFollowPosition(0.2f, enemy.Rigidbody.positionSpeedChase * 2f, -1f); } Face(((Component)victim).transform.position); yield return null; } strikeRunning = false; if (Object.op_Implicit((Object)(object)victim) && FlatDist(victim) <= Plugin.AttackRange.Value + 1f && CanSee(victim)) { yield return Hurt(victim, (!Plugin.Harmless.Value) ? 9999 : 0); } if (Object.op_Implicit((Object)(object)victim) && victim.deadSet && Plugin.ChainTransform.Value && phase == Phase.Body) { formViewID = victim.photonView.ViewID; if (Object.op_Implicit((Object)(object)enemyHealth)) { float num = Mathf.Clamp01((float)enemyHealth.healthCurrent / (float)bodyMax); bodyMax = MaxHealthOf(victim); enemyHealth.health = bodyMax; enemyHealth.healthCurrent = Mathf.Max(1, Mathf.RoundToInt(num * (float)bodyMax)); lastHealth = -1; } chargeSpeed = SprintSpeedOf(victim); Send("SetFormRPC", (RpcTarget)3, formViewID); } attackCooldown = ((Object.op_Implicit((Object)(object)victim) && victim.deadSet) ? Plugin.AttackCooldown.Value : 6f); busy = false; } private void Awake() { enemyParent = ((Component)this).GetComponent<EnemyParent>(); view = ((Component)this).GetComponent<PhotonView>(); skin = ((Component)this).GetComponent<MimicSkin>(); enemy = ((Component)this).GetComponentInChildren<Enemy>(true); enemyHealth = ((Component)this).GetComponentInChildren<EnemyHealth>(true); } private void Start() { if (Host) { ((MonoBehaviour)this).StartCoroutine(Begin()); } } private IEnumerator Begin() { while (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated) { yield return null; } float t = 0f; while (enemyParent.Spawned && t < 10f) { t += Time.deltaTime; yield return null; } grabImpossible = ScriptableObject.CreateInstance<GrabForce>(); grabImpossible.amount = 100000f; grabFree = ScriptableObject.CreateInstance<GrabForce>(); grabFree.amount = 0f; if (Plugin.StartSkinned.Value) { List<PlayerAvatar> list = Spots.Living(); Vector3? val = Spots.FindSpot(Plugin.SpawnInStartRoom.Value, awayFromPlayers: false); if (list.Count > 0 && val.HasValue) { PlayerAvatar val2 = list[Random.Range(0, list.Count)]; Plugin.Log.LogInfo((object)("StartSkinned: mimic starts as " + val2.playerName + ".")); Reveal(val.Value, val2); yield break; } } Spots.ItemSpot? itemSpot = Spots.FindItemSpot(Plugin.SpawnInStartRoom.Value, awayFromPlayers: false); if (!itemSpot.HasValue) { Plugin.Log.LogWarning((object)"Mimic: no place to hide in this level; it sits this one out."); phase = Phase.Dead; } else { SpawnItem(itemSpot.Value); } } private void Update() { if (!Host) { return; } switch (phase) { case Phase.Item: KeepDespawned(); ItemTick(); break; case Phase.Body: BodyTick(); break; case Phase.Dead: if (!enemyParent.Spawned) { enemyParent.DespawnedTimer = 1000000f; } break; } } private void KeepDespawned() { if (enemyParent.Spawned) { enemyParent.Despawn(); } else { enemyParent.DespawnedTimer = 1000000f; } } private void Died(string how) { if (phase != Phase.Dead) { phase = Phase.Dead; busy = false; ((MonoBehaviour)this).StopAllCoroutines(); Plugin.Log.LogInfo((object)("The mimic was killed (" + how + ").")); Send("DiedRPC", (RpcTarget)3); if (enemyParent.Spawned) { ((MonoBehaviour)this).StartCoroutine(DropLoot()); } } } private IEnumerator DropLoot() { yield return (object)new WaitForSeconds(2f); if (enemyParent.Spawned) { enemyParent.Despawn(); } } public void OnInvestigate() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Host && enemy.HasStateInvestigate) { Hear(enemy.StateInvestigate.onInvestigateTriggeredPosition); } } private void Send(string rpc, RpcTarget target, params object[] args) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (SemiFunc.IsMultiplayer()) { view.RPC(rpc, target, args); return; } switch (rpc) { case "SetFormRPC": SetFormRPC((int)args[0]); break; case "LungeRPC": LungeRPC(); break; case "SpeakRPC": SpeakRPC((int)args[0]); break; case "DiedRPC": DiedRPC(); break; } } [PunRPC] private void SetFormRPC(int victimView, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && Object.op_Implicit((Object)(object)skin)) { skin.SetSkin(victimView); } } [PunRPC] private void LungeRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && Object.op_Implicit((Object)(object)skin)) { skin.Lunge(); } } [PunRPC] private void SpeakRPC(int seed, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && Object.op_Implicit((Object)(object)skin)) { skin.Speak(seed); } } [PunRPC] private void DiedRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && Object.op_Implicit((Object)(object)skin)) { skin.Die(); } } private static IEnumerator Hurt(PlayerAvatar victim, int damage) { if (Object.op_Implicit((Object)(object)victim) && !victim.deadSet && damage > 0) { int before = victim.playerHealth.health; victim.playerHealth.HurtOther(damage, Vector3.zero, false, -1, false); float wait = 0f; while (wait < 2f && Object.op_Implicit((Object)(object)victim) && !victim.deadSet && victim.playerHealth.health == before) { wait += Time.deltaTime; yield return null; } if (Object.op_Implicit((Object)(object)victim) && !victim.deadSet) { yield return (object)new WaitForSeconds(0.25f); } } } private void SpawnItem(Spots.ItemSpot spot) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //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) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) ValuableDirector instance = ValuableDirector.instance; List<PrefabRef> list = ((spot.size == (Type?)0) ? instance.tinyValuables : (((int)spot.size.GetValueOrDefault() == 1) ? instance.smallValuables : (((int)spot.size.GetValueOrDefault() == 2) ? instance.mediumValuables : null))); List<PrefabRef> list2 = (from r in ((list == null) ? new List<PrefabRef>[3] { instance.smallValuables, instance.mediumValuables, instance.tinyValuables } : new List<PrefabRef>[1] { list }).Where((List<PrefabRef> l) => l != null).SelectMany((List<PrefabRef> l) => l) where ((PrefabRef<GameObject>)(object)r)?.IsValid() ?? false select r).ToList(); if (list2.Count == 0) { list2 = (from r in new List<PrefabRef>[3] { instance.smallValuables, instance.mediumValuables, instance.tinyValuables }.Where((List<PrefabRef> l) => l != null).SelectMany((List<PrefabRef> l) => l) where ((PrefabRef<GameObject>)(object)r)?.IsValid() ?? false select r).ToList(); } if (list2.Count == 0) { list2 = new List<PrefabRef>[1] { instance.bigValuables }.Where((List<PrefabRef> l) => l != null).SelectMany((List<PrefabRef> l) => l).ToList(); } if (list2.Count == 0) { Plugin.Log.LogWarning((object)"Mimic: no valuable prefabs in this level."); return; } List<PrefabRef> list3 = list2.Where((PrefabRef r) => ((PrefabRef<GameObject>)(object)r).PrefabName != lastLook).ToList(); PrefabRef val = ((list3.Count > 0) ? list3 : list2)[Random.Range(0, ((list3.Count > 0) ? list3 : list2).Count)]; lastLook = ((PrefabRef<GameObject>)(object)val).PrefabName; Vector3 pos = spot.pos; Quaternion rot = spot.rot; GameObject val2 = (GameManager.Multiplayer() ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val).ResourcePath, pos, rot, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val).Prefab, pos, rot)); if (!Object.op_Implicit((Object)(object)val2)) { Plugin.Log.LogWarning((object)("Mimic: could not spawn " + ((PrefabRef<GameObject>)(object)val).ResourcePath + ".")); return; } item = val2; itemGrab = val2.GetComponent<PhysGrabObject>(); itemRb = val2.GetComponent<Rigidbody>(); destroyingItem = false; fleeing = false; itemCooldown = 4f; phase = Phase.Item; ((MonoBehaviour)this).StartCoroutine(KeepOutOfHaulGoal(val2.GetComponent<ValuableObject>())); ManualLogSource log = Plugin.Log; string prefabName = ((PrefabRef<GameObject>)(object)val).PrefabName; object arg = pos; ref Type? size = ref spot.size; log.LogInfo((object)string.Format("Mimic is hiding as {0} at {1} ({2} spot).", prefabName, arg, (size.HasValue ? ((object)size.GetValueOrDefault()/*cast due to .constrained prefix*/).ToString() : null) ?? "floor")); } private static IEnumerator KeepOutOfHaulGoal(ValuableObject v) { float t = 0f; while (Object.op_Implicit((Object)(object)v) && !v.dollarValueSet && t < 10f) { t += Time.deltaTime; yield return null; } yield return null; if (Object.op_Implicit((Object)(object)v) && v.dollarValueSet && Object.op_Implicit((Object)(object)RoundDirector.instance)) { RoundDirector.instance.haulGoalMax = Mathf.Max(0, RoundDirector.instance.haulGoalMax - (int)v.dollarValueCurrent); } } private void DestroyItem() { if (Object.op_Implicit((Object)(object)item)) { destroyingItem = true; if (Object.op_Implicit((Object)(object)itemGrab)) { itemGrab.DestroyPhysGrabObject(); } else { Object.Destroy((Object)(object)item); } item = null; } } private void ItemTick() { if (!Object.op_Implicit((Object)(object)item)) { if (!destroyingItem) { Died("its item form was destroyed"); } } else { if (busy || fleeing) { return; } itemCooldown -= Time.deltaTime; if (!(itemCooldown > 0f)) { PlayerAvatar val = (Object.op_Implicit((Object)(object)itemGrab) ? (from g in itemGrab.playerGrabbing where Object.op_Implicit((Object)(object)g) && Object.op_Implicit((Object)(object)g.playerAvatar) && !g.playerAvatar.deadSet select g.playerAvatar).FirstOrDefault() : null); if (Object.op_Implicit((Object)(object)val)) { ((MonoBehaviour)this).StartCoroutine(ItemStrike(val)); } } } } private IEnumerator ItemStrike(PlayerAvatar victim) { busy = true; float shake = Mathf.Max(0f, Plugin.ShakeTime.Value); float t = 0f; float tick = 0f; while (t < shake && Object.op_Implicit((Object)(object)item)) { t += Time.deltaTime; tick -= Time.deltaTime; if (tick <= 0f && Object.op_Implicit((Object)(object)itemRb)) { tick = 0.03f; float num = Mathf.Lerp(0.6f, 1f, (shake > 0f) ? (t / shake) : 1f); PhysGrabObjectImpactDetector impactDetector = itemGrab.impactDetector; if (impactDetector != null) { impactDetector.ImpactDisable(0.2f); } Vector3 val = Random.insideUnitSphere * 3.5f - itemRb.linearVelocity * 0.5f; itemRb.AddForce(val * num, (ForceMode)2); itemRb.AddTorque(Random.insideUnitSphere * 30f * num, (ForceMode)2); } yield return null; } if (!Object.op_Implicit((Object)(object)item)) { busy = false; yield break; } yield return BreakFree(1.5f, 1f); if (!Object.op_Implicit((Object)(object)item)) { busy = false; yield break; } bool hit = false; if (Object.op_Implicit((Object)(object)victim) && Object.op_Implicit((Object)(object)itemRb)) { PhysGrabObjectImpactDetector impactDetector2 = itemGrab.impactDetector; if (impactDetector2 != null) { impactDetector2.ImpactDisable(1.2f); } Vector3 val2 = (victim.PlayerVisionTarget.VisionTransform.position - ItemCenter) / 0.3f; val2.y += 0.5f * (0f - Physics.gravity.y) * 0.3f; itemRb.linearVelocity = Vector3.ClampMagnitude(val2, 14f); itemRb.AddTorque(Random.insideUnitSphere * 8f, (ForceMode)2); float t2 = 0f; while (t2 < 0.7f && Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)victim) && !victim.deadSet) { t2 += Time.deltaTime; if (ItemHeld) { BreakGrabs(1.5f); } Vector3 itemCenter = ItemCenter; if (Vector3.Distance(itemCenter, victim.PlayerVisionTarget.VisionTransform.position) < 1.1f || Vector3.Distance(itemCenter, ((Component)victim).transform.position + Vector3.up * 0.8f) < 1f) { hit = true; break; } yield return null; } } bool noKill = Plugin.TransformWithoutKill.Value; int num2 = ((hit && !Plugin.Harmless.Value && !noKill) ? Plugin.DisguiseDamage.Value : 0); if (noKill) { Plugin.Log.LogInfo((object)("TransformWithoutKill: the mimic takes " + victim.playerName + "'s form without biting.")); } else if (hit) { Plugin.Log.LogInfo((object)$"Mimic bit {victim.playerName} for {num2}."); } else { Plugin.Log.LogInfo((object)"Mimic's bite missed."); } yield return Hurt(victim, num2); if (!Object.op_Implicit((Object)(object)item)) { busy = false; yield break; } if (Object.op_Implicit((Object)(object)victim) && (victim.deadSet || noKill)) { Spots.OnNav(item.transform.position, 3f, out var floor); DestroyItem(); yield return null; Reveal(floor, victim); } else { if (Plugin.RelocateAfterMiss.Value) { busy = false; ((MonoBehaviour)this).StartCoroutine(Flee()); yield break; } itemCooldown = 5f; } busy = false; } private void BreakGrabs(float noRegrab) { if (!Object.op_Implicit((Object)(object)itemGrab)) { return; } itemGrab.OverrideGrabDisable(noRegrab); foreach (PhysGrabber item in itemGrab.playerGrabbing.ToList()) { if (Object.op_Implicit((Object)(object)item)) { item.OverrideGrabRelease(-1, noRegrab); } } } private IEnumerator BreakFree(float noRegrab, float maxTime) { float t = 0f; float retry = 0f; int tries = 0; while (Object.op_Implicit((Object)(object)item) && ItemHeld && t < maxTime) { float num; retry = (num = retry - Time.deltaTime); if (num <= 0f) { retry = 0.1f; tries++; BreakGrabs(noRegrab); } t += Time.deltaTime; yield return null; } if (Object.op_Implicit((Object)(object)item) && ItemHeld) { Plugin.Log.LogWarning((object)$"Mimic could not break free after {tries} release attempts."); } else if (tries > 0) { Plugin.Log.LogInfo((object)$"Mimic broke free ({tries} release attempt(s))."); } } private IEnumerator Flee() { fleeing = true; Vector3? target = Spots.FindSpot(startRoom: false, awayFromPlayers: true); float t = 0f; float unseen = 0f; float hop = 0.1f; float look = 0f; BreakGrabs(1.5f); while (Object.op_Implicit((Object)(object)item)) { float deltaTime = Time.deltaTime; if (ItemHeld) { BreakGrabs(1f); } t += deltaTime; hop -= deltaTime; look -= deltaTime; if (hop <= 0f && Object.op_Implicit((Object)(object)itemRb) && Mathf.Abs(itemRb.linearVelocity.y) < 1.5f) { hop = Random.Range(0.45f, 0.7f); Vector3 val = FleeDirection(target); if (Object.op_Implicit((Object)(object)itemGrab)) { PhysGrabObjectImpactDetector impactDetector = itemGrab.impactDetector; if (impactDetector != null) { impactDetector.ImpactDisable(0.9f); } } itemRb.AddForce(val * 3.4f + Vector3.up * 3.2f, (ForceMode)2); itemRb.AddTorque(Random.insideUnitSphere * 4f, (ForceMode)2); } if (look <= 0f) { look = 0.2f; unseen = (Spots.SeenByAnyone(ItemCenter) ? 0f : (unseen + 0.2f)); } if (unseen >= 1f && t >= 1f) { Spots.ItemSpot? spot = Spots.FindItemSpot(startRoom: false, awayFromPlayers: true); if (spot.HasValue) { Plugin.Log.LogInfo((object)"Mimic escaped and is hiding as something else."); DestroyItem(); yield return null; SpawnItem(spot.Value); yield break; } t = 0f; } yield return null; } fleeing = false; } private Vector3 FleeDirection(Vector3? target) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00fa: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) Vector3 from = item.transform.position; if (target.HasValue && Spots.OnNav(from, 2f, out var hit)) { NavMeshPath val = new NavMeshPath(); if (NavMesh.CalculatePath(hit, target.Value, Spots.Filter(), val) && val.corners.Length > 1) { Vector3 val2 = val.corners[1] - from; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude > 0.01f) { return ((Vector3)(ref val2)).normalized; } } } PlayerAvatar val3 = (from p in Spots.Living() orderby Vector3.Distance(((Component)p).transform.position, @from) select p).FirstOrDefault(); Vector3 val4 = (Object.op_Implicit((Object)(object)val3) ? (from - ((Component)val3).transform.position) : Random.insideUnitSphere); val4.y = 0f; if (!(((Vector3)(ref val4)).sqrMagnitude > 0.01f)) { return Vector3.forward; } return ((Vector3)(ref val4)).normalized; } } internal class MimicNameTag : MonoBehaviour { private TextMeshProUGUI text; private RectTransform rect; private Transform feet; private float headHeight = 1.5f; private Vector3 followTarget; private Vector3 worldPosition; private float followTargetY; private float showTimer; private float showTimeTotal; private float showTimeTotalResetTimer; internal bool hidden; public static MimicNameTag Create(Transform feet, string playerName, float headHeight) { //IL_0029: 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_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_00dc: Unknown result type (might be due to invalid IL or missing references) WorldSpaceUIParent instance = WorldSpaceUIParent.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.playerNamePrefab)) { return null; } GameObject val = Object.Instantiate<GameObject>(instance.playerNamePrefab, ((Component)instance).transform.position, ((Component)instance).transform.rotation, ((Component)instance).transform); ((Object)val).name = "MimicNameTag"; WorldSpaceUIPlayerName component = val.GetComponent<WorldSpaceUIPlayerName>(); TextMeshProUGUI val2 = (Object.op_Implicit((Object)(object)component) ? component.text : val.GetComponentInChildren<TextMeshProUGUI>(true)); if (Object.op_Implicit((Object)(object)component)) { Object.DestroyImmediate((Object)(object)component); } if (!Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val); return null; } MimicNameTag mimicNameTag = val.AddComponent<MimicNameTag>(); mimicNameTag.text = val2; mimicNameTag.rect = val.GetComponent<RectTransform>(); mimicNameTag.feet = feet; mimicNameTag.headHeight = headHeight; mimicNameTag.followTarget = feet.position; ((TMP_Text)val2).text = playerName; ((Graphic)val2).color = new Color(1f, 1f, 1f, 0f); return mimicNameTag; } public void SetName(string playerName, float height) { if (Object.op_Implicit((Object)(object)text)) { ((TMP_Text)text).text = playerName; } headHeight = height; } public void Show() { showTimeTotal += 0.25f; showTimeTotalResetTimer = 0.5f; if (showTimeTotal >= 1f) { showTimer = 0.5f; } } private void Update() { //IL_0087: 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_00b0: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_00f3: 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_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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b8: 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_01e7: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)feet) || !Object.op_Implicit((Object)(object)text)) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (showTimeTotalResetTimer > 0f && (showTimeTotalResetTimer -= Time.deltaTime) <= 0f) { showTimeTotal = 0f; } if (hidden || Object.op_Implicit((Object)(object)SpectateCamera.instance) || showTimer <= 0f) { ((Graphic)text).color = Color.Lerp(((Graphic)text).color, new Color(1f, 1f, 1f, 0f), Time.deltaTime * 20f); } else { showTimer -= Time.deltaTime; ((Graphic)text).color = Color.Lerp(((Graphic)text).color, new Color(1f, 1f, 1f, 0.5f), Time.deltaTime * 5f); } followTarget = Vector3.Lerp(followTarget, feet.position, Time.deltaTime * 30f); float num = headHeight + 0.35f; followTargetY = Mathf.Lerp(followTargetY, num, Time.deltaTime * ((Mathf.Abs(followTargetY - num) > 0.2f) ? 20f : 3f)); worldPosition = followTarget + Vector3.up * followTargetY; if (Object.op_Implicit((Object)(object)rect)) { rect.anchoredPosition = Vector2.op_Implicit(SemiFunc.UIWorldToCanvasPosition(worldPosition)); } Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { ((TMP_Text)text).fontSize = 20f - Vector3.Distance(worldPosition, ((Component)main).transform.position); } } } internal class MimicSession : MonoBehaviour { private ConfigFile config; private DateTime configWriteTime; private float nextConfigCheck; private int levelId; private float voiceRequestAt = -1f; private bool spawnRolled; private int loggedClips; private float voiceReportAt; internal static MimicSession Instance { get; private set; } internal static void Create(ConfigFile config) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown GameObject val = new GameObject("Mimic.Session") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent<MimicSession>(); Instance.config = config; Instance.configWriteTime = Instance.ReadWriteTime(); } private void Update() { ConfigTick(); VoiceDiagnostics(); LevelGenerator instance = LevelGenerator.Instance; int num = (Object.op_Implicit((Object)(object)instance) ? ((Object)instance).GetInstanceID() : 0); if (num != levelId) { levelId = num; VoiceBank.Clear(); voiceRequestAt = Time.time + 3f; spawnRolled = false; } SpawnTick(instance); if (voiceRequestAt >= 0f && Time.time >= voiceRequestAt && Object.op_Implicit((Object)(object)instance) && instance.Generated) { voiceRequestAt = -1f; if (!SemiFunc.IsMasterClientOrSingleplayer()) { VoiceBank.RequestAll(); } } } private void SpawnTick(LevelGenerator gen) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (spawnRolled || !SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)gen) || !gen.Generated || !SemiFunc.RunIsLevel() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena() || !Object.op_Implicit((Object)(object)Plugin.Setup)) { return; } spawnRolled = true; if (!Plugin.OnlyMimic.Value && Random.value >= Plugin.SpawnChance.Value) { Plugin.Log.LogInfo((object)$"No mimic in this level (SpawnChance {Plugin.SpawnChance.Value:0.##})."); return; } Plugin.Log.LogInfo((object)"A mimic will hide in this level."); Vector3? val = Spots.FindSpot(startRoom: false, awayFromPlayers: false); if (!val.HasValue) { Plugin.Log.LogWarning((object)"Mimic: no spot on the navmesh to spawn it."); return; } List<EnemyParent> list = Enemies.SpawnEnemy(Plugin.Setup, val.Value, Quaternion.identity, true); if (list == null || list.Count == 0) { Plugin.Log.LogWarning((object)"Mimic: REPOLib couldn't spawn it."); } } private DateTime ReadWriteTime() { try { return File.GetLastWriteTimeUtc(config.ConfigFilePath); } catch { return default(DateTime); } } private void ConfigTick() { if (config == null || Time.unscaledTime < nextConfigCheck) { return; } nextConfigCheck = Time.unscaledTime + 1f; DateTime dateTime = ReadWriteTime(); if (dateTime == configWriteTime) { return; } configWriteTime = dateTime; try { config.Reload(); VoiceRecorder.RefreshSettings(); Plugin.Log.LogInfo((object)"Config reloaded."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Config reload failed (file mid-save?): " + ex.Message)); configWriteTime = default(DateTime); } } private void VoiceDiagnostics() { int recordedCount = VoiceRecorder.RecordedCount; if (recordedCount != loggedClips) { loggedClips = recordedCount; Plugin.Log.LogInfo((object)$"Recorded voice clip #{recordedCount} ({VoiceRecorder.LastClipSeconds:0.0} s)."); } if (Time.unscaledTime >= voiceReportAt) { voiceReportAt = Time.unscaledTime + 60f; Plugin.Log.LogInfo((object)$"Voice: {VoiceRecorder.FrameCount} mic frames ({VoiceRecorder.ActiveFrameCount} active), {recordedCount} clips recorded, noise {VoiceRecorder.NoiseFloor:0.0000}, peak {VoiceRecorder.PeakRms:0.0000}, open segment {VoiceRecorder.OpenSegmentSeconds:0.0} s."); VoiceRecorder.PeakRms = 0f; } } } public class MimicSkin : MonoBehaviour { internal Enemy enemy; private Transform skinRoot; private GameObject skin; private Animator skinAnimator; private Transform jaw; private Quaternion jawRest; private float jawMaxAngle = 45f; private SkinRig rig; private Quaternion armRot; private bool armInit; private Vector3 lookPoint; private float lookPitch; private float lookYaw; private float talkerTimer; private PlayerAvatar talker; private readonly float[] outBuf = new float[256]; private AudioSource voice; private readonly List<Material> ownedMaterials = new List<Material>(); private int formView = -1; private Vector3 lastPos; private Vector3 skinLocal; private Vector3 smoothPos; private Quaternion smoothRot = Quaternion.identity; private bool placed; private bool moving; private bool sprinting; private Vector3 velocity; private float headHeight = 1.5f; private float speed; private Vector3 lungeOffset; private bool dead; private MimicNameTag nameTag; private float nameCheckTimer; private readonly MaterialTrigger stepTrigger = new MaterialTrigger(); private float lastStepEvent = -10f; private float stepTimer; private int pendingView = -1; private float pendingTimer; private Vector3 eyeDirLeft = Vector3.forward; private Vector3 eyeDirRight = Vector3.forward; private Vector3 HeadPos => skinRoot.position + Vector3.up * headHeight; private void Awake() { //IL_0075: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_0100: 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_017a: 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_0063: Unknown result type (might be due to invalid IL or missing references) enemy = ((Component)this).GetComponentInChildren<Enemy>(true); EnemyRigidbody componentInChildren = ((Component)this).GetComponentInChildren<EnemyRigidbody>(true); Transform val = (Object.op_Implicit((Object)(object)componentInChildren) ? ((Component)componentInChildren).transform : ((Component)this).transform); float num = ((Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)enemy)) ? (((Component)componentInChildren).transform.position.y - ((Component)enemy).transform.position.y) : 0f); skinRoot = new GameObject("MimicSkinRoot").transform; skinRoot.SetParent(val, false); skinRoot.localPosition = (skinLocal = new Vector3(0f, (0f - num) / Mathf.Max(0.0001f, val.lossyScale.y), 0f)); GameObject val2 = new GameObject("MimicVoice"); val2.transform.SetParent(skinRoot, false); val2.transform.localPosition = new Vector3(0f, 1.4f, 0f); voice = val2.AddComponent<AudioSource>(); voice.playOnAwake = false; voice.spatialBlend = 1f; voice.dopplerLevel = 0f; voice.rolloffMode = (AudioRolloffMode)0; voice.minDistance = 1.5f; voice.maxDistance = 25f; lastPos = skinRoot.position; } public void SetSkin(int victimView) { //IL_016a: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_019d: 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_01bb: 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_0266: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = ((IEnumerable<PlayerAvatar>)SemiFunc.PlayerGetList()).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.photonView) && p.photonView.ViewID == victimView)); if (!Object.op_Implicit((Object)(object)val)) { if (pendingView != victimView) { pendingView = victimView; pendingTimer = 10f; } return; } pendingView = -1; if (Object.op_Implicit((Object)(object)skin)) { Object.Destroy((Object)(object)skin); } foreach (Material ownedMaterial in ownedMaterials) { if (Object.op_Implicit((Object)(object)ownedMaterial)) { Object.Destroy((Object)(object)ownedMaterial); } } ownedMaterials.Clear(); skin = Visuals.ClonePlayer(val, skinRoot, ownedMaterials, out rig); jaw = rig.jaw; jawMaxAngle = rig.jawMaxAngle; if (!Object.op_Implicit((Object)(object)rig.headUp) && !Object.op_Implicit((Object)(object)rig.headSide)) { Plugin.Log.LogWarning((object)"Mimic: no head found on the copied avatar; it won't look around."); } if (!Object.op_Implicit((Object)(object)rig.eyeLeft) && !Object.op_Implicit((Object)(object)rig.eyeRight)) { Plugin.Log.LogWarning((object)"Mimic: no eyes found on the copied avatar."); } lookPoint = skinRoot.position + skinRoot.forward * 3f + Vector3.up * 1.5f; if (Object.op_Implicit((Object)(object)jaw)) { jawRest = jaw.localRotation; } else { Plugin.Log.LogWarning((object)"Mimic: no jaw found on the copied avatar; it won't move its mouth."); } skinAnimator = (Object.op_Implicit((Object)(object)skin) ? skin.GetComponent<Animator>() : null); AnimationEventSink animationEventSink = (Object.op_Implicit((Object)(object)skin) ? skin.GetComponent<AnimationEventSink>() : null); if (Object.op_Implicit((Object)(object)animationEventSink)) { animationEventSink.owner = this; } formView = victimView; float height = 1.5f; PlayerAvatarVisuals playerAvatarVisuals = val.playerAvatarVisuals; if (Object.op_Implicit((Object)(object)playerAvatarVisuals) && Object.op_Implicit((Object)(object)playerAvatarVisuals.headLookAtTransform)) { height = Mathf.Clamp(playerAvatarVisuals.headLookAtTransform.position.y - ((Component)playerAvatarVisuals).transform.position.y, 1f, 2.5f); } headHeight = height; if (Object.op_Implicit((Object)(object)nameTag)) { nameTag.SetName(val.playerName, height); } else { nameTag = MimicNameTag.Create(skinRoot, val.playerName, height); } CopyVoiceSettings(val); Plugin.Log.LogInfo((object)("Mimic took the form of " + val.playerName + ".")); if (val.isLocal && Plugin.ShareMyVoice.Value) { VoiceBank.Share(victimView); } } public void Lunge() { ((MonoBehaviour)this).StartCoroutine(LungeFx()); Speak(Random.Range(0, int.MaxValue)); } public void Speak(int seed) { PlayerAvatar instance = PlayerAvatar.instance; if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.photonView) && instance.photonView.ViewID == formView) { VoiceBank.SyncLocal(formView); } if (!dead && formView >= 0 && Object.op_Implicit((Object)(object)voice) && !voice.isPlaying) { AudioClip val = VoiceBank.Pick(formView, seed); if (Object.op_Implicit((Object)(object)val)) { voice.volume = Plugin.VoiceVolume.Value; voice.clip = val; voice.Play(); } } } public void Die() { dead = true; if (Object.op_Implicit((Object)(object)voice)) { voice.Stop(); } if (Object.op_Implicit((Object)(object)nameTag)) { Object.Destroy((Object)(object)((Component)nameTag).gameObject); } if (rig != null && Object.op_Implicit((Object)(object)rig.flashlight)) { ((Behaviour)rig.flashlight).enabled = false; } ((MonoBehaviour)this).StartCoroutine(Collapse()); } private IEnumerator Collapse() { float t = 0f; while (t < 1.2f && Object.op_Implicit((Object)(object)skin)) { t += Time.deltaTime; skin.transform.localPosition = Vector3.down * t * 1.5f; skin.transform.localScale = Vector3.one * Mathf.Lerp(1f, 0.6f, t / 1.2f); yield return null; } if (Object.op_Implicit((Object)(object)skin)) { Object.Destroy((Object)(object)skin); } } private void CopyVoiceSettings(PlayerAvatar victim) { //IL_003d: 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_0081: Invalid comparison between Unknown and I4 AudioSource val = (Object.op_Implicit((Object)(object)victim.voiceChat) ? victim.voiceChat.audioSource : null); if (Object.op_Implicit((Object)(object)val)) { voice.outputAudioMixerGroup = val.outputAudioMixerGroup; voice.rolloffMode = val.rolloffMode; voice.minDistance = val.minDistance; voice.maxDistance = val.maxDistance; voice.spread = val.spread; if ((int)val.rolloffMode == 2) { voice.SetCustomCurve((AudioSourceCurveType)0, val.GetCustomCurve((AudioSourceCurveType)0)); } voice.spatialBlend = 1f; } } private void Update() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ad: 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_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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (pendingView >= 0) { if ((pendingTimer -= Time.deltaTime) <= 0f) { Plugin.Log.LogWarning((object)$"Mimic: player {pendingView} not found for its form."); pendingView = -1; } else { SetSkin(pendingView); } } if (!Object.op_Implicit((Object)(object)skinRoot)) { return; } bool flag = Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.Rigidbody) && enemy.Rigidbody.grabbed; Vector3 val = smoothPos; Vector3 val2 = val - lastPos; val2.y = 0f; lastPos = val; if (Time.deltaTime > 0f) { speed = Mathf.Lerp(speed, ((Vector3)(ref val2)).magnitude / Time.deltaTime, 10f * Time.deltaTime); velocity = Vector3.Lerp(velocity, val2 / Time.deltaTime, 10f * Time.deltaTime); } if (Object.op_Implicit((Object)(object)skin) && !dead) { skin.transform.localPosition = lungeOffset; moving = !flag && (moving ? (speed > 0.2f) : (speed > 0.6f)); bool flag2 = moving && (sprinting ? (speed > 3.2f) : (speed > 4f)); if (Object.op_Implicit((Object)(object)skinAnimator)) { skinAnimator.SetBool("Moving", moving); if (flag2 && !sprinting) { skinAnimator.SetTrigger("SprintingImpulse"); } skinAnimator.SetBool("Sprinting", flag2); skinAnimator.SetBool("Crouching", false); skinAnimator.SetBool("Crawling", false); skinAnimator.SetBool("Grabbing", false); skinAnimator.SetBool("Sliding", false); skinAnimator.SetBool("Tumbling", false); skinAnimator.SetBool("TumblingMove", false); skinAnimator.SetBool("Jumping", false); skinAnimator.SetBool("Falling", false); } sprinting = flag2; if (moving && Time.time - lastStepEvent > 1f && (stepTimer -= Time.deltaTime) <= 0f) { stepTimer = Mathf.Clamp(0.9f / Mathf.Max(0.5f, speed), 0.25f, 0.6f); PlayStep((SoundType)0); } } NameCheck(); } internal void Footstep(SoundType type) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) lastStepEvent = Time.time; PlayStep(type); } private void PlayStep(SoundType type) { //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) if (!dead && Object.op_Implicit((Object)(object)skinRoot) && Object.op_Implicit((Object)(object)Materials.Instance) && (!Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)enemy.Rigidbody) || !enemy.Rigidbody.grabbed)) { Materials.Instance.Impulse(skinRoot.position, Vector3.down, type, true, true, stepTrigger, (HostType)1); } } private void NameCheck() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 //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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0162: 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_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_017e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)nameTag)) { return; } nameTag.hidden = dead || !Object.op_Implicit((Object)(object)skin) || (Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.EnemyParent) && !enemy.EnemyParent.Spawned); if ((nameCheckTimer -= Time.deltaTime) > 0f) { return; } nameCheckTimer = 0.25f; if (nameTag.hidden || !Object.op_Implicit((Object)(object)GameDirector.instance) || (int)GameDirector.instance.currentState != 2 || (Object.op_Implicit((Object)(object)Map.Instance) && Map.Instance.Active) || (Object.op_Implicit((Object)(object)GameplayManager.instance) && !GameplayManager.instance.playerNames)) { return; } Camera main = Camera.main; if (!Object.op_Implicit((Object)(object)main)) { return; } Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; for (float num = 0.3f; num <= 1.7f; num += 0.35f) { Vector3 val = skinRoot.position + Vector3.up * num; Vector3 val2 = val - position; float num2 = Vector3.Dot(val2, forward); if (!(num2 <= 0f) && !(num2 > 15f)) { Vector3 val3 = val2 - forward * num2; if (!(((Vector3)(ref val3)).magnitude > 0.55f) && !Blocked(position, val)) { nameTag.Show(); break; } } } } private bool Blocked(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) & ~LayerMask.GetMask(new string[1] { "Player" }); RaycastHit[] array = Physics.RaycastAll(from, val, ((Vector3)(ref val)).magnitude, num, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)this).transform) && ((RaycastHit)(ref val2)).distance < ((Vector3)(ref val)).magnitude - 0.4f) { return true; } } return false; } private void Place() { //IL_0017: 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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_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_009d: 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_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_00f2: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_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_015e: 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_014a: 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) Transform parent = skinRoot.parent; if (!Object.op_Implicit((Object)(object)parent)) { return; } Vector3 val = parent.TransformPoint(skinLocal); Vector3 val2 = Vector3.ProjectOnPlane(parent.forward, Vector3.up); Quaternion val3 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? Quaternion.LookRotation(val2) : smoothRot); bool num = Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.Rigidbody) && enemy.Rigidbody.grabbed; float deltaTime = Time.deltaTime; if (placed) { Vector3 val4 = val - smoothPos; if (!(((Vector3)(ref val4)).sqrMagnitude > 4f)) { Vector3 val5 = Vector3.Lerp(smoothPos, val, 1f - Mathf.Exp(-18f * deltaTime)); val5.y = Mathf.Lerp(smoothPos.y, val.y, 1f - Mathf.Exp(-8f * deltaTime)); smoothPos = val5; smoothRot = Quaternion.Slerp(smoothRot, val3, 1f - Mathf.Exp(-10f * deltaTime)); goto IL_0142; } } smoothPos = val; smoothRot = val3; placed = true; goto IL_0142; IL_0142: if (num) { skinRoot.SetPositionAndRotation(val, parent.rotation); } else { skinRoot.SetPositionAndRotation(smoothPos, smoothRot); } } private void LateUpdate() { //IL_00ea: 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_011f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)skinRoot)) { Place(); } if (!Object.op_Implicit((Object)(object)skin) || dead) { return; } Look(); if (!Object.op_Implicit((Object)(object)jaw)) { return; } float num = 0f; if (Object.op_Implicit((Object)(object)voice) && voice.isPlaying) { voice.GetOutputData(outBuf, 0); for (int i = 0; i < outBuf.Length; i++) { num += Mathf.Abs(outBuf[i]); } num /= (float)outBuf.Length; num /= Mathf.Max(0.05f, voice.volume); } float num2 = ((num > 0.005f) ? Mathf.Lerp(0f, 0f - jawMaxAngle, num * 4f) : 0f); jaw.localRotation = Quaternion.Slerp(jaw.localRotation, jawRest * Quaternion.Euler(num2, 0f, 0f), Mathf.Min(1f, 100f * Time.deltaTime)); } private Vector3 PickLookPoint() { //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_0057: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0145: 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_01e8: 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_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_0185: Unknown result type (might be due to invalid IL or missing references) Vector3 position = skinRoot.position; List<PlayerAvatar> list = (from p in SemiFunc.PlayerGetList() where Object.op_Implicit((Object)(object)p) && !p.isDisabled && Object.op_Implicit((Object)(object)p.photonView) && p.photonView.ViewID != formView select p).ToList(); foreach (PlayerAvatar item in list) { if (Object.op_Implicit((Object)(object)item.voiceChat) && item.voiceChat.isTalking && Vector3.Distance(position, ((Component)item).transform.position) < 6f) { talker = item; talkerTimer = Random.Range(2f, 4f); } } if (Object.op_Implicit((Object)(object)talker) && (talkerTimer -= Time.deltaTime) > 0f && !talker.isDisabled) { return Eye(talker); } talker = null; PlayerAvatar val = null; float num = 8f; foreach (PlayerAvatar item2 in list) { Vector3 val2 = ((Component)item2).transform.position - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < num && Vector3.Angle(skinRoot.forward, new Vector3(val2.x, 0f, val2.z)) < 100f) { num = magnitude; val = item2; } } if (Object.op_Implicit((Object)(object)val)) { return Eye(val); } float num2 = Time.time * 0.25f + (float)((Object)this).GetInstanceID() * 0.1f; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor((Mathf.PerlinNoise(num2, 0f) - 0.5f) * 3f, (Mathf.PerlinNoise(0f, num2) - 0.5f) * 1.2f, 0f); return skinRoot.TransformPoint(new Vector3(val3.x, 1.5f + val3.y, 4f)); } private static Vector3 Eye(PlayerAvatar p) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)p.PlayerVisionTarget) || !Object.op_Implicit((Object)(object)p.PlayerVisionTarget.VisionTransform)) { return ((Component)p).transform.position + Vector3.up * 1.5f; } return p.PlayerVisionTarget.VisionTransform.position; } private void Look() { //IL_0011: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_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_0125: 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_019f: 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_0238: 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_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: 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_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) if (rig != null) { float deltaTime = Time.deltaTime; lookPoint = Vector3.Lerp(lookPoint, PickLookPoint(), Mathf.Min(1f, 8f * deltaTime)); Vector3 val = skinRoot.InverseTransformDirection(lookPoint - HeadPos); float num = Mathf.Clamp(Mathf.Atan2(val.x, val.z) * 57.29578f, -40f, 40f); float y = val.y; Vector2 val2 = new Vector2(val.x, val.z); float num2 = Mathf.Clamp((0f - Mathf.Atan2(y, ((Vector2)(ref v