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 SlenderMan v1.0.0
plugins/SlenderMan.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.Globalization; 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 System.Text; using System.Text.RegularExpressions; 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.Modules; using REPOLib.Objects.Sdk; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Networking; 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("SlenderMan")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+33063327d9e85ce62e7789f9df91a14976834643")] [assembly: AssemblyProduct("SlenderMan")] [assembly: AssemblyTitle("SlenderMan")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SlenderMan { internal static class Dance { private static readonly Dictionary<Type, (FieldInfo active, FieldInfo ended)> fields = new Dictionary<Type, (FieldInfo, FieldInfo)>(); private static readonly List<MonoBehaviour> scratch = new List<MonoBehaviour>(); internal static bool IsDancing(Component anyPartOfHim) { if (!Object.op_Implicit((Object)(object)anyPartOfHim)) { return false; } EnemyParent componentInParent = anyPartOfHim.GetComponentInParent<EnemyParent>(true); ((Component)(Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).transform : anyPartOfHim.transform.root)).GetComponentsInChildren<MonoBehaviour>(true, scratch); foreach (MonoBehaviour item in scratch) { if (Object.op_Implicit((Object)(object)item) && !(((object)item).GetType().Name != "DanceDriver")) { Type type = ((object)item).GetType(); if (!fields.TryGetValue(type, out (FieldInfo, FieldInfo) value)) { value = (type.GetField("active", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), type.GetField("ended", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)); fields[type] = value; } bool num = value.Item1 == null || (bool)value.Item1.GetValue(item); bool flag = value.Item2 != null && (bool)value.Item2.GetValue(item); if (num && !flag && ((Behaviour)item).isActiveAndEnabled) { return true; } } } return false; } } internal class SlenderPage : MonoBehaviour { internal const string PrefabName = "Slender Page"; internal static PrefabRef Prefab; internal const float Width = 0.3f; internal const float Height = 0.45f; private const float Thickness = 0.02f; private const float Mass = 0.2f; internal const float WallGap = 0.015999999f; private static readonly string[] Bases = new string[2] { "Valuables/02 Small/Valuable Museum Car", "Valuables/02 Small/Valuable Wizard Love Potion" }; private static readonly HashSet<string> Keep = new HashSet<string> { "PhotonView", "PhotonTransformView", "PhotonRigidbodyView", "ValuableObject", "PhysGrabObject", "PhysGrabObjectImpactDetector", "RoomVolumeCheck", "PhysGrabObjectBoxCollider", "PhysGrabObjectCollider", "PhysGrabObjectMeshCollider", "NotValuableObject" }; internal int index = -1; internal bool pinned = true; internal Renderer outline; internal Material material; internal const float OutlineMargin = 0.12f; private static readonly Color OutlineColour = new Color(1f, 0.95f, 0.8f); private static Material outlineMat; private PhysGrabObject pgo; private PhotonView view; private Vector3 pinPos; private Quaternion pinRot; private Renderer[] faces; private float lostCheck; private string prompt; private float lastUse = -9f; private bool used; internal static Color OutlineColourValue => OutlineColour; internal Renderer[] Faces => faces ?? Array.Empty<Renderer>(); private static Texture2D HaloTexture() { //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //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) float num = 0.54f; float num2 = 0.69f; int num3 = 128; int num4 = Mathf.RoundToInt(128f * num2 / num); Texture2D val = new Texture2D(num3, num4, (TextureFormat)4, false) { name = "Slender Page Halo", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color32[] array = (Color32[])(object)new Color32[num3 * num4]; for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { float num5 = (((float)j + 0.5f) / (float)num3 - 0.5f) * num; float num6 = (((float)i + 0.5f) / (float)num4 - 0.5f) * num2; float num7 = Mathf.Max(0f, Mathf.Abs(num5) - 0.15f); float num8 = Mathf.Max(0f, Mathf.Abs(num6) - 0.225f); float num9 = Mathf.Clamp01(Mathf.Sqrt(num7 * num7 + num8 * num8) / 0.12f); float num10 = Mathf.Pow(1f - Mathf.SmoothStep(0f, 1f, num9), 2f); array[i * num3 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num10 * 255f)); } } val.SetPixels32(array); val.Apply(false, true); Object.DontDestroyOnLoad((Object)(object)val); return val; } internal static Material OutlineMaterial() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)outlineMat)) { return outlineMat; } Shader val = null; string[] array = new string[3] { "Sprites/Default", "UI/Default", "Unlit/Color" }; for (int i = 0; i < array.Length; i++) { val = Shader.Find(array[i]); if (Object.op_Implicit((Object)(object)val)) { break; } } outlineMat = new Material(val) { name = "Slender Page Halo", renderQueue = 3000 }; if (outlineMat.HasProperty("_Color")) { outlineMat.SetColor("_Color", OutlineColour); } outlineMat.mainTexture = (Texture)(object)HaloTexture(); Plugin.Log.LogDebug((object)("[Slender] page outline shader: " + (Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "none") + ".")); return outlineMat; } internal static void BuildAndRegister() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0422: 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_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) if (Prefab != null) { return; } GameObject val = null; string[] bases = Bases; for (int i = 0; i < bases.Length; i++) { val = Resources.Load<GameObject>(bases[i]); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<ValuableObject>()) && Object.op_Implicit((Object)(object)val.GetComponent<PhysGrabObject>()) && Object.op_Implicit((Object)(object)val.GetComponentInChildren<PhysGrabObjectCollider>(true))) { break; } val = null; } if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("No vanilla valuable to build the pages on (looked for " + string.Join(", ", Bases) + ")."); } GameObject val2 = new GameObject("SlenderMan Page Prefab"); val2.SetActive(false); ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform); ((Object)val3).name = "Slender Page"; MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val4 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val4) && !Keep.Contains(((object)val4).GetType().Name)) { Object.DestroyImmediate((Object)(object)val4); } } Behaviour[] componentsInChildren2 = val3.GetComponentsInChildren<Behaviour>(true); foreach (Behaviour val5 in componentsInChildren2) { if (val5 is AudioLowPassFilter || val5 is AudioHighPassFilter || val5 is AudioReverbFilter || val5 is AudioEchoFilter || val5 is AudioDistortionFilter || val5 is AudioChorusFilter) { Object.DestroyImmediate((Object)(object)val5); } } AudioSource[] componentsInChildren3 = val3.GetComponentsInChildren<AudioSource>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } Renderer[] componentsInChildren4 = val3.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { componentsInChildren4[i].enabled = false; } Light[] componentsInChildren5 = val3.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { ((Behaviour)componentsInChildren5[i]).enabled = false; } ValuableObject component = val3.GetComponent<ValuableObject>(); NotValuableObject val6 = val3.AddComponent<NotValuableObject>(); PhysAttribute val7 = ScriptableObject.CreateInstance<PhysAttribute>(); ((Object)val7).name = "PhysAttribute Slender Page"; val7.mass = 0.2f; Object.DontDestroyOnLoad((Object)(object)val7); val6.physAttributePreset = val7; if (Object.op_Implicit((Object)(object)component)) { val6.audioPreset = component.audioPreset; val6.durabilityPreset = component.durabilityPreset; Object.DestroyImmediate((Object)(object)component); } PhysAudio val8 = ((IEnumerable<PhysAudio>)Resources.FindObjectsOfTypeAll<PhysAudio>()).FirstOrDefault((Func<PhysAudio, bool>)((PhysAudio a) => Object.op_Implicit((Object)(object)a) && ((Object)a).name.ToLowerInvariant().Contains("paper"))) ?? ((IEnumerable<PhysAudio>)Resources.FindObjectsOfTypeAll<PhysAudio>()).FirstOrDefault((Func<PhysAudio, bool>)((PhysAudio a) => Object.op_Implicit((Object)(object)a) && ((Object)a).name.ToLowerInvariant().Contains("cloth"))); if (Object.op_Implicit((Object)(object)val8)) { val6.audioPreset = val8; } val6.hasHealth = false; PhysGrabObjectImpactDetector component2 = val3.GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)component2)) { component2.isIndestructible = true; component2.destroyDisable = true; component2.indestructibleBreakEffects = false; } PhysGrabObjectCollider[] componentsInChildren6 = val3.GetComponentsInChildren<PhysGrabObjectCollider>(true); if (componentsInChildren6.Length == 0) { throw new Exception(((Object)val).name + " has no PhysGrabObjectCollider to reuse."); } GameObject gameObject = ((Component)componentsInChildren6[0]).gameObject; PhysicsMaterial val9 = null; Collider[] componentsInChildren7 = val3.GetComponentsInChildren<Collider>(true); foreach (Collider val10 in componentsInChildren7) { if (!Object.op_Implicit((Object)(object)val9) && Object.op_Implicit((Object)(object)((Component)val10).GetComponent<PhysGrabObjectCollider>())) { val9 = val10.sharedMaterial; } if (!(val10 is BoxCollider) || !((Object)(object)((Component)val10).gameObject == (Object)(object)gameObject)) { if ((Object)(object)((Component)val10).gameObject != (Object)(object)gameObject && Object.op_Implicit((Object)(object)((Component)val10).GetComponent<PhysGrabObjectCollider>())) { Object.DestroyImmediate((Object)(object)((Component)val10).GetComponent<PhysGrabObjectCollider>()); } Object.DestroyImmediate((Object)(object)val10); } } BoxCollider val11 = gameObject.GetComponent<BoxCollider>(); if (!Object.op_Implicit((Object)(object)val11)) { val11 = gameObject.AddComponent<BoxCollider>(); } ((Collider)val11).enabled = true; ((Collider)val11).isTrigger = false; if (Object.op_Implicit((Object)(object)val9)) { ((Collider)val11).sharedMaterial = val9; } if ((Object)(object)gameObject != (Object)(object)val3) { gameObject.transform.SetParent(val3.transform, false); gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one; } val11.center = Vector3.zero; val11.size = new Vector3(0.3f, 0.45f, 0.02f); Plugin.Log.LogDebug((object)("[Slender] page grab collider: \"" + ((Object)gameObject).name + "\" tag " + gameObject.tag + ", layer " + LayerMask.LayerToName(gameObject.layer) + ", " + $"{val3.GetComponentsInChildren<Collider>(true).Length} collider(s) left, root layer {LayerMask.LayerToName(val3.layer)}.")); Transform val12 = val3.transform.Find("Center of Mass"); if (Object.op_Implicit((Object)(object)val12)) { val12.localPosition = Vector3.zero; } Face(val3, "Page Front", new Vector3(0f, 0f, -0.0105f), Quaternion.identity); Face(val3, "Page Back", new Vector3(0f, 0f, 0.0105f), Quaternion.Euler(0f, 180f, 0f)); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = "Page Outline"; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); obj.layer = val3.layer; obj.transform.SetParent(val3.transform, false); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = new Vector3(0.54f, 0.69f, 1f); MeshRenderer component3 = obj.GetComponent<MeshRenderer>(); ((Renderer)component3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component3).receiveShadows = false; ((Renderer)component3).enabled = false; val3.AddComponent<SlenderPage>(); Prefab = NetworkPrefabs.RegisterNetworkPrefab("Valuables/Slender Page", val3); if (Prefab == null) { throw new Exception("REPOLib refused to register the page."); } Plugin.Log.LogInfo((object)("Registered Slender Page (built on " + ((Object)val).name + ", sound " + (Object.op_Implicit((Object)(object)val6.audioPreset) ? ((Object)val6.audioPreset).name : "none") + ").")); } private static void Face(GameObject root, string name, Vector3 pos, Quaternion rot) { //IL_003c: 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_0063: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = name; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); obj.layer = root.layer; obj.transform.SetParent(root.transform, false); obj.transform.localPosition = pos; obj.transform.localRotation = rot; obj.transform.localScale = new Vector3(0.3f, 0.45f, 1f); ((Renderer)obj.GetComponent<MeshRenderer>()).shadowCastingMode = (ShadowCastingMode)0; } private void Start() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) pgo = ((Component)this).GetComponent<PhysGrabObject>(); view = ((Component)this).GetComponent<PhotonView>(); if (Object.op_Implicit((Object)(object)view) && view.InstantiationData != null && view.InstantiationData.Length != 0 && view.InstantiationData[0] is int num) { index = num; } if (index < 0 || index >= 8) { Plugin.Log.LogWarning((object)$"[Slender] page with no valid index ({index})."); index = Mathf.Clamp(index, 0, 7); } pinPos = ((Component)this).transform.position; pinRot = ((Component)this).transform.rotation; material = SlenderAssets.Lit((Texture)(object)SlenderAssets.Page(index), $"Slender Page {index + 1}"); faces = (from t in (IEnumerable<Transform>)(object)new Transform[2] { ((Component)this).transform.Find("Page Front"), ((Component)this).transform.Find("Page Back") } where Object.op_Implicit((Object)(object)t) select ((Component)t).GetComponent<Renderer>()).ToArray(); Renderer[] array = faces; foreach (Renderer obj in array) { obj.sharedMaterial = material; obj.enabled = true; } Transform val = ((Component)this).transform.Find("Page Outline"); outline = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<Renderer>() : null); if (Object.op_Implicit((Object)(object)outline)) { outline.sharedMaterial = OutlineMaterial(); outline.enabled = false; } Pages.Register(this); Plugin.Log.LogDebug((object)$"[Slender] page {index + 1} in the world at {pinPos:0.0} (view {(Object.op_Implicit((Object)(object)view) ? view.ViewID : 0)})."); } private void FixedUpdate() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) if (!Object.op_Implicit((Object)(object)pgo) || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (!pinned && !used) { CheckLost(); } if (!pinned) { return; } if (pgo.playerGrabbing.Count > 0 || pgo.grabbed) { pinned = false; pgo.OverrideKinematic(0f); PhysGrabber val = ((IEnumerable<PhysGrabber>)pgo.playerGrabbing).FirstOrDefault((Func<PhysGrabber, bool>)((PhysGrabber g) => Object.op_Implicit((Object)(object)g) && Object.op_Implicit((Object)(object)g.playerAvatar))); Plugin.Log.LogDebug((object)string.Format("[Slender] page {0} taken off the wall by {1}.", index + 1, Object.op_Implicit((Object)(object)val) ? val.playerAvatar.playerName : "someone")); return; } pgo.OverrideKinematic(0.25f); Rigidbody rb = pgo.rb; if (Object.op_Implicit((Object)(object)rb)) { Vector3 val2 = rb.position - pinPos; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f || Quaternion.Angle(rb.rotation, pinRot) > 0.5f) { rb.position = pinPos; rb.rotation = pinRot; ((Component)this).transform.SetPositionAndRotation(pinPos, pinRot); } } } private void CheckLost() { //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_004c: 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_0064: 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_00ee: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if ((lostCheck -= Time.fixedDeltaTime) > 0f) { return; } lostCheck = 1f; if (pgo.playerGrabbing.Count > 0) { return; } Vector3 position = ((Component)this).transform.position; string text = null; if (position.y < Pages.LowestY - 5f) { text = $"fell below the level (y {position.y:0.0}, lowest level point {Pages.LowestY:0.0})"; } else if (Pages.NearestLevelPoint(position) > 50f) { text = $"out of the map ({Pages.NearestLevelPoint(position):0} m from any level point)"; } if (text == null) { return; } if (!Pages.HostFreshSpot(out var pos, out var rot)) { Plugin.Log.LogWarning((object)$"[Slender] page {index + 1} {text}, but no fresh wall spot was found."); return; } Plugin.Log.LogDebug((object)$"[Slender] page {index + 1} {text}: pinned again at {pos:0.0}."); pinPos = pos; pinRot = rot; pinned = true; if (Object.op_Implicit((Object)(object)pgo.rb)) { pgo.rb.linearVelocity = Vector3.zero; pgo.rb.angularVelocity = Vector3.zero; pgo.rb.position = pos; pgo.rb.rotation = rot; } ((Component)this).transform.SetPositionAndRotation(pos, rot); pgo.OverrideKinematic(0.25f); } private void Update() { if (!Object.op_Implicit((Object)(object)pgo)) { return; } if (!pgo.grabbedLocal || !Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)pgo)) { prompt = null; return; } if (Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { if (prompt == null) { prompt = "Page <color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>"; } ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, prompt, false); } if (pgo.heldByLocalPlayer && Object.op_Implicit((Object)(object)PlayerController.instance) && PlayerController.instance.InputDisableTimer <= 0f && SemiFunc.InputDown((InputKey)2) && Time.time - lastUse > 0.4f) { lastUse = Time.time; Plugin.Log.LogDebug((object)$"[Slender] using page {index + 1}."); if (SemiFunc.IsMasterClientOrSingleplayer()) { HostUse(null); } else { view.RPC("UsePageRPC", (RpcTarget)2, Array.Empty<object>()); } } } [PunRPC] private void UsePageRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { HostUse(info.Sender); } } private void HostUse(Player sender) { if (used) { return; } if (sender != null && !sender.IsLocal && !pgo.playerGrabbing.Any((PhysGrabber g) => Object.op_Implicit((Object)(object)g) && Object.op_Implicit((Object)(object)g.photonView) && g.photonView.Owner == sender)) { Plugin.Log.LogDebug((object)$"[Slender] ignored a use of page {index + 1} from {sender.NickName}, who isn't holding it."); return; } used = true; pinned = false; Plugin.Log.LogDebug((object)string.Format("[Slender] page {0} collected{1}.", index + 1, (sender != null) ? (" by " + sender.NickName) : "")); PlayerAvatar collector = (PlayerAvatar)((sender == null || sender.IsLocal) ? ((object)PlayerAvatar.instance) : ((object)((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.photonView) && p.photonView.Owner == sender)))); Pages.HostTake(index, collector); pgo.DestroyPhysGrabObject(); } private void OnDestroy() { Pages.Unregister(this); if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } } } internal static class Pages { private const byte EvTaken = 173; private static object levelKey; private static bool spawned; private static readonly SlenderPage[] pages = new SlenderPage[8]; private static readonly bool[] taken = new bool[8]; private static int count; private static AudioSource music; private static int musicLayer = -1; private static bool hostChecked; private static float hostCheckTimer; private const float OutlineSightDistance = 15f; private const float OutlineFadeSeconds = 0.15f; private static readonly bool[] glowLogged = new bool[8]; private static readonly float[] glow = new float[8]; private const float WallMaxNormalY = 0.2f; private const float WallFlatTolerance = 0.02f; private const float WallRayLength = 3f; private const float StandOut = 0.6f; private const float StandSampleRadius = 1f; private const float StandMaxHorizontal = 1.2f; private static readonly Vector3 ClearHalfExtents = new Vector3(0.25f, 0.3f, 0.3f); private static object lowestKey; private static float lowestY = float.NegativeInfinity; private static readonly Collider[] overlap = (Collider[])(object)new Collider[16]; private static readonly List<Bounds> furniture = new List<Bounds>(); private const float RewardShowSeconds = 3.5f; private static int rewardShown; private static float rewardTimer; private static bool introShown; private static float introDelay = -1f; private static float lastProgress = -1f; private static bool beaconOn; private static int beaconPage = -1; private static readonly RawImage[] markers = (RawImage[])(object)new RawImage[8]; private static RectTransform markerRoot; private static MaterialPropertyBlock block; private static float musicLevel; private static float musicHold; private static float musicPeak = 1f; private static float sightTimer; private static bool seenClose; private static float stingReady; private static AudioSource sting; public static int Taken => count; public static bool AllTaken { get { if (spawned) { return count >= 8; } return false; } } private static int Pressure => Mathf.Min(count, 7); public static float MeterMultiplier { get { if (!AllTaken) { return 1f + 0.04f * (float)Pressure; } return 1f; } } internal static float LowestY { get { if (lowestKey != LevelGenerator.Instance || float.IsInfinity(lowestY)) { lowestKey = LevelGenerator.Instance; List<LevelPoint> list = SemiFunc.LevelPointsGetAll(); lowestY = ((list != null && list.Count > 0) ? list.Where((LevelPoint p) => Object.op_Implicit((Object)(object)p)).Min((LevelPoint p) => ((Component)p).transform.position.y) : float.NegativeInfinity); } return lowestY; } } public static void Init() { PhotonNetwork.NetworkingClient.EventReceived += OnEvent; } private static void Reset() { for (int i = 0; i < pages.Length; i++) { pages[i] = null; taken[i] = false; glow[i] = 0f; glowLogged[i] = false; } spawned = false; count = 0; hostChecked = false; hostCheckTimer = 0f; lastProgress = -1f; beaconOn = false; beaconPage = -1; introShown = false; introDelay = -1f; rewardTimer = 0f; RawImage[] array = markers; foreach (RawImage val in array) { if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = false; } } StopMusic(); } public static void HostEnsureSpawned() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) CheckLevel(); if (spawned || !Plugin.PagesEnabled.Value) { return; } float[] array = PickSpots(); if (array == null) { Plugin.Log.LogWarning((object)"[Slender] couldn't find spots for the pages."); return; } if (SlenderPage.Prefab == null) { Plugin.Log.LogWarning((object)"[Slender] the page prefab isn't registered; no pages this level."); return; } spawned = true; int num = 0; Vector3 val = default(Vector3); Quaternion val2 = default(Quaternion); for (int i = 0; i < 8; i++) { ((Vector3)(ref val))..ctor(array[i * 7], array[i * 7 + 1], array[i * 7 + 2]); ((Quaternion)(ref val2))..ctor(array[i * 7 + 3], array[i * 7 + 4], array[i * 7 + 5], array[i * 7 + 6]); GameObject val3 = NetworkPrefabs.SpawnNetworkPrefab(SlenderPage.Prefab, val, val2, (byte)0, new object[1] { i }); if (!Object.op_Implicit((Object)(object)val3)) { Plugin.Log.LogWarning((object)$"[Slender] page {i + 1} failed to spawn."); continue; } SlenderPage component = val3.GetComponent<SlenderPage>(); if (Object.op_Implicit((Object)(object)component)) { component.index = i; } num++; } Plugin.Log.LogDebug((object)$"[Slender] spawned {num}/{8} pages, pinned to their walls until grabbed."); } internal static void Register(SlenderPage page) { CheckLevel(); if (page.index >= 0 && page.index < pages.Length) { pages[page.index] = page; spawned = true; if (taken[page.index]) { page.pinned = false; } } } internal static void Unregister(SlenderPage page) { if (page.index >= 0 && page.index < pages.Length && (Object)(object)pages[page.index] == (Object)(object)page) { pages[page.index] = null; } } private static float[] PickSpots() { //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: 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_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) List<LevelPoint> list = (from val3 in SemiFunc.LevelPointsGetAll() where Object.op_Implicit((Object)(object)val3) && !val3.inStartRoom select val3).ToList(); if (list.Count == 0) { list = (from val3 in SemiFunc.LevelPointsGetAll() where Object.op_Implicit((Object)(object)val3) select val3).ToList(); } if (list.Count == 0) { return null; } int mask = LayerMask.GetMask(new string[1] { "Default" }); CollectFurniture(); float[] array = new float[56]; List<Vector3> list2 = new List<Vector3>(); HashSet<LevelPoint> used = new HashSet<LevelPoint>(); List<string> list3 = new List<string>(); int rejected = 0; int num = 0; int num2 = 0; while (list2.Count < 8) { LevelPoint val = null; if (list2.Count == 0) { List<LevelPoint> list4 = list.Where((LevelPoint item) => !used.Contains(item)).ToList(); if (list4.Count > 0) { val = list4[Random.Range(0, list4.Count)]; } } else { float num3 = -1f; foreach (LevelPoint p in list) { if (!used.Contains(p)) { float num4 = list2.Min((Vector3 c) => Vector3.Distance(c, ((Component)p).transform.position)) * Random.Range(0.8f, 1.2f); if (num4 > num3) { num3 = num4; val = p; } } } } if (!Object.op_Implicit((Object)(object)val)) { break; } used.Add(val); if (TryWall(val, mask, out var pos, out var rot, out var height, ref rejected)) { Write(array, list2.Count, pos, rot); list3.Add(height.ToString("0.00")); list2.Add(pos); } else { num++; } } while (list2.Count < 8) { Vector3 val2 = ((Component)list[Random.Range(0, list.Count)]).transform.position + Vector3.up * 0.03f; Quaternion rot2 = Quaternion.LookRotation(Vector3.down, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * Vector3.forward); Write(array, list2.Count, val2, rot2); list3.Add("floor"); list2.Add(val2); num2++; } Plugin.Log.LogDebug((object)(string.Format("[Slender] page heights above floor: {0}. Rejected {1} wall spots, ", string.Join(", ", list3), rejected) + $"{num} level points with no usable wall; {num2} page(s) on the floor.")); return array; } internal static float NearestLevelPoint(Vector3 pos) { //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) List<LevelPoint> list = SemiFunc.LevelPointsGetAll(); if (list == null || list.Count == 0) { return 0f; } return list.Where((LevelPoint p) => Object.op_Implicit((Object)(object)p)).Min((LevelPoint p) => Vector3.Distance(((Component)p).transform.position, pos)); } internal static bool HostFreshSpot(out Vector3 pos, out Quaternion rot) { //IL_00ac: 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) List<LevelPoint> source = (from _ in SemiFunc.LevelPointsGetAll() where Object.op_Implicit((Object)(object)_) && !_.inStartRoom orderby Random.value select _).ToList(); int mask = LayerMask.GetMask(new string[1] { "Default" }); int rejected = 0; CollectFurniture(); foreach (LevelPoint item in source.Take(20)) { if (TryWall(item, mask, out pos, out rot, out var _, ref rejected)) { return true; } } pos = default(Vector3); rot = default(Quaternion); return false; } private static void Write(float[] data, int i, Vector3 pos, Quaternion rot) { //IL_0004: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) data[i * 7] = pos.x; data[i * 7 + 1] = pos.y; data[i * 7 + 2] = pos.z; data[i * 7 + 3] = rot.x; data[i * 7 + 4] = rot.y; data[i * 7 + 5] = rot.z; data[i * 7 + 6] = rot.w; } private static void CollectFurniture() { //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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) furniture.Clear(); MeshRenderer[] array = Object.FindObjectsOfType<MeshRenderer>(); foreach (MeshRenderer val in array) { if (!Object.op_Implicit((Object)(object)val) || !((Renderer)val).enabled || !((Component)val).gameObject.activeInHierarchy) { continue; } Bounds bounds = ((Renderer)val).bounds; if (((Bounds)(ref bounds)).size.x > 4f || ((Bounds)(ref bounds)).size.y > 4f || ((Bounds)(ref bounds)).size.z > 4f) { continue; } Vector3 size = ((Bounds)(ref bounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 0.0004f)) { Rigidbody componentInParent = ((Component)val).GetComponentInParent<Rigidbody>(); if ((!Object.op_Implicit((Object)(object)componentInParent) || componentInParent.isKinematic) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<EnemyParent>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<SlenderPage>())) { furniture.Add(bounds); } } } Plugin.Log.LogDebug((object)$"[Slender] page spots: checking against {furniture.Count} furniture-sized meshes."); } private static bool OverlapsFurniture(Vector3 centre, Vector3 half, Quaternion rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_006a: Unknown result type (might be due to invalid IL or missing references) Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(centre, Vector3.zero); for (int i = 0; i < 8; i++) { ((Bounds)(ref val)).Encapsulate(centre + rot * Vector3.Scale(half, new Vector3((float)((i & 1) * 2 - 1), (float)(((i >> 1) & 1) * 2 - 1), (float)(((i >> 2) & 1) * 2 - 1)))); } foreach (Bounds item in furniture) { Bounds current = item; if (((Bounds)(ref current)).Intersects(val)) { return true; } } return false; } private static bool Blocked(Vector3 centre, Vector3 halfExtents, Quaternion rot) { //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_0007: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapBoxNonAlloc(centre, halfExtents, overlap, rot, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = overlap[i]; if (Object.op_Implicit((Object)(object)val)) { Rigidbody attachedRigidbody = val.attachedRigidbody; if ((!Object.op_Implicit((Object)(object)attachedRigidbody) || attachedRigidbody.isKinematic) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<EnemyParent>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<SlenderPage>())) { return true; } } } return false; } private static bool TryWall(LevelPoint lp, int mask, out Vector3 pos, out Quaternion rot, out float height, ref int rejected) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fa: 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_0109: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: 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) Vector3 position = ((Component)lp).transform.position; RaycastHit val3 = default(RaycastHit); RaycastHit val5 = default(RaycastHit); NavMeshHit val7 = default(NavMeshHit); for (int i = 0; i < 4; i++) { height = Random.Range(1.5f, 1.75f); Vector3 val = position + Vector3.up * height; float num = Random.Range(0f, 360f); for (int j = 0; j < 8; j++) { Vector3 val2 = Quaternion.Euler(0f, num + (float)j * 45f + Random.Range(-10f, 10f), 0f) * Vector3.forward; if (!Physics.Raycast(val, val2, ref val3, 3f, mask, (QueryTriggerInteraction)1)) { continue; } Vector3 normal = ((RaycastHit)(ref val3)).normal; if (Mathf.Abs(normal.y) >= 0.2f) { rejected++; continue; } float num2 = Vector3.Dot(normal, ((RaycastHit)(ref val3)).point); Vector3 val4 = Vector3.Cross(Vector3.up, normal); Vector3 normalized = ((Vector3)(ref val4)).normalized; val4 = Vector3.Cross(normal, normalized); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; bool flag = true; for (int k = 0; k < 4 && flag; k++) { flag = Physics.Raycast(val + normalized * (((k & 1) == 0) ? (-0.2f) : 0.2f) + normalized2 * (((k & 2) == 0) ? (-0.25f) : 0.25f), val2, ref val5, 3.5f, mask, (QueryTriggerInteraction)1) && Mathf.Abs(Vector3.Dot(normal, ((RaycastHit)(ref val5)).point) - num2) <= 0.02f; } if (!flag) { rejected++; continue; } if (Blocked(((RaycastHit)(ref val3)).point + normal * 0.35f, ClearHalfExtents, Quaternion.LookRotation(-normal, Vector3.up))) { rejected++; continue; } Quaternion rot2 = Quaternion.LookRotation(-normal, Vector3.up); if (Blocked(((RaycastHit)(ref val3)).point + normal * 0.045f, new Vector3(0.18f, 0.255f, 0.035f), rot2)) { rejected++; continue; } if (OverlapsFurniture(((RaycastHit)(ref val3)).point + normal * 0.085f, new Vector3(0.18f, 0.255f, 0.065f), rot2)) { rejected++; continue; } Vector3 val6 = ((RaycastHit)(ref val3)).point + normal * 0.6f; val6.y = position.y; if (!NavMesh.SamplePosition(val6, ref val7, 1f, -1)) { rejected++; continue; } Vector3 val8 = ((NavMeshHit)(ref val7)).position - ((RaycastHit)(ref val3)).point; val8.y = 0f; if (((Vector3)(ref val8)).magnitude > 1.2f) { rejected++; continue; } pos = ((RaycastHit)(ref val3)).point + normal * 0.015999999f; rot = Quaternion.LookRotation(-normal, Vector3.up) * Quaternion.Euler(0f, 0f, Random.Range(-8f, 8f)); height = pos.y - position.y; return true; } } pos = default(Vector3); rot = default(Quaternion); height = 0f; return false; } public static void Tick() { CheckLevel(); HostCheckLevelStart(); Stalker.HostTick(); CheckSighting(); TickMusic(); if (spawned) { UpdateIntro(); UpdateRewardUI(); UpdateBeacon(); UpdateGlow(Camera.main, LayerMask.GetMask(new string[1] { "Default" })); } } private static void UpdateRewardUI() { if (rewardTimer <= 0f) { return; } rewardTimer -= Time.deltaTime; try { if (Object.op_Implicit((Object)(object)ShopCostUI.instance)) { ShopCostUI.instance.animatedValue = Mathf.CeilToInt(Mathf.Lerp(0f, (float)rewardShown, Mathf.Clamp01((3.5f - rewardTimer) / 1f))); ((SemiUI)ShopCostUI.instance).Show(); } if (Object.op_Implicit((Object)(object)CurrencyUI.instance)) { ((SemiUI)CurrencyUI.instance).Show(); } if (Object.op_Implicit((Object)(object)HaulUI.instance)) { ((SemiUI)HaulUI.instance).Hide(); } } catch (Exception ex) { rewardTimer = 0f; Plugin.Log.LogWarning((object)("[Slender] reward display failed: " + ex.Message)); } } private static void UpdateIntro() { if (introShown || count >= 8) { return; } RoundDirector instance = RoundDirector.instance; bool flag = Object.op_Implicit((Object)(object)instance) && (instance.extractionPointActive || instance.extractionPointsCompleted > 0); if (SlenderTag.All.Any((SlenderTag t) => Object.op_Implicit((Object)(object)t) && Object.op_Implicit((Object)(object)t.tm) && Object.op_Implicit((Object)(object)t.tm.enemy) && Object.op_Implicit((Object)(object)t.tm.enemy.EnemyParent) && t.tm.enemy.EnemyParent.Spawned)) { ShowIntro("he showed up"); } else if (flag) { if (introDelay < 0f) { introDelay = 1.5f; } else if ((introDelay -= Time.deltaTime) <= 0f) { ShowIntro("first extraction started"); } } } private static void ShowIntro(string why) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) introShown = true; Plugin.Log.LogDebug((object)$"[Slender] \"collect all {8} pages\" shown ({why})."); Message($"COLLECT ALL {8} PAGES", Color.white, new Color(0.6f, 0.6f, 0.6f), 3f); } private static void UpdateBeacon() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) int num = -1; if (count == 7) { for (int i = 0; i < pages.Length; i++) { if (!taken[i]) { num = i; break; } } } bool flag = num >= 0 && Object.op_Implicit((Object)(object)pages[num]) && Object.op_Implicit((Object)(object)pages[num].outline) && lastProgress >= 0f && Time.time - lastProgress >= 180f; if (flag != beaconOn) { beaconOn = flag; beaconPage = (flag ? num : (-1)); if (flag) { Plugin.Log.LogDebug((object)$"[Slender] no page found for {180f:0} s: page {num + 1}'s highlight now shows through walls."); Message("THE LAST PAGE IS GLOWING", Color.white, new Color(0.8f, 0.75f, 0.5f), 3f); } } } internal static void Toast(string text) { //IL_0001: 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) Message(text, Color.white, new Color(0.6f, 0.6f, 0.6f), 2f); } private static void Marker(int i, bool show, Vector3 vp, float dist, Camera cam) { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //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_0108: 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) RawImage val = markers[i]; if (!show) { if (Object.op_Implicit((Object)(object)val)) { ((Behaviour)val).enabled = false; } return; } Vector2 val4 = default(Vector2); if (!Object.op_Implicit((Object)(object)val)) { if (!Object.op_Implicit((Object)(object)markerRoot)) { Canvas val2 = null; TumbleWingsUI instance = TumbleWingsUI.instance; if (Object.op_Implicit((Object)(object)instance)) { Canvas componentInParent = ((Component)instance).GetComponentInParent<Canvas>(); if (Object.op_Implicit((Object)(object)componentInParent)) { val2 = componentInParent.rootCanvas; } } GameObject val3; if (Object.op_Implicit((Object)(object)val2)) { val3 = new GameObject("Slender Page Markers", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(((Component)val2).transform, false); val3.transform.SetAsFirstSibling(); } else { val3 = new GameObject("Slender Page Markers"); Canvas obj = val3.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = -9; } markerRoot = val3.GetComponent<RectTransform>(); markerRoot.anchorMin = Vector2.zero; markerRoot.anchorMax = Vector2.one; val4 = (markerRoot.offsetMin = (markerRoot.offsetMax = Vector2.zero)); } val = new GameObject($"Page {i + 1} Marker", new Type[1] { typeof(RectTransform) }).AddComponent<RawImage>(); ((Component)val).transform.SetParent((Transform)(object)markerRoot, false); val.texture = SlenderPage.OutlineMaterial().mainTexture; ((Graphic)val).raycastTarget = false; markers[i] = val; } RectTransform rectTransform = ((Graphic)val).rectTransform; ((Vector2)(ref val4))..ctor(vp.x, vp.y); rectTransform.anchorMax = val4; rectTransform.anchorMin = val4; float num = 0.54f; float num2 = 0.69f; Rect rect = markerRoot.rect; float num3; if (!(((Rect)(ref rect)).height > 1f)) { num3 = Screen.height; } else { rect = markerRoot.rect; num3 = ((Rect)(ref rect)).height; } float num4 = num3; float num5 = num2 / (2f * Mathf.Max(0.1f, dist) * Mathf.Tan(cam.fieldOfView * 0.5f * (MathF.PI / 180f))); float num6 = Mathf.Max(0.04f, num5) * num4; rectTransform.sizeDelta = new Vector2(num6 * num / num2, num6); Color outlineColourValue = SlenderPage.OutlineColourValue; outlineColourValue.a = 0.9f * (0.8f + 0.2f * Mathf.Sin(Time.time * MathF.PI + (float)i)); ((Graphic)val).color = outlineColourValue; ((Behaviour)val).enabled = true; } private static void HostCheckLevelStart() { if (spawned || hostChecked || !Plugin.PagesEnabled.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LevelGenerator instance = LevelGenerator.Instance; EnemyDirector instance2 = EnemyDirector.instance; if (Object.op_Implicit((Object)(object)instance) && instance.Generated && Object.op_Implicit((Object)(object)instance2) && instance2.enemiesSpawned != null && !((hostCheckTimer -= Time.deltaTime) > 0f)) { hostCheckTimer = 1f; hostChecked = true; if (instance2.enemiesSpawned.Any((EnemyParent ep) => Object.op_Implicit((Object)(object)ep) && SlenderTag.Is(((Component)ep).GetComponentInChildren<EnemyThinMan>(true)))) { Plugin.Log.LogDebug((object)"[Slender] level generated with a Slender Man: laying out pages."); HostEnsureSpawned(); } } } private static void UpdateGlow(Camera cam, int mask) { //IL_0015: 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_001a: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Object.op_Implicit((Object)(object)cam) ? ((Component)cam).transform.position : Vector3.zero); for (int i = 0; i < pages.Length; i++) { SlenderPage slenderPage = pages[i]; if (!Object.op_Implicit((Object)(object)slenderPage) || !Object.op_Implicit((Object)(object)slenderPage.outline)) { if (Object.op_Implicit((Object)(object)markers[i])) { ((Behaviour)markers[i]).enabled = false; } continue; } bool flag = false; bool flag2 = !taken[i] && (i == beaconPage || Plugin.HighlightAllPages); bool flag3 = false; Vector3 val2 = default(Vector3); float dist = 0f; if (Object.op_Implicit((Object)(object)cam) && !taken[i]) { Vector3 position = ((Component)slenderPage).transform.position; Vector3 val3 = position - val; float magnitude = ((Vector3)(ref val3)).magnitude; val2 = cam.WorldToViewportPoint(position); dist = magnitude; flag3 = magnitude > 0.01f && val2.z > 0f && val2.x > 0f && val2.x < 1f && val2.y > 0f && val2.y < 1f; flag = flag3 && magnitude <= 15f && !Physics.Linecast(val, position - val3 / magnitude * 0.05f, mask, (QueryTriggerInteraction)1); } Marker(i, flag2 && flag3 && !flag, val2, dist, cam); float num = Mathf.MoveTowards(glow[i], flag ? 1f : 0f, Time.deltaTime / 0.15f); if (num == glow[i] && num == 0f && !slenderPage.outline.enabled) { continue; } glow[i] = num; if (flag && !glowLogged[i]) { glowLogged[i] = true; Plugin.Log.LogDebug((object)$"[Slender] page {i + 1} outlined (in view, {Vector3.Distance(val, ((Component)slenderPage).transform.position):0.0} m)."); } slenderPage.outline.enabled = num > 0.001f; if (block == null) { block = new MaterialPropertyBlock(); } if (slenderPage.outline.enabled) { float num2 = 0.9f + 0.1f * Mathf.Sin(Time.time * MathF.PI + (float)i); Color outlineColourValue = SlenderPage.OutlineColourValue; outlineColourValue.a = 0.85f * num * num2; block.Clear(); block.SetColor("_Color", outlineColourValue); slenderPage.outline.SetPropertyBlock(block); } if (!Object.op_Implicit((Object)(object)slenderPage.material)) { continue; } Color val4 = Color.white * (1f + 0.18f * num); val4.a = 1f; Renderer[] faces = slenderPage.Faces; foreach (Renderer val5 in faces) { if (!Object.op_Implicit((Object)(object)val5)) { continue; } block.Clear(); if (num > 0.001f) { if (slenderPage.material.HasProperty("_Color")) { block.SetColor("_Color", val4); } if (slenderPage.material.HasProperty("_BaseColor")) { block.SetColor("_BaseColor", val4); } } val5.SetPropertyBlock(block); } } } internal static void HostTake(int i, PlayerAvatar collector = null) { //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown if (i < 0 || i >= taken.Length || taken[i]) { return; } int num = count + 1; int num2 = 0; if (num >= 8) { float num3 = (Object.op_Implicit((Object)(object)RoundDirector.instance) ? ((float)RoundDirector.instance.haulGoalMax) : 0f); num2 = Mathf.CeilToInt(num3 * (float)Plugin.RewardPercent.Value / 100f / 1000f); num2 = Mathf.Max(num2, Plugin.MinReward.Value); if (num2 > 0) { SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + num2); } Plugin.Log.LogInfo((object)$"[Slender] all pages found: paid ${num2}K ({Plugin.RewardPercent.Value}% of ${num3:0} level loot, at least ${Plugin.MinReward.Value}K)."); } int num4 = ((Object.op_Implicit((Object)(object)collector) && Object.op_Implicit((Object)(object)collector.photonView) && collector.photonView.Owner != null) ? collector.photonView.Owner.ActorNumber : (-1)); ApplyTaken(i, num, num2, (Object)(object)collector == (Object)null || (Object)(object)collector == (Object)(object)PlayerAvatar.instance); if (SemiFunc.IsMultiplayer()) { PhotonNetwork.RaiseEvent((byte)173, (object)new object[4] { i, num, num2, num4 }, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } if (num >= 8) { SendAllAway(); } else if (Object.op_Implicit((Object)(object)collector)) { Patches.HostHuntAfterPage(collector); } } private static void SendAllAway() { foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { EnemyThinMan val = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponentInChildren<EnemyThinMan>(true) : null); if (SlenderTag.Is(val)) { if (item.Spawned && ((Behaviour)val).isActiveAndEnabled) { val.UpdateState((State)6); } else { Stalker.SetAllPagesAway(item); } } } } private static void ApplyTaken(int i, int newCount, int reward, bool collectedByMe) { //IL_00f6: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (i >= 0 && i < taken.Length) { taken[i] = true; if (Object.op_Implicit((Object)(object)pages[i])) { pages[i].pinned = false; } } count = Mathf.Max(count, newCount); lastProgress = Time.time; Plugin.Log.LogDebug((object)$"[Slender] page {i + 1} taken: {count}/{8}."); if (count >= 8) { Message((reward > 0) ? $"{8}/{8} PAGES +{SemiFunc.DollarGetString(reward)}K" : $"{8}/{8} PAGES", Color.white, new Color(0.8f, 0.1f, 0.1f), 4f); } else { Message($"PAGES {count}/{8}", Color.white, new Color(0.6f, 0.6f, 0.6f), 3f); } if (count >= 8) { StopMusic(); } if (count >= 8 && reward > 0) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + reward); } rewardShown = reward; rewardTimer = 3.5f; } if (collectedByMe) { StaticOverlay.PageJolt(newCount); } } private static void Message(string text, Color main, Color flash, float time) { //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) SemiFunc.UIFocusText(text, main, flash, time); MissionUI instance = MissionUI.instance; if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.Text)) { ((TMP_Text)instance.Text).text = text; } } private static void TriggerMusic(bool sighting) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown if (!Plugin.PageMusic.Value) { return; } if (count >= 8) { StopMusic(); return; } int num = ((count > 0) ? Mathf.Min(3, (count - 1) / 2) : ((!sighting) ? (-1) : 0)); if (num >= 0 && Object.op_Implicit((Object)(object)SlenderAssets.Music[num])) { if (!Object.op_Implicit((Object)(object)music)) { GameObject val = new GameObject("Slender Page Music"); Object.DontDestroyOnLoad((Object)val); music = val.AddComponent<AudioSource>(); music.loop = true; music.spatialBlend = 0f; music.playOnAwake = false; music.volume = 0f; } music.outputAudioMixerGroup = SlenderAssets.Mixer; musicPeak = ((count <= 0) ? 0.5f : 1f); bool num2 = musicHold <= 0f; musicHold = 20f; if (num != musicLayer || !music.isPlaying) { musicLayer = num; music.Stop(); music.clip = SlenderAssets.Music[num]; music.Play(); } if (num2) { Plugin.Log.LogDebug((object)string.Format("[Slender] drone swells: layer {0}, {1}.", num + 1, sighting ? "saw him" : "page collected")); } } } private static void StopMusic() { musicHold = 0f; musicLevel = 0f; musicLayer = -1; if (Object.op_Implicit((Object)(object)music)) { music.Stop(); music.volume = 0f; } } private static void TickMusic() { if (!Object.op_Implicit((Object)(object)music)) { return; } if (!Plugin.PageMusic.Value) { if (music.isPlaying) { StopMusic(); } return; } if (musicHold > 0f) { musicHold -= Time.deltaTime; musicLevel = Mathf.MoveTowards(musicLevel, 1f, Time.deltaTime / 1.5f); if (musicHold <= 0f) { Plugin.Log.LogDebug((object)"[Slender] drone fading out."); } } else { musicLevel = Mathf.MoveTowards(musicLevel, 0f, Time.deltaTime / 6f); } music.volume = 0.35f * musicPeak * musicLevel; if (musicLevel <= 0f && musicHold <= 0f && music.isPlaying) { music.Stop(); musicLayer = -1; } } private static void CheckSighting() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00ff: Unknown result type (might be due to invalid IL or missing references) if ((sightTimer -= Time.deltaTime) > 0f) { return; } sightTimer = 0.2f; PlayerAvatar instance = PlayerAvatar.instance; if (!Object.op_Implicit((Object)(object)instance) || instance.isDisabled) { return; } Vector3 val = (Object.op_Implicit((Object)(object)Camera.main) ? ((Component)Camera.main).transform.position : ((Component)instance).transform.position); float num = float.MaxValue; foreach (SlenderTag item in SlenderTag.All) { if (Object.op_Implicit((Object)(object)item) && !item.dancing) { EnemyThinMan tm = item.tm; Enemy val2 = (Object.op_Implicit((Object)(object)tm) ? tm.enemy : null); if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.OnScreen) && val2.OnScreen.OnScreenLocal && (!Object.op_Implicit((Object)(object)val2.EnemyParent) || val2.EnemyParent.Spawned)) { num = Mathf.Min(num, Vector3.Distance(val, ((Component)tm).transform.position)); } } } if (num <= 20f) { TriggerMusic(sighting: true); } bool num2 = num <= 10f; if (num2 && !seenClose && Time.time >= stingReady) { PlaySting(num); } seenClose = num2; } private static void PlaySting(float distance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown stingReady = Time.time + 30f; StaticOverlay.Flash($"first sight of him {distance:0} m away"); if (!Object.op_Implicit((Object)(object)SlenderAssets.Sting)) { Plugin.Log.LogDebug((object)$"[Slender] sting due ({distance:0} m) but sounds/sm_sting.ogg isn't there."); return; } if (!Object.op_Implicit((Object)(object)sting)) { GameObject val = new GameObject("Slender Sting"); Object.DontDestroyOnLoad((Object)val); sting = val.AddComponent<AudioSource>(); sting.spatialBlend = 0f; sting.playOnAwake = false; } sting.outputAudioMixerGroup = SlenderAssets.Mixer; sting.PlayOneShot(SlenderAssets.Sting, 0.8f); Plugin.Log.LogDebug((object)$"[Slender] sting: saw him {distance:0} m away."); } private static void CheckLevel() { object instance = LevelGenerator.Instance; if (instance != levelKey || ((Object)(object)LevelGenerator.Instance == (Object)null && levelKey != null)) { if (spawned || count > 0) { Plugin.Log.LogDebug((object)"[Slender] new level: pages cleared."); } levelKey = instance; Reset(); } } private static void OnEvent(EventData e) { try { bool flag = PhotonNetwork.MasterClient != null && e.Sender == PhotonNetwork.MasterClient.ActorNumber; switch (e.Code) { case 173: if (flag && e.CustomData is object[] array && array.Length >= 3) { ApplyTaken((int)array[0], (int)array[1], (int)array[2], array.Length >= 4 && (int)array[3] == PhotonNetwork.LocalPlayer.ActorNumber); } break; case 174: StaticOverlay.OnKillRequest(e.Sender); break; } } catch (Exception ex) { Plugin.Log.LogError((object)("[Slender] page event: " + ex)); } } } [HarmonyPatch] internal static class Patches { private static bool testKitLogged; private const float RetrySeconds = 1f; [HarmonyPatch(typeof(EnemyDirector), "Awake")] [HarmonyPrefix] [HarmonyPriority(800)] private static void BuildBeforeDirector(EnemyDirector __instance) { try { SlenderBuilder.BuildAndRegister(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to build Slender Man: " + ex)); } try { SlenderPage.BuildAndRegister(); } catch (Exception ex2) { Plugin.Log.LogError((object)("Failed to build the Slender pages: " + ex2)); } } [HarmonyPatch(typeof(EnemyThinMan), "OnSpawn")] [HarmonyPostfix] private static void OnSpawn(EnemyThinMan __instance) { if (SlenderTag.Is(__instance) && SemiFunc.IsMasterClientOrSingleplayer()) { Pages.HostEnsureSpawned(); if (Pages.AllTaken && Stalker.AwaitingReturn) { Stalker.AwaitingReturn = false; Plugin.Log.LogDebug((object)"[Slender] back after all pages, pressure locked at 0."); } } } [HarmonyPatch(typeof(EnemyParent), "Despawn")] [HarmonyPostfix] private static void ParentDespawn(EnemyParent __instance, bool __runOriginal) { if (__runOriginal && SemiFunc.IsMasterClientOrSingleplayer() && SlenderTag.Is(((Component)__instance).GetComponentInChildren<EnemyThinMan>(true))) { SlenderTag componentInChildren = ((Component)__instance).GetComponentInChildren<SlenderTag>(true); bool flag = Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.drivenOff; if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.drivenOff = false; } if (Pages.AllTaken && !Stalker.AllPagesAwayDone) { Stalker.SetAllPagesAway(__instance); return; } float despawnedTimer = __instance.DespawnedTimer; __instance.DespawnedTimer = Mathf.Max(1f, despawnedTimer * Stalker.AwayMultiplier); Plugin.Log.LogDebug((object)string.Format("[Slender] left{0}: away {1:0} s (vanilla {2:0} s x{3:0.00}, pressure {4}).", flag ? " (driven off)" : "", __instance.DespawnedTimer, despawnedTimer, Stalker.AwayMultiplier, Stalker.Pressure)); } } [HarmonyPatch(typeof(EnemyParent), "DespawnedTimerSet")] [HarmonyPrefix] private static bool DespawnedTimerSet(EnemyParent __instance) { if (__instance.Spawned || !SlenderTag.Is(((Component)__instance).GetComponentInChildren<EnemyThinMan>(true))) { return true; } for (int i = 1; i < 6; i++) { string text = new StackFrame(i, needFileInfo: false).GetMethod()?.DeclaringType?.Assembly.GetName().Name; if (text != null && text == "ModTestKit") { if (!testKitLogged) { testKitLogged = true; Plugin.Log.LogDebug((object)"[Slender] ignoring ModTestKit's NoSpawnDelay: he keeps his own time away."); } return false; } } return true; } [HarmonyPatch(typeof(EnemyParent), "Spawn")] [HarmonyPostfix] private static void ParentSpawn(EnemyParent __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && SlenderTag.Is(((Component)__instance).GetComponentInChildren<EnemyThinMan>(true))) { float spawnedTimer = __instance.SpawnedTimer; __instance.SpawnedTimer = spawnedTimer * Stalker.StayMultiplier; Plugin.Log.LogDebug((object)$"[Slender] arrived: stays {__instance.SpawnedTimer:0} s (vanilla {spawnedTimer:0} s x{Stalker.StayMultiplier:0.00}, pressure {Stalker.Pressure})."); } } [HarmonyPatch(typeof(EnemyThinMan), "SetRoamTimer")] [HarmonyPostfix] private static void SetRoamTimer(EnemyThinMan __instance) { if (SlenderTag.Is(__instance)) { __instance.teleportRoamTimer *= Stalker.RoamMultiplier; } } [HarmonyPatch(typeof(EnemyThinMan), "Teleport")] [HarmonyPrefix] private static bool Teleport(EnemyThinMan __instance, bool _spawn, bool _leave, ref bool __result) { if (_spawn || _leave || !SlenderTag.Is(__instance, out var tag) || !SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (tag.dancing) { __instance.teleportRoamTimer = 1f; __result = false; return false; } try { __result = Stalker.MayTeleport(__instance, tag) && Stalker.Roam(__instance); if (!__result) { __instance.teleportRoamTimer = 1f; } return false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Slender] roam teleport failed: " + ex.Message)); } return true; } private static IEnumerable<PlayerAvatar> Alive() { return Stalker.Alive(); } internal static Vector3 LookDirection(PlayerAvatar p) { //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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_007f: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)p == (Object)(object)PlayerAvatar.instance && Object.op_Implicit((Object)(object)Camera.main)) ? ((Component)Camera.main).transform.forward : ((!p.isLocal || !Object.op_Implicit((Object)(object)p.localCamera)) ? (((SemiFunc.IsMultiplayer() && !p.isLocal) ? p.clientRotation : ((Component)p).transform.rotation) * Vector3.forward) : ((Component)p.localCamera).transform.forward)); val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { return ((Vector3)(ref val)).normalized; } return ((Component)p).transform.forward; } internal static bool TryPool(EnemyThinMan tm, List<LevelPoint> pool, int mask, out LevelPoint chosen) { pool = new List<LevelPoint>(pool); for (int i = 0; i < 8; i++) { if (pool.Count <= 0) { break; } LevelPoint val = pool[Random.Range(0, pool.Count)]; pool.Remove(val); if (TeleportTo(tm, val, mask)) { chosen = val; return true; } } chosen = null; return false; } internal static void HostHuntAfterPage(PlayerAvatar collector) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00b1: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)collector) || !SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)EnemyDirector.instance)) { return; } foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { EnemyThinMan val = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponentInChildren<EnemyThinMan>(true) : null); if (!SlenderTag.Is(val)) { continue; } try { if (!item.Spawned || !((Behaviour)val).isActiveAndEnabled) { item.DespawnedTimerSet(5f, true); Plugin.Log.LogDebug((object)"[Slender] page collected while he's away: back within 5 s."); continue; } State currentState = val.currentState; if ((int)currentState != 0 && (int)currentState != 1) { Plugin.Log.LogDebug((object)$"[Slender] page collected, but he's busy ({currentState})."); continue; } if ((int)currentState == 1) { val.UpdateState((State)0); } if (Stalker.TeleportNear(val, collector, "page collected")) { val.SetRoamTimer(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[Slender] hunt after page failed: " + ex.Message)); } } } internal static bool TeleportTo(EnemyThinMan tm, LevelPoint lp, int mask) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_0096: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)lp).transform.position; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position + Vector3.up * 0.1f, Vector3.up, ref val, 3.5f, mask)) { return false; } foreach (EnemyThinMan otherEnemy in tm.otherEnemies) { if (Object.op_Implicit((Object)(object)otherEnemy) && ((Behaviour)otherEnemy).isActiveAndEnabled && Vector3.Distance(otherEnemy.rb.position, position) <= 2f) { return false; } } if (Vector3.Distance(position, tm.lastTeleportPosition) < 1f) { return false; } if (SemiFunc.EnemyPhysObjectBoundingBoxCheck(((Component)tm).transform.position, position, tm.enemy.Rigidbody.rb, false, 1.2f)) { return false; } tm.lastTeleportPosition = ((Component)tm).transform.position; tm.teleportPosition = position; tm.teleporting = true; if (SemiFunc.IsMultiplayer()) { tm.photonView.RPC("TeleportEffectRPC", (RpcTarget)0, new object[2] { tm.lastTeleportPosition, true }); } else { tm.TeleportEffectRPC(tm.lastTeleportPosition, true, default(PhotonMessageInfo)); } return true; } [HarmonyPatch(typeof(EnemyThinMan), "StateOnScreen")] [HarmonyPrefix] private static bool StateOnScreen(EnemyThinMan __instance) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!SlenderTag.Is(__instance, out var tag) || !SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (tag.dancing) { __instance.UpdateState((State)0); return false; } if (tag.stareCooldown > 0f || !Object.op_Implicit((Object)(object)__instance.enemy) || !Object.op_Implicit((Object)(object)__instance.enemy.OnScreen)) { return true; } int num = 0; foreach (PlayerAvatar item in Alive()) { if (__instance.enemy.OnScreen.GetOnScreen(item) && Vector3.Distance(((Component)item).transform.position, ((Component)__instance).transform.position) < 20f) { num++; } } if (num < 2) { return true; } tag.stareCooldown = 15f; Plugin.Log.LogDebug((object)$"[Slender] {num} players staring: driven off."); __instance.UpdateState((State)0); if (!__instance.Teleport(false, true)) { __instance.Teleport(false, false); } return false; } [HarmonyPatch(typeof(EnemyHealth), "Hurt")] [HarmonyPrefix] private static bool Hurt(EnemyHealth __instance, int _damage) { EnemyThinMan val = ((Component)__instance).GetComponentInChildren<EnemyThinMan>(true); if (!Object.op_Implicit((Object)(object)val)) { EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>(); val = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).GetComponentInChildren<EnemyThinMan>(true) : null); } if (!SlenderTag.Is(val, out var tag)) { return true; } if (SemiFunc.IsMasterClientOrSingleplayer()) { DriveOff(val, tag, $"damage ({_damage})"); } return false; } [HarmonyPatch(typeof(EnemyThinMan), "StateStand")] [HarmonyPrefix] private static bool StateStandWhileDancing(EnemyThinMan __instance) { if (SlenderTag.Is(__instance, out var tag)) { return !tag.dancing; } return true; } [HarmonyPatch(typeof(EnemyParent), "SpawnedTimerSet")] [HarmonyPrefix] private static bool SpawnedTimerSet(EnemyParent __instance, float _time) { if (_time > 0f) { return true; } EnemyThinMan componentInChildren = ((Component)__instance).GetComponentInChildren<EnemyThinMan>(true); if (SlenderTag.Is(componentInChildren, out var tag)) { if (!tag.dancing) { return !Dance.IsDancing((Component)(object)componentInChildren); } return false; } return true; } [HarmonyPatch(typeof(EnemyParent), "Despawn")] [HarmonyPrefix] private static bool ParentDespawnWhileDancing(EnemyParent __instance) { EnemyThinMan componentInChildren = ((Component)__instance).GetComponentInChildren<EnemyThinMan>(true); if (!SlenderTag.Is(componentInChildren, out var tag) || (!tag.dancing && !Dance.IsDancing((Component)(object)componentInChildren))) { return true; } __instance.SpawnedTimer = Mathf.Max(__instance.SpawnedTimer, 1f); return false; } internal static void DriveOff(EnemyThinMan tm, SlenderTag tag, string why, bool afterDance = false) { if (!tag.drivenOff && Object.op_Implicit((Object)(object)tm.enemy) && Object.op_Implicit((Object)(object)tm.enemy.EnemyParent) && tm.enemy.EnemyParent.Spawned && (afterDance || (!tag.dancing && !Dance.IsDancing((Component)(object)tm)))) { tag.drivenOff = true; Plugin.Log.LogDebug((object)("[Slender] driven off by " + why + ".")); tm.enemy.EnemyParent.Despawn(); } } [HarmonyPatch(typeof(EnemyThinMan), "TentacleLogic")] [HarmonyPostfix] private static void TentacleLogic(EnemyThinMan __instance) { if (__instance.tentacleLerp > 0.9f && SlenderTag.Is(__instance)) { __instance.tentacleLerp = 0.9f; } } [HarmonyPatch(typeof(EnemyThinMan), "StateDamage")] [HarmonyPrefix] private static void StateDamage(EnemyThinMan __instance) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!__instance.stateImpulse || !SlenderTag.Is(__instance)) { return; } PlayerAvatar playerTarget = __instance.playerTarget; if (Object.op_Implicit((Object)(object)playerTarget)) { if (Object.op_Implicit((Object)(object)playerTarget.playerHealth) && playerTarget.playerHealth.godMode) { __instance.playerTarget = null; return; } Plugin.Log.LogDebug((object)("[Slender] taking " + playerTarget.playerName + ".")); playerTarget.playerHealth.HurtOther(999, ((Component)playerTarget).transform.position, false, SemiFunc.EnemyGetIndex(__instance.enemy), false); __instance.stateTimer = 0.5f; __instance.stateImpulse = false; } } [HarmonyPatch(typeof(EnemyThinManAnim), "NoticeSet")] [HarmonyPostfix] private static void NoticeSet(EnemyThinManAnim __instance) { EnemyThinMan controller = __instance.controller; if (SlenderTag.Is(controller) && Object.op_Implicit((Object)(object)controller.playerTarget) && controller.playerTarget.isLocal) { StaticOverlay.Cut(1.8f); } } [HarmonyPatch(typeof(EnemyThinMan), "TeleportEffectRPC")] [HarmonyPostfix] private static void TeleportEffect(EnemyThinMan __instance, bool intro) { if (intro && SlenderTag.Is(__instance, out var tag) && !tag.dancing) { PlayerAvatar instance = PlayerAvatar.instance; Enemy enemy = __instance.enemy; if (Object.op_Implicit((Object)(object)instance) && !instance.isDisabled && Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.OnScreen) && enemy.OnScreen.OnScreenLocal && (!Object.op_Implicit((Object)(object)enemy.EnemyParent) || enemy.EnemyParent.Spawned)) { StaticOverlay.Flash("he teleported while you watched", teleport: true); } } } internal static void HostSanityKill(PlayerAvatar target) { //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (!Object.op_Implicit((Object)(object)target) || target.isDisabled || !Object.op_Implicit((Object)(object)target.playerHealth)) { Plugin.Log.LogDebug((object)"[Slender] sanity kill ignored: no such living player."); return; } if (target.playerHealth.godMode) { Plugin.Log.LogDebug((object)("[Slender] sanity kill for " + target.playerName + " ignored: god mode.")); return; } EnemyThinMan val = null; foreach (SlenderTag item in SlenderTag.All) { if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.tm) && !item.dancing && Object.op_Implicit((Object)(object)item.tm.enemy) && (!Object.op_Implicit((Object)(object)item.tm.enemy.EnemyParent) || item.tm.enemy.EnemyParent.Spawned)) { val = item.tm; break; } } if (!Object.op_Implicit((Object)(object)val)) { Plugin.Log.LogDebug((object)("[Slender] sanity kill for " + target.playerName + " ignored: he isn't in the level.")); return; } Plugin.Log.LogDebug((object)("[Slender] " + target.playerName + "'s sanity ran out: taking them.")); target.playerHealth.HurtOther(999, ((Component)target).transform.position, false, SemiFunc.EnemyGetIndex(val.enemy), false); } } [BepInPlugin("bigbootyteam.slenderman", "SlenderMan", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "bigbootyteam.slenderman"; public const string Name = "SlenderMan"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static string Folder; internal static ConfigEntry<int> Difficulty; internal static ConfigEntry<float> Rarity; internal static ConfigEntry<bool> PagesEnabled; internal static ConfigEntry<int> RewardPercent; internal static ConfigEntry<int> MinReward; internal static ConfigEntry<bool> PageMusic; internal static bool HighlightAllPages; internal const float Height = 2.4f; internal const int PageCount = 8; internal const int KillDamage = 999; internal const int StareCount = 2; internal const float StareCooldown = 15f; internal const int MaxPressure = 7; internal const float PressureSeconds = 120f; internal const float NearMin = 6f; internal const float NearMax = 16f; internal const int LatePage = 6; internal const float LongStare = 22f; internal const float LongStareRelocateChance = 0.5f; internal const float ViewHalfAngle = 60f; internal const float StingDistance = 10f; internal const float StingCooldown = 30f; internal const float RestSightDistance = 25f; internal const float AllPagesAwayMax = 300f; internal const float AllPagesAwayPerTwoMinutes = 30f; internal const float AllPagesAwayMin = 120f; internal const float HitboxRadius = 0.45f; internal const float BeaconDelay = 180f; internal const float MeterCap = 0.9f; internal const float MeterSlow = 0.35f; internal const float SanityDrain = 50f; internal const float SanityHalfDistance = 10f; internal const float SanityRecover = 4.32f; internal const float StaticMaxAlpha = 0.4f; internal const float FlashSeconds = 0.06f; internal const float SanityRecoverDelay = 1.5f; internal const float ShockSeconds = 5f; internal const float ShockAlpha = 0.35f; internal const float ExposureFree = 3f; internal const float ExposureFull = 10f; internal const float RecoverMaxMultiplier = 3f; internal const float ExposurePerSpike = 2f; internal const float TeleportFlashCooldown = 10f; internal const float SpikeMinGap = 3f; internal const float SanityCloseRange = 5f; internal const float SanityCloseMultiplier = 3f; internal const float SanitySpike = 25f; internal const float SanitySpikeRecoverPause = 6f; internal const float MeterPerPage = 0.04f; internal const float AmbienceHold = 20f; internal const float AmbienceFadeIn = 1.5f; internal const float AmbienceFadeOut = 6f; internal const float AmbienceVolume = 0.35f; internal const float AmbienceNoPageVolume = 0.5f; internal const float AmbienceSightDistance = 20f; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Difficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "DifficultyTier", 2, new ConfigDescription("Which enemy tier he spawns in (1 = weakest, 3 = strongest).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>())); Rarity = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "Rarity", 100f, new ConfigDescription("How likely he is to be picked in his tier (most vanilla enemies use 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); PagesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Pages", "Pages", true, "Spread 8 pages around levels where he shows up."); RewardPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Pages", "RewardPercent", 10, new ConfigDescription("Collecting all 8 pages pays this percent of the level's starting loot value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100),