using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Xml; using System.Xml.Serialization; using BepInEx; using BepInEx.Configuration; using DreadRifts.Core; using DreadRifts.Runtime; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Ketanol")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4")] [assembly: AssemblyProduct("DreadRifts")] [assembly: AssemblyTitle("DreadRifts")] [assembly: InternalsVisibleTo("DreadRifts.RuntimeProbe")] [assembly: AssemblyVersion("0.1.4.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 DreadRifts { [BepInPlugin("ketanol.dreadrifts", "DreadRifts", "0.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "ketanol.dreadrifts"; public const string Version = "0.1.4"; internal static Plugin Instance; internal RiftServer Server; internal RiftClient Client; internal RiftWire Wire; internal ConfigEntry MenuKey; internal ConfigEntry EffectsIntensity; private Harmony harmony; private void Awake() { //IL_0021: 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_006e: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown Instance = this; MenuKey = ((BaseUnityPlugin)this).Config.Bind("Controls", "Expedition menu", new KeyboardShortcut((KeyCode)289, Array.Empty()), "Open your current expedition. The gate also opens this menu."); EffectsIntensity = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Effects intensity", 1f, new ConfigDescription("Local particle density and light intensity for DreadRifts objects. Does not change combat or other world objects.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1.5f), Array.Empty())); Wire = new RiftWire(); Server = new RiftServer(this); Client = new RiftClient(this); PrefabManager.OnVanillaPrefabsAvailable += RiftAssets.Register; harmony = new Harmony("ketanol.dreadrifts"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DreadRifts development build 0.1.4"); } private void Update() { Client.TickUI(); try { if (!Object.op_Implicit((Object)(object)ZNet.instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance) || !Object.op_Implicit((Object)(object)ObjectDB.instance)) { Server.Reset(); Client.Reset(); return; } if (ZNet.instance.IsServer()) { Server.Tick(); } Client.Tick(); } catch (Exception error) { Fail(error); } } internal void Fail(Exception error) { ((BaseUnityPlugin)this).Logger.LogError((object)error); } internal void LogInfo(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } private void OnDisable() { Client?.Close(); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RiftAssets.Register; Client?.Reset(); Server?.Reset(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Instance = null; } } } namespace DreadRifts.Runtime { internal sealed class ArenaBiomeServices : MonoBehaviour { private Vector3[] anchors; private Transform[] wispModels; public GameObject Campfire { get; private set; } public Demister[] Wisps { get; private set; } = (Demister[])(object)new Demister[0]; public static ArenaBiomeServices Create(ArenaGeometry geometry, int stage, Vector3 firePosition) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) GameObject val = new GameObject("DreadRifts biome services"); val.transform.SetParent(geometry.Root.transform, false); ArenaBiomeServices arenaBiomeServices = val.AddComponent(); if (stage == 3 || stage == 7) { arenaBiomeServices.CreateCampfire(firePosition); } if (stage == 5) { arenaBiomeServices.CreateWisps(geometry.GroundOrigin); } return arenaBiomeServices; } private static GameObject CopyInactive(string native, Vector3 position, Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //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) GameObject prefab = PrefabManager.Instance.GetPrefab(native); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Required native biome asset is missing: " + native); } GameObject val = new GameObject("DreadRifts " + native); val.SetActive(false); val.transform.SetParent(parent, false); return Object.Instantiate(prefab, position, Quaternion.identity, val.transform); } private void CreateCampfire(Vector3 position) { //IL_0005: 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_0099: 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) GameObject val = CopyInactive("fire_pit", position, ((Component)this).transform); Fireplace component = val.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { throw new InvalidOperationException("The native campfire no longer exposes its fire visuals."); } SetActive(component.m_enabledObject, active: true); SetActive(component.m_enabledObjectHigh, active: true); SetActive(component.m_enabledObjectLow, active: false); SetActive(component.m_fullObject, active: true); SetActive(component.m_halfObject, active: false); SetActive(component.m_emptyObject, active: false); SetActive(component.m_playerBaseObject, active: false); int num = 0; EffectArea[] componentsInChildren = val.GetComponentsInChildren(true); foreach (EffectArea val2 in componentsInChildren) { if ((val2.m_type & 1) != 0) { val2.m_type = (Type)67; val2.m_statusEffect = ""; val2.m_playerOnly = true; ((Component)val2).gameObject.SetActive(true); num++; } else { Collider component2 = ((Component)val2).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.enabled = false; } Object.DestroyImmediate((Object)(object)val2); } } if (num == 0) { throw new InvalidOperationException("The native campfire heat trigger is missing."); } foreach (MonoBehaviour item in val.GetComponentsInChildren(true).Reverse()) { if (!(item is EffectArea) && !Appearance(item)) { Object.DestroyImmediate((Object)(object)item); } } Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren2) { obj.isKinematic = true; obj.useGravity = false; } Campfire = val; val.SetActive(true); ((Component)val.transform.parent).gameObject.SetActive(true); } private void CreateWisps(Vector3 origin) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_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_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_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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) anchors = (Vector3[])(object)new Vector3[5] { origin, origin + Vector3.right * 17f, origin + Vector3.left * 17f, origin + Vector3.forward * 17f, origin + Vector3.back * 17f }; Wisps = (Demister[])(object)new Demister[anchors.Length]; wispModels = (Transform[])(object)new Transform[anchors.Length]; for (int i = 0; i < anchors.Length; i++) { GameObject val = CopyInactive("demister_ball", anchors[i] + Vector3.up * 3.2f, ((Component)this).transform); Demister componentInChildren = val.GetComponentInChildren(true); if (!Object.op_Implicit((Object)(object)componentInChildren)) { throw new InvalidOperationException("The native wisplight mist-clearing component is missing."); } ParticleSystemForceField component = ((Component)componentInChildren).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { throw new InvalidOperationException("The native wisplight force field is missing."); } componentInChildren.m_disableForcefieldDelay = 0f; component.endRange = 20f; ((Behaviour)component).enabled = true; foreach (MonoBehaviour item in val.GetComponentsInChildren(true).Reverse()) { if (!(item is Demister) && !Appearance(item)) { Object.DestroyImmediate((Object)(object)item); } } Collider[] componentsInChildren = val.GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; } Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren2) { obj.isKinematic = true; obj.useGravity = false; } Wisps[i] = componentInChildren; wispModels[i] = val.transform; val.SetActive(true); ((Component)val.transform.parent).gameObject.SetActive(true); } } private void Update() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (Wisps.Length == 0) { return; } double num = (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetTime().TimeOfDay.TotalSeconds : ((double)Time.time)); for (int i = 0; i < Wisps.Length; i++) { if (Object.op_Implicit((Object)(object)Wisps[i])) { float num2 = (float)((num * 0.35 + (double)i * 1.7) % (Math.PI * 2.0)); wispModels[i].position = anchors[i] + new Vector3(Mathf.Cos(num2) * 0.8f, 3.2f + Mathf.Sin(num2 * 2f) * 0.45f, Mathf.Sin(num2) * 0.8f); } } } private static bool Appearance(MonoBehaviour script) { if (Object.op_Implicit((Object)(object)script)) { if (!(((object)script).GetType().Name == "LightFlicker") && !(((object)script).GetType().Name == "LightLod")) { return ((object)script).GetType().Name == "ZSFX"; } return true; } return false; } private static void SetActive(GameObject item, bool active) { if (Object.op_Implicit((Object)(object)item)) { item.SetActive(active); } } } internal sealed class ArenaGeometry : IDisposable { private sealed class SourceLease { public GameObject Prefab; public Action Release; } public const float MinimumHeight = 5312f; private static readonly HashSet appearanceScripts = new HashSet { "LightFlicker", "LightLod", "ZSFX", "LodFadeInOut", "SimpleMeshCombine", "MeshLod", "Billboard" }; public GameObject Root { get; private set; } public Bounds Bounds { get; private set; } public string Kind { get; private set; } public Vector3 GroundOrigin { get; private set; } public ArenaPortals Portals { get; private set; } public bool OnTerrain => Kind == "fader_walls"; public static ArenaGeometry Create(string kind, Vector3 floorOrigin) { //IL_0032: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_007e: 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_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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) if (kind != "north" && kind != "queen" && kind != "fader") { throw new ArgumentException("Unknown native arena."); } if (floorOrigin.y < 5312f || floorOrigin.y > 5400f) { throw new ArgumentException("Arena is outside the supported navigation range."); } SourceLease sourceLease = Acquire(kind); GameObject val = null; try { val = new GameObject("DreadRifts Arena " + kind); val.SetActive(false); GameObject val2 = Object.Instantiate(sourceLease.Prefab, Vector3.zero, Quaternion.identity, val.transform); Character[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Character val3 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val3) && (Object)(object)((Component)val3).gameObject != (Object)(object)val2) { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } } Bounds val4 = MeshBounds(val2.transform); Transform transform = val2.transform; transform.position += floorOrigin - new Vector3(((Bounds)(ref val4)).center.x, ((Bounds)(ref val4)).min.y, ((Bounds)(ref val4)).center.z); foreach (MonoBehaviour item in val2.GetComponentsInChildren(true).Reverse()) { if (Object.op_Implicit((Object)(object)item) && !appearanceScripts.Contains(((object)item).GetType().Name)) { Object.DestroyImmediate((Object)(object)item); } } Rigidbody[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren2) { obj.isKinematic = true; obj.useGravity = false; } Bounds bounds = MeshBounds(val2.transform); if (((Bounds)(ref bounds)).max.y > 5490f) { throw new InvalidOperationException("Native room exceeds the navigation ceiling."); } val.AddComponent().Release = sourceLease.Release; val.SetActive(true); val2.SetActive(true); Physics.SyncTransforms(); return new ArenaGeometry { Kind = kind, Root = val, Bounds = bounds }; } catch { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } sourceLease.Release(); throw; } } public List FloorSamples(float spacing = 5f) { //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_011a: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (spacing < 2f) { throw new ArgumentOutOfRangeException("spacing"); } if (OnTerrain) { return BiomeTerrain.FloorSamples(GroundOrigin, 25f, spacing); } List list = new List(); Bounds bounds = Bounds; float num = ((Bounds)(ref bounds)).min.x + 5f; while (true) { float num2 = num; bounds = Bounds; if (!(num2 <= ((Bounds)(ref bounds)).max.x - 5f)) { break; } bounds = Bounds; float num3 = ((Bounds)(ref bounds)).min.z + 5f; while (true) { float num4 = num3; bounds = Bounds; if (!(num4 <= ((Bounds)(ref bounds)).max.z - 5f)) { break; } float num5 = num; bounds = Bounds; Vector3 val = new Vector3(num5, ((Bounds)(ref bounds)).max.y + 3f, num3); Vector3 down = Vector3.down; bounds = Bounds; foreach (RaycastHit item in from h in Physics.RaycastAll(val, down, ((Bounds)(ref bounds)).size.y + 10f, -1, (QueryTriggerInteraction)1) where ((Component)((RaycastHit)(ref h)).collider).transform.IsChildOf(Root.transform) && ((RaycastHit)(ref h)).normal.y > 0.8f orderby ((RaycastHit)(ref h)).point.y select h) { RaycastHit current = item; if (!Physics.CheckCapsule(((RaycastHit)(ref current)).point + Vector3.up * 0.5f, ((RaycastHit)(ref current)).point + Vector3.up * 2f, 0.35f, -1, (QueryTriggerInteraction)1)) { list.Add(((RaycastHit)(ref current)).point); break; } } num3 += spacing; } num += spacing; } return list; } public bool Contains(Vector3 point, float margin = 5f) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_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_00b5: 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_002a: 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_00ca: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: 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_0050: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0108: 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_0121: Unknown result type (might be due to invalid IL or missing references) if (OnTerrain) { if (point.y >= GroundOrigin.y - 15f - margin && point.y <= GroundOrigin.y + 200f + margin) { Vector2 val = new Vector2(point.x - GroundOrigin.x, point.z - GroundOrigin.z); return ((Vector2)(ref val)).sqrMagnitude <= (32f + margin) * (32f + margin); } return false; } float y = point.y; Bounds bounds = Bounds; if (y >= ((Bounds)(ref bounds)).min.y - margin) { float y2 = point.y; bounds = Bounds; if (y2 <= ((Bounds)(ref bounds)).max.y + margin) { float x = point.x; bounds = Bounds; float num = Mathf.Abs(x - ((Bounds)(ref bounds)).center.x); bounds = Bounds; if (num <= ((Bounds)(ref bounds)).extents.x + margin) { float z = point.z; bounds = Bounds; float num2 = Mathf.Abs(z - ((Bounds)(ref bounds)).center.z); bounds = Bounds; return num2 <= ((Bounds)(ref bounds)).extents.z + margin; } } } return false; } public static ArenaGeometry CreateWalls(Vector3 groundOrigin) { //IL_0000: 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_0008: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: 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_03e4: Unknown result type (might be due to invalid IL or missing references) if (!BiomeTerrain.Finite(groundOrigin) || groundOrigin.y < -100f || groundOrigin.y > 2000f) { throw new ArgumentException("Invalid native terrain origin."); } SourceLease sourceLease = Acquire("fader"); GameObject val = null; try { val = new GameObject("DreadRifts Arena fader_walls"); val.SetActive(false); GameObject val2 = Object.Instantiate(sourceLease.Prefab, groundOrigin, Quaternion.identity, val.transform); State state = Random.state; try { Random.InitState(9417363); RandomSpawn[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Prepare(); } componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Randomize(groundOrigin, (Location)null, (DungeonGenerator)null); } } finally { Random.state = state; } Character[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (Character val3 in componentsInChildren2) { if (Object.op_Implicit((Object)(object)val3) && (Object)(object)((Component)val3).gameObject != (Object)(object)val2) { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } } foreach (ZNetView item in val2.GetComponentsInChildren(true).Reverse()) { if (Object.op_Implicit((Object)(object)item) && Radius(((Component)item).transform.position, groundOrigin) < 24f && (Object)(object)((Component)item).gameObject != (Object)(object)val2) { Object.DestroyImmediate((Object)(object)((Component)item).gameObject); } } MeshFilter[] componentsInChildren3 = val2.GetComponentsInChildren(true); foreach (MeshFilter val4 in componentsInChildren3) { if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val4.sharedMesh)) { Transform transform = ((Component)val4).transform; Bounds bounds = val4.sharedMesh.bounds; if (Radius(transform.TransformPoint(((Bounds)(ref bounds)).center), groundOrigin) < 24f) { Object.DestroyImmediate((Object)(object)((Component)val4).gameObject); } } } Collider[] componentsInChildren4 = val2.GetComponentsInChildren(true); foreach (Collider val5 in componentsInChildren4) { if (Object.op_Implicit((Object)(object)val5) && Radius(((Component)val5).transform.position, groundOrigin) < 24f) { Object.DestroyImmediate((Object)(object)val5); } } Light[] componentsInChildren5 = val2.GetComponentsInChildren(true); foreach (Light val6 in componentsInChildren5) { if (Object.op_Implicit((Object)(object)val6) && Radius(((Component)val6).transform.position, groundOrigin) < 24f) { Object.DestroyImmediate((Object)(object)val6); } } ParticleSystem[] componentsInChildren6 = val2.GetComponentsInChildren(true); foreach (ParticleSystem val7 in componentsInChildren6) { if (Object.op_Implicit((Object)(object)val7) && Radius(((Component)val7).transform.position, groundOrigin) < 24f) { Object.DestroyImmediate((Object)(object)((Component)val7).gameObject); } } foreach (MonoBehaviour item2 in val2.GetComponentsInChildren(true).Reverse()) { if (Object.op_Implicit((Object)(object)item2) && !appearanceScripts.Contains(((object)item2).GetType().Name)) { Object.DestroyImmediate((Object)(object)item2); } } Rigidbody[] componentsInChildren7 = val2.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren7) { obj.isKinematic = true; obj.useGravity = false; } if (val2.GetComponentsInChildren(true).Length < 20) { throw new InvalidOperationException("The installed FaderLocation wall hierarchy differs from the supported layout."); } Bounds bounds2 = MeshBounds(val2.transform); val.AddComponent().Release = sourceLease.Release; ArenaPortals portals = ArenaStartSide.Create(val.transform, groundOrigin); val.SetActive(true); val2.SetActive(true); Physics.SyncTransforms(); return new ArenaGeometry { Kind = "fader_walls", Root = val, Bounds = bounds2, GroundOrigin = groundOrigin, Portals = portals }; } catch { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } sourceLease.Release(); throw; } } private static float Radius(Vector3 point, Vector3 origin) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(point.x - origin.x, point.z - origin.z); return ((Vector2)(ref val)).magnitude; } public void Dispose() { if (Object.op_Implicit((Object)(object)Root)) { Object.Destroy((Object)(object)Root); } Root = null; } private static SourceLease Acquire(string kind) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown string text = ((kind == "fader") ? "FaderLocation" : ((kind == "north") ? "DN_Bossroom" : "Mistlands_DvergrBossEntrance1")); ZoneLocation location = ZoneManager.Instance.GetZoneLocation(text); if (location == null) { throw new InvalidOperationException("The installed game does not provide the required arena."); } location.m_prefab.Load(); try { if (kind == "fader") { return new SourceLease { Prefab = location.m_prefab.Asset, Release = Once(delegate { location.m_prefab.Release(); }) }; } if (kind == "north") { Transform val = (from x in (from t in location.m_prefab.Asset.GetComponentsInChildren(true) select new { Node = t, Count = ((Component)t).GetComponentsInChildren(true).Length, Bounds = MeshBounds(t) }).Where(x => { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (x.Count > 0) { Bounds bounds = x.Bounds; return ((Bounds)(ref bounds)).min.y > location.m_prefab.Asset.transform.position.y + 1000f; } return false; }) orderby x.Count descending select x.Node).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("The native Northern interior is missing."); } return new SourceLease { Prefab = ((Component)val).gameObject, Release = Once(delegate { location.m_prefab.Release(); }) }; } DungeonGenerator componentInChildren = location.m_prefab.Asset.GetComponentInChildren(true); AccessTools.Method(typeof(DungeonGenerator), "SetupAvailableRooms", (Type[])null, (Type[])null).Invoke(componentInChildren, null); foreach (object item in (IEnumerable)AccessTools.Field(typeof(DungeonGenerator), "m_availableRooms").GetValue(componentInChildren)) { object reference = AccessTools.Field(item.GetType(), "m_prefab").GetValue(item); AccessTools.Method(reference.GetType(), "Load", (Type[])null, (Type[])null).Invoke(reference, null); GameObject val2 = (GameObject)reference.GetType().GetProperty("Asset").GetValue(reference); if (((Object)val2).name == "dvergr_new_bossroom_ENTRANCE02") { return new SourceLease { Prefab = val2, Release = Once(delegate { AccessTools.Method(reference.GetType(), "Release", (Type[])null, (Type[])null).Invoke(reference, null); location.m_prefab.Release(); }) }; } AccessTools.Method(reference.GetType(), "Release", (Type[])null, (Type[])null).Invoke(reference, null); } throw new InvalidOperationException("The native Queen room is missing."); } catch { location.m_prefab.Release(); throw; } } private static Action Once(Action action) { bool released = false; return delegate { if (!released) { released = true; action(); } }; } private static Bounds MeshBounds(Transform root) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0055: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) bool flag = false; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(root.position, Vector3.zero); MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (MeshFilter val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val.sharedMesh)) { continue; } Bounds bounds = val.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val2 = ((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))))); if (!flag) { ((Bounds)(ref result))..ctor(val2, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val2); } } } return result; } } internal sealed class ArenaAssetLease : MonoBehaviour { public Action Release; private void OnDestroy() { Release?.Invoke(); Release = null; } } internal static class ArenaMusic { [HarmonyPatch(typeof(MusicMan), "UpdateCurrentMusic")] private static class Choose { private static bool Prefix(MusicMan __instance) { return !Select(__instance); } } [HarmonyPatch(typeof(MusicMan), "UpdateMusic")] private static class Loop { private static IEnumerable Transpiler(IEnumerable instructions) { FieldInfo field = AccessTools.Field(typeof(Settings), "ContinousMusic"); foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldsfld && object.Equals(instruction.operand, field)) { instruction.opcode = OpCodes.Call; instruction.operand = AccessTools.Method(typeof(ArenaMusic), "Continuous", (Type[])null, (Type[])null); } yield return instruction; } } } private static MusicMan owner; private static NamedMusic source; private static NamedMusic track; private static string selection = ""; private static readonly FieldInfo Current = AccessTools.Field(typeof(MusicMan), "m_currentMusic"); private static readonly FieldInfo Queued = AccessTools.Field(typeof(MusicMan), "m_queuedMusic"); private static readonly MethodInfo Start = AccessTools.Method(typeof(MusicMan), "StartMusic", new Type[1] { typeof(NamedMusic) }, (Type[])null); private static readonly MethodInfo Stop = AccessTools.Method(typeof(MusicMan), "StopMusic", (Type[])null, (Type[])null); private static readonly MethodInfo EnvironmentMusic = AccessTools.Method(typeof(MusicMan), "GetEnvironmentMusic", (Type[])null, (Type[])null); private static readonly string[] BossNames = new string[8] { "boss_eikthyr", "boss_gdking", "boss_bonemass", "boss_moder", "boss_goblinking", "boss_seekerqueen", "boss_fader", "boss_frozenking" }; private static string Normalize(string value) { return new string((value ?? "").Where(char.IsLetterOrDigit).Select(char.ToLowerInvariant).ToArray()); } private static NamedMusic Match(List tracks, params string[] names) { foreach (string item in names.Where((string n) => !string.IsNullOrEmpty(n))) { string key = Normalize(item); NamedMusic val = ((IEnumerable)tracks).FirstOrDefault((Func)((NamedMusic t) => Normalize(t.m_name) == key && t.m_clips != null && t.m_clips.Any((AudioClip c) => Object.op_Implicit((Object)(object)c)))); if (val != null) { return val; } } return null; } public static void Reset() { if (Object.op_Implicit((Object)(object)owner) && track != null && (Current.GetValue(owner) == track || Queued.GetValue(owner) == track)) { Stop.Invoke(owner, null); } owner = null; source = null; track = null; selection = ""; } private static bool Select(MusicMan manager) { //IL_02e1: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Expected O, but got Unknown RiftClient riftClient = (Object.op_Implicit((Object)(object)Plugin.Instance) ? Plugin.Instance.Client : null); if (riftClient == null || !riftClient.InTrial || !riftClient.ArenaReady || !Object.op_Implicit((Object)(object)Game.instance) || Game.instance.IsShuttingDown()) { Reset(); return false; } RunState run = riftClient.Run; string text = run.Id + ":" + run.Stage + ":" + ((run.Phase != RunPhase.Combat) ? "rest" : ((run.Level == 10) ? "boss" : "wave")); if ((Object)(object)owner != (Object)(object)manager || selection != text || track == null) { if (!(AccessTools.Field(typeof(MusicMan), "m_music").GetValue(manager) is List tracks)) { return false; } NamedMusic val = null; if (run.Phase == RunPhase.Combat) { if (run.Level == 10) { GameObject prefab = ZNetScene.instance.GetPrefab(StageCatalog.Stages[run.Stage].BossPrefab); Character val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent() : null); string text2 = (Object.op_Implicit((Object)(object)val2) ? (AccessTools.Field(typeof(Character), "m_bossMusic")?.GetValue(val2) as string) : null); val = Match(tracks, text2, BossNames[run.Stage], "boss_" + StageCatalog.Stages[run.Stage].BossPrefab, (run.Stage == 3) ? "boss_dragon" : ((run.Stage == 5) ? "boss_queen" : null)); } val = val ?? Match(tracks, "combat", "event_forest", "The Forest is moving"); val = val ?? ((IEnumerable)tracks).FirstOrDefault((Func)((NamedMusic t) => t.m_clips != null && t.m_clips.Any((AudioClip c) => Object.op_Implicit((Object)(object)c) && Normalize(((Object)c).name).Contains("forestismoving")))); val = val ?? Match(tracks, "boss_gdking", "boss_eikthyr"); } else { object? obj = EnvironmentMusic.Invoke(manager, null); val = (NamedMusic)((obj is NamedMusic) ? obj : null); } if (val?.m_clips == null || !val.m_clips.Any((AudioClip c) => Object.op_Implicit((Object)(object)c))) { Reset(); return false; } owner = manager; selection = text; if (source != val || track == null) { source = val; track = new NamedMusic { m_name = "dreadrifts_" + val.m_name, m_clips = val.m_clips.Where((AudioClip c) => Object.op_Implicit((Object)(object)c)).ToArray(), m_volume = val.m_volume, m_fadeInTime = 2f, m_alwaysFadeout = true, m_loop = true, m_resume = false, m_enabled = true, m_ambientMusic = false }; } } if (Current.GetValue(manager) != track && Queued.GetValue(manager) != track) { AccessTools.Field(typeof(MusicMan), "m_resetMusicTimer").SetValue(manager, 0f); Start.Invoke(manager, new object[1] { track }); } return true; } private static bool Continuous() { if (!Settings.ContinousMusic) { if (Object.op_Implicit((Object)(object)owner) && track != null) { return Current.GetValue(owner) == track; } return false; } return true; } } internal sealed class ArenaPortals : MonoBehaviour { public string RunId = ""; public string ArenaId = ""; private readonly GameObject[] effects = (GameObject[])(object)new GameObject[12]; private readonly Light[] lights = (Light[])(object)new Light[12]; private readonly Renderer[] surfaces = (Renderer[])(object)new Renderer[12]; private readonly ParticleSystem[][] particles = new ParticleSystem[12][]; private float[][] emissionRates; private MaterialPropertyBlock surfaceColour; private float nextUpdate; private static readonly Color violet = new Color(0.65f, 0.2f, 1f, 1f); public int ActivePortal { get; private set; } = -1; public static Vector3 Direction(int portal) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (portal < 0 || portal >= 12) { throw new ArgumentOutOfRangeException("portal"); } float num = (56.25f + (float)portal * 22.5f) * ((float)Math.PI / 180f); return new Vector3(Mathf.Sin(num), 0f, 0f - Mathf.Cos(num)); } public static ArenaPortals Create(Transform parent, Material black, int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DreadRifts Enemy Entrances"); val.transform.SetParent(parent, false); ArenaPortals arenaPortals = val.AddComponent(); arenaPortals.emissionRates = new float[12][]; bool flag = GUIManager.IsHeadless(); if (!flag) { arenaPortals.surfaceColour = new MaterialPropertyBlock(); } for (int i = 0; i < 12; i++) { arenaPortals.surfaces[i] = (Renderer)(object)ArenaStartSide.Backing(val.transform, Direction(i), black, layer, "DreadRifts Enemy Arch " + (i + 1)); if (!flag) { arenaPortals.CreateEffects(i); } } return arenaPortals; } private void CreateEffects(int index) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Direction(index); GameObject val2 = new GameObject("DreadRifts Arch Warning " + (index + 1)); val2.SetActive(false); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = val * 29.1f; val2.transform.localRotation = Quaternion.LookRotation(-val, Vector3.up); effects[index] = val2; GameObject val3 = new GameObject("DreadRifts entrance light"); val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = new Vector3(0f, 3f, 1.3f); Light val4 = val3.AddComponent(); val4.color = violet; val4.range = 11f; val4.intensity = 3.2f; val4.shadows = (LightShadows)0; lights[index] = val4; GameObject prefab = PrefabManager.Instance.GetPrefab("vfx_prespawn"); particles[index] = Array.Empty(); emissionRates[index] = Array.Empty(); if (!Object.op_Implicit((Object)(object)prefab)) { return; } GameObject val5 = Object.Instantiate(prefab, val2.transform); ((Object)val5).name = "DreadRifts native entrance mist"; val5.transform.localPosition = new Vector3(0f, 1.8f, 0.6f); val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = new Vector3(1.2f, 1.4f, 1.2f); foreach (MonoBehaviour item in val5.GetComponentsInChildren(true).Reverse()) { Object.DestroyImmediate((Object)(object)item); } Collider[] componentsInChildren = val5.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } AudioSource[] componentsInChildren2 = val5.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Light[] componentsInChildren3 = val5.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } particles[index] = val5.GetComponentsInChildren(true); emissionRates[index] = new float[particles[index].Length]; for (int j = 0; j < particles[index].Length; j++) { ParticleSystem obj = particles[index][j]; ((Component)obj).gameObject.SetActive(true); MainModule main = obj.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(violet); ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; ((MainModule)(ref main)).maxParticles = Math.Min(((MainModule)(ref main)).maxParticles, 100); ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = false; EmissionModule emission = obj.emission; emissionRates[index][j] = ((EmissionModule)(ref emission)).rateOverTimeMultiplier; } val5.SetActive(true); } private void Update() { //IL_0258: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Plugin.Instance) || GUIManager.IsHeadless() || Time.unscaledTime < nextUpdate) { return; } nextUpdate = Time.unscaledTime + 0.05f; RunState runState = Plugin.Instance.Server.FindRun(RunId) ?? ((Plugin.Instance.Client.Run?.Id == RunId) ? Plugin.Instance.Client.Run : null); if (runState != null && runState.ArenaId != ArenaId) { runState = null; } float value = Plugin.Instance.EffectsIntensity.Value; long num = ((runState == null) ? 0 : ((Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) ? runState.PortalClockMs : PortalWaves.PredictClock(runState, Plugin.Instance.Client.ServerNow))); EnemyRecord enemyRecord = ((runState == null || value <= 0f) ? null : PortalWaves.ActiveGroup(runState, num)); int num2 = enemyRecord?.PortalIndex ?? (-1); if (num2 != ActivePortal) { if (ActivePortal >= 0) { ParticleSystem[] array = particles[ActivePortal]; for (int i = 0; i < array.Length; i++) { array[i].Stop(false, (ParticleSystemStopBehavior)0); } effects[ActivePortal].SetActive(false); surfaces[ActivePortal].SetPropertyBlock((MaterialPropertyBlock)null); } ActivePortal = num2; if (num2 >= 0) { effects[num2].SetActive(true); ParticleSystem[] array = particles[num2]; for (int i = 0; i < array.Length; i++) { array[i].Play(false); } } } if (num2 >= 0) { float num3 = (float)(num - enemyRecord.PortalOpensAtMs) / 1000f; float num4 = Mathf.Lerp(0.2f, 1f, Mathf.Clamp01(num3 / 2f)); float num5 = Mathf.Clamp01(((float)PortalWaves.Duration(enemyRecord) / 1000f - num3) / 0.65f); float num6 = 0.9f + 0.1f * Mathf.Sin(num3 * 8f); float num7 = num4 * num5 * num6 * value; lights[num2].intensity = 3.2f * num7; surfaceColour.SetColor("_Color", Color.Lerp(Color.black, new Color(0.13f, 0.012f, 0.22f, 1f), Mathf.Clamp01(num7))); surfaces[num2].SetPropertyBlock(surfaceColour); for (int j = 0; j < particles[num2].Length; j++) { EmissionModule emission = particles[num2][j].emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = emissionRates[num2][j] * num4 * num5 * value; } } } } internal sealed class ArenaReturnGate : MonoBehaviour { public string RunId; public string ArenaId; private float nextAttempt; private bool armed; public bool OpenPose { get; private set; } internal static Quaternion RotationFor(ArenaSite site) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val = RiftWire.Vec(site.Origin) - RiftWire.Vec(site.Checkpoint); val.y = 0f; return Quaternion.LookRotation((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); } internal static Vector3 PositionFor(ArenaSite site) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) return RiftWire.Vec(site.Checkpoint) - RotationFor(site) * Vector3.forward * 3.25f - Vector3.up * 1.2f; } internal static bool Contains(ArenaSite site, Vector3 position) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (site != null) { return RiftGate.ContainsEntry(Quaternion.Inverse(RotationFor(site)) * (position - PositionFor(site))); } return false; } internal static bool BlocksStation(ArenaSite site, Vector3 position) { //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_000b: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_002f: 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) Vector3 val = Quaternion.Inverse(RotationFor(site)) * (position - PositionFor(site)); if (Mathf.Abs(val.x) < 6.5f && val.z > -8.5f) { return val.z < 3.5f; } return false; } internal static ArenaReturnGate Create(ArenaRuntime arena, ArenaSite site) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DreadRifts Return Gate"); val.transform.SetParent(arena.Geometry.Root.transform, false); val.SetActive(false); GameObject val2 = Object.Instantiate(PrefabManager.Instance.GetPrefab("DreadRifts_Gate"), PositionFor(site), RotationFor(site), val.transform); ((Object)val2).name = "DreadRifts Arena Gate"; Door component = val2.GetComponent(); GameObject val3 = (Object.op_Implicit((Object)(object)component) ? component.m_openEnable : null); foreach (MonoBehaviour item in val2.GetComponentsInChildren(true).Reverse()) { Object.DestroyImmediate((Object)(object)item); } Rigidbody[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren) { obj.isKinematic = true; obj.useGravity = false; } Animator componentInChildren = val2.GetComponentInChildren(true); if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)componentInChildren.runtimeAnimatorController)) { throw new InvalidOperationException("The return gate has no native Queen animation."); } AnimationClip val4 = ((IEnumerable)componentInChildren.runtimeAnimatorController.animationClips).FirstOrDefault((Func)((AnimationClip x) => ((Object)x).name == "Open")); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("The native Queen open pose is unavailable."); } ArenaReturnGate arenaReturnGate = val2.AddComponent(); arenaReturnGate.RunId = arena.RunId; arenaReturnGate.ArenaId = arena.Id; ((Behaviour)componentInChildren).enabled = false; val2.SetActive(true); val.SetActive(true); val4.SampleAnimation(((Component)componentInChildren).gameObject, val4.length); if (Object.op_Implicit((Object)(object)val3)) { val3.SetActive(true); } arenaReturnGate.OpenPose = true; Physics.SyncTransforms(); return arenaReturnGate; } private void Update() { //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) if (Object.op_Implicit((Object)(object)Plugin.Instance) && !GUIManager.IsHeadless()) { Player localPlayer = Player.m_localPlayer; RiftClient client = Plugin.Instance.Client; if (!Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || !client.InTrial || client.Own.Dead || client.Run.Id != RunId || client.Run.ArenaId != ArenaId) { armed = false; } else if (!RiftGate.ContainsEntry(((Component)this).transform.InverseTransformPoint(((Component)localPlayer).transform.position))) { armed = true; } else if (armed && !(Time.unscaledTime < nextAttempt)) { nextAttempt = Time.unscaledTime + 3f; client.Send("leave_gate"); } } } } internal sealed class ArenaRuntime { private static readonly Dictionary arenas = new Dictionary(); public string Id; public string RunId; public ArenaGeometry Geometry; public Vector3 Checkpoint; public Vector3 AltarPosition; public List Floors; public StaticTarget AltarTarget; public ArenaBiomeServices BiomeServices; public ArenaTransition Transition; public ArenaReturnGate ReturnGate; private ArenaSite site; private readonly List stationPoints = new List(); private GameObject altarObject; public Vector3 WarehousePoint => stationPoints[0]; public Quaternion ArrivalRotation => ArenaReturnGate.RotationFor(site); public static ArenaRuntime Ensure(RunState run) { if (TryEnsure(run, out var arena)) { return arena; } throw new InvalidOperationException("Площадка испытания ещё загружается."); } public static bool TryEnsure(RunState run, out ArenaRuntime arena) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between I4 and Unknown //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_006c: 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_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: 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_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0494: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: 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_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) arena = null; ArenaSite site = ArenaSites.Current(run); if (site == null) { return false; } if (site.LayoutVersion != 1 || site.Biome != (int)BiomeTerrain.StageBiome(run.Stage)) { throw new InvalidOperationException("Сохранённая арена не соответствует этапу."); } Vector3 val = RiftWire.Vec(site.Origin); BiomeArenaPlacement.Register(site); if (!BiomeTerrain.Prepare(val)) { return false; } if (!NativeArenaGround.Ensure(site)) { return false; } if (arenas.TryGetValue(site.Id, out arena)) { arena.UpdateObjective(run); return true; } if (!site.Ready && !ZNet.instance.IsServer()) { return false; } ArenaGeometry arenaGeometry = ArenaGeometry.CreateWalls(val); try { if (!site.Ready) { List list = arenaGeometry.FloorSamples(4f); if (list.Count < 100) { throw new InvalidOperationException("Недостаточно безопасной земли внутри арены."); } Vector3 checkpoint = Nearest(list, val + Vector3.back * 18f) + Vector3.up * 1.2f; Vector3 value = Nearest(list, val); Vector3[] obj = new Vector3[4] { val + new Vector3(-12f, 0f, -18f), val + new Vector3(-6f, 0f, -23f), val + new Vector3(6f, 0f, -23f), val + new Vector3(12f, 0f, -18f) }; List services = new List(); Vector3[] array = (Vector3[])(object)obj; foreach (Vector3 target in array) { Vector3 item = (from p in list where Vector3.Distance(p, checkpoint) >= 3f && services.All((Vector3 q) => Vector3.Distance(p, q) >= 4f) orderby HorizontalSquared(p, target) select p).First(); services.Add(item); } site.Floors = list.Select(RiftWire.Pos).ToList(); site.Checkpoint = RiftWire.Pos(checkpoint); site.Altar = RiftWire.Pos(value); site.Services = services.Select(RiftWire.Pos).ToList(); ArenaSites.SetReady(run, site); } arena = new ArenaRuntime { Id = site.Id, RunId = run.Id, site = site, Geometry = arenaGeometry, Floors = site.Floors.Select(RiftWire.Vec).ToList(), Checkpoint = RiftWire.Vec(site.Checkpoint), AltarPosition = RiftWire.Vec(site.Altar) }; arenaGeometry.Portals.RunId = run.Id; arenaGeometry.Portals.ArenaId = site.Id; arena.MakeStation("guard_stone", arena.AltarPosition, "altar", "Алтарь испытания"); arena.ReturnGate = ArenaReturnGate.Create(arena, site); arena.MakeStation("piece_chest_wood", arena.StationPoint(0), "bank", "Склад экспедиции"); arena.MakeStation("forge", arena.StationPoint(1), "repair", "Ремонт снаряжения"); arena.MakeStation("piece_chest_wood", arena.StationPoint(2), "reward", "Личная награда"); List occupiedServices = arena.stationPoints; Vector3 firePosition = Nearest(arena.Floors.Where((Vector3 p) => !ArenaReturnGate.BlocksStation(site, p) && occupiedServices.All((Vector3 s) => Vector3.Distance(p, s) >= 4f) && Vector3.Distance(p, RiftWire.Vec(site.Checkpoint)) >= 4f), val + new Vector3(-17f, 0f, -15f)); arena.BiomeServices = ArenaBiomeServices.Create(arenaGeometry, run.Stage, firePosition); if (site.ReadyCircle == null) { Vector3 altarForCircle = arena.AltarPosition; Vector3 value2 = Nearest(arena.Floors.Where((Vector3 p) => !ArenaReturnGate.BlocksStation(site, p) && Vector3.Distance(p, altarForCircle) >= 5f && occupiedServices.All((Vector3 s) => Vector3.Distance(p, s) >= 5f)), val + Vector3.back * 10f); site.ReadyCircle = RiftWire.Pos(value2); } arena.Transition = ArenaTransition.Create(arena); arenaGeometry.Root.AddComponent(); arena.UpdateObjective(run); arenas.Add(site.Id, arena); return true; } catch { arenaGeometry.Dispose(); throw; } } private static float HorizontalSquared(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(a.x - b.x, a.z - b.z); return ((Vector2)(ref val)).sqrMagnitude; } private static Vector3 Nearest(IEnumerable floors, Vector3 target) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return floors.OrderBy((Vector3 p) => HorizontalSquared(p, target)).First(); } private Vector3 StationPoint(int index) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) //IL_003b: 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) Vector3 target = RiftWire.Vec(site.Services[index]); Vector3 val = Nearest(Floors.Where((Vector3 p) => !ArenaReturnGate.BlocksStation(site, p) && Vector3.Distance(p, Checkpoint) >= 3f && stationPoints.All((Vector3 q) => Vector3.Distance(p, q) >= 4f)), target); stationPoints.Add(val); return val; } internal void UpdateObjective(RunState run) { if (Object.op_Implicit((Object)(object)altarObject)) { altarObject.SetActive(Expedition.Objective(run.Level) == ObjectiveKind.Defend && run.Phase != RunPhase.Intermission && run.Phase != RunPhase.Complete); } } public bool CheckpointSupported() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (BiomeTerrain.TryFloor(Checkpoint, out var floor, checkObstacles: false)) { return Mathf.Abs(floor.y + 1.2f - Checkpoint.y) < 1f; } return false; } public Vector3 SpawnPoint(int index) { //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_002d: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Vector3 center = RiftWire.Vec(site.Origin); float num = (float)index * 2.3999631f; Vector3 target = center + new Vector3(Mathf.Sin(num), 0f, Mathf.Cos(num)) * 16f; Vector3[] array = Floors.Where((Vector3 x) => Vector3.Distance(x, Checkpoint) > 14f && HorizontalSquared(x, center) < 441f && Vector3.Distance(x, AltarPosition) > 4f && stationPoints.All((Vector3 p) => Vector3.Distance(x, p) > 4f)).ToArray(); if (array.Length == 0) { throw new InvalidOperationException("На арене нет подходящих точек появления противников."); } return Nearest(array, target) + Vector3.up * 0.6f; } public bool TryPortalSpawn(int portal, int slot, GameObject prefab, out Vector3 position) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_003b: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0191: 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_019b: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ArenaPortals.Direction(portal); Vector3 val2 = Vector3.Cross(Vector3.up, val); CapsuleCollider component = prefab.GetComponent(); Vector3 lossyScale = prefab.transform.lossyScale; float num = (Object.op_Implicit((Object)(object)component) ? (component.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z))) : 1f); float num2 = (Object.op_Implicit((Object)(object)component) ? (component.height * Mathf.Abs(lossyScale.y)) : 2f); num = Mathf.Max(0.4f, num); num2 = Mathf.Max(num * 2f, num2); float num3 = Mathf.Max(14f, 29.4f - num); float num4 = Mathf.Min(0.9f, Mathf.Max(0f, 2.5f - num)); int num5 = slot % 3 - 1; float[] array = new float[3] { 0f, 1.5f, 3f }; foreach (float num6 in array) { foreach (int item in new int[4] { num5, 0, -1, 1 }.Distinct()) { if (BiomeTerrain.TryFloor(RiftWire.Vec(site.Origin) + val * (num3 - num6) + val2 * ((float)item * num4), out var floor, checkObstacles: false)) { Vector3 val3 = floor + Vector3.up * (num + 0.2f); Vector3 val4 = floor + Vector3.up * (num2 - num + 0.2f); if (!Physics.OverlapCapsule(val3, val4, num, -1, (QueryTriggerInteraction)1).Any((Collider c) => Object.op_Implicit((Object)(object)c) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent()) && LayerMask.LayerToName(((Component)c).gameObject.layer) != "terrain")) { position = floor + Vector3.up * 0.2f; return true; } } } } position = Vector3.zero; return false; } private void MakeStation(string native, Vector3 point, string action, string label) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0058: 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_0165: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab(native); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Required native station is missing: " + native); } GameObject val = new GameObject("DreadRifts " + action); val.transform.SetParent(Geometry.Root.transform, false); val.SetActive(false); GameObject val2 = Object.Instantiate(prefab, point, Quaternion.identity, val.transform); foreach (MonoBehaviour item in val2.GetComponentsInChildren(true).Reverse()) { Object.DestroyImmediate((Object)(object)item); } Rigidbody[] componentsInChildren = val2.GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren) { obj.isKinematic = true; obj.useGravity = false; } Rigidbody obj2 = val2.GetComponent() ?? val2.AddComponent(); obj2.isKinematic = true; obj2.useGravity = false; RiftStation riftStation = val2.AddComponent(); riftStation.RunId = RunId; riftStation.Action = action; riftStation.Label = label; if (action == "altar") { altarObject = val; AltarTarget = val2.AddComponent(); AltarTarget.m_primaryTarget = true; val2.AddComponent().RunId = RunId; } if (action == "reward") { Light obj3 = val2.AddComponent(); obj3.color = new Color(1f, 0.68f, 0.22f); obj3.range = 5f; obj3.intensity = 1.1f; } val.SetActive(true); val2.SetActive(true); } public static ArenaRuntime Find(string runId, Vector3 position) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return arenas.Values.FirstOrDefault((ArenaRuntime x) => x.RunId == runId && x.Geometry.Contains(position)); } public static ArenaRuntime At(Vector3 position) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return arenas.Values.FirstOrDefault((ArenaRuntime x) => x.Geometry.Contains(position, 10f)); } public static void Reset() { foreach (ArenaRuntime value in arenas.Values) { value.Geometry.Dispose(); } arenas.Clear(); } } internal sealed class RiftStation : MonoBehaviour, Hoverable, Interactable { public string RunId; public string Action; public string Label; public string GetHoverName() { return Label; } public float GetHoverOffset() { return 1f; } public string GetHoverText() { return Localization.instance.Localize(Label + "\n[$KEY_Use] Открыть"); } public bool UseItem(Humanoid user, ItemData item) { return false; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || Plugin.Instance.Client.Run?.Id != RunId) { return false; } Plugin.Instance.Client.Station(Action); return true; } } internal sealed class RiftAltar : MonoBehaviour, IDestructible { public string RunId; public DestructibleType GetDestructibleType() { return (DestructibleType)1; } public void Damage(HitData hit) { Character attacker = hit.GetAttacker(); RiftActor riftActor = (Object.op_Implicit((Object)(object)attacker) ? ((Component)attacker).GetComponent() : null); if (Object.op_Implicit((Object)(object)riftActor) && Object.op_Implicit((Object)(object)riftActor.View) && riftActor.View.IsOwner() && !(riftActor.RunId != RunId)) { float num = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage() * riftActor.DamageFactor; if (!(num <= 0f)) { Plugin.Instance.Wire.Request(new RiftRequest { Command = "altar_hit", RunId = RunId, ActorId = riftActor.ActorId, NetworkId = RiftWire.Identity(riftActor.View.GetZDO()), Amount = num }); } } } } internal static class ArenaSpectator { [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] private static class Camera { private static bool Prefix(GameCamera __instance) { //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_0174: 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_0183: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0160: 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_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) if (!Active) { return true; } RiftClient client = Client; Player[] array = (from p in Player.GetAllPlayers() where Object.op_Implicit((Object)(object)p) && (Object)(object)p != (Object)(object)Player.m_localPlayer && !((Character)p).IsDead() && !((Character)p).IsTeleporting() && client.Run.Members.Any((Member m) => m.PlayerId == p.GetPlayerID() && m.Present && m.Connected && !m.Dead) orderby p.GetPlayerID() select p).ToArray(); int num = Array.FindIndex(array, (Player p) => p.GetPlayerID() == targetId); if (num < 0) { num = 0; } if (array.Length > 1 && !Menu.IsVisible() && !client.MenuOpen && !Console.IsVisible() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus())) { if (Input.GetKeyDown((KeyCode)275)) { num = (num + 1) % array.Length; } if (Input.GetKeyDown((KeyCode)276)) { num = (num + array.Length - 1) % array.Length; } } Vector3 val = Vector3.back; if (array.Length != 0) { Player obj = array[num]; targetId = obj.GetPlayerID(); TargetName = client.Run.Members.First((Member m) => m.PlayerId == targetId).Name; lastFocus = ((Component)obj).transform.position; val = -((Component)obj).transform.forward; } else { targetId = 0L; TargetName = "Обзор арены"; } Vector3 val2 = lastFocus + Vector3.up * 1.7f; Vector3 val3 = val2 + val * 8f + Vector3.up * 4f; int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); Vector3 val4 = val3 - val2; RaycastHit val5 = default(RaycastHit); if (Physics.SphereCast(val2, 0.25f, ((Vector3)(ref val4)).normalized, ref val5, ((Vector3)(ref val4)).magnitude, mask, (QueryTriggerInteraction)1)) { val3 = val2 + ((Vector3)(ref val4)).normalized * Mathf.Max(0.5f, ((RaycastHit)(ref val5)).distance - 0.3f); } ((Component)__instance).transform.position = Vector3.Lerp(((Component)__instance).transform.position, val3, 1f - Mathf.Exp(-5f * Time.unscaledDeltaTime)); ((Component)__instance).transform.rotation = Quaternion.LookRotation(val2 - ((Component)__instance).transform.position, Vector3.up); if (Object.op_Implicit((Object)(object)ZNet.instance)) { ZNet.instance.SetReferencePosition(lastFocus); } return false; } } [HarmonyPatch(typeof(Hud), "UpdateBlackScreen")] private static class DeathScreen { private static bool Prefix(Hud __instance) { if (!Active) { return true; } object? value = AccessTools.Field(typeof(Hud), "m_loadingScreen").GetValue(__instance); CanvasGroup val = (CanvasGroup)((value is CanvasGroup) ? value : null); if (Object.op_Implicit((Object)(object)val)) { val.alpha = 0f; ((Component)val).gameObject.SetActive(false); } return false; } } private static bool witnessedDeath; private static bool requestedRespawn; private static string runId = ""; private static Vector3 lastFocus; private static long targetId; public static string TargetName { get; private set; } = ""; private static RiftClient Client { get { if (!Object.op_Implicit((Object)(object)Plugin.Instance)) { return null; } return Plugin.Instance.Client; } } public static bool Active { get { RiftClient client = Client; if (client != null && client.InTrial && Object.op_Implicit((Object)(object)Game.instance) && !Game.instance.IsShuttingDown() && (witnessedDeath || Client.Own.Dead)) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return ((Character)Player.m_localPlayer).IsDead(); } return true; } return false; } } public static void Begin(Player player) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) witnessedDeath = true; requestedRespawn = false; targetId = 0L; runId = Client.Run.Id; lastFocus = ((Component)player).transform.position; TargetName = ""; } public static void Reset() { witnessedDeath = false; requestedRespawn = false; targetId = 0L; runId = ""; TargetName = ""; } public static void Tick() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) RiftClient client = Client; if (client == null || !client.InTrial) { Reset(); return; } if (runId != client.Run.Id) { Reset(); runId = client.Run.Id; if (client.Run.Checkpoint != null) { lastFocus = RiftWire.Vec(client.Run.Checkpoint); } } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Character)Player.m_localPlayer).IsDead()) { witnessedDeath = false; requestedRespawn = false; TargetName = ""; } else if (Active && client.Own.Dead && client.ServerNow >= client.Own.RespawnAtMs && !requestedRespawn && client.Run.HasCheckpoint) { requestedRespawn = true; if (((MonoBehaviour)Game.instance).IsInvoking("_RequestRespawn") || !Game.instance.WaitingForRespawn()) { Game.instance.RequestRespawn(0f, true); } } } } internal sealed class ArenaStartSide : MonoBehaviour { private Material blackout; public static ArenaPortals Create(Transform arena, Vector3 groundOrigin) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0064: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("The arena blackout shader is unavailable."); } int num = LayerMask.NameToLayer("piece"); if (num < 0) { throw new InvalidOperationException("The native structure collision layer is unavailable."); } GameObject val2 = new GameObject("DreadRifts Arch Backings"); val2.transform.SetParent(arena, false); val2.transform.position = groundOrigin; ArenaStartSide arenaStartSide = val2.AddComponent(); arenaStartSide.blackout = new Material(val) { name = "DreadRifts opaque black arch backing", color = Color.black, hideFlags = (HideFlags)52 }; if (arenaStartSide.blackout.HasProperty("_MainTex")) { arenaStartSide.blackout.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } for (int i = 0; i < 4; i++) { float num2 = (33.75f - (float)i * 22.5f) * ((float)Math.PI / 180f); Backing(val2.transform, new Vector3(Mathf.Sin(num2), 0f, 0f - Mathf.Cos(num2)), arenaStartSide.blackout, num, "DreadRifts Start Arch " + (i + 1)); } return ArenaPortals.Create(val2.transform, arenaStartSide.blackout, num); } internal static MeshRenderer Backing(Transform parent, Vector3 outward, Material material, int layer, string name) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = outward * 30.4f + Vector3.up * 3f; obj.transform.localRotation = Quaternion.LookRotation(outward, Vector3.up); obj.transform.localScale = new Vector3(7.2f, 10f, 0.8f); obj.layer = layer; ((Collider)obj.GetComponent()).isTrigger = false; MeshRenderer component = obj.GetComponent(); ((Renderer)component).sharedMaterial = material; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; ((Renderer)component).lightProbeUsage = (LightProbeUsage)0; ((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0; return component; } private void OnDestroy() { if (Object.op_Implicit((Object)(object)blackout)) { Object.Destroy((Object)(object)blackout); } } } internal sealed class ArenaTransition : MonoBehaviour { public string RunId; public string ArenaId; private GameObject visual; private Material material; private Light glow; private Transform rotating; private ArenaRuntime arena; private TextMesh caption; private CircleAction lastMode; private float nextCheck; private static readonly Color Violet = new Color(0.65f, 0.3f, 1f, 0.95f); private static readonly Color Gold = new Color(1f, 0.76f, 0.35f, 0.95f); private static readonly MethodInfo takeInput = AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null); public bool Visible { get { if (Object.op_Implicit((Object)(object)visual)) { return visual.activeSelf; } return false; } } public Vector3 Center => ((Component)this).transform.position; public static ArenaTransition Create(ArenaRuntime arena) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DreadRifts Next Level Circle"); val.transform.SetParent(arena.Geometry.Root.transform, false); val.transform.position = arena.AltarPosition + Vector3.up * 0.12f; ArenaTransition arenaTransition = val.AddComponent(); arenaTransition.arena = arena; arenaTransition.RunId = arena.RunId; arenaTransition.ArenaId = arena.Id; if (!GUIManager.IsHeadless()) { arenaTransition.CreateVisual(); } return arenaTransition; } private void CreateVisual() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) visual = new GameObject("DreadRifts transition light"); visual.transform.SetParent(((Component)this).transform, false); visual.SetActive(false); Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color"); if (Object.op_Implicit((Object)(object)val)) { material = new Material(val); Ring(visual.transform, 3f, 0.48f, new Color(Violet.r, Violet.g, Violet.b, 0.16f), 0f, 360f); Ring(visual.transform, 3f, 0.075f, Violet, 0f, 360f); Ring(visual.transform, 2.55f, 0.055f, Gold, 0f, 360f); GameObject val2 = new GameObject("DreadRifts rotating runes"); val2.transform.SetParent(visual.transform, false); rotating = val2.transform; for (int i = 0; i < 12; i++) { Ring(rotating, 2.77f, 0.12f, (i % 3 == 0) ? Gold : Violet, i * 30 + 5, 10f); } for (int j = 0; j < 3; j++) { LineRenderer obj = Line(visual.transform, 0.085f, Gold); obj.positionCount = 3; obj.SetPositions((Vector3[])(object)new Vector3[3] { new Vector3(-0.45f, -0.6f + (float)j * 0.55f, 0f), new Vector3(0f, -0.3f + (float)j * 0.55f, 0f), new Vector3(0.45f, -0.6f + (float)j * 0.55f, 0f) }); } GameObject val3 = new GameObject("DreadRifts circle readiness"); val3.transform.SetParent(visual.transform, false); val3.transform.localPosition = Vector3.up * 1.7f; caption = val3.AddComponent(); caption.fontSize = 48; caption.characterSize = 0.1f; caption.anchor = (TextAnchor)4; caption.alignment = (TextAlignment)1; caption.font = Resources.GetBuiltinResource("LegacyRuntime.ttf"); if (Object.op_Implicit((Object)(object)caption.font)) { ((Renderer)((Component)caption).GetComponent()).sharedMaterial = caption.font.material; } GameObject val4 = new GameObject("DreadRifts circle glow"); val4.transform.SetParent(visual.transform, false); val4.transform.localPosition = Vector3.up * 1.1f; glow = val4.AddComponent(); glow.color = Violet; glow.range = 8f; glow.shadows = (LightShadows)0; } } private LineRenderer Line(Transform parent, float width, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj = new GameObject("DreadRifts circle stroke").AddComponent(); ((Component)obj).transform.SetParent(parent, false); obj.useWorldSpace = false; ((Renderer)obj).sharedMaterial = material; float startWidth = (obj.endWidth = width); obj.startWidth = startWidth; Color startColor = (obj.endColor = color); obj.startColor = startColor; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; obj.alignment = (LineAlignment)1; ((Component)obj).transform.localRotation = Quaternion.Euler(90f, 0f, 0f); return obj; } private void Ring(Transform parent, float radius, float width, Color color, float from, float degrees) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) LineRenderer val = Line(parent, width, color); int num = Math.Max(3, Mathf.CeilToInt(degrees / 3f)); val.loop = degrees >= 360f; val.positionCount = (val.loop ? num : (num + 1)); for (int i = 0; i < val.positionCount; i++) { float num2 = (from + degrees * (float)i / (float)num) * ((float)Math.PI / 180f); val.SetPosition(i, new Vector3(Mathf.Sin(num2) * radius, Mathf.Cos(num2) * radius, 0f)); } } private void Update() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //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_0119: 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_03c1: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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) //IL_037d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Plugin.Instance) || GUIManager.IsHeadless()) { return; } RiftClient client = Plugin.Instance.Client; RunState run = client.Run; CircleAction circleAction = PartyCircle.Action(run); bool flag = client.InTrial && run.Id == RunId && run.ArenaId == ArenaId && circleAction != CircleAction.None; if (Object.op_Implicit((Object)(object)visual) && visual.activeSelf != flag) { if (run?.Id == RunId && run.ArenaId == ArenaId) { arena.UpdateObjective(run); } visual.SetActive(flag); } if (flag) { Position position = PartyCircle.Center(run); if (position != null) { ((Component)this).transform.position = RiftWire.Vec(position) + Vector3.up * 0.12f; } Color val = (Color)((circleAction == CircleAction.Start) ? new Color(0.25f, 1f, 0.58f, 1f) : Violet); if (circleAction != lastMode && Object.op_Implicit((Object)(object)visual)) { LineRenderer[] componentsInChildren = visual.GetComponentsInChildren(); foreach (LineRenderer val2 in componentsInChildren) { Color val3 = val; val3.a = val2.startColor.a; Color startColor = (val2.endColor = val3); val2.startColor = startColor; } } lastMode = circleAction; float value = Plugin.Instance.EffectsIntensity.Value; if (Object.op_Implicit((Object)(object)rotating)) { rotating.localRotation = Quaternion.Euler(0f, Time.time * 7f, 0f); } if (Object.op_Implicit((Object)(object)glow)) { glow.color = val; glow.intensity = (1.25f + 0.25f * Mathf.Sin(Time.time * 2f)) * value; } if (Object.op_Implicit((Object)(object)caption)) { int num = run.Members.Count((Member m) => m.Present && m.Connected); int num2 = run.Members.Count((Member m) => m.Present && m.Connected && m.Ready && !m.Dead); caption.text = ((circleAction == CircleAction.Start) ? "Начать раунд" : "Следующий раунд") + "\nГотовы: " + num2 + "/" + num; if (run.CircleMessage.Length > 0) { TextMesh obj = caption; obj.text = obj.text + "\n" + run.CircleMessage; } else if (run.CircleEndsAtMs > 0) { TextMesh obj2 = caption; obj2.text = obj2.text + "\n" + Math.Max(0, (int)Math.Ceiling((double)(run.CircleEndsAtMs - client.ServerNow) / 1000.0)); } caption.color = val; if (Object.op_Implicit((Object)(object)Camera.main)) { ((Component)caption).transform.rotation = ((Component)Camera.main).transform.rotation; } } } if (Time.unscaledTime < nextCheck) { return; } nextCheck = Time.unscaledTime + 0.1f; Player localPlayer = Player.m_localPlayer; int num3; if (flag && Object.op_Implicit((Object)(object)localPlayer) && PartyCircle.Contains(run, RiftWire.Pos(((Component)localPlayer).transform.position)) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting() && !client.Own.Dead && !client.MenuOpen && !Menu.IsVisible()) { object obj3 = takeInput?.Invoke(localPlayer, null); if (obj3 is bool && (bool)obj3) { num3 = ((Time.timeScale > 0f) ? 1 : 0); goto IL_043a; } } num3 = 0; goto IL_043a; IL_043a: bool eligible = (byte)num3 != 0; if (flag) { client.CirclePresence(eligible); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } } } internal sealed class BiomeArenaSearch { public const int MaximumAttempts = 150000; private readonly Random random; private readonly int stage; public readonly Dictionary Rejections = new Dictionary(); public int Attempts { get; private set; } public bool Exhausted => Attempts >= 150000; public float BestHeightRange { get; private set; } = float.PositiveInfinity; public string Diagnostic => "attempts=" + Attempts + " best_height_range=" + BestHeightRange + " rejected=" + string.Join(",", Rejections.Select((KeyValuePair x) => x.Key + ":" + x.Value)); private void Reject(string reason) { Rejections[reason] = ((!Rejections.TryGetValue(reason, out var value)) ? 1 : (value + 1)); } public BiomeArenaSearch(int seed, int stage) { this.stage = stage; random = new Random(seed + stage * 7919); } public Vector3? Step(IEnumerable reserved, int budgetMs = 10) { //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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); while (!Exhausted && stopwatch.ElapsedMilliseconds < budgetMs) { Attempts++; float num = ((stage == 0) ? 500 : ((stage == 1) ? 800 : ((stage == 2) ? 2000 : ((stage == 3) ? 1000 : ((stage == 4) ? 3200 : 6200))))); float num2 = ((stage == 0) ? 4300 : ((stage == 1) ? 6000 : ((stage == 2) ? 7200 : ((stage == 4) ? 7900 : 9650)))); float num3 = Mathf.Sqrt(Mathf.Lerp(num * num, num2 * num2, (float)random.NextDouble())); float num4 = (float)random.NextDouble() * (float)Math.PI * 2f; Vector3 point = new Vector3(Mathf.Sin(num4) * num3, 0f, Mathf.Cos(num4) * num3); if ((stage == 6 && point.z > -6500f) || (stage == 7 && point.z < 6500f)) { Reject("latitude"); } else if (WorldGenerator.instance.GetBiome(point) != BiomeTerrain.StageBiome(stage)) { Reject("biome"); } else { if (reserved.Any((ArenaSite x) => HorizontalDistance(RiftWire.Vec(x.Origin), point) < 160f)) { continue; } if (ZoneSystem.instance.m_locationInstances.Values.Any((LocationInstance x) => HorizontalDistance(x.m_position, point) < Math.Max((x.m_location.m_iconAlways || x.m_location.m_unique) ? 180f : 55f, x.m_location.m_exteriorRadius + 45f))) { Reject("location"); continue; } float averageHeight; string reason; float range; bool num5 = BiomeTerrain.SuitableGeneratedGround(point, stage, out averageHeight, out reason, out range); BestHeightRange = Math.Min(BestHeightRange, range); if (!num5) { Reject(reason); continue; } point.y = averageHeight; if (!BiomeArenaPlacement.IsFreshFootprint(point)) { Reject("generated"); } else if (!RiftWire.NetworkObjects().Any((ZDO x) => x.GetLong("creator", 0L) != 0L && HorizontalDistance(x.GetPosition(), point) < 140f)) { return point; } } } return null; } private static float HorizontalDistance(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(a.x - b.x, a.z - b.z); return ((Vector2)(ref val)).magnitude; } } internal static class BiomeArenaPlacement { [HarmonyPatch(typeof(ZoneSystem), "InsideClearArea")] private static class ClearNewFootprints { private static void Postfix(Vector3 point, ref bool __result) { //IL_0037: 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) if (__result || !Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer()) { return; } foreach (ArenaSite value in reservations.Values) { float num = point.x - value.Origin.X; float num2 = point.z - value.Origin.Z; if (num * num + num2 * num2 <= 1444f) { __result = true; break; } } } } private static readonly MethodInfo generated = AccessTools.Method(typeof(ZoneSystem), "IsZoneGenerated", (Type[])null, (Type[])null); private static readonly Dictionary reservations = new Dictionary(); public static void Register(ArenaSite site) { reservations[site.Id] = site; } public static void Reset() { reservations.Clear(); } public static bool IsFreshFootprint(Vector3 origin) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Vector2s zone = ZoneSystem.GetZone(origin - new Vector3(38f, 0f, 38f)); Vector2s zone2 = ZoneSystem.GetZone(origin + new Vector3(38f, 0f, 38f)); for (int i = zone.x; i <= zone2.x; i++) { for (int j = zone.y; j <= zone2.y; j++) { if ((bool)generated.Invoke(ZoneSystem.instance, new object[1] { (object)new Vector2s(i, j) })) { return false; } } } return true; } } internal static class BiomeTerrain { private static readonly MethodInfo poke = AccessTools.Method(typeof(ZoneSystem), "PokeLocalZone", (Type[])null, (Type[])null); private static readonly Biome[] biomes; public static Biome StageBiome(int stage) { if (stage < 0 || stage >= biomes.Length) { throw new ArgumentOutOfRangeException("stage"); } return biomes[stage]; } public static bool Finite(Vector3 point) { //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(point.x) && !float.IsNaN(point.y) && !float.IsNaN(point.z) && !float.IsInfinity(point.x) && !float.IsInfinity(point.y)) { return !float.IsInfinity(point.z); } return false; } public static bool Prepare(Vector3 origin, float radius = 40f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0047: 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_0050: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || HeightmapBuilder.instance == null) { return false; } Vector2s zone = ZoneSystem.GetZone(origin - new Vector3(radius, 0f, radius)); Vector2s zone2 = ZoneSystem.GetZone(origin + new Vector3(radius, 0f, radius)); bool flag = true; Vector2s val = default(Vector2s); for (int i = zone.x; i <= zone2.x; i++) { for (int j = zone.y; j <= zone2.y; j++) { ((Vector2s)(ref val))..ctor(i, j); poke.Invoke(ZoneSystem.instance, new object[1] { val }); flag &= ZoneSystem.instance.IsZoneLoaded(val); } } if (flag) { return !Heightmap.HaveQueuedRebuild(origin, radius); } return false; } public static bool TryFloor(Vector3 point, out Vector3 floor, bool checkObstacles = true) { //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_000b: 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_0028: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c1: 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_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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //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) floor = Vector3.zero; Heightmap val = Heightmap.FindHeightmap(point); float num = default(float); if (!Object.op_Implicit((Object)(object)val) || !ZoneSystem.instance.IsZoneLoaded(point) || !val.GetWorldHeight(point, ref num)) { return false; } RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(new Vector3(point.x, num + 3f, point.z), Vector3.down, ref val2, 6f, LayerMask.GetMask(new string[1] { "terrain" }), (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.88f) { return false; } if (((RaycastHit)(ref val2)).point.y <= ZoneSystem.instance.m_waterLevel + 0.5f || val.IsLava(((RaycastHit)(ref val2)).point, 0.6f)) { return false; } if (checkObstacles && Physics.OverlapCapsule(((RaycastHit)(ref val2)).point + Vector3.up * 0.5f, ((RaycastHit)(ref val2)).point + Vector3.up * 2.1f, 0.4f, -1, (QueryTriggerInteraction)1).Any((Collider c) => Object.op_Implicit((Object)(object)c) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent()) && !Object.op_Implicit((Object)(object)((Component)c).GetComponentInParent()))) { return false; } floor = ((RaycastHit)(ref val2)).point; return true; } public static List FloorSamples(Vector3 origin, float radius, float spacing) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (float num = 0f - radius; num <= radius; num += spacing) { for (float num2 = 0f - radius; num2 <= radius; num2 += spacing) { if (num * num + num2 * num2 <= radius * radius && TryFloor(origin + new Vector3(num, 0f, num2), out var floor)) { list.Add(floor); } } } return list; } public static bool SuitableGeneratedGround(Vector3 origin, int stage, out float averageHeight, out string reason, out float range) { //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_0053: 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_0066: 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_006f: 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) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) averageHeight = 0f; reason = ""; range = float.PositiveInfinity; Biome val = StageBiome(stage); float num = float.MaxValue; float num2 = float.MinValue; Color val3 = default(Color); for (float num3 = -36f; num3 <= 36f; num3 += 4f) { for (float num4 = -36f; num4 <= 36f; num4 += 4f) { if (!(num3 * num3 + num4 * num4 > 1296f)) { Vector3 val2 = origin + new Vector3(num3, 0f, num4); if (WorldGenerator.instance.GetBiome(val2) != val) { reason = "biome_edge"; return false; } float height = WorldGenerator.instance.GetHeight(val2.x, val2.z, ref val3); if (stage == 6 && val3.a > 0.45f) { reason = "lava"; return false; } if (float.IsNaN(height) || float.IsInfinity(height) || height <= ZoneSystem.instance.m_waterLevel - ((stage == 2) ? 5f : (-1f))) { reason = "water"; return false; } num = Mathf.Min(num, height); num2 = Mathf.Max(num2, height); } } } range = num2 - num; averageHeight = Math.Max(ZoneSystem.instance.m_waterLevel + 1.5f, (num2 + num) * 0.5f); if (Math.Max(num2 - averageHeight, averageHeight - num) > 7.5f) { reason = "slope"; return false; } return true; } static BiomeTerrain() { Biome[] array = new Biome[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); biomes = (Biome[])(object)array; } } internal static class GuardianProtection { [HarmonyPatch(typeof(WearNTear), "Damage")] private static class BuildingHit { private static bool Prefix(HitData hit) { return !IsGuardian(hit); } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] private static class BuildingOwnerHit { private static bool Prefix(HitData hit) { return !IsGuardian(hit); } } [HarmonyPatch(typeof(Aoe), "Setup")] private static class GuardianAreaDamage { private static void Postfix(Aoe __instance, Character owner) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)owner) || guardianImpact != 0) { HitData val = new HitData(); val.SetAttacker(owner); if (IsGuardian(val)) { ProtectArea(__instance); } } } } private sealed class GuardianProjectile : MonoBehaviour { } [HarmonyPatch(typeof(Projectile), "Setup")] private static class MarkProjectile { private static void Postfix(Projectile __instance, Character owner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown HitData val = new HitData(); val.SetAttacker(owner); if (IsGuardian(val) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Projectile), "OnHit")] private static class ProjectileImpact { private static void Prefix(Projectile __instance, out bool __state) { __state = Object.op_Implicit((Object)(object)((Component)__instance).GetComponent()); if (__state) { guardianImpact++; } } private static Exception Finalizer(Exception __exception, bool __state) { if (__state) { guardianImpact--; } return __exception; } } [HarmonyPatch(typeof(Aoe), "Awake")] private static class ImpactArea { private static void Postfix(Aoe __instance) { if (guardianImpact > 0) { ProtectArea(__instance); } } } [ThreadStatic] private static int guardianImpact; internal static bool IsGuardian(HitData hit) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (guardianImpact > 0) { return true; } if (hit == null || ZDOMan.instance == null || ((ZDOID)(ref hit.m_attacker)).IsNone()) { return false; } ZDO zDO = ZDOMan.instance.GetZDO(hit.m_attacker); if (zDO != null && zDO.GetPrefab() == StringExtensionMethods.GetStableHashCode("DreadRifts_Guardian")) { return zDO.GetString("dr_gate", "").Length > 0; } return false; } private static void ProtectArea(Aoe area) { area.m_hitProps = false; area.m_hitTerrain = false; area.m_spawnOnHitTerrain = null; area.m_groundLavaValue = -1f; } } internal static class ModCompatibility { [HarmonyPatch] private static class EpicLootGuardianDrops { private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("EpicLoot.CharacterDrop_OnDeath_Patch"), "Postfix", (Type[])null, (Type[])null); } private static bool Prepare() { return AccessTools.TypeByName("EpicLoot.CharacterDrop_OnDeath_Patch") != null; } private static bool Prefix(CharacterDrop __0) { RiftActor riftActor = (Object.op_Implicit((Object)(object)__0) ? ((Component)__0).GetComponent() : null); if (Object.op_Implicit((Object)(object)riftActor) && Object.op_Implicit((Object)(object)riftActor.View) && riftActor.View.IsValid()) { return riftActor.View.GetZDO().GetString("dr_gate", "").Length == 0; } return true; } } } internal static class NativeArenaGround { [HarmonyPatch(typeof(ZNetScene), "IsAreaReady")] private static class HoldNativeTeleportUntilGroundLoads { private static void Postfix(Vector3 __0, ref bool __result) { //IL_0036: 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) RiftClient riftClient = Plugin.Instance?.Client; if (__result && riftClient != null && riftClient.InTrial && riftClient.Run.HasCheckpoint && !riftClient.ArenaReady && Vector3.Distance(__0, RiftWire.Vec(riftClient.Run.Checkpoint)) < 80f) { __result = false; } } } private const string Marker = "dr_arena_ground"; private static readonly MethodInfo operation = AccessTools.Method(typeof(TerrainComp), "DoOperation", (Type[])null, (Type[])null); private static readonly MethodInfo createObject = AccessTools.Method(typeof(ZNetScene), "CreateObject", (Type[])null, (Type[])null); public static bool Ensure(ArenaSite site) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) Vector3 val = RiftWire.Vec(site.Origin); if (!BiomeTerrain.Prepare(val)) { return false; } if (!ZNet.instance.IsServer()) { return IsLevel(val); } List list = new List(); Heightmap.FindHeightmap(val, 38f, list); foreach (Heightmap map in list) { TerrainComp val2 = TerrainComp.FindTerrainCompiler(((Component)map).transform.position); if (!Object.op_Implicit((Object)(object)val2)) { int prefab = StringExtensionMethods.GetStableHashCode(((Object)map.m_terrainCompilerPrefab).name); ZDO val3 = RiftWire.NetworkObjects().FirstOrDefault((Func)((ZDO z) => z.GetPrefab() == prefab && Vector3.Distance(z.GetPosition(), ((Component)map).transform.position) < 1f)); if (val3 != null) { ZNetView val4 = ZNetScene.instance.FindInstance(val3); GameObject val5 = (GameObject)(Object.op_Implicit((Object)(object)val4) ? ((object)((Component)val4).gameObject) : ((object)(GameObject)createObject.Invoke(ZNetScene.instance, new object[1] { val3 }))); val2 = (Object.op_Implicit((Object)(object)val5) ? val5.GetComponent() : null); } else { val2 = map.GetAndCreateTerrainCompiler(); } } if (!Object.op_Implicit((Object)(object)val2)) { return false; } ZNetView component = ((Component)val2).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { return false; } string text = component.GetZDO().GetString("dr_arena_ground", ""); if (!(text == site.Id)) { if (text.Length > 0) { throw new InvalidOperationException("Участок уже занят другой ареной."); } component.ClaimOwnership(); if (!component.IsOwner()) { return false; } Settings val6 = new Settings { m_smooth = true, m_smoothRadius = 38f, m_smoothPower = 3f, m_square = false, m_paintCleared = false }; operation.Invoke(val2, new object[3] { val, Vector3.zero, val6 }); map.Poke(0, false); Settings val7 = new Settings { m_level = true, m_levelRadius = 32f, m_square = false, m_paintCleared = false }; operation.Invoke(val2, new object[3] { val, Vector3.zero, val7 }); map.Poke(0, false); component.GetZDO().Set("dr_arena_ground", site.Id); } } Physics.SyncTransforms(); return IsLevel(val); } public static bool IsLevel(Vector3 origin) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) for (int i = -24; i <= 24; i += 4) { for (int j = -24; j <= 24; j += 4) { if (i * i + j * j <= 576 && (!BiomeTerrain.TryFloor(origin + new Vector3((float)i, 0f, (float)j), out var floor, checkObstacles: false) || Math.Abs(floor.y - origin.y) > 0.35f)) { return false; } } } return true; } } public static class InventoryCompatibility { private static readonly List>> providers = new List>>(); public static void Register(Func> provider) { if (provider == null) { throw new ArgumentNullException("provider"); } if (!providers.Contains(provider)) { providers.Add(provider); } } public static Inventory[] GetInventories(Player player) { if (!Object.op_Implicit((Object)(object)player)) { throw new ArgumentNullException("player"); } List list = new List { ((Humanoid)player).GetInventory() }; foreach (Func> provider in providers) { IEnumerable enumerable = provider(player); if (enumerable != null) { list.AddRange(enumerable.Where((Inventory x) => x != null)); } } return list.Distinct().ToArray(); } } internal static class NativeItems { [HarmonyPatch(typeof(Inventory), "FindFreeStackItem")] private static class PreserveStackProperties { [HarmonyPriority(800)] private static bool Prefix(Inventory __instance, ref ItemData __result) { if (__instance != exactInsert) { return true; } __result = null; return false; } [HarmonyPriority(0)] private static void Postfix(Inventory __instance, ref ItemData __result) { if (__instance == exactInsert) { __result = null; } } } [ThreadStatic] private static Inventory exactInsert; public static bool InsertExact(Inventory inventory, ItemData item, Vector2i position) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0036: 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_0054: Unknown result type (might be due to invalid IL or missing references) if (exactInsert != null || position.x < 0 || position.y < 0 || position.x >= inventory.GetWidth() || position.y >= inventory.GetHeight() || inventory.GetItemAt(position.x, position.y) != null) { return false; } try { exactInsert = inventory; return inventory.AddItem(item, position); } finally { exactInsert = null; } } public static ItemPayload Encode(ItemData original) { //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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown if (original == null || !Object.op_Implicit((Object)(object)original.m_dropPrefab) || original.m_stack <= 0) { throw new InvalidOperationException("Item prefab is unavailable."); } ItemData val = original.Clone(); val.m_gridPos = new Vector2i(0, 0); val.m_equipped = false; Inventory val2 = new Inventory("DreadRifts item transfer", (Sprite)null, 1, 1); if (!val2.AddItem(val)) { throw new InvalidOperationException("Item cannot be serialized as a native stack."); } ZPackage val3 = new ZPackage(); val2.Save(val3); byte[] array = val3.GetArray(); return new ItemPayload { Data = Convert.ToBase64String(array), Fingerprint = Digest(array), Prefab = ((Object)original.m_dropPrefab).name, DisplayName = original.m_shared.m_name, Quantity = original.m_stack }; } public static ItemData Decode(ItemPayload payload) { //IL_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) payload.Validate(); byte[] array = Convert.FromBase64String(payload.Data); if (Digest(array) != payload.Fingerprint) { throw new InvalidDataException("Item transfer checksum mismatch."); } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(payload.Prefab); if (!Object.op_Implicit((Object)(object)itemPrefab) || !Object.op_Implicit((Object)(object)itemPrefab.GetComponent())) { throw new InvalidOperationException("The mod providing this item is not currently loaded."); } Inventory val = new Inventory("DreadRifts item restore", (Sprite)null, 1, 1); val.Load(new ZPackage(array)); if (val.NrOfItems() != 1) { throw new InvalidDataException("A transfer must contain one item stack."); } ItemData val2 = val.GetAllItems()[0]; if (!Object.op_Implicit((Object)(object)val2.m_dropPrefab) || ((Object)val2.m_dropPrefab).name != payload.Prefab || val2.m_stack != payload.Quantity || val2.m_stack < 1 || val2.m_stack > val2.m_shared.m_maxStackSize) { throw new InvalidDataException("Item transfer metadata does not match its contents."); } return val2; } public static bool FindEmptySlot(Inventory inventory, out Vector2i position) { //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_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) for (int i = 0; i < inventory.GetHeight(); i++) { for (int j = 0; j < inventory.GetWidth(); j++) { if (inventory.GetItemAt(j, i) == null) { position = new Vector2i(j, i); return true; } } } position = new Vector2i(-1, -1); return false; } public static int RepairDurability(Player player) { int num = 0; Inventory[] inventories = InventoryCompatibility.GetInventories(player); foreach (Inventory val in inventories) { bool flag = false; ItemData[] array = val.GetAllItems().ToArray(); foreach (ItemData val2 in array) { if (val2.m_shared.m_useDurability) { float maxDurability = val2.GetMaxDurability(); if (!float.IsNaN(maxDurability) && !float.IsInfinity(maxDurability) && !(maxDurability <= val2.m_durability)) { val2.m_durability = maxDurability; num++; flag = true; } } } if (flag) { AccessTools.Method(typeof(Inventory), "Changed", (Type[])null, (Type[])null).Invoke(val, new object[2] { false, false }); } } return num; } private static string Digest(byte[] bytes) { using SHA256 sHA = SHA256.Create(); return BitConverter.ToString(sHA.ComputeHash(bytes)).Replace("-", "").ToLowerInvariant(); } } internal static class NativeProfileSave { [HarmonyPatch(typeof(PlayerProfile), "Save")] internal static class SaveResult { private static void Postfix(PlayerProfile __instance, bool __result) { if (__instance == expected) { observed = true; returnedSuccess = __result; } } } [ThreadStatic] private static PlayerProfile expected; [ThreadStatic] private static bool observed; [ThreadStatic] private static bool returnedSuccess; private static readonly FieldInfo playerData = AccessTools.Field(typeof(PlayerProfile), "m_playerData"); public static bool TrySave(Player player, out string error) { //IL_00a0: 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_00ab: Expected O, but got Unknown error = ""; if (!Object.op_Implicit((Object)(object)player) || (Object)(object)player != (Object)(object)Player.m_localPlayer || !Object.op_Implicit((Object)(object)Game.instance) || expected != null) { error = "Character save is unavailable."; return false; } try { expected = Game.instance.GetPlayerProfile(); observed = (returnedSuccess = false); Game.instance.SavePlayerProfile(false, false); if (!observed || !returnedSuccess) { error = "The game did not confirm the character save."; return false; } byte[] array = (byte[])playerData.GetValue(expected); PlayerProfile val = new PlayerProfile(expected.GetFilename(), expected.m_fileSource); if (!val.Load()) { error = "The saved character could not be read back."; return false; } byte[] array2 = (byte[])playerData.GetValue(val); if (array == null || array2 == null || !array.SequenceEqual(array2)) { error = "The active save does not contain the inventory operation yet."; return false; } return true; } catch (Exception ex) { error = ex.Message; return false; } finally { expected = null; } } } internal static class PlayerLifecycle { [HarmonyPatch(typeof(Player), "OnDeath")] private static class Death { [HarmonyPriority(800)] private static void Prefix(Player __instance, out bool __state) { __state = (Object)(object)__instance == (Object)(object)Player.m_localPlayer && Object.op_Implicit((Object)(object)Plugin.Instance) && Plugin.Instance.Client.InTrial; if (__state) { deathScope++; ArenaSpectator.Begin(__instance); Plugin.Instance.Client.Send("death"); Plugin.Instance.Client.Close(); } } [HarmonyPriority(0)] private static Exception Finalizer(Exception __exception, bool __state) { if (__state) { deathScope--; } return __exception; } } [HarmonyPatch(typeof(ZoneSystem), "GetGlobalKey", new Type[] { typeof(GlobalKeys) })] private static class NativeDeathRules { private static bool Prefix(GlobalKeys key, ref bool __result) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if (deathScope <= 0) { return true; } if ((int)key == 23) { __result = true; return false; } if ((int)key == 22) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(Skills), "OnDeath")] private static class SkillLoss { private static bool Prefix() { return deathScope <= 0; } } [HarmonyPatch(typeof(Game), "RequestRespawn")] private static class RespawnDelay { private static void Prefix(ref float delay, bool afterDeath) { if (deathScope > 0 && afterDeath) { delay = 60f; } } } [HarmonyPatch(typeof(Game), "FindSpawnPoint")] private static class SpawnPoint { private static bool Prefix(ref Vector3 point, ref bool usedLogoutPoint, ref bool __result) { //IL_0029: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Plugin.Instance) || GUIManager.IsHeadless()) { return true; } RiftClient client = Plugin.Instance.Client; if (!client.Synced) { point = Vector3.zero; usedLogoutPoint = false; __result = false; return false; } if (!client.InTrial) { return true; } Member own = client.Own; if (!client.Run.HasCheckpoint || (own.Dead && client.ServerNow < own.RespawnAtMs)) { point = Vector3.zero; usedLogoutPoint = false; __result = false; return false; } point = RiftWire.Vec(client.Run.Checkpoint); usedLogoutPoint = false; ZNet.instance.SetReferencePosition(point); __result = ArenaRuntime.TryEnsure(client.Run, out var arena) && arena.CheckpointSupported() && ZNetScene.instance.IsAreaReady(point); return false; } } [ThreadStatic] private static int deathScope; } internal sealed class RiftActor : MonoBehaviour { [HarmonyPatch(typeof(Character), "Awake")] private static class Attach { private static void Postfix(Character __instance) { if (__instance.IsPlayer() || !Object.op_Implicit((Object)(object)Plugin.Instance)) { return; } ZNetView component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { return; } ZDO zDO = component.GetZDO(); if (zDO.GetString("dr_run", "").Length == 0 && zDO.GetString("dr_gate", "").Length == 0) { if (spawnOrigin == null || !component.IsOwner()) { return; } RunState runState = spawnOrigin.Resolve(); if (runState == null) { return; } zDO.Set("dr_run", runState.Id); zDO.Set("dr_actor", "summon:" + RiftWire.Identity(zDO)); zDO.Set("dr_stage", runState.Stage); zDO.Set("dr_floor", runState.Level); zDO.Set("dr_attempt", runState.Attempt); zDO.Set("dr_damage", StageCatalog.DamageFactor(runState.Difficulty)); zDO.Set("dr_health", StageCatalog.HealthFactor(runState.Difficulty)); zDO.Persistent = true; } if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { ((Component)__instance).gameObject.AddComponent(); } ((Behaviour)__instance).enabled = true; } } private sealed class DeathScope { public RiftSpawnContext Spawn; public RiftSpawnContext Loot; } [HarmonyPatch(typeof(Character), "OnDeath")] private static class Death { private static bool Prefix(Character __instance, out DeathScope __state) { __state = new DeathScope { Spawn = spawnOrigin, Loot = RiftLootDrop.Origin }; RiftActor component = ((Component)__instance).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.DeferDeath()) { return false; } spawnOrigin = Origin(__instance); RiftLootDrop.Origin = ((Object.op_Implicit((Object)(object)component) && component.approvedDeath) ? spawnOrigin : null); return true; } private static Exception Finalizer(Exception __exception, DeathScope __state) { if (__state != null) { spawnOrigin = __state.Spawn; RiftLootDrop.Origin = __state.Loot; } return __exception; } } [HarmonyPatch(typeof(Projectile), "Awake")] private static class RememberDeathProjectile { private static void Postfix(Projectile __instance) { RiftSpawnSource.Remember((Component)(object)__instance, spawnOrigin); } } [HarmonyPatch(typeof(Projectile), "Setup")] private static class RememberAttackProjectile { private static void Prefix(Projectile __instance, Character owner) { RiftSpawnSource.Remember((Component)(object)__instance, Origin(owner) ?? spawnOrigin); } } [HarmonyPatch(typeof(SpawnAbility), "Awake")] private static class RememberSpawnAbility { private static void Prefix(SpawnAbility __instance) { RiftSpawnSource.Remember((Component)(object)__instance, spawnOrigin); } } [HarmonyPatch(typeof(Projectile), "SpawnOnHit")] private static class ProjectileSummons { private static void Prefix(Projectile __instance, out RiftSpawnContext __state) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown __state = spawnOrigin; spawnOrigin = Origin((Character)AccessTools.Field(typeof(Projectile), "m_owner").GetValue(__instance)) ?? RiftSpawnSource.Read((Component)(object)__instance) ?? spawnOrigin; } private static Exception Finalizer(Exception __exception, RiftSpawnContext __state) { spawnOrigin = __state; return __exception; } } [HarmonyPatch(typeof(Attack), "SpawnOnHit")] private static class AttackSummons { private static void Prefix(Attack __instance, out RiftSpawnContext __state) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown __state = spawnOrigin; spawnOrigin = Origin((Character)AccessTools.Field(typeof(Attack), "m_character").GetValue(__instance)); } private static Exception Finalizer(Exception __exception, RiftSpawnContext __state) { spawnOrigin = __state; return __exception; } } [HarmonyPatch(typeof(Attack), "SpawnOnHitTerrain")] private static class TerrainSummons { private static void Prefix(Character character, out RiftSpawnContext __state) { __state = spawnOrigin; spawnOrigin = Origin(character); } private static Exception Finalizer(Exception __exception, RiftSpawnContext __state) { spawnOrigin = __state; return __exception; } } [HarmonyPatch(typeof(SpawnAbility), "Spawn")] private static class AbilitySummons { private static void Postfix(SpawnAbility __instance, ref IEnumerator __result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown RiftSpawnContext riftSpawnContext = Origin((Character)AccessTools.Field(typeof(SpawnAbility), "m_owner").GetValue(__instance)) ?? RiftSpawnSource.Read((Component)(object)__instance) ?? spawnOrigin; if (riftSpawnContext != null) { __result = WithOrigin(__result, riftSpawnContext); } } private static IEnumerator WithOrigin(IEnumerator routine, RiftSpawnContext origin) { while (true) { if (origin.Resolve() == null) { (routine as IDisposable)?.Dispose(); break; } RiftSpawnContext spawnOrigin = RiftActor.spawnOrigin; bool flag; object obj; try { RiftActor.spawnOrigin = origin; flag = routine.MoveNext(); obj = (flag ? routine.Current : null); } finally { RiftActor.spawnOrigin = spawnOrigin; } if (!flag) { break; } yield return obj; } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class Damage { private static void Prefix(HitData hit) { Character attacker = hit.GetAttacker(); RiftActor riftActor = (Object.op_Implicit((Object)(object)attacker) ? ((Component)attacker).GetComponent() : null); if (Object.op_Implicit((Object)(object)riftActor)) { hit.ApplyModifier(riftActor.DamageFactor); } } } [HarmonyPatch(typeof(MonsterAI), "UpdateTarget")] private static class AltarTarget { private static void Postfix(MonsterAI __instance) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) RiftActor component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.View) || !component.View.IsValid() || !component.View.IsOwner() || !component.View.GetZDO().GetBool("dr_altar", false)) { return; } RunState state = component.State; if (state != null && state.Phase == RunPhase.Combat && !(state.AltarHealth <= 0f)) { ArenaRuntime arenaRuntime = ArenaRuntime.Find(state.Id, ((Component)component).transform.position); if (arenaRuntime != null && Object.op_Implicit((Object)(object)arenaRuntime.AltarTarget)) { AccessTools.Field(typeof(MonsterAI), "m_targetStatic").SetValue(__instance, arenaRuntime.AltarTarget); AccessTools.Field(typeof(MonsterAI), "m_targetCreature").SetValue(__instance, null); } } } } [HarmonyPatch(typeof(BaseAI), "UpdateAI")] private static class PausedAI { private static bool Prefix(BaseAI __instance, ref bool __result) { RiftActor component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !component.Paused) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ItemDrop), "Load")] private static class KeyBinding { private static void Postfix(ItemDrop __instance) { ZNetView component = ((Component)__instance).GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.IsValid()) { string text = component.GetZDO().GetString("dr_key_gate", ""); if (text.Length != 0) { __instance.m_itemData.m_customData["dreadrifts.gate"] = text; __instance.m_itemData.m_customData["dreadrifts.grant"] = component.GetZDO().GetString("dr_key_grant", ""); } } } } [ThreadStatic] private static RiftSpawnContext spawnOrigin; private static readonly List live = new List(); public ZNetView View; private Character character; private BaseAI ai; private bool initialized; private bool awaitingDeath; private bool approvedDeath; private float nextTick; private Rigidbody body; private bool frozen; public string RunId { get { if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return ""; } return View.GetZDO().GetString("dr_run", ""); } } public string ActorId { get { if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return ""; } return View.GetZDO().GetString("dr_actor", ""); } } public float DamageFactor { get { if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return 1f; } return View.GetZDO().GetFloat("dr_damage", 1f); } } private RunState State { get { RunState runState = Plugin.Instance.Server.FindRun(RunId); if (runState == null) { if (!(Plugin.Instance.Client.Run?.Id == RunId)) { return null; } runState = Plugin.Instance.Client.Run; } return runState; } } private bool Paused { get { if (RunId.Length > 0) { if (State != null && State.Phase != RunPhase.Paused && State.HasCheckpoint) { ArenaSite arenaSite = ArenaSites.Current(State); if (arenaSite == null) { return true; } return !arenaSite.Ready; } return true; } return false; } } private void Awake() { View = ((Component)this).GetComponent(); character = ((Component)this).GetComponent(); ai = ((Component)this).GetComponent(); body = ((Component)this).GetComponent(); live.Add(this); } private void OnDestroy() { live.Remove(this); } private void Start() { if (Object.op_Implicit((Object)(object)character) && Object.op_Implicit((Object)(object)View) && View.IsValid()) { ((Behaviour)character).enabled = true; Initialize(); } } private void Initialize() { //IL_0089: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown if (initialized || !Object.op_Implicit((Object)(object)character) || !Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return; } ((Behaviour)character).enabled = true; character.m_defeatSetGlobalKey = ""; character.m_dreamCinematic = ""; character.m_bossEvent = ""; character.m_group = "DreadRifts"; character.m_faction = (Faction)8; character.m_tolerateFire = true; character.m_tolerateSmoke = true; if (RunId.Length > 0 && View.GetZDO().GetInt(ZDOVars.s_level, 1) > 1) { character.m_name = "Элита · " + Localization.instance.Localize(character.m_name); Light obj = ((Component)this).gameObject.AddComponent(); obj.color = new Color(0.64f, 0.3f, 1f); obj.range = 2.2f; obj.intensity = 0.7f; ((Component)this).gameObject.AddComponent(); } if (View.GetZDO().GetString("dr_gate", "").Length > 0) { CharacterDrop component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.m_drops = new List(); component.SetDropsEnabled(false); } } if (Object.op_Implicit((Object)(object)ai)) { string[] array = new string[2] { "m_despawnInDay", "m_eventCreature" }; foreach (string text in array) { FieldInfo fieldInfo = AccessTools.Field(((object)ai).GetType(), text); if (fieldInfo != null && fieldInfo.FieldType == typeof(bool)) { fieldInfo.SetValue(ai, false); } } ai.SetHuntPlayer(true); } HashSet phases = new HashSet { "FrozenKing_p2", "FrozenKing_p3" }; character.m_deathEffects = new EffectList { m_effectPrefabs = character.m_deathEffects.m_effectPrefabs.Where((EffectData x) => !Object.op_Implicit((Object)(object)x.m_prefab) || !phases.Contains(((Object)x.m_prefab).name)).ToArray() }; initialized = true; } private void Update() { //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return; } if (!initialized) { Initialize(); } if (!View.IsOwner()) { return; } if (RunId.Length > 0) { _ = State; bool paused = Paused; if (Object.op_Implicit((Object)(object)body) && frozen != paused) { body.isKinematic = paused; frozen = paused; } if (paused) { return; } } if (Time.unscaledTime < nextTick) { return; } nextTick = Time.unscaledTime + 1f; ZDO zDO = View.GetZDO(); if (!zDO.GetBool("dr_initialized", false)) { float num = ((zDO.GetPrefab() == StringExtensionMethods.GetStableHashCode("FrozenKing_p2")) ? 1f : zDO.GetFloat("dr_health", 1f)); float num2 = character.GetMaxHealth() * num; float num3 = character.GetHealth() / Math.Max(1f, character.GetMaxHealth()); character.SetMaxHealth(num2); character.SetHealth(num2 * num3); zDO.Set("dr_initialized", true); } if (RunId.Length > 0) { RunState state = State; ArenaRuntime arenaRuntime = ArenaRuntime.Find(RunId, ((Component)this).transform.position); if (state != null && arenaRuntime == null && state.HasCheckpoint) { if (ArenaRuntime.TryEnsure(state, out var arena)) { Vector3 position = arena.SpawnPoint(0); ((Component)this).transform.position = position; if (Object.op_Implicit((Object)(object)body)) { body.position = position; body.linearVelocity = Vector3.zero; } } return; } if (state != null && !state.Enemies.Any((EnemyRecord x) => x.Id == ActorId)) { if (arenaRuntime == null || !arenaRuntime.Geometry.Contains(zDO.GetPosition())) { return; } Plugin.Instance.Wire.Request(new RiftRequest { Command = "adopt", RunId = RunId, ActorId = ActorId, NetworkId = RiftWire.Identity(zDO) }); if (!state.Enemies.Any((EnemyRecord x) => x.Id == ActorId)) { return; } } } if (awaitingDeath) { Plugin.Instance.Wire.Request(new RiftRequest { Command = "actor_dead", RunId = RunId, ActorId = ActorId, NetworkId = RiftWire.Identity(zDO), Number = ((zDO.GetString("dr_gate", "").Length > 0) ? zDO.GetInt("dr_generation", 0) : zDO.GetInt("dr_phase", 0)), GateId = zDO.GetString("dr_gate", "") }); } else { if (character.GetHealth() <= 0f) { return; } BaseAI obj = ai; MonsterAI val = (MonsterAI)(object)((obj is MonsterAI) ? obj : null); if (val != null) { if (val.m_sleeping) { AccessTools.Method(typeof(MonsterAI), "Wakeup", (Type[])null, (Type[])null).Invoke(val, null); } ((BaseAI)val).SetHuntPlayer(true); ((BaseAI)val).Alert(); } } } public static void Acknowledge(string networkId) { RiftActor riftActor = live.FirstOrDefault((RiftActor x) => Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)x.View) && x.View.IsValid() && RiftWire.Identity(x.View.GetZDO()) == networkId); if (Object.op_Implicit((Object)(object)riftActor) && riftActor.View.IsOwner() && riftActor.awaitingDeath && !riftActor.approvedDeath) { riftActor.approvedDeath = true; riftActor.character.OnDeath(); } } private bool DeferDeath() { if (approvedDeath || !Object.op_Implicit((Object)(object)View) || !View.IsValid() || !View.IsOwner()) { return false; } awaitingDeath = true; nextTick = 0f; return true; } private static RiftSpawnContext Origin(Character character) { return RiftSpawnContext.FromActor(character); } } internal sealed class RiftLootDrop : MonoBehaviour { [HarmonyPatch(typeof(ItemDrop), "Awake")] private static class NewDrop { private static void Postfix(ItemDrop __instance) { Attach(__instance); } } [HarmonyPatch(typeof(ItemDrop), "Load")] private static class LoadedDrop { private static void Postfix(ItemDrop __instance) { Attach(__instance); } } [HarmonyPatch(typeof(ItemDrop), "CanPickup")] private static class CanPickup { private static bool Prefix(ItemDrop __instance, ref bool __result) { if (!Tagged(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ItemDrop), "Pickup")] private static class Pickup { private static bool Prefix(ItemDrop __instance) { return !Tagged(__instance); } } [HarmonyPatch(typeof(ItemDrop), "AutoStackItems")] private static class Stack { private static bool Prefix(ItemDrop __instance) { return !Tagged(__instance); } } [ThreadStatic] internal static RiftSpawnContext Origin; private ItemDrop drop; private ZNetView view; private float captureAt; internal static bool Tagged(ItemDrop item) { ZNetView val = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponent() : null); if (Object.op_Implicit((Object)(object)val) && val.IsValid()) { return val.GetZDO().GetString("dr_loot_id", "").Length > 0; } return false; } internal static void Attach(ItemDrop item) { ZNetView val = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponent() : null); if (!Object.op_Implicit((Object)(object)val) || !val.IsValid()) { return; } ZDO zDO = val.GetZDO(); if (zDO.GetString("dr_loot_id", "").Length == 0 && Origin != null && val.IsOwner()) { zDO.Set("dr_loot_id", Guid.NewGuid().ToString("N")); zDO.Set("dr_loot_run", Origin.RunId); zDO.Set("dr_loot_round", Origin.RunId + ":" + Origin.Stage + ":" + Origin.Floor + ":" + Origin.Attempt); zDO.Set("dr_loot_actor", Origin.ActorId ?? ""); zDO.Persistent = true; } if (zDO.GetString("dr_loot_id", "").Length != 0) { if (!Object.op_Implicit((Object)(object)((Component)item).GetComponent())) { ((Component)item).gameObject.AddComponent(); } Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } private void Awake() { drop = ((Component)this).GetComponent(); view = ((Component)this).GetComponent(); captureAt = Time.unscaledTime + 0.25f; } private void LateUpdate() { //IL_0088: 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) if (!Object.op_Implicit((Object)(object)drop) || !Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return; } Collider[] componentsInChildren = ((Component)drop).GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } if (Time.unscaledTime < captureAt) { return; } ((MonoBehaviour)drop).CancelInvoke(); ((Behaviour)drop).enabled = false; Rigidbody component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component) && !component.isKinematic) { component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.isKinematic = true; } if (!view.IsOwner() || view.GetZDO().GetString("dr_loot_payload", "").Length > 0) { return; } try { ItemPayload value = NativeItems.Encode(drop.m_itemData); AccessTools.Method(typeof(ItemDrop), "Save", (Type[])null, (Type[])null).Invoke(drop, null); view.GetZDO().Set("dr_loot_payload", DataCodec.Encode(value)); } catch (Exception error) { captureAt = Time.unscaledTime + 3f; Plugin.Instance.Fail(error); } } } internal sealed class RiftServer { private sealed class CirclePulse { public string Token; public long At; public bool Eligible; } private float nextLootTick; private readonly Dictionary circlePulses = new Dictionary(); private readonly Dictionary partyCircles = new Dictionary(); private float nextCircleTick; private float lastPortalTick; private readonly Plugin plugin; private WorldState world; private AtomicStore store; private string fault = ""; private float nextTick; private int arenaSearchTurn; private readonly Dictionary sessions = new Dictionary(); private readonly Dictionary observedPositions = new Dictionary(); private readonly Dictionary altarHits = new Dictionary(); private readonly Dictionary arenaSearches = new Dictionary(); private readonly HashSet arenaMigrations = new HashSet(); private void BeginLootCollection(RunState run) { string item = NextLevelCircle.Encounter(run); if (!run.ClearedLootRounds.Contains(item)) { run.ClearedLootRounds.Add(item); } run.LootSettled = false; run.LootCollectAfterMs = RiftWire.Now + 1500; run.CircleEndsAtMs = 0L; } private void TickArenaLoot() { //IL_01aa: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < nextLootTick) { return; } nextLootTick = Time.unscaledTime + 0.25f; ZDO[] source = (from z in RiftWire.NetworkObjects() where z.GetString("dr_loot_id", "").Length > 0 select z).ToArray(); foreach (RunState run in world.Runs) { bool flag = false; bool flag2 = false; List list = new List(); foreach (ZDO item in source.Where((ZDO x) => x.GetString("dr_loot_run", "") == run.Id)) { string id = item.GetString("dr_loot_id", ""); string text = item.GetString("dr_loot_round", ""); ArenaLootEntry arenaLootEntry = run.ArenaLoot.FirstOrDefault((ArenaLootEntry x) => x.Id == id); string text2 = item.GetString("dr_loot_payload", ""); if (text2.Length == 0) { flag2 = true; continue; } bool flag3 = run.LootSources.Contains(text + "|" + item.GetString("dr_loot_actor", "")); if (arenaLootEntry == null && !flag3) { flag2 = true; continue; } ItemPayload itemPayload = DataCodec.Decode(text2); Expedition.Require(StringExtensionMethods.GetStableHashCode(itemPayload.Prefab) == item.GetPrefab(), "Arena loot prefab changed."); flag |= RoundLoot.Record(run, id, text, RiftWire.Pos(item.GetPosition()), itemPayload); arenaLootEntry = run.ArenaLoot.First((ArenaLootEntry x) => x.Id == id); if (arenaLootEntry.Stored) { list.Add(item); } } if ((run.Phase == RunPhase.Intermission || run.Phase == RunPhase.Complete || (run.Phase == RunPhase.Paused && run.PhaseBeforePause == RunPhase.Intermission)) && RiftWire.Now >= run.LootCollectAfterMs && !flag2) { ArenaLootEntry[] array = run.ArenaLoot.Where((ArenaLootEntry x) => !x.Stored).ToArray(); if (array.Length != 0) { run.LootOrigins = (from x in array.Take(24) select x.Origin.Copy()).ToList(); run.LootCollectedUnits = RoundLoot.StoreAfterVictory(run); run.LootCollectedAtMs = RiftWire.Now; flag = true; } if (!run.LootSettled) { run.LootSettled = true; flag = true; } if (run.Level == 10 && run.Stage + 1 == StageCatalog.Stages.Length && run.Phase == RunPhase.Intermission) { run.Phase = RunPhase.Complete; flag = true; } foreach (ZDO item2 in source.Where((ZDO x) => x.GetString("dr_loot_run", "") == run.Id && run.ArenaLoot.Any((ArenaLootEntry e) => e.Id == x.GetString("dr_loot_id", "") && e.Stored))) { if (!list.Contains(item2)) { list.Add(item2); } } } if (flag) { Save(); SendRunState(run); } foreach (ZDO item3 in list) { RemoveNetworkObject(item3); } } } private static string PulseKey(RunState run, long player) { return run.Id + ":" + player; } private void ReceiveCirclePresence(RunState run, Member member, RiftRequest request) { if (member.Present && member.Connected && !(request.Encounter != PartyCircle.Token(run))) { circlePulses[PulseKey(run, member.PlayerId)] = new CirclePulse { Token = request.Encounter, At = RiftWire.Now, Eligible = request.Flag }; } } private void TickPartyCircles() { //IL_00ff: 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) if (Time.unscaledTime < nextCircleTick) { return; } nextCircleTick = Time.unscaledTime + 0.1f; long now = RiftWire.Now; foreach (RunState run in world.Runs) { if (!partyCircles.TryGetValue(run.Id, out var value)) { value = (partyCircles[run.Id] = new PartyCircle()); } string text = CircleStamp(run); string text2 = PartyCircle.Token(run); CircleAction circleAction = PartyCircle.Action(run); List list = new List(); foreach (Member item in run.Members.Where((Member x) => x.Present && x.Connected)) { long num = PeerFor(item.PlayerId); int num2; if (num != ZNet.GetUID()) { ZNetPeer peer = ZNet.instance.GetPeer(num); num2 = ((peer != null && ZDOMan.instance.GetZDO(peer.m_characterID) != null) ? 1 : 0); } else { num2 = ((Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Character)Player.m_localPlayer).IsDead() && !((Character)Player.m_localPlayer).IsTeleporting()) ? 1 : 0); } bool flag = (byte)num2 != 0; CirclePulse value2; bool flag2 = circlePulses.TryGetValue(PulseKey(run, item.PlayerId), out value2) && value2.Token == text2 && value2.Eligible && now - value2.At <= 1000; list.Add(new CirclePresence { PlayerId = item.PlayerId, Position = ((num != 0 && flag) ? RiftWire.Pos(PlayerPosition(num)) : null), Eligible = (flag && flag2 && !item.Dead) }); } bool flag3 = HasPending(run, 0L); bool flag4 = ((circleAction == CircleAction.Start) ? WorldBoss(run.Stage) : (run.Level < 10 || WorldBoss(run.Stage + 1))); bool enabled = run.LootSettled && !flag3 && flag4; run.CircleMessage = ((!run.LootSettled) ? "Добыча собирается на склад…" : (flag3 ? "Завершается перенос предметов…" : ((!flag4) ? "Сначала победите босса этого этапа в обычном мире" : ""))); switch (value.Update(run, list, now, enabled)) { case CircleAction.Start: Expedition.Begin(run, WorldBoss(run.Stage), now, StageCatalog.Waves(run.Level), Encounters.AltarHealthForParty(run)); run.CircleEndsAtMs = 0L; Save(); break; case CircleAction.Advance: if (Expedition.Advance(run, StageCatalog.Stages.Length, WorldBoss(run.Stage + 1))) { PrepareArena(run); } foreach (Member member in run.Members) { member.Ready = false; } run.CircleEndsAtMs = 0L; Save(); break; } if (text != CircleStamp(run)) { SendRunState(run); } } } private static string CircleStamp(RunState run) { return run.Phase.ToString() + ":" + run.Stage + ":" + run.Level + ":" + run.CircleEndsAtMs + ":" + run.CircleMessage + ":" + string.Join(",", from m in run.Members where m.Ready select m.PlayerId); } private void SendRunState(RunState run) { foreach (Member item in run.Members.Where((Member x) => x.Present && x.Connected)) { long num = PeerFor(item.PlayerId); if (num != 0L) { plugin.Wire.Reply(num, View(run, item.PlayerId, "state")); } } } private void TickPortals() { //IL_00e5: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; if (unscaledTime - lastPortalTick < 0.1f) { return; } long elapsedMs = ((lastPortalTick == 0f) ? 0 : ((long)((unscaledTime - lastPortalTick) * 1000f))); lastPortalTick = unscaledTime; if (Time.timeScale <= 0f) { return; } foreach (RunState item in world.Runs.Where(Expedition.IsCombat)) { item.PortalClockAtMs = RiftWire.Now; if (item.Phase != RunPhase.Combat || !item.HasCheckpoint || !item.Members.Any((Member m) => m.Connected && m.Present)) { continue; } ArenaRuntime arenaRuntime = ArenaRuntime.Find(item.Id, RiftWire.Vec(item.Checkpoint)); if (arenaRuntime == null) { continue; } PortalWaves.Advance(item, elapsedMs); EnemyRecord enemyRecord = PortalWaves.Due(item); if (enemyRecord != null) { GameObject prefab = ZNetScene.instance.GetPrefab(ActorLifecycle.ExpectedPrefab(item, enemyRecord)); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Противник для арки недоступен: " + enemyRecord.Prefab); } if (arenaRuntime.TryPortalSpawn(enemyRecord.PortalIndex, enemyRecord.PortalSlot, prefab, out var position)) { SpawnActor(item, enemyRecord, position, Quaternion.LookRotation(-ArenaPortals.Direction(enemyRecord.PortalIndex), Vector3.up)); } } } } private void SpawnActor(RunState run, EnemyRecord actor, Vector3 position, Quaternion rotation) { //IL_0069: 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) SpawnPlan spawnPlan = Encounters.Wave(run, actor.Wave).FirstOrDefault((SpawnPlan x) => x.Id == actor.Id) ?? new SpawnPlan { Id = actor.Id, Prefab = actor.Prefab }; string text = ActorLifecycle.ExpectedPrefab(run, actor); ZDO val = CreateNetworkObject(text, position); val.SetRotation(rotation); val.Set("dr_run", run.Id); val.Set("dr_actor", actor.Id); val.Set("dr_phase", actor.PhaseIndex); val.Set("dr_stage", run.Stage); val.Set("dr_floor", run.Level); val.Set("dr_attempt", run.Attempt); val.Set("dr_health", (text == "FrozenKing_p2") ? 1f : StageCatalog.HealthFactor(run.Difficulty)); val.Set("dr_damage", StageCatalog.DamageFactor(run.Difficulty)); val.Set("dr_altar", Expedition.Objective(run.Level) == ObjectiveKind.Defend && run.Enemies.IndexOf(actor) % 2 == 0); val.Set("dr_portal", actor.PortalIndex); val.Set(ZDOVars.s_level, spawnPlan.Level, false); actor.NetworkId = ""; ActorLifecycle.Bind(run, actor.Id, actor.PhaseIndex, text, RiftWire.Identity(val)); Save(); val.SetOwner(0L); } public RiftServer(Plugin plugin) { this.plugin = plugin; } public RunState FindRun(string id) { return world?.Runs.FirstOrDefault((RunState x) => x.Id == id); } private bool WorldBoss(int stage) { if (stage >= 0 && stage < StageCatalog.Stages.Length) { return ZoneSystem.instance.GetGlobalKey(StageCatalog.WorldDefeatKeys[stage]); } return false; } private void Load() { if (world != null || fault.Length != 0 || !Object.op_Implicit((Object)(object)ZoneSystem.instance) || ZDOMan.instance == null) { return; } try { string text = ZNet.instance.GetWorldUID().ToString(); store = new AtomicStore(Path.Combine(Paths.ConfigPath, "DreadRifts", "world-" + text + ".dat")); world = store.Load(); Expedition.Require(world.SchemaVersion == 1, "Unsupported expedition save version."); Expedition.Require(world.WorldId.Length == 0 || world.WorldId == text, "Expedition save belongs to another world."); world.WorldId = text; RebindLoadedObjects(); foreach (RunState run in world.Runs) { run.PortalClockAtMs = 0L; run.CircleEndsAtMs = 0L; run.CircleMessage = ""; foreach (ArenaSite arenaSite in run.ArenaSites) { BiomeArenaPlacement.Register(arenaSite); } if (ArenaSites.Current(run) == null && run.HasCheckpoint) { run.HasCheckpoint = false; arenaMigrations.Add(run.Id); } foreach (Member member in run.Members) { member.Connected = false; member.Ready = false; } if (run.Phase != RunPhase.Paused && run.Phase != RunPhase.Complete) { run.PhaseBeforePause = run.Phase; run.Phase = RunPhase.Paused; } } Save(); } catch (Exception ex) { fault = ex.Message; plugin.Fail(ex); } } private void RebindLoadedObjects() { ZDO[] source = RiftWire.NetworkObjects().ToArray(); foreach (GateState gate in world.Gates) { if (((IEnumerable)source).FirstOrDefault((Func)((ZDO x) => x.GetPrefab() == StringExtensionMethods.GetStableHashCode("DreadRifts_Gate") && x.GetString("dr_gate_id", "") == gate.Id)) == null) { ZDO[] array = source.Where((ZDO x) => x.GetPrefab() == StringExtensionMethods.GetStableHashCode("DreadRifts_Gate") && x.GetString("dr_gate_id", "").Length == 0 && Vector3.Distance(x.GetPosition(), RiftWire.Vec(gate.Position)) < 0.1f).ToArray(); if (array.Length == 1) { array[0].Set("dr_gate_id", gate.Id); } } ZDO[] source2 = source.Where((ZDO x) => x.GetString("dr_gate", "") == gate.Id && x.GetInt("dr_generation", 0) == gate.GuardianGeneration).ToArray(); ZDO guardian = (gate.GuardianAlive ? (((IEnumerable)source2).FirstOrDefault((Func)((ZDO x) => RiftWire.Identity(x) == gate.GuardianNetworkId)) ?? source2.FirstOrDefault()) : null); gate.GuardianNetworkId = ((guardian == null) ? "" : RiftWire.Identity(guardian)); foreach (ZDO item in source2.Where((ZDO x) => x != guardian)) { RemoveNetworkObject(item); } foreach (KeyGrant grant in gate.KeyGrants) { ZDO val = ((IEnumerable)source).FirstOrDefault((Func)((ZDO x) => x.GetString("dr_key_grant", "") == grant.Id)); if (val != null) { grant.DropNetworkId = RiftWire.Identity(val); grant.SpawnConfirmed = true; } } } foreach (RunState run in world.Runs) { ZDO[] source3 = source.Where((ZDO x) => x.GetString("dr_run", "") == run.Id).ToArray(); HashSet keep = new HashSet(); foreach (EnemyRecord actor in run.Enemies.Where((EnemyRecord x) => !x.Dead)) { ZDO[] source4 = source3.Where((ZDO x) => x.GetString("dr_actor", "") == actor.Id && x.GetInt("dr_phase", 0) == actor.PhaseIndex && x.GetInt("dr_stage", 0) == run.Stage && x.GetInt("dr_floor", 0) == run.Level && x.GetInt("dr_attempt", 0) == run.Attempt && x.GetPrefab() == StringExtensionMethods.GetStableHashCode(ActorLifecycle.ExpectedPrefab(run, actor))).ToArray(); ZDO val2 = ((IEnumerable)source4).FirstOrDefault((Func)((ZDO x) => RiftWire.Identity(x) == actor.NetworkId)) ?? source4.FirstOrDefault(); actor.NetworkId = ((val2 == null) ? "" : RiftWire.Identity(val2)); if (val2 != null) { keep.Add(val2); actor.AwaitingNextPhase = false; if (actor.PortalIndex >= 0) { actor.PortalReleased = true; } } } foreach (ZDO item2 in source3.Where((ZDO x) => !keep.Contains(x))) { RemoveNetworkObject(item2); } } } private void Save() { try { world.Revision++; store.Save(world); } catch (Exception ex) { fault = "Сохранение экспедиции недоступно: " + ex.Message; throw; } } public void Reset() { if (world != null || store != null || fault.Length != 0) { world = null; store = null; fault = ""; sessions.Clear(); observedPositions.Clear(); altarHits.Clear(); nextTick = 0f; lastPortalTick = 0f; partyCircles.Clear(); circlePulses.Clear(); nextCircleTick = 0f; nextLootTick = 0f; arenaSearches.Clear(); arenaSearchTurn = 0; arenaMigrations.Clear(); BiomeArenaPlacement.Reset(); ArenaRuntime.Reset(); } } public void Tick() { //IL_01d2: Unknown result type (might be due to invalid IL or missing references) Load(); if (world == null || fault.Length != 0) { return; } SearchArenaSites(); TickPortals(); TickArenaLoot(); TickPartyCircles(); if (Time.unscaledTime < nextTick) { return; } nextTick = Time.unscaledTime + 1f; long[] live = (from x in ZNet.instance.GetPeers() select x.m_uid).Concat((!Object.op_Implicit((Object)(object)Game.instance) || GUIManager.IsHeadless()) ? new long[0] : new long[1] { ZNet.GetUID() }).ToArray(); long[] array = sessions.Keys.Where((long x) => !live.Contains(x)).ToArray(); foreach (long key in array) { long player = sessions[key]; sessions.Remove(key); observedPositions.Remove(key); foreach (RunState item in world.Runs.Where((RunState x) => x.Members.Any((Member m) => m.PlayerId == player && m.Connected))) { Expedition.Disconnect(item, player); } Save(); } foreach (long key3 in sessions.Keys) { PlayerPosition(key3); } RunState[] array2 = world.Runs.Where((RunState x) => x.Members.Any((Member m) => m.Connected && m.Present)).ToArray(); foreach (RunState runState in array2) { if (PrepareArena(runState) && runState.Phase == RunPhase.Combat) { ReconcileActors(runState); if (runState.Enemies.All((EnemyRecord x) => x.Dead) && RiftWire.Now >= runState.NextWaveAtMs) { if (runState.CurrentWave > 0) { Expedition.ReleaseRespawnsAfterWave(runState); } if (runState.CurrentWave < runState.TotalWaves) { SpawnWave(runState); } else { Expedition.CompleteLevel(runState); BeginLootCollection(runState); if (runState.Level == 10) { foreach (long item2 in runState.BattleRoster) { Warehouse.GrantReward(runState, item2, RewardItems(runState)); } } Save(); } } } foreach (Member item3 in runState.Members.Where((Member x) => x.Present && x.Connected)) { long num2 = PeerFor(item3.PlayerId); if (num2 != 0L) { plugin.Wire.Reply(num2, View(runState, item3.PlayerId, "state")); } } } string[] array3 = (from x in altarHits where RiftWire.Now - x.Value > 180000 select x.Key).ToArray(); foreach (string key2 in array3) { altarHits.Remove(key2); } } public void Receive(long sender, RiftRequest request) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_07a1: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) Load(); try { Expedition.Require(fault.Length == 0 && world != null, (fault.Length > 0) ? fault : "Мир ещё загружается."); bool flag = request.Command == "actor_dead" || request.Command == "adopt" || request.Command == "altar_hit"; long player = (flag ? 0 : Authenticate(sender)); if (flag) { int value; if (sender != ZNet.GetUID()) { ZNetPeer peer = ZNet.instance.GetPeer(sender); value = ((peer != null && peer.IsReady()) ? 1 : 0); } else { value = 1; } Expedition.Require((byte)value != 0, "Владелец противника не подключён."); } else { sessions[sender] = player; PlayerPosition(sender); } if (request.Command == "hello") { RunState runState = world.Runs.LastOrDefault((RunState x) => x.Members.Any((Member m) => m.PlayerId == player && m.Present)); if (runState != null) { Member member = Expedition.RequireMember(runState, player); if (!member.Connected) { Expedition.Join(runState, player, member.Name, member.ReturnPosition); if (!runState.HasCheckpoint) { PrepareArena(runState); } Save(); } } plugin.Wire.Reply(sender, View(runState, player, "hello")); return; } if (request.Command == "gate_seen" || request.Command == "gate_view" || request.Command == "guardian" || request.Command == "enter" || request.Command == "open_gate" || request.Command == "recover_gate" || request.Command == "restart_gate") { GateRequest(sender, player, request); return; } if (request.Command == "actor_dead" && request.GateId.Length > 0) { GuardianDeath(sender, request); return; } RunState runState2 = FindRun(request.RunId); Expedition.Require(runState2 != null, "Экспедиция не найдена."); Member member2 = (flag ? null : Expedition.RequireMember(runState2, player)); switch (request.Command) { case "adopt": { Expedition.Require(runState2.Phase == RunPhase.Combat, "Призыв вне боя."); ZDO val = RiftWire.Find(request.NetworkId); Expedition.Require(val != null && val.GetOwner() == sender && val.GetString("dr_run", "") == runState2.Id && val.GetInt("dr_stage", 0) == runState2.Stage && val.GetInt("dr_floor", 0) == runState2.Level && val.GetInt("dr_attempt", 0) == runState2.Attempt && request.ActorId == "summon:" + request.NetworkId && ArenaRuntime.Ensure(runState2).Geometry.Contains(val.GetPosition()), "Неверный призванный противник."); GameObject prefab = ZNetScene.instance.GetPrefab(val.GetPrefab()); Expedition.Require(Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab.GetComponent()) && !Object.op_Implicit((Object)(object)prefab.GetComponent()), "Неизвестный призыв."); if (!runState2.Enemies.Any((EnemyRecord x) => x.Id == request.ActorId)) { runState2.Enemies.Add(new EnemyRecord { Id = request.ActorId, NetworkId = request.NetworkId, Prefab = ((Object)prefab).name, Wave = runState2.CurrentWave }); Save(); } return; } case "view": plugin.Wire.Reply(sender, View(runState2, player, "view")); return; case "circle_presence": ReceiveCirclePresence(runState2, member2, request); return; case "ready": case "advance": case "circle": throw new InvalidOperationException("Для готовности оставайтесь всем отрядом в круге."); case "leave_gate": Expedition.Require(member2.Present && runState2.HasCheckpoint && ArenaReturnGate.Contains(ArenaSites.Current(runState2), RequireLiveGatePosition(sender)), "Для выхода зайдите внутрь врат за точкой появления."); goto case "leave"; case "leave": { if (runState2.HasCheckpoint) { RequirePresent(runState2, member2, sender); } else { Expedition.Require(member2.Present && !Expedition.IsCombat(runState2), "Дождитесь загрузки текущего боя."); } Expedition.Require(!member2.Dead && !HasPending(runState2, player), "Дождитесь возрождения и завершения переноса предметов."); Expedition.Leave(runState2, player); Save(); RiftReply riftReply = View(runState2, player, "leave"); riftReply.Destination = member2.ReturnPosition.Copy(); plugin.Wire.Reply(sender, riftReply); return; } case "death": Expedition.Require(member2.Present, "Персонаж не в экспедиции."); if (Expedition.RecordDeath(runState2, player, RiftWire.Now)) { Save(); if (runState2.Phase == RunPhase.Failed) { RemoveActors(runState2); PrepareArena(runState2); Save(); } } break; case "respawn": RequirePresent(runState2, member2, sender); if (member2.Dead) { Expedition.ConfirmRespawn(runState2, player, RiftWire.Now); Save(); } break; case "actor_dead": ActorDeath(sender, runState2, request); return; case "altar_hit": RequireActorOwner(sender, runState2, request); Expedition.Require(runState2.Phase == RunPhase.Combat && Expedition.Objective(runState2.Level) == ObjectiveKind.Defend, "Алтарь сейчас не является целью."); Expedition.Require(request.Amount > 0f && request.Amount < 100000f && !float.IsNaN(request.Amount), "Некорректный урон."); if (!altarHits.ContainsKey(request.Id)) { altarHits[request.Id] = RiftWire.Now; runState2.AltarHealth = Math.Max(0f, runState2.AltarHealth - request.Amount); if (runState2.AltarHealth <= 0f) { Expedition.Fail(runState2); Save(); RemoveActors(runState2); PrepareArena(runState2); } Save(); } return; case "repair": RequirePresent(runState2, member2, sender); Expedition.RequireWarehouseAccess(runState2, player, withdraw: false); Expedition.Require(!member2.Dead, "Дождитесь возрождения."); plugin.Wire.Reply(sender, View(runState2, player, "repair")); return; case "bank": SendBank(sender, runState2, player, request.Page, request.Flag, request.Id); return; case "deposit": { RequireServiceAccess(runState2, member2, sender); Expedition.Require(!RiftAssets.IsGateKey(NativeItems.Decode(request.Item)), "Ключ врат остаётся при вас для повторного входа."); Transfer transfer3 = Warehouse.PrepareDeposit(runState2, player, request.Id, request.Item, RiftWire.Now); if (transfer3.Phase == TransferPhase.Prepared) { member2.Ready = false; } Save(); ReplyTransfer(sender, runState2, player, transfer3); return; } case "withdraw": { RequireServiceAccess(runState2, member2, sender); Transfer transfer2 = Warehouse.PrepareWithdrawal(runState2, player, request.Id, request.EntryId, RiftWire.Now, request.RewardId); Save(); ReplyTransfer(sender, runState2, player, transfer2); return; } case "commit": { Transfer transfer = Warehouse.Commit(runState2, player, request.Id); Save(); ReplyTransfer(sender, runState2, player, transfer); return; } case "cancel": Warehouse.CancelUnapplied(runState2, player, request.Id); Save(); ReplyTransfer(sender, runState2, player, runState2.Transfers.Single((Transfer x) => x.Id == request.Id)); return; default: throw new InvalidOperationException("Неизвестное действие экспедиции."); } plugin.Wire.Reply(sender, View(runState2, player, request.Command)); } catch (Exception ex) { plugin.Wire.Reply(sender, new RiftReply { Command = request.Command, Id = request.Id, Error = ex.Message }); if (!(ex is InvalidOperationException)) { plugin.Fail(ex); } } } private void GateRequest(long sender, long player, RiftRequest request) { //IL_0049: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042b: 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_0435: 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_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) ZDO val = RiftWire.FindGate(request.GateId); Expedition.Require(val != null && val.GetPrefab() == StringExtensionMethods.GetStableHashCode("DreadRifts_Gate"), "Врата не найдены."); Expedition.Require(Vector3.Distance(PlayerPosition(sender), val.GetPosition()) <= 30f, "Подойдите к вратам."); val.Set("dr_gate_id", RiftWire.GateIdentity(val)); request.GateId = RiftWire.GateIdentity(val); bool num = !world.Gates.Any((GateState x) => x.Id == request.GateId); GateState gate = Gates.Register(world, request.GateId, RiftWire.Pos(val.GetPosition())); if (num) { Gates.ReserveGuardian(gate, RiftWire.Now, 8000L); Save(); } if (request.Command == "guardian") { Gates.ReserveGuardian(gate, RiftWire.Now, 8000L); Save(); } val.Set("dr_guardian_at", gate.GuardianSpawnAtMs); if (gate.GuardianAlive) { EnsureGuardian(gate, val); } RunState runState = FindRun(gate.RunId); if (request.Command == "recover_gate") { RequireGateKey(sender, gate, request); RunState runState2 = FindRun(request.RunId); Expedition.Require(runState2 != null && (runState2.GateId == gate.Id || RiftWire.FindGate(runState2.GateId) == null), "Прежние врата ещё существуют."); runState = Gates.RecoverExpedition(world, gate, request.RunId, player); Save(); } if (request.Command == "restart_gate") { Expedition.Require(runState != null, "Нет завершённой экспедиции."); Expedition.RequireMember(runState, player); Expedition.Require(runState.Phase == RunPhase.Complete && runState.Members.All((Member x) => !x.Present), "Сначала завершите испытания и выйдите всей группой."); Expedition.Require(!HasPending(runState, 0L) && runState.Warehouse.Count == 0 && runState.Rewards.All((PersonalReward x) => x.Items.Count == 0), "Сначала заберите общий склад и все личные награды."); gate.RunId = ""; runState = null; Save(); } if (request.Command == "open_gate") { Expedition.Require(Vector3.Distance(PlayerPosition(sender), val.GetPosition()) <= 12f, "Подойдите ближе к вратам."); RequireGateKey(sender, gate, request); Expedition.Require(runState != null || WorldBoss(0), "Сначала победите Эйктюра в обычном мире."); Expedition.Require(Enum.IsDefined(typeof(Difficulty), request.Number), "Неизвестная сложность."); val.Set("dr_gate_difficulty", ((int?)runState?.Difficulty) ?? request.Number); if (val.GetInt(ZDOVars.s_state, 0) == 0) { val.Set("dr_gate_open_ready_at", RiftWire.Now + 24600); val.Set(ZDOVars.s_state, 1, false); } RiftReply riftReply = View(null, player, "open_gate"); riftReply.GateId = gate.Id; plugin.Wire.Reply(sender, riftReply); } else if (request.Command == "enter") { Vector3 val2 = RequireLiveGatePosition(sender); Expedition.Require(RiftGate.ContainsEntry(Quaternion.Inverse(val.GetRotation()) * (val2 - val.GetPosition())), "Для входа зайдите внутрь врат."); Expedition.Require(val.GetInt(ZDOVars.s_state, 0) != 0 && RiftWire.Now >= val.GetLong("dr_gate_open_ready_at", 0L), "Дождитесь полного открытия створок."); RequireGateKey(sender, gate, request); Expedition.Require(world.Runs.FirstOrDefault((RunState x) => x.Id != gate.RunId && x.Members.Any((Member m) => m.PlayerId == player && m.Present)) == null, "Сначала покиньте текущую экспедицию."); if (runState == null) { Expedition.Require(WorldBoss(0), "Сначала победите Эйктюра в обычном мире."); Expedition.Require(world.NextArenaSlot < 1024, "Все места для экспедиций заняты."); runState = Expedition.Create(gate.Id, (Difficulty)val.GetInt("dr_gate_difficulty", 0)); runState.ArenaSlot = world.NextArenaSlot++; world.Runs.Add(runState); gate.RunId = runState.Id; } bool num2 = !runState.Members.Any((Member x) => x.PlayerId == player && x.Present); Vector3 value = val.GetPosition() + val.GetRotation() * new Vector3(0f, 0.2f, 4.5f); Member member = Expedition.Join(runState, player, PlayerName(sender), RiftWire.Pos(value)); if (num2) { member.ReturnPosition = RiftWire.Pos(value); } if (!runState.HasCheckpoint) { PrepareArena(runState); } member.Ready = false; Save(); val.Set(ZDOVars.s_state, 1, false); RiftReply riftReply2 = View(runState, player, "enter"); riftReply2.GateId = gate.Id; if (runState.HasCheckpoint) { riftReply2.Destination = runState.Checkpoint.Copy(); } plugin.Wire.Reply(sender, riftReply2); } else { if (request.Command == "gate_seen") { return; } RiftReply riftReply3 = View((runState != null && runState.Members.Any((Member x) => x.PlayerId == player)) ? runState : null, player, "gate_view"); riftReply3.GateId = gate.Id; riftReply3.GateUnlocked = gate.Unlocked; riftReply3.GuardianAlive = gate.GuardianAlive; riftReply3.GateHasExpedition = runState != null; riftReply3.GateDifficulty = ((int?)runState?.Difficulty) ?? val.GetInt("dr_gate_difficulty", 0); if (gate.RunId.Length == 0) { riftReply3.Recoverable = (from x in world.Runs where x.GateId != gate.Id && x.Members.Any((Member m) => m.PlayerId == player) && !Expedition.IsCombat(x) && RiftWire.FindGate(x.GateId) == null select new SavedRunRow { Id = x.Id, Stage = x.Stage, Level = x.Level, Difficulty = x.Difficulty }).ToList(); } plugin.Wire.Reply(sender, riftReply3); } } private static Vector3 RequireLiveGatePosition(long sender) { //IL_0055: 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_008b: Unknown result type (might be due to invalid IL or missing references) if (sender == ZNet.GetUID()) { Player localPlayer = Player.m_localPlayer; Expedition.Require(Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting(), "Дождитесь появления персонажа."); return ((Component)localPlayer).transform.position; } ZNetPeer peer = ZNet.instance.GetPeer(sender); ZDO val = ((peer == null) ? null : ZDOMan.instance.GetZDO(peer.m_characterID)); Expedition.Require(val != null && val.GetFloat(ZDOVars.s_health, 0f) > 0f, "Для входа нужен живой персонаж внутри врат."); return val.GetPosition(); } private static void RequireGateKey(long sender, GateState gate, RiftRequest request) { Expedition.Require(gate.Unlocked && request.Item != null, "Нужен ключ именно от этих врат."); ItemData val = NativeItems.Decode(request.Item); Expedition.Require(RiftAssets.IsGateKey(val) && val.m_customData.TryGetValue("dreadrifts.gate", out var value) && value == gate.Id && val.m_customData.TryGetValue("dreadrifts.grant", out var grant) && gate.KeyGrants.Any((KeyGrant x) => x.Id == grant && x.GateId == gate.Id), "Нужен ключ, выпавший у этих врат."); if (sender == ZNet.GetUID()) { Expedition.Require(RiftAssets.HasKey(Player.m_localPlayer, gate.Id), "Ключ должен быть у персонажа."); } } private void EnsureGuardian(GateState gate, ZDO gateZdo) { //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_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_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (RiftWire.Find(gate.GuardianNetworkId) == null && RiftWire.Now >= gate.GuardianSpawnAtMs) { Vector3 position = gateZdo.GetPosition() + gateZdo.GetRotation() * Vector3.forward * 8f + Vector3.up; ZDO val = CreateNetworkObject("DreadRifts_Guardian", position); val.Set("dr_gate", gate.Id); val.Set("dr_generation", gate.GuardianGeneration); val.Set("dr_damage", 0.45f); val.Set("dr_health", 1f); gate.GuardianNetworkId = ""; Gates.BindGuardian(gate, gate.GuardianGeneration, RiftWire.Identity(val)); Save(); val.SetOwner(0L); } } private void GuardianDeath(long sender, RiftRequest request) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) GateState gateState = world.Gates.FirstOrDefault((GateState x) => x.Id == request.GateId); Expedition.Require(gateState != null, "Неизвестные врата."); string item = gateState.Id + ":" + request.Number; if (!gateState.IssuedGuardianDeaths.Contains(item)) { ZDO val = RiftWire.Find(request.NetworkId); Expedition.Require(val != null && val.GetOwner() == sender && val.GetString("dr_gate", "") == gateState.Id, "Неверный владелец хранителя."); Expedition.Require(val.GetFloat(ZDOVars.s_health, 1f) <= 0f, "Хранитель ещё жив."); NearbyCharacter[] nearby = sessions.Select((KeyValuePair pair) => new NearbyCharacter { PlayerId = pair.Value, Connected = true, Position = RiftWire.Pos(PlayerPosition(pair.Key)) }).ToArray(); Gates.DefeatGuardian(gateState, request.Number, request.NetworkId, RiftWire.Pos(val.GetPosition()), nearby, 30f, RiftWire.Now, 60000L); Save(); } foreach (KeyGrant item2 in gateState.KeyGrants.Where((KeyGrant x) => !x.SpawnConfirmed)) { ZDO val2 = CreateNetworkObject("DreadRifts_Key", RiftWire.Vec(gateState.Position) + Vector3.up * 1.5f); val2.Set("dr_key_gate", gateState.Id); val2.Set("dr_key_grant", item2.Id); Gates.ConfirmKeySpawn(gateState, item2.Id, RiftWire.Identity(val2)); Save(); val2.SetOwner(0L); } plugin.Wire.Reply(sender, new RiftReply { Command = "actor_ack", GateId = gateState.Id, NetworkId = request.NetworkId }); } private void SearchArenaSites() { //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected I4, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) if (WorldGenerator.instance == null) { return; } RunState[] array = world.Runs.Where((RunState r) => r.Members.Any((Member m) => m.Connected && m.Present) && ArenaSites.Current(r) == null).ToArray(); if (array.Length == 0) { return; } if (arenaSearchTurn >= array.Length) { arenaSearchTurn = 0; } RunState runState = array[arenaSearchTurn++]; string key = runState.Id + ":" + runState.Stage; if (!arenaSearches.TryGetValue(key, out var value)) { value = new BiomeArenaSearch(runState.Seed, runState.Stage); arenaSearches.Add(key, value); } if (value.Exhausted) { return; } Vector3? val = value.Step(world.Runs.SelectMany((RunState x) => x.ArenaSites), 2); if (!val.HasValue) { runState.ArenaStatus = (value.Exhausted ? "Подходящий свободный участок не найден. Можно выйти через меню экспедиции." : ("Подбираем площадку: " + StageCatalog.Stages[runState.Stage].NameRu + "…")); if (value.Exhausted) { plugin.LogInfo("Arena search exhausted stage=" + runState.Stage + " " + value.Diagnostic); } return; } ArenaSite site = new ArenaSite { Id = runState.Id + ":biome:" + runState.Stage, Stage = runState.Stage, Biome = (int)BiomeTerrain.StageBiome(runState.Stage), Origin = RiftWire.Pos(val.Value) }; ArenaSites.Reserve(runState, site); Save(); BiomeArenaPlacement.Register(site); arenaSearches.Remove(key); plugin.LogInfo("Arena reserved stage=" + runState.Stage + " origin=" + ((object)val.Value/*cast due to .constrained prefix*/).ToString() + " " + value.Diagnostic); } private bool PrepareArena(RunState run) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if (WorldGenerator.instance == null) { return false; } string arenaStatus = run.ArenaStatus; try { ArenaSite arenaSite = ArenaSites.Current(run); if (arenaSite == null) { if (run.ArenaStatus.Length == 0) { run.ArenaStatus = "Подбираем площадку: " + StageCatalog.Stages[run.Stage].NameRu + "…"; } return false; } run.ArenaStatus = "Подготавливаем арену: " + StageCatalog.Stages[run.Stage].NameRu + "…"; bool flag = arenaSite.Ready && arenaSite.ReadyCircle != null; if (!ArenaRuntime.TryEnsure(run, out var arena)) { return false; } if (!arena.CheckpointSupported()) { return false; } if (!run.HasCheckpoint) { ArenaSites.ApplyPreparedCheckpoint(run); if (arenaMigrations.Remove(run.Id)) { for (int i = 0; i < run.Enemies.Count; i++) { ZDO val = RiftWire.Find(run.Enemies[i].NetworkId); if (val != null) { val.SetPosition(arena.SpawnPoint(i * 7)); } } } run.ArenaStatus = ""; Save(); } else if (!flag) { run.ArenaStatus = ""; Save(); } else { run.ArenaStatus = ""; } return true; } catch (InvalidOperationException ex) { string text = "Арена не готова: " + ex.Message; if (arenaStatus != text) { plugin.LogInfo(text); } run.ArenaStatus = text; return false; } } private void SpawnWave(RunState run) { int wave = run.CurrentWave + 1; PortalWaves.Plan(run, wave); Save(); } private void ReconcileActors(RunState run) { //IL_00ac: 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_00b1: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_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_00fa: Unknown result type (might be due to invalid IL or missing references) ArenaRuntime arenaRuntime = ArenaRuntime.Ensure(run); EnemyRecord[] array = run.Enemies.Where((EnemyRecord x) => !x.Dead).ToArray(); foreach (EnemyRecord enemyRecord in array) { if (RiftWire.Find(enemyRecord.NetworkId) != null || PortalWaves.Pending(enemyRecord)) { continue; } if (enemyRecord.PortalIndex >= 0 && enemyRecord.PhaseIndex == 0 && enemyRecord.PortalReleased) { PortalWaves.RequeueMissing(run, enemyRecord); Save(); continue; } Vector3 val = ((enemyRecord.PhasePosition == null) ? arenaRuntime.SpawnPoint(run.Enemies.IndexOf(enemyRecord) * 7) : RiftWire.Vec(enemyRecord.PhasePosition)); if (!arenaRuntime.Geometry.Contains(val)) { val = arenaRuntime.SpawnPoint(0); } if (enemyRecord.PhasePosition != null && BiomeTerrain.TryFloor(val, out var floor, checkObstacles: false)) { val = floor + Vector3.up * 0.6f; } SpawnActor(run, enemyRecord, val, Quaternion.identity); } } private void ActorDeath(long sender, RunState run, RiftRequest request) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) EnemyRecord enemyRecord = run.Enemies.FirstOrDefault((EnemyRecord x) => x.Id == request.ActorId); Expedition.Require(enemyRecord != null, "Противник не принадлежит этому уровню."); if (!enemyRecord.Dead && enemyRecord.PhaseIndex == request.Number) { ZDO val = RequireActorOwner(sender, run, request); Expedition.Require(val.GetFloat(ZDOVars.s_health, 1f) <= 0f, "Противник ещё жив."); if (enemyRecord.Boss) { enemyRecord.PhasePosition = RiftWire.Pos(val.GetPosition()); } ActorLifecycle.Died(run, enemyRecord.Id, request.Number, request.NetworkId); run.NextWaveAtMs = RiftWire.Now + 5000; Save(); if (enemyRecord.AwaitingNextPhase) { ReconcileActors(run); } } plugin.Wire.Reply(sender, new RiftReply { Command = "actor_ack", ActorId = request.ActorId, NetworkId = request.NetworkId }); } private ZDO RequireActorOwner(long sender, RunState run, RiftRequest request) { ZDO val = RiftWire.Find(request.NetworkId); Expedition.Require(val != null && val.GetOwner() == sender && val.GetString("dr_run", "") == run.Id && val.GetString("dr_actor", "") == request.ActorId && run.Enemies.Any((EnemyRecord x) => x.Id == request.ActorId && x.NetworkId == request.NetworkId && !x.Dead), "Неверное сообщение противника."); return val; } private static ZDO CreateNetworkObject(string name, Vector3 position) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab(name); Expedition.Require(Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab.GetComponent()), "Сетевой объект недоступен: " + name); ZNetView component = prefab.GetComponent(); ZDO obj = ZDOMan.instance.CreateNewZDO(position, StringExtensionMethods.GetStableHashCode(name)); obj.Persistent = true; obj.Type = component.m_type; obj.Distant = component.m_distant; obj.SetPrefab(StringExtensionMethods.GetStableHashCode(name)); obj.SetRotation(Quaternion.identity); return obj; } private void RemoveActors(RunState run) { ZDO[] array = ((Dictionary)AccessTools.Field(typeof(ZDOMan), "m_objectsByID").GetValue(ZDOMan.instance)).Values.Where((ZDO x) => x.GetString("dr_run", "") == run.Id || x.GetString("dr_spawn_run", "") == run.Id).ToArray(); for (int num = 0; num < array.Length; num++) { RemoveNetworkObject(array[num]); } } private static void RemoveNetworkObject(ZDO zdo) { zdo.SetOwner(ZNet.GetUID()); ZDOMan.instance.DestroyZDO(zdo); } private IEnumerable RewardItems(RunState run) { string[] materials = StageCatalog.Stages[run.Stage].Materials; for (int index = 0; index < materials.Length; index++) { GameObject prefab = ObjectDB.instance.GetItemPrefab(materials[index]); Expedition.Require(Object.op_Implicit((Object)(object)prefab), "Материал награды недоступен: " + materials[index]); ItemData original = prefab.GetComponent().m_itemData; int remaining = Encounters.MaterialRewardCount(run, index); while (remaining > 0) { ItemData val = original.Clone(); val.m_dropPrefab = prefab; val.m_stack = Math.Min(remaining, val.m_shared.m_maxStackSize); remaining -= val.m_stack; yield return NativeItems.Encode(val); } } } private void SendBank(long peer, RunState run, long player, int requestedPage, bool rewards, string requestId) { Expedition.RequireWarehouseAccess(run, player, withdraw: false); IEnumerable source = (rewards ? run.Rewards.Where((PersonalReward x) => x.PlayerId == player).SelectMany((PersonalReward r) => r.Items.Select((BankEntry e) => Row(e, r.Id))) : run.Warehouse.Select((BankEntry x) => Row(x, ""))); int num = source.Count(); int num2 = Math.Max(0, Math.Min(requestedPage, Math.Max(0, (num - 1) / 8))); RiftReply riftReply = View(run, player, rewards ? "rewards" : "bank"); riftReply.Id = requestId; riftReply.Page = num2; riftReply.TotalRows = num; riftReply.Rows = source.Skip(num2 * 8).Take(8).ToList(); plugin.Wire.Reply(peer, riftReply); } private static BankRow Row(BankEntry entry, string reward) { return new BankRow { Id = entry.Id, Name = entry.Item.DisplayName, Prefab = entry.Item.Prefab, Quantity = entry.Item.Quantity, Reserved = (entry.ReservedBy.Length > 0), RewardId = reward }; } private void ReplyTransfer(long sender, RunState run, long player, Transfer transfer) { RiftReply riftReply = View(run, player, "transfer"); riftReply.Transfer = transfer; riftReply.Id = transfer.Id; plugin.Wire.Reply(sender, riftReply); } private RiftReply View(RunState run, long player, string command) { RiftReply riftReply = new RiftReply { Command = command, WorldId = world.WorldId, Revision = world.Revision, WorldBosses = Enumerable.Range(0, StageCatalog.Stages.Length).Select(WorldBoss).ToArray() }; if (run == null) { return riftReply; } riftReply.Run = new RunState { Id = run.Id, GateId = run.GateId, ArenaId = run.ArenaId, ArenaSlot = run.ArenaSlot, Seed = run.Seed, Stage = run.Stage, Level = run.Level, Attempt = run.Attempt, HighestCompletedStage = run.HighestCompletedStage, Difficulty = run.Difficulty, CombatRules = run.CombatRules, Phase = run.Phase, PhaseBeforePause = run.PhaseBeforePause, HasCheckpoint = run.HasCheckpoint, Checkpoint = run.Checkpoint, WarehouseLocked = run.WarehouseLocked, LockStage = run.LockStage, LockLevel = run.LockLevel, ArenaStatus = run.ArenaStatus, ArenaSites = run.ArenaSites.Where((ArenaSite x) => x.Stage == run.Stage).ToList(), CurrentWave = run.CurrentWave, TotalWaves = run.TotalWaves, AltarHealth = run.AltarHealth, AltarMaxHealth = run.AltarMaxHealth, StartedAtMs = run.StartedAtMs, NextWaveAtMs = run.NextWaveAtMs, BattleRoster = run.BattleRoster, PortalClockMs = run.PortalClockMs, PortalClockAtMs = run.PortalClockAtMs, NextPortal = run.NextPortal, Members = run.Members, Enemies = run.Enemies, CircleEndsAtMs = run.CircleEndsAtMs, CircleMessage = run.CircleMessage, LootSettled = run.LootSettled, LootCollectedAtMs = run.LootCollectedAtMs, LootCollectedUnits = run.LootCollectedUnits, LootOrigins = run.LootOrigins }; riftReply.Pending = run.Transfers.Where((Transfer x) => x.PlayerId == player && x.Phase == TransferPhase.Prepared).ToList(); return riftReply; } private long Authenticate(long sender) { if (sender == ZNet.GetUID()) { Expedition.Require(Object.op_Implicit((Object)(object)Game.instance), "Персонаж ещё загружается."); if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Game.instance.GetPlayerProfile().GetPlayerID(); } return Player.m_localPlayer.GetPlayerID(); } ZNetPeer peer = ZNet.instance.GetPeer(sender); Expedition.Require(peer != null && peer.m_playerID != 0, "Сетевая личность персонажа ещё не подтверждена."); return peer.m_playerID; } private long PeerFor(long player) { return sessions.FirstOrDefault((KeyValuePair x) => x.Value == player).Key; } private Vector3 PlayerPosition(long peer) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_008b: 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_00ca: Unknown result type (might be due to invalid IL or missing references) if (peer == ZNet.GetUID() && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Vector3 position = ((Component)Player.m_localPlayer).transform.position; observedPositions[peer] = position; return position; } ZNetPeer peer2 = ZNet.instance.GetPeer(peer); ZDO val = ((peer2 == null) ? null : ZDOMan.instance.GetZDO(peer2.m_characterID)); if (val != null) { Vector3 position2 = val.GetPosition(); observedPositions[peer] = position2; return position2; } if (observedPositions.TryGetValue(peer, out var value)) { return value; } if (sessions.TryGetValue(peer, out var player)) { RunState runState = world.Runs.FirstOrDefault((RunState x) => x.Members.Any((Member m) => m.PlayerId == player && m.Present)); if (runState != null) { return RiftWire.Vec(runState.Checkpoint); } } return new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); } private string PlayerName(long sender) { object obj; if (sender != ZNet.GetUID() || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { obj = ZNet.instance.GetPeer(sender)?.m_playerName; if (obj == null) { return "Viking"; } } else { obj = Player.m_localPlayer.GetPlayerName(); } return (string)obj; } private void RequirePresent(RunState run, Member member, long sender) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) Expedition.Require(member.Present && member.Connected, "Персонаж находится вне экспедиции."); Expedition.Require(ArenaRuntime.Ensure(run).Geometry.Contains(PlayerPosition(sender), 12f), "Сначала войдите в испытание."); } private void AdvanceLevel(RunState run, Member member, bool ready) { Expedition.Require(!member.Dead, "Дождитесь возрождения."); Expedition.Require(!HasPending(run, 0L), "Дождитесь завершения переноса предметов."); Expedition.Require(run.Phase == RunPhase.Intermission, "Сначала завершите уровень."); member.Ready = ready; if (!run.Members.Where((Member x) => x.Present && x.Connected && !x.Dead).All((Member x) => x.Ready)) { return; } if (Expedition.Advance(run, StageCatalog.Stages.Length, WorldBoss(run.Stage + 1))) { PrepareArena(run); } foreach (Member member2 in run.Members) { member2.Ready = false; } } private void RequireServiceAccess(RunState run, Member member, long sender) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) Expedition.Require(!member.Dead, "Дождитесь возрождения."); Expedition.RequireWarehouseAccess(run, member.PlayerId, withdraw: false); if (member.Present) { RequirePresent(run, member, sender); return; } GateState gateState = world.Gates.FirstOrDefault((GateState x) => x.Id == run.GateId); Expedition.Require(gateState != null && Vector3.Distance(PlayerPosition(sender), RiftWire.Vec(gateState.Position)) <= 12f, "Подойдите к вратам для получения добычи."); } private static bool HasPending(RunState run, long player = 0L) { return run.Transfers.Any((Transfer x) => x.Phase == TransferPhase.Prepared && (player == 0L || x.PlayerId == player)); } } internal sealed class RiftLootFlight : MonoBehaviour { private Vector3 from; private Vector3 to; private float born; private LineRenderer trail; private Material material; internal static void Show(Vector3 from, Vector3 to) { //IL_0005: 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_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) RiftLootFlight riftLootFlight = new GameObject("DreadRifts collected loot").AddComponent(); riftLootFlight.from = from; riftLootFlight.to = to + Vector3.up; riftLootFlight.born = Time.time; Shader val = Shader.Find("Sprites/Default"); if (!Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)((Component)riftLootFlight).gameObject); return; } riftLootFlight.material = new Material(val); riftLootFlight.trail = ((Component)riftLootFlight).gameObject.AddComponent(); ((Renderer)riftLootFlight.trail).sharedMaterial = riftLootFlight.material; riftLootFlight.trail.useWorldSpace = true; riftLootFlight.trail.positionCount = 10; riftLootFlight.trail.startWidth = 0.11f; riftLootFlight.trail.endWidth = 0.025f; riftLootFlight.trail.startColor = new Color(1f, 0.77f, 0.3f); riftLootFlight.trail.endColor = new Color(0.65f, 0.3f, 1f, 0f); } private Vector3 At(float t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0029: 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) return Vector3.Lerp(from, to, t) + Vector3.up * (Mathf.Sin(t * (float)Math.PI) * 2.5f); } private void Update() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = (Time.time - born) / 1.15f; if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } else if (Object.op_Implicit((Object)(object)trail)) { for (int i = 0; i < trail.positionCount; i++) { trail.SetPosition(i, At(Mathf.Clamp01(num - (float)i * 0.016f))); } } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } } } internal static class RiftAssets { public const string Gate = "DreadRifts_Gate"; public const string Key = "DreadRifts_Key"; public const string Guardian = "DreadRifts_Guardian"; public const string GateKey = "dreadrifts.gate"; public const string GrantKey = "dreadrifts.grant"; private static bool registered; public static void Register() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown if (!registered) { PrefabManager instance = PrefabManager.Instance; GameObject val = instance.CreateClonedPrefab("DreadRifts_Key", "DvergrKey"); ItemDrop component = val.GetComponent(); component.m_itemData.m_shared.m_maxStackSize = 1; component.m_itemData.m_shared.m_teleportable = true; ItemManager.Instance.AddItem(new CustomItem(val, false, new ItemConfig { Name = "Ключ врат DreadRifts", Description = "Многоразовый ключ, связанный со своими вратами.", Enabled = false })); GameObject val2 = instance.CreateClonedPrefab("DreadRifts_Guardian", "Skeleton_Hildir"); Character component2 = val2.GetComponent(); component2.m_name = "Хранитель врат"; component2.m_defeatSetGlobalKey = ""; component2.m_dreamCinematic = ""; component2.m_health = 450f; component2.m_boss = false; component2.m_group = "DreadRifts"; CharacterDrop component3 = val2.GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { component3.m_drops = new List(); } val2.AddComponent(); CreatureManager.Instance.AddCreature(new CustomCreature(val2, false)); GameObject val3 = instance.CreateClonedPrefab("DreadRifts_Gate", "dungeon_queen_door"); Door component4 = val3.GetComponent(); component4.m_name = "Врата DreadRifts"; component4.m_keyItem = null; component4.m_consumeKey = false; component4.m_canNotBeClosed = false; component4.m_checkGuardStone = true; (val3.GetComponent() ?? val3.AddComponent()).m_canBeRemoved = true; RiftGateModel.Attach(val3); val3.GetComponent().m_persistent = true; val3.AddComponent(); val3.AddComponent(); PieceManager instance2 = PieceManager.Instance; PieceConfig val4 = new PieceConfig(); val4.Name = "Врата DreadRifts"; val4.Description = "Победите хранителя, возьмите ключ и войдите внутрь открытых врат. Каждый участник входит со своим ключом."; val4.PieceTable = "Hammer"; val4.Category = "DreadRifts"; val4.Icon = RiftGateModel.Icon(val3); val4.CraftingStation = "piece_workbench"; val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("Stone", 60, 0, true), new RequirementConfig("Wood", 40, 0, true), new RequirementConfig("BoneFragments", 10, 0, true), new RequirementConfig("SurtlingCore", 2, 0, true) }; instance2.AddPiece(new CustomPiece(val3, true, val4)); registered = true; } } public static bool IsGateKey(ItemData item) { if (item != null && Object.op_Implicit((Object)(object)item.m_dropPrefab)) { return ((Object)item.m_dropPrefab).name == "DreadRifts_Key"; } return false; } public static ItemData FindKey(Player player, string gateId) { string value; if (Object.op_Implicit((Object)(object)player)) { return InventoryCompatibility.GetInventories(player).SelectMany((Inventory x) => x.GetAllItems()).FirstOrDefault((Func)((ItemData x) => IsGateKey(x) && x.m_stack > 0 && x.m_customData.TryGetValue("dreadrifts.gate", out value) && value == gateId)); } return null; } public static bool HasKey(Player player, string gateId) { return FindKey(player, gateId) != null; } } internal sealed class RiftGate : MonoBehaviour { [HarmonyPatch(typeof(Door), "Interact")] private static class InteractPatch { private static bool Prefix(Door __instance, bool hold, ref bool __result) { RiftGate component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return true; } if (!hold) { component.OpenMenu(); } __result = !hold; return false; } } [HarmonyPatch(typeof(Door), "GetHoverText")] private static class HoverPatch { private static bool Prefix(Door __instance, ref string __result) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { return true; } __result = Localization.instance.Localize("Врата DreadRifts\n[$KEY_Use] Испытания"); return false; } } [HarmonyPatch(typeof(Door), "UseItem")] private static class UseItemPatch { private static bool Prefix(Door __instance, ref bool __result) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { return true; } __result = false; return false; } } private ZNetView view; private float nextCheck; private float nextEntryCheck; private float nextAttempt; private float nextKeyWarning; private long warnedAt; private void Awake() { view = ((Component)this).GetComponent(); } public static bool HasOpened(string gateId) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) RiftGate riftGate = Object.FindObjectsByType((FindObjectsSortMode)0).FirstOrDefault((RiftGate x) => Object.op_Implicit((Object)(object)x.view) && x.view.IsValid() && RiftWire.GateIdentity(x.view.GetZDO()) == gateId); if (!Object.op_Implicit((Object)(object)riftGate)) { return true; } Animator componentInChildren = ((Component)riftGate).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren) && !componentInChildren.IsInTransition(0)) { AnimatorStateInfo currentAnimatorStateInfo = componentInChildren.GetCurrentAnimatorStateInfo(0); return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("open"); } return false; } private void Update() { //IL_0073: 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) if (Time.unscaledTime >= nextEntryCheck) { nextEntryCheck = Time.unscaledTime + 0.15f; CheckEntry(); } if (Time.unscaledTime < nextCheck || !Object.op_Implicit((Object)(object)view) || !view.IsValid() || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } nextCheck = Time.unscaledTime + 5f; if (Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < 25f) { long num = view.GetZDO().GetLong("dr_guardian_at", 0L); if (num > RiftWire.Now && num != warnedAt) { warnedAt = num; ((Character)Player.m_localPlayer).Message((MessageType)2, "Врата пробуждаются. Приготовьтесь: выходит хранитель!", 0, (Sprite)null, false); } Plugin.Instance?.Wire.Request(new RiftRequest { Command = "gate_seen", GateId = RiftWire.GateIdentity(view.GetZDO()) }); } } internal static bool ContainsEntry(Vector3 local) { //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 (local.x >= -2.15f && local.x <= 2.15f && local.y >= -0.3f && local.y <= 3.2f && local.z <= -4.75f) { return local.z >= -5.95f; } return false; } private void CheckEntry() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)view) || !view.IsValid() || !Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || (Object)(object)Plugin.Instance == (Object)null || Plugin.Instance.Client.InTrial || !ContainsEntry(((Component)this).transform.InverseTransformPoint(((Component)localPlayer).transform.position))) { return; } string gateId = RiftWire.GateIdentity(view.GetZDO()); if (!HasOpened(gateId)) { return; } if (!RiftAssets.HasKey(localPlayer, gateId)) { if (Time.unscaledTime >= nextKeyWarning) { nextKeyWarning = Time.unscaledTime + 5f; ((Character)localPlayer).Message((MessageType)2, "Для входа нужен ключ именно от этих врат.", 0, (Sprite)null, false); } } else if (!(Time.unscaledTime < nextAttempt) && PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { nextAttempt = Time.unscaledTime + 3f; Plugin.Instance.Client.EnterInside(gateId); } } public void OpenMenu() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)view) && view.IsValid() && Object.op_Implicit((Object)(object)Player.m_localPlayer) && PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { Plugin.Instance.Client.OpenGate(RiftWire.GateIdentity(view.GetZDO())); } } } internal sealed class RiftClient { private sealed class DepositSource { public Inventory Inventory; public ItemData Item; } private sealed class QuickDepositBatch { public string World; public string Run; public string Encounter; public string ActiveId = ""; public long Player; public bool Present; public readonly Queue Remaining = new Queue(); public LootStack Active; public int Total; public int Stored; public int Skipped; public int Units; public float RetryAt; } private const string ReceiptKey = "dreadrifts.transfers.v1"; private readonly Plugin plugin; public RunState Run; public RiftReply Last = new RiftReply(); public bool Synced; public string GateId = ""; public string Notice = ""; public string Tab = "run"; public int Page; public readonly List Rows = new List(); public int TotalRows; public bool MenuOpen; public bool GateUnlocked; public bool GuardianAlive; public bool GateHasExpedition; public int GateDifficulty; public readonly List Recoverable = new List(); public bool[] WorldBosses = new bool[0]; public string WorldId = ""; private float nextHello; private float nextSave; private float nextTeleport; private float nextArenaUpdate; private bool arenaReady; private string lastLootVisual = ""; private string checkpointToken = ""; private Position destination; private string openingGate = ""; private long clockOffset; private long latestStateRevision; private ZNetPeer announcedPeer; private readonly Dictionary sources = new Dictionary(); private readonly HashSet activeSaves = new HashSet(); private readonly HashSet bankRefreshes = new HashSet(); private RiftUI ui; private bool resetting; private QuickDepositBatch quickDeposit; public bool ArenaReady { get { if (arenaReady) { return Run?.HasCheckpoint ?? false; } return false; } } public long PlayerId { get { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!Object.op_Implicit((Object)(object)Game.instance)) { return 0L; } return Game.instance.GetPlayerProfile().GetPlayerID(); } return Player.m_localPlayer.GetPlayerID(); } } public Member Own => Run?.Members.FirstOrDefault((Member x) => x.PlayerId == PlayerId); public long ServerNow => RiftWire.Now + clockOffset; public bool InTrial { get { if (Own != null) { return Own.Present; } return false; } } public bool BetweenLevels { get { if (Run != null) { return !Expedition.IsCombat(Run); } return false; } } public bool QuickDepositActive => quickDeposit != null; public bool TransferBusy { get { if (quickDeposit == null && sources.Count <= 0 && activeSaves.Count <= 0) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && WorldId.Length > 0) { return ReadBook().Items.Any((ItemReceipt r) => r.World == WorldId && !r.Completed); } return false; } return true; } } public string QuickDepositProgress { get { if (quickDeposit != null) { return "Сложено: " + quickDeposit.Stored + "/" + quickDeposit.Total + " стопок"; } return ""; } } internal void CirclePresence(bool eligible) { if (InTrial && PartyCircle.Action(Run) != CircleAction.None) { plugin.Wire.Request(new RiftRequest { Command = "circle_presence", RunId = Run.Id, Encounter = PartyCircle.Token(Run), Flag = (eligible && !TransferBusy) }); } } public RiftClient(Plugin plugin) { this.plugin = plugin; ui = new RiftUI(this); } public void TickUI() { //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_0066: 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_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) try { KeyboardShortcut value; if (Object.op_Implicit((Object)(object)Game.instance) && (Object.op_Implicit((Object)(object)Player.m_localPlayer) || ArenaSpectator.Active) && !GUIManager.IsHeadless()) { Scene activeScene = SceneManager.GetActiveScene(); if (!(((Scene)(ref activeScene)).name != "main")) { if (!MenuOpen) { goto IL_0084; } if (!Input.GetKeyDown((KeyCode)27)) { value = plugin.MenuKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown() && !Menu.IsVisible()) { goto IL_0084; } } Close(); goto IL_00e7; } } Close(); return; IL_00e7: ui.Tick(); return; IL_0084: if (!MenuOpen && Run != null && !Menu.IsVisible()) { value = plugin.MenuKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { MenuOpen = true; Tab = ((Run.Phase == RunPhase.Intermission) ? "complete_level" : "run"); ui.Refresh(); } } goto IL_00e7; } catch (Exception error) { Close(); plugin.Fail(error); } } public void Tick() { //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_0310: 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_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Game.instance) || GUIManager.IsHeadless()) { return; } if (Time.unscaledTime >= nextHello) { nextHello = Time.unscaledTime + 3f; if (!ZNet.instance.IsServer()) { ZNetPeer serverPeer = ZNet.instance.GetServerPeer(); if (serverPeer == null || !serverPeer.IsReady() || PlayerId == 0L) { return; } if (announcedPeer != serverPeer) { serverPeer.m_rpc.Invoke("PlayerID", new object[1] { PlayerId }); announcedPeer = serverPeer; } } plugin.Wire.Request(new RiftRequest { Command = "hello" }); } ArenaSpectator.Tick(); Player localPlayer = Player.m_localPlayer; if (InTrial && Run.HasCheckpoint && Time.unscaledTime >= nextArenaUpdate) { nextArenaUpdate = Time.unscaledTime + 0.25f; arenaReady = ArenaRuntime.TryEnsure(Run, out var arena) && arena.CheckpointSupported(); string text = Run.Id + ":" + Run.Stage + ":" + Run.Level + ":" + Run.Attempt; if (checkpointToken != text) { checkpointToken = text; if (!Own.Dead) { destination = Run.Checkpoint.Copy(); } } } if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } if (openingGate.Length > 0 && RiftGate.HasOpened(openingGate)) { openingGate = ""; } if (InTrial && ArenaReady && destination == null && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting()) { ArenaRuntime arenaRuntime = ArenaRuntime.Find(Run.Id, RiftWire.Vec(Run.Checkpoint)); if (arenaRuntime != null && !arenaRuntime.Geometry.Contains(((Component)localPlayer).transform.position)) { destination = Run.Checkpoint.Copy(); } } if (destination != null && (!InTrial || Run.HasCheckpoint) && openingGate.Length == 0 && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting() && Time.unscaledTime >= nextTeleport) { Vector3 val = RiftWire.Vec(destination); if (Vector3.Distance(((Component)localPlayer).transform.position, val) < 3f && (!InTrial || ArenaReady)) { destination = null; } else { Quaternion val2 = ((Component)localPlayer).transform.rotation; if (InTrial) { ArenaRuntime arenaRuntime2 = ArenaRuntime.Find(Run.Id, val); if (arenaRuntime2 != null) { val2 = arenaRuntime2.ArrivalRotation; } } else if (Run != null) { ZDO val3 = RiftWire.FindGate(Run.GateId); if (val3 != null && Vector3.Distance(val, val3.GetPosition()) < 15f) { val2 = val3.GetRotation(); } } nextTeleport = Time.unscaledTime + 4f; ((Character)localPlayer).TeleportTo(val, val2, true); } } if (Own != null && Own.Dead && !((Character)localPlayer).IsDead() && ServerNow >= Own.RespawnAtMs) { Send("respawn"); } if (Time.unscaledTime >= nextSave) { nextSave = Time.unscaledTime + 5f; ReconcileReceipts(); } TickQuickDeposit(); } public void Receive(RiftReply reply) { //IL_04da: 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_0523: Unknown result type (might be due to invalid IL or missing references) if (reply.Error.Length > 0) { Notice = reply.Error; if ((reply.Command == "circle" || reply.Command == "enter" || reply.Command == "open_gate" || reply.Command == "leave_gate") && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, reply.Error, 0, (Sprite)null, false); } if (reply.Command == "enter") { openingGate = ""; } if (reply.Command == "deposit" || reply.Command == "withdraw") { sources.Remove(reply.Id); activeSaves.Remove(reply.Id); } QuickDepositError(reply); if (reply.Command != "actor_dead" && reply.Command != "adopt") { ui.Refresh(); } return; } clockOffset = reply.ServerTimeMs - RiftWire.Now; if (reply.Command == "actor_ack") { RiftActor.Acknowledge(reply.NetworkId); return; } if (reply.WorldId.Length > 0) { WorldId = reply.WorldId; } if (reply.Command == "hello") { Synced = true; } long num = latestStateRevision; if (reply.Command != "transfer" && reply.Revision < latestStateRevision) { if (reply.Run?.Id == Run?.Id && Own != null) { if (reply.Command == "leave" && !Own.Present) { openingGate = ""; destination = reply.Destination; Close(); } else if (reply.Command == "enter" && Own.Present && !Own.Dead) { openingGate = reply.GateId; destination = (Run.HasCheckpoint ? Run.Checkpoint.Copy() : null); Close(); } } return; } if (reply.Command != "transfer") { latestStateRevision = Math.Max(latestStateRevision, reply.Revision); } bool flag = reply.WorldBosses.Length != 0 && !reply.WorldBosses.SequenceEqual(WorldBosses); if (reply.WorldBosses.Length != 0) { WorldBosses = reply.WorldBosses; } if (reply.Run != null && reply.Command != "transfer") { bool flag2 = Run?.Id == reply.Run.Id && Run.Phase == RunPhase.Combat && reply.Run.Phase == RunPhase.Intermission; bool flag3 = reply.Run.Phase == RunPhase.Combat && (Run?.Id != reply.Run.Id || Run.Phase != RunPhase.Combat); bool flag4 = Run?.ArenaId != reply.Run.ArenaId || Run?.Stage != reply.Run.Stage; Run = reply.Run; string text = Run.Id + ":" + Run.LootCollectedAtMs; if (InTrial && Run.LootCollectedAtMs > 0 && ServerNow - Run.LootCollectedAtMs < 5000 && text != lastLootVisual) { lastLootVisual = text; if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, "Добыча собрана на склад: +" + Run.LootCollectedUnits, 0, (Sprite)null, false); ArenaRuntime arenaRuntime = ArenaRuntime.Find(Run.Id, ((Component)Player.m_localPlayer).transform.position); if (arenaRuntime != null && plugin.EffectsIntensity.Value > 0f) { foreach (Position lootOrigin in Run.LootOrigins) { RiftLootFlight.Show(RiftWire.Vec(lootOrigin), arenaRuntime.WarehousePoint); } } } } if (!Run.HasCheckpoint || flag4) { arenaReady = false; destination = null; checkpointToken = ""; nextArenaUpdate = 0f; } if (flag3 && InTrial) { Close(); } if (flag2 && InTrial && !Own.Dead) { Tab = "complete_level"; } } Last = reply; switch (reply.Command) { case "open_gate": Close(); Notice = "Дождитесь открытия створок и войдите внутрь с ключом."; if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, Notice, 0, (Sprite)null, false); } break; case "gate_view": if (reply.Run == null && !InTrial) { Run = null; } GateId = reply.GateId; GateUnlocked = reply.GateUnlocked; GuardianAlive = reply.GuardianAlive; GateHasExpedition = reply.GateHasExpedition; GateDifficulty = reply.GateDifficulty; Recoverable.Clear(); Recoverable.AddRange(reply.Recoverable); Tab = "gate"; MenuOpen = true; break; case "enter": { openingGate = reply.GateId; RunState run = Run; destination = ((run != null && run.HasCheckpoint) ? reply.Destination : null); Close(); break; } case "leave": openingGate = ""; destination = reply.Destination; Close(); break; case "bank": case "rewards": if (!bankRefreshes.Remove(reply.Id) || (MenuOpen && !(Tab != reply.Command))) { Rows.Clear(); Rows.AddRange(reply.Rows); Page = reply.Page; TotalRows = reply.TotalRows; Tab = reply.Command; MenuOpen = true; } break; case "repair": if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && InTrial && BetweenLevels) { Notice = "Восстановлена прочность: " + NativeItems.RepairDurability(Player.m_localPlayer) + "."; if (!NativeProfileSave.TrySave(Player.m_localPlayer, out var error)) { Notice = Notice + " " + error; } } break; case "transfer": HandleTransfer(reply.Transfer, reply.Run?.Id); break; } if (reply.Command == "hello" && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ReceiptBook receiptBook = ReadBook(); foreach (Transfer pending in reply.Pending) { if (receiptBook.Items.FirstOrDefault((ItemReceipt x) => x.World == WorldId && x.Run == Run?.Id && x.Id == pending.Id) == null && !sources.ContainsKey(pending.Id) && !activeSaves.Contains(pending.Id)) { SendTransfer("cancel", pending.Id); } } } if ((reply.Command != "state" && reply.Command != "hello") || reply.Revision > num || flag) { ui.Refresh(); } } public void OpenGate(string id) { GateId = id; Notice = ""; plugin.Wire.Request(new RiftRequest { Command = "gate_view", GateId = id }); } public void Enter(int difficulty) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!RiftAssets.HasKey(Player.m_localPlayer, GateId)) { Notice = "Нужен ключ, выпавший у этих врат."; ui.Refresh(); return; } plugin.Wire.Request(new RiftRequest { Command = "open_gate", GateId = GateId, Number = difficulty, Item = NativeItems.Encode(RiftAssets.FindKey(Player.m_localPlayer, GateId)) }); } } internal void EnterInside(string gateId) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; ItemData val = RiftAssets.FindKey(localPlayer, gateId); if (Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting() && !InTrial && val != null) { ZDO val2 = RiftWire.FindGate(gateId); if (val2 != null && RiftGate.ContainsEntry(Quaternion.Inverse(val2.GetRotation()) * (((Component)localPlayer).transform.position - val2.GetPosition())) && RiftGate.HasOpened(gateId)) { plugin.Wire.Request(new RiftRequest { Command = "enter", GateId = gateId, Item = NativeItems.Encode(val) }); } } } public void Recall() { plugin.Wire.Request(new RiftRequest { Command = "guardian", GateId = GateId }); } public void RecoverGate(string runId) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !RiftAssets.HasKey(Player.m_localPlayer, GateId)) { Notice = "Нужен ключ от новых врат."; ui.Refresh(); return; } plugin.Wire.Request(new RiftRequest { Command = "recover_gate", GateId = GateId, RunId = runId, Item = NativeItems.Encode(RiftAssets.FindKey(Player.m_localPlayer, GateId)) }); } public void RestartGate() { plugin.Wire.Request(new RiftRequest { Command = "restart_gate", GateId = GateId }); } public void Send(string command, bool flag = true) { if (Run != null) { plugin.Wire.Request(new RiftRequest { Command = command, RunId = Run.Id, Flag = flag }); } } public void ReadyForWave(string command) { if (TransferBusy) { Notice = "Дождитесь завершения переноса добычи."; ui.Refresh(); } else { Notice = "Для готовности оставайтесь всем отрядом в напольном круге."; Close(); } } public void EnterNextCircle() { if (!TransferBusy && NextLevelCircle.Available(Run) && Own != null && !Own.Dead) { CirclePresence(eligible: true); } } public void Bank(bool rewards = false, int page = 0, bool open = true) { if (Run != null) { string text = Guid.NewGuid().ToString("N"); if (!open) { bankRefreshes.Add(text); } plugin.Wire.Request(new RiftRequest { Command = "bank", RunId = Run.Id, Id = text, Page = page, Flag = rewards }); } } public void Station(string action) { Notice = ""; if (!BetweenLevels && action != "altar") { Notice = "Доступно между уровнями."; MenuOpen = true; Tab = "run"; ui.Refresh(); return; } switch (action) { case "bank": Bank(); break; case "reward": Bank(rewards: true); break; case "repair": Send("repair"); break; case "exit": MenuOpen = true; Tab = "exit"; ui.Refresh(); break; default: MenuOpen = true; Tab = "run"; ui.Refresh(); break; } } public void Close() { MenuOpen = false; ui.Close(); } public void Deposit(Inventory inventory, ItemData item) { if (Run != null && Object.op_Implicit((Object)(object)Player.m_localPlayer) && InventoryCompatibility.GetInventories(Player.m_localPlayer).Contains(inventory) && inventory.GetAllItems().Contains(item)) { if (RiftAssets.IsGateKey(item)) { Notice = "Ключ врат остаётся при вас для повторного входа."; ui.Refresh(); return; } if (item.m_equipped) { Notice = "Перед переносом снимите предмет."; ui.Refresh(); return; } if (TransferBusy) { Notice = "Дождитесь завершения предыдущего переноса."; ui.Refresh(); return; } ItemPayload item2 = NativeItems.Encode(item); string text = Guid.NewGuid().ToString("N"); sources[text] = new DepositSource { Inventory = inventory, Item = item }; plugin.Wire.Request(new RiftRequest { Command = "deposit", RunId = Run.Id, Id = text, Item = item2 }); } } public void Withdraw(BankRow row) { if (Run != null && Object.op_Implicit((Object)(object)Player.m_localPlayer) && !row.Reserved) { if (TransferBusy) { Notice = "Дождитесь завершения предыдущего переноса."; ui.Refresh(); return; } string text = Guid.NewGuid().ToString("N"); activeSaves.Add(text); plugin.Wire.Request(new RiftRequest { Command = "withdraw", RunId = Run.Id, Id = text, EntryId = row.Id, RewardId = row.RewardId }); } } private void HandleTransfer(Transfer transfer, string runId) { //IL_038d: Unknown result type (might be due to invalid IL or missing references) if (transfer == null || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || string.IsNullOrEmpty(runId)) { return; } if (transfer.PlayerId != PlayerId) { throw new InvalidOperationException("Transfer belongs to another character."); } ReceiptBook receiptBook = ReadBook(); ItemReceipt itemReceipt = receiptBook.Items.FirstOrDefault((ItemReceipt x) => x.Id == transfer.Id && x.Run == runId && x.World == WorldId); if (transfer.Phase == TransferPhase.Cancelled) { sources.Remove(transfer.Id); activeSaves.Remove(transfer.Id); Notice = "Перенос отменён. Предмет не изменён."; CompleteQuickStack(transfer, runId); return; } if (transfer.Phase == TransferPhase.Committed) { if (itemReceipt == null) { throw new InvalidOperationException("Server acknowledged an inventory operation without its local receipt."); } itemReceipt.Completed = true; WriteBook(receiptBook); NativeProfileSave.TrySave(Player.m_localPlayer, out var _); sources.Remove(transfer.Id); activeSaves.Remove(transfer.Id); Notice = "Предмет перенесён."; if (!CompleteQuickStack(transfer, runId) && MenuOpen && Run?.Id == runId && (Tab == "bank" || Tab == "rewards")) { Bank(Tab == "rewards", Page, open: false); } return; } if (itemReceipt != null) { SaveAndCommit(itemReceipt); return; } if (transfer.Kind == TransferKind.Deposit) { if (!sources.TryGetValue(transfer.Id, out var value) || !value.Inventory.GetAllItems().Contains(value.Item) || value.Item.m_equipped || RiftAssets.IsGateKey(value.Item) || !QuickSourceStillValid(transfer.Id, value) || NativeItems.Encode(value.Item).Fingerprint != transfer.Item.Fingerprint) { SendTransfer("cancel", transfer.Id, runId); return; } itemReceipt = AddReceipt(receiptBook, transfer.Id, runId); if (!value.Inventory.RemoveItem(value.Item)) { receiptBook.Items.Remove(itemReceipt); WriteBook(receiptBook); SendTransfer("cancel", transfer.Id, runId); return; } } else { if (!activeSaves.Contains(transfer.Id)) { SendTransfer("cancel", transfer.Id, runId); return; } ItemData item = NativeItems.Decode(transfer.Item); Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (!NativeItems.FindEmptySlot(inventory, out var position)) { Notice = "Освободите одну ячейку инвентаря для полного стака."; SendTransfer("cancel", transfer.Id, runId); return; } itemReceipt = AddReceipt(receiptBook, transfer.Id, runId); if (!NativeItems.InsertExact(inventory, item, position)) { receiptBook.Items.Remove(itemReceipt); WriteBook(receiptBook); SendTransfer("cancel", transfer.Id, runId); return; } } activeSaves.Add(transfer.Id); SaveAndCommit(itemReceipt); } private ItemReceipt AddReceipt(ReceiptBook book, string id, string runId) { ItemReceipt itemReceipt = new ItemReceipt { World = WorldId, Run = runId, Id = id }; book.Items.Add(itemReceipt); WriteBook(book); return itemReceipt; } private ReceiptBook ReadBook() { if (!Player.m_localPlayer.m_customData.TryGetValue("dreadrifts.transfers.v1", out var value)) { return new ReceiptBook(); } ReceiptBook receiptBook = DataCodec.Decode(value); if (receiptBook == null || receiptBook.Items == null) { throw new InvalidOperationException("История переноса предметов повреждена; перенос остановлен."); } return receiptBook; } private static void WriteBook(ReceiptBook book) { Player.m_localPlayer.m_customData["dreadrifts.transfers.v1"] = DataCodec.Encode(book); } private void SaveAndCommit(ItemReceipt receipt) { if (!NativeProfileSave.TrySave(Player.m_localPlayer, out var error)) { Notice = "Ожидаем сохранение персонажа: " + error; return; } plugin.Wire.Request(new RiftRequest { Command = "commit", RunId = receipt.Run, Id = receipt.Id }); } private void ReconcileReceipts() { if (WorldId.Length != 0) { ItemReceipt[] array = ReadBook().Items.Where((ItemReceipt x) => x.World == WorldId && !x.Completed).ToArray(); foreach (ItemReceipt receipt in array) { SaveAndCommit(receipt); } } } private void SendTransfer(string command, string id, string runId = null) { plugin.Wire.Request(new RiftRequest { Command = command, RunId = (runId ?? Run.Id), Id = id }); } public void Reset() { ArenaSpectator.Reset(); ArenaMusic.Reset(); if (resetting) { return; } resetting = true; try { Close(); if (Run != null) { ArenaRuntime.Reset(); } BiomeArenaPlacement.Reset(); Synced = false; Run = null; GateId = ""; WorldId = ""; checkpointToken = ""; destination = null; openingGate = ""; GateHasExpedition = (GateUnlocked = (GuardianAlive = false)); GateDifficulty = 0; sources.Clear(); activeSaves.Clear(); bankRefreshes.Clear(); quickDeposit = null; Rows.Clear(); Recoverable.Clear(); Notice = ""; MenuOpen = false; ui.Destroy(); nextHello = (nextSave = (nextTeleport = (nextArenaUpdate = 0f))); arenaReady = false; latestStateRevision = 0L; announcedPeer = null; WorldBosses = new bool[0]; } finally { resetting = false; } } public void DepositLoot() { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || Run == null || Own == null || Own.Dead || !BetweenLevels) { return; } if (TransferBusy) { Notice = "Дождитесь завершения предыдущего переноса."; ui.Refresh(); return; } LootStack[] array = QuickLoot.Candidates(Player.m_localPlayer); LootStack[] array2 = array; foreach (LootStack obj in array2) { obj.Payload = NativeItems.Encode(obj.Item); } if (array.Length == 0) { Notice = "Нет ресурсов и трофеев для быстрого переноса. Нужные вещи можно выбрать вручную."; ui.Refresh(); return; } QuickDepositBatch quickDepositBatch = new QuickDepositBatch { World = WorldId, Run = Run.Id, Encounter = NextLevelCircle.Encounter(Run), Player = PlayerId, Present = Own.Present, Total = array.Length }; array2 = array; foreach (LootStack item in array2) { quickDepositBatch.Remaining.Enqueue(item); } quickDeposit = quickDepositBatch; Notice = QuickDepositProgress; ui.Refresh(); } public void StopQuickDeposit() { if (quickDeposit != null) { quickDeposit.Skipped += quickDeposit.Remaining.Count; quickDeposit.Remaining.Clear(); if (quickDeposit.ActiveId.Length == 0) { FinishQuickDeposit(); return; } Notice = "Завершаем текущую стопку. Остальные вещи останутся при вас."; ui.Refresh(); } } private bool QuickContextValid(QuickDepositBatch batch) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && batch.World == WorldId && batch.Player == PlayerId && Run?.Id == batch.Run && NextLevelCircle.Encounter(Run) == batch.Encounter && BetweenLevels && Own != null && !Own.Dead && Own.Present == batch.Present && Own.Connected && !((Character)Player.m_localPlayer).IsDead()) { return !((Character)Player.m_localPlayer).IsTeleporting(); } return false; } private bool QuickSourceStillValid(string id, DepositSource source) { if (!(quickDeposit?.ActiveId != id)) { if (QuickContextValid(quickDeposit) && QuickLoot.Eligible(Player.m_localPlayer, source.Inventory, source.Item)) { return InventoryCompatibility.GetInventories(Player.m_localPlayer).Contains(source.Inventory); } return false; } return true; } private void TickQuickDeposit() { QuickDepositBatch quickDepositBatch = quickDeposit; if (quickDepositBatch == null) { return; } try { if (quickDepositBatch.ActiveId.Length > 0) { if (!activeSaves.Contains(quickDepositBatch.ActiveId) && Time.unscaledTime >= quickDepositBatch.RetryAt) { SendQuickStack(quickDepositBatch); } return; } if (!QuickContextValid(quickDepositBatch)) { StopQuickDeposit(); return; } if (quickDepositBatch.Remaining.Count == 0) { FinishQuickDeposit(); return; } LootStack lootStack = quickDepositBatch.Remaining.Dequeue(); if (!InventoryCompatibility.GetInventories(Player.m_localPlayer).Contains(lootStack.Inventory) || !lootStack.Inventory.GetAllItems().Contains(lootStack.Item) || !QuickLoot.Eligible(Player.m_localPlayer, lootStack.Inventory, lootStack.Item) || NativeItems.Encode(lootStack.Item).Fingerprint != lootStack.Payload.Fingerprint) { quickDepositBatch.Skipped++; Notice = QuickDepositProgress; ui.Refresh(); return; } quickDepositBatch.Active = lootStack; quickDepositBatch.ActiveId = Guid.NewGuid().ToString("N"); sources[quickDepositBatch.ActiveId] = new DepositSource { Inventory = lootStack.Inventory, Item = lootStack.Item }; SendQuickStack(quickDepositBatch); } catch (Exception ex) { quickDepositBatch.Skipped += quickDepositBatch.Remaining.Count; quickDepositBatch.Remaining.Clear(); Notice = "Перенос остановлен: " + ex.Message; if (quickDepositBatch.ActiveId.Length == 0) { quickDeposit = null; } else { quickDepositBatch.RetryAt = Time.unscaledTime + 5f; } ui.Refresh(); plugin.Fail(ex); } } private void SendQuickStack(QuickDepositBatch batch) { batch.RetryAt = Time.unscaledTime + 3f; plugin.Wire.Request(new RiftRequest { Command = "deposit", RunId = batch.Run, Id = batch.ActiveId, Item = batch.Active.Payload }); } private bool CompleteQuickStack(Transfer transfer, string runId) { QuickDepositBatch quickDepositBatch = quickDeposit; if (quickDepositBatch == null || quickDepositBatch.ActiveId != transfer.Id || quickDepositBatch.Run != runId) { return false; } if (transfer.Phase == TransferPhase.Committed) { quickDepositBatch.Stored++; quickDepositBatch.Units += transfer.Item.Quantity; } else { quickDepositBatch.Skipped++; } quickDepositBatch.ActiveId = ""; quickDepositBatch.Active = null; Notice = QuickDepositProgress; return true; } private void QuickDepositError(RiftReply reply) { QuickDepositBatch quickDepositBatch = quickDeposit; if (quickDepositBatch != null && !(reply.Id != quickDepositBatch.ActiveId)) { quickDepositBatch.Skipped += quickDepositBatch.Remaining.Count; quickDepositBatch.Remaining.Clear(); if (reply.Command == "deposit") { quickDepositBatch.Skipped++; quickDepositBatch.ActiveId = ""; quickDepositBatch.Active = null; FinishQuickDeposit(); Notice = Notice + " " + reply.Error; } } } private void FinishQuickDeposit() { QuickDepositBatch quickDepositBatch = quickDeposit; if (quickDepositBatch != null && quickDepositBatch.ActiveId.Length <= 0) { quickDeposit = null; Notice = "На склад: " + quickDepositBatch.Stored + " стопок, " + quickDepositBatch.Units + " шт." + ((quickDepositBatch.Skipped > 0) ? (" Осталось при вас: " + quickDepositBatch.Skipped + " стопок.") : ""); if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)1, Notice, 0, (Sprite)null, false); } if (MenuOpen && Tab == "bank" && Run?.Id == quickDepositBatch.Run) { Bank(rewards: false, Page, open: false); } ui.Refresh(); } } } [Serializable] public sealed class ItemReceipt { public string World = ""; public string Run = ""; public string Id = ""; public bool Completed; } [Serializable] public sealed class ReceiptBook { public List Items = new List(); } internal sealed class RiftEffects : MonoBehaviour { private sealed class Particle { public ParticleSystem System; public float TimeRate; public float DistanceRate; public int Maximum; } private Particle[] particles; private Light[] lights; private float[] brightness; private float previous = float.NaN; private void Start() { particles = (from x in ((Component)this).GetComponentsInChildren(true) where !Object.op_Implicit((Object)(object)((Component)x).GetComponentInParent()) select x).Select(delegate(ParticleSystem x) { //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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Particle obj = new Particle { System = x }; EmissionModule emission = x.emission; obj.TimeRate = ((EmissionModule)(ref emission)).rateOverTimeMultiplier; emission = x.emission; obj.DistanceRate = ((EmissionModule)(ref emission)).rateOverDistanceMultiplier; MainModule main = x.main; obj.Maximum = ((MainModule)(ref main)).maxParticles; return obj; }).ToArray(); lights = (from x in ((Component)this).GetComponentsInChildren(true) where !Object.op_Implicit((Object)(object)((Component)x).GetComponentInParent()) && !Object.op_Implicit((Object)(object)((Component)x).GetComponentInParent()) select x).ToArray(); brightness = lights.Select((Light x) => x.intensity).ToArray(); Update(); } private void Update() { //IL_005d: 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_0088: 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) if (particles == null || !Object.op_Implicit((Object)(object)Plugin.Instance)) { return; } float value = Plugin.Instance.EffectsIntensity.Value; if (Mathf.Approximately(value, previous)) { return; } previous = value; Particle[] array = particles; foreach (Particle particle in array) { if (Object.op_Implicit((Object)(object)particle.System)) { EmissionModule emission = particle.System.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = particle.TimeRate * value; ((EmissionModule)(ref emission)).rateOverDistanceMultiplier = particle.DistanceRate * value; MainModule main = particle.System.main; ((MainModule)(ref main)).maxParticles = Mathf.RoundToInt((float)particle.Maximum * value); if (value == 0f) { particle.System.Clear(); } } } for (int j = 0; j < lights.Length; j++) { if (Object.op_Implicit((Object)(object)lights[j])) { lights[j].intensity = brightness[j] * value; } } } } internal static class RiftGateModel { private static readonly Dictionary materials = new Dictionary(); private static readonly Dictionary textures = new Dictionary(); private static Stream Resource(string name) { return typeof(RiftGateModel).Assembly.GetManifestResourceStream("DreadRifts.Gate." + name) ?? throw new InvalidDataException("Missing gate resource: " + name); } private static string ReadName(BinaryReader reader) { return Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32())); } private static Vector3 Vector(BinaryReader reader) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); } internal static void Attach(GameObject gate) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown GameObject val = new GameObject("DreadRifts_GateShell"); val.transform.SetParent(gate.transform, false); int num = LayerMask.NameToLayer("piece"); using BinaryReader binaryReader = new BinaryReader(Resource("gate.mesh")); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "DRGM" || binaryReader.ReadInt32() != 1) { throw new InvalidDataException("Unsupported gate mesh."); } int num2 = binaryReader.ReadInt32(); for (int i = 0; i < num2; i++) { string text = ReadName(binaryReader); int num3 = binaryReader.ReadInt32(); GameObject val2 = new GameObject(text); val2.transform.SetParent(val.transform, false); for (int j = 0; j < num3; j++) { string name = ReadName(binaryReader); int num4 = binaryReader.ReadInt32(); int num5 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num4]; Vector3[] array2 = (Vector3[])(object)new Vector3[num4]; Vector2[] array3 = (Vector2[])(object)new Vector2[num4]; for (int k = 0; k < num4; k++) { array[k] = Vector(binaryReader); array2[k] = Vector(binaryReader); array3[k] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num5]; for (int l = 0; l < num5; l++) { array4[l] = binaryReader.ReadInt32(); } Mesh val3 = new Mesh { name = text + "_" + j, indexFormat = (IndexFormat)1 }; val3.vertices = array; val3.normals = array2; val3.uv = array3; val3.triangles = array4; val3.RecalculateBounds(); val3.RecalculateTangents(); GameObject val4 = new GameObject("Surface_" + j); val4.transform.SetParent(val2.transform, false); val4.layer = ((num >= 0) ? num : gate.layer); val4.AddComponent().sharedMesh = val3; MeshRenderer obj = val4.AddComponent(); ((Renderer)obj).sharedMaterial = MaterialFor(name); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; switch (text) { case "DR_Shell_Stone": case "DR_RearWall": case "DR_InteriorStone": case "DR_BackClosure": case "DR_DoorPockets": val4.AddComponent().sharedMesh = val3; break; } } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Trailing gate mesh data."); } } private static Texture2D Texture(string name, bool linear = false, bool normal = false) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (textures.TryGetValue(name, out var value)) { return value; } byte[] array; using (Stream stream = Resource(name)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, wrapMode = (TextureWrapMode)0, anisoLevel = 4 }; if (!AssetUtils.LoadImage(val, array)) { throw new InvalidDataException("Invalid gate texture: " + name); } if (normal) { Color[] pixels = val.GetPixels(); for (int i = 0; i < pixels.Length; i++) { pixels[i] = new Color(1f, pixels[i].g, 1f, pixels[i].r); } val.SetPixels(pixels); val.Apply(true, false); } textures.Add(name, val); return val; } private static Material MaterialFor(string name) { //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_00e3: 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_00ef: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0393: 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_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0442: 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_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return null; } if (materials.TryGetValue(name, out var value)) { return value; } PrefabManager.Instance.GetPrefab("stone_wall_4x2"); PrefabManager.Instance.GetPrefab("portal_wood"); Shader[] source = Resources.FindObjectsOfTypeAll(); Shader val = (from x in source where Object.op_Implicit((Object)(object)x) && x.isSupported && x.FindPropertyIndex("_MainTex") >= 0 && x.FindPropertyIndex("_BumpMap") >= 0 && x.FindPropertyIndex("_EmissionColor") >= 0 && x.FindPropertyIndex("_MetallicGlossMap") >= 0 orderby (!(((Object)x).name == "Standard")) ? (((Object)x).name.Contains("Standard") ? 1 : 2) : 0 select x).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("No loaded native PBR shader supports the gate maps. Loaded: " + string.Join(",", source.Select((Shader x) => ((Object)x).name))); } Material val2 = new Material(val) { name = name, color = Color.white }; val2.SetFloat("_Mode", 0f); val2.SetInt("_SrcBlend", 1); val2.SetInt("_DstBlend", 0); val2.SetInt("_ZWrite", 1); val2.DisableKeyword("_ALPHATEST_ON"); val2.DisableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val2.renderQueue = 2000; if (materials.Count == 0) { Plugin.Instance.LogInfo("Gate material uses " + ((Object)val).name); } if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", Color.black); } val2.SetFloat("_Glossiness", 0.12f); switch (name) { case "DR_Basalt_PBR": case "DR_Bronze_PBR": { string text = ((name == "DR_Basalt_PBR") ? "Basalt" : "Bronze"); float num = ((text == "Bronze") ? 0.82f : 0f); val2.mainTexture = (Texture)(object)Texture("DR_" + text + "_BaseColor.png"); val2.SetTexture("_BumpMap", (Texture)(object)Texture("DR_" + text + "_Normal.png", linear: true, normal: true)); val2.EnableKeyword("_NORMALMAP"); val2.SetFloat("_BumpScale", 1f); Texture2D val5 = Texture("DR_" + text + "_Roughness.png", linear: true); Color[] pixels = val5.GetPixels(); for (int num2 = 0; num2 < pixels.Length; num2++) { pixels[num2] = new Color(num, num, num, 1f - pixels[num2].r); } Texture2D val6 = new Texture2D(((Texture)val5).width, ((Texture)val5).height, (TextureFormat)4, true, true) { name = "DR_" + text + "_MetallicGloss" }; val6.SetPixels(pixels); val6.Apply(true, true); val2.SetTexture("_MetallicGlossMap", (Texture)(object)val6); val2.EnableKeyword("_METALLICGLOSSMAP"); val2.SetFloat("_GlossMapScale", 1f); val2.SetFloat("_Metallic", num); break; } case "DR_EmeraldInlay": case "DR_RiftViolet": { Color val3 = (val2.color = ((name == "DR_EmeraldInlay") ? new Color(0.08f, 0.62f, 0.2f) : new Color(0.2f, 0.015f, 0.58f))); val2.SetColor("_EmissionColor", val3 * 3.2f); val2.EnableKeyword("_EMISSION"); break; } case "DR_Rift_PBR": val2.color = new Color(0.0002f, 0.0005f, 0.0003f); val2.SetTexture("_EmissionMap", (Texture)(object)Texture("DR_Rift_Emission.png")); val2.SetColor("_EmissionColor", Color.white * 1.25f); val2.EnableKeyword("_EMISSION"); val2.SetFloat("_Glossiness", 0f); break; case "DR_InteriorBronze": val2.color = new Color(0.085f, 0.042f, 0.014f); val2.SetFloat("_Metallic", 0.78f); val2.SetFloat("_Glossiness", 0.42f); break; default: val2.color = ((name == "DR_BackClosureMortar") ? new Color(0.017f, 0.023f, 0.024f) : new Color(0.013f, 0.023f, 0.019f)); break; } materials.Add(name, val2); return val2; } internal static Sprite Icon(GameObject gate) { //IL_008f: 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_006a: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return RenderManager.Instance.Render(gate); } if (typeof(RiftGateModel).Assembly.GetManifestResourceInfo("DreadRifts.Gate.DreadRifts_GateIcon.png") != null) { Texture2D val = Texture("DreadRifts_GateIcon.png"); ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } return RenderManager.Instance.Render(gate, Quaternion.Euler(8f, -22f, 0f)); } } internal sealed class LootStack { public Inventory Inventory; public ItemData Item; public ItemPayload Payload; } internal static class QuickLoot { public static bool Eligible(Player player, Inventory inventory, ItemData item) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)player) || inventory == null || item?.m_shared == null || !Object.op_Implicit((Object)(object)item.m_dropPrefab) || item.m_stack <= 0 || item.m_equipped || item.m_shared.m_questItem || RiftAssets.IsGateKey(item)) { return false; } if (inventory == ((Humanoid)player).GetInventory() && item.m_gridPos.y == 0) { return false; } if ((int)item.m_shared.m_itemType != 1) { return (int)item.m_shared.m_itemType == 13; } return true; } public static LootStack[] Candidates(Player player) { if (!Object.op_Implicit((Object)(object)player)) { return new LootStack[0]; } HashSet seen = new HashSet(); return InventoryCompatibility.GetInventories(player).SelectMany((Inventory inventory) => from item in inventory.GetAllItems() where Eligible(player, inventory, item) && seen.Add(item) select new LootStack { Inventory = inventory, Item = item }).ToArray(); } } internal sealed class RiftSpawnContext { internal string RunId; internal string ActorId; internal int Stage; internal int Floor; internal int Attempt; internal RunState Resolve() { if (!Object.op_Implicit((Object)(object)Plugin.Instance)) { return null; } RunState runState = Plugin.Instance.Server.FindRun(RunId) ?? Plugin.Instance.Client.Run; if (runState == null || !(runState.Id == RunId) || runState.Stage != Stage || runState.Level != Floor || runState.Attempt != Attempt || !Expedition.IsCombat(runState)) { return null; } return runState; } internal static RiftSpawnContext FromActor(Character character) { RiftActor riftActor = (Object.op_Implicit((Object)(object)character) ? ((Component)character).GetComponent() : null); if (!Object.op_Implicit((Object)(object)riftActor) || !Object.op_Implicit((Object)(object)riftActor.View) || !riftActor.View.IsValid() || riftActor.RunId.Length == 0) { return null; } ZDO zDO = riftActor.View.GetZDO(); return new RiftSpawnContext { RunId = riftActor.RunId, ActorId = riftActor.ActorId, Stage = zDO.GetInt("dr_stage", 0), Floor = zDO.GetInt("dr_floor", 0), Attempt = zDO.GetInt("dr_attempt", 0) }; } } internal sealed class RiftSpawnSource : MonoBehaviour { private RiftSpawnContext context; internal static void Remember(Component effect, RiftSpawnContext origin) { if (Object.op_Implicit((Object)(object)effect) && origin?.Resolve() != null) { RiftSpawnSource obj = effect.GetComponent() ?? effect.gameObject.AddComponent(); obj.context = origin; obj.Sync(); } } private void Start() { Sync(); } private void Sync() { ZNetView component = ((Component)this).GetComponent(); if (context != null && Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner()) { ZDO zDO = component.GetZDO(); zDO.Set("dr_spawn_run", context.RunId); zDO.Set("dr_spawn_stage", context.Stage); zDO.Set("dr_spawn_floor", context.Floor); zDO.Set("dr_spawn_attempt", context.Attempt); } } internal static RiftSpawnContext Read(Component effect) { if (!Object.op_Implicit((Object)(object)effect)) { return null; } RiftSpawnSource component = effect.GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.context != null) { return component.context; } ZNetView component2 = effect.GetComponent(); if (!Object.op_Implicit((Object)(object)component2) || !component2.IsValid()) { return null; } ZDO zDO = component2.GetZDO(); string text = zDO.GetString("dr_spawn_run", ""); if (text.Length != 0) { return new RiftSpawnContext { RunId = text, Stage = zDO.GetInt("dr_spawn_stage", 0), Floor = zDO.GetInt("dr_spawn_floor", 0), Attempt = zDO.GetInt("dr_spawn_attempt", 0) }; } return null; } } internal sealed class RiftUI { private readonly RiftClient client; private GameObject panel; private GameObject hud; private Text hudText; private bool dirty; private bool inputBlocked; private float nextHud; private int rosterPage; private static readonly Color Gold = new Color(1f, 0.77f, 0.36f); private static readonly Color Pale = new Color(0.88f, 0.87f, 0.96f); private static readonly Color Violet = new Color(0.71f, 0.5f, 1f); private static readonly Vector2 Center = new Vector2(0.5f, 0.5f); public RiftUI(RiftClient client) { this.client = client; } public void Refresh() { dirty = true; } public void Tick() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { client.Close(); return; } if (dirty) { dirty = false; Draw(); } if (Time.unscaledTime < nextHud) { return; } nextHud = Time.unscaledTime + 0.5f; if (!client.InTrial) { if (Object.op_Implicit((Object)(object)hud)) { Object.Destroy((Object)(object)hud); } hud = null; hudText = null; return; } if (!Object.op_Implicit((Object)(object)hud)) { hud = GUIManager.Instance.CreateText("", GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -82f), GUIManager.Instance.AveriaSerifBold, 17, Pale, true, Color.black, 580f, 90f, false); hudText = hud.GetComponent(); hudText.alignment = (TextAnchor)1; ((Graphic)hudText).raycastTarget = false; } RunState run = client.Run; string text = (client.Own.Dead ? ("Возрождение через " + TimeSpan.FromMilliseconds(Math.Max(0L, client.Own.RespawnAtMs - client.ServerNow)).ToString("mm\\:ss")) : ((run.Phase == RunPhase.Combat) ? ("Волна " + run.CurrentWave + "/" + run.TotalWaves + " · Противников: " + run.Enemies.Count((EnemyRecord x) => !x.Dead)) : ("Между уровнями · " + ((object)Plugin.Instance.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " — экспедиция"))); if (!client.Own.Dead && run.Phase == RunPhase.Combat && run.CurrentWave == 0) { text = "Подготовка · бой через " + Math.Max(0L, (long)Math.Ceiling((double)(run.StartedAtMs - client.ServerNow) / 1000.0)) + " с"; } if (!client.Own.Dead && run.Phase == RunPhase.Failed) { text = "Повтор этапа · склад откроется на уровне " + run.LockLevel; } if (!client.Own.Dead && run.Phase == RunPhase.Intermission) { text = (NextLevelCircle.HasNext(run) ? ("Уровень пройден · круг в центре — дальше · " + ((object)Plugin.Instance.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " — добыча") : ("Все испытания пройдены · " + ((object)Plugin.Instance.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " — награды и выход")); } if (!client.Own.Dead && client.BetweenLevels && client.Own.Ready) { text = "Вы готовы · " + run.Members.Count((Member m) => m.Present && m.Connected && !m.Dead && m.Ready) + "/" + run.Members.Count((Member m) => m.Present && m.Connected && !m.Dead) + " участников · " + ((object)Plugin.Instance.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " — экспедиция"; } if (!run.HasCheckpoint || !client.ArenaReady) { text = ((run.ArenaStatus.Length > 0) ? run.ArenaStatus : "Загружаем площадку испытания…"); } if (client.QuickDepositActive) { text = client.QuickDepositProgress + " · " + ((object)Plugin.Instance.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " — склад"; } if (Expedition.Objective(run.Level) == ObjectiveKind.Defend && run.Phase == RunPhase.Combat) { text = text + "\nАлтарь: " + Math.Ceiling(run.AltarHealth) + " / " + Math.Ceiling(run.AltarMaxHealth); } if (ArenaSpectator.Active) { text = text + "\nНаблюдение: " + ArenaSpectator.TargetName + " · ← / → — сменить союзника"; } hudText.text = "DREADRIFTS · " + StageCatalog.Stages[run.Stage].NameRu + " · " + run.Level + "/10\n" + text; } private void Draw() { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) RemovePanel(); if (!client.MenuOpen) { Close(); return; } panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, Center, Center, Vector2.zero, 780f, 530f); Text("DREADRIFTS", 0f, 216f, 32, Gold, 680f, 42f, (TextAnchor)4); Button("×", 345f, 220f, 38f, client.Close); if (client.Tab == "gate") { Gate(); } else if (client.Tab == "stages") { Stages(); } else if (client.Tab == "complete_level") { CompleteLevel(); } else if (client.Tab == "recover") { Recover(); } else if (client.Tab == "bank" || client.Tab == "rewards") { Bank(); } else if (client.Tab == "deposit") { Deposit(); } else if (client.Tab == "exit") { Exit(); } else { Run(); } if (client.Notice.Length > 0) { Text(client.Notice, 0f, -207f, 15, Gold, 710f, 46f, (TextAnchor)4); } if (!inputBlocked) { GUIManager.BlockInput(true); inputBlocked = true; } } private void Gate() { //IL_0026: 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_0287: 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_017e: Unknown result type (might be due to invalid IL or missing references) Text(client.GateUnlocked ? "Врата открыты для испытаний" : "Победите хранителя и подберите ключ", 0f, 160f, 21, Pale, 690f, 40f, (TextAnchor)4); Text("Откройте створки и войдите внутрь. Каждый участник входит со своим многоразовым ключом — вместе или по одному.", 0f, 104f, 17, Pale, 650f, 68f, (TextAnchor)4); bool gateHasExpedition = client.GateHasExpedition; if (gateHasExpedition) { Button("Открыть врата", 0f, 24f, 340f, delegate { client.Enter(client.GateDifficulty); }, client.GateUnlocked); } else { bool flag = client.GateUnlocked && client.WorldBosses.Length != 0 && client.WorldBosses[0]; Button("Лёгкий", -235f, 24f, 220f, delegate { client.Enter(0); }, flag); Button("Для викингов", 0f, 24f, 220f, delegate { client.Enter(1); }, flag); Button("Дьявольский", 235f, 24f, 220f, delegate { client.Enter(2); }, flag); if (!flag && client.GateUnlocked) { Text("Первое испытание откроется после победы над Эйктюром.", 0f, -36f, 17, Gold, 690f, 44f, (TextAnchor)4); } } if (client.Run != null && client.Run.GateId == client.GateId) { Text("Продолжение: " + StageCatalog.Stages[client.Run.Stage].NameRu + " · уровень " + client.Run.Level + " · " + DifficultyName(client.Run.Difficulty), 0f, -36f, 17, Violet, 680f, 44f, (TextAnchor)4); } else if (gateHasExpedition) { Text("Экспедиция отряда · " + DifficultyName((Difficulty)client.GateDifficulty), 0f, -36f, 17, Violet, 680f, 44f, (TextAnchor)4); } Button(client.GuardianAlive ? "Хранитель у врат" : "Вызвать хранителя", 0f, -110f, 260f, client.Recall, !client.GuardianAlive); Button("Этапы", -260f, -110f, 150f, delegate { client.Tab = "stages"; Refresh(); }); if (client.Run != null) { Button("Моя добыча", 245f, -110f, 175f, delegate { client.Bank(); }); } if (client.Recoverable.Count > 0) { Button("Восстановить экспедицию", 0f, -164f, 340f, delegate { client.Tab = "recover"; client.Page = 0; Refresh(); }, client.GateUnlocked); } else { RunState run = client.Run; if (run != null && run.Phase == RunPhase.Complete) { Button("Новая экспедиция", 0f, -164f, 300f, client.RestartGate, !client.InTrial); } } } private void Stages() { //IL_0012: 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_0060: 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_0150: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) Text("Путь испытаний · 80 уровней", 0f, 161f, 22, Pale, 700f, 42f, (TextAnchor)4); Text("Этап", -239f, 121f, 15, Gold, 190f, 30f, (TextAnchor)3); Text("Босс обычного мира", -12f, 121f, 15, Gold, 220f, 30f, (TextAnchor)4); Text("Экспедиция", 249f, 121f, 15, Gold, 190f, 30f, (TextAnchor)4); for (int i = 0; i < StageCatalog.Stages.Length; i++) { bool flag = i < client.WorldBosses.Length && client.WorldBosses[i]; bool flag2 = client.Run != null && client.Run.HighestCompletedStage >= i; bool flag3 = i == 0 || (client.Run != null && client.Run.HighestCompletedStage >= i - 1); float y = 86 - i * 31; Text(i + 1 + ". " + StageCatalog.Stages[i].NameRu, -228f, y, 17, Pale, 235f, 30f, (TextAnchor)3); Text(flag ? "Побеждён" : "Не побеждён", -12f, y, 16, flag ? Gold : Pale, 195f, 30f, (TextAnchor)4); Text(flag2 ? "Пройден" : ((flag && flag3) ? "Доступен" : "Закрыт"), 249f, y, 16, flag2 ? Gold : ((flag && flag3) ? Violet : Pale), 185f, 30f, (TextAnchor)4); } Button("Назад", 0f, -172f, 250f, delegate { client.Tab = (client.InTrial ? "run" : "gate"); Refresh(); }, enabled: true, 35f); } private void Recover() { //IL_0012: 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_00fe: Unknown result type (might be due to invalid IL or missing references) Text("Восстановить доступ через новые врата", 0f, 163f, 22, Pale, 700f, 42f, (TextAnchor)4); Text("Прогресс, сложность и блокировка склада сохранятся.", 0f, 122f, 17, Violet, 700f, 35f, (TextAnchor)4); SavedRunRow[] array = client.Recoverable.Skip(client.Page * 6).Take(6).ToArray(); for (int i = 0; i < array.Length; i++) { SavedRunRow row = array[i]; Text(StageCatalog.Stages[row.Stage].NameRu + " · " + row.Level + "/10 · " + DifficultyName(row.Difficulty), -87f, 65 - i * 36, 17, Pale, 465f, 32f, (TextAnchor)3); Button("Восстановить", 255f, 65 - i * 36, 170f, delegate { client.RecoverGate(row.Id); }, enabled: true, 31f); } Button("‹", -235f, -172f, 60f, delegate { client.Page--; Refresh(); }, client.Page > 0, 34f); Button("›", -145f, -172f, 60f, delegate { client.Page++; Refresh(); }, (client.Page + 1) * 6 < client.Recoverable.Count, 34f); Button("Назад", 195f, -172f, 240f, delegate { client.Tab = "gate"; Refresh(); }, enabled: true, 34f); } private void CompleteLevel() { //IL_0053: 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_00cc: Unknown result type (might be due to invalid IL or missing references) RunState run = client.Run; if (run != null) { Text("Уровень " + run.Level + " пройден", 0f, 151f, 26, Gold, 690f, 45f, (TextAnchor)4); Text(StageCatalog.Stages[run.Stage].NameRu + " · " + DifficultyName(run.Difficulty), 0f, 101f, 19, Violet, 650f, 38f, (TextAnchor)4); Text("Добыча врагов автоматически собирается на склад. Для перехода дальше соберитесь всем отрядом в фиолетовом круге и оставайтесь внутри до конца отсчёта.", 0f, 29f, 19, Pale, 640f, 110f, (TextAnchor)4); Button(client.QuickDepositActive ? "Перенос добычи…" : "Сложить добычу", -179f, -65f, 300f, client.DepositLoot, !client.TransferBusy); Button((run.Level == 10) ? "Личная награда" : "Открыть склад", 179f, -65f, 300f, delegate { client.Bank(run.Level == 10); }); Button("Ремонт", -260f, -131f, 150f, delegate { client.Send("repair"); }); Button("Вернуться к арене", 0f, -131f, 240f, client.Close); Button("К вратам", 260f, -131f, 150f, delegate { client.Station("exit"); }); } } private void Run() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) RunState run = client.Run; if (run == null) { Text("Подойдите к вратам, чтобы начать экспедицию.", 0f, 70f, 20, Pale, 660f, 80f, (TextAnchor)4); return; } Text(StageCatalog.Stages[run.Stage].NameRu + " · уровень " + run.Level + " из 10", 0f, 160f, 22, Pale, 680f, 42f, (TextAnchor)4); string text = ((Expedition.Objective(run.Level) == ObjectiveKind.Defend) ? "Защита алтаря от волн" : ((run.Level == 10) ? "Босс и противники его биома" : "Зачистка и элитные противники")); Text(text + " · " + DifficultyName(run.Difficulty), 0f, 113f, 18, Violet, 680f, 40f, (TextAnchor)4); rosterPage = Math.Max(0, Math.Min(rosterPage, Math.Max(0, (run.Members.Count - 1) / 6))); string value = string.Join("\n", from m in run.Members.Skip(rosterPage * 6).Take(6) select Safe(m.Name) + " · " + ((!m.Connected) ? "не в сети" : ((!m.Present) ? "снаружи" : (m.Dead ? "ожидает возрождения" : (m.Ready ? "готов" : "в группе"))))); Text(value, -97f, 22f, 16, Pale, 460f, 126f, (TextAnchor)0); if (run.Members.Count > 6) { Button("‹", -315f, -73f, 32f, delegate { rosterPage--; Refresh(); }, rosterPage > 0, 28f); Button("›", -205f, -73f, 32f, delegate { rosterPage++; Refresh(); }, (rosterPage + 1) * 6 < run.Members.Count, 28f); Text((rosterPage + 1).ToString(), -260f, -73f, 15, Pale, 60f, 28f, (TextAnchor)4); } Button("Этапы", 265f, 53f, 150f, delegate { client.Tab = "stages"; Refresh(); }, enabled: true, 32f); Text(run.WarehouseLocked ? ("Склад закрыт\nдо уровня " + run.LockLevel) : "Склад доступен\nмежду уровнями", 253f, 0f, 15, run.WarehouseLocked ? Gold : Violet, 195f, 65f, (TextAnchor)4); bool flag = client.BetweenLevels && client.Own != null && !client.Own.Dead; if (!run.HasCheckpoint || !client.ArenaReady) { Text((run.ArenaStatus.Length > 0) ? run.ArenaStatus : "Загружаем площадку испытания…", 0f, -73f, 17, Pale, 660f, 65f, (TextAnchor)4); Button("Вернуться к вратам", 0f, -139f, 300f, delegate { client.Send("leave"); }, flag && !run.HasCheckpoint); return; } if (run.Phase == RunPhase.Ready || run.Phase == RunPhase.Failed) { Text("Для старта соберитесь в зелёном круге", 0f, -85f, 17, Gold, 660f, 35f, (TextAnchor)4); } else if (run.Phase == RunPhase.Intermission) { Text("Для перехода соберитесь в фиолетовом круге", 0f, -85f, 17, Gold, 660f, 35f, (TextAnchor)4); } else if (run.Phase == RunPhase.Complete) { Text("Все испытания пройдены", 0f, -73f, 22, Gold, 660f, 44f, (TextAnchor)4); } Button("Склад", -260f, -139f, 150f, delegate { client.Bank(); }, flag); Button("Награды", -90f, -139f, 165f, delegate { client.Bank(rewards: true); }, flag); Button("Ремонт", 90f, -139f, 150f, delegate { client.Send("repair"); }, flag && client.InTrial); Button("Выход", 260f, -139f, 150f, delegate { client.Station("exit"); }, flag && client.InTrial); } private void Bank() { //IL_0049: 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_01b3: 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_024d: 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) bool rewards = client.Tab == "rewards"; Text(rewards ? "Личные награды" : "Общий склад экспедиции", 0f, 163f, 22, Pale, 700f, 42f, (TextAnchor)4); bool flag = !rewards && client.Run != null && client.Run.WarehouseLocked; if (!rewards) { QuickDepositAction(); } for (int i = 0; i < client.Rows.Count; i++) { BankRow row = client.Rows[i]; float y = 85 - i * 29; Text(Localization.instance.Localize(row.Name) + " ×" + row.Quantity, -76f, y, 17, Pale, 500f, 28f, (TextAnchor)3); Button(row.Reserved ? "Перенос…" : "Забрать", 262f, y, 140f, delegate { client.Withdraw(row); }, !row.Reserved && !flag && !client.TransferBusy, 27f); } if (client.Rows.Count == 0) { Text("Здесь пока нет предметов", 0f, 20f, 18, Pale, 650f, 50f, (TextAnchor)4); } if (!rewards) { Text(flag ? ("Выдача закрыта до этапа " + (client.Run.LockStage + 1) + ", уровня " + client.Run.LockLevel + ". Складывать добычу можно.") : "Оружие, еда, ключ и быстрые слоты остаются при вас.", 0f, -139f, 13, flag ? Gold : Pale, 710f, 22f, (TextAnchor)4); } Button("‹", -310f, -165f, 45f, delegate { client.Bank(rewards, client.Page - 1); }, client.Page > 0, 32f); Text(client.Page + 1 + " / " + Math.Max(1, (client.TotalRows + 7) / 8), -244f, -165f, 15, Pale, 75f, 30f, (TextAnchor)4); Button("›", -175f, -165f, 45f, delegate { client.Bank(rewards, client.Page + 1); }, (client.Page + 1) * 8 < client.TotalRows, 32f); if (!rewards) { Button("Положить предметы", 18f, -165f, 255f, delegate { client.Tab = "deposit"; client.Page = 0; Refresh(); }, enabled: true, 34f); } Button("Экспедиция", 263f, -165f, 185f, delegate { client.Tab = "run"; Refresh(); }, enabled: true, 34f); } private void Deposit() { //IL_0012: 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_01bf: 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_0198: Unknown result type (might be due to invalid IL or missing references) Text("Перенести в общий склад", 0f, 163f, 22, Pale, 700f, 42f, (TextAnchor)4); if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } var array = InventoryCompatibility.GetInventories(Player.m_localPlayer).SelectMany((Inventory inventory) => from item in inventory.GetAllItems() where !item.m_equipped && !RiftAssets.IsGateKey(item) select new { Inventory = inventory, Item = item }).ToArray(); client.Page = Math.Max(0, Math.Min(client.Page, Math.Max(0, (array.Length - 1) / 8))); QuickDepositAction(); var array2 = array.Skip(client.Page * 8).Take(8).ToArray(); for (int num = 0; num < array2.Length; num++) { var entry = array2[num]; float y = 85 - num * 29; Text(Localization.instance.Localize(entry.Item.m_shared.m_name) + " ×" + entry.Item.m_stack, -75f, y, 17, Pale, 490f, 29f, (TextAnchor)3); Button("Положить", 265f, y, 140f, delegate { client.Deposit(entry.Inventory, entry.Item); }, !client.TransferBusy, 27f); } if (array.Length == 0) { Text("Нет предметов для переноса", 0f, 20f, 18, Pale, 650f, 50f, (TextAnchor)4); } Text("Быстро: ресурсы и трофеи вне быстрых слотов. Вручную: выбранная стопка.", 0f, -139f, 13, Pale, 710f, 22f, (TextAnchor)4); Button("‹", -300f, -165f, 45f, delegate { client.Page--; Refresh(); }, client.Page > 0, 34f); Text(client.Page + 1 + " / " + Math.Max(1, (array.Length + 7) / 8), -210f, -165f, 16, Pale, 90f, 30f, (TextAnchor)4); Button("›", -120f, -165f, 45f, delegate { client.Page++; Refresh(); }, (client.Page + 1) * 8 < array.Length, 34f); Button("Вернуться к складу", 150f, -165f, 300f, delegate { client.Bank(); }, enabled: true, 34f); } private void QuickDepositAction() { //IL_0109: Unknown result type (might be due to invalid IL or missing references) int num = ((!client.QuickDepositActive) ? QuickLoot.Candidates(Player.m_localPlayer).Length : 0); Button(client.QuickDepositActive ? client.QuickDepositProgress : ("Сложить добычу (" + num + ")"), -151f, 123f, 380f, client.DepositLoot, !client.TransferBusy && client.BetweenLevels && client.Own != null && !client.Own.Dead && num > 0, 32f); if (client.QuickDepositActive) { Button("Остановить", 225f, 123f, 225f, client.StopQuickDeposit, enabled: true, 32f); } else { Text("Ресурсы и трофеи", 218f, 123f, 15, Violet, 255f, 32f, (TextAnchor)4); } } private void Exit() { //IL_0012: 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) Text("Вернуться к вратам?", 0f, 135f, 24, Pale, 650f, 50f, (TextAnchor)4); Text("Снаряжение и добыча в инвентаре останутся с вами. Прогресс группы сохранится: можно вернуться на тот же уровень. Предметы на складе доступны через врата.", 0f, 45f, 19, Pale, 620f, 125f, (TextAnchor)4); Button("Забрать добычу", -190f, -90f, 280f, delegate { client.Bank(); }); Button("Вернуться домой", 190f, -90f, 280f, delegate { client.Send("leave"); }); } private void Text(string value, float x, float y, int size, Color color, float width, float height, TextAnchor align = (TextAnchor)3) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0031: 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) Text component = GUIManager.Instance.CreateText(value, panel.transform, Center, Center, new Vector2(x, y), GUIManager.Instance.AveriaSerifBold, size, color, false, Color.black, width, height, false).GetComponent(); component.alignment = align; ((Graphic)component).raycastTarget = false; } private void Button(string value, float x, float y, float width, Action action, bool enabled = true, float height = 40f) { //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_0032: 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_0063: Expected O, but got Unknown Button component = GUIManager.Instance.CreateButton(value, panel.transform, Center, Center, new Vector2(x, y), width, height).GetComponent