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 Shepot v0.1.0
plugins/Shepot/Shepot.dll
Decompiled 39 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Shepot")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("Shepot")] [assembly: AssemblyTitle("Shepot")] [assembly: AssemblyVersion("0.1.0.0")] namespace Shepot; internal sealed class Appearance : IDisposable { private readonly GameObject root; private readonly Transform figure; private readonly Dictionary<string, Transform> parts = new Dictionary<string, Transform>(); private readonly List<Object> owned = new List<Object>(); private readonly AudioSource source; private readonly Vector3 jawRest; private readonly Texture2D portrait; private float overlayAt = -20f; private bool visible; internal Appearance(Transform parent, string directory) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) root = new GameObject("Shepot | Шёпот"); root.transform.SetParent(parent, false); root.SetActive(false); try { figure = new GameObject("Figure").transform; figure.SetParent(root.transform, false); using (Stream stream = Asset("shape")) { ReadParts(stream); } jawRest = parts["jaw"].localPosition; portrait = new Texture2D(2, 2, (TextureFormat)4, false); owned.Add((Object)(object)portrait); using (Stream stream2 = Asset("face")) { using MemoryStream memoryStream = new MemoryStream(); stream2.CopyTo(memoryStream); if (!ImageConversion.LoadImage(portrait, memoryStream.ToArray(), true)) { throw new InvalidDataException("Unreadable mask texture."); } } GameObject val = new GameObject("Voice"); val.transform.SetParent(root.transform, false); val.transform.localPosition = Vector3.up * 1.55f; source = val.AddComponent<AudioSource>(); source.playOnAwake = false; source.spatialBlend = 1f; source.rolloffMode = (AudioRolloffMode)0; source.minDistance = 2.2f; source.maxDistance = 16f; source.dopplerLevel = 0f; using FileStream stream3 = File.OpenRead(Path.Combine(directory, "voice.wav")); int rate; float[] array = ClipReader.Read(stream3, out rate); AudioClip val2 = AudioClip.Create("Shepot voice (RU)", array.Length, 1, rate, false); owned.Add((Object)(object)val2); if (!val2.SetData(array, 0)) { throw new InvalidDataException("Cannot populate voice clip."); } source.clip = val2; } catch { Dispose(); throw; } } private static Stream Asset(string name) { return typeof(Appearance).Assembly.GetManifestResourceStream("Shepot." + name) ?? throw new InvalidDataException("Missing asset " + name); } private static Vector3 Point(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private void ReadParts(Stream stream) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01e7: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02ce: Expected O, but got Unknown //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(stream, Encoding.ASCII, leaveOpen: true); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "SHP1") { throw new InvalidDataException("Invalid sculpt."); } Material[] array = (Material[])(object)new Material[binaryReader.ReadByte()]; Shader val = (Object.op_Implicit((Object)(object)GraphicsSettings.currentRenderPipeline) ? Shader.Find("Universal Render Pipeline/Lit") : Shader.Find("Standard")) ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("No compatible material shader."); } for (int i = 0; i < array.Length; i++) { Color val2 = Color32.op_Implicit(new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), byte.MaxValue)); bool num = binaryReader.ReadByte() != 0; Material val3 = new Material(val); owned.Add((Object)(object)val3); if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", val2); } if (val3.HasProperty("_Color")) { val3.SetColor("_Color", val2); } if (val3.HasProperty("_Glossiness")) { val3.SetFloat("_Glossiness", 0.13f); } if (val3.HasProperty("_Smoothness")) { val3.SetFloat("_Smoothness", 0.13f); } if (num && val3.HasProperty("_EmissionColor")) { val3.EnableKeyword("_EMISSION"); val3.SetColor("_EmissionColor", val2 * 1.7f); } array[i] = val3; } int num2 = binaryReader.ReadByte(); for (int j = 0; j < num2; j++) { string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(binaryReader.ReadByte())); GameObject val4 = new GameObject(text); val4.transform.SetParent(figure, false); val4.transform.localPosition = Point(binaryReader); parts.Add(text, val4.transform); int num3 = binaryReader.ReadInt32(); if (num3 < 1 || num3 > 16000) { throw new InvalidDataException("Invalid mesh size."); } Vector3[] array2 = (Vector3[])(object)new Vector3[num3 * 3]; SortedDictionary<int, List<int>> sortedDictionary = new SortedDictionary<int, List<int>>(); for (int k = 0; k < num3; k++) { int key = binaryReader.ReadByte(); if (!sortedDictionary.TryGetValue(key, out var value)) { sortedDictionary.Add(key, value = new List<int>()); } for (int l = 0; l < 3; l++) { int num4 = 3 * k + l; array2[num4] = Point(binaryReader); value.Add(num4); } } Mesh val5 = new Mesh { name = "Shepot " + text, vertices = array2, subMeshCount = sortedDictionary.Count }; owned.Add((Object)(object)val5); List<Material> list = new List<Material>(sortedDictionary.Count); int num5 = 0; foreach (KeyValuePair<int, List<int>> item in sortedDictionary) { val5.SetTriangles(item.Value, num5++); list.Add(array[item.Key]); } val5.RecalculateNormals(); val5.RecalculateBounds(); val5.UploadMeshData(true); val4.AddComponent<MeshFilter>().sharedMesh = val5; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterials = list.ToArray(); } } internal void Place(Vector3 at, float yaw, bool snap) { //IL_003d: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (!(!visible || snap)) { Vector3 val = root.transform.position - at; if (!(((Vector3)(ref val)).sqrMagnitude > 16f)) { float num = 1f - Mathf.Exp(-14f * Time.deltaTime); root.transform.position = Vector3.Lerp(root.transform.position, at, num); root.transform.rotation = Quaternion.Slerp(root.transform.rotation, Quaternion.Euler(0f, yaw, 0f), num); goto IL_00c9; } } root.transform.SetPositionAndRotation(at, Quaternion.Euler(0f, yaw, 0f)); goto IL_00c9; IL_00c9: if (!visible) { root.SetActive(true); visible = true; } } internal void Pose(float now, bool scaring, float sinceScare) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sin(now * 5.2f); float num2 = (scaring ? Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(sinceScare / 0.15f)) : 0f); float num3 = (scaring ? Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.34f, 1.72f, sinceScare)) : 0f); figure.localPosition = new Vector3(0f, 0.027f * Mathf.Sin(now * 4.8f) - 0.14f * num2 - 1.2f * num3, 0.12f * num2 - 0.52f * num3); figure.localScale = Vector3.one * (1f - 0.85f * num3); parts["mask"].localRotation = Quaternion.Euler(-11f * num2, 4f * Mathf.Sin(now * 1.7f), -5f * num2); parts["jaw"].localRotation = Quaternion.Euler(40f * num2 * (0.89f + 0.11f * Mathf.Sin(19f * sinceScare)), 0f, 0f); parts["jaw"].localPosition = jawRest + 0.045f * num2 * Vector3.down; parts["armL"].localRotation = Quaternion.Euler(10f * num - 54f * num2, 0f, -6f - 9f * num2); parts["armR"].localRotation = Quaternion.Euler(-10f * num - 54f * num2, 0f, 6f + 9f * num2); } internal void Scare(float volume, bool showMask) { source.volume = Mathf.Clamp01(volume); source.Play(); if (showMask) { overlayAt = Time.unscaledTime; } } internal void DrawMask() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0086: 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_00c9: Unknown result type (might be due to invalid IL or missing references) float num = Time.unscaledTime - overlayAt; if (!(num < 0f) && !(num >= 0.46f) && (int)Event.current.type == 7) { float num2 = Mathf.Clamp01(num / 0.055f) * (1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.21f, 0.46f, num))); float num3 = (float)Screen.height * Mathf.Lerp(0.57f, 0.85f, Mathf.Min(1f, num * 9f)); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.95f * num2); GUI.DrawTexture(new Rect(((float)Screen.width - num3) * 0.5f, ((float)Screen.height - num3) * 0.5f, num3, num3), (Texture)(object)portrait, (ScaleMode)2, true); GUI.color = color; } } internal void Hide() { if (visible) { source.Stop(); root.SetActive(false); visible = false; } overlayAt = -20f; } public void Dispose() { if (Object.op_Implicit((Object)(object)root)) { Object.Destroy((Object)(object)root); } foreach (Object item in owned) { if (Object.op_Implicit(item)) { Object.Destroy(item); } } owned.Clear(); } } internal static class ClipReader { internal static float[] Read(Stream stream, out int rate) { BinaryReader r = new BinaryReader(stream, Encoding.ASCII, leaveOpen: true); try { if (Tag() != "RIFF") { throw new InvalidDataException("Invalid RIFF header."); } r.ReadUInt32(); if (Tag() != "WAVE") { throw new InvalidDataException("Invalid WAV header."); } rate = 0; while (stream.Position + 8 <= stream.Length) { string text = Tag(); uint num = r.ReadUInt32(); long num2 = stream.Position + num; if (num2 > stream.Length) { throw new InvalidDataException("Truncated WAV chunk."); } if (text == "fmt ") { if (num < 16 || r.ReadUInt16() != 1 || r.ReadUInt16() != 1) { throw new InvalidDataException("Expected mono PCM."); } rate = r.ReadInt32(); r.ReadUInt32(); r.ReadUInt16(); if (r.ReadUInt16() != 16 || rate < 8000 || rate > 96000) { throw new InvalidDataException("Expected 16-bit PCM at 8–96 kHz."); } } if (text == "data" && rate > 0) { if (num < 2 || num % 2 != 0 || num > (long)rate * 2L * 30) { throw new InvalidDataException("Invalid voice clip length."); } float[] array = new float[num / 2]; for (int i = 0; i < array.Length; i++) { array[i] = (float)r.ReadInt16() / 32768f; } return array; } stream.Position = num2 + (num & 1); } throw new InvalidDataException("Missing voice data."); } finally { if (r != null) { ((IDisposable)r).Dispose(); } } string Tag() { return Encoding.ASCII.GetString(r.ReadBytes(4)); } } } [BepInPlugin("shepot.repo.whisper", "Shepot", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private const string Signature = "shepot.v1"; private static readonly BindingFlags AllInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo CompletedLevels = typeof(RunManager).GetField("levelsCompleted", AllInstance); private readonly RaiseEventOptions others = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; private Pursuit ai; private Appearance art; private NetworkedEvent channel; private ConfigEntry<float> firstDelay; private ConfigEntry<float> returnDelay; private ConfigEntry<float> voiceVolume; private ConfigEntry<bool> faceScare; private Room room; private int world; private int level; private int master; private int enteredAt; private int sequence; private int lastSequence; private int encounter; private int heardEncounter; private float nextVisit; private float nextSend; private float stageStart; private float lastHeard; private Vector3 position; private float facing; private VisitStage stage; private bool multiplayer; private bool authority; private bool inLevel; private void Awake() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown firstDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Encounter", "FirstVisitSeconds", 25f, "Seconds after a playable level is ready."); returnDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Encounter", "ReturnSeconds", 55f, "Minimum wait between completed visits (host setting)."); voiceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "VoiceVolume", 0.82f, "Local voice gain, from 0 to 1."); faceScare = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "CloseUp", true, "Show a brief close-up for the pursued player."); try { art = new Appearance(((Component)this).transform, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); ai = new Pursuit(); channel = new NetworkedEvent("shepot.repo.whisper/pose-v1", (Action<EventData>)Receive); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shepot loaded with model and Russian voice."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); ((Behaviour)this).enabled = false; } } private static bool Ready() { if (Object.op_Implicit((Object)(object)RunManager.instance) && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated) { return SemiFunc.RunIsLevel(); } return false; } private void Update() { //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (!Ready()) { if (inLevel) { Leave(); } return; } bool flag = SemiFunc.IsMultiplayer(); if (flag && (!PhotonNetwork.InRoom || PhotonNetwork.MasterClient == null)) { if (inLevel) { Leave(); } return; } Room val = (flag ? PhotonNetwork.CurrentRoom : null); int num = (flag ? PhotonNetwork.MasterClient.ActorNumber : 0); int instanceID = ((Object)LevelGenerator.Instance).GetInstanceID(); if (!inLevel || world != instanceID || room != val || master != num || flag != multiplayer) { Leave(); inLevel = true; world = instanceID; room = val; master = num; multiplayer = flag; authority = !flag || PhotonNetwork.IsMasterClient; level = ((CompletedLevels?.GetValue(RunManager.instance) is int num2) ? num2 : 0); enteredAt = (flag ? PhotonNetwork.ServerTimestamp : 0); nextVisit = Time.time + Mathf.Clamp(firstDelay.Value, 1f, 600f); } float time = Time.time; if (authority) { HostTick(time); } else if (stage != VisitStage.Hidden && Time.unscaledTime - lastHeard > 2.6f) { SetHidden(); } if (stage != VisitStage.Hidden) { art.Place(position, facing, authority); art.Pose(time, stage == VisitStage.Scare, time - stageStart); } } private void HostTick(float now) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f3: Unknown result type (might be due to invalid IL or missing references) if (stage == VisitStage.Hidden) { if (now < nextVisit) { return; } if (!ai.Begin(now)) { nextVisit = now + 2.5f; return; } encounter++; stage = VisitStage.Hunt; stageStart = now; position = ai.Position; facing = ai.Facing; Send(reliable: true); } else if (stage == VisitStage.Hunt) { if (!ai.Tick(now, Time.deltaTime) || now - stageStart > 100f) { Finish(now, completed: false); return; } position = ai.Position; facing = ai.Facing; if (ai.CanScare) { stage = VisitStage.Scare; stageStart = now; art.Place(position, facing, snap: true); Sound(ai.TargetId); Send(reliable: true); } } else if (now - stageStart >= 1.72f) { Finish(now, completed: true); return; } if (multiplayer && now >= nextSend) { Send(reliable: false); } } private void Finish(float now, bool completed) { SetHidden(); stageStart = now; nextVisit = now + (completed ? Mathf.Clamp(returnDelay.Value, 5f, 600f) : 5f); Send(reliable: true); } private void Send(bool reliable) { //IL_007c: 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_00e5: Unknown result type (might be due to invalid IL or missing references) if (multiplayer) { nextSend = Time.time + 0.16f; object[] array = new object[10] { "shepot.v1", level, ++sequence, PhotonNetwork.ServerTimestamp, encounter, (int)stage, position, facing, ai.TargetId, Mathf.Max(0f, Time.time - stageStart) }; NetworkedEvent obj = channel; RaiseEventOptions obj2 = others; SendOptions val = default(SendOptions); ((SendOptions)(ref val)).Reliability = reliable; obj.RaiseEvent((object)array, obj2, val); } } private void Receive(EventData msg) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_02a3: Unknown result type (might be due to invalid IL or missing references) if (!inLevel || !Object.op_Implicit((Object)(object)this) || !((Behaviour)this).isActiveAndEnabled || !multiplayer || authority || room != PhotonNetwork.CurrentRoom || PhotonNetwork.MasterClient == null || msg.Sender != PhotonNetwork.MasterClient.ActorNumber || !(msg.CustomData is object[] array) || array.Length != 10 || !(array[0] is string text) || text != "shepot.v1" || !(array[1] is int num) || !(array[2] is int serial) || !(array[3] is int num2) || !(array[4] is int num3) || !(array[5] is int num4) || num4 < 0 || num4 > 2 || !(array[6] is Vector3 val) || !(array[7] is float n) || !(array[8] is int victim) || !(array[9] is float num5)) { return; } int serverTimestamp = PhotonNetwork.ServerTimestamp; if (!Visit.AcceptSnapshot(msg.Sender, master, num, level, num2, serverTimestamp, enteredAt, serial, lastSequence) || !Finite(val.x) || !Finite(val.y) || !Finite(val.z) || !Finite(n) || !Finite(num5) || num5 < 0f) { return; } lastSequence = serial; lastHeard = Time.unscaledTime; if (num4 == 0) { SetHidden(); return; } bool num6 = encounter != num3 || stage == VisitStage.Hidden; encounter = num3; stage = (VisitStage)num4; position = val; facing = n; float num7 = num5 + (float)Mathf.Max(0, serverTimestamp - num2) * 0.001f; stageStart = Time.time - num7; if (num6) { art.Place(position, facing, snap: true); } if (stage == VisitStage.Scare && heardEncounter != encounter) { if (num7 < 0.7f) { art.Place(position, facing, snap: true); Sound(victim); } else { heardEncounter = encounter; } } } private static bool Finite(float n) { if (!float.IsNaN(n)) { return !float.IsInfinity(n); } return false; } private void Sound(int victim) { heardEncounter = encounter; bool flag = !multiplayer; PlayerAvatar val = SemiFunc.PlayerGetLocal(); if (multiplayer && Object.op_Implicit((Object)(object)val)) { PhotonView component = ((Component)val).GetComponent<PhotonView>(); flag = Object.op_Implicit((Object)(object)component) && component.ViewID == victim; } art.Scare(voiceVolume.Value, flag && faceScare.Value); } private void SetHidden() { stage = VisitStage.Hidden; art?.Hide(); } private void Leave() { inLevel = false; room = null; SetHidden(); ai?.Reset(); lastSequence = 0; sequence = 0; encounter = 0; heardEncounter = -1; nextSend = 0f; } private void OnGUI() { art?.DrawMask(); } private void OnDestroy() { inLevel = false; art?.Dispose(); } } internal sealed class Pursuit { private static readonly FieldInfo Disabled = typeof(PlayerAvatar).GetField("isDisabled", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private readonly Random random = new Random(); private readonly NavMeshPath path = new NavMeshPath(); private NavMeshQueryFilter filter; private Vector3[] corners = Array.Empty<Vector3>(); private int nextCorner; private float nextRoute; private float withoutRoute; private PlayerAvatar target; private PlayerAvatar previous; private Vector3 floorGoal; internal Vector3 Position { get; private set; } internal float Facing { get; private set; } internal int TargetId { get; private set; } internal bool CanScare { get; private set; } private static bool Alive(PlayerAvatar p) { if (Object.op_Implicit((Object)(object)p) && ((Behaviour)p).isActiveAndEnabled) { object obj = Disabled?.GetValue(p); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return ((uint)num & (flag ? 1u : 0u)) == 0; } return false; } internal bool Begin(float now) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) List<PlayerAvatar> list = SemiFunc.PlayerGetList(); if (list == null || list.Count == 0) { return false; } int num = random.Next(list.Count); for (int i = 0; i <= 1; i++) { for (int j = 0; j < list.Count; j++) { PlayerAvatar val = list[(j + num) % list.Count]; if (Alive(val) && (Object)(object)val == (Object)(object)previous == (i == 1) && FindStart(val)) { target = val; previous = val; PhotonView component = ((Component)val).GetComponent<PhotonView>(); TargetId = (Object.op_Implicit((Object)(object)component) ? component.ViewID : 0); Vector3 val2 = ((Component)val).transform.position - Position; Facing = Mathf.Atan2(val2.x, val2.z) * 57.29578f; CanScare = false; withoutRoute = 0f; nextRoute = now + 0.28f; return true; } } } return false; } private bool FindStart(PlayerAvatar player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)player).transform.position; NavMeshHit val2 = default(NavMeshHit); NavMeshHit val5 = default(NavMeshHit); for (int i = 0; i < NavMesh.GetSettingsCount(); i++) { NavMeshQueryFilter val = default(NavMeshQueryFilter); NavMeshBuildSettings settingsByIndex = NavMesh.GetSettingsByIndex(i); ((NavMeshQueryFilter)(ref val)).agentTypeID = ((NavMeshBuildSettings)(ref settingsByIndex)).agentTypeID; ((NavMeshQueryFilter)(ref val)).areaMask = -1; filter = val; if (!NavMesh.SamplePosition(position, ref val2, 3.2f, filter)) { continue; } Vector3 val3 = -((Component)player).transform.forward; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.01f) { val3 = Vector3.back; } ((Vector3)(ref val3)).Normalize(); float num = (float)random.NextDouble() * 65f - 32.5f; for (int j = 0; j < 20; j++) { float num2 = ((j < 13) ? (9f + 3f * (float)random.NextDouble()) : 6f); Vector3 val4 = Quaternion.Euler(0f, num + (float)j * 137.5f, 0f) * val3; if (NavMesh.SamplePosition(((NavMeshHit)(ref val2)).position + val4 * num2, ref val5, 3.5f, filter)) { Vector3 val6 = ((NavMeshHit)(ref val5)).position - position; if (!(((Vector3)(ref val6)).sqrMagnitude < 24f) && !(Mathf.Abs(((NavMeshHit)(ref val5)).position.y - ((NavMeshHit)(ref val2)).position.y) > 3.1f) && BuildRoute(((NavMeshHit)(ref val5)).position, ((NavMeshHit)(ref val2)).position)) { Position = ((NavMeshHit)(ref val5)).position; return true; } } } } return false; } private bool BuildRoute(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_0003: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!NavMesh.CalculatePath(from, to, filter, path) || (int)path.status != 0) { return false; } Vector3[] array = path.corners; if (array.Length == 0) { return false; } floorGoal = to; corners = array; nextCorner = 0; return true; } internal bool Tick(float now, float dt) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004d: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0187: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) if (!Alive(target)) { return false; } Vector3 position = ((Component)target).transform.position; if (now >= nextRoute) { nextRoute = now + 0.38f; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 2.9f, filter) && BuildRoute(Position, ((NavMeshHit)(ref val)).position)) { withoutRoute = 0f; } else { if (withoutRoute == 0f) { withoutRoute = now; } if (now - withoutRoute > 5.5f) { return false; } } } Vector3 val2 = position - Position; float num = Visit.ChaseSpeed(((Vector3)(ref val2)).magnitude) * Mathf.Min(dt, 0.15f); Vector3 position2 = Position; while (num > 0.0001f && nextCorner < corners.Length) { Vector3 val3 = corners[nextCorner] - Position; float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude <= num) { Position = corners[nextCorner++]; num -= magnitude; continue; } Position += val3 * (num / magnitude); break; } Vector3 val4 = ((((Vector3)(ref val2)).sqrMagnitude < 8f) ? val2 : (Position - position2)); if (val4.x * val4.x + val4.z * val4.z > 1E-05f) { Facing = Mathf.MoveTowardsAngle(Facing, Mathf.Atan2(val4.x, val4.z) * 57.29578f, 360f * dt); } Vector3 val5 = floorGoal - Position; CanScare = withoutRoute == 0f && Mathf.Abs(position.y - floorGoal.y) < 2.2f && Visit.WithinScare(val2.x, val5.y, val2.z) && ClearSight(target, floorGoal); return true; } private bool ClearSight(PlayerAvatar player, Vector3 floor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0050: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Position + Vector3.up * 1.52f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(((Component)player).transform.position.x, floor.y + 1.1f, ((Component)player).transform.position.z); RaycastHit val3 = default(RaycastHit); if (!Physics.Linecast(val, val2, ref val3, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { return true; } if (!((Object)(object)((RaycastHit)(ref val3)).transform == (Object)(object)((Component)player).transform)) { return ((RaycastHit)(ref val3)).transform.IsChildOf(((Component)player).transform); } return true; } internal void Reset() { target = null; previous = null; corners = Array.Empty<Vector3>(); CanScare = false; } } internal enum VisitStage { Hidden, Hunt, Scare } internal static class Visit { internal const float ScareSeconds = 1.72f; internal const float ScareRadius = 1.65f; internal static bool WithinScare(float dx, float dy, float dz) { if (dy > -1.6f && dy < 1.6f) { return dx * dx + dz * dz <= 2.7224998f; } return false; } internal static float ChaseSpeed(float distance) { if (!(distance < 4.5f)) { return 1.85f; } return 3.8f; } internal static bool AcceptSnapshot(int sender, int master, int level, int expectedLevel, int sent, int now, int levelEntered, int serial, int lastSerial) { int num = now - sent; if (sender == master && level == expectedLevel && serial > lastSerial && num >= -250 && num <= 2300) { return sent - levelEntered >= -100; } return false; } }