Decompiled source of Uriel v0.17.0
BepInEx/plugins/Uriel.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Tiles; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using UnityEngine; using Uriel.Config; using Uriel.Services; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("kdpen")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Kristopher Penland")] [assembly: AssemblyDescription("Uriel, Lord of Hosts — a host of server-side quality-of-life enhancements and structural fixes for V Rising dedicated servers.")] [assembly: AssemblyFileVersion("0.17.0.0")] [assembly: AssemblyInformationalVersion("0.17.0+5490af2b075bd405ce3c2891eb1cb652a3816b90")] [assembly: AssemblyProduct("Uriel")] [assembly: AssemblyTitle("Uriel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.17.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.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 Uriel { internal static class Core { private static bool _initInProgress; private static int _initAttempts; public static World Server { get; private set; } public static EntityManager EntityManager { get; private set; } public static PrefabCollectionSystem PrefabCollectionSystem { get; private set; } public static ServerScriptMapper ServerScriptMapper { get; private set; } public static DebugEventsSystem DebugEventsSystem { get; private set; } public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static PublicStorageService PublicStorage { get; private set; } public static ItemCatalogService ItemCatalog { get; private set; } public static StairSwapService StairSwap { get; private set; } public static ObjectSpawnService ObjectSpawn { get; private set; } public static PlayerUnlockService PlayerUnlock { get; private set; } public static ManualLogSource Log => Plugin.PluginLog; public static bool IsReady { get; private set; } internal static void TryInitialize(string trigger) { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) if (IsReady || _initInProgress) { return; } _initInProgress = true; _initAttempts++; bool flag = default(bool); try { World val = FindServerWorld(); BepInExInfoLogInterpolatedStringHandler val2; if (val == null) { if (_initAttempts == 1) { ManualLogSource log = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Uriel init ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): Server world not yet present; will retry."); } log.LogInfo(val2); } return; } PrefabCollectionSystem existingSystemManaged = val.GetExistingSystemManaged<PrefabCollectionSystem>(); if (existingSystemManaged == null || existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count == 0) { if (_initAttempts == 1) { ManualLogSource log2 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(68, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Uriel init ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): PrefabCollectionSystem not yet populated; will retry."); } log2.LogInfo(val2); } return; } Server = val; EntityManager = val.EntityManager; PrefabCollectionSystem = existingSystemManaged; ServerScriptMapper = val.GetExistingSystemManaged<ServerScriptMapper>(); DebugEventsSystem = val.GetExistingSystemManaged<DebugEventsSystem>(); Tick.StartDriver(); ItemCatalog = new ItemCatalogService(); ItemCatalog.Build(); StairSwap = new StairSwapService(); PlayerUnlock = new PlayerUnlockService(); PlayerUnlock.Load(); ObjectSpawn = new ObjectSpawnService(); ObjectSpawn.Load(); try { ObjectSpawn.ReapplySpawned(); } catch (Exception ex) { ManualLogSource log3 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Uriel SPAWN] boot re-apply failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex); } log3.LogWarning(val3); } try { ObjectSpawn.StartRespawnLoop(); } catch (Exception ex2) { ManualLogSource log4 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Uriel SPAWN] respawn loop start failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex2); } log4.LogWarning(val3); } PublicStorage = new PublicStorageService(); PublicStorage.Load(); try { PublicStorage.ReapplyAll(); } catch (Exception ex3) { ManualLogSource log5 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Uriel SHARE] re-apply failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex3); } log5.LogWarning(val3); } IsReady = true; ManualLogSource log6 = Log; val2 = new BepInExInfoLogInterpolatedStringHandler(60, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Uriel initialized via "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (attempt #"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_initAttempts); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("). Prefab map has "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entries."); } log6.LogInfo(val2); } catch (Exception ex4) { ManualLogSource log7 = Log; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(35, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Uriel init ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(trigger); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") FAILED on attempt #"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(_initAttempts); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex4); } log7.LogError(val4); } finally { _initInProgress = false; } } private static World FindServerWorld() { Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == "Server") { return current; } } return null; } } internal static class EntityExtensions { public delegate void RefAction<T>(ref T value) where T : unmanaged; public static bool Exists(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_0015: Unknown result type (might be due to invalid IL or missing references) if (entity != Entity.Null) { EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).Exists(entity); } return false; } public static bool Has<T>(this Entity entity) { //IL_0000: 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_000d: 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 (entity.Exists()) { EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).HasComponent<T>(entity); } return false; } public static T Read<T>(this Entity entity) where T : unmanaged { //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_0008: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; return ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); } public static bool TryGetComponent<T>(this Entity entity, out T component) where T : unmanaged { //IL_0000: 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_000d: 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_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_002a: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).HasComponent<T>(entity)) { entityManager = Core.EntityManager; component = ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); return true; } } component = default(T); return false; } public static void With<T>(this Entity entity, RefAction<T> mutator) where T : unmanaged { //IL_0000: 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_005c: 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_0070: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has<T>()) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(44, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel] Entity.With<"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeof(T).Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(">: component missing on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Entity>(entity); } log.LogWarning(val); } else { EntityManager entityManager = Core.EntityManager; T value = ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); mutator(ref value); entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, value); } } public static void AddOrSet<T>(this Entity entity, T value) where T : unmanaged { //IL_0000: 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_0011: 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_0030: 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_0021: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { EntityManager entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<T>(entity)) { entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).AddComponent<T>(entity); } entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, value); } } public static void RemoveIfPresent<T>(this Entity entity) { //IL_0000: 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_000d: 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 (entity.Has<T>()) { EntityManager entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent<T>(entity); } } public static ulong GetSteamId(this Entity playerCharacter) { //IL_0000: 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_000b: 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) if (playerCharacter.TryGetComponent<PlayerCharacter>(out PlayerCharacter component) && component.UserEntity.TryGetComponent<User>(out User component2)) { return component2.PlatformId; } return 0uL; } public static PrefabGUID GetPrefabGuid(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) if (!entity.TryGetComponent<PrefabGUID>(out PrefabGUID component)) { return default(PrefabGUID); } return component; } public static bool TryResolvePlayer(string nameOrId, out ulong steamId, out string resolvedName, out string error) { //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_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_005c: 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_0065: 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_0076: 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) steamId = 0uL; resolvedName = null; error = null; if (string.IsNullOrWhiteSpace(nameOrId)) { error = "Provide a character name or steamId."; return false; } if (ulong.TryParse(nameOrId, out var result) && result > 1000) { steamId = result; resolvedName = result.ToString(); return true; } EntityManager entityManager = Core.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); int num = 0; try { for (int i = 0; i < val2.Length; i++) { if (!val2[i].TryGetComponent<User>(out User component)) { continue; } string text = ((object)(FixedString64Bytes)(ref component.CharacterName)).ToString(); if (!string.IsNullOrEmpty(text) && text.Contains(nameOrId, StringComparison.OrdinalIgnoreCase)) { num++; steamId = component.PlatformId; resolvedName = text; if (string.Equals(text, nameOrId, StringComparison.OrdinalIgnoreCase)) { num = 1; break; } } } } finally { val2.Dispose(); } if (num == 0) { error = "No player matches '" + nameOrId + "'."; return false; } if (num > 1) { error = "'" + nameOrId + "' matches multiple players — be more specific or use the steamId."; steamId = 0uL; return false; } return true; } public static string GetPrefabName(this PrefabGUID prefabGuid) { //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_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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) try { PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap; NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = prefabLookupMap.GuidToEntityMap; if (guidToEntityMap.ContainsKey(prefabGuid)) { return ((PrefabLookupMap)(ref prefabLookupMap)).GetName(prefabGuid); } } catch { } return $"PrefabGuid({prefabGuid._Value})"; } } [BepInPlugin("kdpen.Uriel", "Uriel", "0.17.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { internal static Harmony Harmony; internal static ManualLogSource PluginLog; internal static Plugin Instance { get; private set; } public override void Load() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown if (!(Application.productName != "VRisingServer")) { Instance = this; PluginLog = ((BasePlugin)this).Log; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("kdpen.Uriel"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.17.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loading..."); } log.LogInfo(val); Settings.Initialize(((BasePlugin)this).Config); Harmony = new Harmony("kdpen.Uriel"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); int num = Harmony.GetPatchedMethods().Count(); ManualLogSource log2 = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches applied: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" method(s) patched."); } log2.LogInfo(val); CommandRegistry.RegisterAll(); ManualLogSource log3 = ((BasePlugin)this).Log; val = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("kdpen.Uriel"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.17.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded. Awaiting game data init."); } log3.LogInfo(val); } } public override bool Unload() { CommandRegistry.UnregisterAssembly(); Core.PublicStorage?.SaveSync(); Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "kdpen.Uriel"; public const string PLUGIN_NAME = "Uriel"; public const string PLUGIN_VERSION = "0.17.0"; } } namespace Uriel.Services { internal static class ChatNotify { public static void ToUserEntity(Entity userEntity, string message) { //IL_0000: 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_0018: Unknown result type (might be due to invalid IL or missing references) if (userEntity.TryGetComponent<User>(out User component)) { FixedString512Bytes val = default(FixedString512Bytes); ((FixedString512Bytes)(ref val))..ctor(message); ServerChatUtils.SendSystemMessageToClient(Core.EntityManager, component, ref val); } } public static void ToCharacter(Entity characterEntity, string message) { //IL_0000: 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) if (characterEntity.TryGetComponent<PlayerCharacter>(out PlayerCharacter component)) { ToUserEntity(component.UserEntity, message); } } } internal sealed class ItemCatalogService { private readonly List<(string Name, int Guid)> _items = new List<(string, int)>(); private readonly HashSet<int> _guids = new HashSet<int>(); public int Count => _items.Count; public void Build() { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown _items.Clear(); _guids.Clear(); bool flag = default(bool); try { Enumerator<string, PrefabGUID> enumerator = Core.PrefabCollectionSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, PrefabGUID> current = enumerator.Current; string text = current.Key.ToString(); if (text.StartsWith("Item_", StringComparison.OrdinalIgnoreCase)) { int value = current.Value._Value; _items.Add((text, value)); _guids.Add(value); } } _items.Sort(((string Name, int Guid) a, (string Name, int Guid) b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel ITEMS] catalog built: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_items.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" item prefab(s)."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel ITEMS] catalog build failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } public bool IsKnownItem(int guid) { return _guids.Contains(guid); } public string NameOf(int guid) { foreach (var item in _items) { var (result, _) = item; if (item.Guid == guid) { return result; } } return $"PrefabGuid({guid})"; } public List<(string Name, int Guid)> Search(string fragment, int max, out int totalMatches) { List<(string, int)> list = new List<(string, int)>(); totalMatches = 0; if (string.IsNullOrWhiteSpace(fragment)) { return list; } foreach (var (text, item) in _items) { if (text.Contains(fragment, StringComparison.OrdinalIgnoreCase)) { totalMatches++; if (list.Count < max) { list.Add((text, item)); } } } return list; } } internal sealed class ObjectSpawnService { internal sealed class SpawnRecord { public int PrefabGuid { get; set; } public int TileX { get; set; } public int TileY { get; set; } public float PosX { get; set; } public float PosY { get; set; } public float PosZ { get; set; } public bool Indestructible { get; set; } public int TerritoryIndex { get; set; } = -1; public bool HasHeart { get; set; } public int HeartTileX { get; set; } public int HeartTileY { get; set; } public ulong SpawnedBySteamId { get; set; } public string SpawnedAtUtc { get; set; } public int PaidCostItem { get; set; } public int PaidCostAmount { get; set; } public int Rot { get; set; } public bool RespawnOnDestroy { get; set; } public bool PlayerBreakable { get; set; } } private sealed class SaveFile { public int SchemaVersion { get; set; } = 3; public List<SpawnRecord> Objects { get; set; } = new List<SpawnRecord>(); } private sealed class LiveIndex { public readonly Dictionary<(int, int, int), Entity> ByTile = new Dictionary<(int, int, int), Entity>(); public readonly Dictionary<int, List<Entity>> ByGuid = new Dictionary<int, List<Entity>>(); public Entity Resolve(SpawnRecord r) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00c4: 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_010d: 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_00f1: 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_011a: Unknown result type (might be due to invalid IL or missing references) if (ByTile.TryGetValue((r.PrefabGuid, r.TileX, r.TileY), out var value) && value.Exists()) { return value; } if ((r.PosX != 0f || r.PosY != 0f || r.PosZ != 0f) && ByGuid.TryGetValue(r.PrefabGuid, out var value2)) { Entity val = Entity.Null; float num = 4f; foreach (Entity item in value2) { if (item.TryGetComponent<Translation>(out Translation component)) { float num2 = component.Value.x - r.PosX; float num3 = component.Value.y - r.PosY; float num4 = component.Value.z - r.PosZ; float num5 = num2 * num2 + num3 * num3 + num4 * num4; if (num5 < num) { num = num5; val = item; } } } if (val != Entity.Null) { return val; } } return Entity.Null; } } private readonly struct CatalogEntry { public readonly string Name; public readonly PrefabGUID Guid; public readonly string Label; public readonly string Cat; public CatalogEntry(string name, PrefabGUID guid, string label, string cat) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Name = name; Guid = guid; Label = label; Cat = cat; } } private sealed class PendingForce { public int Guid; public int TileX; public int TileY; public float PosX; public float PosY; public float PosZ; public string Name; public DateTime ExpiresUtc; } private const int TileGridOffset = 6400; private const float BlockSize = 10f; private readonly List<SpawnRecord> _records = new List<SpawnRecord>(); private readonly HashSet<int> _blocked = new HashSet<int>(); private readonly Dictionary<int, List<int>> _bossUnlocks = new Dictionary<int, List<int>>(); private List<CatalogEntry> _placeable; private HashSet<int> _placeableGuids; private HashSet<int> _discoverableGuids; private Dictionary<int, CatalogEntry> _byGuid; private static readonly string[] NonObjectPrefixes = new string[7] { "CHAR_", "AB_", "GM_", "Liquid_", "Summon", "USB_", "PrefabVariant" }; private static readonly Random _rng = new Random(); private const int DraculaGuid = -327335305; private HashSet<int> _bossRoster; private const int ApiPageSize = 20; private static readonly string[] DebugMarkers = new string[6] { "Debug", "Benchmark", "ArtQuality", "Placeholder", "DELETE", "_TBD" }; private const int ReplyByteBudget = 480; private readonly Dictionary<ulong, PendingForce> _pendingForce = new Dictionary<ulong, PendingForce>(); private static readonly TimeSpan ForceConfirmWindow = TimeSpan.FromSeconds(30.0); private static string SaveDir => Path.Combine(Paths.ConfigPath, "Uriel"); private static string SavePath => Path.Combine(SaveDir, "spawned_objects.json"); private static string SavePathBlocked => Path.Combine(SaveDir, "blocked_prefabs.json"); private static string SavePathBossMap => Path.Combine(SaveDir, "boss_unlocks.json"); public bool TracksKills { get { bool flag = Settings.ObjectSpawn_Enabled.Value && Settings.ObjectSpawn_CollectionEnabled.Value && !Settings.ObjectSpawn_AdminOnly.Value && IsDiscoveryMode(); if (flag) { bool flag2 = Settings.ObjectSpawn_DiscoveryChancePercent.Value > 0 || Settings.ObjectSpawn_BossUnlocksEnabled.Value; if (!flag2) { bool flag3; switch (NonDestructibleMode()) { case "collection": case "finalboss": case "allbosses": flag3 = true; break; default: flag3 = false; break; } flag2 = flag3; } flag = flag2; } return flag; } } public void Load() { LoadRecords(); LoadBlocked(); LoadBossMap(); } private void LoadBossMap() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown bool flag = default(bool); try { if (!File.Exists(SavePathBossMap)) { return; } Dictionary<string, List<int>> dictionary = JsonSerializer.Deserialize<Dictionary<string, List<int>>>(File.ReadAllText(SavePathBossMap)); if (dictionary == null) { return; } _bossUnlocks.Clear(); foreach (KeyValuePair<string, List<int>> item in dictionary) { if (int.TryParse(item.Key, out var result)) { _bossUnlocks[result] = new List<int>(item.Value); } } if (_bossUnlocks.Count > 0) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] loaded boss-unlock map for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_bossUnlocks.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" V-blood(s)."); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel SPAWN] failed loading "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(SavePathBossMap); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } private void SaveBossMap() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown try { Directory.CreateDirectory(SaveDir); Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>(); foreach (KeyValuePair<int, List<int>> bossUnlock in _bossUnlocks) { dictionary[bossUnlock.Key.ToString()] = bossUnlock.Value; } File.WriteAllText(SavePathBossMap, JsonSerializer.Serialize(dictionary, new JsonSerializerOptions { WriteIndented = true })); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] failed saving "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SavePathBossMap); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } } private void LoadRecords() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown bool flag = default(bool); try { if (!File.Exists(SavePath)) { return; } SaveFile saveFile = JsonSerializer.Deserialize<SaveFile>(File.ReadAllText(SavePath)); if (saveFile?.Objects != null) { _records.Clear(); _records.AddRange(saveFile.Objects); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_records.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" spawned-object record(s)."); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel SPAWN] failed loading "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(SavePath); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } private void LoadBlocked() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown bool flag = default(bool); try { if (!File.Exists(SavePathBlocked)) { return; } List<int> list = JsonSerializer.Deserialize<List<int>>(File.ReadAllText(SavePathBlocked)); if (list == null) { return; } _blocked.Clear(); foreach (int item in list) { _blocked.Add(item); } if (_blocked.Count > 0) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_blocked.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" blocked prefab(s)."); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel SPAWN] failed loading "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(SavePathBlocked); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } private void SaveBlocked() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown try { Directory.CreateDirectory(SaveDir); File.WriteAllText(SavePathBlocked, JsonSerializer.Serialize(new List<int>(_blocked), new JsonSerializerOptions { WriteIndented = true })); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] failed saving "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SavePathBlocked); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } } private void SaveSync() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown try { Directory.CreateDirectory(SaveDir); string contents = JsonSerializer.Serialize(new SaveFile { Objects = _records }, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(SavePath, contents); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] failed saving "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SavePath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } } private void RegisterRecord(Entity e, bool indestructible, int territoryIndex, Entity heart, ulong bySteamId, int paidItem = 0, int paidAmount = 0, int rot = 0, bool respawnOnDestroy = false, bool playerBreakable = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0079: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0120: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_014e: Unknown result type (might be due to invalid IL or missing references) if (!e.TryGetComponent<TilePosition>(out TilePosition component)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(65, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.GetPrefabGuid().GetPrefabName()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" has no TilePosition; not persisted (session-only)."); } log.LogWarning(val); return; } SpawnRecord spawnRecord = new SpawnRecord { PrefabGuid = e.GetPrefabGuid()._Value, TileX = component.Tile.x, TileY = component.Tile.y, Indestructible = indestructible, TerritoryIndex = territoryIndex, SpawnedBySteamId = bySteamId, SpawnedAtUtc = DateTime.UtcNow.ToString("u"), PaidCostItem = paidItem, PaidCostAmount = paidAmount, Rot = (rot & 3), RespawnOnDestroy = respawnOnDestroy, PlayerBreakable = playerBreakable }; if (e.TryGetComponent<Translation>(out Translation component2)) { spawnRecord.PosX = component2.Value.x; spawnRecord.PosY = component2.Value.y; spawnRecord.PosZ = component2.Value.z; } if (heart.Exists() && heart.TryGetComponent<TilePosition>(out TilePosition component3)) { spawnRecord.HasHeart = true; spawnRecord.HeartTileX = component3.Tile.x; spawnRecord.HeartTileY = component3.Tile.y; } _records.Add(spawnRecord); SaveSync(); } private LiveIndex BuildLiveIndex() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_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_0039: 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_0045: 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_0050: 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_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_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_0077: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a6: 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_00b7: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) LiveIndex liveIndex = new LiveIndex(); EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<TilePosition>(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)66); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); NativeArray<Entity> val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5.TryGetComponent<PrefabGUID>(out PrefabGUID component) && val5.TryGetComponent<TilePosition>(out TilePosition component2)) { liveIndex.ByTile[(component._Value, component2.Tile.x, component2.Tile.y)] = val5; if (!liveIndex.ByGuid.TryGetValue(component._Value, out var value)) { value = (liveIndex.ByGuid[component._Value] = new List<Entity>()); } value.Add(val5); } } return liveIndex; } finally { val4.Dispose(); } } private (Entity Entity, SpawnRecord Record) NearestSpawnedRecord(float3 pos, float maxDist) { //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_000d: 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_004f: 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_0053: 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_00e1: 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_006c: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (_records.Count == 0) { return (Entity.Null, null); } LiveIndex liveIndex = BuildLiveIndex(); float num = maxDist * maxDist; Entity item = Entity.Null; SpawnRecord item2 = null; foreach (SpawnRecord record in _records) { Entity val = liveIndex.Resolve(record); if (!(val == Entity.Null) && val.TryGetComponent<Translation>(out Translation component)) { float num2 = component.Value.x - pos.x; float num3 = component.Value.y - pos.y; float num4 = component.Value.z - pos.z; float num5 = num2 * num2 + num3 * num3 + num4 * num4; if (num5 < num) { num = num5; item = val; item2 = record; } } } return (item, item2); } public void ReapplySpawned() { //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0171: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00ca: 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) if (_records.Count == 0) { return; } LiveIndex liveIndex = BuildLiveIndex(); bool value = Settings.ObjectSpawn_PurgeOrphansOnBoot.Value; int num = 0; int num2 = 0; int num3 = 0; bool flag = false; foreach (SpawnRecord item in new List<SpawnRecord>(_records)) { Entity val = liveIndex.Resolve(item); if (val == Entity.Null) { num3++; continue; } if (item.PosX == 0f && item.PosY == 0f && item.PosZ == 0f && val.TryGetComponent<Translation>(out Translation component)) { item.PosX = component.Value.x; item.PosY = component.Value.y; item.PosZ = component.Value.z; flag = true; } if (value && item.HasHeart && !HeartExistsByTile(item.HeartTileX, item.HeartTileY)) { DestroySpawned(val); _records.Remove(item); num2++; flag = true; continue; } if (item.Indestructible) { val.AddOrSet<Immortal>(new Immortal { IsImmortal = true }); if (val.Has<CastleDecayAndRegen>()) { val.With<CastleDecayAndRegen>((EntityExtensions.RefAction<CastleDecayAndRegen>)delegate(ref CastleDecayAndRegen d) { d.CanDieFromDecay = false; }); } else { val.AddOrSet<CastleDecayAndRegen>(new CastleDecayAndRegen { CanDieFromDecay = false }); } } num++; } if (flag) { SaveSync(); } ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(123, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel SPAWN] re-applied "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" object(s); "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" orphan(s) purged (castle gone); "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" not resolved this boot (KEPT — may be streaming in)."); } log.LogInfo(val2); } public void StartRespawnLoop() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (!Settings.ObjectSpawn_RespawnEnabled.Value) { return; } if (!Tick.IsRunning) { Core.Log.LogWarning((object)"[Uriel SPAWN] auto-respawn loop NOT started (tick driver unavailable)."); return; } int num = Math.Max(5, Settings.ObjectSpawn_RespawnPollSeconds.Value); Tick.RunRepeating(num * 60, RespawnTick); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] auto-respawn loop started (~"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s cadence)."); } log.LogInfo(val); } private void RespawnTick() { //IL_007d: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown if (!Settings.ObjectSpawn_RespawnEnabled.Value) { return; } bool flag = false; foreach (SpawnRecord record in _records) { if (record.RespawnOnDestroy) { flag = true; break; } } if (!flag) { return; } LiveIndex liveIndex = BuildLiveIndex(); int num = 0; foreach (SpawnRecord item in new List<SpawnRecord>(_records)) { if (item.RespawnOnDestroy && !(liveIndex.Resolve(item) != Entity.Null) && item.HasHeart && HeartExistsByTile(item.HeartTileX, item.HeartTileY) && TryRespawnRecord(item)) { num++; } } if (num > 0) { ManualLogSource log = Core.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] auto-respawned "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" destroyed object(s)."); } log.LogInfo(val); } } private bool TryRespawnRecord(SpawnRecord r) { //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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0061: 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_0081: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_00c2: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { float3 val = default(float3); ((float3)(ref val))..ctor(r.PosX, r.PosY, r.PosZ); if (((float3)(ref val)).Equals(default(float3))) { return false; } if (!TryResolvePlot(val, out var heart, out var territoryIndex)) { return false; } NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = Core.PrefabCollectionSystem._PrefabLookupMap.GuidToEntityMap; Entity val2 = default(Entity); if (!guidToEntityMap.TryGetValue(new PrefabGUID(r.PrefabGuid), ref val2) || !val2.Exists()) { return false; } string adoptNote; Entity val3 = ExecuteSpawn(val2, val, r.Rot, r.Indestructible, heart, out adoptNote, r.PlayerBreakable); if (val3 == Entity.Null) { return false; } if (val3.TryGetComponent<TilePosition>(out TilePosition component)) { r.TileX = component.Tile.x; r.TileY = component.Tile.y; } r.TerritoryIndex = territoryIndex; SaveSync(); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(33, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Uriel SPAWN] respawned "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(EntityExtensions.GetPrefabName(new PrefabGUID(r.PrefabGuid))); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" at ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(val.x, "F1"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(val.y, "F1"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(val.z, "F1"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")."); } log.LogInfo(val4); return true; } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Uriel SPAWN] respawn of "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(EntityExtensions.GetPrefabName(new PrefabGUID(r.PrefabGuid))); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } log2.LogWarning(val5); return false; } } private bool TryResolvePlot(float3 pos, out Entity heart, out int territoryIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) heart = Entity.Null; territoryIndex = GetTerritoryIndex(pos); if (territoryIndex < 0) { return false; } heart = GetHeartForTerritory(territoryIndex); return heart.Exists(); } private static int2 ConvertPosToBlockCoord(float3 pos) { //IL_0000: 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_004c: Unknown result type (might be due to invalid IL or missing references) int num = (int)math.floor(pos.x * 2f) + 6400; int num2 = (int)math.floor(pos.z * 2f) + 6400; return new int2((int)math.floor((float)num / 10f), (int)math.floor((float)num2 / 10f)); } private int GetTerritoryIndex(float3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) int2 val = ConvertPosToBlockCoord(pos); EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<CastleTerritory>(), (AccessMode)1)); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions((EntityQueryOptions)66); EntityManager entityManager = Core.EntityManager; EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); NativeArray<Entity> val5 = ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val5.Length; i++) { Entity val6 = val5[i]; if (!val6.TryGetComponent<CastleTerritory>(out CastleTerritory component)) { continue; } entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<CastleTerritoryBlocks>(val6)) { continue; } entityManager = Core.EntityManager; DynamicBuffer<CastleTerritoryBlocks> buffer = ((EntityManager)(ref entityManager)).GetBuffer<CastleTerritoryBlocks>(val6, false); for (int j = 0; j < buffer.Length; j++) { CastleTerritoryBlocks val7 = buffer[j]; if (((int2)(ref val7.BlockCoordinate)).Equals(val)) { return component.CastleTerritoryIndex; } } } } finally { val5.Dispose(); } return -1; } private Entity GetHeartForTerritory(int territoryIndex) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (territoryIndex < 0) { return Entity.Null; } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<CastleHeart>(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)66); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); NativeArray<Entity> val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { Entity val5 = val4[i]; if (val5.TryGetComponent<CastleHeart>(out CastleHeart component) && component.CastleTerritoryEntity.TryGetComponent<CastleTerritory>(out CastleTerritory component2) && component2.CastleTerritoryIndex == territoryIndex) { return val5; } } } finally { val4.Dispose(); } return Entity.Null; } private static bool OwnsHeart(Entity character, Entity heart) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!heart.TryGetComponent<Team>(out Team component)) { return false; } if (!character.TryGetComponent<Team>(out Team component2)) { return false; } return component2.Value == component.Value; } private static bool HeartExistsByTile(int x, int y) { //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_0014: 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_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_0031: 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_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_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_0050: 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_005a: 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_0072: 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_0081: 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) EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<CastleHeart>(), (AccessMode)1)); val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<TilePosition>(), (AccessMode)1)); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)66); EntityManager entityManager = Core.EntityManager; EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); NativeArray<Entity> val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { for (int i = 0; i < val4.Length; i++) { if (val4[i].TryGetComponent<TilePosition>(out TilePosition component) && component.Tile.x == x && component.Tile.y == y) { return true; } } } finally { val4.Dispose(); } return false; } private bool CheckPlacement(Entity character, bool isAdmin, float3 pos, string verb, out Entity heart, out int territory, out string error) { //IL_0005: 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_002d: Unknown result type (might be due to invalid IL or missing references) error = null; if (!TryResolvePlot(pos, out heart, out territory)) { error = "Objects can only be " + verb + " inside a castle plot — stand/aim inside a castle."; return false; } if (!isAdmin && !OwnsHeart(character, heart)) { error = "You can only " + verb.Replace("placed", "place").Replace("moved", "move") + " objects in your own castle plot."; return false; } return true; } private void EnsureCatalog() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00c9: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_010f: 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_011d: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) if (_placeable != null) { return; } List<CatalogEntry> list = new List<CatalogEntry>(); HashSet<int> hashSet = new HashSet<int>(); HashSet<int> hashSet2 = new HashSet<int>(); int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; bool value = Settings.ObjectSpawn_IncludeCastleBuildables.Value; NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = Core.PrefabCollectionSystem._PrefabLookupMap.GuidToEntityMap; Enumerator<string, PrefabGUID> enumerator = Core.PrefabCollectionSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); Entity val = default(Entity); while (enumerator.MoveNext()) { KeyValuePair<string, PrefabGUID> current = enumerator.Current; num6++; string name = current.Key.ToString(); if (IsDebugPrefab(name)) { num2++; } else if (_blocked.Contains(current.Value._Value)) { num3++; } else { if (!guidToEntityMap.TryGetValue(current.Value, ref val) || !val.Exists()) { continue; } if (IsSpawnChainController(val)) { num++; } else if (IsNonObject(name, val)) { num4++; } else if (!value && val.Has<BlueprintData>()) { num5++; } else if (IsPlaceableObject(val)) { list.Add(new CatalogEntry(name, current.Value, SafeToken(Humanize(name)), Categorize(name, val))); hashSet.Add(current.Value._Value); if (IsDiscoverable(val)) { hashSet2.Add(current.Value._Value); } } } } list.Sort((CatalogEntry a, CatalogEntry b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); _placeable = list; _placeableGuids = hashSet; _discoverableGuids = hashSet2; _byGuid = new Dictionary<int, CatalogEntry>(list.Count); foreach (CatalogEntry item in list) { _byGuid[item.Guid._Value] = item; } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(169, 8, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Uriel SPAWN] object catalog built: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_placeable.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" placeable objects "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_discoverableGuids.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" discoverable by destruction; "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" chains, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" units/NPCs, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num5); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" castle-buildables, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" debug, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" blocked skipped) of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num6); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" spawnables."); } log.LogInfo(val2); } private static bool IsNonObject(string name, Entity prefab) { //IL_0024: 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) string[] nonObjectPrefixes = NonObjectPrefixes; foreach (string value in nonObjectPrefixes) { if (name.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { return true; } } if (!prefab.Has<Movement>()) { return prefab.Has<VBloodConsumeSource>(); } return true; } private bool IsRealPlaceableObject(int guid) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_006a: 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) PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(guid); NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = Core.PrefabCollectionSystem._PrefabLookupMap.GuidToEntityMap; Entity val2 = default(Entity); if (!guidToEntityMap.TryGetValue(val, ref val2) || !val2.Exists()) { return false; } string prefabName = val.GetPrefabName(); if (IsDebugPrefab(prefabName)) { return false; } if (IsSpawnChainController(val2)) { return false; } if (IsNonObject(prefabName, val2)) { return false; } if (!Settings.ObjectSpawn_IncludeCastleBuildables.Value && val2.Has<BlueprintData>()) { return false; } return IsPlaceableObject(val2); } private void PruneStaleUnlocks(ulong steamId) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown int num = Core.PlayerUnlock.PruneUnlocked(steamId, IsRealPlaceableObject); if (num > 0) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(81, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] pruned "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stale non-object unlock(s) (characters/V Bloods/etc.) for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } } private static bool IsDiscoverable(Entity prefab) { //IL_0000: 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_0014: 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_001e: 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) if (!prefab.Has<Health>()) { return false; } if (prefab.Has<BlueprintData>()) { return false; } if (prefab.TryGetComponent<Immortal>(out Immortal component) && component.IsImmortal) { return false; } if (prefab.TryGetComponent<HealthConstants>(out HealthConstants component2)) { return component2.DestroyOnDeath; } return false; } public bool IsPlaceableGuid(int guid) { EnsureCatalog(); return _placeableGuids.Contains(guid); } public bool IsDiscoverableGuid(int guid) { EnsureCatalog(); return _discoverableGuids.Contains(guid); } private static bool IsDiscoveryMode() { return string.Equals(Settings.ObjectSpawn_PlayerAccessMode.Value?.Trim(), "Discovery", StringComparison.OrdinalIgnoreCase); } private static string NonDestructibleMode() { return Settings.ObjectSpawn_NonDestructibleUnlock.Value?.Trim().ToLowerInvariant() ?? "off"; } private static bool IsVBlood(Entity e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return e.Has<VBloodConsumeSource>(); } public void HandleKill(Entity killer, Entity died) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0073: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) if (!TracksKills) { return; } ulong steamId = killer.GetSteamId(); if (steamId == 0L) { return; } int value = died.GetPrefabGuid()._Value; if (value == 0) { return; } if (Settings.ObjectSpawn_BossUnlocksEnabled.Value && _bossUnlocks.TryGetValue(value, out var value2)) { GrantBossObjects(killer, steamId, value, value2); } string text = NonDestructibleMode(); if ((text == "finalboss" || text == "allbosses") && IsVBlood(died)) { HandleBossCompletion(killer, steamId, value, text); } int value3 = Settings.ObjectSpawn_DiscoveryChancePercent.Value; if (value3 > 0 && IsDiscoverableGuid(value) && !Core.PlayerUnlock.IsUnlocked(steamId, value) && _rng.Next(100) < value3 && Core.PlayerUnlock.Unlock(steamId, value)) { string prefabName = EntityExtensions.GetPrefabName(new PrefabGUID(value)); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" discovered "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prefabName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); if (Core.PlayerUnlock.WantsNotify(steamId, Settings.ObjectSpawn_DiscoveryNotify.Value)) { Notify(killer, $"Uriel: you can now build {prefabName}! Use '.uriel spawn {prefabName}'."); } if (text == "collection" && IsDiscoverableComplete(steamId)) { GrantIndestructibles(killer, steamId, "collecting everything"); } } } private void GrantBossObjects(Entity killer, ulong steamId, int vbloodGuid, List<int> objects) { //IL_0044: 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_0060: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (int @object in objects) { if (Core.PlayerUnlock.Unlock(steamId, @object)) { num++; } } if (num != 0) { string prefabName = EntityExtensions.GetPrefabName(new PrefabGUID(vbloodGuid)); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unlocked "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" object(s) from defeating "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prefabName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); if (Core.PlayerUnlock.WantsNotify(steamId, Settings.ObjectSpawn_DiscoveryNotify.Value)) { Notify(killer, $"Uriel: defeating {prefabName} unlocked {num} new object(s) to build!"); } } } private void HandleBossCompletion(Entity killer, ulong steamId, int vbloodGuid, string mode) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (mode == "finalboss") { if (vbloodGuid == -327335305) { GrantIndestructibles(killer, steamId, "defeating Dracula"); } return; } EnsureBossRoster(); if (!_bossRoster.Contains(vbloodGuid)) { return; } Core.PlayerUnlock.RecordBossDefeat(steamId, vbloodGuid); foreach (int item in _bossRoster) { if (!Core.PlayerUnlock.HasDefeatedBoss(steamId, item)) { return; } } GrantIndestructibles(killer, steamId, "defeating every V-blood"); } private bool IsDiscoverableComplete(ulong steamId) { EnsureCatalog(); foreach (int discoverableGuid in _discoverableGuids) { if (!Core.PlayerUnlock.IsUnlocked(steamId, discoverableGuid)) { return false; } } return true; } private void GrantIndestructibles(Entity killer, ulong steamId, string reason) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) EnsureCatalog(); int num = 0; foreach (int placeableGuid in _placeableGuids) { if (!_discoverableGuids.Contains(placeableGuid) && Core.PlayerUnlock.Unlock(steamId, placeableGuid)) { num++; } } if (num != 0) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(64, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unlocked "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" non-destructible object(s) via "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); if (Core.PlayerUnlock.WantsNotify(steamId, Settings.ObjectSpawn_DiscoveryNotify.Value)) { Notify(killer, $"Uriel: {reason} unlocked all {num} remaining (non-destructible) objects to build!"); } } } private void EnsureBossRoster() { //IL_0014: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_0077: 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_008e: 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) if (_bossRoster != null) { return; } HashSet<int> hashSet = new HashSet<int>(); NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = Core.PrefabCollectionSystem._PrefabLookupMap.GuidToEntityMap; Enumerator<string, PrefabGUID> enumerator = Core.PrefabCollectionSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); Entity entity = default(Entity); while (enumerator.MoveNext()) { KeyValuePair<string, PrefabGUID> current = enumerator.Current; string text = current.Key.ToString(); if (text.StartsWith("CHAR_", StringComparison.OrdinalIgnoreCase) && text.IndexOf("VBlood", StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("GateBoss", StringComparison.OrdinalIgnoreCase) < 0 && guidToEntityMap.TryGetValue(current.Value, ref entity) && entity.Exists() && entity.Has<VBloodConsumeSource>()) { hashSet.Add(current.Value._Value); } } _bossRoster = hashSet; ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(66, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] V-blood roster for AllBosses unlock: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_bossRoster.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" main boss(es)."); } log.LogInfo(val); } public bool GrantAll(ulong steamId, string mode, out string message) { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown EnsureCatalog(); mode = (mode ?? "all").Trim().ToLowerInvariant(); List<int> list = new List<int>(); string text; switch (mode) { case "all": list.AddRange(_placeableGuids); text = "all"; break; case "destructible": case "discoverable": list.AddRange(_discoverableGuids); text = "destructible"; break; case "indestructible": case "nondestructible": case "non-destructible": foreach (int placeableGuid in _placeableGuids) { if (!_discoverableGuids.Contains(placeableGuid)) { list.Add(placeableGuid); } } text = "non-destructible"; break; default: message = "Mode must be: all | destructible | indestructible."; return false; } int num = 0; foreach (int item in list) { if (Core.PlayerUnlock.Unlock(steamId, item)) { num++; } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] grantall "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ulong>(steamId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" new of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); message = $"Granted {text} objects to {steamId}: {num} newly unlocked ({list.Count} in that set)."; return true; } private bool TryResolveAnyPrefab(string input, out int guid, out string name, out string error) { //IL_0042: 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_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_00c2: 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) guid = 0; name = null; error = null; if (string.IsNullOrWhiteSpace(input)) { error = "Give a V-blood name or GUID."; return false; } input = input.Trim(); if (int.TryParse(input, out var result)) { guid = result; name = EntityExtensions.GetPrefabName(new PrefabGUID(result)); return true; } PrefabGUID val = default(PrefabGUID); bool flag = false; List<(string, int)> list = new List<(string, int)>(); Enumerator<string, PrefabGUID> enumerator = Core.PrefabCollectionSystem.SpawnableNameToPrefabGuidDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair<string, PrefabGUID> current = enumerator.Current; string text = current.Key.ToString(); if (string.Equals(text, input, StringComparison.OrdinalIgn