Decompiled source of RaidForge v2.2.0
RaidForge.dll
Decompiled a month 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.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Text; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Gameplay.Clan; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Scripting; using RaidForge.Config; using RaidForge.Core; using RaidForge.Data; using RaidForge.Services; using RaidForge.Systems; using RaidForge.Utils; using Stunlock.Core; using Stunlock.Network; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("RaidForge")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Allows for flexible control over raid mechanics.")] [assembly: AssemblyFileVersion("0.1.10.0")] [assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e")] [assembly: AssemblyProduct("RaidForge")] [assembly: AssemblyTitle("RaidForge")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.10.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [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 RaidForge { [BepInPlugin("raidforge", "RaidForge", "v2.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private Harmony _harmony; private ModUpdater _updaterComponent; private static ConfigFile _raidScheduleConfigFile; private static ConfigFile _golemSettingsConfigFile; private static ConfigFile _offlineProtectionConfigFile; private static ConfigFile _raidInterferenceConfigFile; private static ConfigFile _troubleshootingConfigFile; private static int _initializationAttempts = 0; private const int MAX_INITIALIZATION_ATTEMPTS = 120; private static float _firstInitAttemptTimestamp = 0f; private const float MAX_INIT_WAIT_SECONDS = 600f; private static bool _firstAttemptTimestampSet = false; public static Plugin Instance { get; private set; } public static ManualLogSource BepInLogger { get; private set; } public static bool SystemsInitialized { get; private set; } = false; public static bool ServerHasJustBooted { get; private set; } = true; public static bool IsAutoRaidCurrentlyActive => RaidSchedulingSystem.IsAutoRaidActive; public static List<RaidScheduleEntry> GetSchedule() { return (RaidConfig.Schedule == null) ? new List<RaidScheduleEntry>() : new List<RaidScheduleEntry>(RaidConfig.Schedule); } public static void NotifyPlayerHasConnectedThisSession() { if (ServerHasJustBooted) { LoggingHelper.Info("[Plugin] First active player connection this session. 'ServerHasJustBooted' flag set to false."); ServerHasJustBooted = false; } } public override void Load() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown Instance = this; BepInLogger = ((BasePlugin)this).Log; ServerHasJustBooted = true; LoggingHelper.Initialize(BepInLogger); LoggingHelper.Info("RaidForge Plugin starting to load (v2.2.1)..."); string text = Path.Combine(Paths.ConfigPath, "RaidForge"); Directory.CreateDirectory(text); _troubleshootingConfigFile = new ConfigFile(Path.Combine(text, "Troubleshooting.cfg"), true); _raidScheduleConfigFile = new ConfigFile(Path.Combine(text, "RaidScheduleAndGeneral.cfg"), true); _golemSettingsConfigFile = new ConfigFile(Path.Combine(text, "GolemSettings.cfg"), true); _offlineProtectionConfigFile = new ConfigFile(Path.Combine(text, "OfflineProtection.cfg"), true); _raidInterferenceConfigFile = new ConfigFile(Path.Combine(text, "RaidInterference.cfg"), true); try { TroubleshootingConfig.Initialize(_troubleshootingConfigFile); RaidConfig.Initialize(_raidScheduleConfigFile, BepInLogger); GolemAutomationConfig.Initialize(_golemSettingsConfigFile, BepInLogger); OfflineRaidProtectionConfig.Initialize(_offlineProtectionConfigFile); RaidInterferenceConfig.Initialize(_raidInterferenceConfigFile, BepInLogger); RaidConfig.ParseSchedule(); GolemAutomationConfig.ReloadAndParseAll(); LoggingHelper.Debug("Core configurations initialized and parsed."); } catch (Exception ex) { LoggingHelper.Error("Failed to initialize or parse configurations during Load.", ex); } _troubleshootingConfigFile.SettingChanged += OnTroubleshootingConfigSettingChanged; _raidScheduleConfigFile.SettingChanged += OnRaidScheduleConfigSettingChanged; _golemSettingsConfigFile.SettingChanged += OnGolemSettingsConfigSettingChanged; _offlineProtectionConfigFile.SettingChanged += OnOfflineProtectionConfigSettingChanged; _raidInterferenceConfigFile.SettingChanged += OnRaidInterferenceConfigSettingChanged; try { _harmony = new Harmony("raidforge"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); LoggingHelper.Info("Harmony patches applied."); } catch (Exception ex2) { LoggingHelper.Error("CRITICAL: Failed to apply Harmony patches.", ex2); } OfflineGraceService.Initialize(); RaidInterferenceService.Initialize(BepInLogger); LoggingHelper.Debug("Basic services (OfflineGrace, RaidInterference) Initialize() called."); try { CommandRegistry.RegisterAll(); LoggingHelper.Debug("Commands registered."); } catch (Exception ex3) { LoggingHelper.Error("CRITICAL: Failed to register commands.", ex3); } if (!ClassInjector.IsTypeRegisteredInIl2Cpp<ModUpdater>()) { ClassInjector.RegisterTypeInIl2Cpp<ModUpdater>(); } _updaterComponent = ((BasePlugin)this).AddComponent<ModUpdater>(); if ((Object)(object)_updaterComponent == (Object)null) { LoggingHelper.Error("Failed to add ModUpdater component! Core logic will not run."); } else { LoggingHelper.Debug("ModUpdater component added."); } LoggingHelper.Info("RaidForge Plugin load sequence complete. Waiting for world to be ready to initialize core systems..."); } public static void AttemptInitializeCoreSystems() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) if (SystemsInitialized && _firstAttemptTimestampSet) { return; } if (!VWorld.IsServerWorldReady()) { LoggingHelper.Debug("[Plugin] AttemptInitializeCoreSystems: VWorld not ready yet. Will retry."); return; } if (!_firstAttemptTimestampSet) { _firstInitAttemptTimestamp = Time.realtimeSinceStartup; _firstAttemptTimestampSet = true; LoggingHelper.Info($"[Plugin] VWorld is ready. First attempt to initialize core systems at game time {_firstInitAttemptTimestamp:F2}s."); } _initializationAttempts++; LoggingHelper.Info($"[Plugin] Attempting core system initialization (Attempt: {_initializationAttempts})"); EntityManager entityManager = VWorld.EntityManager; if (entityManager == default(EntityManager)) { LoggingHelper.Error("[Plugin] AttemptInitializeCoreSystems: EntityManager is default. Cannot initialize further."); return; } LoggingHelper.Info("[Plugin] Initializing ownership caches..."); int num = OwnershipCacheService.InitializeHeartOwnershipCache(entityManager); int num2 = OwnershipCacheService.InitializeUserToClanCache(entityManager); LoggingHelper.Info("[Plugin] Loading persisted offline states from OfflineGraceService..."); OfflineGraceService.LoadOfflineStatesFromDisk(entityManager); bool flag = OwnershipCacheService.IsInitialScanAttemptedAndConsideredPopulated(); bool flag2 = false; if (flag && (_initializationAttempts > 1 || num > 0 || num2 > 0)) { LoggingHelper.Info("[Plugin] Ownership cache and persisted offline states loading considered complete."); flag2 = true; } else if (Time.realtimeSinceStartup - _firstInitAttemptTimestamp > 600f) { LoggingHelper.Warning($"[Plugin] Max initialization time ({600f}s) reached. Proceeding. Cache status: {flag}"); flag2 = true; } else if (_initializationAttempts >= 120) { LoggingHelper.Warning($"[Plugin] Max initialization attempts ({_initializationAttempts}/{120}) reached. Proceeding. Cache status: {flag}"); flag2 = true; } if (flag2) { SystemsInitialized = true; LoggingHelper.Info("[Plugin] Base data systems (Caches, Persisted Data Load) INITIALIZED."); LoggingHelper.Info("[Plugin] Performing follow-up initial system setups..."); LoggingHelper.Info("[Plugin] Calling OfflineGraceService.EstablishInitialGracePeriodsOnBoot..."); OfflineGraceService.EstablishInitialGracePeriodsOnBoot(entityManager); RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true); GolemAutomationSystem.CheckAutomation(); LoggingHelper.Info("[Plugin] All core systems and initial checks are now complete. Plugin fully active."); } else { LoggingHelper.Info($"[Plugin] Initialization attempt {_initializationAttempts}: Core data services not yet considered fully ready. Will retry."); } } private void OnTroubleshootingConfigSettingChanged(object sender, SettingChangedEventArgs e) { LoggingHelper.Info($"Troubleshooting.cfg: [{e.ChangedSetting.Definition.Section}] {e.ChangedSetting.Definition.Key} = {e.ChangedSetting.BoxedValue}."); if (e.ChangedSetting.Definition.Key == ((ConfigEntryBase)TroubleshootingConfig.EnableVerboseLogging).Definition.Key) { LoggingHelper.Info("Verbose logging has been " + (TroubleshootingConfig.EnableVerboseLogging.Value ? "ENABLED" : "DISABLED") + "."); } } private void OnRaidScheduleConfigSettingChanged(object sender, SettingChangedEventArgs e) { LoggingHelper.Info("RaidScheduleAndGeneral.cfg changed. Reparsing raid schedule..."); RaidConfig.ParseSchedule(); if (SystemsInitialized) { RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true); } else { LoggingHelper.Warning("Raid schedule changed, but systems not initialized. Check skipped."); } } private void OnGolemSettingsConfigSettingChanged(object sender, SettingChangedEventArgs e) { LoggingHelper.Info("GolemSettings.cfg changed. Reparsing golem settings..."); GolemAutomationConfig.ReloadAndParseAll(); if (SystemsInitialized) { GolemAutomationSystem.ResetAutomationState(); GolemAutomationSystem.CheckAutomation(); } else { LoggingHelper.Warning("Golem settings changed, but systems not initialized. Check skipped."); } } private void OnOfflineProtectionConfigSettingChanged(object sender, SettingChangedEventArgs e) { LoggingHelper.Info($"OfflineProtection.cfg changed: [{e.ChangedSetting.Definition.Section}] {e.ChangedSetting.Definition.Key} = {e.ChangedSetting.BoxedValue}."); } private void OnRaidInterferenceConfigSettingChanged(object sender, SettingChangedEventArgs e) { LoggingHelper.Info($"RaidInterference.cfg changed: [{e.ChangedSetting.Definition.Section}] {e.ChangedSetting.Definition.Key} = {e.ChangedSetting.BoxedValue}."); } public static void ReloadAllConfigsAndRefreshSystems() { LoggingHelper.Info("ReloadAllConfigsAndRefreshSystems called by command..."); try { if (_troubleshootingConfigFile != null) { _troubleshootingConfigFile.Reload(); } if (_raidScheduleConfigFile != null) { _raidScheduleConfigFile.Reload(); } if (_golemSettingsConfigFile != null) { _golemSettingsConfigFile.Reload(); } if (_offlineProtectionConfigFile != null) { _offlineProtectionConfigFile.Reload(); } if (_raidInterferenceConfigFile != null) { _raidInterferenceConfigFile.Reload(); } RaidConfig.ParseSchedule(); GolemAutomationConfig.ReloadAndParseAll(); LoggingHelper.Info("All configurations reloaded and reparsed."); if (SystemsInitialized) { LoggingHelper.Info("Refreshing systems due to config reload..."); RaidSchedulingSystem.CheckScheduleAndToggleRaids(forceCheck: true); GolemAutomationSystem.ResetAutomationState(); GolemAutomationSystem.CheckAutomation(); } else { LoggingHelper.Warning("Configs reloaded, but systems not initialized. System refresh skipped."); } } catch (Exception ex) { LoggingHelper.Error("Error during ReloadAllConfigsAndRefreshSystems: ", ex); } } public static void TriggerReloadFromCommand() { ReloadAllConfigsAndRefreshSystems(); } public static void TriggerGolemAutomationResetFromCommand() { if (SystemsInitialized) { GolemAutomationSystem.ResetAutomationState(); LoggingHelper.Info("Golem automation state reset by command."); } } public override bool Unload() { LoggingHelper.Info("Unloading RaidForge Plugin..."); try { if (_troubleshootingConfigFile != null) { _troubleshootingConfigFile.SettingChanged -= OnTroubleshootingConfigSettingChanged; } if (_raidScheduleConfigFile != null) { _raidScheduleConfigFile.SettingChanged -= OnRaidScheduleConfigSettingChanged; } if (_golemSettingsConfigFile != null) { _golemSettingsConfigFile.SettingChanged -= OnGolemSettingsConfigSettingChanged; } if (_offlineProtectionConfigFile != null) { _offlineProtectionConfigFile.SettingChanged -= OnOfflineProtectionConfigSettingChanged; } if (_raidInterferenceConfigFile != null) { _raidInterferenceConfigFile.SettingChanged -= OnRaidInterferenceConfigSettingChanged; } if ((Object)(object)_updaterComponent != (Object)null) { Object.Destroy((Object)(object)_updaterComponent); _updaterComponent = null; } try { CommandRegistry.UnregisterAssembly(); } catch { } RaidInterferenceService.StopService(); OfflineGraceService.Initialize(); OwnershipCacheService.ClearAllCaches(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } SystemsInitialized = false; ServerHasJustBooted = true; _initializationAttempts = 0; _firstAttemptTimestampSet = false; LoggingHelper.Info("RaidForge Plugin (v2.2.1) unloaded successfully!"); } catch (Exception ex) { LoggingHelper.Error("Error during RaidForge plugin unload.", ex); return false; } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "RaidForge"; public const string PLUGIN_NAME = "RaidForge"; public const string PLUGIN_VERSION = "2.0.0"; } } namespace RaidForge.Utils { public static class ChatColors { public const string Error = "#FF4136"; public const string Success = "#2ECC40"; public const string Info = "#FFFFFF"; public const string Warning = "#F00534"; public const string Highlight = "#7FDBFF"; public const string Accent = "#FFDC00"; public const string Muted = "#AAAAAA"; public static string Format(string message, string colorHex) { if (string.IsNullOrEmpty(colorHex)) { return message; } return $"<color={colorHex}>{message}</color>"; } public static string ErrorText(string message) { return Format(message, "#FF4136"); } public static string SuccessText(string message) { return Format(message, "#2ECC40"); } public static string InfoText(string message) { return Format(message, "#FFFFFF"); } public static string WarningText(string message) { return Format(message, "#F00534"); } public static string HighlightText(string message) { return Format(message, "#7FDBFF"); } public static string AccentText(string message) { return Format(message, "#FFDC00"); } public static string MutedText(string message) { return Format(message, "#AAAAAA"); } } public static class ClanUtilities { public static bool TryGetClanEntityByNetworkId(EntityManager em, NetworkId clanNetworkId, out Entity foundClanEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) foundClanEntity = Entity.Null; NetworkId val = default(NetworkId); if (((NetworkId)(ref clanNetworkId)).Equals(val)) { LoggingHelper.Debug("[ClanUtilities] TryGetClanEntityByNetworkId: provided clanNetworkId is default. Cannot find clan."); return false; } EntityQuery val2 = default(EntityQuery); NativeArray<Entity> val3 = default(NativeArray<Entity>); try { val2 = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadOnly<ClanTeam>(), ComponentType.ReadOnly<NetworkId>() }); val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); Enumerator<Entity> enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; val = ((EntityManager)(ref em)).GetComponentData<NetworkId>(current); if (((NetworkId)(ref val)).Equals(clanNetworkId)) { foundClanEntity = current; return true; } } } catch (Exception value) { LoggingHelper.Error($"[ClanUtilities] Exception in TryGetClanEntityByNetworkId for NetID {clanNetworkId}: {value}"); } finally { if (val3.IsCreated) { val3.Dispose(); } if (val2 != default(EntityQuery)) { ((EntityQuery)(ref val2)).Dispose(); } } LoggingHelper.Debug($"[ClanUtilities] ClanEntity with NetworkId {clanNetworkId} not found."); return false; } } internal static class EntityExtensions { public delegate void WithRefHandler<T>(ref T item) where T : struct; private static EntityManager Em => VWorld.EntityManager; public static bool Exists(this Entity entity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) int result; if (entity != Entity.Null) { EntityManager em = Em; result = (((EntityManager)(ref em)).Exists(entity) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } public static bool Has<T>(this Entity entity) where T : struct { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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_001c: Unknown result type (might be due to invalid IL or missing references) if (entity == Entity.Null) { return false; } EntityManager em = Em; return ((EntityManager)(ref em)).HasComponent<T>(entity); } public static T Read<T>(this Entity entity) where T : struct { //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_0009: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; return ((EntityManager)(ref em)).GetComponentData<T>(entity); } public static bool TryRead<T>(this Entity entity, out T component) where T : struct { //IL_0001: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists() && entity.Has<T>()) { EntityManager em = Em; component = ((EntityManager)(ref em)).GetComponentData<T>(entity); return true; } component = default(T); return false; } public static void Write<T>(this Entity entity, T data) where T : struct { //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_0009: Unknown result type (might be due to invalid IL or missing references) EntityManager em = Em; ((EntityManager)(ref em)).SetComponentData<T>(entity, data); } public static void Add<T>(this Entity entity) where T : struct { //IL_0001: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists() && !entity.Has<T>()) { EntityManager em = Em; ((EntityManager)(ref em)).AddComponent<T>(entity); } } public static void With<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists() && entity.Has<T>()) { T item = entity.Read<T>(); action(ref item); entity.Write(item); } } public static string Explore(this Entity entity) { //IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005e: 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) if (!entity.Exists()) { return "Entity does not exist."; } StringBuilder val = new StringBuilder(); try { if (VWorld.IsServerWorldReady()) { EntityDebuggingUtility.DumpEntity(VWorld.Server, entity, true, val); return ((Object)val).ToString(); } return $"Cannot explore entity {entity}: Server world not ready."; } catch (Exception ex) { return $"Error exploring entity {entity}: {ex.Message}"; } } } public static class LoggingHelper { private static ManualLogSource _logger; private static bool IsVerboseLoggingGloballyEnabled => TroubleshootingConfig.EnableVerboseLogging?.Value ?? false; public static void Initialize(ManualLogSource logger) { _logger = logger; if (_logger == null) { Console.WriteLine("[RaidForge.LoggingHelper] CRITICAL: Logger passed to Initialize is null!"); } } public static void Info(string message) { ManualLogSource logger = _logger; if (logger != null) { logger.LogInfo((object)message); } } public static void Warning(string message, Exception ex = null) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (_logger == null) { return; } if (ex != null) { ManualLogSource logger = _logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | Exception: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString()); } logger.LogWarning(val); } else { _logger.LogWarning((object)message); } } public static void Error(string message, Exception ex = null) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (_logger == null) { Console.WriteLine("[RaidForge.LoggingHelper ERROR (logger not init)]: " + message + " " + ((ex != null) ? ex.ToString() : "")); } else if (ex != null) { ManualLogSource logger = _logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | Exception: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString()); } logger.LogError(val); } else { _logger.LogError((object)message); } } public static void Debug(string message) { if (IsVerboseLoggingGloballyEnabled && _logger != null) { _logger.LogDebug((object)message); } } } public static class UserHelper { public static bool FindUserEntity(EntityManager em, string identifier, out Entity userEntity, out User userData, out string characterName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) userEntity = Entity.Null; userData = default(User); characterName = string.Empty; if (string.IsNullOrWhiteSpace(identifier)) { return false; } EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { ulong result; bool flag = ulong.TryParse(identifier, out result); Enumerator<Entity> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!((EntityManager)(ref em)).Exists(current) || !((EntityManager)(ref em)).HasComponent<User>(current)) { continue; } User componentData = ((EntityManager)(ref em)).GetComponentData<User>(current); if (flag) { if (componentData.PlatformId != result) { continue; } userEntity = current; userData = componentData; characterName = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString(); return true; } string text = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString(); if (!text.Equals(identifier, StringComparison.OrdinalIgnoreCase)) { continue; } userEntity = current; userData = componentData; characterName = text; return true; } } finally { if (val2.IsCreated) { val2.Dispose(); } } return false; } public static bool TryGetPlayerOwnerFromSource(EntityManager em, Entity sourceEntity, out Entity playerCharacterEntity, out Entity userEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_002f: 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_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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) playerCharacterEntity = Entity.Null; userEntity = Entity.Null; if (!((EntityManager)(ref em)).Exists(sourceEntity)) { return false; } if (((EntityManager)(ref em)).HasComponent<PlayerCharacter>(sourceEntity)) { playerCharacterEntity = sourceEntity; PlayerCharacter val = default(PlayerCharacter); if (((EntityManager)(ref em)).TryGetComponentData<PlayerCharacter>(playerCharacterEntity, ref val)) { userEntity = val.UserEntity; return ((EntityManager)(ref em)).Exists(userEntity); } return false; } if (((EntityManager)(ref em)).HasComponent<EntityOwner>(sourceEntity)) { Entity owner = ((EntityManager)(ref em)).GetComponentData<EntityOwner>(sourceEntity).Owner; if (((EntityManager)(ref em)).Exists(owner) && ((EntityManager)(ref em)).HasComponent<PlayerCharacter>(owner)) { playerCharacterEntity = owner; PlayerCharacter val2 = default(PlayerCharacter); if (((EntityManager)(ref em)).TryGetComponentData<PlayerCharacter>(playerCharacterEntity, ref val2)) { userEntity = val2.UserEntity; return ((EntityManager)(ref em)).Exists(userEntity); } return false; } } return false; } public static bool IsAnyClanMemberOnline(EntityManager em, Entity clanEntity, Entity excludingUserEntity = default(Entity)) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0033: 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_0035: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) if (!((EntityManager)(ref em)).Exists(clanEntity) || !((EntityManager)(ref em)).HasComponent<ClanTeam>(clanEntity)) { return false; } NativeList<Entity> val = default(NativeList<Entity>); val..ctor(AllocatorHandle.op_Implicit((Allocator)2)); try { TeamUtility.GetClanMembers(em, clanEntity, val); Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if ((!(excludingUserEntity != default(Entity)) || !(current == excludingUserEntity)) && ((EntityManager)(ref em)).Exists(current) && ((EntityManager)(ref em)).HasComponent<User>(current)) { User componentData = ((EntityManager)(ref em)).GetComponentData<User>(current); if (componentData.IsConnected) { return true; } } } } catch (Exception ex) { LoggingHelper.Error($"[UserHelper] Exception during IsAnyClanMemberOnline for clan {clanEntity}", ex); } finally { if (val.IsCreated) { val.Dispose(); } } return false; } } internal static class VWorld { private static World _serverWorld; private static EntityManager _entityManager; public static World Server { get { //IL_006d: 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_0052: Unknown result type (might be due to invalid IL or missing references) if (_serverWorld != null && _serverWorld.IsCreated) { return _serverWorld; } _serverWorld = GetWorld("Server"); if (_serverWorld == null || !_serverWorld.IsCreated) { _entityManager = default(EntityManager); LoggingHelper.Error("VWorld: Server world is not available or not created. Subsequent calls may fail."); return null; } _entityManager = _serverWorld.EntityManager; return _serverWorld; } } public static EntityManager EntityManager { get { //IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if ((!(_entityManager == default(EntityManager)) && (_serverWorld == null || !_serverWorld.IsCreated || !(_entityManager != _serverWorld.EntityManager))) || Server != null) { } if (_entityManager == default(EntityManager)) { LoggingHelper.Error("VWorld: EntityManager is not available. Ensure Server world is initialized."); } return _entityManager; } } private static World GetWorld(string name) { if (World.s_AllWorlds == null) { return null; } Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == name && current.IsCreated) { return current; } } return null; } public static bool IsServerWorldReady() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return Server != null && Server.IsCreated && EntityManager != default(EntityManager); } public static bool ZDateTime(out TimeZonedDateTime dt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) dt = default(TimeZonedDateTime); return true; } public static bool GameBalanceSettings(out ServerGameBalanceSettings settings, Func<ServerGameBalanceSettings, ServerGameBalanceSettings> modify = null) { //IL_0002: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_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_007b: 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_0095: 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_009e: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) settings = default(ServerGameBalanceSettings); try { if (!IsServerWorldReady()) { LoggingHelper.Error("VWorld.GameBalanceSettings: Server world or EntityManager not ready."); return false; } EntityManager entityManager = EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServerGameBalanceSettings>() }); if (((EntityQuery)(ref val)).IsEmptyIgnoreFilter) { LoggingHelper.Error("VWorld.GameBalanceSettings: Could not find ServerGameBalanceSettings entity."); return false; } Entity singletonEntity = ((EntityQuery)(ref val)).GetSingletonEntity(); ServerGameBalanceSettings componentData = ((EntityManager)(ref entityManager)).GetComponentData<ServerGameBalanceSettings>(singletonEntity); if (modify == null) { settings = componentData; return true; } ServerGameBalanceSettings val2 = modify(componentData); ((EntityManager)(ref entityManager)).SetComponentData<ServerGameBalanceSettings>(singletonEntity, val2); settings = val2; return true; } catch (Exception ex) { LoggingHelper.Error("VWorld.GameBalanceSettings: Exception while accessing/modifying ServerGameBalanceSettings.", ex); return false; } } } } namespace RaidForge.Systems { public static class GolemAutomationSystem { private static int _lastDayCheckedForSchedule = -1; private static SiegeWeaponHealth? _lastHealthSuccessfullySet = null; public static bool CheckAutomation() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) if (!VWorld.IsServerWorldReady()) { ConfigEntry<bool> enableVerboseLogging = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging != null && enableVerboseLogging.Value) { LoggingHelper.Debug("GolemAutomationSystem: Server world not ready. Golem automation check skipped."); } return false; } SiegeWeaponHealth? val = null; string value = "None"; string text = GolemAutomationConfig.ManualSiegeWeaponHealthOverride?.Value; if (!string.IsNullOrEmpty(text)) { if (Enum.TryParse<SiegeWeaponHealth>(text, ignoreCase: true, out SiegeWeaponHealth result)) { val = result; value = "Manual Level Override ('" + text + "')"; LoggingHelper.Debug("[GolemAutomationSystem] Manual SiegeWeaponHealth level override active: " + text + "."); } else { LoggingHelper.Warning("[GolemAutomationSystem] Invalid ManualSiegeWeaponHealthOverride value in config: '" + text + "'. It will be ignored."); } } if (!val.HasValue) { ConfigEntry<bool> enableDayBasedAutomation = GolemAutomationConfig.EnableDayBasedAutomation; if (enableDayBasedAutomation != null && enableDayBasedAutomation.Value) { if (!GolemAutomationConfig.ParsedStartDate.HasValue) { ConfigEntry<bool> enableVerboseLogging2 = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging2 != null && enableVerboseLogging2.Value) { LoggingHelper.Debug("GolemAutomationSystem: Day-based automation enabled, but ServerStartDateForAutomation not parsed. Schedule skipped."); } } else { DateTime now = DateTime.Now; DateTime value2 = GolemAutomationConfig.ParsedStartDate.Value; int num = (int)Math.Floor((now - value2).TotalDays); if (num < 0) { num = 0; } LoggingHelper.Debug($"[GolemAutomationSystem] Evaluating day-based schedule for Day {num}. Last schedule check day: {_lastDayCheckedForSchedule}."); val = GolemAutomationConfig.GetScheduledHealthForDay(num); if (val.HasValue) { value = $"Day-Based Schedule (Day {num} -> Level {val.Value})"; LoggingHelper.Debug($"[GolemAutomationSystem] Day-based schedule determined target: {val.Value}."); } else { LoggingHelper.Debug($"[GolemAutomationSystem] No day-based schedule entry found for Day {num}."); } _lastDayCheckedForSchedule = num; } goto IL_02d4; } } if (!val.HasValue) { LoggingHelper.Debug("[GolemAutomationSystem] No manual override set and day-based automation is disabled."); } goto IL_02d4; IL_02d4: if (val.HasValue) { if (!_lastHealthSuccessfullySet.HasValue || _lastHealthSuccessfullySet.Value != val.Value) { LoggingHelper.Info($"[GolemAutomationSystem] Attempting to set Golem Health to {val.Value} (Source: {value})."); if (SiegeWeaponSystem.SetSiegeWeaponHealth(val.Value)) { _lastHealthSuccessfullySet = val.Value; LoggingHelper.Info($"[GolemAutomationSystem] Successfully set Golem Health to {val.Value}."); } else { LoggingHelper.Error($"[GolemAutomationSystem] FAILED to set Golem Health to {val.Value}."); } } else { LoggingHelper.Debug($"[GolemAutomationSystem] Golem Health {val.Value} (Source: {value}) is already what was last successfully set. No change needed."); } } else { LoggingHelper.Debug("[GolemAutomationSystem] No golem health change determined by overrides or active day-based schedule for today."); } return true; } public static void ResetAutomationState() { _lastDayCheckedForSchedule = -1; _lastHealthSuccessfullySet = null; LoggingHelper.Info("GolemAutomationSystem: State (last check day and last applied health) has been reset."); } } public static class RaidSchedulingSystem { private static bool _initialCheckPerformed; public static bool IsAutoRaidActive { get; private set; } public static bool CheckScheduleAndToggleRaids(bool forceCheck = false) { bool flag = forceCheck || !_initialCheckPerformed; if (!VWorld.IsServerWorldReady()) { if (flag) { ConfigEntry<bool> enableVerboseLogging = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging != null && enableVerboseLogging.Value) { LoggingHelper.Warning("RaidSchedulingSystem: Server world not ready yet for schedule check."); } } return false; } DateTime now = DateTime.Now; List<RaidScheduleEntry> schedule = RaidConfig.Schedule; if (schedule == null) { LoggingHelper.Error("RaidSchedulingSystem: Check FAILED - RaidConfig.Schedule is null. Raids will be treated as OFF by default."); if (IsAutoRaidActive) { LoggingHelper.Info("RaidSchedulingSystem: Turning raids OFF due to null schedule."); RaidToggleSystem.DisableRaids(); IsAutoRaidActive = false; } return true; } bool flag2 = false; string value = "No matching schedule entry found."; foreach (RaidScheduleEntry item in schedule) { if (item.Day == now.DayOfWeek) { DateTime dateTime = now.Date + item.StartTime; DateTime dateTime2 = ((!(item.EndTime == TimeSpan.Zero) || !item.SpansMidnight) ? (item.SpansMidnight ? (now.Date.AddDays(1.0) + item.EndTime) : (now.Date + item.EndTime)) : now.Date.AddDays(1.0)); if (now >= dateTime && now < dateTime2) { flag2 = true; string value2 = ((item.EndTime == TimeSpan.Zero && item.SpansMidnight) ? "24:00" : item.EndTime.ToString("hh\\:mm")); value = $"Active window: {item.Day} {item.StartTime:hh\\:mm} - {value2}"; break; } } else if (item.SpansMidnight && item.Day == (DayOfWeek)((int)(now.DayOfWeek - 1 + 7) % 7)) { DateTime dateTime = now.Date.AddDays(-1.0) + item.StartTime; DateTime dateTime2 = now.Date + item.EndTime; if (now >= dateTime && now < dateTime2) { flag2 = true; value = $"Active window (spanned from yesterday): {item.Day} {item.StartTime:hh\\:mm} - {item.EndTime:hh\\:mm}"; break; } } } bool flag3 = flag2 != IsAutoRaidActive; if (flag3) { goto IL_0391; } if (flag) { ConfigEntry<bool> enableVerboseLogging2 = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging2 != null && enableVerboseLogging2.Value) { goto IL_0391; } } goto IL_0416; IL_0391: LoggingHelper.Info($"RaidSchedulingSystem: Schedule check - Should be {(flag2 ? "ON" : "OFF")}. Reason: {value}. Current state: {IsAutoRaidActive}. Change needed: {flag3}"); goto IL_0416; IL_0416: if (flag3) { LoggingHelper.Info(flag2 ? "RaidSchedulingSystem: Enabling raids (Scheduled)..." : "RaidSchedulingSystem: Disabling raids (Scheduled)..."); if (flag2 ? RaidToggleSystem.EnableRaids() : RaidToggleSystem.DisableRaids()) { IsAutoRaidActive = flag2; LoggingHelper.Info($"RaidSchedulingSystem: Raid state successfully changed to: {IsAutoRaidActive}"); } else { LoggingHelper.Error($"RaidSchedulingSystem: FAILED to set CastleDamageMode. Raid state remains {IsAutoRaidActive}."); } } else if (flag) { ConfigEntry<bool> enableVerboseLogging3 = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging3 != null && enableVerboseLogging3.Value) { LoggingHelper.Info($"RaidSchedulingSystem: Raid state ({IsAutoRaidActive}) matches desired state. No action needed."); } } if (!_initialCheckPerformed && VWorld.IsServerWorldReady()) { _initialCheckPerformed = true; ConfigEntry<bool> enableVerboseLogging4 = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging4 != null && enableVerboseLogging4.Value) { LoggingHelper.Info("RaidSchedulingSystem: Initial raid schedule check performed."); } } return true; } } public static class RaidToggleSystem { public static bool EnableRaids(ManualLogSource loggerContext = null) { return SetCastleDamageMode((CastleDamageMode)1, loggerContext); } public static bool DisableRaids(ManualLogSource loggerContext = null) { return SetCastleDamageMode((CastleDamageMode)2, loggerContext); } private static bool SetCastleDamageMode(CastleDamageMode newMode, ManualLogSource loggerContext = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) try { if (VWorld.GameBalanceSettings(out var _, delegate(ServerGameBalanceSettings settings) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (settings.CastleDamageMode == newMode) { return settings; } settings.CastleDamageMode = newMode; return settings; })) { return true; } return false; } catch (Exception) { return false; } } } public static class SiegeWeaponSystem { public static bool SetSiegeWeaponHealth(SiegeWeaponHealth newValue, ManualLogSource loggerContext = null) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) try { if (VWorld.GameBalanceSettings(out var _, delegate(ServerGameBalanceSettings settings) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (settings.SiegeWeaponHealth == newValue) { return settings; } settings.SiegeWeaponHealth = newValue; return settings; })) { return true; } return false; } catch (Exception) { return false; } } public static SiegeWeaponHealth? GetSiegeWeaponHealth(ManualLogSource loggerContext = null) { //IL_000f: 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) try { if (VWorld.GameBalanceSettings(out var settings)) { return settings.SiegeWeaponHealth; } return null; } catch (Exception) { return null; } } } } namespace RaidForge.Services { public class PersistedOfflineStateEntry { public string PersistentKey { get; set; } public long OfflineStartTimeTicks { get; set; } public string ContextualName { get; set; } } public static class PersistentKeyHelper { public static string GetUserKey(ulong platformId) { return $"user_{platformId}"; } public static string GetClanKey(EntityManager em, Entity clanEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (clanEntity == Entity.Null || !((EntityManager)(ref em)).Exists(clanEntity)) { return null; } if (((EntityManager)(ref em)).HasComponent<NetworkId>(clanEntity)) { NetworkId componentData = ((EntityManager)(ref em)).GetComponentData<NetworkId>(clanEntity); if (!((NetworkId)(ref componentData)).Equals(default(NetworkId))) { string text = ((object)(NetworkId)(ref componentData)).ToString(); return "clan_nid_" + text; } } return null; } } public static class OfflineGraceService { private static Dictionary<string, DateTime> _persistedOfflineStartTimes = new Dictionary<string, DateTime>(); private static Dictionary<string, string> _persistedOfflineEntityNames = new Dictionary<string, string>(); private static HashSet<string> _defaultOrpAtBootKeys = new HashSet<string>(); private static readonly string DataSubfolder = "Data"; private static readonly string OfflineStatesSaveFileName = "RaidForge_OfflineStates.json"; private static bool _dataLoadedFromDisk = false; private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions { WriteIndented = true }; private static readonly object _saveLock = new object(); private static string GetSaveFilePath() { string text = Path.Combine(Paths.ConfigPath, "RaidForge", DataSubfolder); Directory.CreateDirectory(text); return Path.Combine(text, OfflineStatesSaveFileName); } public static void LoadOfflineStatesFromDisk(EntityManager entityManager) { if (_dataLoadedFromDisk) { return; } lock (_saveLock) { string saveFilePath = GetSaveFilePath(); _persistedOfflineStartTimes.Clear(); _persistedOfflineEntityNames.Clear(); _defaultOrpAtBootKeys.Clear(); if (!File.Exists(saveFilePath)) { _dataLoadedFromDisk = true; return; } try { string text = File.ReadAllText(saveFilePath); if (string.IsNullOrWhiteSpace(text)) { _dataLoadedFromDisk = true; return; } List<PersistedOfflineStateEntry> list = JsonSerializer.Deserialize<List<PersistedOfflineStateEntry>>(text); if (list == null || !list.Any()) { _dataLoadedFromDisk = true; return; } foreach (PersistedOfflineStateEntry item in list) { if (!string.IsNullOrEmpty(item.PersistentKey)) { _persistedOfflineStartTimes[item.PersistentKey] = new DateTime(item.OfflineStartTimeTicks, DateTimeKind.Utc); _persistedOfflineEntityNames[item.PersistentKey] = item.ContextualName ?? "UnknownNameFromSave"; } } } catch (Exception) { } _dataLoadedFromDisk = true; } } private static void SaveTimedOfflineStatesToDiskInternal() { if (!Plugin.SystemsInitialized && !_dataLoadedFromDisk) { return; } lock (_saveLock) { string saveFilePath = GetSaveFilePath(); string directoryName = Path.GetDirectoryName(saveFilePath); try { Directory.CreateDirectory(directoryName); List<PersistedOfflineStateEntry> list = new List<PersistedOfflineStateEntry>(); foreach (KeyValuePair<string, DateTime> persistedOfflineStartTime in _persistedOfflineStartTimes) { list.Add(new PersistedOfflineStateEntry { PersistentKey = persistedOfflineStartTime.Key, OfflineStartTimeTicks = persistedOfflineStartTime.Value.Ticks, ContextualName = (_persistedOfflineEntityNames.TryGetValue(persistedOfflineStartTime.Key, out var value) ? value : "NameNotFoundOnSave") }); } string contents = JsonSerializer.Serialize(list, _jsonOptions); File.WriteAllText(saveFilePath, contents); } catch (Exception) { } } } public static void Initialize() { } public static void MarkAsOffline(string persistentKey, DateTime offlineTimeUtc, string contextualName) { if (!string.IsNullOrEmpty(persistentKey)) { _persistedOfflineStartTimes[persistentKey] = offlineTimeUtc; _persistedOfflineEntityNames[persistentKey] = contextualName; _defaultOrpAtBootKeys.Remove(persistentKey); SaveTimedOfflineStatesToDiskInternal(); } } public static void MarkAsOnline(string persistentKey, string contextualName) { if (!string.IsNullOrEmpty(persistentKey)) { bool flag = _persistedOfflineStartTimes.Remove(persistentKey); _persistedOfflineEntityNames.Remove(persistentKey); bool flag2 = _defaultOrpAtBootKeys.Remove(persistentKey); if ((flag || flag2) && flag) { SaveTimedOfflineStatesToDiskInternal(); } } } public static bool TryGetOfflineStartTime(string persistentKey, out DateTime offlineStartTimeUtc) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) offlineStartTimeUtc = default(DateTime); if (string.IsNullOrEmpty(persistentKey)) { return false; } if (!_dataLoadedFromDisk && Plugin.SystemsInitialized && VWorld.IsServerWorldReady()) { LoadOfflineStatesFromDisk(VWorld.EntityManager); } return _persistedOfflineStartTimes.TryGetValue(persistentKey, out offlineStartTimeUtc); } public static bool IsUnderDefaultBootORP(string persistentKey) { if (string.IsNullOrEmpty(persistentKey)) { return false; } return _defaultOrpAtBootKeys.Contains(persistentKey) && !_persistedOfflineStartTimes.ContainsKey(persistentKey); } public static void HandleUserDisconnected(EntityManager entityManager, Entity disconnectedUserEntity, bool isFromPersistenceLoadEvent_IGNORED) { //IL_0037: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.SystemsInitialized) { return; } ConfigEntry<bool> enableOfflineRaidProtection = OfflineRaidProtectionConfig.EnableOfflineRaidProtection; if (enableOfflineRaidProtection == null || !enableOfflineRaidProtection.Value || !((EntityManager)(ref entityManager)).Exists(disconnectedUserEntity) || !((EntityManager)(ref entityManager)).HasComponent<User>(disconnectedUserEntity)) { return; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(disconnectedUserEntity); FixedString64Bytes characterName = componentData.CharacterName; string text = ((object)(FixedString64Bytes)(ref characterName)).ToString(); ulong platformId = componentData.PlatformId; string userKey = PersistentKeyHelper.GetUserKey(platformId); Entity entity = componentData.ClanEntity._Entity; DateTime utcNow = DateTime.UtcNow; if (entity != Entity.Null && ((EntityManager)(ref entityManager)).Exists(entity) && ((EntityManager)(ref entityManager)).HasComponent<ClanTeam>(entity)) { string clanKey = PersistentKeyHelper.GetClanKey(entityManager, entity); if (string.IsNullOrEmpty(clanKey)) { MarkAsOffline(userKey, utcNow, text); } else if (!UserHelper.IsAnyClanMemberOnline(entityManager, entity, disconnectedUserEntity)) { ClanTeam componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<ClanTeam>(entity); string text2 = ((object)(FixedString64Bytes)(ref componentData2.Name)).ToString(); MarkAsOffline(clanKey, utcNow, text2 + " (last online: " + text + ")"); } } else { MarkAsOffline(userKey, utcNow, text); } } public static void HandleClanMemberDeparted(EntityManager entityManager, Entity userWhoLeft, Entity clanThatWasLeft, FixedString64Bytes userWhoLeftCharacterNameFs) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) string text = ((object)(FixedString64Bytes)(ref userWhoLeftCharacterNameFs)).ToString(); if (!Plugin.SystemsInitialized) { return; } ConfigEntry<bool> enableOfflineRaidProtection = OfflineRaidProtectionConfig.EnableOfflineRaidProtection; if (enableOfflineRaidProtection != null && enableOfflineRaidProtection.Value && !(clanThatWasLeft == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(clanThatWasLeft) && ((EntityManager)(ref entityManager)).HasComponent<ClanTeam>(clanThatWasLeft)) { string clanKey = PersistentKeyHelper.GetClanKey(entityManager, clanThatWasLeft); if (!string.IsNullOrEmpty(clanKey) && !UserHelper.IsAnyClanMemberOnline(entityManager, clanThatWasLeft)) { ClanTeam componentData = ((EntityManager)(ref entityManager)).GetComponentData<ClanTeam>(clanThatWasLeft); string text2 = ((object)(FixedString64Bytes)(ref componentData.Name)).ToString(); MarkAsOffline(clanKey, DateTime.UtcNow, text2 + " (after " + text + " departed)"); } } } public static void EstablishInitialGracePeriodsOnBoot(EntityManager entityManager) { //IL_0036: 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_0048: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) if (!_dataLoadedFromDisk || !Plugin.SystemsInitialized) { return; } _defaultOrpAtBootKeys.Clear(); EntityQuery val = default(EntityQuery); NativeArray<Entity> val2 = default(NativeArray<Entity>); int num = 0; EntityQuery val3 = default(EntityQuery); NativeArray<Entity> val4 = default(NativeArray<Entity>); int num2 = 0; try { val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); Enumerator<Entity> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref entityManager)).HasComponent<User>(current)) { User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current); string userKey = PersistentKeyHelper.GetUserKey(componentData.PlatformId); string text = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString(); if (!_persistedOfflineStartTimes.ContainsKey(userKey) && _defaultOrpAtBootKeys.Add(userKey)) { _persistedOfflineEntityNames[userKey] = text + " (Default Boot ORP - User)"; num++; } } } } catch (Exception) { } finally { if (val2.IsCreated) { val2.Dispose(); } } val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ClanTeam>() }); val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); try { Enumerator<Entity> enumerator2 = val4.GetEnumerator(); while (enumerator2.MoveNext()) { Entity current2 = enumerator2.Current; string clanKey = PersistentKeyHelper.GetClanKey(entityManager, current2); if (!string.IsNullOrEmpty(clanKey) && !_persistedOfflineStartTimes.ContainsKey(clanKey) && !UserHelper.IsAnyClanMemberOnline(entityManager, current2) && _defaultOrpAtBootKeys.Add(clanKey)) { ClanTeam componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<ClanTeam>(current2); string text2 = ((object)(FixedString64Bytes)(ref componentData2.Name)).ToString(); _persistedOfflineEntityNames[clanKey] = text2 + " (Default Boot ORP - Clan)"; num2++; } } } catch (Exception) { } finally { if (val4.IsCreated) { val4.Dispose(); } } } } public static class OfflineProtectionService { public static bool AreAllDefendersActuallyOffline(Entity castleHeartEntity, EntityManager entityManager) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: 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_005c: 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_0077: 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_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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: 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_00b9: 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) if (!Plugin.SystemsInitialized) { return false; } if (!((EntityManager)(ref entityManager)).Exists(castleHeartEntity) || !((EntityManager)(ref entityManager)).HasComponent<UserOwner>(castleHeartEntity)) { return false; } Entity entity = ((EntityManager)(ref entityManager)).GetComponentData<UserOwner>(castleHeartEntity).Owner._Entity; if (!((EntityManager)(ref entityManager)).Exists(entity) || !((EntityManager)(ref entityManager)).HasComponent<User>(entity)) { return false; } User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(entity); Entity clanEntity = Entity.Null; OwnershipCacheService.TryGetUserClan(entity, out clanEntity); if (clanEntity != Entity.Null && ((EntityManager)(ref entityManager)).Exists(clanEntity) && ((EntityManager)(ref entityManager)).HasComponent<ClanTeam>(clanEntity)) { bool flag = UserHelper.IsAnyClanMemberOnline(entityManager, clanEntity); return !flag; } return !componentData.IsConnected; } public static bool IsBaseDecaying(Entity castleHeartEntity, EntityManager entityManager) { //IL_0003: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((EntityManager)(ref entityManager)).Exists(castleHeartEntity) || !((EntityManager)(ref entityManager)).HasComponent<CastleHeart>(castleHeartEntity)) { return true; } CastleHeart componentData = ((EntityManager)(ref entityManager)).GetComponentData<CastleHeart>(castleHeartEntity); if (componentData.FuelQuantity <= 0 || ((CastleHeart)(ref componentData)).IsDecaying()) { return true; } return false; } } public static class OwnershipCacheService { private static Dictionary<Entity, Entity> _heartToOwnerUserCache = new Dictionary<Entity, Entity>(); private static bool _isHeartCachePopulatedFromInitialScan = false; private static Dictionary<Entity, Entity> _userToClanCache = new Dictionary<Entity, Entity>(); private static bool _isClanCachePopulatedFromInitialScan = false; public static int InitializeHeartOwnershipCache(EntityManager entityManager) { //IL_0001: 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_000a: 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_0055: Expected O, but got Unknown //IL_005f: 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_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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if (entityManager == default(EntityManager)) { LoggingHelper.Error("[OwnershipCacheService] EntityManager is null during InitializeHeartOwnershipCache. Heart cache NOT initialized."); _isHeartCachePopulatedFromInitialScan = false; return 0; } LoggingHelper.Info("[OwnershipCacheService] Initializing Heart Ownership Cache..."); _heartToOwnerUserCache.Clear(); _isHeartCachePopulatedFromInitialScan = false; EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2] { ComponentType.ReadOnly<CastleHeart>(), ComponentType.ReadOnly<UserOwner>() }); EntityQueryDesc val2 = val; EntityQuery val3 = default(EntityQuery); NativeArray<Entity> val4 = default(NativeArray<Entity>); int num = 0; int num2 = 0; int value = 0; try { val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 }); val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); value = val4.Length; LoggingHelper.Debug($"[OwnershipCacheService] Initial scan found {value} entities with CastleHeart & UserOwner for heart cache."); Enumerator<Entity> enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref entityManager)).Exists(current)) { UserOwner componentData = ((EntityManager)(ref entityManager)).GetComponentData<UserOwner>(current); Entity entity = componentData.Owner._Entity; if (entity != Entity.Null && ((EntityManager)(ref entityManager)).Exists(entity)) { _heartToOwnerUserCache[current] = entity; num++; continue; } num2++; LoggingHelper.Debug($"[OwnershipCacheService] Heart {current} has null or non-existent owner UserEntity {entity}. Not cached."); } } } catch (Exception ex) { LoggingHelper.Error("[OwnershipCacheService] Exception during Heart Ownership Cache initialization.", ex); _isHeartCachePopulatedFromInitialScan = false; return num; } finally { if (val4.IsCreated) { val4.Dispose(); } if (val3 != default(EntityQuery)) { ((EntityQuery)(ref val3)).Dispose(); } } LoggingHelper.Info($"[OwnershipCacheService] Heart Ownership Cache init complete. Cached {num} hearts out of {value} queried. Invalid/Null owners found for: {num2} hearts."); _isHeartCachePopulatedFromInitialScan = true; return num; } public static int InitializeUserToClanCache(EntityManager entityManager) { //IL_0001: 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_000a: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00f9: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (entityManager == default(EntityManager)) { LoggingHelper.Error("[OwnershipCacheService] EntityManager is null during InitializeUserToClanCache. Clan cache NOT initialized."); _isClanCachePopulatedFromInitialScan = false; return 0; } LoggingHelper.Info("[OwnershipCacheService] Initializing User to Clan Cache..."); _userToClanCache.Clear(); _isClanCachePopulatedFromInitialScan = false; EntityQuery val = default(EntityQuery); NativeArray<Entity> val2 = default(NativeArray<Entity>); int num = 0; int value = 0; try { val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() }); val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)3)); value = val2.Length; LoggingHelper.Debug($"[OwnershipCacheService] Found {value} User entities for clan cache."); Enumerator<Entity> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (((EntityManager)(ref entityManager)).Exists(current)) { User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current); _userToClanCache[current] = componentData.ClanEntity._Entity; num++; } } } catch (Exception ex) { LoggingHelper.Error("[OwnershipCacheService] Exception during User to Clan Cache initialization.", ex); _isClanCachePopulatedFromInitialScan = false; return num; } finally { if (val2.IsCreated) { val2.Dispose(); } if (val != default(EntityQuery)) { ((EntityQuery)(ref val)).Dispose(); } } LoggingHelper.Info($"[OwnershipCacheService] User to Clan Cache init complete. Cached {num} users out of {value} queried."); _isClanCachePopulatedFromInitialScan = true; return num; } public static bool IsInitialScanAttemptedAndConsideredPopulated() { return _isHeartCachePopulatedFromInitialScan && _isClanCachePopulatedFromInitialScan; } public static bool UpdateUserClan(Entity userEntity, Entity clanEntity, EntityManager em) { //IL_0001: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) if (em == default(EntityManager)) { LoggingHelper.Warning($"[OwnershipCacheService] UpdateUserClan: EntityManager is default. Cannot update cache for User: {userEntity}."); return false; } if (userEntity == Entity.Null) { LoggingHelper.Warning("[OwnershipCacheService] UpdateUserClan: Attempted to update clan for a Null UserEntity."); return false; } if (!((EntityManager)(ref em)).Exists(userEntity)) { LoggingHelper.Warning($"[OwnershipCacheService] UpdateUserClan: UserEntity {userEntity} does not exist. Cannot update cache."); return false; } if (clanEntity != Entity.Null && !((EntityManager)(ref em)).Exists(clanEntity)) { LoggingHelper.Warning($"[OwnershipCacheService] UpdateUserClan: Attempt to set non-existent Clan {clanEntity} for User {userEntity}. Caching as clanless (Null) instead."); clanEntity = Entity.Null; } bool flag = false; Entity value; bool flag2 = _userToClanCache.TryGetValue(userEntity, out value); string value2 = "UnknownUser"; if (((EntityManager)(ref em)).HasComponent<User>(userEntity)) { try { User componentData = ((EntityManager)(ref em)).GetComponentData<User>(userEntity); value2 = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString(); } catch (Exception ex) { LoggingHelper.Debug($"[OwnershipCacheService] Could not get CharacterName for User {userEntity} in UpdateUserClan: {ex.Message}"); } } string value3 = ((clanEntity == Entity.Null) ? "None (clanless)" : ((object)(Entity)(ref clanEntity)).ToString()); string value4 = ((!flag2) ? "N/A (new to cache)" : ((value == Entity.Null) ? "None (clanless)" : ((object)(Entity)(ref value)).ToString())); if (!flag2) { LoggingHelper.Info($"[OwnershipCacheService] ADDING User {userEntity} ('{value2}') to clan cache. New Clan: {value3}."); _userToClanCache[userEntity] = clanEntity; flag = true; } else if (value != clanEntity) { LoggingHelper.Info($"[OwnershipCacheService] UPDATING Clan for User {userEntity} ('{value2}'). Previous Cached Clan: {value4}, New Clan: {value3}."); _userToClanCache[userEntity] = clanEntity; flag = true; } else { ConfigEntry<bool> enableVerboseLogging = TroubleshootingConfig.EnableVerboseLogging; if (enableVerboseLogging != null && enableVerboseLogging.Value) { LoggingHelper.Debug($"[OwnershipCacheService] User {userEntity} ('{value2}') clan data ({value3}) is already up-to-date in cache. No change made."); } flag = false; } return flag; } public static bool TryGetUserClan(Entity userEntity, out Entity clanEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) clanEntity = Entity.Null; if (userEntity == Entity.Null) { return false; } return _userToClanCache.TryGetValue(userEntity, out clanEntity); } public static bool TryGetHeartOwner(Entity heartEntity, out Entity ownerUserEntity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ownerUserEntity = Entity.Null; if (heartEntity == Entity.Null) { return false; } return _heartToOwnerUserCache.TryGetValue(heartEntity, out ownerUserEntity); } public static void UpdateHeartOwner(Entity heartEntity, Entity ownerUserEntity, EntityManager em) { //IL_0001: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL