using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Mein Schatz")] [assembly: AssemblyCompany("TGamerT")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0-prototype")] [assembly: AssemblyVersion("0.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CursedRingPrototype { public sealed class CursedRingItem : GrabbableObject { internal bool Wearing; private float nextInput; private GameObject fingerRing; private bool visualWearing; public bool AiSafeToTest => false; public bool AiCanUse => Time.time >= nextInput; public override void ItemActivate(bool used, bool buttonDown = true) { if (buttonDown && ((NetworkBehaviour)this).IsOwner && !((Object)(object)base.playerHeldBy == (Object)null) && !base.playerHeldBy.isPlayerDead && !(Time.time < nextInput)) { nextInput = Time.time + 0.4f; RingNet.Request(this, RingMessage.Toggle); } } public override void ItemInteractLeftRight(bool right) { if (((NetworkBehaviour)this).IsOwner && Wearing && !((Object)(object)base.playerHeldBy == (Object)null) && !(Time.time < nextInput)) { nextInput = Time.time + 0.5f; RingNet.Request(this, right ? RingMessage.Surrender : RingMessage.Shake); } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RingNet.RingSpawned(this); } public override void OnNetworkDespawn() { RingNet.RingDespawned(this); ((NetworkBehaviour)this).OnNetworkDespawn(); } public override void Update() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Update(); if (!((NetworkBehaviour)this).IsSpawned) { return; } base.isBeingUsed = Wearing; if (visualWearing != Wearing) { Transform val = ((Component)this).transform.Find("RingVisual"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(!Wearing); } visualWearing = Wearing; if (!Wearing) { ((GrabbableObject)this).EnableItemMeshes(!base.isPocketed); } } if (Wearing && (Object)(object)base.playerHeldBy != (Object)null) { if ((Object)(object)fingerRing == (Object)null) { fingerRing = RingVisualFactory.CreateRing(base.playerHeldBy.serverItemHolder); ((Object)fingerRing).name = "DerEineRing_Angezogen"; fingerRing.transform.localScale = Vector3.one * 0.24f; fingerRing.transform.localPosition = new Vector3(0.018f, -0.03f, 0.015f); } } else if ((Object)(object)fingerRing != (Object)null) { Object.Destroy((Object)(object)fingerRing); fingerRing = null; } } private void OnDisable() { if ((Object)(object)fingerRing != (Object)null) { Object.Destroy((Object)(object)fingerRing); } } } internal static class FaceAtlas { private static readonly int width; private static readonly int height; private static readonly byte[] rgb; static FaceAtlas() { using Stream stream = typeof(FaceAtlas).Assembly.GetManifestResourceStream("CursedRingPrototype.FaceAtlas"); if (stream == null) { throw new InvalidDataException("Embedded face albedo is missing."); } using GZipStream input = new GZipStream(stream, CompressionMode.Decompress); using BinaryReader binaryReader = new BinaryReader(input); width = binaryReader.ReadInt32(); height = binaryReader.ReadInt32(); if (width < 2 || height < 2 || width > 4096 || height > 4096) { throw new InvalidDataException("Invalid face albedo dimensions."); } rgb = binaryReader.ReadBytes(checked(width * height * 3)); if (rgb.Length != width * height * 3) { throw new InvalidDataException("Incomplete face albedo."); } } private static float Channel(int x, int y, int channel) { return (float)(int)rgb[(y * width + x) * 3 + channel] / 255f; } public static Color Sample(float u, float v) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(u) * (float)(width - 1); float num2 = (1f - Mathf.Clamp01(v)) * (float)(height - 1); int x0 = (int)num; int y0 = (int)num2; int x1 = Math.Min(width - 1, x0 + 1); int y1 = Math.Min(height - 1, y0 + 1); float tx = num - (float)x0; float ty = num2 - (float)y0; return new Color(Read(0), Read(1), Read(2)); float Read(int channel) { return Mathf.Lerp(Mathf.Lerp(Channel(x0, y0, channel), Channel(x1, y0, channel), tx), Mathf.Lerp(Channel(x0, y1, channel), Channel(x1, y1, channel), tx), ty); } } } public sealed class GollumActor : EnemyAI { private sealed class Joint { internal Transform transform; internal Quaternion rest; } public ulong RingId; public int Generation; public int WearerSlot = -1; public RingEncounterState Phase; private readonly Dictionary joints = new Dictionary(); private readonly Dictionary recentHits = new Dictionary(); private readonly RaycastHit[] castHits = (RaycastHit[])(object)new RaycastHit[16]; private GameObject visual; private Vector3 visualRest; private Vector3 lastAnimatedPosition; private Vector3 receivedPosition; private Vector3 leapStart; private Quaternion receivedRotation; private bool initialized; private bool havePose; private bool defeatSent; private bool registered; private bool bound; private float phaseStarted; private float nextPath; private float verticalSpeed; private float nextNavProbe; private float gait; private const float Radius = 0.25f; private const float Height = 1.2f; private const float LeapDuration = 0.65f; private int WorldMask { get { StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance != (Object)null)) { return LayerMask.GetMask(new string[3] { "Default", "Room", "Colliders" }); } return instance.collidersAndRoomMaskAndDefault; } } private void Initialize() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if (initialized) { return; } initialized = true; base.thisNetworkObject = ((Component)this).GetComponent(); if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent(); } if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).gameObject.AddComponent(); } ((Behaviour)base.agent).enabled = false; base.agent.radius = 0.25f; base.agent.height = 1.2f; base.agent.baseOffset = 0f; base.agent.acceleration = 16f; base.agent.angularSpeed = 440f; base.agent.stoppingDistance = 1.1f; base.agent.updatePosition = false; base.agent.updateRotation = false; base.path1 = new NavMeshPath(); base.agentMask = -1; base.removedPowerLevel = true; base.enemyHP = Math.Max(1, base.enemyHP); base.ventAnimationFinished = true; base.exitVentAnimationTime = 0f; base.stunNormalizedTimer = -1f; base.postStunInvincibilityTimer = -1f; base.currentOwnershipOnThisClient = ((!((NetworkBehaviour)this).IsServer) ? (-1) : 0); base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; base.enemyBehaviourStates = (EnemyBehaviourState[])(((object)base.enemyBehaviourStates) ?? ((object)new EnemyBehaviourState[0])); Transform val = ((Component)this).transform.Find("GollumVisual"); visual = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : RingVisualFactory.CreateGollum(((Component)this).transform)); visualRest = visual.transform.localPosition; Transform[] componentsInChildren = visual.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (!joints.ContainsKey(((Object)val2).name)) { joints[((Object)val2).name] = new Joint { transform = val2, rest = val2.localRotation }; } } base.meshRenderers = ((Component)this).GetComponentsInChildren(true); base.skinnedMeshRenderers = ((Component)this).GetComponentsInChildren(true); if (joints.TryGetValue("head", out var value)) { base.eye = value.transform; } else { base.eye = ((Component)this).transform; } if ((Object)(object)base.creatureVoice == (Object)null) { base.creatureVoice = ((Component)this).gameObject.AddComponent(); } base.creatureVoice.playOnAwake = false; base.creatureVoice.spatialBlend = 1f; base.creatureVoice.rolloffMode = (AudioRolloffMode)1; base.creatureVoice.minDistance = 1.5f; base.creatureVoice.maxDistance = 22f; if ((Object)(object)base.creatureSFX == (Object)null) { base.creatureSFX = base.creatureVoice; } lastAnimatedPosition = (receivedPosition = ((Component)this).transform.position); receivedRotation = ((Component)this).transform.rotation; } private void Enroll() { RoundManager instance = RoundManager.Instance; if (!((Object)(object)instance == (Object)null) && ((NetworkBehaviour)this).IsSpawned && !registered) { if (!instance.SpawnedEnemies.Contains((EnemyAI)(object)this)) { instance.SpawnedEnemies.Add((EnemyAI)(object)this); } int numberOfEnemiesInScene = instance.numberOfEnemiesInScene; instance.numberOfEnemiesInScene = numberOfEnemiesInScene + 1; base.thisEnemyIndex = numberOfEnemiesInScene; registered = true; } } private void Unenroll() { RoundManager instance = RoundManager.Instance; if ((Object)(object)instance != (Object)null && instance.SpawnedEnemies != null) { instance.SpawnedEnemies.Remove((EnemyAI)(object)this); } registered = false; } public override void Start() { Initialize(); Enroll(); if (!((NetworkBehaviour)this).IsServer && ((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); Initialize(); Enroll(); base.currentOwnershipOnThisClient = ((!((NetworkBehaviour)this).IsServer) ? (-1) : 0); RingNet.ActorSpawned(this); } public override void OnNetworkDespawn() { Unenroll(); if ((Object)(object)base.agent != (Object)null) { ((Behaviour)base.agent).enabled = false; } RingNet.ActorDespawned(this); ((NetworkBehaviour)this).OnNetworkDespawn(); } public override void OnDestroy() { Unenroll(); base.removedPowerLevel = true; base.inSpecialAnimationWithPlayer = null; base.inSpecialAnimation = false; try { ((EnemyAI)this).OnDestroy(); } catch (NullReferenceException) when ((Object)(object)RoundManager.Instance == (Object)null) { } } public void Bind(ulong ring, int generation, int wearer) { Initialize(); if (!bound || RingId != ring || Generation != generation || WearerSlot != wearer) { bound = true; RingId = ring; Generation = generation; WearerSlot = wearer; base.isEnemyDead = false; defeatSent = false; recentHits.Clear(); SetPhase(RingEncounterState.Stalking); } } public void SetPhase(RingEncounterState phase) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Initialize(); if (Phase == phase) { return; } Phase = phase; phaseStarted = Time.time; base.inSpecialAnimation = phase == RingEncounterState.Leaping || phase == RingEncounterState.Clinging; switch (phase) { case RingEncounterState.Leaping: leapStart = ((Component)this).transform.position; verticalSpeed = 0f; if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } break; case RingEncounterState.Clinging: verticalSpeed = 0f; if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } break; case RingEncounterState.Off: case RingEncounterState.Departed: if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } break; default: nextNavProbe = 0f; break; } } public override void Update() { //IL_00b1: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) Initialize(); if (!((NetworkBehaviour)this).IsSpawned) { return; } float num = Mathf.Clamp(Time.deltaTime, 0f, 0.1f); base.timeSinceSpawn += num; if (base.stunNormalizedTimer > -1f) { base.stunNormalizedTimer -= num; } if (base.postStunInvincibilityTimer > -1f) { base.postStunInvincibilityTimer -= num; } if (!((NetworkBehaviour)this).IsServer) { if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } if (havePose) { float num2 = 1f - Mathf.Exp((0f - num) * 18f); ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, receivedPosition, num2); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, receivedRotation, num2); } } Animate(num); } public void ApplyPose(Vector3 position, Quaternion rotation, RingEncounterState phase) { //IL_000e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) Initialize(); if (!((NetworkBehaviour)this).IsServer && Finite(position)) { SetPhase(phase); if (!havePose) { ((Component)this).transform.SetPositionAndRotation(position, rotation); havePose = true; } receivedPosition = position; receivedRotation = rotation; base.serverPosition = position; } } private static bool Finite(Vector3 value) { //IL_0000: 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_001a: 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_0034: 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) if (!float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z)) { return !float.IsInfinity(value.z); } return false; } private static Vector3 Chest(PlayerControllerB player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) return ((Component)player).transform.position + Vector3.up * 0.25f + ((Component)player).transform.forward * 0.45f; } public bool Touching(PlayerControllerB player) { //IL_0019: 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_0036: 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) if ((Object)(object)player == (Object)null || player.isPlayerDead) { return false; } if (Vector3.Distance(((Component)this).transform.position, Chest(player)) <= 0.45f && Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) <= 0.85f) { return Sees(player); } return false; } public bool Sees(PlayerControllerB player) { //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_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_0038: 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_0047: 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) if ((Object)(object)player == (Object)null || player.isPlayerDead) { return false; } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.9f; Vector3 val2 = ((Component)player).transform.position + Vector3.up; RaycastHit val3 = default(RaycastHit); if (!Physics.Linecast(val, val2, ref val3, WorldMask, (QueryTriggerInteraction)1)) { return true; } if (!IsSelf(((RaycastHit)(ref val3)).collider)) { return (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)player; } return true; } public bool Grounded() { //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_0046: 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) Initialize(); if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { return true; } RaycastHit val = default(RaycastHit); if (Physics.SphereCast(((Component)this).transform.position + Vector3.up * 0.35f, 0.17f, Vector3.down, ref val, 0.5f, WorldMask, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).normal.y >= 0.55f; } return false; } public void HostTick(PlayerControllerB wearer, float dt) { //IL_0035: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) Initialize(); if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned || base.isEnemyDead || (Object)(object)wearer == (Object)null || wearer.isPlayerDead || !Finite(((Component)wearer).transform.position)) { return; } dt = Mathf.Clamp(dt, 0f, 0.1f); base.targetPlayer = wearer; base.isOutside = !wearer.isInsideFactory; if (base.stunNormalizedTimer > 0f || base.stunnedIndefinitely > 0) { if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.nextPosition = ((Component)this).transform.position; } } else if (Phase == RingEncounterState.Leaping) { if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } float num = Mathf.Clamp01((Time.time - phaseStarted) / 0.65f); Vector3 val = Vector3.Lerp(leapStart, Chest(wearer), num) + Vector3.up * Mathf.Sin(num * MathF.PI) * 0.85f; MoveSafely(val - ((Component)this).transform.position, wearer); Face(((Component)wearer).transform.position - ((Component)this).transform.position, dt, 16f); } else if (Phase == RingEncounterState.Clinging) { if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } MoveSafely(Vector3.ClampMagnitude(Chest(wearer) - ((Component)this).transform.position, Mathf.Max(0.05f, 16f * dt)), wearer); Face(-((Component)wearer).transform.forward, dt, 22f); } else { if (Phase != RingEncounterState.Stalking && Phase != RingEncounterState.Recovering) { return; } if (Phase == RingEncounterState.Recovering) { if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.isStopped = true; base.agent.nextPosition = ((Component)this).transform.position; } ApplyGravity(dt); return; } EnsureNavMesh(); float num2 = Mathf.Clamp(Plugin.CreatureSpeed.Value, 1f, 8f); if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.speed = num2; base.agent.isStopped = false; if (Time.time >= nextPath) { nextPath = Time.time + 0.15f; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)wearer).transform.position, ref val2, 1.2f, base.agent.areaMask)) { base.agent.SetDestination(((NavMeshHit)(ref val2)).position); } else { base.agent.isStopped = true; } } if (!base.agent.isStopped && !base.agent.pathPending) { Vector3 desiredVelocity = base.agent.desiredVelocity; if (!Finite(desiredVelocity)) { base.agent.isStopped = true; base.agent.nextPosition = ((Component)this).transform.position; return; } Vector3 val3 = Vector3.ClampMagnitude(desiredVelocity * dt, num2 * dt); NavMeshQueryFilter val4 = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref val4)).agentTypeID = base.agent.agentTypeID; ((NavMeshQueryFilter)(ref val4)).areaMask = base.agent.areaMask; NavMeshQueryFilter val5 = val4; NavMeshHit val6 = default(NavMeshHit); if (Finite(val3) && NavMesh.SamplePosition(((Component)this).transform.position + val3, ref val6, 0.35f, val5)) { Vector3 val7 = ((NavMeshHit)(ref val6)).position - (((Component)this).transform.position + val3); val7.y = 0f; if (((Vector3)(ref val7)).sqrMagnitude <= 0.01f) { val3.y = Mathf.Clamp(((NavMeshHit)(ref val6)).position.y - ((Component)this).transform.position.y, (0f - num2) * dt, num2 * dt); } } MoveSafely(Vector3.ClampMagnitude(val3, num2 * dt), wearer); Face(desiredVelocity, dt, 10f); } base.agent.nextPosition = ((Component)this).transform.position; return; } Vector3 direction = ((Component)wearer).transform.position - ((Component)this).transform.position; direction.y = 0f; if (((Vector3)(ref direction)).magnitude > 1.05f) { Vector3 val8 = ((Vector3)(ref direction)).normalized * Mathf.Min(num2 * dt, ((Vector3)(ref direction)).magnitude - 1.05f); RaycastHit val9 = default(RaycastHit); if (Physics.Raycast(((Component)this).transform.position + val8 + Vector3.up * 0.5f, Vector3.down, ref val9, 1f, WorldMask, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val9)).normal.y >= 0.55f && Mathf.Abs(((RaycastHit)(ref val9)).point.y - ((Component)this).transform.position.y) <= 0.45f) { MoveSafely(new Vector3(val8.x, Mathf.Clamp(((RaycastHit)(ref val9)).point.y - ((Component)this).transform.position.y, -0.1f, 0.1f), val8.z), wearer); } Face(direction, dt, 10f); } ApplyGravity(dt); } } private void EnsureNavMesh() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { return; } if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } if (Time.time < nextNavProbe) { return; } nextNavProbe = Time.time + 1f; NavMeshQueryFilter val = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref val)).agentTypeID = base.agent.agentTypeID; ((NavMeshQueryFilter)(ref val)).areaMask = base.agent.areaMask; NavMeshQueryFilter val2 = val; NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val3, 0.45f, val2) && !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.5f, ((NavMeshHit)(ref val3)).position + Vector3.up * 0.5f, WorldMask, (QueryTriggerInteraction)1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val3)).position; ((Behaviour)base.agent).enabled = true; if (!base.agent.isOnNavMesh) { ((Behaviour)base.agent).enabled = false; } else { base.agent.Warp(((NavMeshHit)(ref val3)).position); } } } private bool IsSelf(Collider collider) { if ((Object)(object)collider != (Object)null) { if (!((Object)(object)((Component)collider).transform == (Object)(object)((Component)this).transform)) { return ((Component)collider).transform.IsChildOf(((Component)this).transform); } return true; } return false; } private void MoveSafely(Vector3 movement, PlayerControllerB wearer = null) { //IL_0010: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector3)(ref movement)).magnitude; if (magnitude < 1E-05f || !Finite(movement)) { return; } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.25f; Vector3 val2 = ((Component)this).transform.position + Vector3.up * 0.95000005f; int num = Physics.CapsuleCastNonAlloc(val, val2, 0.25f, movement / magnitude, castHits, magnitude + 0.015f, WorldMask, (QueryTriggerInteraction)1); float num2 = magnitude; for (int i = 0; i < num; i++) { RaycastHit val3 = castHits[i]; if (!((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) && !IsSelf(((RaycastHit)(ref val3)).collider) && (!((Object)(object)wearer != (Object)null) || !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent() == (Object)(object)wearer))) { num2 = Mathf.Min(num2, Mathf.Max(0f, ((RaycastHit)(ref val3)).distance - 0.015f)); } } Transform transform = ((Component)this).transform; transform.position += movement / magnitude * num2; } private void ApplyGravity(float dt) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { verticalSpeed = (Grounded() ? (-2f) : Mathf.Max(-20f, verticalSpeed - 26f * dt)); MoveSafely(Vector3.up * verticalSpeed * dt); } } private void Face(Vector3 direction, float dt, float speed) { //IL_0027: 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_002d: 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) direction.y = 0f; if (!(((Vector3)(ref direction)).sqrMagnitude < 0.0001f)) { ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(direction), 1f - Mathf.Exp((0f - speed) * dt)); } } private void Pose(string name, Vector3 angles) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (joints.TryGetValue(name, out var value)) { value.transform.localRotation = value.rest * Quaternion.Euler(angles); } } private void Animate(float dt) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)visual == (Object)null)) { float num = ((dt > 0.0001f) ? (Vector3.Distance(((Component)this).transform.position, lastAnimatedPosition) / dt) : 0f); lastAnimatedPosition = ((Component)this).transform.position; float num2 = Mathf.Clamp01(num / 2.5f); gait += dt * (4f + num2 * 8f); float num3 = Mathf.Sin(gait); float num4 = Mathf.Sin(Time.time * 14f); bool flag = Phase == RingEncounterState.Leaping; bool flag2 = Phase == RingEncounterState.Clinging; visual.transform.localPosition = visualRest + Vector3.up * (Mathf.Abs(num3) * 0.025f * num2); Pose("hips", new Vector3(0f, 0f, num3 * 4f * num2)); Pose("spine", new Vector3((float)(flag ? (-8) : (flag2 ? (-12) : 0)), num3 * 4f * num2, 0f)); Pose("head", new Vector3(flag2 ? (-12f) : (Mathf.Sin(Time.time * 2.5f) * 3f), Mathf.Sin(Time.time * 1.8f) * 7f, flag2 ? (num4 * 4f) : 0f)); Pose("leftArm", new Vector3(flag ? (-75f) : (flag2 ? (-115f) : (num3 * 28f * num2)), (float)(flag2 ? (-20) : 0), (float)(flag2 ? (-25) : (-8)))); Pose("rightArm", new Vector3(flag ? (-75f) : (flag2 ? (-115f) : ((0f - num3) * 28f * num2)), (float)(flag2 ? 20 : 0), (float)(flag2 ? 25 : 8))); Pose("leftForearm", new Vector3(flag2 ? (-35f + num4 * 8f) : ((float)(flag ? (-15) : (-10))), 0f, 0f)); Pose("rightForearm", new Vector3(flag2 ? (-35f - num4 * 8f) : ((float)(flag ? (-15) : (-10))), 0f, 0f)); Pose("leftLeg", new Vector3(flag2 ? (-65f) : (flag ? (-30f) : ((0f - num3) * 32f * num2)), 0f, (float)(flag2 ? (-12) : 0))); Pose("rightLeg", new Vector3(flag2 ? (-65f) : (flag ? (-30f) : (num3 * 32f * num2)), 0f, (float)(flag2 ? 12 : 0))); Pose("leftShin", new Vector3(flag2 ? 65f : (Mathf.Max(0f, num3) * 30f * num2), 0f, 0f)); Pose("rightShin", new Vector3(flag2 ? 65f : (Mathf.Max(0f, 0f - num3) * 30f * num2), 0f, 0f)); } } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { Initialize(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || defeatSent || force <= 0) { return; } long key = ((long)(((Object)(object)playerWhoHit == (Object)null) ? (-1) : ((int)playerWhoHit.playerClientId)) << 32) ^ (uint)hitID; float now = Time.realtimeSinceStartup; if (recentHits.TryGetValue(key, out var value) && now - value < 0.15f) { return; } if (recentHits.Count >= 64) { long[] array = (from pair in recentHits where now - pair.Value >= 0.15f select pair.Key).ToArray(); foreach (long key2 in array) { recentHits.Remove(key2); } } recentHits[key] = now; base.enemyHP = Math.Max(0, base.enemyHP - Mathf.Clamp(force, 1, 100)); RingNet.CreatureHit(this); if (playHitSFX && (Object)(object)base.enemyType != (Object)null && (Object)(object)base.enemyType.hitBodySFX != (Object)null) { base.creatureSFX.PlayOneShot(base.enemyType.hitBodySFX); } if (base.enemyHP <= 0) { ((EnemyAI)this).KillEnemy(false); } } public override void KillEnemy(bool destroy = false) { Initialize(); if (base.isEnemyDead || defeatSent) { return; } if (!((NetworkBehaviour)this).IsServer) { RingNet.RequestDefeat(this); return; } defeatSent = true; base.isEnemyDead = true; if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } RingNet.CreatureDefeated(this); } } internal static class NativeRingInventory { private static readonly MethodInfo Select = typeof(PlayerControllerB).GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[2] { typeof(int), typeof(GrabbableObject) }, null); private static readonly MethodInfo Sync = typeof(PlayerControllerB).GetMethod("SwitchToSlotServerRpc", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null); internal static bool TryDropRing(PlayerControllerB player, GrabbableObject ring) { //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)ring == (Object)null || !((NetworkBehaviour)player).IsOwner || !player.isPlayerControlled || player.isPlayerDead || (Object)(object)ring.playerHeldBy != (Object)(object)player || player.isGrabbingObjectAnimation || player.inSpecialInteractAnimation || player.inTerminalMenu || player.isClimbingLadder) { return false; } int num = ((player.ItemSlots == null) ? (-1) : Array.IndexOf(player.ItemSlots, ring)); if (num < 0 && (Object)(object)player.ItemOnlySlot == (Object)(object)ring) { num = 50; } if (num < 0) { return false; } try { if (player.currentItemSlot != num) { if (player.twoHanded || Select == null || Sync == null) { return false; } Select.Invoke(player, new object[2] { num, null }); Sync.Invoke(player, new object[1] { num }); } if (player.currentItemSlot != num || (Object)(object)player.currentlyHeldObjectServer != (Object)(object)ring || (Object)(object)ring.playerHeldBy != (Object)(object)player) { return false; } player.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Ring konnte nicht normal abgelegt werden; kein anderes Item wird fallengelassen: " + ex.Message)); return false; } } } [BepInPlugin("tgamert.meinschatz", "Mein Schatz", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Plugin Instance; internal static GameObject RingPrefab; internal static GameObject CreaturePrefab; internal static ConfigEntry CreatureSpeed; internal static ConfigEntry Damage; internal static ConfigEntry ShopPrice; internal static ConfigEntry ShipDelivery; internal static ConfigEntry WearDamage; internal static ConfigEntry WearInterval; internal static ConfigEntry WearCanKill; private Harmony harmony; private void Awake() { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; CreatureSpeed = ((BaseUnityPlugin)this).Config.Bind("Comedy", "GollumSpeed", 3.8f, "Laufgeschwindigkeit des Ringjaegers."); Damage = ((BaseUnityPlugin)this).Config.Bind("Comedy", "ClingDamage", 3, "Schaden pro Klammerimpuls. Laesst mindestens 1 HP uebrig; 0 fuer reine Comedy."); ShopPrice = ((BaseUnityPlugin)this).Config.Bind("Ring", "ShopPrice", 10, "Ringpreis im Terminal-Shop."); ShipDelivery = ((BaseUnityPlugin)this).Config.Bind("Ring", "FirstRoundRing", true, "Beim ersten Einsatz einer Lobby einen kostenlosen Ring auf den Schiffsboden legen."); WearDamage = ((BaseUnityPlugin)this).Config.Bind("Ring", "WearDamage", 1, "Lebenspunkteverlust pro Zehrungsimpuls beim Tragen (0 bis 10). Host entscheidet."); WearInterval = ((BaseUnityPlugin)this).Config.Bind("Ring", "WearDamageInterval", 2f, "Sekunden zwischen Zehrungsimpulsen (0.5 bis 30). Host entscheidet."); WearCanKill = ((BaseUnityPlugin)this).Config.Bind("Ring", "WearDrainCanKill", true, "Die langsame Ringzehrung darf toedlich sein. False laesst mindestens 1 HP uebrig."); BuildPrefabs(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); harmony = new Harmony("tgamert.meinschatz"); harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Mein Schatz 0.2.0: Unsichtbarkeit, Lebenszehrung und Gollum registriert."); } private void OnDestroy() { RingWearEffects.ClearAll(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private static void BuildPrefabs() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) RingPrefab = NetworkPrefabs.CreateNetworkPrefab("TGamerT.MeinSchatz.Ring.v1"); RingPrefab.layer = 6; RingPrefab.tag = "PhysicsProp"; GameObject val = RingVisualFactory.CreateRing(RingPrefab.transform); AudioSource obj = RingPrefab.AddComponent(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.maxDistance = 15f; Rigidbody val2 = RingPrefab.AddComponent(); val2.isKinematic = true; val2.useGravity = false; BoxCollider val3 = RingPrefab.AddComponent(); val3.size = new Vector3(0.27f, 0.12f, 0.27f); val3.center = new Vector3(0f, 0.04f, 0f); Item val4 = ScriptableObject.CreateInstance(); ((Object)val4).name = "TGamerT.MeinSchatz.Ring.Asset"; val4.itemName = "Der Eine Ring"; val4.spawnPrefab = RingPrefab; val4.weight = 1.01f; val4.itemSpawnsOnGround = true; val4.canBeGrabbedBeforeGameStart = true; val4.twoHanded = false; val4.requiresBattery = false; val4.automaticallySetUsingPower = false; val4.syncUseFunction = false; val4.syncInteractLRFunction = false; val4.holdButtonUse = false; val4.isScrap = false; val4.creditsWorth = Math.Max(0, ShopPrice.Value); val4.grabSFX = MetalSound(); val4.dropSFX = val4.grabSFX; val4.toolTips = new string[3] { "Ring an/aus : Hauptaktion", "Abschuetteln : Zusatzaktion 1 / springen", "Ring ueberlassen : Zusatzaktion 2" }; val4.positionOffset = new Vector3(0.04f, 0.03f, 0.08f); val4.rotationOffset = new Vector3(0f, 0f, 0f); val4.verticalOffset = 0.06f; CursedRingItem cursedRingItem = RingPrefab.AddComponent(); ((GrabbableObject)cursedRingItem).itemProperties = val4; ((GrabbableObject)cursedRingItem).grabbable = true; ((GrabbableObject)cursedRingItem).grabbableToEnemies = true; ((GrabbableObject)cursedRingItem).propBody = val2; ((GrabbableObject)cursedRingItem).propColliders = (Collider[])(object)new Collider[1] { (Collider)val3 }; ((GrabbableObject)cursedRingItem).mainObjectRenderer = val.GetComponentInChildren(); ((GrabbableObject)cursedRingItem).originalScale = Vector3.one; GameObject val5 = new GameObject("ScanNode") { layer = 22 }; val5.transform.SetParent(RingPrefab.transform, false); val5.transform.localPosition = Vector3.up * 0.1f; BoxCollider obj2 = val5.AddComponent(); ((Collider)obj2).isTrigger = true; obj2.size = Vector3.one * 0.3f; ScanNodeProperties obj3 = val5.AddComponent(); obj3.headerText = "Der Eine Ring"; obj3.subText = "Unsichtbar. Zehrt beim Tragen an deinem Leben."; obj3.nodeType = 0; obj3.minRange = 0; obj3.maxRange = 20; obj3.requiresLineOfSight = true; Items.RegisterShopItem(val4, Math.Max(0, ShopPrice.Value)); CreaturePrefab = NetworkPrefabs.CreateNetworkPrefab("TGamerT.MeinSchatz.Gollum.v1"); CreaturePrefab.layer = 19; RingVisualFactory.CreateGollum(CreaturePrefab.transform); NavMeshAgent val6 = CreaturePrefab.AddComponent(); ((Behaviour)val6).enabled = false; val6.radius = 0.24f; val6.height = 1.15f; val6.speed = Mathf.Clamp(CreatureSpeed.Value, 1f, 8f); val6.acceleration = 16f; val6.angularSpeed = 360f; val6.stoppingDistance = 1.1f; GollumActor gollumActor = CreaturePrefab.AddComponent(); ((EnemyAI)gollumActor).agent = val6; EnemyType val7 = ScriptableObject.CreateInstance(); val7.enemyName = "Gollum"; val7.enemyPrefab = CreaturePrefab; val7.canDie = true; val7.PowerLevel = 0f; ((EnemyAI)gollumActor).enemyType = val7; ((EnemyAI)gollumActor).enemyHP = 3; GameObject val8 = new GameObject("GollumHitbox") { layer = 19 }; val8.transform.SetParent(CreaturePrefab.transform, false); CapsuleCollider obj4 = val8.AddComponent(); ((Collider)obj4).isTrigger = true; obj4.radius = 0.3f; obj4.height = 1.25f; obj4.center = Vector3.up * 0.65f; EnemyAICollisionDetect obj5 = val8.AddComponent(); obj5.mainScript = (EnemyAI)(object)gollumActor; obj5.alwaysAllowHitting = true; obj5.onlyCollideWhenGrounded = false; Log.LogInfo((object)"Stabile Ring-/Gollum-Prefabs erstellt; beide Seiten brauchen dieselbe Modversion."); } private static AudioClip MetalSound() { float[] array = new float[4410]; for (int i = 0; i < array.Length; i++) { float num = (float)i / 22050f; array[i] = Mathf.Exp((0f - num) * 30f) * (Mathf.Sin(num * 1900f * MathF.PI * 2f) * 0.12f + Mathf.Sin(num * 3713f * MathF.PI * 2f) * 0.06f); } AudioClip obj = AudioClip.Create("RingClink", array.Length, 1, 22050, false); obj.SetData(array, 0); return obj; } } internal static class RingAudio { private static readonly AudioClip[] clips = (AudioClip[])(object)new AudioClip[5]; internal static void Initialize() { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); string[] array = new string[5] { "warning", "pounce", "cling", "stolen", "hit" }; for (int i = 0; i < array.Length; i++) { try { clips[i] = ReadWave(Path.Combine(directoryName, "audio", array[i] + ".wav")); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Gollum-Ton nicht geladen: " + array[i] + ": " + ex.Message)); } } } internal static void Play(int cue, Vector3 position) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0090: Expected O, but got Unknown if (cue >= 0 && cue < clips.Length && !((Object)(object)clips[cue] == (Object)null)) { GameObject val = new GameObject("GollumStimme"); val.transform.position = position; AudioSource obj = val.AddComponent(); obj.spatialBlend = 1f; obj.minDistance = 2f; obj.maxDistance = 24f; obj.volume = 0.8f; obj.playOnAwake = false; obj.PlayOneShot(clips[cue]); Object.Destroy((Object)val, clips[cue].length + 0.25f); } } private static AudioClip ReadWave(string path) { BinaryReader reader = new BinaryReader(File.OpenRead(path)); try { if (Four() != "RIFF") { throw new InvalidDataException("Kein RIFF"); } reader.ReadInt32(); if (Four() != "WAVE") { throw new InvalidDataException("Kein WAV"); } int num = 44100; int num2 = 1; int num3 = 16; int num4 = 1; byte[] array = null; while (reader.BaseStream.Position + 8 <= reader.BaseStream.Length) { string text = Four(); int num5 = reader.ReadInt32(); long num6 = reader.BaseStream.Position + num5; if (num5 < 0 || num6 > reader.BaseStream.Length) { throw new InvalidDataException("WAV-Laenge"); } if (text == "fmt ") { num4 = reader.ReadInt16(); num2 = reader.ReadInt16(); num = reader.ReadInt32(); reader.ReadInt32(); reader.ReadInt16(); num3 = reader.ReadInt16(); } if (text == "data") { array = reader.ReadBytes(num5); } reader.BaseStream.Position = Math.Min(reader.BaseStream.Length, num6 + (num5 & 1)); } if (array == null || num4 != 1 || num3 != 16 || num2 < 1 || num2 > 2 || num < 8000 || num > 96000) { throw new InvalidDataException("PCM16 erwartet"); } float[] array2 = new float[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f; } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), array2.Length / num2, num2, num, false); obj.SetData(array2, 0); return obj; } finally { if (reader != null) { ((IDisposable)reader).Dispose(); } } string Four() { return new string(reader.ReadChars(4)); } } } public sealed class RingNet : MonoBehaviour { private sealed class Encounter { internal CursedRingItem Ring; internal GollumActor Actor; internal RingEncounterPolicy Policy; internal readonly RingWearDrain Drain = new RingWearDrain(); internal int Slot; internal int Sequence; internal int Generation; internal bool Wearing; internal bool Shake; internal bool PendingTake; internal float NextSend; internal float RemoveAt; internal float TakeUntil; internal float NextRequest; } private const string Channel = "TGamerT.MeinSchatz.v2"; private static RingNet instance; private static readonly Dictionary rings = new Dictionary(); private readonly Dictionary encounters = new Dictionary(); private readonly Dictionary snapshots = new Dictionary(); private readonly Dictionary received = new Dictionary(); private CustomMessagingManager messaging; private NetworkManager manager; private StartOfRound round; private int epoch = 1; private int generationSerial; private bool delivered; private bool leaving; private static int epochValue => instance?.epoch ?? 0; private static bool Server { get { if ((Object)(object)NetworkManager.Singleton != (Object)null) { return NetworkManager.Singleton.IsServer; } return false; } } internal static bool IsWearingRing(PlayerControllerB player) { if ((Object)(object)player != (Object)null && !player.isPlayerDead && (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening) { return rings.Values.Any((CursedRingItem r) => (Object)(object)r != (Object)null && ((NetworkBehaviour)r).IsSpawned && r.Wearing && ((GrabbableObject)r).isHeld && (Object)(object)((GrabbableObject)r).playerHeldBy == (Object)(object)player); } return false; } internal static PlayerControllerB[] Wearers() { return (from r in rings.Values where (Object)(object)r != (Object)null && (Object)(object)((GrabbableObject)r).playerHeldBy != (Object)null && IsWearingRing(((GrabbableObject)r).playerHeldBy) select ((GrabbableObject)r).playerHeldBy).Distinct().ToArray(); } private void Awake() { instance = this; RingAudio.Initialize(); } internal static void RingSpawned(CursedRingItem ring) { rings[((NetworkBehaviour)ring).NetworkObjectId] = ring; if ((Object)(object)instance != (Object)null) { instance.ApplyCached(); } } internal static void RingDespawned(CursedRingItem ring) { ring.Wearing = false; ulong networkObjectId = ((NetworkBehaviour)ring).NetworkObjectId; rings.Remove(networkObjectId); if (!((Object)(object)instance == (Object)null)) { if (instance.encounters.TryGetValue(networkObjectId, out var value)) { instance.RemoveActor(value); instance.encounters.Remove(networkObjectId); } instance.snapshots.Remove(networkObjectId); string suffix = ":" + networkObjectId; string[] array = instance.received.Keys.Where((string k) => k.EndsWith(suffix, StringComparison.Ordinal)).ToArray(); foreach (string key in array) { instance.received.Remove(key); } } } public static void ActorSpawned(GollumActor actor) { if ((Object)(object)instance != (Object)null) { instance.ApplyCached(); } } public static void ActorDespawned(GollumActor actor) { } public static void CreatureDefeated(GollumActor actor) { if (!((Object)(object)instance == (Object)null) && Server && instance.encounters.TryGetValue(actor.RingId, out var value) && !((Object)(object)value.Actor != (Object)(object)actor) && value.Policy.HasWearer) { instance.Commands(value, value.Policy.Relinquish((ulong)value.Slot, epochValue, Time.time, authoritative: true)); instance.Broadcast(value, reliable: true); } } public static void CreatureHit(GollumActor actor) { if ((Object)(object)instance != (Object)null && Server && instance.encounters.TryGetValue(actor.RingId, out var value) && (Object)(object)value.Actor == (Object)(object)actor) { instance.Cue(value, 4); } } public static void RequestDefeat(GollumActor actor) { if (!((Object)(object)actor == (Object)null)) { SendHost(new RingPacket { Kind = RingMessage.Defeat, Ring = actor.RingId, Creature = ((NetworkBehaviour)actor).NetworkObjectId, Generation = actor.Generation, Slot = LocalSlot() }); } } private static int LocalSlot() { if (!((Object)(object)GameNetworkManager.Instance?.localPlayerController != (Object)null)) { return -1; } return (int)GameNetworkManager.Instance.localPlayerController.playerClientId; } public static void Request(CursedRingItem ring, RingMessage kind) { if (!((Object)(object)ring == (Object)null) && ((NetworkBehaviour)ring).IsSpawned && !((Object)(object)((GrabbableObject)ring).playerHeldBy == (Object)null)) { SendHost(new RingPacket { Kind = kind, Ring = ((NetworkBehaviour)ring).NetworkObjectId, Slot = (int)((GrabbableObject)ring).playerHeldBy.playerClientId }); } } private unsafe static void SendHost(RingPacket packet) { //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_0054: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)instance == (Object)null || (Object)(object)singleton == (Object)null || !singleton.IsListening) { return; } if (singleton.IsServer) { instance.Handle(singleton.LocalClientId, packet); return; } FastBufferWriter val = packet.Write(); try { singleton.CustomMessagingManager.SendNamedMessage("TGamerT.MeinSchatz.v2", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void Send(ulong client, RingPacket packet, bool reliable = true) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)manager == (Object)null || !manager.IsServer || messaging == null) { return; } if (client == manager.LocalClientId) { Handle(0uL, packet); return; } FastBufferWriter val = packet.Write(); try { messaging.SendNamedMessage("TGamerT.MeinSchatz.v2", client, val, (NetworkDelivery)((!reliable) ? 1 : 3)); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void Receive(ulong sender, FastBufferReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { Handle(sender, RingPacket.Read(reader)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Ring-Nachricht verworfen: " + ex.Message)); } } private void Update() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_025d: 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) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening) { if (messaging != null) { messaging.UnregisterNamedMessageHandler("TGamerT.MeinSchatz.v2"); messaging = null; Clear(); } return; } if (singleton.CustomMessagingManager != messaging) { if (messaging != null) { messaging.UnregisterNamedMessageHandler("TGamerT.MeinSchatz.v2"); } manager = singleton; messaging = singleton.CustomMessagingManager; messaging.RegisterNamedMessageHandler("TGamerT.MeinSchatz.v2", new HandleNamedMessageDelegate(Receive)); if (!Server) { SendHost(new RingPacket { Kind = RingMessage.Sync, Slot = LocalSlot() }); } } if ((Object)(object)StartOfRound.Instance != (Object)(object)round) { if ((Object)(object)round != (Object)null) { ((UnityEvent)(object)round.PlayerJumpEvent).RemoveListener((UnityAction)OnJump); } Clear(); round = StartOfRound.Instance; epoch++; delivered = false; if ((Object)(object)round != (Object)null) { ((UnityEvent)(object)round.PlayerJumpEvent).AddListener((UnityAction)OnJump); } } ApplyCached(); if (!Server || (Object)(object)round == (Object)null) { return; } Encounter[] array; if (round.shipIsLeaving || round.firingPlayersCutsceneRunning) { if (!leaving) { leaving = true; array = encounters.Values.ToArray(); foreach (Encounter encounter in array) { Commands(encounter, encounter.Policy.Relinquish((ulong)encounter.Slot, epoch, Time.time, authoritative: true)); encounter.Wearing = false; Broadcast(encounter, reliable: true); } } } else { leaving = false; } if (!delivered && Plugin.ShipDelivery.Value && (Object)(object)round.localPlayerController != (Object)null && round.localPlayerController.isPlayerControlled && (Object)(object)round.middleOfShipNode != (Object)null) { delivered = true; Object.Instantiate(Plugin.RingPrefab, round.middleOfShipNode.position + Vector3.up * 0.3f, Quaternion.identity).GetComponent().Spawn(false); Plugin.Log.LogInfo((object)"Ein kostenloser Film-Ring liegt im Schiff. Weitere Ringe im Shop."); } array = encounters.Values.ToArray(); foreach (Encounter e in array) { if ((Object)(object)e.Ring == (Object)null || !((NetworkBehaviour)e.Ring).IsSpawned) { RemoveActor(e); encounters.Remove(((Object)(object)e.Ring == (Object)null) ? encounters.FirstOrDefault((KeyValuePair p) => p.Value == e).Key : ((NetworkBehaviour)e.Ring).NetworkObjectId); continue; } PlayerControllerB val = Player(e.Slot); if ((Object)(object)val == (Object)null || val.isPlayerDead || !((GrabbableObject)e.Ring).isHeld || (Object)(object)((GrabbableObject)e.Ring).playerHeldBy != (Object)(object)val || leaving) { e.Wearing = false; } if (e.Policy.HasWearer) { if ((Object)(object)e.Actor != (Object)null && ((EnemyAI)e.Actor).stunNormalizedTimer > 0f) { Commands(e, e.Policy.Relinquish((ulong)e.Slot, epoch, Time.time, authoritative: true)); } bool flag = ((GrabbableObject)e.Ring).isHeld && (Object)(object)((GrabbableObject)e.Ring).playerHeldBy == (Object)(object)val; RingEncounterFrame frame = new RingEncounterFrame { Authoritative = true, RoundId = epoch, WearerId = (ulong)e.Slot, Now = Time.time, Wearing = (e.Wearing && flag && !leaving), Alive = ((Object)(object)val != (Object)null && !val.isPlayerDead), Health = (((Object)(object)val != (Object)null) ? val.health : 0), Distance = (((Object)(object)e.Actor != (Object)null && (Object)(object)val != (Object)null) ? Vector3.Distance(((Component)e.Actor).transform.position, ((Component)val).transform.position) : 100f), Grounded = ((Object)(object)e.Actor != (Object)null && e.Actor.Grounded()), LineOfSight = ((Object)(object)e.Actor != (Object)null && (Object)(object)val != (Object)null && e.Actor.Sees(val)), TouchingWearer = ((Object)(object)e.Actor != (Object)null && (Object)(object)val != (Object)null && e.Actor.Touching(val)), Shake = e.Shake }; e.Shake = false; Commands(e, e.Policy.Tick(frame)); } int num = e.Drain.Tick(Server, e.Wearing && ((GrabbableObject)e.Ring).isHeld && (Object)(object)((GrabbableObject)e.Ring).playerHeldBy == (Object)(object)val && !leaving, (Object)(object)val != (Object)null && !val.isPlayerDead, e.Slot, e.Generation, Time.time, ((Object)(object)val != (Object)null) ? val.health : 0, Plugin.WearDamage.Value, Plugin.WearInterval.Value, Plugin.WearCanKill.Value); if (num > 0) { DrainWearer(e, num); } if ((Object)(object)e.Actor != (Object)null) { e.Actor.SetPhase(e.Policy.State); e.Actor.HostTick(val, Time.deltaTime); } if (e.RemoveAt > 0f && Time.time >= e.RemoveAt) { RemoveActor(e); e.RemoveAt = 0f; } if (e.PendingTake && ((!((GrabbableObject)e.Ring).isHeld && (Object)(object)e.Actor == (Object)null) || Time.time > e.TakeUntil)) { if (!((GrabbableObject)e.Ring).isHeld) { e.PendingTake = false; ((NetworkBehaviour)e.Ring).NetworkObject.Despawn(true); continue; } e.PendingTake = false; Plugin.Log.LogWarning((object)"Ringdiebstahl ohne bestaetigtes Ablegen abgebrochen; Item bleibt erhalten."); } e.Ring.Wearing = e.Wearing; if (Time.time >= e.NextSend) { e.NextSend = Time.time + 0.1f; Broadcast(e, reliable: false); } } } private void Handle(ulong sender, RingPacket p) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_056b: Unknown result type (might be due to invalid IL or missing references) if (p.Kind == RingMessage.Snapshot || p.Kind == RingMessage.Damage || p.Kind == RingMessage.Drop || p.Kind == RingMessage.Cue || p.Kind == RingMessage.Drain) { if (sender != 0L) { return; } if (p.Kind == RingMessage.Snapshot) { if (!snapshots.TryGetValue(p.Ring, out var value) || (p.Generation >= value.Generation && (p.Generation != value.Generation || p.Sequence > value.Sequence))) { snapshots[p.Ring] = p; Apply(p); } return; } string key = p.Kind.ToString() + ":" + p.Ring; if (received.TryGetValue(key, out var value2) && p.Sequence <= value2) { return; } received[key] = p.Sequence; PlayerControllerB val = Player(p.Slot); if (p.Kind == RingMessage.Cue) { RingAudio.Play(p.Amount, p.Position); } else { if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)GameNetworkManager.Instance?.localPlayerController || !rings.TryGetValue(p.Ring, out var value3) || (Object)(object)value3 == (Object)null || (Object)(object)((GrabbableObject)value3).playerHeldBy != (Object)(object)val || !snapshots.TryGetValue(p.Ring, out var value4) || value4.Generation != p.Generation) { return; } if (p.Kind == RingMessage.Drain) { if (value4.Wearing && value4.Slot == p.Slot && value3.Wearing && ((GrabbableObject)value3).isHeld && ((NetworkBehaviour)val).IsOwner) { DamageDrainLocal(val, p.Amount, p.State == 1); } } else if (p.Kind == RingMessage.Damage) { DamageLocal(val, p.Amount); } else { DropLocal(val, p.Ring); } } } else { if (!Server) { return; } if (p.Kind == RingMessage.Sync) { foreach (Encounter value8 in encounters.Values) { Send(sender, Packet(value8, RingMessage.Snapshot)); } return; } if (!rings.TryGetValue(p.Ring, out var value5) || (Object)(object)value5 == (Object)null || !((NetworkBehaviour)value5).IsSpawned) { return; } if (p.Kind == RingMessage.Defeat) { PlayerControllerB val2 = Player(p.Slot); if (encounters.TryGetValue(p.Ring, out var value6) && !((Object)(object)value6.Actor == (Object)null) && p.Creature == ((NetworkBehaviour)value6.Actor).NetworkObjectId && p.Generation == value6.Actor.Generation && !((Object)(object)val2 == (Object)null) && !val2.isPlayerDead && val2.actualClientId == sender && !(Vector3.Distance(((Component)val2).transform.position, ((Component)value6.Actor).transform.position) > 65f)) { CreatureDefeated(value6.Actor); } return; } PlayerControllerB playerHeldBy = ((GrabbableObject)value5).playerHeldBy; if ((Object)(object)playerHeldBy == (Object)null || playerHeldBy.isPlayerDead || !((GrabbableObject)value5).isHeld || ((NetworkBehaviour)value5).OwnerClientId != sender || (int)playerHeldBy.playerClientId != p.Slot) { return; } if (!encounters.TryGetValue(p.Ring, out var value7)) { value7 = new Encounter { Ring = value5, Slot = p.Slot, Policy = new RingEncounterPolicy(new RingEncounterSettings { DamagePerTick = Mathf.Clamp(Plugin.Damage.Value, 0, 25) }) }; encounters[p.Ring] = value7; } if (Time.time < value7.NextRequest) { return; } value7.NextRequest = Time.time + ((p.Kind == RingMessage.Shake) ? 0.5f : 0.35f); if (p.Kind == RingMessage.Toggle) { if (!value7.Wearing) { if (leaving || encounters.Values.Count((Encounter x) => x.Wearing) >= 3 || SlotAlreadyWearing(p.Slot)) { return; } value7.Slot = p.Slot; value7.Wearing = true; value7.RemoveAt = 0f; value7.Generation = ++generationSerial; Commands(value7, value7.Policy.BeginWear((ulong)value7.Slot, epoch, Time.time, authoritative: true)); } else { Commands(value7, value7.Policy.Relinquish((ulong)value7.Slot, epoch, Time.time, authoritative: true)); value7.Wearing = false; } } else if (p.Kind == RingMessage.Shake && value7.Wearing) { value7.Shake = true; } else if (p.Kind == RingMessage.Surrender && value7.Wearing && (Object)(object)value7.Actor != (Object)null && value7.Actor.Sees(playerHeldBy) && Vector3.Distance(((Component)value7.Actor).transform.position, ((Component)playerHeldBy).transform.position) < 4f) { Commands(value7, value7.Policy.Relinquish((ulong)value7.Slot, epoch, Time.time, authoritative: true, offerRing: true)); value7.Wearing = false; } value5.Wearing = value7.Wearing; Broadcast(value7, reliable: true); } } private RingPacket Packet(Encounter e, RingMessage kind) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) return new RingPacket { Kind = kind, Ring = ((NetworkBehaviour)e.Ring).NetworkObjectId, Creature = (((Object)(object)e.Actor != (Object)null && ((NetworkBehaviour)e.Actor).IsSpawned) ? ((NetworkBehaviour)e.Actor).NetworkObjectId : 0), Slot = e.Slot, Generation = e.Generation, State = (int)e.Policy.State, Amount = (((Object)(object)e.Actor != (Object)null && ((EnemyAI)e.Actor).isEnemyDead) ? 1 : 0), Wearing = e.Wearing, Sequence = ++e.Sequence, Position = (((Object)(object)e.Actor != (Object)null) ? ((Component)e.Actor).transform.position : ((Component)e.Ring).transform.position), Rotation = (((Object)(object)e.Actor != (Object)null) ? ((Component)e.Actor).transform.rotation : Quaternion.identity) }; } private bool SlotAlreadyWearing(int slot) { foreach (Encounter value in encounters.Values) { if (value.Wearing && value.Slot == slot) { return true; } } return false; } private void Broadcast(Encounter e, bool reliable) { RingPacket packet = Packet(e, RingMessage.Snapshot); foreach (ulong connectedClientsId in manager.ConnectedClientsIds) { Send(connectedClientsId, packet, reliable); } } private void Commands(Encounter e, RingEncounterCommand[] commands) { for (int i = 0; i < commands.Length; i++) { RingEncounterCommand ringEncounterCommand = commands[i]; switch (ringEncounterCommand.Kind) { case RingEncounterCommandKind.Warning: Cue(e, 0); break; case RingEncounterCommandKind.Spawn: if (!SpawnCreature(e)) { Commands(e, e.Policy.Relinquish((ulong)e.Slot, epoch, Time.time, authoritative: true)); } break; case RingEncounterCommandKind.Pounce: Cue(e, 1); break; case RingEncounterCommandKind.Cling: Cue(e, 2); break; case RingEncounterCommandKind.Release: if (ringEncounterCommand.Reason == RingEncounterReason.ShakenOff) { Cue(e, 4); } break; case RingEncounterCommandKind.Damage: DamageWearer(e, ringEncounterCommand.Amount); break; case RingEncounterCommandKind.TakeRing: { e.PendingTake = true; e.TakeUntil = Time.time + 2f; e.Wearing = false; Cue(e, 3); PlayerControllerB val = Player(e.Slot); if ((Object)(object)val != (Object)null) { if (Intern(val) != null) { DropNpc(val, e.Ring); break; } RingPacket packet = Packet(e, RingMessage.Drop); Send(val.actualClientId, packet); } break; } case RingEncounterCommandKind.Despawn: e.RemoveAt = Time.time + 2f; break; } } } private bool SpawnCreature(Encounter e) { //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_0044: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_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_0078: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = Player(e.Slot); if ((Object)(object)val == (Object)null) { return false; } Vector3 val2 = ((Component)val).transform.position; bool flag = false; NavMeshHit val4 = default(NavMeshHit); RaycastHit val6 = default(RaycastHit); for (int i = 0; i < 10; i++) { float num = (float)i * 137.5f * (MathF.PI / 180f); Vector3 val3 = ((Component)val).transform.position + new Vector3(Mathf.Sin(num), 0f, Mathf.Cos(num)) * (float)(val.isInHangarShipRoom ? 3 : 7); if (NavMesh.SamplePosition(val3, ref val4, 2.5f, -1)) { NavMeshPath val5 = new NavMeshPath(); if (NavMesh.CalculatePath(((Component)val).transform.position, ((NavMeshHit)(ref val4)).position, -1, val5) && (int)val5.status == 0) { val2 = ((NavMeshHit)(ref val4)).position; flag = true; break; } } if (Physics.Raycast(val3 + Vector3.up * 2f, Vector3.down, ref val6, 5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && !Physics.Linecast(((Component)val.gameplayCamera).transform.position, ((RaycastHit)(ref val6)).point + Vector3.up, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { val2 = ((RaycastHit)(ref val6)).point; flag = true; break; } } if (!flag) { Plugin.Log.LogWarning((object)"Hier kein erreichbarer Boden fuer Gollum. Ring kann erneut probiert werden."); return false; } RemoveActor(e); GameObject val7 = Object.Instantiate(Plugin.CreaturePrefab, val2, Quaternion.identity); e.Actor = val7.GetComponent(); e.Actor.Bind(((NetworkBehaviour)e.Ring).NetworkObjectId, e.Generation, e.Slot); ((EnemyAI)e.Actor).isOutside = !val.isInsideFactory; val7.GetComponent().Spawn(false); return true; } private void Cue(Encounter e, int cue) { RingPacket packet = Packet(e, RingMessage.Cue); packet.Amount = cue; foreach (ulong connectedClientsId in manager.ConnectedClientsIds) { Send(connectedClientsId, packet); } } private void DamageWearer(Encounter e, int amount) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = Player(e.Slot); if ((Object)(object)val == (Object)null || val.isPlayerDead || (Object)(object)e.Actor == (Object)null || !e.Actor.Touching(val)) { return; } amount = Math.Min(Math.Max(0, amount), Math.Max(0, val.health - 1)); if (amount != 0) { if (Intern(val) != null) { val.DamagePlayer(amount, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); return; } RingPacket packet = Packet(e, RingMessage.Damage); packet.Amount = amount; Send(val.actualClientId, packet); } } private static void DamageLocal(PlayerControllerB player, int amount) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!player.isPlayerDead) { amount = Math.Min(Math.Max(0, amount), Math.Max(0, player.health - 1)); if (amount > 0) { player.DamagePlayer(amount, true, true, (CauseOfDeath)6, 0, false, default(Vector3)); } } } private void DrainWearer(Encounter e, int amount) { PlayerControllerB val = Player(e.Slot); if (Server && e.Wearing && !((Object)(object)val == (Object)null) && !val.isPlayerDead && ((GrabbableObject)e.Ring).isHeld && !((Object)(object)((GrabbableObject)e.Ring).playerHeldBy != (Object)(object)val)) { if (Intern(val) != null) { DamageDrainLocal(val, amount, Plugin.WearCanKill.Value); return; } RingPacket packet = Packet(e, RingMessage.Drain); packet.Amount = amount; packet.State = (Plugin.WearCanKill.Value ? 1 : 0); Send(val.actualClientId, packet); } } private static void DamageDrainLocal(PlayerControllerB player, int amount, bool fatal) { //IL_0048: 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) if (!((Object)(object)player == (Object)null) && !player.isPlayerDead && IsWearingRing(player)) { amount = Math.Min(Mathf.Clamp(amount, 0, 10), Math.Max(0, player.health - ((!fatal) ? 1 : 0))); if (amount > 0) { player.DamagePlayer(amount, false, true, (CauseOfDeath)0, 0, false, default(Vector3)); } } } private void ApplyCached() { RingPacket[] array = snapshots.Values.ToArray(); foreach (RingPacket p in array) { Apply(p); } } private void Apply(RingPacket p) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (rings.TryGetValue(p.Ring, out var value) && (Object)(object)value != (Object)null) { value.Wearing = p.Wearing; } if (Server || p.Creature == 0L || (Object)(object)manager == (Object)null || !manager.SpawnManager.SpawnedObjects.TryGetValue(p.Creature, out var value2)) { return; } GollumActor component = ((Component)value2).GetComponent(); if ((Object)(object)component != (Object)null) { if (component.RingId != p.Ring || component.Generation != p.Generation || component.WearerSlot != p.Slot) { component.Bind(p.Ring, p.Generation, p.Slot); } ((EnemyAI)component).isEnemyDead = (p.Amount & 1) != 0; PlayerControllerB val = Player(p.Slot); if ((Object)(object)val != (Object)null) { ((EnemyAI)component).isOutside = !val.isInsideFactory; } component.ApplyPose(p.Position, p.Rotation, (RingEncounterState)p.State); } } private static PlayerControllerB Player(int slot) { if (StartOfRound.Instance?.allPlayerScripts == null || slot < 0 || slot >= StartOfRound.Instance.allPlayerScripts.Length) { return null; } return StartOfRound.Instance.allPlayerScripts[slot]; } private static object Intern(PlayerControllerB player) { try { object obj = Type.GetType("LethalInternship.SharedAbstractions.ManagerProviders.InternManagerProvider, LethalInternship.SharedAbstractions", throwOnError: false)?.GetProperty("Instance")?.GetValue(null); return obj?.GetType().GetMethod("GetInternAI", new Type[1] { typeof(int) })?.Invoke(obj, new object[1] { (int)player.playerClientId }); } catch { return null; } } private static void DropNpc(PlayerControllerB player, CursedRingItem ring) { object obj = Intern(player); obj?.GetType().GetMethod("DropItem", new Type[1] { typeof(GrabbableObject) })?.Invoke(obj, new object[1] { ring }); } private static void DropLocal(PlayerControllerB player, ulong ringId) { if (rings.TryGetValue(ringId, out var value) && !((Object)(object)value == (Object)null) && !((Object)(object)((GrabbableObject)value).playerHeldBy != (Object)(object)player)) { NativeRingInventory.TryDropRing(player, (GrabbableObject)(object)value); } } private void RemoveActor(Encounter e) { if ((Object)(object)e.Actor != (Object)null && ((NetworkBehaviour)e.Actor).IsSpawned && Server && NetworkManager.Singleton.IsListening) { ((NetworkBehaviour)e.Actor).NetworkObject.Despawn(true); } e.Actor = null; } private void Clear() { foreach (CursedRingItem value in rings.Values) { if ((Object)(object)value != (Object)null) { value.Wearing = false; } } RingWearEffects.ClearAll(); Encounter[] array = encounters.Values.ToArray(); foreach (Encounter e in array) { RemoveActor(e); } encounters.Clear(); snapshots.Clear(); received.Clear(); leaving = false; } private void OnJump(PlayerControllerB player) { CursedRingItem[] array = rings.Values.ToArray(); foreach (CursedRingItem cursedRingItem in array) { if ((Object)(object)cursedRingItem != (Object)null && ((NetworkBehaviour)cursedRingItem).IsOwner && cursedRingItem.Wearing && (Object)(object)((GrabbableObject)cursedRingItem).playerHeldBy == (Object)(object)player) { Request(cursedRingItem, RingMessage.Shake); } } } private void OnDestroy() { Clear(); if ((Object)(object)round != (Object)null) { ((UnityEvent)(object)round.PlayerJumpEvent).RemoveListener((UnityAction)OnJump); } if (messaging != null) { messaging.UnregisterNamedMessageHandler("TGamerT.MeinSchatz.v2"); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } } public enum RingMessage : byte { Toggle = 1, Shake, Surrender, Snapshot, Damage, Drop, Defeat, Sync, Cue, Drain } internal struct RingPacket { internal RingMessage Kind; internal ulong Ring; internal ulong Creature; internal int Generation; internal int Slot; internal int State; internal int Amount; internal int Sequence; internal bool Wearing; internal Vector3 Position; internal Quaternion Rotation; internal FastBufferWriter Write() { //IL_001d: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter result = default(FastBufferWriter); ((FastBufferWriter)(ref result))..ctor(128, (Allocator)2, -1); byte b = 2; byte kind = (byte)Kind; ((FastBufferWriter)(ref result)).WriteValueSafe(ref b, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref kind, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Ring, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Creature, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Generation, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Slot, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref State, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Amount, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Sequence, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Wearing, default(ForPrimitives)); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Position); ((FastBufferWriter)(ref result)).WriteValueSafe(ref Rotation); return result; } internal static RingPacket Read(FastBufferReader r) { //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_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) byte b = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe(ref b, default(ForPrimitives)); byte b2 = default(byte); ((FastBufferReader)(ref r)).ReadValueSafe(ref b2, default(ForPrimitives)); if (b != 2 || b2 < 1 || b2 > 10) { throw new ArgumentException("Unbekanntes Ringprotokoll"); } RingPacket result = new RingPacket { Kind = (RingMessage)b2 }; ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Ring, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Creature, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Generation, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Slot, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.State, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Amount, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Sequence, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Wearing, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Position); ((FastBufferReader)(ref r)).ReadValueSafe(ref result.Rotation); if (result.Slot < -1 || result.Slot > 255 || result.State < 0 || result.State > 6 || !Finite(result.Position.x) || !Finite(result.Position.y) || !Finite(result.Position.z) || !Finite(result.Rotation.x) || !Finite(result.Rotation.y) || !Finite(result.Rotation.z) || !Finite(result.Rotation.w)) { throw new ArgumentException("Ungueltiger Ringzustand"); } return result; } private static bool Finite(float v) { if (!float.IsNaN(v) && !float.IsInfinity(v)) { return Math.Abs(v) < 1000000f; } return false; } } internal static class RingSight { [ThreadStatic] internal static int Depth; internal static bool HiddenFrom(EnemyAI enemy, PlayerControllerB player) { if (!(enemy is GollumActor)) { return RingWearEffects.IsInvisible(player); } return false; } internal static IEnumerable Queries() { string[] names = new string[4] { "GetAllPlayersInLineOfSight", "GetAllPlayersInLineOfSightNonAlloc", "CheckLOSForTarget", "CheckLOSForClosestPlayer" }; MethodInfo[] methods = typeof(EnemyAI).GetMethods(); foreach (MethodInfo methodInfo in methods) { if (names.Contains(methodInfo.Name)) { yield return methodInfo; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("LethalInternship.Core.Interns.AI.InternAI", throwOnError: false); if (type == null) { continue; } methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (names.Contains(methodInfo2.Name)) { yield return methodInfo2; } } } } internal static PlayerControllerB Select(EnemyAI enemy, float width, int range, int proximity, bool closest, float buffer) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if (instance?.allPlayerScripts == null) { return null; } Transform val = (((Object)(object)enemy.eye != (Object)null) ? enemy.eye : ((Component)enemy).transform); if (enemy.isOutside && (Object)(object)enemy.enemyType != (Object)null && !enemy.enemyType.canSeeThroughFog && (Object)(object)TimeOfDay.Instance != (Object)null && (int)TimeOfDay.Instance.currentLevelWeather == 3) { range = Math.Min(range, 30); } PlayerControllerB val2 = null; float num = float.PositiveInfinity; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if ((Object)(object)val3 == (Object)null || (Object)(object)val3.gameplayCamera == (Object)null || HiddenFrom(enemy, val3) || !enemy.PlayerIsTargetable(val3, false, false, true)) { continue; } Vector3 position = ((Component)val3.gameplayCamera).transform.position; Vector3 val4 = position - val.position; float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude >= (float)range) && (!(Vector3.Angle(val.forward, val4) >= width) || (proximity >= 0 && !(magnitude >= (float)proximity))) && !Physics.Linecast(val.position, position, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && !Physics.Linecast(position, val.position, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { if (!closest) { return val3; } if (magnitude < num) { num = magnitude; val2 = val3; } } } if ((Object)(object)val2 != (Object)null && (Object)(object)enemy.targetPlayer != (Object)null && (Object)(object)enemy.targetPlayer != (Object)(object)val2 && !HiddenFrom(enemy, enemy.targetPlayer) && buffer > 0f && Mathf.Abs(num - Vector3.Distance(((Component)enemy).transform.position, ((Component)enemy.targetPlayer).transform.position)) < buffer) { return null; } if ((Object)(object)val2 != (Object)null) { enemy.mostOptimalDistance = num; } return val2; } } [HarmonyPatch] internal static class RingVisionScopePatch { private static IEnumerable TargetMethods() { return RingSight.Queries(); } [HarmonyPriority(800)] private static void Prefix(out int __state) { __state = RingSight.Depth + 1; RingSight.Depth++; } private static void Finalizer(int __state) { if (__state > 0) { RingSight.Depth = __state - 1; } } } [HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")] internal static class RingVisualTargetPatch { [HarmonyPriority(0)] private static void Postfix(EnemyAI __instance, PlayerControllerB playerScript, ref bool __result) { if (__result && RingSight.Depth > 0 && RingSight.HiddenFrom(__instance, playerScript)) { __result = false; } } } [HarmonyPatch] internal static class RingSingleSightPatch { private static IEnumerable TargetMethods() { return from m in typeof(EnemyAI).GetMethods() where m.Name == "CheckLineOfSightForPlayer" || m.Name == "CheckLineOfSightForClosestPlayer" select m; } [HarmonyPriority(0)] private static bool Prefix(EnemyAI __instance, MethodBase __originalMethod, object[] __args, ref PlayerControllerB __result) { if (__instance is GollumActor || !RingWearEffects.AnyInvisible) { return true; } __result = RingSight.Select(__instance, (float)__args[0], (int)__args[1], (int)__args[2], __originalMethod.Name.Contains("Closest"), (__args.Length > 3) ? ((float)__args[3]) : 0f); return false; } } [HarmonyPatch(typeof(EnemyAI), "CheckLineOfSightForPosition")] internal static class RingPositionSightPatch { private static void Postfix(EnemyAI __instance, Vector3 objectPosition, ref bool __result) { //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_003f: Unknown result type (might be due to invalid IL or missing references) if (!__result || __instance is GollumActor) { return; } PlayerControllerB[] array = RingNet.Wearers(); foreach (PlayerControllerB val in array) { if ((Object)(object)val.gameplayCamera != (Object)null) { Vector3 val2 = ((Component)val.gameplayCamera).transform.position - objectPosition; if (((Vector3)(ref val2)).sqrMagnitude < 0.0025f) { __result = false; break; } } } } } internal static class RingVisualFactory { private static Material skin; private static Material skinDark; private static Material skinLight; private static Material faceSkin; private static Material nail; private static Material eyeWhite; private static Material iris; private static Material pupil; private static Material cloth; private static Material mouth; private static Material teeth; private static Material gold; private static Material rune; private static Material hair; private static readonly float[] headY = new float[12] { -0.165f, -0.145f, -0.12f, -0.09f, -0.06f, -0.025f, 0.02f, 0.06f, 0.1f, 0.14f, 0.175f, 0.2f }; private static readonly float[] headWidth = new float[12] { 0f, 0.055f, 0.086f, 0.106f, 0.123f, 0.14f, 0.148f, 0.148f, 0.139f, 0.116f, 0.078f, 0f }; private static readonly float[] headDepth = new float[12] { 0f, 0.043f, 0.072f, 0.085f, 0.098f, 0.111f, 0.124f, 0.132f, 0.13f, 0.113f, 0.072f, 0f }; private static readonly float[] headCenter = new float[12] { 0.038f, 0.028f, 0.017f, 0.008f, 0f, -0.004f, -0.007f, -0.012f, -0.018f, -0.024f, -0.027f, -0.027f }; private static Material Material(string name, Color color, float metallic = 0f, float smoothness = 0.35f) { //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_0033: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("HDRP/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Color")) { name = name }; if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", smoothness); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } return val; } private static void EnsureMaterials() { //IL_0022: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)skin != (Object)null) { return; } skin = Material("Creature_Skin", new Color(0.6f, 0.55f, 0.49f), 0f, 0.17f); skinDark = Material("Creature_SkinDark", new Color(0.42f, 0.38f, 0.34f), 0f, 0.15f); skinLight = Material("Creature_SkinLight", new Color(0.63f, 0.58f, 0.52f), 0f, 0.18f); nail = Material("Creature_Nails", new Color(0.25f, 0.23f, 0.18f), 0f, 0.18f); eyeWhite = Material("Creature_EyeWhite", new Color(0.58f, 0.565f, 0.52f), 0f, 0.6f); iris = Material("Creature_Iris", new Color(0.78f, 0.78f, 0.78f), 0f, 0.63f); pupil = Material("Creature_Pupil", new Color(0.012f, 0.015f, 0.014f), 0f, 0.68f); cloth = Material("Creature_Loincloth", new Color(0.17f, 0.15f, 0.11f), 0f, 0.06f); mouth = Material("Creature_Mouth", new Color(0.09f, 0.058f, 0.045f), 0f, 0.12f); hair = Material("Creature_Hair", new Color(0.12f, 0.115f, 0.09f), 0f, 0.1f); Texture2D val = SkinTexture(); Material[] array = (Material[])(object)new Material[3] { skin, skinDark, skinLight }; foreach (Material val2 in array) { if (val2.HasProperty("_BaseColorMap")) { val2.SetTexture("_BaseColorMap", (Texture)(object)val); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)val); } } faceSkin = Material("Creature_FaceSkin", new Color(0.77f, 0.8f, 0.84f), 0f, 0.19f); Texture(faceSkin, FaceTexture()); Texture(iris, IrisTexture()); teeth = Material("Creature_WornTeeth", new Color(0.43f, 0.405f, 0.34f), 0f, 0.16f); gold = Material("Ring_Gold", new Color(0.95f, 0.64f, 0.15f), 1f, 0.88f); rune = Material("Ring_Engraving", new Color(0.34f, 0.12f, 0.012f), 0.55f, 0.45f); } private static Texture2D SkinTexture() { //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_001c: 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_002b: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true) { name = "Gollum_MottledSkin", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = Mathf.Sin((float)j * 0.079f + Mathf.Sin((float)i * 0.061f) * 2f) * Mathf.Sin((float)i * 0.097f - (float)j * 0.017f); float num2 = Mathf.Sin((float)j * 0.27f + (float)i * 0.19f) * Mathf.Cos((float)j * 0.113f - (float)i * 0.31f); float num3 = Mathf.Sin((float)j * 2.71f + (float)i * 1.91f) * Mathf.Sin((float)i * 2.31f - (float)j * 0.87f); float num4 = 0.82f + num * 0.085f + num2 * 0.045f + num3 * 0.025f; float num5 = Mathf.Pow(Mathf.Max(0f, Mathf.Cos((float)j * 0.31f + Mathf.Sin((float)i * 0.13f) * 2.7f)), 24f) * 0.045f; array[i * 128 + j] = new Color(num4 + num2 * 0.018f - num5, num4 - num5 * 0.65f, num4 - num * 0.025f); } } val.SetPixels(array); val.Apply(true, false); return val; } private static float Bell(float x, float center, float width) { return Mathf.Exp((0f - (x - center)) * (x - center) / (width * width)); } private static void Texture(Material material, Texture2D texture) { if (material.HasProperty("_BaseColorMap")) { material.SetTexture("_BaseColorMap", (Texture)(object)texture); } if (material.HasProperty("_MainTex")) { material.SetTexture("_MainTex", (Texture)(object)texture); } } private static float Profile(float y, float[] values) { if (y <= headY[0]) { return values[0]; } for (int i = 1; i < headY.Length; i++) { if (y <= headY[i]) { if (values != headCenter && i == 1) { return values[1] * Mathf.Sqrt(Mathf.Max(0f, 1f - Mathf.Pow((y + 0.12f) / 0.045f, 2f))) / 0.8314794f; } if (values != headCenter && i == headY.Length - 1) { return values[i - 1] * Mathf.Sqrt(Mathf.Max(0f, 1f - Mathf.Pow((y - 0.148f) / 0.052f, 2f))) / 0.854631f; } float num = headY[i] - headY[i - 1]; float t = (y - headY[i - 1]) / num; int num2 = Math.Max(0, i - 2); int num3 = Math.Min(headY.Length - 1, i + 1); float da = (values[i] - values[num2]) / (headY[i] - headY[num2]) * num; float db = (values[num3] - values[i - 1]) / (headY[num3] - headY[i - 1]) * num; return Hermite(values[i - 1], values[i], da, db, t); } } return values[^1]; } private static float Hermite(float a, float b, float da, float db, float t) { float num = t * t; float num2 = num * t; return (2f * num2 - 3f * num + 1f) * a + (num2 - 2f * num + t) * da + (-2f * num2 + 3f * num) * b + (num2 - num) * db; } private static float FaceDepth(float x, float y) { float num = Profile(y, headWidth); float num2 = ((num > 1E-05f) ? Mathf.Sqrt(Mathf.Max(0f, 1f - x * x / (num * num))) : 0f); float num3 = Profile(y, headCenter) + Profile(y, headDepth) * num2; float num4 = Mathf.Abs(x); float num5 = Bell(num4, 0.062f, 0.04f) * Bell(y, 0.016f, 0.035f); float num6 = -0.012f * num5; num6 += 0.015f * Bell(num4, 0.06f, 0.044f) * Bell(y, 0.051f - 0.12f * num4, 0.016f); num6 += 0.019f * Bell(num4, 0.104f, 0.031f) * Bell(y, -0.036f + 0.5f * (num4 - 0.07f), 0.014f); num6 -= 0.032f * Bell(num4, 0.077f, 0.031f) * Bell(y, -0.077f, 0.031f); num6 -= 0.007f * Bell(num4, 0.06f, 0.039f) * Bell(y, -0.029f, 0.008f); num6 += 0.026f * Bell(x, 0f, 0.017f) * Bell(y, -0.005f, 0.047f); num6 += 0.038f * Bell(x, 0f, 0.022f) * Bell(y, -0.039f, 0.014f); num6 += 0.02f * (Bell(x, -0.019f, 0.01f) + Bell(x, 0.019f, 0.01f)) * Bell(y, -0.046f, 0.011f); num6 += 0.02f * Bell(x, 0f, 0.058f) * Bell(y, -0.102f, 0.03f); num6 -= 0.006f * Bell(num4, 0.026f + 0.55f * Mathf.Abs(y + 0.042f), 0.005f) * Bell(y, -0.08f, 0.028f); num6 += 0.014f * Bell(x, 0.002f, 0.042f) * Bell(y, -0.145f, 0.018f); for (int i = 0; i < 4; i++) { num6 -= 0.0013f * Bell(x, 0f, 0.105f) * Bell(y, 0.078f + (float)i * 0.017f + 0.003f * Mathf.Sin(x * 34f + (float)i), 0.0022f); } num6 -= 0.002f * Bell(num4, 0.112f, 0.022f) * (Bell(y, 0.024f - (num4 - 0.09f) * 0.3f, 0.0025f) + Bell(y, 0.007f - (num4 - 0.09f) * 0.45f, 0.0025f)); return num3 + num6 * Mathf.Min(1f, num2 * 3f); } private static Texture2D FaceTexture() { //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_001c: 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_002b: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true) { name = "Gollum_AnatomicalFace", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[262144]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { float num = (float)j / 511f; float num2 = (float)i / 511f; float num3 = num * MathF.PI * 2f; float y = -0.165f + num2 * 0.365f; float num4 = Mathf.Cos(num3) * Profile(y, headWidth); float num5 = Mathf.Max(0f, Mathf.Sin(num3)); Color val2 = FaceAtlas.Sample(0.5f + num4 / 0.32f, num2); Color val3 = FaceAtlas.Sample(0.5f, 0.88f); float num6 = 0.97f + 0.035f * Mathf.Sin((float)j * 0.117f + (float)i * 0.071f) * Mathf.Cos((float)i * 0.097f - (float)j * 0.042f); float num7 = Mathf.Clamp01(num5 * 4f); array[i * 512 + j] = new Color(Mathf.Lerp(val3.r * num6, val2.r, num7), Mathf.Lerp(val3.g * num6, val2.g, num7), Mathf.Lerp(val3.b * num6, val2.b, num7)); } } val.SetPixels(array); val.Apply(true, false); return val; } private static Texture2D IrisTexture() { //IL_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 64, (TextureFormat)4, true) { name = "Gollum_RadialIris", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[8192]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 128; j++) { float num = (float)j / 127f * MathF.PI * 2f; float num2 = (float)i / 63f; float num3 = 0.025f * Mathf.Sin(num * 37f + num2 * 8f) + 0.018f * Mathf.Cos(num * 61f - num2 * 11f) + 0.012f * Mathf.Sin(num * 93f + num2 * 17f); float num4 = 1f - 0.55f * Bell(num2, 1f, 0.07f); float num5 = Bell(num2, 0.43f, 0.13f); array[i * 128 + j] = new Color((0.34f + num3 + num5 * 0.035f) * num4, (0.405f + num3 - num5 * 0.01f) * num4, (0.43f + num3 - num5 * 0.04f) * num4); } } val.SetPixels(array); val.Apply(true, false); return val; } private static void FaceUV(Mesh mesh) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3[] vertices = mesh.vertices; foreach (Vector3 val in vertices) { float num = Profile(val.y, headWidth); float num2 = Mathf.Acos(Mathf.Max(-1f, Mathf.Min(1f, val.x / Mathf.Max(num, 0.0001f)))); list.Add(new Vector2(num2 / (MathF.PI * 2f), (val.y + 0.165f) / 0.365f)); } mesh.SetUVs(0, list); } private static float EyeY(int side) { return 0.016f + ((side < 0) ? 0.0015f : 0f); } private static float EyeZ(float x, float y, int side) { float num = (x - (float)side * 0.062f) / 0.038f; float num2 = (y - EyeY(side)) / 0.036f; return 0.083f + 0.036f * Mathf.Sqrt(Mathf.Max(0f, 1f - num * num - num2 * num2)); } private static Vector3 EyeEdge(float angle, int side) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(angle); float num2 = Mathf.Sin(angle); return new Vector3((float)side * 0.062f + num * 0.034f, EyeY(side) + num2 * ((num2 > 0f) ? 0.02f : 0.017f) - (float)side * num * 0.003f, 0f); } private static Vector3 MouthEdge(float angle, float radius = 1f) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(angle); float num2 = Mathf.Sin(angle); return new Vector3(num * 0.052f * radius, -0.105f + num2 * ((num2 > 0f) ? 0.004f : 0.007f) * radius + 0.0015f * num * radius - 0.004f * num * num * radius, 0f); } private static bool InEye(float x, float y, int side) { float num = (x - (float)side * 0.062f) / 0.034f; float num2 = y - EyeY(side) + (float)side * num * 0.003f; return num * num + num2 * num2 / ((num2 > 0f) ? 0.0004f : 0.000289f) <= 1f; } private static float IrisRadius(float a, int side) { float num = 0f; float num2 = 0.0225f; for (int i = 0; i < 12; i++) { float num3 = (num + num2) * 0.5f; if (InEye((float)side * 0.062f + Mathf.Cos(a) * num3, EyeY(side) - 0.001f + Mathf.Sin(a) * num3, side)) { num = num3; } else { num2 = num3; } } return num; } private static void OpenFace(Mesh mesh) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_006b: 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[] vertices = mesh.vertices; List list = new List(); int[] triangles = mesh.triangles; for (int i = 0; i < triangles.Length; i += 3) { if (!Opening((vertices[triangles[i]] + vertices[triangles[i + 1]] + vertices[triangles[i + 2]]) * (1f / 3f)) && !Opening(vertices[triangles[i]]) && !Opening(vertices[triangles[i + 1]]) && !Opening(vertices[triangles[i + 2]])) { list.Add(triangles[i]); list.Add(triangles[i + 1]); list.Add(triangles[i + 2]); } } mesh.triangles = list.ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); static bool Opening(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) int side = ((!(p.x < 0f)) ? 1 : (-1)); float num = (Mathf.Abs(p.x) - 0.062f) / 0.038f; float num2 = (p.y - EyeY(side)) / 0.024f; float num3 = p.x / 0.064f; float num4 = (p.y + 0.105f) / 0.019f; if (p.z > 0.025f) { if (!(num * num + num2 * num2 < 1f)) { return num3 * num3 + num4 * num4 < 1f; } return true; } return false; } } private static GameObject Curve(string name, Transform parent, Func center, float radius, Material material, int steps = 14) { Mesh mesh = Surface(8, steps, delegate(float u, float v) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = center(v); Vector3 val2 = center(Mathf.Max(0f, v - 0.01f)); Vector3 val3 = center(Mathf.Min(1f, v + 0.01f)) - val2; Vector3 normalized = ((Vector3)(ref val3)).normalized; val3 = Vector3.Cross(normalized, Vector3.forward); Vector3 val4 = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { val4 = Vector3.right; } val3 = Vector3.Cross(val4, normalized); Vector3 normalized2 = ((Vector3)(ref val3)).normalized; float num = u * MathF.PI * 2f; return val + (val4 * Mathf.Cos(num) + normalized2 * Mathf.Sin(num)) * radius; }, noise: false, name); return Render(name, parent, mesh, material); } private static Mesh Surface(int longitude, int latitude, Func shape, bool noise, string label, bool reverse = false) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown List list = new List(); List list2 = new List(); List list3 = new List(); for (int i = 0; i <= latitude; i++) { for (int j = 0; j <= longitude; j++) { float num = (float)j / (float)longitude; float num2 = (float)i / (float)latitude; Vector3 val = shape(num, num2); if (noise) { val *= 1f + 0.006f * Mathf.Sin(num * MathF.PI * 10f + num2 * 7.8f) * Mathf.Sin(num * MathF.PI * 8f - num2 * 4.7f) * Mathf.Sin(num2 * MathF.PI); } list.Add(val); list2.Add(new Vector2(num, num2)); } } for (int k = 0; k < latitude; k++) { for (int l = 0; l < longitude; l++) { int num3 = k * (longitude + 1) + l; list3.Add(num3); list3.Add(num3 + longitude + 1); list3.Add(num3 + 1); list3.Add(num3 + 1); list3.Add(num3 + longitude + 1); list3.Add(num3 + longitude + 2); } } if (reverse) { for (int m = 0; m < list3.Count; m += 3) { int value = list3[m + 1]; list3[m + 1] = list3[m + 2]; list3[m + 2] = value; } } Mesh val2 = new Mesh { name = label }; val2.SetVertices(list); val2.SetUVs(0, list2); val2.SetTriangles(list3, 0); val2.RecalculateNormals(); val2.RecalculateBounds(); return val2; } private static GameObject Render(string name, Transform parent, Mesh mesh, Material material) { //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_0013: 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_003a: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent().sharedMesh = mesh; MeshRenderer obj = val.AddComponent(); ((Renderer)obj).sharedMaterial = material; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; return val; } private static Transform Joint(string name, Transform parent, Vector3 local) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = local; return val.transform; } private static GameObject Ellipsoid(string name, Transform parent, Vector3 position, Vector3 scale, Material mat, bool rough = true) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Mesh mesh = Surface(20, 14, delegate(float u, float v) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) float num = u * MathF.PI * 2f; float num2 = (1f - v) * MathF.PI; return new Vector3(Mathf.Cos(num) * Mathf.Sin(num2), Mathf.Cos(num2), Mathf.Sin(num) * Mathf.Sin(num2)); }, rough, name); GameObject obj = Render(name, parent, mesh, mat); obj.transform.localPosition = position; obj.transform.localScale = scale; return obj; } private static GameObject Bone(string name, Transform parent, Vector3 end, float startRadius, float endRadius, Material mat) { //IL_004b: 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) float length = ((Vector3)(ref end)).magnitude; Mesh mesh = Surface(18, 12, delegate(float u, float v) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) float num = u * MathF.PI * 2f; float num2 = Mathf.Lerp(startRadius, endRadius, v) * (0.68f + 0.32f * Mathf.Sin(v * MathF.PI)); return new Vector3(Mathf.Cos(num) * num2, v * length, Mathf.Sin(num) * num2); }, noise: true, name); GameObject obj = Render(name, parent, mesh, mat); obj.transform.localRotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref end)).normalized); return obj; } private static void Ear(Transform head, int side) { Mesh mesh = Surface(18, 12, delegate(float u, float v) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) float num = u * MathF.PI * 2f; float num2 = Mathf.Sin(v * MathF.PI); float num3 = ((Mathf.Cos(v * MathF.PI) > 0f) ? (0.014f * Bell(num2, 0f, 0.6f)) : 0f); return new Vector3((float)side * (0.163f + Mathf.Sin(num) * 0.024f * num2), -0.015f + Mathf.Cos(num) * 0.047f * num2, 0.003f + 0.012f * Mathf.Cos(v * MathF.PI) - num3); }, noise: true, "folded-ear", side > 0); Render((side > 0) ? "rightEar" : "leftEar", head, mesh, skin); Curve("earHelix", head, delegate(float t) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) float num = t * MathF.PI * 1.9f; return new Vector3((float)side * (0.163f + Mathf.Sin(num) * 0.0225f), -0.015f + Mathf.Cos(num) * 0.045f, 0.007f); }, 0.0018f, skin); Curve("earCrease", head, (float t) => new Vector3((float)side * (0.16f + t * 0.01f), 0.004f - t * 0.039f, 0.016f), 0.0012f, skinDark, 8); } private static void Eye(Transform head, int side) { float cx = (float)side * 0.062f; float cy = EyeY(side); Mesh mesh = Surface(56, 20, delegate(float u, float v) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = EyeEdge(u * MathF.PI * 2f, side); float num2 = Mathf.Lerp(cx, val2.x, v); float num3 = Mathf.Lerp(cy, val2.y, v); return new Vector3(num2, num3, EyeZ(num2, num3, side)); }, noise: false, "spherical-cornea-aperture"); Render("eyeWhite", head, mesh, eyeWhite); List irisUV = new List(); Mesh val = Surface(56, 20, delegate(float u, float v) { //IL_0051: 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) float num2 = u * MathF.PI * 2f; float num3 = IrisRadius(num2, side) * v; float num4 = cx + Mathf.Cos(num2) * num3; float num5 = cy - 0.001f + Mathf.Sin(num2) * num3; irisUV.Add(new Vector2(u, num3 / 0.0225f)); return new Vector3(num4, num5, EyeZ(num4, num5, side) + 0.00045f); }, noise: false, "radial-iris-on-cornea"); val.SetUVs(0, irisUV); Render("iris", head, val, iris); Mesh mesh2 = Surface(40, 10, delegate(float u, float v) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) float num2 = u * MathF.PI * 2f; float num3 = cx + Mathf.Cos(num2) * 0.009f * v; float num4 = cy - 0.001f + Mathf.Sin(num2) * 0.009f * v; return new Vector3(num3, num4, EyeZ(num3, num4, side) + 0.0008f); }, noise: false, "pupil-on-cornea"); Render("pupil", head, mesh2, pupil); bool[] array = new bool[2] { true, false }; foreach (bool upper in array) { Mesh mesh3 = Surface(40, 16, delegate(float u, float v) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) float num2 = (u + (float)((!upper) ? 1 : 0)) * MathF.PI; float num3 = Mathf.Cos(num2); float num4 = Mathf.Sin(num2); Vector3 val2 = EyeEdge(num2, side); float num5 = cx + num3 * 0.056f; float num6 = cy + num4 * (upper ? 0.045f : 0.043f) - (float)side * num3 * 0.003f; float num7 = Mathf.Lerp(val2.x, num5, v); float num8 = Mathf.Lerp(val2.y, num6, v); float num9 = num5 - val2.x; float num10 = num6 - val2.y; float num11 = 0.01f; float num12 = Hermite(da: (EyeZ(val2.x + num9 * num11, val2.y + num10 * num11, side) - EyeZ(val2.x, val2.y, side)) / num11, db: (FaceDepth(num5, num6) - FaceDepth(num5 - num9 * num11, num6 - num10 * num11)) / num11, a: EyeZ(val2.x, val2.y, side) + 0.0025f, b: FaceDepth(num5, num6), t: v); return new Vector3(num7, num8, num12); }, noise: false, upper ? "fleshy-upper-orbit" : "fleshy-lower-orbit"); FaceUV(mesh3); Render(upper ? "upperEyelid" : "lowerEyelid", head, mesh3, faceSkin); } } private static void Mouth(Transform head) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown Mesh mesh = Surface(64, 14, delegate(float u, float v) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = MouthEdge(u * MathF.PI * 2f, v); val2.z = FaceDepth(val2.x, val2.y) - 0.011f; return val2; }, noise: false, "recessed-oral-cavity"); Render("mouthOpening", head, mesh, mouth); Mesh mesh2 = Surface(64, 16, delegate(float u, float v) { //IL_0020: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) float num7 = u * MathF.PI * 2f; float num8 = Mathf.Cos(num7); float num9 = Mathf.Sin(num7); Vector3 val2 = MouthEdge(num7); float num10 = num8 * 0.077f; float num11 = -0.105f + num9 * ((num9 > 0f) ? 0.025f : 0.031f) + 0.0015f * num8 - 0.004f * num8 * num8; float num12 = Mathf.Lerp(val2.x, num10, v); float num13 = Mathf.Lerp(val2.y, num11, v); float num14 = num10 - val2.x; float num15 = num11 - val2.y; float num16 = Hermite(da: (FaceDepth(val2.x + num14 * 0.01f, val2.y + num15 * 0.01f) - FaceDepth(val2.x, val2.y)) / 0.01f, db: (FaceDepth(num10, num11) - FaceDepth(num10 - num14 * 0.01f, num11 - num15 * 0.01f)) / 0.01f, a: FaceDepth(val2.x, val2.y) + 0.0015f, b: FaceDepth(num10, num11), t: v); num16 += Mathf.Sin(v * MathF.PI) * Mathf.Sin(v * MathF.PI) * ((num9 > 0f) ? 0.0015f : 0.0025f); return new Vector3(num12, num13, num16); }, noise: false, "thin-asymmetric-lips-and-mouth-folds"); FaceUV(mesh2); Render("mouthFolds", head, mesh2, faceSkin); for (int num = 0; num < 5; num++) { float num2 = -0.04f + (float)num * 0.019f; float num3 = -0.101f + 0.002f * Mathf.Sin((float)num * 2.7f); float num4 = FaceDepth(num2, num3) - 0.002f; float num5 = 0.0045f + (float)(num % 2) * 0.0005f; float num6 = 0.006f + (float)(num % 3) * 0.0017f; Vector3[] vertices = (Vector3[])(object)new Vector3[5] { new Vector3(num2 - num5, num3, num4), new Vector3(num2 + num5, num3, num4), new Vector3(num2 + num5 * 0.8f, num3 - num6 * 0.72f, num4 + 0.001f), new Vector3(num2 + num5 * 0.15f, num3 - num6, num4 + 0.001f), new Vector3(num2 - num5 * 0.8f, num3 - num6 * 0.85f, num4 + 0.001f) }; Mesh val = new Mesh { name = "chipped-tooth" }; val.vertices = vertices; val.triangles = new int[9] { 0, 2, 1, 0, 3, 2, 0, 4, 3 }; val.RecalculateNormals(); val.RecalculateBounds(); Render("wornTooth", head, val, teeth); } } private static void Hand(Transform parent, int side) { //IL_0015: 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_006d: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) Ellipsoid("palm", parent, new Vector3(0f, -0.035f, 0.03f), new Vector3(0.054f, 0.08f, 0.027f), skin); Vector3 val = default(Vector3); for (int i = 0; i < 4; i++) { float num = ((float)i - 1.5f) * 0.028f; Transform parent2 = Joint("finger" + i, parent, new Vector3(num, -0.075f, 0.04f)); ((Vector3)(ref val))..ctor(num * 0.37f, -0.105f + Mathf.Abs((float)i - 1.5f) * 0.013f, 0.028f); Bone("fingerBone", parent2, val, 0.0125f, 0.008f, skin); Transform parent3 = Joint("fingerTip", parent2, val); Bone("bentFinger", parent3, new Vector3(0f, -0.024f, 0.025f), 0.008f, 0.005f, skin); Ellipsoid("fingernail", parent3, new Vector3(0f, -0.023f, 0.024f), new Vector3(0.006f, 0.01f, 0.003f), nail, rough: false); } Transform parent4 = Joint("thumb", parent, new Vector3((float)side * 0.045f, -0.015f, 0.025f)); Bone("thumbBone", parent4, new Vector3((float)side * 0.055f, -0.06f, 0.025f), 0.019f, 0.009f, skin); Ellipsoid("thumbNail", parent4, new Vector3((float)side * 0.05f, -0.056f, 0.029f), new Vector3(0.01f, 0.011f, 0.003f), nail, rough: false); } private static void Foot(Transform parent, int side) { //IL_0015: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Ellipsoid("longFoot", parent, new Vector3(0f, -0.015f, 0.06f), new Vector3(0.055f, 0.035f, 0.1f), skin); for (int i = 0; i < 5; i++) { float num = (float)(i - 2) * 0.022f; float num2 = 0.14f - (float)Mathf.Abs(i - 1) * 0.01f; Ellipsoid("toe" + i, parent, new Vector3(num, -0.014f, num2), new Vector3(0.016f, 0.02f, 0.04f - (float)i * 0.003f), skin); Ellipsoid("toeNail" + i, parent, new Vector3(num, -0.002f, num2 + 0.026f), new Vector3(0.01f, 0.004f, 0.011f), nail, rough: false); } } private static void Rag(Transform hips, bool front) { //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown float num = (front ? 1 : (-1)); Vector3[] array = (Vector3[])(object)new Vector3[7] { new Vector3(-0.12f, 0.025f, num * 0.08f), new Vector3(0.12f, 0.025f, num * 0.08f), new Vector3(0.1f, -0.19f, num * 0.14f), new Vector3(0.033f, -0.235f, num * 0.15f), new Vector3(-0.018f, -0.201f, num * 0.155f), new Vector3(-0.08f, -0.23f, num * 0.14f), new Vector3(-0.12f, -0.15f, num * 0.12f) }; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length * 2]; Array.Copy(array, 0, array2, 0, array.Length); Array.Copy(array, 0, array2, array.Length, array.Length); List list = new List(); for (int i = 1; i < array.Length - 1; i++) { list.Add(0); list.Add(i); list.Add(i + 1); list.Add(array.Length); list.Add(array.Length + i + 1); list.Add(array.Length + i); } Mesh val = new Mesh { name = "torn-loincloth" }; val.vertices = array2; val.triangles = list.ToArray(); val.RecalculateNormals(); val.RecalculateBounds(); Render(front ? "frontRag" : "backRag", hips, val, cloth); } private static GameObject Creature() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0025: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GollumVisual"); Transform val2 = Joint("hips", val.transform, new Vector3(0f, 0.54f, -0.075f)); Ellipsoid("pelvis", val2, new Vector3(0f, 0f, 0f), new Vector3(0.115f, 0.12f, 0.085f), skin); Transform parent = Joint("spine", val2, new Vector3(0f, 0.18f, 0.065f)); Mesh mesh = Surface(32, 28, delegate(float u, float v) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) float num6 = u * MathF.PI * 2f; float num7 = -0.18f + v * 0.34f; float num8 = 0.083f + 0.057f * Bell(num7, 0.075f, 0.13f); float num9 = 0.058f + 0.019f * Bell(num7, 0.085f, 0.1f); float num10 = Mathf.Sqrt(Mathf.Max(0f, 1f - Mathf.Pow(v * 2f - 1f, 8f))); num8 *= num10; num9 *= num10; float num11 = Mathf.Cos(num6) * num8; float num12 = Mathf.Sin(num6) * num9 + 0.025f + v * 0.07f; if (Mathf.Sin(num6) > 0f) { float num13 = 0f; for (int j = 0; j < 5; j++) { num13 += 0.0024f * Bell(num7, 0.085f - (float)j * 0.031f + 0.07f * Mathf.Abs(num11), 0.006f); } num12 += Mathf.Sin(num6) * (num13 - 0.009f * Bell(num11, 0f, 0.034f) * Bell(num7, -0.04f, 0.09f)); } return new Vector3(num11, num7, num12); }, noise: true, "sunken-chest-under-skin"); Render("gauntTorso", parent, mesh, skin); Curve("leftCollarbone", parent, (float t) => new Vector3(-0.015f - t * 0.115f, 0.105f - 0.028f * t, 0.144f - 0.021f * t), 0.003f, skinLight); Curve("rightCollarbone", parent, (float t) => new Vector3(0.015f + t * 0.115f, 0.105f - 0.028f * t, 0.144f - 0.021f * t), 0.003f, skinLight); Transform parent2 = Joint("neckBase", parent, new Vector3(0f, 0.105f, 0.105f)); Bone("neck", parent2, new Vector3(0f, 0.11f, 0.14f), 0.046f, 0.044f, skin); Transform val3 = Joint("head", parent, new Vector3(0f, 0.215f, 0.245f)); val3.localScale = new Vector3(0.88f, 0.98f, 0.95f); Mesh mesh2 = Surface(144, 104, delegate(float u, float v) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) float num6 = u * MathF.PI * 2f; float num7 = -0.165f + v * 0.365f; float num8 = Mathf.Cos(num6) * Profile(num7, headWidth); float num9 = ((Mathf.Sin(num6) >= 0f) ? FaceDepth(num8, num7) : (Profile(num7, headCenter) + Mathf.Sin(num6) * Profile(num7, headDepth))); return new Vector3(num8, num7, num9); }, noise: false, "anatomical-cranium-cheekbones-nose-and-jaw"); OpenFace(mesh2); Render("sculptedHead", val3, mesh2, faceSkin); Eye(val3, -1); Eye(val3, 1); Ear(val3, -1); Ear(val3, 1); for (int num = -1; num <= 1; num += 2) { float num2 = (float)num * 0.017f; float num3 = -0.05f; Ellipsoid("nostril", val3, new Vector3(num2, num3, FaceDepth(num2, num3) + 0.0005f), new Vector3(0.0045f, 0.0017f, 0.001f), mouth, rough: false); } Mouth(val3); for (int i = 0; i < 11; i++) { float num4 = (float)i / 11f * MathF.PI * 2f; Vector3 start = new Vector3(Mathf.Cos(num4) * 0.105f, 0.145f, Mathf.Sin(num4) * 0.06f - 0.025f); Curve("stringyHair", val3, (float t) => new Vector3(start.x * (1f + 0.26f * Mathf.Sin(t * MathF.PI * 0.75f)), start.y - t * (0.19f + (float)(i % 3) * 0.018f), start.z - (1f - Mathf.Cos(t * MathF.PI * 0.5f)) * 0.09f), 0.0007f, hair, 12); } Vector3 val4 = default(Vector3); Vector3 val5 = default(Vector3); Vector3 val6 = default(Vector3); Vector3 val7 = default(Vector3); for (int num5 = -1; num5 <= 1; num5 += 2) { string obj = ((num5 < 0) ? "left" : "right"); Transform parent3 = Joint(obj + "Arm", parent, new Vector3((float)num5 * 0.146f, 0.102f, 0.105f)); Ellipsoid("shoulder", parent3, new Vector3(0f, -0.015f, 0f), new Vector3(0.038f, 0.05f, 0.038f), skin); ((Vector3)(ref val4))..ctor((float)num5 * 0.08f, -0.255f, 0.075f); Bone("upperArm", parent3, val4, 0.041f, 0.028f, skin); Transform parent4 = Joint(obj + "Forearm", parent3, val4); Ellipsoid("elbow", parent4, Vector3.zero, new Vector3(0.026f, 0.031f, 0.027f), skin); ((Vector3)(ref val5))..ctor((float)num5 * 0.018f, -0.25f, 0.14f); Bone("forearm", parent4, val5, 0.03f, 0.019f, skin); Transform obj2 = Joint(obj + "Hand", parent4, val5); obj2.localRotation = Quaternion.Euler(-18f, (float)(num5 * -9), (float)(num5 * 8)); Hand(obj2, num5); Transform parent5 = Joint(obj + "Leg", val2, new Vector3((float)num5 * 0.105f, -0.025f, 0f)); ((Vector3)(ref val6))..ctor((float)num5 * 0.055f, -0.19f, 0.235f); Bone("thigh", parent5, val6, 0.059f, 0.035f, skin); Transform parent6 = Joint(obj + "Shin", parent5, val6); Ellipsoid("knee", parent6, new Vector3(0f, 0f, 0.008f), new Vector3(0.033f, 0.03f, 0.027f), skin); ((Vector3)(ref val7))..ctor((float)(-num5) * 0.015f, -0.25f, -0.03f); Bone("shin", parent6, val7, 0.036f, 0.023f, skin); Transform obj3 = Joint(obj + "Foot", parent6, val7); obj3.localRotation = Quaternion.Euler(0f, (float)(num5 * 12), 0f); Foot(obj3, num5); } Rag(val2, front: true); Rag(val2, front: false); Ellipsoid("ragBelt", val2, new Vector3(0f, 0.022f, 0f), new Vector3(0.118f, 0.013f, 0.087f), cloth, rough: false); return val; } private static void RuneStroke(List points, List indices, float angle, Vector2 a, Vector2 b) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00d8: Unknown result type (might be due to invalid IL or missing references) int count = points.Count; float num = b.x - a.x; float num2 = b.y - a.y; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = (0f - num2) / num3 * 0.00065f; float num5 = num / num3 * 0.00065f; for (int i = 0; i <= 6; i++) { for (int j = -1; j <= 1; j += 2) { float num6 = (float)i / 6f; float num7 = Mathf.Lerp(a.x, b.x, num6) + num4 * (float)j; float num8 = Mathf.Lerp(a.y, b.y, num6) + num5 * (float)j; float num9 = 0.135f + Mathf.Sqrt(0.00062500004f - num8 * num8) + 0.00018f; float num10 = angle + num7 / num9; points.Add(new Vector3(Mathf.Cos(num10) * num9, num8, Mathf.Sin(num10) * num9)); } } for (int k = 0; k < 12; k += 2) { indices.Add(count + k); indices.Add(count + k + 2); indices.Add(count + k + 1); indices.Add(count + k + 1); indices.Add(count + k + 2); indices.Add(count + k + 3); } } private static GameObject Ring() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_00d3: 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_0100: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RingVisual"); Mesh mesh = Surface(96, 18, delegate(float u, float v) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) float num2 = u * MathF.PI * 2f; float num3 = v * MathF.PI * 2f; return new Vector3((0.135f + 0.025f * Mathf.Cos(num3)) * Mathf.Cos(num2), 0.025f * Mathf.Sin(num3), (0.135f + 0.025f * Mathf.Cos(num3)) * Mathf.Sin(num2)); }, noise: false, "gold-ring"); Render("OneRing", val.transform, mesh, gold); List list = new List(); List list2 = new List(); for (int num = 0; num < 32; num++) { float angle = ((float)num + 0.5f) * MathF.PI * 2f / 32f; RuneStroke(list, list2, angle, new Vector2(0f, -0.009f), new Vector2(0f, 0.009f)); RuneStroke(list, list2, angle, new Vector2(0f, 0.002f), new Vector2((float)((num % 2 == 0) ? 1 : (-1)) * 0.005f, 0.007f)); if (num % 3 == 0) { RuneStroke(list, list2, angle, new Vector2(-0.004f, -0.004f), new Vector2(0f, 0.001f)); } } Mesh val2 = new Mesh { name = "curved-engraving" }; val2.SetVertices(list); val2.SetTriangles(list2, 0); val2.RecalculateNormals(); val2.RecalculateBounds(); Render("engravedRunes", val.transform, val2, rune); return val; } public static GameObject CreateRing(Transform parent) { EnsureMaterials(); GameObject obj = Ring(); obj.transform.SetParent(parent, false); return obj; } public static GameObject CreateGollum(Transform parent) { EnsureMaterials(); GameObject obj = Creature(); obj.transform.SetParent(parent, false); return obj; } } [DefaultExecutionOrder(32000)] internal sealed class RingWearEffects : MonoBehaviour { private static readonly VisibilityLease meshes = new VisibilityLease((Renderer r) => r.forceRenderingOff, delegate(Renderer r, bool v) { r.forceRenderingOff = v; }, (Renderer r) => (Object)(object)r != (Object)null); private static readonly VisibilityLease names = new VisibilityLease((Canvas c) => !((Behaviour)c).enabled, delegate(Canvas c, bool v) { ((Behaviour)c).enabled = !v; }, (Canvas c) => (Object)(object)c != (Object)null); internal static bool AnyInvisible => RingNet.Wearers().Length != 0; internal static bool IsInvisible(PlayerControllerB player) { if ((Object)(object)player != (Object)null && !player.isPlayerDead) { return RingNet.IsWearingRing(player); } return false; } private void LateUpdate() { meshes.Begin(); names.Begin(); PlayerControllerB[] array = RingNet.Wearers(); foreach (PlayerControllerB val in array) { Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (Renderer target in componentsInChildren) { meshes.Hide(target); } if (val.ItemSlots != null) { GrabbableObject[] itemSlots = val.ItemSlots; for (int j = 0; j < itemSlots.Length; j++) { HideItem(itemSlots[j], val); } } HideItem(val.currentlyHeldObjectServer, val); meshes.Hide((Renderer)(object)val.mapRadarDirectionIndicator); names.Hide(val.usernameCanvas); } meshes.End(); names.End(); } private static void HideItem(GrabbableObject item, PlayerControllerB player) { if ((Object)(object)item != (Object)null && item.isHeld && (Object)(object)item.playerHeldBy == (Object)(object)player) { Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); foreach (Renderer target in componentsInChildren) { meshes.Hide(target); } } } internal static void ClearAll() { meshes.Restore(); names.Restore(); } private void OnDisable() { ClearAll(); } private void OnDestroy() { ClearAll(); } } internal sealed class RingWearDrain { private bool active; private int slot; private int generation; private double next; internal void Stop() { active = false; } internal int Tick(bool server, bool wearing, bool alive, int wearer, int version, double now, int health, int damage, double interval, bool fatal) { if (!server) { return 0; } if (!wearing || !alive || health <= 0 || double.IsNaN(now) || double.IsInfinity(now)) { Stop(); return 0; } interval = ((double.IsNaN(interval) || double.IsInfinity(interval)) ? 2.0 : Math.Max(0.5, Math.Min(30.0, interval))); damage = Math.Max(0, Math.Min(10, damage)); if (!active || slot != wearer || generation != version) { active = true; slot = wearer; generation = version; next = now + interval; return 0; } if (now < next) { return 0; } next = now + interval; return Math.Min(damage, Math.Max(0, health - ((!fatal) ? 1 : 0))); } } internal sealed class VisibilityLease where T : class { private readonly Dictionary originals = new Dictionary(); private readonly HashSet touched = new HashSet(); private readonly Func read; private readonly Func alive; private readonly Action write; internal VisibilityLease(Func read, Action write, Func alive) { this.read = read; this.write = write; this.alive = alive; } internal void Hide(T target) { if (target != null && alive(target)) { if (!originals.ContainsKey(target)) { originals.Add(target, read(target)); } touched.Add(target); write(target, arg2: true); } } internal void Begin() { touched.Clear(); } internal void End() { List list = new List(); foreach (KeyValuePair original in originals) { if (!touched.Contains(original.Key)) { if (alive(original.Key)) { write(original.Key, original.Value); } list.Add(original.Key); } } foreach (T item in list) { originals.Remove(item); } } internal void Restore() { foreach (KeyValuePair original in originals) { if (alive(original.Key)) { write(original.Key, original.Value); } } originals.Clear(); } } public enum RingEncounterState { Off, Dormant, Stalking, Leaping, Clinging, Recovering, Departed } public enum RingEncounterCommandKind { Warning, Spawn, Pursue, Pounce, Cling, Damage, Release, TakeRing, Despawn } public enum RingEncounterReason { None, RingRemoved, Surrendered, WearerDied, RoundChanged, Transferred, MissedLeap, ShakenOff, StoleRing, LostContact } public sealed class RingEncounterSettings { public double SpawnDelaySeconds = 2.7; public double PounceDistance = 3.2; public double ContactDistance = 0.85; public double LeapSeconds = 0.65; public double PounceCooldownSeconds = 4.0; public double RecoverySeconds = 1.25; public double ClingSeconds = 6.5; public int ShakesToRelease = 3; public double ShakeDebounceSeconds = 0.5; public int DamagePerTick = 3; public double DamageIntervalSeconds = 1.5; public bool StealOnTimeout = true; } public struct RingEncounterFrame { public bool Authoritative; public int RoundId; public ulong WearerId; public double Now; public bool Wearing; public bool Alive; public int Health; public double Distance; public bool LineOfSight; public bool Grounded; public bool TouchingWearer; public bool Shake; } public struct RingEncounterCommand { public readonly RingEncounterCommandKind Kind; public readonly RingEncounterReason Reason; public readonly ulong WearerId; public readonly int RoundId; public readonly int Generation; public readonly int Amount; public readonly double DurationSeconds; internal RingEncounterCommand(RingEncounterCommandKind kind, RingEncounterReason reason, ulong wearer, int round, int generation, int amount = 0, double duration = 0.0) { Kind = kind; Reason = reason; WearerId = wearer; RoundId = round; Generation = generation; Amount = amount; DurationSeconds = duration; } } public sealed class RingEncounterPolicy { private static readonly RingEncounterCommand[] Empty = new RingEncounterCommand[0]; private readonly double spawnDelay; private readonly double pounceDistance; private readonly double contactDistance; private readonly double leapSeconds; private readonly double pounceCooldown; private readonly double recoverySeconds; private readonly double clingSeconds; private readonly double shakeDebounce; private readonly double damageInterval; private readonly int shakesRequired; private readonly int damagePerTick; private readonly bool stealOnTimeout; private bool spawned; private double lastTime; private double due; private double nextPounce; private double nextDamage; private double lastShake; public RingEncounterState State { get; private set; } public bool HasWearer { get; private set; } public ulong WearerId { get; private set; } public int RoundId { get; private set; } public int Generation { get; private set; } public int ShakeCount { get; private set; } public double StateStartedAt { get; private set; } public double NextActionAt => due; public RingEncounterPolicy(RingEncounterSettings settings = null) { RingEncounterSettings ringEncounterSettings = settings ?? new RingEncounterSettings(); spawnDelay = Bound(ringEncounterSettings.SpawnDelaySeconds, 2.0, 4.0, 2.7); pounceDistance = Bound(ringEncounterSettings.PounceDistance, 0.5, 3.2, 3.2); contactDistance = Bound(ringEncounterSettings.ContactDistance, 0.1, Math.Min(1.0, pounceDistance), 0.85); leapSeconds = Bound(ringEncounterSettings.LeapSeconds, 0.2, 1.5, 0.65); pounceCooldown = Bound(ringEncounterSettings.PounceCooldownSeconds, 1.0, 30.0, 4.0); recoverySeconds = Bound(ringEncounterSettings.RecoverySeconds, 0.5, 8.0, 1.25); clingSeconds = Bound(ringEncounterSettings.ClingSeconds, 1.0, 8.0, 6.5); shakesRequired = Math.Max(1, Math.Min(10, ringEncounterSettings.ShakesToRelease)); shakeDebounce = Bound(ringEncounterSettings.ShakeDebounceSeconds, 0.5, 3.0, 0.5); damagePerTick = Math.Max(0, Math.Min(25, ringEncounterSettings.DamagePerTick)); damageInterval = Bound(ringEncounterSettings.DamageIntervalSeconds, 0.5, 8.0, 1.5); stealOnTimeout = ringEncounterSettings.StealOnTimeout; State = RingEncounterState.Off; lastTime = double.NegativeInfinity; lastShake = double.NegativeInfinity; } private static bool Finite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } private static double Bound(double value, double minimum, double maximum, double fallback) { if (!Finite(value)) { return Math.Max(minimum, Math.Min(maximum, fallback)); } return Math.Max(minimum, Math.Min(maximum, value)); } private void Add(List output, RingEncounterCommandKind kind, RingEncounterReason reason = RingEncounterReason.None, int amount = 0, double duration = 0.0) { output.Add(new RingEncounterCommand(kind, reason, WearerId, RoundId, Generation, amount, duration)); } private void Change(RingEncounterState state, double now, double wait = 0.0) { State = state; StateStartedAt = now; due = now + wait; } private void End(List output, RingEncounterReason reason, double now, bool take) { if (take) { Add(output, RingEncounterCommandKind.TakeRing, reason); } if (State == RingEncounterState.Clinging || State == RingEncounterState.Leaping) { Add(output, RingEncounterCommandKind.Release, reason); } if (spawned) { Add(output, RingEncounterCommandKind.Despawn, reason); } spawned = false; HasWearer = false; ShakeCount = 0; Change(RingEncounterState.Departed, now); } public RingEncounterCommand[] BeginWear(ulong wearerId, int roundId, double now, bool authoritative) { if (!authoritative || !Finite(now)) { return Empty; } if (HasWearer && wearerId == WearerId && roundId == RoundId) { return Empty; } List list = new List(); if (HasWearer) { End(list, (roundId == RoundId) ? RingEncounterReason.Transferred : RingEncounterReason.RoundChanged, now, take: false); } WearerId = wearerId; RoundId = roundId; HasWearer = true; Generation++; ShakeCount = 0; spawned = false; lastTime = now; nextPounce = now; lastShake = double.NegativeInfinity; Change(RingEncounterState.Dormant, now, spawnDelay); Add(list, RingEncounterCommandKind.Warning, RingEncounterReason.None, 0, spawnDelay); return list.ToArray(); } public RingEncounterCommand[] Relinquish(ulong wearerId, int roundId, double now, bool authoritative, bool offerRing = false) { if (!authoritative || !Finite(now) || !HasWearer || wearerId != WearerId || roundId != RoundId || now < lastTime) { return Empty; } lastTime = now; List list = new List(); End(list, (!offerRing) ? RingEncounterReason.RingRemoved : RingEncounterReason.Surrendered, now, offerRing && spawned); return list.ToArray(); } public RingEncounterCommand[] Tick(RingEncounterFrame frame) { if (!frame.Authoritative || !HasWearer || !Finite(frame.Now)) { return Empty; } List list = new List(); if (frame.RoundId != RoundId) { End(list, RingEncounterReason.RoundChanged, frame.Now, take: false); return list.ToArray(); } if (frame.WearerId != WearerId || frame.Now < lastTime) { return Empty; } lastTime = frame.Now; if (!frame.Alive || frame.Health <= 0) { End(list, RingEncounterReason.WearerDied, frame.Now, take: false); return list.ToArray(); } if (!frame.Wearing) { End(list, RingEncounterReason.RingRemoved, frame.Now, take: false); return list.ToArray(); } switch (State) { case RingEncounterState.Dormant: if (frame.Now >= due) { spawned = true; Change(RingEncounterState.Stalking, frame.Now); Add(list, RingEncounterCommandKind.Spawn); Add(list, RingEncounterCommandKind.Pursue); } break; case RingEncounterState.Stalking: if (frame.Now >= nextPounce && Finite(frame.Distance) && frame.Distance >= 0.0 && frame.Distance <= pounceDistance && frame.LineOfSight && frame.Grounded) { Change(RingEncounterState.Leaping, frame.Now, leapSeconds); nextPounce = frame.Now + pounceCooldown; Add(list, RingEncounterCommandKind.Pounce, RingEncounterReason.None, 0, leapSeconds); } break; case RingEncounterState.Leaping: if (frame.TouchingWearer && frame.LineOfSight && Finite(frame.Distance) && frame.Distance >= 0.0 && frame.Distance <= contactDistance) { Change(RingEncounterState.Clinging, frame.Now, clingSeconds); ShakeCount = 0; lastShake = double.NegativeInfinity; nextDamage = frame.Now + damageInterval; Add(list, RingEncounterCommandKind.Cling, RingEncounterReason.None, 0, clingSeconds); } else if (frame.Now >= due) { Change(RingEncounterState.Recovering, frame.Now, recoverySeconds); Add(list, RingEncounterCommandKind.Release, RingEncounterReason.MissedLeap); } break; case RingEncounterState.Clinging: if (!frame.TouchingWearer || !frame.LineOfSight || !Finite(frame.Distance) || frame.Distance < 0.0 || frame.Distance > contactDistance) { Add(list, RingEncounterCommandKind.Release, RingEncounterReason.LostContact); Change(RingEncounterState.Recovering, frame.Now, recoverySeconds); nextPounce = frame.Now + pounceCooldown; break; } if (frame.Shake && frame.Now - lastShake >= shakeDebounce) { lastShake = frame.Now; ShakeCount++; } if (ShakeCount >= shakesRequired) { Add(list, RingEncounterCommandKind.Release, RingEncounterReason.ShakenOff); Change(RingEncounterState.Recovering, frame.Now, recoverySeconds); nextPounce = frame.Now + pounceCooldown; } else if (frame.Now >= due) { if (stealOnTimeout) { End(list, RingEncounterReason.StoleRing, frame.Now, take: true); break; } Add(list, RingEncounterCommandKind.Release); Change(RingEncounterState.Recovering, frame.Now, recoverySeconds); nextPounce = frame.Now + pounceCooldown; } else if (frame.Now >= nextDamage) { int num = Math.Min(damagePerTick, Math.Max(0, frame.Health - 1)); if (num > 0) { Add(list, RingEncounterCommandKind.Damage, RingEncounterReason.None, num); } nextDamage = frame.Now + damageInterval; } break; case RingEncounterState.Recovering: if (frame.Now >= due) { Change(RingEncounterState.Stalking, frame.Now); Add(list, RingEncounterCommandKind.Pursue); } break; } if (list.Count != 0) { return list.ToArray(); } return Empty; } } }