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 Him v1.2.2
REPO.Him.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.AI; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPO.Him { internal static class CustomAudioLoader { internal static AudioClip? ScreamClip { get; private set; } internal static IEnumerator LoadScreamAudio(string baseName) { (string, AudioType)[] array = new(string, AudioType)[3] { (".ogg", (AudioType)14), (".wav", (AudioType)20), (".mp3", (AudioType)13) }; for (int i = 0; i < array.Length; i++) { (string, AudioType) tuple = array[i]; string item = tuple.Item1; AudioType item2 = tuple.Item2; string path = Resolve(baseName + item); if (!File.Exists(path)) { continue; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip("file://" + path, item2); try { yield return request.SendWebRequest(); if ((int)request.result == 1) { ScreamClip = DownloadHandlerAudioClip.GetContent(request); } else { HimPlugin.Log.Warning("[Him] Could not load " + Path.GetFileName(path) + ": " + request.error); } break; } finally { ((IDisposable)request)?.Dispose(); } } } private static string Resolve(string fileName) { string text = Path.Combine(Paths.PluginPath, fileName); if (File.Exists(text)) { return text; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (directoryName == null) { return text; } return Path.Combine(directoryName, fileName); } } internal sealed class DoorBreacher { internal enum DebugAction { Auto, Throw, Pry, Rip } private sealed class Door { internal readonly struct Protection : IDisposable { private readonly HingeJoint? _joint; private readonly float _force; private readonly float _torque; private readonly bool _useMotor; private readonly JointMotor _motor; internal Protection(Door door) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) _joint = door.Joint; if ((Object)(object)_joint == (Object)null) { _force = (_torque = 0f); _useMotor = false; _motor = default(JointMotor); return; } _force = ((Joint)_joint).breakForce; _torque = ((Joint)_joint).breakTorque; _useMotor = _joint.useMotor; _motor = _joint.motor; ((Joint)_joint).breakForce = float.PositiveInfinity; ((Joint)_joint).breakTorque = float.PositiveInfinity; } public void Dispose() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_joint == (Object)null) && (((Joint)_joint).breakForce != 0f || ((Joint)_joint).breakTorque != 0f)) { ((Joint)_joint).breakForce = _force; ((Joint)_joint).breakTorque = _torque; _joint.motor = _motor; _joint.useMotor = _useMotor; } } } internal readonly PhysGrabHinge Hinge; internal readonly PhysGrabObject Leaf; internal readonly Rigidbody Body; private readonly float _startAngle; internal HingeJoint? Joint { get { if (!((Object)(object)Hinge != (Object)null)) { return null; } return Hinge.joint; } } internal bool Alive { get { if ((Object)(object)Hinge != (Object)null && !Hinge.broken && !Hinge.dead) { return (Object)(object)Joint != (Object)null; } return false; } } internal string Name { get { if (!((Object)(object)Hinge != (Object)null)) { return "<gone>"; } return ((Object)Hinge).name; } } internal bool HeldByPlayer { get { if ((Object)(object)Leaf != (Object)null) { return Leaf.playerGrabbing.Count > 0; } return false; } } internal float OpenedBy { get { if (!((Object)(object)Joint != (Object)null)) { return 0f; } return Mathf.Abs(Joint.angle - _startAngle); } } internal Vector3 Axis { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) Vector3 val = ((Component)Body).transform.TransformDirection(((Joint)Joint).axis); return ((Vector3)(ref val)).normalized; } } internal Vector3 Anchor => ((Component)Body).transform.TransformPoint(((Joint)Joint).anchor); private Vector3 Lever { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_004f: 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) Vector3 val = Body.worldCenterOfMass - Anchor; val -= Vector3.Project(val, Axis); if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { return val; } return ((Component)Body).transform.right * 0.4f; } } internal Vector3 Normal { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) Vector3 val = Vector3.Cross(Axis, Lever); return ((Vector3)(ref val)).normalized; } } private Door(PhysGrabHinge hinge, PhysGrabObject leaf, Rigidbody body) { Hinge = hinge; Leaf = leaf; Body = body; _startAngle = (((Object)(object)hinge.joint != (Object)null) ? hinge.joint.angle : 0f); } internal static Door? From(PhysGrabHinge hinge) { if ((Object)(object)hinge == (Object)null || (Object)(object)hinge.joint == (Object)null) { return null; } PhysGrabObject physGrabObject = hinge.physGrabObject; if ((Object)(object)physGrabObject == (Object)null || (Object)(object)physGrabObject.rb == (Object)null) { return null; } return new Door(hinge, physGrabObject, physGrabObject.rb); } internal float Side(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return Vector3.Dot(point - Anchor, Normal); } internal Vector3 ClosestPointOnLeaf(Vector3 point) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) Vector3 val = Body.worldCenterOfMass; Vector3 val2 = val - point; float num = ((Vector3)(ref val2)).sqrMagnitude; Collider[] componentsInChildren = ((Component)Body).GetComponentsInChildren<Collider>(); foreach (Collider val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && !val3.isTrigger) { Bounds bounds = val3.bounds; Vector3 val4 = ((Bounds)(ref bounds)).ClosestPoint(point); val2 = val4 - point; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val4; } } } return val; } internal float MovingTowards(float side) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Body == (Object)null) { return 0f; } return Vector3.Dot(Body.GetPointVelocity(Anchor + Lever), Normal * Mathf.Sign(side)); } internal float MotorSign(float towards) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) HingeJoint joint = Joint; if (joint.useLimits) { JointLimits limits = joint.limits; float num = ((JointLimits)(ref limits)).max - joint.angle; float angle = joint.angle; limits = joint.limits; float num2 = angle - ((JointLimits)(ref limits)).min; if (num > 5f && num2 <= 5f) { return 1f; } if (num2 > 5f && num <= 5f) { return -1f; } } if (!(Vector3.Dot(Vector3.Cross(Axis, Lever), Normal * Mathf.Sign(towards)) >= 0f)) { return -1f; } return 1f; } internal void Drive(float degPerSecond, float accelTime) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) HingeJoint joint = Joint; if (!((Object)(object)joint == (Object)null) && !((Object)(object)Body == (Object)null)) { float num = InertiaAboutHinge(); float num2 = Mathf.Abs(degPerSecond) * ((float)Math.PI / 180f) / Mathf.Max(accelTime, 0.01f); float force = Mathf.Clamp(num * num2 * 2f, 20f, 40000f); JointMotor motor = default(JointMotor); ((JointMotor)(ref motor)).targetVelocity = degPerSecond; ((JointMotor)(ref motor)).force = force; ((JointMotor)(ref motor)).freeSpin = false; joint.motor = motor; joint.useMotor = true; Body.WakeUp(); } } internal void ReleaseMotor() { HingeJoint joint = Joint; if ((Object)(object)joint != (Object)null) { joint.useMotor = false; } } private float InertiaAboutHinge() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Vector3 axis = Axis; Vector3 val = Quaternion.Inverse(Body.rotation * Body.inertiaTensorRotation) * axis; Vector3 inertiaTensor = Body.inertiaTensor; float num = inertiaTensor.x * val.x * val.x + inertiaTensor.y * val.y * val.y + inertiaTensor.z * val.z * val.z; Vector3 val2 = Body.worldCenterOfMass - Anchor; val2 -= Vector3.Project(val2, axis); return num + Body.mass * ((Vector3)(ref val2)).sqrMagnitude; } internal void Open() { if (!((Object)(object)Hinge == (Object)null)) { if (Hinge.closed) { Hinge.OpenImpulse(); } HoldOpen(1f); } } internal void HoldOpen(float seconds) { if ((Object)(object)Hinge != (Object)null && Hinge.closeDisableTimer < seconds) { Hinge.closeDisableTimer = seconds; } } internal void KnockOffGrabbers(float noRegrabSeconds) { if ((Object)(object)Leaf == (Object)null || Leaf.playerGrabbing.Count == 0) { return; } PhysGrabber[] array = Leaf.playerGrabbing.ToArray(); foreach (PhysGrabber val in array) { if (!((Object)(object)val == (Object)null)) { val.OverrideGrabRelease(-1, noRegrabSeconds); } } } internal void Break() { HingeJoint joint = Joint; if (!((Object)(object)joint == (Object)null)) { joint.useMotor = false; ((Joint)joint).breakForce = 0f; ((Joint)joint).breakTorque = 0f; Body.WakeUp(); } } internal void BreakByHand() { if (!((Object)(object)Hinge == (Object)null)) { HingeJoint joint = Joint; if ((Object)(object)joint != (Object)null) { Object.Destroy((Object)(object)joint); } Hinge.HingeBreakImpulse(); Hinge.broken = true; } } internal Protection Protect() { return new Protection(this); } } private const float ScanInterval = 0.25f; private const float ReachAhead = 1.8f; private const float TouchRadius = 1.25f; private const float ScanRadius = 0.45f; private const float ThrowSpeedDeg = 520f; private const float ThrowPushTime = 0.2f; private const float TeaseSpeedDeg = 40f; private const float TeaseOpenDeg = 55f; private const float PrySpeedDeg = 70f; private const float PryTimeout = 2.6f; private const float OpenEnoughDeg = 75f; private const int Bangs = 3; private const float PerHingeCooldown = 2f; private readonly Enemy? _enemy; private readonly EnemyNavMeshAgent? _nav; private readonly Transform? _actor; private readonly Dictionary<PhysGrabHinge, int> _failures = new Dictionary<PhysGrabHinge, int>(); private readonly Dictionary<PhysGrabHinge, float> _cooldownUntil = new Dictionary<PhysGrabHinge, float>(); private readonly RaycastHit[] _hits = (RaycastHit[])(object)new RaycastHit[16]; private readonly Collider[] _near = (Collider[])(object)new Collider[24]; private static readonly RaycastHit[] _probe = (RaycastHit[])(object)new RaycastHit[8]; private float _scanTimer; private bool _cancelled; private bool _busy; private bool _breakingIn; internal Action<PlayerAvatar, Vector3>? HidingSpotOpened; private PlayerAvatar? _currentTarget; internal bool IsBusy => _busy; internal bool BreakingIn { get { if (_busy) { return _breakingIn; } return false; } } private Vector3 Position { get { //IL_0071: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_001c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_enemy != (Object)null)) { if (!((Object)(object)_actor != (Object)null)) { return Vector3.zero; } return _actor.position + Vector3.up * 1f; } if (!((Object)(object)_enemy.CenterTransform != (Object)null)) { return ((Component)_enemy).transform.position; } return _enemy.CenterTransform.position; } } private Transform? IgnoreRoot { get { if (!((Object)(object)_enemy != (Object)null) || !((Object)(object)_enemy.EnemyParent != (Object)null)) { return _actor; } return ((Component)_enemy.EnemyParent).transform; } } internal DoorBreacher(Enemy enemy, EnemyNavMeshAgent? nav) { _enemy = enemy; _nav = nav; } internal DoorBreacher(Transform actor) { _actor = actor; } internal void Cancel() { _cancelled = true; } internal void Tick(float dt, PlayerAvatar target) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (_cancelled || !HimConfig.CanOpenDoors.Value || IsBusy || (Object)(object)target == (Object)null) { return; } _scanTimer -= dt; if (_scanTimer > 0f) { return; } _scanTimer = 0.25f; _currentTarget = target; Vector3 position = ((Component)target).transform.position; PhysGrabHinge val = FindBlockingHinge(position); if ((Object)(object)val == (Object)null) { return; } Door door = Door.From(val); if (door != null) { _cooldownUntil[val] = Time.time + 2f; door.Leaf.EnemyInteractTimeSet(); _failures.TryGetValue(val, out var value); _breakingIn = IsHidingBehind(door, position, Position); IEnumerator routine = (_breakingIn ? ((value > 0 || door.HeldByPlayer) ? RipOff(door, "held shut or jammed", hidingSpot: true) : BreakIntoHidingSpot(door)) : ((value <= 0 && !(Random.value < HimConfig.DoorRipChance.Value)) ? Throw(door) : RipOff(door, (value > 0) ? "jammed" : "rage"))); _busy = true; if (HimRunner.Run(Guard(routine)) == null) { _busy = false; } } } private IEnumerator Guard(IEnumerator routine) { while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { HimPlugin.Log.Warning("[Him] Door routine failed: " + ex.Message); break; } if (!flag) { break; } yield return routine.Current; } _busy = false; _breakingIn = false; } private PhysGrabHinge? FindBlockingHinge(Vector3 targetPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) Vector3 position = Position; Vector3 val = PathHeading(position, targetPosition); PhysGrabHinge best = null; float bestDistance = float.MaxValue; int num = Physics.SphereCastNonAlloc(position, 0.45f, val, _hits, 1.8f, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Consider(((RaycastHit)(ref _hits[i])).collider, ((RaycastHit)(ref _hits[i])).distance, ref best, ref bestDistance); } num = Physics.OverlapSphereNonAlloc(position, 1.25f, _near, -5, (QueryTriggerInteraction)1); for (int j = 0; j < num; j++) { Collider val2 = _near[j]; if (!((Object)(object)val2 == (Object)null)) { Bounds bounds = val2.bounds; Vector3 val3 = ((Bounds)(ref bounds)).ClosestPoint(position) - position; val3.y = 0f; if (!(((Vector3)(ref val3)).sqrMagnitude > 0.0001f) || !(Vector3.Dot(((Vector3)(ref val3)).normalized, val) < 0.2f)) { Consider(val2, ((Vector3)(ref val3)).magnitude, ref best, ref bestDistance); } } } return best; } private void Consider(Collider? collider, float distance, ref PhysGrabHinge? best, ref float bestDistance) { if ((Object)(object)collider == (Object)null || collider.isTrigger) { return; } Transform ignoreRoot = IgnoreRoot; if (!((Object)(object)ignoreRoot != (Object)null) || !((Component)collider).transform.IsChildOf(ignoreRoot)) { PhysGrabHinge componentInParent = ((Component)collider).GetComponentInParent<PhysGrabHinge>(); if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.broken && !componentInParent.dead && !((Object)(object)componentInParent.joint == (Object)null) && (!_cooldownUntil.TryGetValue(componentInParent, out var value) || !(Time.time < value)) && (componentInParent.closed || !(Mathf.Abs(componentInParent.joint.angle) > 52.5f)) && distance < bestDistance) { bestDistance = distance; best = componentInParent; } } } private Vector3 PathHeading(Vector3 origin, Vector3 targetPosition) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = targetPosition; NavMeshAgent val2 = (((Object)(object)_nav != (Object)null) ? _nav.Agent : null); if ((Object)(object)val2 != (Object)null && ((Behaviour)val2).enabled && val2.hasPath) { val = val2.steeringTarget; } Vector3 val3 = val - origin; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = (((Object)(object)_enemy != (Object)null) ? ((Component)_enemy).transform.forward : (((Object)(object)_actor != (Object)null) ? _actor.forward : Vector3.forward)); val3.y = 0f; } return ((Vector3)(ref val3)).normalized; } private static bool IsHidingBehind(Door door, Vector3 playerPosition, Vector3 hisPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = playerPosition + Vector3.up * 0.9f; Vector3 val2 = door.ClosestPointOnLeaf(val) - val; if (((Vector3)(ref val2)).sqrMagnitude > 2.25f) { return false; } float num = door.Side(val); float num2 = door.Side(hisPosition); if (num * num2 >= 0f) { return false; } int num3 = 0; for (int i = 0; i < 8; i++) { float num4 = (float)i * 45f; Vector3 dir = Quaternion.Euler(0f, num4, 0f) * Vector3.forward; if (Blocked(val, dir, 1.3f)) { num3++; } } return num3 >= 7; } private static bool Blocked(Vector3 from, Vector3 dir, float reach) { //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) int num = Physics.RaycastNonAlloc(from, dir, _probe, reach, -5, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider collider = ((RaycastHit)(ref _probe[i])).collider; if (!((Object)(object)collider == (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent<PlayerAvatar>() != (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent<PlayerController>() != (Object)null)) { return true; } } return false; } private IEnumerator Throw(Door door) { using (door.Protect()) { door.Open(); float sign = door.MotorSign((door.Side(Position) > 0f) ? (-1f) : 1f); door.Drive(sign * 520f, 0.08f); float t = 0f; int checks = 0; while (t < 0.2f && door.Alive) { yield return (object)new WaitForFixedUpdate(); t += Time.fixedDeltaTime; door.HoldOpen(1.5f); int num = checks + 1; checks = num; if (num == 3 && door.MovingTowards(0f - door.Side(Position)) < 0f) { sign = 0f - sign; door.Drive(sign * 520f, 0.08f); } if (door.OpenedBy >= 75f) { break; } } door.ReleaseMotor(); door.HoldOpen(2.5f); if (door.Alive && door.OpenedBy < 15f) { MarkFailed(door); } else { Forget(door); } } } private IEnumerator BreakIntoHidingSpot(Door door) { float sign = door.MotorSign(door.Side(Position)); float t; float w; using (door.Protect()) { yield return (object)new WaitForSeconds(0.4f); if (!door.Alive) { yield break; } if (door.HeldByPlayer) { yield return RipOff(door, "held shut", hidingSpot: true); yield break; } door.Open(); door.Drive(sign * 40f, 0.4f); t = 0f; bool flipped = false; while (t < 2.2f && door.Alive) { yield return (object)new WaitForFixedUpdate(); t += Time.fixedDeltaTime; door.HoldOpen(2f); if (door.HeldByPlayer) { door.ReleaseMotor(); yield return RipOff(door, "grabbed while he opened it", hidingSpot: true); yield break; } if (!flipped && t > 0.25f && door.MovingTowards(door.Side(Position)) < 0f) { flipped = true; sign = 0f - sign; door.Drive(sign * 40f, 0.2f); } if (door.OpenedBy >= 55f) { break; } } door.Drive(0f, 0.1f); for (w = 0f; w < 0.9f; w += Time.fixedDeltaTime) { if (!door.Alive) { break; } yield return (object)new WaitForFixedUpdate(); door.HoldOpen(1f); if (door.HeldByPlayer) { door.ReleaseMotor(); yield return RipOff(door, "grabbed while he looked in", hidingSpot: true); yield break; } } if (!door.Alive) { yield break; } door.Drive((0f - sign) * 40f, 0.3f); for (t = 0f; t < 2.2f; t += Time.fixedDeltaTime) { if (!door.Alive) { break; } if (!(door.OpenedBy > 4f)) { break; } yield return (object)new WaitForFixedUpdate(); if (door.HeldByPlayer) { door.ReleaseMotor(); yield return RipOff(door, "grabbed while he closed it", hidingSpot: true); yield break; } } door.ReleaseMotor(); } t = 0f; w = Random.Range(1f, 1.6f); while (true) { if (t < w) { if (!door.Alive) { break; } if (!door.HeldByPlayer) { yield return null; t += Time.deltaTime; continue; } } if (door.Alive) { HimAudio.PlayAll(((Object)(object)door.Body != (Object)null) ? door.Body.worldCenterOfMass : Position, impact: true, 1.5f, 0.55f, 40f); yield return RipOff(door, "the reveal", hidingSpot: true); } break; } } private IEnumerator RipOff(Door door, string why, bool hidingSpot = false) { Vector3 outward = door.Normal * Mathf.Sign(door.Side(Position)); Forget(door); using (door.Protect()) { door.Open(); float num = door.MotorSign(door.Side(Position)); door.Drive(num * 400f, 0.04f); for (int s = 0; s < 6; s++) { yield return (object)new WaitForFixedUpdate(); door.HoldOpen(1f); } door.ReleaseMotor(); } if (!door.Alive) { yield break; } door.KnockOffGrabbers(2.5f); door.Break(); for (int s = 0; s < 3; s++) { if (!((Object)(object)door.Joint != (Object)null)) { break; } yield return (object)new WaitForFixedUpdate(); } if ((Object)(object)door.Joint != (Object)null) { door.Body.AddForce(Vector3.up * 0.5f, (ForceMode)2); for (int s = 0; s < 3; s++) { if (!((Object)(object)door.Joint != (Object)null)) { break; } yield return (object)new WaitForFixedUpdate(); } if ((Object)(object)door.Joint != (Object)null) { door.BreakByHand(); } } yield return (object)new WaitForFixedUpdate(); if (!((Object)(object)door.Body == (Object)null)) { Vector3 val = Position - door.Body.worldCenterOfMass; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : (-door.Normal)); Vector3 val2 = Vector3.Cross(Vector3.up, val) * ((Random.value < 0.5f) ? 1f : (-1f)); Vector3 val3 = val * 0.55f + val2 * 0.85f; Vector3 normalized = ((Vector3)(ref val3)).normalized; door.Body.AddForce(normalized * 5.5f + Vector3.up * 1.8f, (ForceMode)2); door.Body.AddTorque(Random.onUnitSphere * 6f, (ForceMode)2); if (hidingSpot && (Object)(object)_currentTarget != (Object)null) { HidingSpotOpened?.Invoke(_currentTarget, ((Vector3)(ref outward)).normalized); } } } internal bool DebugForce(PhysGrabHinge hinge, DebugAction action) { if (IsBusy) { HimPlugin.Log.Warning("[Him] Door routine already running."); return false; } Door door = Door.From(hinge); if (door == null) { HimPlugin.Log.Warning("[Him] That hinge has no joint here (host only, intact doors only)."); return false; } IEnumerator routine = action switch { DebugAction.Throw => Throw(door), DebugAction.Pry => BreakIntoHidingSpot(door), DebugAction.Rip => RipOff(door, "dev key"), _ => Throw(door), }; _busy = true; if (HimRunner.Run(Guard(routine)) == null) { _busy = false; } return true; } internal string Describe(PhysGrabHinge hinge, Vector3 playerPosition) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) Door door = Door.From(hinge); if (door == null) { return $"{((Object)hinge).name}: no joint (client, broken={hinge.broken}, dead={hinge.dead})"; } HingeJoint joint = door.Joint; object obj; if (!joint.useLimits) { obj = "none"; } else { JointLimits limits = joint.limits; object arg = ((JointLimits)(ref limits)).min; limits = joint.limits; obj = $"[{arg:F0}..{((JointLimits)(ref limits)).max:F0}]"; } string text = (string)obj; Vector3 point = playerPosition + Vector3.up * 0.9f; Vector3 hisPosition = door.Anchor - door.Normal * Mathf.Sign(door.Side(point)) * 2f; bool flag = IsHidingBehind(door, playerPosition, hisPosition); string text2 = (((Object)(object)((Component)hinge).transform.parent != (Object)null) ? ((Object)((Component)hinge).transform.parent).name : "-"); return $"{((Object)hinge).name} (in {text2}): closed={hinge.closed} angle={joint.angle:F0} limits={text} " + $"mass={door.Body.mass:F1} springy={hinge.springy} breakForce={((Joint)joint).breakForce:F0} " + $"held={door.HeldByPlayer} -> player hiding behind it from here: {flag}"; } private void RaiseHidingSpotOpened(Door door) { //IL_001e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_currentTarget == (Object)null) && !((Object)(object)door.Joint == (Object)null)) { Vector3 val = door.Normal * Mathf.Sign(door.Side(Position)); HidingSpotOpened?.Invoke(_currentTarget, ((Vector3)(ref val)).normalized); } } private static Vector3 Flat(Vector3 v) { //IL_0022: 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) v.y = 0f; if (!(((Vector3)(ref v)).sqrMagnitude > 1E-06f)) { return Vector3.forward; } return ((Vector3)(ref v)).normalized; } private void MarkFailed(Door door) { _failures.TryGetValue(door.Hinge, out var value); _failures[door.Hinge] = value + 1; _cooldownUntil[door.Hinge] = Time.time + 0.6f; } private void Forget(Door door) { _failures.Remove(door.Hinge); } } internal static class FlashlightDirector { internal enum State { Normal, BuildUp, FadeOut, Off, FadeIn, Panic, FadeRestore } private static float _fadeFrom = 1f; private static float _fadeTo = 1f; private static float _fadeProgress; private static float _fadeDuration = 1f; private static float _panicRemaining; private static float _panicIdleTimer; private static float _panicBurstTimer; private static bool _inBurst; private static float _noiseSeed; internal static Action? PanicFinished; internal static State Current { get; private set; } = State.Normal; internal static bool IsOverriding => Current != State.Normal; internal static bool ForcedOff => Current == State.Off; internal static float IntensityMultiplier { get; private set; } = 1f; internal static void Reset() { Current = State.Normal; IntensityMultiplier = 1f; _panicRemaining = 0f; _inBurst = false; PanicFinished = null; } internal static void SetBuildUp() { _noiseSeed = Random.Range(0f, 10000f); Current = State.BuildUp; } internal static void FadeOut(float duration) { StartFade(State.FadeOut, IntensityMultiplier, 0f, duration); } internal static void SetOff() { Current = State.Off; } internal static void FadeIntoPanic(float duration, float target, float panicDuration) { _panicRemaining = panicDuration; _panicIdleTimer = Random.Range(2f, 5f); _inBurst = false; StartFade(State.FadeIn, 0f, target, duration); } internal static void FadeRestore(float duration) { StartFade(State.FadeRestore, IntensityMultiplier, 1f, duration); } private static void StartFade(State state, float from, float to, float duration) { Current = state; _fadeFrom = from; _fadeTo = to; _fadeProgress = 0f; _fadeDuration = Mathf.Max(0.01f, duration); } internal static void Tick(float dt) { switch (Current) { case State.Normal: IntensityMultiplier = 1f; break; case State.BuildUp: { float num2 = Mathf.PerlinNoise(_noiseSeed, Time.time * 25f); IntensityMultiplier = Mathf.Lerp(0.2f, 1.2f, num2); if (Random.value > 0.95f) { IntensityMultiplier = 0f; } break; } case State.FadeOut: case State.FadeIn: case State.FadeRestore: { _fadeProgress += dt; float num = Mathf.Clamp01(_fadeProgress / _fadeDuration); IntensityMultiplier = Mathf.Lerp(_fadeFrom, _fadeTo, num); if (num >= 1f) { Current = ((Current == State.FadeIn) ? State.Panic : ((Current != State.FadeRestore) ? State.Off : State.Normal)); } break; } case State.Off: IntensityMultiplier = 0f; break; case State.Panic: TickPanic(dt); break; } } private static void TickPanic(float dt) { if (_panicRemaining > 0f) { _panicRemaining -= dt; if (_panicRemaining <= 0f) { Action? panicFinished = PanicFinished; PanicFinished = null; panicFinished?.Invoke(); return; } } if (_inBurst) { _panicBurstTimer -= dt; float num = Mathf.PerlinNoise(_noiseSeed, Time.time * 15f); IntensityMultiplier = Mathf.Lerp(0.1f, 0.7f, num); if (Random.value > 0.85f) { IntensityMultiplier = 0f; } if (_panicBurstTimer <= 0f) { _inBurst = false; _panicIdleTimer = Random.Range(3f, 8f); } } else { _panicIdleTimer -= dt; float num2 = Mathf.PerlinNoise(_noiseSeed + 100f, Time.time * 2f); IntensityMultiplier = 0.45f * Mathf.Lerp(0.95f, 1.05f, num2); if (_panicIdleTimer <= 0f) { _inBurst = true; _panicBurstTimer = Random.Range(0.3f, 1.2f); } } } } internal static class FurAssets { internal const string BundleFile = "himfur.bundle"; private const string FullName = "Him/SpiderFur"; private const string LiteName = "Him/SpiderFurLite"; private static bool _started; internal static Shader? Full { get; private set; } internal static Shader? Lite { get; private set; } internal static bool Done { get; private set; } internal static string Status { get; private set; } = "not loaded"; internal static IEnumerator Load() { if (_started) { yield break; } _started = true; string text = Locate(); if (text == null) { Finish("himfur.bundle not found next to the plugin - using geometry bristles (normal)"); yield break; } AssetBundleCreateRequest bundleRequest = AssetBundle.LoadFromFileAsync(text); yield return bundleRequest; AssetBundle bundle = bundleRequest.assetBundle; if ((Object)(object)bundle == (Object)null) { Finish("himfur.bundle could not be opened (built with a different Unity version?)"); yield break; } AssetBundleRequest assetsRequest = bundle.LoadAllAssetsAsync<Shader>(); yield return assetsRequest; Object[] allAssets = assetsRequest.allAssets; foreach (Object obj in allAssets) { Shader val = (Shader)(object)((obj is Shader) ? obj : null); if (val != null) { ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20); if (((Object)val).name == "Him/SpiderFur") { Full = val; } else if (((Object)val).name == "Him/SpiderFurLite") { Lite = val; } } } bundle.Unload(false); if ((Object)(object)Full != (Object)null && !Full.isSupported) { Full = null; } if ((Object)(object)Lite != (Object)null && !Lite.isSupported) { Lite = null; } Finish(((Object)(object)Full == (Object)null && (Object)(object)Lite == (Object)null) ? "bundle loaded but no supported fur shader in it" : $"ok (full={(Object)(object)Full != (Object)null}, lite={(Object)(object)Lite != (Object)null})"); } internal static Shader? Pick(int quality) { if (quality > 0) { if (quality == 1) { return Lite ?? Full; } return Full ?? Lite; } return null; } private static void Finish(string status) { Status = status; Done = true; if ((Object)(object)Full == (Object)null) { _ = (Object)(object)Lite == (Object)null; } } private static string? Locate() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (directoryName != null) { string text = Path.Combine(directoryName, "himfur.bundle"); if (File.Exists(text)) { return text; } } string text2 = Path.Combine(Paths.PluginPath, "himfur.bundle"); if (!File.Exists(text2)) { return null; } return text2; } } [HarmonyPatch(typeof(PlayerAvatar), "Start")] internal static class PlayerAvatar_Start_Patch { [HarmonyPostfix] private static void Postfix(PlayerAvatar __instance) { HimTrace.Write($"PlayerAvatar.Start postfix: isLocal={__instance.isLocal}"); if (__instance.isLocal && !((Object)(object)((Component)__instance).GetComponent<ParanoiaManager>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<ParanoiaManager>(); HimTrace.Write("ParanoiaManager attached (Harmony postfix)"); } } } [HarmonyPatch(typeof(FlashlightController), "Update")] internal static class FlashlightController_Update_Patch { [HarmonyPostfix] private static void Postfix(FlashlightController __instance) { if (FlashlightDirector.IsOverriding && !((Object)(object)__instance.PlayerAvatar == (Object)null) && __instance.PlayerAvatar.isLocal && !((Object)(object)__instance.spotlight == (Object)null)) { if (FlashlightDirector.ForcedOff) { ((Behaviour)__instance.spotlight).enabled = false; return; } ((Behaviour)__instance.spotlight).enabled = __instance.LightActive; __instance.spotlight.intensity = __instance.baseIntensity * FlashlightDirector.IntensityMultiplier; } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class RunManager_ChangeLevel_Patch { [HarmonyPrefix] private static void Prefix() { try { if (HimRound.Phase != HimPhase.Dormant) { HimTrace.Write("ChangeLevel prefix reached"); } HimRound.ResetAll("level change"); } catch (Exception arg) { HimPlugin.Log.Error($"[Him] ChangeLevel prefix threw: {arg}"); } } } internal static class HimAudio { private static AudioClip? _last; internal static void Prewarm() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)AudioScare.instance == (Object)null) { return; } AudioClip[][] array = new AudioClip[2][] { AudioScare.instance.impactSounds, AudioScare.instance.softSounds }; foreach (AudioClip[] array2 in array) { if (array2 == null) { continue; } AudioClip[] array3 = array2; foreach (AudioClip val in array3) { if ((Object)(object)val != (Object)null && (int)val.loadState == 0) { val.LoadAudioData(); } } } } internal static AudioClip? RandomSoft() { return Pick(impact: false); } internal static AudioClip? RandomImpact() { return Pick(impact: true); } private static AudioClip? Pick(bool impact) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 if ((Object)(object)AudioScare.instance == (Object)null) { return null; } AudioClip[] array = (impact ? AudioScare.instance.impactSounds : AudioScare.instance.softSounds); if (array == null || array.Length == 0) { return null; } int num = Random.Range(0, array.Length); AudioClip val = null; for (int i = 0; i < array.Length; i++) { AudioClip val2 = array[(num + i) % array.Length]; if ((Object)(object)val2 == (Object)null) { continue; } if ((int)val2.loadState == 0) { val2.LoadAudioData(); } else if ((int)val2.loadState == 2) { if (!((Object)(object)val2 == (Object)(object)_last)) { _last = val2; return val2; } val = val2; } } if ((Object)(object)val != (Object)null) { return val; } return null; } internal static void PlayAt(Vector3 position, bool impact, float volume = 1f, float pitch = 1f, float range = 60f) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown AudioClip val = Pick(impact); if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("HimStinger"); val2.transform.position = position; AudioSource obj = val2.AddComponent<AudioSource>(); obj.clip = val; obj.volume = volume; obj.pitch = pitch; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = Mathf.Min(3f, range * 0.25f); obj.maxDistance = range; obj.dopplerLevel = 0f; obj.Play(); Object.Destroy((Object)val2, val.length / Mathf.Max(0.1f, pitch) + 0.5f); } } internal static void PlayAll(Vector3 position, bool impact, float volume = 1f, float pitch = 1f, float range = 60f) { //IL_0050: 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_0045: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { HimPlugin.SoundEvent.RaiseEvent((object)new object[5] { position, impact, volume, pitch, range }, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } else { PlayAt(position, impact, volume, pitch, range); } } internal static void PlayDelayed(Vector3 position, float delay, bool impact, float volume, float pitch) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) HimRunner.Run(DelayedRoutine(position, delay, impact, volume, pitch)); } private static IEnumerator DelayedRoutine(Vector3 position, float delay, bool impact, float volume, float pitch) { //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) if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } PlayAt(position, impact, volume, pitch); } } internal static class HimConfig { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> InfectDelayMin; internal static ConfigEntry<float> InfectDelayMax; internal static ConfigEntry<float> TriggerTimeMin; internal static ConfigEntry<float> TriggerTimeMax; internal static ConfigEntry<float> LevelChance; internal static ConfigEntry<float> IsolationRadius; internal static ConfigEntry<float> TrackingRadius; internal static ConfigEntry<float> HuntDuration; internal static ConfigEntry<float> ChaseSpeed; internal static ConfigEntry<int> MonsterHealth; internal static ConfigEntry<bool> CanOpenDoors; internal static ConfigEntry<float> DoorRipChance; internal static ConfigEntry<bool> DragOutOfHiding; internal static ConfigEntry<bool> GrabWhileChasing; internal static ConfigEntry<bool> CeilingAmbush; internal static ConfigEntry<bool> ScreenEffects; internal static ConfigEntry<float> GlitchRate; internal static ConfigEntry<float> ScreamVolume; internal static ConfigEntry<int> FurQuality; internal static ConfigEntry<float> HairLength; internal static ConfigEntry<float> HairDensity; internal static ConfigEntry<int> FurStyle; internal static ConfigEntry<float> FurRim; internal static ConfigEntry<float> FurRimGlow; internal static ConfigEntry<bool> VerboseLogging; internal static ConfigEntry<bool> DebugHotkeys; internal const bool IsDebugBuild = false; internal static bool DebugKeysActive => DebugHotkeys?.Value ?? false; internal static bool Verbose => VerboseLogging?.Value ?? false; internal static void Bind(ConfigFile cfg) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Expected O, but got Unknown //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Expected O, but got Unknown //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Expected O, but got Unknown //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Expected O, but got Unknown //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Expected O, but got Unknown Enabled = cfg.Bind<bool>("General", "Enabled", true, "Master switch. When false the mod never infects anything."); InfectDelayMin = cfg.Bind<float>("Infection", "DelayMin", 45f, new ConfigDescription("Shortest wait (seconds) before a new valuable can be infected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); InfectDelayMax = cfg.Bind<float>("Infection", "DelayMax", 90f, new ConfigDescription("Longest wait (seconds) before a new valuable can be infected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); TriggerTimeMin = cfg.Bind<float>("Infection", "TriggerTimeMin", 15f, new ConfigDescription("Shortest time the carrier must stay isolated and turned away before he comes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f), Array.Empty<object>())); TriggerTimeMax = cfg.Bind<float>("Infection", "TriggerTimeMax", 60f, new ConfigDescription("Longest time the carrier must stay isolated and turned away before he comes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f), Array.Empty<object>())); LevelChance = cfg.Bind<float>("Infection", "LevelChance", 0.15f, new ConfigDescription("Chance that a level has a fake valuable at all (0.15 = about 1 in 7). Every level without one adds 5%, so a run never goes long without him. 1 = every level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); IsolationRadius = cfg.Bind<float>("Infection", "IsolationRadius", 7f, new ConfigDescription("Another player within this radius keeps the carrier safe.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); TrackingRadius = cfg.Bind<float>("Infection", "TrackingRadius", 15f, new ConfigDescription("The carrier must be within this distance of the infected valuable for the countdown to start.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); HuntDuration = cfg.Bind<float>("Hunt", "Duration", 60f, new ConfigDescription("How long he stays in the level once he has arrived.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), Array.Empty<object>())); ChaseSpeed = cfg.Bind<float>("Hunt", "ChaseSpeed", 9.5f, new ConfigDescription("Top chase speed. The vanilla Upscream runs at about 5.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); MonsterHealth = cfg.Bind<int>("Hunt", "Health", 1500, new ConfigDescription("Hit points. High on purpose: he is not meant to be killed.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100000), Array.Empty<object>())); CanOpenDoors = cfg.Bind<bool>("Hunt", "CanOpenDoors", true, "Let him get through hinged things instead of being stopped by them. Doors in his way get thrown open; anything you are hiding inside gets worked open slowly, and torn off if you hold it shut."); DragOutOfHiding = cfg.Bind<bool>("Hunt", "DragOutOfHiding", true, "When you hide in a locker, wardrobe or crate, he teases the door, then tears it off, grabs you with his legs and carries you to another room before he attacks."); GrabWhileChasing = cfg.Bind<bool>("Hunt", "GrabWhileChasing", true, "When he catches up with you in the open he can grab you and carry you off too (at most once every 30 seconds; the other times he just attacks)."); CeilingAmbush = cfg.Bind<bool>("Hunt", "CeilingAmbush", true, "When the hunt ends he does not leave. He runs to a room away from everyone, hangs upside down from the ceiling and watches. Anyone who walks under him is dropped on and attacked three times; then he moves to another room and waits again, until the level ends. No new infection starts while he is up there."); DoorRipChance = cfg.Bind<float>("Hunt", "DoorRipChance", 0.15f, new ConfigDescription("Chance that a door merely in his way is torn off its hinges instead of thrown open. Hiding spots are always pried open first, and only torn off if you hold them shut or they jam.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ScreenEffects = cfg.Bind<bool>("Presentation", "ScreenEffects", true, "Full-screen glitch text and static during the build-up. Disable if you are photosensitive."); GlitchRate = cfg.Bind<float>("Presentation", "GlitchRate", 24f, new ConfigDescription("How many times per second the glitch overlay redraws. Lower is cheaper and looks more like film.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 60f), Array.Empty<object>())); ScreamVolume = cfg.Bind<float>("Presentation", "ScreamVolume", 1f, new ConfigDescription("Volume of the custom scream loop.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FurQuality = cfg.Bind<int>("Appearance", "FurQuality", 2, new ConfigDescription("Spider bristles on his legs. 0 = none (bare black chitin), 1 = geometry bristles (real 3D spikes, no extra files needed), 2 = shader fur if himfur.bundle is installed, otherwise geometry bristles. Only drawn within 20 m, never casts shadows.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>())); HairLength = cfg.Bind<float>("Appearance", "HairLength", 0.04f, new ConfigDescription("Guard hair length in metres; the undercoat is a bit over half of it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.08f), Array.Empty<object>())); HairDensity = cfg.Bind<float>("Appearance", "HairDensity", 16f, new ConfigDescription("Undercoat hairs per square centimetre. 16 is a thick pelt. Lower it on slow PCs (8 is still a coat); the guard hairs scale with it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 30f), Array.Empty<object>())); FurStyle = cfg.Bind<int>("Appearance", "FurStyle", 0, new ConfigDescription("0 = tarantula (flat dark velvet + sparse long pale bristles), 1 = shaggy (long, standing up, very full), 2 = the 1.2.0 coat.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>())); FurRim = cfg.Bind<float>("Appearance", "FurRim", 0.18f, new ConfigDescription("Rim light on his silhouette, tinting his surface. Lit, so it fades with the room. 0 disables.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FurRimGlow = cfg.Bind<float>("Appearance", "FurRimGlow", 0.22f, new ConfigDescription("Unlit part of the rim. This is the setting that makes a black creature readable in a pitch-dark corridor, because it survives having no light at all. Raise it if he is still hard to see, lower it if he glows.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); VerboseLogging = cfg.Bind<bool>("Diagnostics", "VerboseLogging", false, "Write the full step-by-step trace to the BepInEx console. Always on in a debug build, whatever this says."); DebugHotkeys = cfg.Bind<bool>("Diagnostics", "DebugHotkeys", false, "Numpad debug keys, host only. Always on in a debug build, whatever this says.\n * infect the nearest valuable and drop it in front of you\n - skip the countdown: he arrives now, with the full light and text sequence\n + skip everything: he spawns immediately, straight into the hunt\n / print diagnostics (resolved shaders, mesh readability, round state)"); } } internal enum HimPhase { Dormant, Infected, Stalking, Arriving, Hunting, Aftermath } internal static class HimRound { internal static bool SomeoneElseIsCarrier; internal static Coroutine? ActiveSequence; private static float _phaseChangedAt; internal static bool LurkerActive; internal const float PhaseTimeout = 300f; internal static HimPhase Phase { get; private set; } internal static float TimeInPhase => Time.time - _phaseChangedAt; internal static bool CanInfect { get { if (HimConfig.Enabled.Value && Phase == HimPhase.Dormant) { return !LurkerActive; } return false; } } private static bool IsAlreadyClean { get { if (Phase == HimPhase.Dormant && !SomeoneElseIsCarrier && ActiveSequence == null && !InfectionDirector.Active && !SceneLightDirector.HasWorkToUndo) { return !FlashlightDirector.IsOverriding; } return false; } } internal static void SetPhase(HimPhase phase) { if (Phase != phase) { Phase = phase; _phaseChangedAt = Time.time; } } internal static void EndRound() { HimRunner.Stop(ref ActiveSequence); InfectionDirector.ClearInfection(); HuntDirector.DiscardStagedAssets(); SomeoneElseIsCarrier = false; SetPhase(HimPhase.Dormant); ResetLocalManager(); } private static void ResetLocalManager() { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if (!((Object)(object)val == (Object)null)) { ParanoiaManager component = ((Component)val).GetComponent<ParanoiaManager>(); if ((Object)(object)component != (Object)null) { component.ResetLocalState(); } } } internal static void ResetAll(string reason) { if (!IsAlreadyClean) { HimRunner.Stop(ref ActiveSequence); SceneLightDirector.RestoreImmediate(); FlashlightDirector.Reset(); InfectionDirector.ClearInfection(); HuntDirector.DiscardStagedAssets(); HorrorOverlay.DestroyActive(); SomeoneElseIsCarrier = false; LurkerActive = false; Phase = HimPhase.Dormant; ResetLocalManager(); } } } internal static class HimUtil { internal static PlayerAvatar? FindPlayerByViewId(int viewId) { if (viewId == 0) { return SemiFunc.PlayerAvatarLocal(); } List<PlayerAvatar> list = SemiFunc.PlayerGetList(); if (list == null) { return null; } for (int i = 0; i < list.Count; i++) { PlayerAvatar val = list[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null && val.photonView.ViewID == viewId) { return val; } } return null; } internal static int ViewIdOf(PlayerAvatar? player) { if (!((Object)(object)player != (Object)null) || !((Object)(object)player.photonView != (Object)null)) { return 0; } return player.photonView.ViewID; } internal static void Shuffle<T>(IList<T> list) { for (int num = list.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); int index = num; int index2 = num2; T value = list[num2]; T value2 = list[num]; list[index] = value; list[index2] = value2; } } } internal sealed class HimRunner : MonoBehaviour { private static HimRunner? _instance; private static HimRunner? Instance { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if ((Object)(object)_instance != (Object)null) { return _instance; } try { GameObject val = new GameObject("HimRunner"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent<HimRunner>(); HimTrace.Write("HimRunner created"); return _instance; } catch (Exception ex) { HimPlugin.Log.Error("[Him] Could not create the coroutine host: " + ex.Message); return null; } } } internal static Coroutine? Run(IEnumerator routine) { HimRunner instance = Instance; if ((Object)(object)instance != (Object)null) { return ((MonoBehaviour)instance).StartCoroutine(routine); } HimPlugin instance2 = HimPlugin.Instance; if (!((Object)(object)instance2 != (Object)null)) { return null; } return ((MonoBehaviour)instance2).StartCoroutine(routine); } internal static void Stop(ref Coroutine? routine) { StopOne(routine); routine = null; } internal static void StopOne(Coroutine? routine) { if (routine == null) { return; } if ((Object)(object)_instance != (Object)null) { ((MonoBehaviour)_instance).StopCoroutine(routine); return; } HimPlugin instance = HimPlugin.Instance; if ((Object)(object)instance != (Object)null) { ((MonoBehaviour)instance).StopCoroutine(routine); } } private void OnDestroy() { HimTrace.Write("HimRunner destroyed"); if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } } internal static class HimSpike { private const float SpikeMs = 45f; private const int Capacity = 32; private static readonly string[] _marks = new string[32]; private static readonly int[] _frames = new int[32]; private static readonly float[] _costMs = new float[32]; private static int _next; private static readonly Stopwatch _watch = new Stopwatch(); [Conditional("HIM_DEV")] internal static void Mark(string what) { Add(what, 0f); } [Conditional("HIM_DEV")] internal static void Mark(string what, float milliseconds) { Add(what, milliseconds); } [Conditional("HIM_DEV")] internal static void Begin() { _watch.Restart(); } [Conditional("HIM_DEV")] internal static void End(string what) { Add(what, (float)_watch.Elapsed.TotalMilliseconds); } private static void Add(string what, float ms) { _marks[_next] = what; _frames[_next] = Time.frameCount; _costMs[_next] = ms; _next = (_next + 1) % 32; } [Conditional("HIM_DEV")] internal static void Check() { float num = Time.unscaledDeltaTime * 1000f; if (num < 45f || Time.frameCount < 10) { return; } int frameCount = Time.frameCount; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"[Him][SPIKE] {num:F0} ms frame phase={HimRound.Phase} flashlight={FlashlightDirector.Current} marks: "); int num2 = 0; for (int i = 0; i < 32; i++) { int num3 = (_next + i) % 32; if (_marks[num3] != null && frameCount - _frames[num3] <= 2) { if (num2++ > 0) { stringBuilder.Append(" | "); } stringBuilder.Append(_marks[num3]); if (_costMs[num3] > 0.05f) { stringBuilder.Append($" ({_costMs[num3]:F1} ms)"); } } } if (num2 == 0) { stringBuilder.Append("none - the mod did nothing special this frame (game or engine side)"); } HimPlugin.Log.Warning(stringBuilder.ToString()); } } internal static class HimTrace { internal static string Path => "<release build: tracing compiled out>"; internal static void Start() { } internal static void Write(string message) { } } internal sealed class HorrorOverlay : MonoBehaviour { private const int NoiseFrameCount = 8; private const int NoiseWidth = 128; private const int NoiseHeight = 72; private const int CorruptedVariants = 16; private static readonly char[] GlitchChars = new char[9] { '░', '▒', '▓', '‡', '†', 'X', '?', '#', '%' }; private static Texture2D[]? _noiseFrames; private static Font? _font; private static HorrorOverlay? _active; private RawImage _static; private Text _text; private Outline _outline; private Shadow _shadow; private CanvasRenderer _textRenderer; private string[] _variants = Array.Empty<string>(); private float _glitchTimer; private float _alpha; private const string AllGlyphs = "RUN. CALLFORHELP HECANYOUISW░▒▓‡†X?#%"; internal static IEnumerator Preload() { ResolveFont(); WarmFont(); if (_noiseFrames != null) { yield break; } Texture2D[] frames = (Texture2D[])(object)new Texture2D[8]; Color32[] pixels = (Color32[])(object)new Color32[9216]; for (int f = 0; f < 8; f++) { for (int i = 0; i < pixels.Length; i++) { byte b = (byte)((Random.value < 0.35f) ? ((uint)Random.Range(40, 190)) : 0u); byte b2 = (byte)Random.Range(90, 255); pixels[i] = new Color32(b2, (byte)(b2 / 5), (byte)(b2 / 6), b); } Texture2D val = new Texture2D(128, 72, (TextureFormat)4, false) { name = $"HimNoise{f}", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)0, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, true); frames[f] = val; yield return null; } _noiseFrames = frames; } private static void ResolveFont() { if (!((Object)(object)_font != (Object)null)) { _font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); if ((Object)(object)_font == (Object)null) { _font = Resources.GetBuiltinResource<Font>("Arial.ttf"); } if ((Object)(object)_font == (Object)null) { _font = Font.CreateDynamicFontFromOSFont(new string[5] { "Arial", "Segoe UI", "Helvetica", "Liberation Sans", "DejaVu Sans" }, 110); } if ((Object)(object)_font == (Object)null) { HimPlugin.Log.Error("[Him] No usable font found; the text sequence will be silent."); } } } private static void WarmFont() { if (!((Object)(object)_font == (Object)null)) { _font.RequestCharactersInTexture("RUN. CALLFORHELP HECANYOUISW░▒▓‡†X?#%", 110, (FontStyle)0); } } private static void OnFontRebuilt(Font font) { if (!((Object)(object)font != (Object)(object)_font)) { WarmFont(); } } internal static HorrorOverlay? Create() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!HimConfig.ScreenEffects.Value) { return null; } DestroyActive(); _active = new GameObject("HimHorrorOverlay").AddComponent<HorrorOverlay>(); _active.Build(); return _active; } internal static void DestroyActive() { if (!((Object)(object)_active == (Object)null)) { Object.Destroy((Object)(object)((Component)_active).gameObject); _active = null; } } private void Build() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) ResolveFont(); WarmFont(); GameObject val = new GameObject("Static"); val.transform.SetParent(((Component)this).transform, false); Canvas obj = val.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 9990; GameObject val2 = new GameObject("Grain"); val2.transform.SetParent(val.transform, false); _static = val2.AddComponent<RawImage>(); ((Graphic)_static).raycastTarget = false; ((Graphic)_static).color = new Color(1f, 1f, 1f, 0.06f); Texture2D[] noiseFrames = _noiseFrames; if (noiseFrames != null && noiseFrames.Length > 0) { _static.texture = (Texture)(object)_noiseFrames[0]; } Stretch(((Graphic)_static).rectTransform); GameObject val3 = new GameObject("Headline"); val3.transform.SetParent(((Component)this).transform, false); Canvas obj2 = val3.AddComponent<Canvas>(); obj2.renderMode = (RenderMode)0; obj2.sortingOrder = 10000; GameObject val4 = new GameObject("Text"); val4.transform.SetParent(val3.transform, false); _text = val4.AddComponent<Text>(); _text.font = _font; _text.fontSize = 110; _text.alignment = (TextAnchor)4; _text.horizontalOverflow = (HorizontalWrapMode)1; _text.verticalOverflow = (VerticalWrapMode)1; ((Graphic)_text).raycastTarget = false; ((Graphic)_text).color = new Color(0.8f, 0f, 0f, 1f); _outline = val4.AddComponent<Outline>(); ((Shadow)_outline).effectColor = new Color(0.1f, 0f, 0f, 1f); ((Shadow)_outline).effectDistance = new Vector2(4f, -4f); _shadow = val4.AddComponent<Shadow>(); _shadow.effectColor = new Color(0f, 0f, 0f, 0.8f); _shadow.effectDistance = new Vector2(8f, -8f); RectTransform rectTransform = ((Graphic)_text).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0.15f); rectTransform.anchorMax = new Vector2(1f, 0.35f); rectTransform.sizeDelta = Vector2.zero; _textRenderer = ((Graphic)_text).canvasRenderer; _textRenderer.SetAlpha(0f); Font.textureRebuilt += OnFontRebuilt; } private static void Stretch(RectTransform rect) { //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } private void Update() { _textRenderer.SetAlpha(_alpha); float num = Mathf.Max(1f, HimConfig.GlitchRate.Value); _glitchTimer -= Time.deltaTime; if (!(_glitchTimer > 0f)) { _glitchTimer = 1f / num; GlitchTick(); } } private void GlitchTick() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) Texture2D[] noiseFrames = _noiseFrames; if (noiseFrames != null && noiseFrames.Length > 0) { _static.texture = (Texture)(object)_noiseFrames[Random.Range(0, _noiseFrames.Length)]; float num = Random.Range(6f, 9f); _static.uvRect = new Rect(Random.value, Random.value, num, num * 0.6f); } if (_variants.Length != 0) { _text.text = _variants[Random.Range(0, _variants.Length)]; } RectTransform rectTransform = ((Graphic)_text).rectTransform; if (Random.value > 0.12f) { float num2 = ((Random.value > 0.92f) ? 28f : 11f); rectTransform.anchoredPosition = new Vector2(Random.Range(0f - num2, num2), Random.Range(0f - num2, num2)); ((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, Random.Range(-4f, 4f)); ((Transform)rectTransform).localScale = new Vector3(1f + Random.Range(-0.06f, 0.06f), 1f + Random.Range(-0.06f, 0.06f), 1f); ((Shadow)_outline).effectDistance = new Vector2(Random.Range(3f, 6f), Random.Range(-6f, -3f)); _shadow.effectDistance = new Vector2(Random.Range(6f, 11f), Random.Range(-11f, -6f)); } else { rectTransform.anchoredPosition = Vector2.zero; ((Transform)rectTransform).localRotation = Quaternion.identity; ((Transform)rectTransform).localScale = Vector3.one; ((Shadow)_outline).effectDistance = new Vector2(4f, -4f); _shadow.effectDistance = new Vector2(8f, -8f); } } internal IEnumerator PlayPhrase(string content, float displayTime) { BuildVariants(content); for (float t = 0f; t < 0.5f; t += Time.deltaTime) { _alpha = Mathf.PingPong(Time.time * 20f, 1f); yield return null; } _alpha = 1f; for (float t = 0f; t < displayTime; t += Time.deltaTime) { yield return null; } for (float t = 0f; t < 0.5f; t += Time.deltaTime) { _alpha = Mathf.PingPong(Time.time * 20f, 1f); yield return null; } _alpha = 0f; } internal void HoldPhrase(string content) { BuildVariants(content); _alpha = 1f; } private void BuildVariants(string content) { string[] array = new string[16]; StringBuilder stringBuilder = new StringBuilder(content.Length); for (int i = 0; i < 16; i++) { stringBuilder.Clear(); for (int j = 0; j < content.Length; j++) { char c = content[j]; if (c != ' ' && c != '\n' && Random.value > 0.93f) { c = GlitchChars[Random.Range(0, GlitchChars.Length)]; } stringBuilder.Append(c); } array[i] = stringBuilder.ToString(); } array[0] = content; _variants = array; _text.text = content; } private void OnDestroy() { Font.textureRebuilt -= OnFontRebuilt; if ((Object)(object)_active == (Object)(object)this) { _active = null; } } } internal static class HuntDirector { private static EnemySetup? _cachedSetup; private static GameObject? _stagedHead; private static GameObject? _cachedLoomPrefab; internal static void RequestSpawn(Vector3 itemPosition, PlayerAvatar target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Vector3 val = itemPosition + Vector3.up * 0.5f; Vector3 val2 = ((Component)target).transform.position - val; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.forward; } Quaternion val3 = Quaternion.LookRotation(val2); int num = HimUtil.ViewIdOf(target); if (SemiFunc.IsMasterClientOrSingleplayer()) { HostSpawn(val, val3, num); return; } HimPlugin.RequestEvent.RaiseEvent((object)new object[3] { val, val3, num }, NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable); } internal static void HostSpawn(Vector3 position, Quaternion rotation, int targetViewId) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) EnemySetup val = FindSetup(); if ((Object)(object)val == (Object)null) { HimPlugin.Log.Error("[Him] No suitable enemy setup found; he cannot arrive."); return; } List<EnemyParent> list = Enemies.SpawnEnemy(val, position, rotation, false); if (list == null || list.Count == 0) { HimPlugin.Log.Error("[Him] Enemies.SpawnEnemy returned nothing; spawn failed."); return; } foreach (EnemyParent item in list) { if ((Object)(object)item != (Object)null) { Enhance(item, targetViewId); } } if (SemiFunc.IsMultiplayer()) { HimRunner.Run(AnnounceToOthers(list, targetViewId)); } } private static IEnumerator AnnounceToOthers(List<EnemyParent> spawned, int targetViewId) { yield return (object)new WaitForSeconds(1.5f); foreach (EnemyParent item in spawned) { if (!((Object)(object)item == (Object)null)) { PhotonView component = ((Component)item).GetComponent<PhotonView>(); if (!((Object)(object)component == (Object)null) && component.ViewID != 0) { HimPlugin.EnhanceEvent.RaiseEvent((object)new object[2] { component.ViewID, targetViewId }, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } } } internal static void ApplyLocalEnhancement(int enemyViewId, int targetViewId) { PhotonView val = PhotonView.Find(enemyViewId); if ((Object)(object)val == (Object)null) { HimPlugin.Log.Warning($"[Him] Enemy view {enemyViewId} is unknown on this client."); return; } EnemyParent component = ((Component)val).GetComponent<EnemyParent>(); if ((Object)(object)component != (Object)null) { Enhance(component, targetViewId); } } private static void Enhance(EnemyParent parent, int targetViewId) { if (!((Object)(object)parent == (Object)null) && !((Object)(object)((Component)parent).GetComponent<UpscreamEnhancer>() != (Object)null)) { ((Component)parent).gameObject.AddComponent<UpscreamEnhancer>().Initialise(parent, targetViewId, HimUtil.FindPlayerByViewId(targetViewId)); } } internal static EnemySetup? FindSetup() { if ((Object)(object)_cachedSetup != (Object)null) { return _cachedSetup; } if ((Object)(object)EnemyDirector.instance == (Object)null) { return null; } IEnumerable<EnemySetup> enumerable = EnemyDirector.instance.enemiesDifficulty1.Concat(EnemyDirector.instance.enemiesDifficulty2).Concat(EnemyDirector.instance.enemiesDifficulty3); foreach (EnemySetup item in enumerable) { if ((Object)(object)item == (Object)null) { continue; } List<PrefabRef> spawnObjects = item.spawnObjects; if (spawnObjects != null && spawnObjects.Count > 0) { string text = (((Object)item).name + " " + ((PrefabRef<GameObject>)(object)item.spawnObjects[0])?.ResourcePath).ToLowerInvariant(); if (text.Contains("upscream") || text.Contains("scream")) { _cachedSetup = item; return item; } } } EnemySetup val = null; foreach (EnemySetup item2 in enumerable) { if (!((Object)(object)item2 == (Object)null)) { EnemyParent prefabParent = GetPrefabParent(item2); string text2 = ((((Object)(object)prefabParent != (Object)null) ? prefabParent.enemyName : ((Object)item2).name) ?? string.Empty).ToLowerInvariant(); if (text2.Contains("scream") || text2.Contains("shriek") || text2.Contains("howl")) { _cachedSetup = item2; return item2; } if ((Object)(object)val == (Object)null) { val = item2; } } } if ((Object)(object)val != (Object)null) { HimPlugin.Log.Warning("[Him] Upscream not found; falling back to '" + ((Object)val).name + "'."); } _cachedSetup = val; return val; } internal static void StageArrivalAssets() { if (!((Object)(object)_stagedHead != (Object)null)) { FindSetup(); _stagedHead = ExtractLoomPieces(); _ = (Object)(object)_stagedHead != (Object)null; } } internal static GameObject? TakeStagedHead() { GameObject stagedHead = _stagedHead; _stagedHead = null; if (!((Object)(object)stagedHead != (Object)null)) { return null; } return stagedHead; } internal static void DiscardStagedAssets() { if (!((Object)(object)_stagedHead == (Object)null)) { Object.Destroy((Object)(object)_stagedHead); _stagedHead = null; } } internal static GameObject? ExtractLoomPieces() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown GameObject val = FindLoomPrefab(); if ((Object)(object)val == (Object)null) { return null; } bool activeSelf = val.activeSelf; GameObject val2; try { val.SetActive(false); val2 = Object.Instantiate<GameObject>(val); } finally { val.SetActive(activeSelf); } ((Object)val2).name = "Him"; val2.SetActive(false); Transform val3 = null; Transform val4 = null; Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>(true); foreach (Transform val5 in componentsInChildren) { if (((Object)val5).name.Contains("Head ANIM")) { val3 = val5; } else if (((Object)val5).name == "Particles" && (Object)(object)val5.parent == (Object)(object)val2.transform) { val4 = val5; } } if ((Object)(object)val3 == (Object)null) { HimPlugin.Log.Warning("[Him] 'Head ANIM' not found inside the Loom prefab."); Object.Destroy((Object)(object)val2); return null; } GameObject val6 = new GameObject("HimStagedHead"); val6.SetActive(false); val3.SetParent(val6.transform, true); if ((Object)(object)val4 != (Object)null) { val4.SetParent(val6.transform, true); } Object.Destroy((Object)(object)val2); return val6; } internal static GameObject? FindLoomPrefab() { if ((Object)(object)_cachedLoomPrefab != (Object)null) { return _cachedLoomPrefab; } PrefabRef val = LoomRef(); if (val != null) { _cachedLoomPrefab = ((PrefabRef<GameObject>)(object)val).Prefab; if ((Object)(object)_cachedLoomPrefab != (Object)null) { return _cachedLoomPrefab; } } IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies; if (allEnemies == null) { return null; } foreach (EnemySetup item in allEnemies) { if ((Object)(object)item == (Object)null) { continue; } List<PrefabRef> spawnObjects = item.spawnObjects; if (spawnObjects == null || spawnObjects.Count <= 0) { continue; } GameObject prefab = ((PrefabRef<GameObject>)(object)item.spawnObjects[0]).Prefab; if (!((Object)(object)prefab == (Object)null)) { EnemyParent componentInChildren = prefab.GetComponentInChildren<EnemyParent>(); if (!((Object)(object)componentInChildren == (Object)null) && componentInChildren.enemyName != null && componentInChildren.enemyName.ToLowerInvariant().Contains("loom")) { _cachedLoomPrefab = prefab; return prefab; } } } return null; } private static PrefabRef? LoomRef() { IReadOnlyList<EnemySetup> allEnemies = Enemies.AllEnemies; if (allEnemies == null) { return null; } foreach (EnemySetup item in allEnemies) { if ((Object)(object)item == (Object)null) { continue; } List<PrefabRef> spawnObjects = item.spawnObjects; if (spawnObjects != null && spawnObjects.Count > 0) { PrefabRef val = item.spawnObjects[0]; if (val != null && !string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)val).ResourcePath) && (((PrefabRef<GameObject>)(object)val).ResourcePath.ToLowerInvariant().Contains("loom") || (((Object)item).name != null && ((Object)item).name.ToLowerInvariant().Contains("loom")))) { return val; } } } return null; } internal static IEnumerator StageArrivalAssetsAsync() { if ((Object)(object)_stagedHead != (Object)null) { yield break; } if ((Object)(object)_cachedLoomPrefab == (Object)null) { PrefabRef val = LoomRef(); if (val != null) { ResourceRequest request = Resources.LoadAsync<GameObject>(((PrefabRef<GameObject>)(object)val).ResourcePath); yield return request; Object asset = request.asset; _cachedLoomPrefab = (GameObject?)(object)((asset is GameObject) ? asset : null); } } yield return null; StageArrivalAssets(); } private static EnemyParent? GetPrefabParent(EnemySetup setup) { List<PrefabRef> spawnObjects = setup.spawnObjects; if (spawnObjects == null || spawnObjects.Count <= 0) { return null; } GameObject prefab = ((PrefabRef<GameObject>)(object)setup.spawnObjects[0]).Prefab; if ((Object)(object)prefab == (Object)null) { return null; } EnemyParent component = prefab.GetComponent<EnemyParent>(); if (!((Object)(object)component != (Object)null)) { return null; } return component; } } internal static class InfectionDirector { private static GameObject? _disguise; private static readonly List<Renderer> _hiddenRenderers = new List<Renderer>(); private static Coroutine? _hostRoutine; private const float PityStep = 0.05f; private static int _rolledFor; private static bool _levelCursed; private static int _dryLevels; private static bool _appearedThisLevel; internal static Transform? InfectedTransform { get; private set; } internal static Vector3 LastKnownPosition { get; private set; } internal static float TriggerLimit { get; private set; } = 30f; internal static int CarrierViewId { get; private set; } internal static bool Active { get; private set; } internal static void StartHostRoutine() { if (_hostRoutine == null) { _hostRoutine = HimRunner.Run(HostRoutine()); } } internal static void StopHostRoutine() { HimRunner.Stop(ref _hostRoutine); } private static IEnumerator HostRoutine() { while (true) { float num = Random.Range(Mathf.Min(HimConfig.InfectDelayMin.Value, HimConfig.InfectDelayMax.Value), Mathf.Max(HimConfig.InfectDelayMin.Value, HimConfig.InfectDelayMax.Value)); yield return (object)new WaitForSeconds(num); if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || !LevelIsCursed()) { continue; } if (!HimRound.CanInfect) { if (HimRound.TimeInPhase > 300f) { BroadcastCure(); } } else { TryInfectSomething(); } } } private static bool LevelIsCursed() { LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null) { return false; } int num = ((Object)instance).GetInstanceID() ^ ((((Object)(object)RunManager.instance != (Object)null) ? (RunManager.instance.levelsCompleted + 1) : 0) * 7919); if (num != _rolledFor) { if (_rolledFor != 0) { _dryLevels = ((!_appearedThisLevel) ? (_dryLevels + 1) : 0); } _rolledFor = num; _appearedThisLevel = false; float num2 = Mathf.Clamp01(HimConfig.LevelChance.Value + (float)_dryLevels * 0.05f); _levelCursed = Random.value < num2; } return _levelCursed; } private static void TryInfectSomething() { ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); if (array.Length < 2) { return; } List<Bounds> cartBounds = CollectCartBounds(); List<ValuableObject> list = new List<ValuableObject>(); List<ValuableObject> list2 = new List<ValuableObject>(); ValuableObject[] array2 = array; foreach (ValuableObject val in array2) { if (!((Object)(object)val == (Object)null) && (!SemiFunc.IsMultiplayer() || HasUsableView(val))) { if (IsInCart(((Component)val).transform, cartBounds)) { list.Add(val); } else { list2.Add(val); } } } if (list.Count != 0 && list2.Count != 0) { ValuableObject source = list[Random.Range(0, list.Count)]; ValuableObject target = list2[Random.Range(0, list2.Count)]; float limit = Random.Range(Mathf.Min(HimConfig.TriggerTimeMin.Value, HimConfig.TriggerTimeMax.Value), Mathf.Max(HimConfig.TriggerTimeMin.Value, HimConfig.TriggerTimeMax.Value)); Broadcast(target, source, limit); } } private static bool HasUsableView(ValuableObject valuable) { PhotonView component = ((Component)valuable).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null) { return component.ViewID != 0; } return false; } private static void Broadcast(ValuableObject target, ValuableObject source, float limit) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) _appearedThisLevel = true; if (!SemiFunc.IsMultiplayer()) { ApplyInfection(target, source, limit); return; } PhotonView component = ((Component)target).GetComponent<PhotonView>(); PhotonView component2 = ((Component)source).GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null || component.ViewID == 0 || component2.ViewID == 0) { HimPlugin.Log.Warning("[Him] '" + ((Object)target).name + "' or '" + ((Object)source).name + "' has no network id; skipping this infection."); } else { HimPlugin.InfectEvent.RaiseEvent((object)new object[3] { component.ViewID, component2.ViewID, limit }, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } internal static void ForceInfect(ValuableObject valuable, float limit, ValuableObject? disguiseAs = null) { Broadcast(valuable, (ValuableObject)(((Object)(object)disguiseAs != (Object)null) ? ((object)disguiseAs) : ((object)valuable)), limit); } private static List<Bounds> CollectC