Decompiled source of Uriel v0.19.0
BepInEx/plugins/Uriel.dll
Decompiled a week 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.19.0.0")] [assembly: AssemblyInformationalVersion("0.19.0+47f1964947395f94341b3d5decbaedb9e82465fd")] [assembly: AssemblyProduct("Uriel")] [assembly: AssemblyTitle("Uriel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.19.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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 ObjectConditionsService ObjectConditions { 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027f: 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(); ObjectConditions = new ObjectConditionsService(); ObjectConditions.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); } try { ObjectSpawn.StartOrphanSweepLoop(); } catch (Exception ex3) { ManualLogSource log5 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Uriel SPAWN] orphan sweep start failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex3); } log5.LogWarning(val3); } PublicStorage = new PublicStorageService(); PublicStorage.Load(); try { PublicStorage.ReapplyAll(); } catch (Exception ex4) { ManualLogSource log6 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Uriel SHARE] re-apply failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex4); } log6.LogWarning(val3); } IsReady = true; ManualLogSource log7 = 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."); } log7.LogInfo(val2); } catch (Exception ex5) { ManualLogSource log8 = 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>(ex5); } log8.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 unsafe 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*)(&component.CharacterName))/*cast due to .constrained prefix*/).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.19.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.19.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.19.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.19.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 ObjectConditionsService { internal sealed class Cond { public int? MaxPerPlot { get; set; } public int? CostItem { get; set; } public int? CostAmount { get; set; } public bool? PermitIndestructible { get; set; } public bool? PermitRespawn { get; set; } public bool IsEmpty { get { if (!MaxPerPlot.HasValue && !CostItem.HasValue && !CostAmount.HasValue && !PermitIndestructible.HasValue) { return !PermitRespawn.HasValue; } return false; } } } internal readonly struct Effective { public readonly int MaxPerPlot; public readonly bool CostSpecified; public readonly int CostItem; public readonly int CostAmount; public readonly bool PermitIndestructible; public readonly bool PermitRespawn; public Effective(int max, bool costSpec, int costItem, int costAmt, bool permitInd, bool permitResp) { MaxPerPlot = max; CostSpecified = costSpec; CostItem = costItem; CostAmount = costAmt; PermitIndestructible = permitInd; PermitRespawn = permitResp; } } private sealed class SaveFile { public int SchemaVersion { get; set; } = 1; public Cond Global { get; set; } = new Cond(); public Dictionary<string, Cond> Objects { get; set; } = new Dictionary<string, Cond>(); } private readonly Cond _global = new Cond(); private readonly Dictionary<int, Cond> _byGuid = new Dictionary<int, Cond>(); private static string SaveDir => Path.Combine(Paths.ConfigPath, "Uriel"); private static string SavePath => Path.Combine(SaveDir, "object_conditions.json"); public bool HasAnyConditions { get { if (_byGuid.Count <= 0) { return !_global.IsEmpty; } return true; } } public void Load() { //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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 == null) { return; } CopyInto(saveFile.Global ?? new Cond(), _global); _byGuid.Clear(); if (saveFile.Objects != null) { foreach (KeyValuePair<string, Cond> @object in saveFile.Objects) { if (int.TryParse(@object.Key, out var result)) { Cond value = @object.Value; if (value != null && !value.IsEmpty) { _byGuid[result] = value; } } } } if (_byGuid.Count > 0 || !_global.IsEmpty) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Uriel SPAWN] loaded object conditions: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_byGuid.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" per-object, global "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_global.IsEmpty ? "unset" : "set"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } 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 SaveSync() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown try { Directory.CreateDirectory(SaveDir); SaveFile saveFile = new SaveFile { Global = _global }; foreach (KeyValuePair<int, Cond> item in _byGuid) { if (!item.Value.IsEmpty) { saveFile.Objects[item.Key.ToString()] = item.Value; } } File.WriteAllText(SavePath, JsonSerializer.Serialize(saveFile, 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>(SavePath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } } private static void CopyInto(Cond src, Cond dst) { dst.MaxPerPlot = src.MaxPerPlot; dst.CostItem = src.CostItem; dst.CostAmount = src.CostAmount; dst.PermitIndestructible = src.PermitIndestructible; dst.PermitRespawn = src.PermitRespawn; } public Effective Resolve(int guid) { _byGuid.TryGetValue(guid, out var value); int max = value?.MaxPerPlot ?? _global.MaxPerPlot.GetValueOrDefault(); Cond obj = ((value?.CostItem).HasValue ? value : (_global.CostItem.HasValue ? _global : null)); bool costSpec = obj != null; int valueOrDefault = (obj?.CostItem).GetValueOrDefault(); int valueOrDefault2 = (obj?.CostAmount).GetValueOrDefault(); bool permitInd = value?.PermitIndestructible ?? _global.PermitIndestructible ?? true; bool permitResp = value?.PermitRespawn ?? _global.PermitRespawn ?? true; return new Effective(max, costSpec, valueOrDefault, valueOrDefault2, permitInd, permitResp); } private Cond LayerFor(int? guid, bool create) { if (!guid.HasValue) { return _global; } if (_byGuid.TryGetValue(guid.Value, out var value)) { return value; } if (!create) { return null; } return _byGuid[guid.Value] = new Cond(); } public void SetMax(int? guid, int? max) { LayerFor(guid, create: true).MaxPerPlot = ((max.HasValue && max.GetValueOrDefault() > 0) ? max : ((int?)null)); Prune(guid); SaveSync(); } public void SetCost(int? guid, int? item, int amount) { Cond cond = LayerFor(guid, create: true); if ((!item.HasValue || item.GetValueOrDefault() == 0) ? true : false) { cond.CostItem = null; cond.CostAmount = null; } else { cond.CostItem = item; cond.CostAmount = Math.Max(0, amount); } Prune(guid); SaveSync(); } public void SetPermitIndestructible(int? guid, bool? permit) { LayerFor(guid, create: true).PermitIndestructible = permit; Prune(guid); SaveSync(); } public void SetPermitRespawn(int? guid, bool? permit) { LayerFor(guid, create: true).PermitRespawn = permit; Prune(guid); SaveSync(); } public void Clear(int? guid) { if (!guid.HasValue) { CopyInto(new Cond(), _global); } else { _byGuid.Remove(guid.Value); } SaveSync(); } private void Prune(int? guid) { if (guid.HasValue && _byGuid.TryGetValue(guid.Value, out var value) && value.IsEmpty) { _byGuid.Remove(guid.Value); } } public string DescribeLayer(int? guid, string label) { Cond cond = LayerFor(guid, create: false); if (cond == null || cond.IsEmpty) { return label + ": no conditions set (uses defaults — unlimited, server cost config, indestructible/respawn allowed)."; } return label + ": " + Render(cond); } private static string Render(Cond c) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); int? maxPerPlot = c.MaxPerPlot; if (maxPerPlot.HasValue) { int valueOrDefault = maxPerPlot.GetValueOrDefault(); list.Add($"max {valueOrDefault}/plot"); } maxPerPlot = c.CostItem; if (maxPerPlot.HasValue) { int valueOrDefault2 = maxPerPlot.GetValueOrDefault(); list.Add((valueOrDefault2 == 0) ? "free" : $"cost {c.CostAmount.GetValueOrDefault()}x {EntityExtensions.GetPrefabName(new PrefabGUID(valueOrDefault2))}"); } bool? permitIndestructible = c.PermitIndestructible; if (permitIndestructible.HasValue) { bool valueOrDefault3 = permitIndestructible == true; list.Add("indestructible=" + (valueOrDefault3 ? "allowed" : "denied")); } permitIndestructible = c.PermitRespawn; if (permitIndestructible.HasValue) { bool valueOrDefault4 = permitIndestructible == true; list.Add("respawn=" + (valueOrDefault4 ? "allowed" : "denied")); } if (list.Count != 0) { return string.Join(", ", list); } return "(none)"; } public string DescribeAll() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(8, 1, stringBuilder2); handler.AppendLiteral("Global: "); handler.AppendFormatted(_global.IsEmpty ? "(unset)" : Render(_global)); stringBuilder3.Append(ref handler); if (_byGuid.Count == 0) { stringBuilder.Append("\nNo per-object conditions set."); return stringBuilder.ToString(); } stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; handler = new StringBuilder.AppendInterpolatedStringHandler(15, 1, stringBuilder2); handler.AppendLiteral("\nPer-object ("); handler.AppendFormatted(_byGuid.Count); handler.AppendLiteral("):"); stringBuilder4.Append(ref handler); foreach (KeyValuePair<int, Cond> item in _byGuid) { string text = $"\n {EntityExtensions.GetPrefabName(new PrefabGUID(item.Key))} ({item.Key}): {Render(item.Value)}"; if (stringBuilder.Length + text.Length > 460) { stringBuilder.Append("\n ...(more — edit object_conditions.json to see all)"); break; } stringBuilder.Append(text); } return stringBuilder.ToString(); } } 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<Entity> _liveSpawns = new HashSet<Entity>(); private readonly HashSet<int> _blocked = new HashSet<int>(); private readonly Dictionary<int, List<int>> _bossUnlocks = new Dictionary<int, List<int>>(); private const float HerePlacementForward = 1.5f; private List<CatalogEntry> _placeable; private HashSet<int> _placeableGuids; private HashSet<int> _discoverableGuids; private Dictionary<int, CatalogEntry> _byGuid; private static readonly string[] NonObjectPrefixes = new string[8] { "CHAR_", "AB_", "GM_", "Liquid_", "Summon", "USB_", "PrefabVariant", "MicroPOI" }; private static readonly string[] InvisibleMarkerFragments = new string[2] { "InvisibleObject", "IdleInteractionLocation" }; private static bool _dropInInvUsable = true; 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 const float OverlapHeightBand = 2.5f; 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_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_0064: 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_0075: 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_0086: 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_00f0: 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_0028: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_003a: 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_0136: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) _liveSpawns.Add(e); 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: Entity.Null, Record: 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 (Entity: item, Record: item2); } public void ReapplySpawned() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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; int num4 = 0; bool flag = false; foreach (SpawnRecord item in new List<SpawnRecord>(_records)) { if (!IsTileModelObject(item.PrefabGuid)) { _records.Remove(item); num4++; flag = true; continue; } 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; } _liveSpawns.Add(val); 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(155, 4, 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>(num4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" now-blocked record(s) dropped; "); ((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 static float3 InFrontOf(Entity character, float3 feet) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (character.TryGetComponent<Rotation>(out Rotation component)) { float3 val = math.mul(component.Value, new float3(0f, 0f, 1f)); val.y = 0f; if (math.lengthsq(val) > 0.0001f) { val = math.normalize(val); return new float3(feet.x + val.x * 1.5f, feet.y, feet.z + val.z * 1.5f); } } return feet; } private static int2 ConvertPosToTile(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_0030: Unknown result type (might be due to invalid IL or missing references) return new int2((int)math.floor(pos.x * 2f) + 6400, (int)math.floor(pos.z * 2f) + 6400); } 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 CastleClaimedAndAlive(Entity heart) { //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_003b: 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_001a: 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_0030: Unknown result type (might be due to invalid IL or missing references) if (!heart.Exists()) { return false; } if (heart.TryGetComponent<CastleHeart>(out CastleHeart component) && component.FuelEndTime - Core.ServerGameManager.ServerTime <= 0.0 && component.FuelQuantity <= 0) { return false; } if (heart.TryGetComponent<UserOwner>(out UserOwner component2) && !((NetworkedEntity)(ref component2.Owner)).GetEntityOnServer().Exists()) { return false; } return true; } 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_0029: 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_0051: 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 (!CastleClaimedAndAlive(heart)) { error = "That castle plot has been abandoned or is decaying — objects can't be " + verb + " there."; 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_0049: 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_0059: 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_0069: 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; } } nonObjectPrefixes = InvisibleMarkerFragments; foreach (string value2 in nonObjectPrefixes) { if (name.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } if (!prefab.Has<Movement>() && !prefab.Has<VBloodConsumeSource>() && !prefab.Has<MicroPOIInstance>() && !prefab.Has<CastleRoofOrnaments>()) { return HasDropInInventoryOnSpawn(prefab); } return true; } private static bool HasDropInInventoryOnSpawn(Entity prefab) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!_dropInInvUsable) { return false; } try { return prefab.Has<DropInInventoryOnSpawn>(); } catch (Exception ex) { _dropInInvUsable = false; Core.Log.LogWarning((object)("[Uriel SPAWN] DropInInventoryOnSpawn check unavailable (" + ex.Message + "); container crash-filter disabled this session (catalog still builds).")); return false; } } private bool IsRealPlaceableObject(int