Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RaidMaster v1.0.1
RaidMaster.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using RaidMaster.Core; using RaidMaster.Models; using RaidMaster.UI; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RaidMaster")] [assembly: AssemblyConfiguration("release")] [assembly: AssemblyDescription("Game Master live raid director, editor, and zero-restart sync for Valheim")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RaidMaster")] [assembly: AssemblyTitle("RaidMaster")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RaidMaster { [BepInPlugin("com.custom.raidmaster", "RaidMaster", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.custom.raidmaster"; public const string PluginName = "RaidMaster"; public const string PluginVersion = "1.0.1"; private Harmony _harmony; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static ConfigEntry<KeyCode> ToggleGuiKey { get; private set; } public static ConfigEntry<float> UiScale { get; private set; } public static ConfigEntry<bool> VerboseLogging { get; private set; } public static string ConfigDir => Path.Combine(Paths.ConfigPath, "RaidMaster"); public static string RaidsJsonPath => Path.Combine(ConfigDir, "raids.json"); public static string ImportDir => Path.Combine(ConfigDir, "import"); private void Awake() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Directory.CreateDirectory(ConfigDir); Directory.CreateDirectory(ImportDir); ToggleGuiKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1 - Interface", "ToggleGuiKey", (KeyCode)290, "Hotkey to open/close the RaidMaster Game Master GUI (Admins only)."); UiScale = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Interface", "UiScale", 1.25f, "GUI scale multiplier (0.8 to 2.2). Can also be adjusted live with the - / + buttons in the top bar."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Debug", "VerboseLogging", false, "Log detailed raid eligibility checks and spawn timing decisions."); RaidManager.Initialize(); _harmony = new Harmony("com.custom.raidmaster"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ((Component)this).gameObject.AddComponent<RaidMasterUI>(); Log.LogInfo((object)string.Format("{0} v{1} loaded! Press {2} in-game (Admin) to open the Game Master Director.", "RaidMaster", "1.0.1", ToggleGuiKey.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace RaidMaster.Patches { [HarmonyPatch(typeof(ZNet), "Awake")] public static class Patch_ZNet_Awake { private static void Postfix() { RaidNetworkSync.ResetRegistration(); RaidNetworkSync.RegisterRpcs(); } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] public static class Patch_ZNet_PeerInfo { private static void Postfix(ZNet __instance, ZRpc rpc) { if (__instance.IsServer()) { ZNetPeer peer = __instance.GetPeer(rpc); if (peer != null) { RaidNetworkSync.SyncPeerOnJoin(peer); } } } } [HarmonyPatch(typeof(RandEventSystem), "Start")] public static class Patch_RandEventSystem_Start { private static void Postfix() { RaidManager.ApplyToRandEventSystem(); } } [HarmonyPatch(typeof(RandEventSystem), "SetRandomEvent")] public static class Patch_RandEventSystem_SetRandomEvent { private static void Postfix(RandomEvent ev) { if (ev != null) { RaidManager.OnEventActivated(ev.m_name); } else { RaidManager.OnEventDeactivated(); } } } [HarmonyPatch(typeof(RandEventSystem), "ResetRandomEvent")] public static class Patch_RandEventSystem_ResetRandomEvent { private static void Postfix() { RaidManager.OnEventDeactivated(); } } [HarmonyPatch(typeof(RandEventSystem), "UpdateRandomEvent")] public static class Patch_RandEventSystem_UpdateRandomEvent { private static void Prefix(RandEventSystem __instance, float dt) { __instance.m_eventTimer = 0f; RaidManager.TickActiveEventElapsed(dt); } private static void Postfix(RandEventSystem __instance, float dt) { RaidNetworkSync.TickNetworkLoops(dt); RaidManager.TickServerScheduler(__instance, dt); } } [HarmonyPatch(typeof(SpawnSystem), "UpdateSpawnList")] public static class Patch_SpawnSystem_UpdateSpawnList { public static bool IsUpdatingEventSpawners { get; private set; } private static void Prefix(ref List<SpawnData> spawners, bool eventSpawners) { if (!eventSpawners || spawners == null) { return; } IsUpdatingEventSpawners = true; RandEventSystem instance = RandEventSystem.instance; string text = ((instance == null) ? null : instance.GetCurrentRandomEvent()?.m_name) ?? ""; if (string.IsNullOrEmpty(text)) { return; } float activeEventElapsedSeconds = RaidManager.ActiveEventElapsedSeconds; bool flag = false; for (int i = 0; i < spawners.Count; i++) { WaveDefinition waveDefinition = RaidManager.FindWaveMeta(text, spawners[i].m_name); if (waveDefinition != null && (waveDefinition.StartAfterSeconds > 0f || waveDefinition.StopAfterSeconds > 0f)) { flag = true; break; } } if (!flag) { return; } List<SpawnData> list = new List<SpawnData>(spawners.Count); foreach (SpawnData spawner in spawners) { WaveDefinition waveDefinition2 = RaidManager.FindWaveMeta(text, spawner.m_name); if (waveDefinition2 == null || ((!(waveDefinition2.StartAfterSeconds > 0f) || !(activeEventElapsedSeconds < waveDefinition2.StartAfterSeconds)) && (!(waveDefinition2.StopAfterSeconds > 0f) || !(activeEventElapsedSeconds > waveDefinition2.StopAfterSeconds)))) { list.Add(spawner); } } spawners = list; } private static void Finalizer() { IsUpdatingEventSpawners = false; } } [HarmonyPatch(typeof(EffectArea), "IsPointInsideArea")] public static class Patch_EffectArea_SiegeBreaker { private static bool Prefix(Vector3 p, Type type, ref EffectArea __result) { //IL_001e: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!Patch_SpawnSystem_UpdateSpawnList.IsUpdatingEventSpawners) { return true; } SiegeBreakerMode siegeBreaker = RaidManager.Database.Global.SiegeBreaker; if (siegeBreaker == SiegeBreakerMode.Off) { return true; } if ((type & 4) == 0 && (siegeBreaker != SiegeBreakerMode.FullBypass || (type & 0x20) <= 0)) { return true; } if (!RaidManager.ShouldBypassPlayerBaseAt(p)) { return true; } __result = null; return false; } } [HarmonyPatch(typeof(Character), "Awake")] public static class Patch_Character_Awake_Telemetry { private static void Postfix(Character __instance) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (Patch_SpawnSystem_UpdateSpawnList.IsUpdatingEventSpawners && !((Object)(object)__instance == (Object)null) && !__instance.IsPlayer()) { RaidManager.RecordEventSpawn(((Object)((Component)__instance).gameObject).name, ((Component)__instance).transform.position); } } } [HarmonyPatch(typeof(TextInput), "IsVisible")] public static class Patch_TextInput_IsVisible { private static void Postfix(ref bool __result) { if (RaidMasterUI.IsOpen) { __result = true; } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] public static class Patch_PlayerController_TakeInput { private static bool Prefix(ref bool __result) { if (!RaidMasterUI.IsOpen) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "TakeInput")] public static class Patch_Player_TakeInput { private static bool Prefix(ref bool __result) { if (!RaidMasterUI.IsOpen) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] public static class Patch_GameCamera_MouseCapture { private static bool Prefix() { if (!RaidMasterUI.IsOpen) { return true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } } } namespace RaidMaster.UI { public class RaidMasterUI : MonoBehaviour { private Rect _windowRect = new Rect(40f, 40f, 1020f, 680f); private int _activeTab; private readonly string[] _tabNames = new string[4] { "GM Director", "Global & Siege Breaker", "Raid & Wave Editor", "Presets & Import" }; private int _directorSelectedRaidIdx; private int _directorSelectedPlayerIdx; private string _directorSearch = ""; private string _narrativeStartMsg = ""; private string _narrativeEndMsg = ""; private string _narrativeDurationStr = ""; private string _narrativeEnv = ""; private Vector2 _directorListScroll; private int _editorSelectedRaidIdx; private string _editorSearch = ""; private Vector2 _editorListScroll; private Vector2 _editorDetailScroll; private int _pickingWaveIndex = -1; private string _prefabSearch = ""; private Vector2 _prefabScroll; private List<string> _cachedCreaturePrefabs; private string _statusMessage = ""; private float _statusTimer; private GUIStyle _headerStyle; private GUIStyle _boxStyle; private GUIStyle _listButtonStyle; private bool _stylesBuilt; private static readonly string[] AllBiomes = new string[9] { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands", "DeepNorth", "Ocean" }; public static bool IsOpen { get; private set; } = false; private void Update() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_statusTimer > 0f) { _statusTimer -= Time.unscaledDeltaTime; if (_statusTimer <= 0f) { _statusMessage = ""; } } if (Input.GetKeyDown(Plugin.ToggleGuiKey.Value)) { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } if (!RaidNetworkSync.LocalIsAdmin) { ((Character)Player.m_localPlayer).Message((MessageType)1, "RaidMaster: Admin privileges required.", 0, (Sprite)null, false); return; } IsOpen = !IsOpen; if (IsOpen) { if (RaidManager.Database == null || RaidManager.Database.Raids == null || RaidManager.Database.Raids.Count == 0) { RaidManager.LoadFromDiskOrCreateDefaults(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } if (IsOpen && Input.GetKeyDown((KeyCode)27)) { IsOpen = false; } } private void BuildStyles() { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_004e: 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_006d: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0098: Expected O, but got Unknown if (!_stylesBuilt) { _stylesBuilt = true; _headerStyle = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, fontSize = 14 }; _headerStyle.normal.textColor = new Color(1f, 0.84f, 0.45f); _boxStyle = new GUIStyle(GUI.skin.box); _listButtonStyle = new GUIStyle(GUI.skin.button) { alignment = (TextAnchor)3, padding = new RectOffset(8, 6, 4, 4) }; } } private void OnGUI() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { BuildStyles(); float num = Mathf.Clamp(Plugin.UiScale.Value, 0.8f, 2.2f); Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; ((Rect)(ref _windowRect)).width = Mathf.Min(1040f, num2 - 20f); ((Rect)(ref _windowRect)).height = Mathf.Min(680f, num3 - 20f); ((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 10f, Mathf.Max(10f, num2 - ((Rect)(ref _windowRect)).width - 10f)); ((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 10f, Mathf.Max(10f, num3 - ((Rect)(ref _windowRect)).height - 10f)); GUI.backgroundColor = new Color(0.14f, 0.16f, 0.2f, 0.98f); _windowRect = GUI.Window(948271, _windowRect, new WindowFunction(DrawMainWindow), "RaidMaster v1.0.1 — Game Master Raid Console"); GUI.matrix = matrix; } } private void DrawMainWindow(int id) { //IL_0000: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) GUI.backgroundColor = Color.white; GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); DrawTelemetryBar(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); _activeTab = GUILayout.Toolbar(_activeTab, _tabNames, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }); GUILayout.Space(8f); GUI.backgroundColor = new Color(0.25f, 0.72f, 0.35f, 1f); if (GUILayout.Button("Apply & Push Live", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(145f), GUILayout.Height(28f) })) { RaidNetworkSync.PushDatabaseLive(); ShowStatus("Pushed raid configuration LIVE to server & all connected players!"); } GUI.backgroundColor = new Color(0.72f, 0.22f, 0.22f, 1f); if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(30f), GUILayout.Height(28f) })) { IsOpen = false; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(_statusMessage)) { GUI.color = new Color(0.55f, 1f, 0.65f); GUILayout.Label(_statusMessage, Array.Empty<GUILayoutOption>()); GUI.color = Color.white; } GUILayout.Space(6f); switch (_activeTab) { case 0: DrawTabDirector(); break; case 1: DrawTabGlobalSettings(); break; case 2: DrawTabRaidEditor(); break; case 3: DrawTabPresetsAndImport(); break; } GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 24f)); } private void DrawTelemetryBar() { LiveTelemetry latestTelemetry = RaidNetworkSync.LatestTelemetry; GUILayout.BeginHorizontal(_boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label(string.IsNullOrEmpty(latestTelemetry.ActiveEventName) ? "Active Raid: NONE" : $"ACTIVE: {latestTelemetry.ActiveEventName} ({latestTelemetry.ActiveEventElapsed:F0}s / {latestTelemetry.ActiveEventDuration:F0}s)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(280f) }); GUILayout.Label(latestTelemetry.AutoRaidsPaused ? "Auto-Raids: PAUSED" : ((latestTelemetry.CooldownRemainingSeconds > 0f) ? $"Cooldown: {latestTelemetry.CooldownRemainingSeconds / 60f:F1}m" : $"Next Check: {latestTelemetry.NextCheckSeconds / 60f:F1}m"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); GUILayout.Label($"Raids: {RaidManager.Database.Raids.Count}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) }); GUILayout.Label($"Siege Breaker: {RaidManager.Database.Global.SiegeBreaker}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(175f) }); GUILayout.FlexibleSpace(); GUILayout.Label($"UI: {Mathf.RoundToInt(Plugin.UiScale.Value * 100f)}%", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(64f) }); if (GUILayout.Button("-", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) })) { Plugin.UiScale.Value = Mathf.Clamp(Mathf.Round((Plugin.UiScale.Value - 0.1f) * 10f) / 10f, 0.8f, 2.2f); } if (GUILayout.Button("+", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) })) { Plugin.UiScale.Value = Mathf.Clamp(Mathf.Round((Plugin.UiScale.Value + 0.1f) * 10f) / 10f, 0.8f, 2.2f); } GUILayout.EndHorizontal(); } private void DrawTabDirector() { //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) List<RaidDefinition> raids = RaidManager.Database.Raids; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(350f), GUILayout.ExpandHeight(true) }); GUILayout.Label($"Select Raid to Execute ({raids.Count} loaded)", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Filter:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) }); _directorSearch = GUILayout.TextField(_directorSearch, Array.Empty<GUILayoutOption>()); if (!string.IsNullOrEmpty(_directorSearch) && GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) })) { _directorSearch = ""; } GUILayout.EndHorizontal(); if (raids.Count == 0) { GUILayout.Space(12f); GUILayout.Label("No raids loaded in memory.", Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Load 29 Built-In Default Raids", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { RaidManager.ResetToDefaults(); RaidNetworkSync.PushDatabaseLive(); ShowStatus("Loaded 29 built-in default raids!"); } } else { _directorListScroll = GUILayout.BeginScrollView(_directorListScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); for (int i = 0; i < raids.Count; i++) { RaidDefinition raidDefinition = raids[i]; if (string.IsNullOrEmpty(_directorSearch) || raidDefinition.Name.IndexOf(_directorSearch, StringComparison.OrdinalIgnoreCase) >= 0 || (raidDefinition.Category ?? "").IndexOf(_directorSearch, StringComparison.OrdinalIgnoreCase) >= 0) { GUI.backgroundColor = ((i == _directorSelectedRaidIdx) ? new Color(0.95f, 0.65f, 0.2f) : new Color(0.75f, 0.78f, 0.85f)); if (GUILayout.Button("[" + raidDefinition.Category + "] " + raidDefinition.Name, _listButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) })) { _directorSelectedRaidIdx = i; } } } GUI.backgroundColor = Color.white; GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); GUILayout.Label("Live Narrative Execution Controls", _headerStyle, Array.Empty<GUILayoutOption>()); if (raids.Count > 0) { _directorSelectedRaidIdx = Mathf.Clamp(_directorSelectedRaidIdx, 0, raids.Count - 1); RaidDefinition raidDefinition2 = raids[_directorSelectedRaidIdx]; GUILayout.Label($"Selected Raid: {raidDefinition2.Name} ({raidDefinition2.Waves.Count} waves, default {raidDefinition2.Duration}s)", Array.Empty<GUILayoutOption>()); GUILayout.Label("Last Spawn Event: " + RaidManager.LastSpawnSummary, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); List<string> list = new List<string> { "At My Position" }; if (RaidNetworkSync.LatestTelemetry.OnlinePlayers != null) { foreach (string onlinePlayer in RaidNetworkSync.LatestTelemetry.OnlinePlayers) { list.Add("On Player: " + onlinePlayer); } } _directorSelectedPlayerIdx = Mathf.Clamp(_directorSelectedPlayerIdx, 0, list.Count - 1); GUILayout.Label("Target Location:", Array.Empty<GUILayoutOption>()); _directorSelectedPlayerIdx = GUILayout.SelectionGrid(_directorSelectedPlayerIdx, list.ToArray(), 3, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label("Optional One-Off Narrative Overrides (Leave blank to use preset defaults):", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Custom Start Banner:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); _narrativeStartMsg = GUILayout.TextField(_narrativeStartMsg, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Custom End Banner:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); _narrativeEndMsg = GUILayout.TextField(_narrativeEndMsg, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Override Duration (s):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); _narrativeDurationStr = GUILayout.TextField(_narrativeDurationStr, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.Space(16f); GUILayout.Label("Force Weather:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }); _narrativeEnv = GUILayout.TextField(_narrativeEnv, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Weather Quick-Pick:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); string[] array = new string[5] { "Misty", "ThunderStorm", "SnowStorm", "Ashrain", "Clear" }; foreach (string text in array) { if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { _narrativeEnv = text; } } GUILayout.EndHorizontal(); GUILayout.Space(16f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.backgroundColor = new Color(0.95f, 0.4f, 0.18f); if (GUILayout.Button("LAUNCH RAID NOW", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { float.TryParse(_narrativeDurationStr, out var result); Vector3 val = (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Component)Player.m_localPlayer).transform.position : Vector3.zero); bool flag = _directorSelectedPlayerIdx == 0; string text2 = (flag ? "" : RaidNetworkSync.LatestTelemetry.OnlinePlayers[_directorSelectedPlayerIdx - 1]); RaidNetworkSync.SendTriggerRaid(new TriggerRaidRequest { RaidName = raidDefinition2.Name, UseSenderPosition = flag, TargetPlayerName = text2, PosX = val.x, PosY = val.y, PosZ = val.z, OverrideStartMessage = _narrativeStartMsg, OverrideEndMessage = _narrativeEndMsg, OverrideDuration = result, OverrideEnvironment = _narrativeEnv }); ShowStatus("Launched '" + raidDefinition2.Name + "' " + (flag ? "at your location" : ("on " + text2)) + "!"); } GUI.backgroundColor = new Color(0.75f, 0.2f, 0.2f); if (GUILayout.Button("FORCE STOP ACTIVE RAID", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(40f), GUILayout.Width(210f) })) { RaidNetworkSync.SendStopRaid(); ShowStatus("Force-stopped active raid event."); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(12f); bool autoRaidsPaused = RaidManager.Database.Global.AutoRaidsPaused; GUI.backgroundColor = (autoRaidsPaused ? new Color(0.9f, 0.7f, 0.2f) : new Color(0.35f, 0.58f, 0.85f)); if (GUILayout.Button(autoRaidsPaused ? "Auto-Raids PAUSED (Click to Resume & Push)" : "Pause Automatic Background Raids", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { RaidManager.Database.Global.AutoRaidsPaused = !autoRaidsPaused; RaidNetworkSync.PushDatabaseLive(); ShowStatus(RaidManager.Database.Global.AutoRaidsPaused ? "Automatic raids PAUSED server-wide." : "Automatic raids RESUMED server-wide."); } GUI.backgroundColor = Color.white; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } private void DrawTabGlobalSettings() { GlobalRaidSettings global = RaidManager.Database.Global; GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.Label("Master Raid Scheduler (Replaces Vanilla EventRate)", _headerStyle, Array.Empty<GUILayoutOption>()); global.AutoRaidsPaused = GUILayout.Toggle(global.AutoRaidsPaused, " Pause Automatic Background Raids", Array.Empty<GUILayoutOption>()); global.UseIndividualRaidChecks = GUILayout.Toggle(global.UseIndividualRaidChecks, " Use Individual Per-Raid Timers & Chances (Unchecked = Master Clock Mode)", Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); if (!global.UseIndividualRaidChecks) { global.CheckIntervalMinutes = DrawFloatSlider("Master Check Interval (minutes):", global.CheckIntervalMinutes, 1f, 120f); global.TriggerChancePercent = DrawFloatSlider("Master Trigger Chance (%):", global.TriggerChancePercent, 1f, 100f); } global.MinCooldownMinutes = DrawFloatSlider("Minimum Cooldown Between Raids (minutes):", global.MinCooldownMinutes, 0f, 120f); GUILayout.Space(10f); GUILayout.Label("Boss Progression Key Mode:", _headerStyle, Array.Empty<GUILayoutOption>()); global.Progression = (ProgressionMode)GUILayout.Toolbar((int)global.Progression, new string[3] { "Player Keys (playerevents)", "Global World Keys", "Ignore All Keys (Free-For-All)" }, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }); GUILayout.Space(16f); GUILayout.Label("Live Siege Breaker (Anti-Spawn-Cheese Bypass)", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Overrides Workbenches, Campfires, and Wards ONLY during active raids:", Array.Empty<GUILayoutOption>()); global.SiegeBreaker = (SiegeBreakerMode)GUILayout.Toolbar((int)global.SiegeBreaker, new string[3] { "Off (Use Per-Wave InsidePlayerBase)", "Outdoors Only (Roof Check — Safe Bedrooms)", "Full Bypass (Apocalypse Mode)" }, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }); GUILayout.Space(16f); GUILayout.Label("Global Spawn Ring Override (Tower Defense Tuning)", _headerStyle, Array.Empty<GUILayoutOption>()); global.OverrideGlobalSpawnRadius = GUILayout.Toggle(global.OverrideGlobalSpawnRadius, " Override ALL Wave Spawn Radii Globally (e.g., push mobs into outer turret kill-zones)", Array.Empty<GUILayoutOption>()); if (global.OverrideGlobalSpawnRadius) { global.GlobalSpawnRadiusMin = DrawFloatSlider("Global Spawn Radius Min (m):", global.GlobalSpawnRadiusMin, 5f, 120f); global.GlobalSpawnRadiusMax = DrawFloatSlider("Global Spawn Radius Max (m):", global.GlobalSpawnRadiusMax, 10f, 150f); if (global.GlobalSpawnRadiusMax < global.GlobalSpawnRadiusMin) { global.GlobalSpawnRadiusMax = global.GlobalSpawnRadiusMin; } } GUILayout.Space(12f); global.KeepVanillaNonRandomEvents = GUILayout.Toggle(global.KeepVanillaNonRandomEvents, " Keep Vanilla Boss Fight Events (Recommended: ON)", Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); GUILayout.Label("Remember to click 'Apply & Push Live' in the top bar to save and sync changes to all players.", Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); } private void DrawTabRaidEditor() { //IL_0136: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) List<RaidDefinition> raids = RaidManager.Database.Raids; GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(285f), GUILayout.ExpandHeight(true) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("+ New Raid", Array.Empty<GUILayoutOption>())) { RaidDefinition item = new RaidDefinition { Name = $"custom_raid_{raids.Count + 1}", Category = "Custom", Waves = new List<WaveDefinition> { new WaveDefinition { Name = "Wave_0", PrefabName = "Greydwarf" } } }; raids.Add(item); _editorSelectedRaidIdx = raids.Count - 1; } if (GUILayout.Button("Clone", Array.Empty<GUILayoutOption>()) && raids.Count > 0) { RaidDefinition raidDefinition = raids[_editorSelectedRaidIdx].DeepClone(); raidDefinition.Name += "_copy"; raids.Add(raidDefinition); _editorSelectedRaidIdx = raids.Count - 1; } GUI.backgroundColor = new Color(0.8f, 0.25f, 0.25f); if (GUILayout.Button("Del", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) }) && raids.Count > 1) { raids.RemoveAt(_editorSelectedRaidIdx); _editorSelectedRaidIdx = Mathf.Clamp(_editorSelectedRaidIdx, 0, raids.Count - 1); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Filter:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) }); _editorSearch = GUILayout.TextField(_editorSearch, Array.Empty<GUILayoutOption>()); if (!string.IsNullOrEmpty(_editorSearch) && GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) })) { _editorSearch = ""; } GUILayout.EndHorizontal(); _editorListScroll = GUILayout.BeginScrollView(_editorListScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); for (int i = 0; i < raids.Count; i++) { RaidDefinition raidDefinition2 = raids[i]; if (string.IsNullOrEmpty(_editorSearch) || raidDefinition2.Name.IndexOf(_editorSearch, StringComparison.OrdinalIgnoreCase) >= 0 || (raidDefinition2.Category ?? "").IndexOf(_editorSearch, StringComparison.OrdinalIgnoreCase) >= 0) { GUI.backgroundColor = ((i == _editorSelectedRaidIdx) ? new Color(0.95f, 0.65f, 0.2f) : (raidDefinition2.Enabled ? new Color(0.75f, 0.78f, 0.85f) : new Color(0.5f, 0.35f, 0.35f))); if (GUILayout.Button((raidDefinition2.Enabled ? "" : "[OFF] ") + raidDefinition2.Name, _listButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })) { _editorSelectedRaidIdx = i; _pickingWaveIndex = -1; } } } GUI.backgroundColor = Color.white; GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); if (raids.Count > 0) { _editorSelectedRaidIdx = Mathf.Clamp(_editorSelectedRaidIdx, 0, raids.Count - 1); RaidDefinition raidDefinition3 = raids[_editorSelectedRaidIdx]; if (_pickingWaveIndex >= 0 && _pickingWaveIndex < raidDefinition3.Waves.Count) { DrawPrefabPicker(raidDefinition3.Waves[_pickingWaveIndex]); } else { DrawRaidDetailForm(raidDefinition3); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } private void DrawRaidDetailForm(RaidDefinition raid) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) _editorDetailScroll = GUILayout.BeginScrollView(_editorDetailScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.Label("Editing Raid: " + raid.Name, _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Raid ID:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(65f) }); raid.Name = GUILayout.TextField(raid.Name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(210f) }); GUILayout.Label("Category:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(65f) }); raid.Category = GUILayout.TextField(raid.Category, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(145f) }); raid.Enabled = GUILayout.Toggle(raid.Enabled, " Enabled", Array.Empty<GUILayoutOption>()); raid.Random = GUILayout.Toggle(raid.Random, " Random Pool", Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); raid.NearBaseOnly = GUILayout.Toggle(raid.NearBaseOnly, " Near Base Only (>=3 base pieces)", Array.Empty<GUILayoutOption>()); raid.PauseIfNoPlayerInArea = GUILayout.Toggle(raid.PauseIfNoPlayerInArea, " Pause If No Player Nearby", Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); raid.Duration = DrawFloatSlider("Duration (seconds):", raid.Duration, 10f, 600f); raid.RaidFrequencyMinutes = DrawFloatSlider("Individual Frequency (mins):", raid.RaidFrequencyMinutes, 5f, 300f); raid.RaidChancePercent = DrawFloatSlider("Individual Chance (%):", raid.RaidChancePercent, 1f, 100f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Start Banner:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(105f) }); raid.StartMessage = GUILayout.TextField(raid.StartMessage, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("End Banner:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(105f) }); raid.EndMessage = GUILayout.TextField(raid.EndMessage, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Force Weather:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(105f) }); raid.ForceEnvironment = GUILayout.TextField(raid.ForceEnvironment, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.Label("Music:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); raid.ForceMusic = GUILayout.TextField(raid.ForceMusic, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.Label("Allowed Biomes:", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < AllBiomes.Length; i++) { if (i == 5) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); } string biome = AllBiomes[i]; bool flag = raid.Biomes.Any((string x) => x.Equals(biome, StringComparison.OrdinalIgnoreCase)); bool num = GUILayout.Toggle(flag, biome, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(115f) }); if (num && !flag) { raid.Biomes.Add(biome); } if (!num && flag) { raid.Biomes.RemoveAll((string x) => x.Equals(biome, StringComparison.OrdinalIgnoreCase)); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Must Have Key(s):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) }); string text = string.Join(", ", raid.RequiredKeysAny); string text2 = GUILayout.TextField(text, Array.Empty<GUILayoutOption>()); if (text2 != text) { raid.RequiredKeysAny = (from s in text2.Split(new char[1] { ',' }) select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToList(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Must NOT Have:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) }); string text3 = string.Join(", ", raid.NotRequiredKeysAny); string text4 = GUILayout.TextField(text3, Array.Empty<GUILayoutOption>()); if (text4 != text3) { raid.NotRequiredKeysAny = (from s in text4.Split(new char[1] { ',' }) select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToList(); } GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"Spawn Waves ({raid.Waves.Count})", _headerStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("+ Add Wave", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) })) { raid.Waves.Add(new WaveDefinition { Name = $"Wave_{raid.Waves.Count}", PrefabName = "Greydwarf" }); } GUILayout.EndHorizontal(); for (int num2 = 0; num2 < raid.Waves.Count; num2++) { WaveDefinition waveDefinition = raid.Waves[num2]; GUILayout.BeginVertical(_boxStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); waveDefinition.Enabled = GUILayout.Toggle(waveDefinition.Enabled, "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }); waveDefinition.Name = GUILayout.TextField(waveDefinition.Name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.Label("Prefab:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) }); waveDefinition.PrefabName = GUILayout.TextField(waveDefinition.PrefabName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(165f) }); if (GUILayout.Button("Browse...", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(75f) })) { _pickingWaveIndex = num2; _prefabSearch = ""; } GUILayout.FlexibleSpace(); GUI.backgroundColor = new Color(0.8f, 0.25f, 0.25f); if (GUILayout.Button("Remove", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(65f) })) { raid.Waves.RemoveAt(num2); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.EndVertical(); break; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); waveDefinition.InsidePlayerBase = GUILayout.Toggle(waveDefinition.InsidePlayerBase, " Breach (Ignore Wards/Campfires)", Array.Empty<GUILayoutOption>()); waveDefinition.HuntPlayer = GUILayout.Toggle(waveDefinition.HuntPlayer, " Hunt Player Immediately", Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); waveDefinition.MinLevel = DrawIntField("Min Lvl:", waveDefinition.MinLevel, 1, 5); waveDefinition.MaxLevel = DrawIntField("Max Lvl:", waveDefinition.MaxLevel, 1, 5); waveDefinition.GroupSizeMin = DrawIntField("Grp Min:", waveDefinition.GroupSizeMin, 1, 20); waveDefinition.GroupSizeMax = DrawIntField("Grp Max:", waveDefinition.GroupSizeMax, 1, 20); waveDefinition.MaxSpawned = DrawIntField("Max Alive:", waveDefinition.MaxSpawned, 1, 50); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); waveDefinition.SpawnInterval = DrawFloatField("Interval(s):", waveDefinition.SpawnInterval, 1f, 300f); waveDefinition.SpawnChancePerInterval = DrawFloatField("Chance(%):", waveDefinition.SpawnChancePerInterval, 0f, 100f); waveDefinition.SpawnRadiusMin = DrawFloatField("Rad Min(m):", waveDefinition.SpawnRadiusMin, 0f, 150f); waveDefinition.SpawnRadiusMax = DrawFloatField("Rad Max(m):", waveDefinition.SpawnRadiusMax, 5f, 200f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); waveDefinition.StartAfterSeconds = DrawFloatField("Phase Start(s):", waveDefinition.StartAfterSeconds, 0f, 600f); waveDefinition.StopAfterSeconds = DrawFloatField("Phase Stop(s, 0=end):", waveDefinition.StopAfterSeconds, 0f, 600f); waveDefinition.SpawnDistance = DrawFloatField("Min Spacing(m):", waveDefinition.SpawnDistance, 1f, 100f); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.EndScrollView(); } private void DrawPrefabPicker(WaveDefinition wave) { //IL_00a4: 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_00bd: Unknown result type (might be due to invalid IL or missing references) EnsureCreaturePrefabsCached(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Pick Creature Prefab for '" + wave.Name + "'", _headerStyle, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Cancel", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) })) { _pickingWaveIndex = -1; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Search (Vanilla + Monstrum + Modded):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(240f) }); _prefabSearch = GUILayout.TextField(_prefabSearch, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); _prefabScroll = GUILayout.BeginScrollView(_prefabScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); int num = 0; foreach (string cachedCreaturePrefab in _cachedCreaturePrefabs) { if (string.IsNullOrEmpty(_prefabSearch) || cachedCreaturePrefab.IndexOf(_prefabSearch, StringComparison.OrdinalIgnoreCase) >= 0) { if (GUILayout.Button(cachedCreaturePrefab, _listButtonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })) { wave.PrefabName = cachedCreaturePrefab; _pickingWaveIndex = -1; break; } if (++num >= 150) { break; } } } GUILayout.EndScrollView(); } private void EnsureCreaturePrefabsCached() { if (_cachedCreaturePrefabs != null && _cachedCreaturePrefabs.Count > 0) { return; } _cachedCreaturePrefabs = new List<string>(); if ((Object)(object)ZNetScene.instance == (Object)null) { return; } foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<Character>() != (Object)null && (Object)(object)prefab.GetComponent<Player>() == (Object)null) { _cachedCreaturePrefabs.Add(((Object)prefab).name); } } _cachedCreaturePrefabs.Sort(StringComparer.OrdinalIgnoreCase); } private void DrawTabPresetsAndImport() { //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(_boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); GUILayout.Label("Built-In Raid Packs", _headerStyle, Array.Empty<GUILayoutOption>()); foreach (IGrouping<string, RaidDefinition> item in from r in RaidManager.Database.Raids group r by r.Category) { int num = item.Count((RaidDefinition r) => r.Enabled); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"• {item.Key}: {num} / {item.Count()} enabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) }); if (GUILayout.Button("Enable All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { foreach (RaidDefinition item2 in item) { item2.Enabled = true; } } if (GUILayout.Button("Disable All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { foreach (RaidDefinition item3 in item) { item3.Enabled = false; } } GUILayout.EndHorizontal(); } GUILayout.Space(20f); GUILayout.Label("Import Legacy Custom Raids (.cfg) Files", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("Drop any custom_raid.supplemental.*.cfg files (e.g., turret_sieges.cfg or modded_raids.cfg) into:\n" + Plugin.ImportDir, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); if (GUILayout.Button("Import .cfg Files from Server & Sync Live", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(34f), GUILayout.Width(340f) })) { RaidNetworkSync.SendImportCfgRequest(); ShowStatus("Requested server import from RaidMaster/import/ folder!"); } GUILayout.Space(24f); GUILayout.Label("Safety Reset", _headerStyle, Array.Empty<GUILayoutOption>()); GUI.backgroundColor = new Color(0.8f, 0.25f, 0.25f); if (GUILayout.Button("Reset Database to 29 Built-In Default Raids", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(30f), GUILayout.Width(340f) })) { RaidManager.ResetToDefaults(); RaidNetworkSync.PushDatabaseLive(); ShowStatus("Reset database to the 29 built-in default raids and pushed live."); } GUI.backgroundColor = Color.white; GUILayout.EndVertical(); } private float DrawFloatSlider(string label, float value, float min, float max) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label($"{label} {value:F1}", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(280f) }); value = GUILayout.HorizontalSlider(value, min, max, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); return Mathf.Round(value * 10f) / 10f; } private int DrawIntField(string label, int value, int min, int max) { GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(68f) }); if (int.TryParse(GUILayout.TextField(value.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) }), out var result)) { value = Mathf.Clamp(result, min, max); } return value; } private float DrawFloatField(string label, float value, float min, float max) { GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(105f) }); if (float.TryParse(GUILayout.TextField(value.ToString("0.#"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }), out var result)) { value = Mathf.Clamp(result, min, max); } return value; } private void ShowStatus(string msg) { _statusMessage = msg; _statusTimer = 6f; } } } namespace RaidMaster.Core { public static class RaidManager { private class PlayerCandidate { public string Name; public Vector3 Position; public Biome Biome; public int BaseValue; public HashSet<string> Keys; } private static readonly Dictionary<string, WaveDefinition> _waveLookup = new Dictionary<string, WaveDefinition>(StringComparer.OrdinalIgnoreCase); private static List<RandomEvent> _cachedVanillaNonRandomEvents; private static float _masterCheckTimer = 0f; private static float _cooldownRemaining = 0f; private static readonly Dictionary<string, float> _individualTimers = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase); private static RandomEvent _pendingNarrativeEvent; public static RaidDatabase Database { get; private set; } = new RaidDatabase(); public static float ActiveEventElapsedSeconds { get; private set; } public static string ActiveEventName { get; private set; } = ""; public static string LastSpawnSummary { get; private set; } = "None yet"; public static void Initialize() { LoadFromDiskOrCreateDefaults(); } public static void RecordEventSpawn(string rawPrefabName, Vector3 pos) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) string arg = (rawPrefabName ?? "Unknown").Replace("(Clone)", "").Trim(); float num = (((Object)(object)Player.m_localPlayer != (Object)null) ? Vector3.Distance(((Component)Player.m_localPlayer).transform.position, pos) : 0f); LastSpawnSummary = $"{arg} ({num:F0}m away @ {DateTime.Now:HH:mm:ss})"; if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)("[SpawnTelemetry] " + LastSpawnSummary)); } } public static void LoadFromDiskOrCreateDefaults() { try { if (File.Exists(Plugin.RaidsJsonPath)) { RaidDatabase raidDatabase = JsonUtility.FromJson<RaidDatabase>(File.ReadAllText(Plugin.RaidsJsonPath)); if (raidDatabase != null && raidDatabase.Raids != null && raidDatabase.Raids.Count > 0) { Database = raidDatabase; Plugin.Log.LogInfo((object)$"Loaded {Database.Raids.Count} raids from {Plugin.RaidsJsonPath}."); RebuildWaveLookup(); return; } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to read {Plugin.RaidsJsonPath}, falling back to defaults: {arg}"); } Database = DefaultRaidPresets.BuildDefaultDatabase(); SaveToDisk(); RebuildWaveLookup(); Plugin.Log.LogInfo((object)$"Created default RaidMaster database with {Database.Raids.Count} built-in raids."); } public static void ResetToDefaults() { Database = DefaultRaidPresets.BuildDefaultDatabase(); SaveToDisk(); RebuildWaveLookup(); ApplyToRandEventSystem(); } public static void SaveToDisk() { try { Directory.CreateDirectory(Plugin.ConfigDir); string contents = JsonUtility.ToJson((object)Database, true); File.WriteAllText(Plugin.RaidsJsonPath, contents); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to save raids.json: {arg}"); } } public static void LoadFromJsonString(string json, bool saveToDisk) { RaidDatabase raidDatabase = JsonUtility.FromJson<RaidDatabase>(json); if (raidDatabase != null && raidDatabase.Raids != null && raidDatabase.Raids.Count != 0) { Database = raidDatabase; if (saveToDisk) { SaveToDisk(); } RebuildWaveLookup(); ApplyToRandEventSystem(); } } public static string SerializeDatabase() { return JsonUtility.ToJson((object)Database, false); } private static void RebuildWaveLookup() { _waveLookup.Clear(); foreach (RaidDefinition raid in Database.Raids) { foreach (WaveDefinition wave in raid.Waves) { string key = raid.Name + "|" + wave.Name; _waveLookup[key] = wave; } } } public static WaveDefinition FindWaveMeta(string eventName, string waveName) { if (string.IsNullOrEmpty(eventName) || string.IsNullOrEmpty(waveName)) { return null; } _waveLookup.TryGetValue(eventName + "|" + waveName, out var value); return value; } public static void OnEventActivated(string eventName) { ActiveEventName = eventName ?? ""; ActiveEventElapsedSeconds = 0f; LastSpawnSummary = "Waiting for first wave interval..."; } public static void OnEventDeactivated() { ActiveEventName = ""; ActiveEventElapsedSeconds = 0f; _pendingNarrativeEvent = null; } public static void TickActiveEventElapsed(float dt) { if (RandEventSystem.HaveActiveEvent()) { ActiveEventElapsedSeconds += dt; } else if (ActiveEventElapsedSeconds > 0f) { ActiveEventElapsedSeconds = 0f; ActiveEventName = ""; } } public static bool ShouldBypassPlayerBaseAt(Vector3 point) { //IL_0048: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) SiegeBreakerMode siegeBreaker = Database.Global.SiegeBreaker; if (siegeBreaker == SiegeBreakerMode.Off) { return false; } if (!RandEventSystem.HaveActiveEvent()) { return false; } if (siegeBreaker == SiegeBreakerMode.FullBypass) { return true; } int mask = LayerMask.GetMask(new string[3] { "piece", "piece_nonsolid", "Default_small" }); return !Physics.Raycast(point + Vector3.up * 0.5f, Vector3.up, 25f, mask); } public static void ApplyToRandEventSystem() { if ((Object)(object)RandEventSystem.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return; } if (_cachedVanillaNonRandomEvents == null) { _cachedVanillaNonRandomEvents = RandEventSystem.instance.m_events.Where((RandomEvent e) => e != null && !e.m_random).ToList(); } List<RandomEvent> list = new List<RandomEvent>(); if (Database.Global.KeepVanillaNonRandomEvents) { list.AddRange(_cachedVanillaNonRandomEvents); } int skippedWaves = 0; foreach (RaidDefinition raid in Database.Raids) { RandomEvent val = BuildRandomEvent(raid, ref skippedWaves); if (val != null) { list.Add(val); } } if (_pendingNarrativeEvent != null && !list.Any((RandomEvent e) => e.m_name == _pendingNarrativeEvent.m_name)) { list.Add(_pendingNarrativeEvent); } RandEventSystem.instance.m_events = list; Plugin.Log.LogInfo((object)$"Applied {Database.Raids.Count} RaidMaster raids live to RandEventSystem (total events: {list.Count}, unresolved prefabs skipped: {skippedWaves})."); } public static RandomEvent BuildRandomEvent(RaidDefinition def, ref int skippedWaves) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0029: 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_004b: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007e: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_033f: 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_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Expected O, but got Unknown RandomEvent val = new RandomEvent { m_name = def.Name, m_enabled = def.Enabled, m_random = def.Random, m_duration = Mathf.Max(5f, def.Duration), m_nearBaseOnly = def.NearBaseOnly, m_pauseIfNoPlayerInArea = def.PauseIfNoPlayerInArea, m_biome = ParseBiomes(def.Biomes), m_requiredGlobalKeys = new List<string>(), m_notRequiredGlobalKeys = new List<string>(), m_startMessage = (def.StartMessage ?? ""), m_endMessage = (def.EndMessage ?? ""), m_forceMusic = (def.ForceMusic ?? ""), m_forceEnvironment = (def.ForceEnvironment ?? ""), m_spawn = new List<SpawnData>() }; SiegeBreakerMode siegeBreaker = Database.Global.SiegeBreaker; bool flag = siegeBreaker != SiegeBreakerMode.Off; foreach (WaveDefinition wave in def.Waves) { GameObject prefab = ZNetScene.instance.GetPrefab(wave.PrefabName); if ((Object)(object)prefab == (Object)null) { skippedWaves++; if (Plugin.VerboseLogging.Value) { Plugin.Log.LogWarning((object)("[" + def.Name + "] Prefab '" + wave.PrefabName + "' not found in ZNetScene; wave '" + wave.Name + "' skipped.")); } continue; } float num = (Database.Global.OverrideGlobalSpawnRadius ? Database.Global.GlobalSpawnRadiusMin : (flag ? Mathf.Min(wave.SpawnRadiusMin, 12f) : wave.SpawnRadiusMin)); float num2 = (Database.Global.OverrideGlobalSpawnRadius ? Database.Global.GlobalSpawnRadiusMax : (flag ? Mathf.Min(wave.SpawnRadiusMax, 38f) : wave.SpawnRadiusMax)); if (num2 < num) { num2 = num; } bool flag2 = wave.InsidePlayerBase || siegeBreaker == SiegeBreakerMode.FullBypass; SpawnData item = new SpawnData { m_name = wave.Name, m_prefab = prefab, m_enabled = wave.Enabled, m_biome = (Biome)895, m_biomeArea = (BiomeArea)3, m_maxSpawned = Mathf.Max(1, wave.MaxSpawned), m_spawnInterval = Mathf.Max(1f, wave.SpawnInterval), m_spawnChance = Mathf.Clamp(wave.SpawnChancePerInterval, 0f, 100f), m_spawnDistance = Mathf.Max(1f, wave.SpawnDistance), m_spawnRadiusMin = Mathf.Max(0f, num), m_spawnRadiusMax = Mathf.Max(0f, num2), m_groupSizeMin = Mathf.Max(1, wave.GroupSizeMin), m_groupSizeMax = Mathf.Max(1, wave.GroupSizeMax), m_groupRadius = Mathf.Max(1f, wave.GroupRadius), m_minLevel = Mathf.Clamp(wave.MinLevel, 1, 5), m_maxLevel = Mathf.Clamp(wave.MaxLevel, 1, 5), m_huntPlayer = wave.HuntPlayer, m_insidePlayerBase = flag2, m_canSpawnCloseToPlayer = (flag2 || flag || num < 25f), m_spawnAtDay = true, m_spawnAtNight = true, m_inForest = true, m_outsideForest = true, m_minAltitude = -10f, m_maxAltitude = 1000f, m_minTilt = 0f, m_maxTilt = 45f, m_requiredGlobalKey = "", m_requiredEnvironments = new List<string>() }; val.m_spawn.Add(item); } return val; } public static Biome ParseBiomes(List<string> biomeNames) { //IL_0012: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) if (biomeNames == null || biomeNames.Count == 0) { return (Biome)895; } Biome val = (Biome)0; foreach (string biomeName in biomeNames) { string text = biomeName.Trim(); if (text.Equals("Ashlands", StringComparison.OrdinalIgnoreCase)) { text = "AshLands"; } if (Enum.TryParse<Biome>(text, ignoreCase: true, out Biome result)) { val |= result; } } if ((int)val != 0) { return val; } return (Biome)895; } public static void TickServerScheduler(RandEventSystem res, float dt) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } if (_cooldownRemaining > 0f) { _cooldownRemaining = Mathf.Max(0f, _cooldownRemaining - dt); } if (Database.Global.AutoRaidsPaused || RandEventSystem.HaveActiveEvent() || _cooldownRemaining > 0f) { return; } List<PlayerCandidate> list = CollectOnlinePlayersForCheck(); if (list.Count != 0) { if (Database.Global.UseIndividualRaidChecks) { TickIndividualChecks(res, dt, list); } else { TickMasterClock(res, dt, list); } } } private static void TickMasterClock(RandEventSystem res, float dt, List<PlayerCandidate> players) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) _masterCheckTimer += dt; float num = Mathf.Max(30f, Database.Global.CheckIntervalMinutes * 60f); if (_masterCheckTimer < num) { return; } _masterCheckTimer = 0f; float num2 = Random.Range(0f, 100f); if (num2 > Database.Global.TriggerChancePercent) { if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)$"[Scheduler] Master check rolled {num2:F1} > {Database.Global.TriggerChancePercent:F1}%. Skipping."); } return; } List<(RaidDefinition, PlayerCandidate)> list = new List<(RaidDefinition, PlayerCandidate)>(); foreach (RaidDefinition raid in Database.Raids) { if (!raid.Enabled || !raid.Random) { continue; } foreach (PlayerCandidate player in players) { if (IsPlayerEligibleForRaid(player, raid)) { list.Add((raid, player)); } } } if (list.Count == 0) { if (Plugin.VerboseLogging.Value) { Plugin.Log.LogInfo((object)"[Scheduler] Master check succeeded, but 0 raids matched any online player's biome/base/keys."); } } else { (RaidDefinition, PlayerCandidate) tuple = list[Random.Range(0, list.Count)]; ExecuteRaidOnServer(res, tuple.Item1.Name, tuple.Item2.Position, null); } } private static void TickIndividualChecks(RandEventSystem res, float dt, List<PlayerCandidate> players) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) foreach (RaidDefinition raid in Database.Raids) { if (!raid.Enabled || !raid.Random) { continue; } _individualTimers.TryGetValue(raid.Name, out var value); value += dt; float num = Mathf.Max(60f, raid.RaidFrequencyMinutes * 60f); if (value < num) { _individualTimers[raid.Name] = value; continue; } _individualTimers[raid.Name] = 0f; if (!(Random.Range(0f, 100f) > raid.RaidChancePercent)) { List<PlayerCandidate> list = players.Where((PlayerCandidate p) => IsPlayerEligibleForRaid(p, raid)).ToList(); if (list.Count != 0) { PlayerCandidate playerCandidate = list[Random.Range(0, list.Count)]; ExecuteRaidOnServer(res, raid.Name, playerCandidate.Position, null); break; } } } } public static void ExecuteRaidOnServer(RandEventSystem res, string raidName, Vector3 pos, TriggerRaidRequest narrativeOverride) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)res == (Object)null) { return; } RaidDefinition raidDefinition = Database.Raids.FirstOrDefault((RaidDefinition r) => r.Name.Equals(raidName, StringComparison.OrdinalIgnoreCase)); RandomEvent val = null; if (raidDefinition != null && narrativeOverride != null && (!string.IsNullOrWhiteSpace(narrativeOverride.OverrideStartMessage) || !string.IsNullOrWhiteSpace(narrativeOverride.OverrideEndMessage) || narrativeOverride.OverrideDuration > 0f || !string.IsNullOrWhiteSpace(narrativeOverride.OverrideEnvironment))) { RaidDefinition raidDefinition2 = raidDefinition.DeepClone(); if (!string.IsNullOrWhiteSpace(narrativeOverride.OverrideStartMessage)) { raidDefinition2.StartMessage = narrativeOverride.OverrideStartMessage; } if (!string.IsNullOrWhiteSpace(narrativeOverride.OverrideEndMessage)) { raidDefinition2.EndMessage = narrativeOverride.OverrideEndMessage; } if (narrativeOverride.OverrideDuration > 0f) { raidDefinition2.Duration = narrativeOverride.OverrideDuration; } if (!string.IsNullOrWhiteSpace(narrativeOverride.OverrideEnvironment)) { raidDefinition2.ForceEnvironment = narrativeOverride.OverrideEnvironment; } RaidNetworkSync.BroadcastNarrativeOverride(raidDefinition2); int skippedWaves = 0; val = (_pendingNarrativeEvent = BuildRandomEvent(raidDefinition2, ref skippedWaves)); ApplyTemporaryOverrideEvent(val); } else { val = ((IEnumerable<RandomEvent>)res.m_events).FirstOrDefault((Func<RandomEvent, bool>)((RandomEvent e) => e.m_name.Equals(raidName, StringComparison.OrdinalIgnoreCase))); } if (val == null) { Plugin.Log.LogWarning((object)("Cannot execute raid '" + raidName + "': not found in RandEventSystem.")); return; } res.SetRandomEvent(val, pos); _cooldownRemaining = Mathf.Max(0f, Database.Global.MinCooldownMinutes * 60f); _masterCheckTimer = 0f; Plugin.Log.LogInfo((object)$"Executed raid '{val.m_name}' at {pos} (Duration: {val.m_duration}s)."); } public static void ApplyTemporaryOverrideEvent(RandomEvent ev) { if (!((Object)(object)RandEventSystem.instance == (Object)null) && ev != null) { _pendingNarrativeEvent = ev; RandEventSystem.instance.m_events.RemoveAll((RandomEvent e) => e.m_name.Equals(ev.m_name, StringComparison.OrdinalIgnoreCase)); RandEventSystem.instance.m_events.Add(ev); } } public static LiveTelemetry BuildServerTelemetry() { LiveTelemetry liveTelemetry = new LiveTelemetry { AutoRaidsPaused = Database.Global.AutoRaidsPaused, CooldownRemainingSeconds = _cooldownRemaining, ActiveRaidCount = Database.Raids.Count((RaidDefinition r) => r.Enabled), NextCheckSeconds = Mathf.Max(0f, Database.Global.CheckIntervalMinutes * 60f - _masterCheckTimer), OnlinePlayers = new List<string>() }; if ((Object)(object)RandEventSystem.instance != (Object)null && RandEventSystem.HaveActiveEvent()) { RandomEvent activeEvent = RandEventSystem.instance.GetActiveEvent(); liveTelemetry.ActiveEventName = activeEvent?.m_name ?? ""; liveTelemetry.ActiveEventDuration = activeEvent?.m_duration ?? 0f; liveTelemetry.ActiveEventElapsed = ActiveEventElapsedSeconds; } if ((Object)(object)Player.m_localPlayer != (Object)null) { liveTelemetry.OnlinePlayers.Add(Player.m_localPlayer.GetPlayerName()); } if ((Object)(object)ZNet.instance != (Object)null) { foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer != null && !string.IsNullOrEmpty(peer.m_playerName) && !liveTelemetry.OnlinePlayers.Contains(peer.m_playerName)) { liveTelemetry.OnlinePlayers.Add(peer.m_playerName); } } } return liveTelemetry; } private static List<PlayerCandidate> CollectOnlinePlayersForCheck() { //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: 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_016b: Unknown result type (might be due to invalid IL or missing references) List<PlayerCandidate> list = new List<PlayerCandidate>(); if ((Object)(object)Player.m_localPlayer != (Object)null && !((Character)Player.m_localPlayer).IsDead()) { list.Add(new PlayerCandidate { Name = Player.m_localPlayer.GetPlayerName(), Position = ((Component)Player.m_localPlayer).transform.position, Biome = Player.m_localPlayer.GetCurrentBiome(), BaseValue = Player.m_localPlayer.GetBaseValue(), Keys = new HashSet<string>(Player.m_localPlayer.GetUniqueKeys(), StringComparer.OrdinalIgnoreCase) }); } if ((Object)(object)ZNet.instance != (Object)null) { foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer == null || !peer.IsReady() || string.IsNullOrEmpty(peer.m_playerName) || list.Any((PlayerCandidate p) => p.Name == peer.m_playerName)) { continue; } Dictionary<string, string> serverSyncedPlayerData = peer.m_serverSyncedPlayerData; int result = 0; if (serverSyncedPlayerData.TryGetValue("rm_base", out var value)) { int.TryParse(value, out result); } Biome biome = (Biome)((WorldGenerator.instance == null) ? 1 : ((int)WorldGenerator.instance.GetBiome(peer.m_refPos))); if (serverSyncedPlayerData.TryGetValue("rm_biome", out var value2) && Enum.TryParse<Biome>(value2, out Biome result2)) { biome = result2; } HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if (serverSyncedPlayerData.TryGetValue("rm_keys", out var value3) && !string.IsNullOrEmpty(value3)) { string[] array = value3.Split(new char[1] { ',' }); foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text)) { hashSet.Add(text.Trim()); } } } list.Add(new PlayerCandidate { Name = peer.m_playerName, Position = peer.m_refPos, Biome = biome, BaseValue = result, Keys = hashSet }); } } return list; } private static bool IsPlayerEligibleForRaid(PlayerCandidate p, RaidDefinition raid) { //IL_001f: 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) if (raid.NearBaseOnly && p.BaseValue < 3) { return false; } if ((ParseBiomes(raid.Biomes) & p.Biome) == 0) { return false; } ProgressionMode progression = Database.Global.Progression; if (progression == ProgressionMode.IgnoreKeys) { return true; } HashSet<string> activeKeys = ((progression == ProgressionMode.PlayerKeys) ? p.Keys : new HashSet<string>(((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.GetGlobalKeys() : new List<string>(), StringComparer.OrdinalIgnoreCase)); if (raid.RequiredKeysAny != null && raid.RequiredKeysAny.Count > 0 && !raid.RequiredKeysAny.Any((string k) => !string.IsNullOrWhiteSpace(k) && activeKeys.Contains(k.Trim()))) { return false; } if (raid.NotRequiredKeysAny != null && raid.NotRequiredKeysAny.Count > 0 && raid.NotRequiredKeysAny.Any((string k) => !string.IsNullOrWhiteSpace(k) && activeKeys.Contains(k.Trim()))) { return false; } return true; } public static int ImportCustomRaidsCfgFolder() { if (!Directory.Exists(Plugin.ImportDir)) { return 0; } int num = 0; string[] files = Directory.GetFiles(Plugin.ImportDir, "*.cfg"); foreach (string path in files) { foreach (RaidDefinition raid in ParseCustomRaidsCfg(category: Path.GetFileNameWithoutExtension(path), lines: File.ReadAllLines(path))) { int num2 = Database.Raids.FindIndex((RaidDefinition r) => r.Name.Equals(raid.Name, StringComparison.OrdinalIgnoreCase)); if (num2 >= 0) { Database.Raids[num2] = raid; } else { Database.Raids.Add(raid); } num++; } } if (num > 0) { SaveToDisk(); RebuildWaveLookup(); ApplyToRandEventSystem(); } return num; } private static List<RaidDefinition> ParseCustomRaidsCfg(string[] lines, string category) { Dictionary<string, RaidDefinition> dictionary = new Dictionary<string, RaidDefinition>(StringComparer.OrdinalIgnoreCase); RaidDefinition value = null; WaveDefinition waveDefinition = null; for (int i = 0; i < lines.Length; i++) { string text = lines[i].Trim(); if (string.IsNullOrEmpty(text) || text.StartsWith("#") || text.StartsWith(";")) { continue; } if (text.StartsWith("[") && text.EndsWith("]")) { string text2 = text.Substring(1, text.Length - 2).Trim(); int num = text2.LastIndexOf('.'); if (num > 0 && int.TryParse(text2.Substring(num + 1), out var _)) { string text3 = text2.Substring(0, num); if (!dictionary.TryGetValue(text3, out value)) { value = (dictionary[text3] = new RaidDefinition { Name = text3, Category = category }); } waveDefinition = new WaveDefinition { Name = text2 }; value.Waves.Add(waveDefinition); } else { if (!dictionary.TryGetValue(text2, out value)) { value = (dictionary[text2] = new RaidDefinition { Name = text2, Category = category, Biomes = new List<string>() }); } waveDefinition = null; } continue; } int num2 = text.IndexOf('='); if (num2 > 0 && value != null) { string key = text.Substring(0, num2).Trim(); string val = text.Substring(num2 + 1).Trim(); if (waveDefinition == null) { ApplyRaidCfgField(value, key, val); } else { ApplyWaveCfgField(waveDefinition, key, val); } } } return dictionary.Values.ToList(); } private static void ApplyRaidCfgField(RaidDefinition r, string key, string val) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; string text = key.ToLowerInvariant(); if (text == null) { return; } switch (text.Length) { case 6: switch (text[0]) { case 'r': if (text == "random") { bool.TryParse(val, out r.Random); } break; case 'b': if (text == "biomes") { r.Biomes = (from s in val.Split(new char[1] { ',' }) select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToList(); } break; } return; case 12: switch (text[0]) { case 'n': if (text == "nearbaseonly") { bool.TryParse(val, out r.NearBaseOnly); } break; case 's': if (text == "startmessage") { r.StartMessage = val; } break; } return; case 10: switch (text[0]) { case 'r': if (text == "raidchance") { float.TryParse(val, NumberStyles.Float, invariantCulture, out r.RaidChancePercent); } break; case 'e': if (text == "endmessage") { r.EndMessage = val; } break; case 'f': if (text == "forcemusic") { r.ForceMusic = val; } break; } return; case 4: if (text == "name") { r.Name = val; } return; case 7: if (text == "enabled") { bool.TryParse(val, out r.Enabled); } return; case 8: if (text == "duration") { float.TryParse(val, NumberStyles.Float, invariantCulture, out r.Duration); } return; case 13: if (text == "raidfrequency") { float.TryParse(val, NumberStyles.Float, invariantCulture, out r.RaidFrequencyMinutes); } return; case 16: if (text == "forceenvironment") { r.ForceEnvironment = val; } return; case 38: if (!(text == "conditionplayermusthaveanyofplayerkeys")) { return; } goto IL_02c8; case 18: if (!(text == "requiredglobalkeys")) { return; } goto IL_02c8; case 41: if (!(text == "conditionplayermustnothaveanyofplayerkeys")) { return; } break; case 21: if (!(text == "notrequiredglobalkeys")) { return; } break; default: return; IL_02c8: r.RequiredKeysAny = (from s in val.Split(new char[1] { ',' }) select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToList(); return; } r.NotRequiredKeysAny = (from s in val.Split(new char[1] { ',' }) select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToList(); } private static void ApplyWaveCfgField(WaveDefinition w, string key, string val) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; string text = key.ToLowerInvariant(); if (text == null) { return; } switch (text.Length) { case 10: switch (text[0]) { default: return; case 'p': if (text == "prefabname") { w.PrefabName = val; } return; case 'm': if (text == "maxspawned") { int.TryParse(val, out w.MaxSpawned); } return; case 'h': break; } if (!(text == "huntplayer")) { break; } goto IL_0313; case 8: switch (text[1]) { case 'i': if (text == "minlevel") { int.TryParse(val, out w.MinLevel); } break; case 'a': if (text == "maxlevel") { int.TryParse(val, out w.MaxLevel); } break; } break; case 13: switch (text[5]) { default: return; case 'i': if (text == "spawninterval") { float.TryParse(val, NumberStyles.Float, invariantCulture, out w.SpawnInterval); } return; case 'd': if (text == "spawndistance") { float.TryParse(val, NumberStyles.Float, invariantCulture, out w.SpawnDistance); } return; case 'n': break; } if (!(text == "sethuntplayer")) { break; } goto IL_0313; case 14: switch (text[12]) { case 'i': if (text == "spawnradiusmin") { float.TryParse(val, NumberStyles.Float, invariantCulture, out w.SpawnRadiusMin); } break; case 'a': if (text == "spawnradiusmax") { float.TryParse(val, NumberStyles.Float, invariantCulture, out w.SpawnRadiusMax); } break; } break; case 12: switch (text[10]) { case 'i': if (text == "groupsizemin") { int.TryParse(val, out w.GroupSizeMin); } break; case 'a': if (text == "groupsizemax") { int.TryParse(val, out w.GroupSizeMax); } break; } break; case 4: if (text == "name") { w.Name = val; } break; case 7: if (text == "enabled") { bool.TryParse(val, out w.Enabled); } break; case 22: if (text == "spawnchanceperinterval") { float.TryParse(val, NumberStyles.Float, invariantCulture, out w.SpawnChancePerInterval); } break; case 16: if (text == "insideplayerbase") { bool.TryParse(val, out w.InsidePlayerBase); } break; case 34: { if (text == "conditionspawnmustbeplayerbasefree" && bool.TryParse(val, out var result)) { w.InsidePlayerBase = !result; } break; } IL_0313: bool.TryParse(val, out w.HuntPlayer); break; } } } public static class RaidNetworkSync { private const string RpcSyncDatabase = "RaidMaster_SyncDatabase"; private const string RpcAdminPushDatabase = "RaidMaster_AdminPushDatabase"; private const string RpcAdminTriggerRaid = "RaidMaster_AdminTriggerRaid"; private const string RpcAdminStopRaid = "RaidMaster_AdminStopRaid"; private const string RpcAdminStatus = "RaidMaster_AdminStatus"; private const string RpcTelemetry = "RaidMaster_Telemetry"; private const string RpcNarrativeOverride = "RaidMaster_NarrativeOverride"; private const string RpcRequestImport = "RaidMaster_RequestImport"; private static bool _registered = false; private static float _telemetryTimer = 0f; private static float _playerDataSyncTimer = 0f; public static bool LocalIsAdmin { get; private set; } = false; public static LiveTelemetry LatestTelemetry { get; private set; } = new LiveTelemetry(); public static void RegisterRpcs() { if (!_registered && ZRoutedRpc.instance != null) { _registered = true; ZRoutedRpc.instance.Register<ZPackage>("RaidMaster_SyncDatabase", (Action<long, ZPackage>)OnReceiveDatabaseFromServer); ZRoutedRpc.instance.Register<ZPackage>("RaidMaster_AdminPushDatabase", (Action<long, ZPackage>)OnServerReceiveAdminPush); ZRoutedRpc.instance.Register<ZPackage>("RaidMaster_AdminTriggerRaid", (Action<long, ZPackage>)OnServerReceiveTriggerRequest); ZRoutedRpc.instance.Register("RaidMaster_AdminStopRaid", (Action<long>)OnServerReceiveStopRequest); ZRoutedRpc.instance.Register<bool>("RaidMaster_AdminStatus", (Action<long, bool>)OnClientReceiveAdminStatus); ZRoutedRpc.instance.Register<string>("RaidMaster_Telemetry", (Action<long, string>)OnClientReceiveTelemetry); ZRoutedRpc.instance.Register<string>("RaidMaster_NarrativeOverride", (Action<long, string>)OnClientReceiveNarrativeOverride); ZRoutedRpc.instance.Register("RaidMaster_RequestImport", (Action<long>)OnServerReceiveImportRequest); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { LocalIsAdmin = true; } } } public static void ResetRegistration() { _registered = false; LocalIsAdmin = false; } public static void TickNetworkLoops(float dt) { //IL_007f: 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) if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null) { return; } _playerDataSyncTimer += dt; if (_playerDataSyncTimer >= 3f && (Object)(object)Player.m_localPlayer != (Object)null) { _playerDataSyncTimer = 0f; Player localPlayer = Player.m_localPlayer; ZNet.instance.m_serverSyncedPlayerData["rm_base"] = localPlayer.GetBaseValue().ToString(); ZNet.instance.m_serverSyncedPlayerData["rm_biome"] = ((object)localPlayer.GetCurrentBiome()/*cast due to .constrained prefix*/).ToString(); ZNet.instance.m_serverSyncedPlayerData["rm_keys"] = string.Join(",", localPlayer.GetUniqueKeys()); } if (ZNet.instance.IsServer()) { _telemetryTimer += dt; if (_telemetryTimer >= 2f) { _telemetryTimer = 0f; string text = JsonUtility.ToJson((object)(LatestTelemetry = RaidManager.BuildServerTelemetry()), false); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RaidMaster_Telemetry", new object[1] { text }); } } } public static void SyncPeerOnJoin(ZNetPeer peer) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && peer != null) { bool flag = IsPeerAdmin(peer); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "RaidMaster_AdminStatus", new object[1] { flag }); ZPackage val = BuildCompressedPackage(RaidManager.SerializeDatabase()); ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "RaidMaster_SyncDatabase", new object[1] { val }); } } public static void PushDatabaseLive() { if (!((Object)(object)ZNet.instance == (Object)null)) { if (ZNet.instance.IsServer()) { RaidManager.SaveToDisk(); RaidManager.ApplyToRandEventSystem(); BroadcastDatabaseToAllClients(); } else { ZPackage val = BuildCompressedPackage(RaidManager.SerializeDatabase()); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RaidMaster_AdminPushDatabase", new object[1] { val }); } } } public static void SendTriggerRaid(TriggerRaidRequest req) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (!((Object)(object)ZNet.instance == (Object)null)) { if (ZNet.instance.IsServer()) { HandleTriggerRequestOnServer(req, ZRoutedRpc.instance.GetServerPeerID()); return; } ZPackage val = new ZPackage(); val.Write(JsonUtility.ToJson((object)req, false)); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RaidMaster_AdminTriggerRaid", new object[1] { val }); } } public static void SendStopRaid() { if ((Object)(object)ZNet.instance == (Object)null) { return; } if (ZNet.instance.IsServer()) { RandEventSystem instance = RandEventSystem.instance; if (instance != null) { instance.ResetRandomEvent(); } } else { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RaidMaster_AdminStopRaid", Array.Empty<object>()); } } public static void SendImportCfgRequest() { if (!((Object)(object)ZNet.instance == (Object)null)) { if (ZNet.instance.IsServer()) { int num = RaidManager.ImportCustomRaidsCfgFolder(); Plugin.Log.LogInfo((object)$"Imported {num} raids from {Plugin.ImportDir}."); BroadcastDatabaseToAllClients(); } else { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RaidMaster_RequestImport", Array.Empty<object>()); } } } public static void BroadcastNarrativeOverride(RaidDefinition tempDef) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { string text = JsonUtility.ToJson((object)tempDef, false); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RaidMaster_NarrativeOverride", new object[1] { text }); } } private static void BroadcastDatabaseToAllClients() { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { ZPackage val = BuildCompressedPackage(RaidManager.SerializeDatabase()); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RaidMaster_SyncDatabase", new object[1] { val }); } } private static void OnReceiveDatabaseFromServer(long sender, ZPackage pkg) { if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { return; } try { RaidManager.LoadFromJsonString(ReadCompressedPackage(pkg), saveToDisk: false); Plugin.Log.LogInfo((object)"Synced live RaidMaster database from server."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to unpack server RaidMaster database: {arg}"); } } private static void OnServerReceiveAdminPush(long sender, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } if (!IsSenderAdmin(sender)) { Plugin.Log.LogWarning((object)$"Rejected RaidMaster database push from non-admin peer {sender}."); return; } try { RaidManager.LoadFromJsonString(ReadCompressedPackage(pkg), saveToDisk: true); BroadcastDatabaseToAllClients(); Plugin.Log.LogInfo((object)$"Admin peer {sender} pushed live RaidMaster update to all clients."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to apply admin database push: {arg}"); } } private static void OnServerReceiveTriggerRequest(long sender, ZPackage pkg) { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } if (!IsSenderAdmin(sender)) { Plugin.Log.LogWarning((object)$"Rejected raid trigger from non-admin peer {sender}."); return; } TriggerRaidRequest triggerRaidRequest = JsonUtility.FromJson<TriggerRaidRequest>(pkg.ReadString()); if (triggerRaidRequest != null) { HandleTriggerRequestOnServer(triggerRaidRequest, sender); } } private static void HandleTriggerRequestOnServer(TriggerRaidRequest req, long sender) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(req.PosX, req.PosY, req.PosZ); if (!req.UseSenderPosition && !string.IsNullOrEmpty(req.TargetPlayerName)) { if ((Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.GetPlayerName().Equals(req.TargetPlayerName, StringComparison.OrdinalIgnoreCase)) { pos = ((Component)Player.m_localPlayer).transform.position; } else { ZNetPeer val = ((IEnumerable<ZNetPeer>)ZNet.instance.GetPeers()).FirstOrDefault((Func<ZNetPeer, bool>)((ZNetPeer p) => p?.m_playerName.Equals(req.TargetPlayerName, StringComparison.OrdinalIgnoreCase) ?? false)); if (val != null) { pos = val.m_refPos; } } } else if (req.UseSenderPosition && sender != ZRoutedRpc.instance.GetServerPeerID()) { ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer != null) { pos = peer.m_refPos; } } RaidManager.ExecuteRaidOnServer(RandEventSystem.instance, req.RaidName, pos, req); } private static void OnServerReceiveStopRequest(long sender) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && IsSenderAdmin(sender)) { RandEventSystem instance = RandEventSystem.instance; if (instance != null) { instance.ResetRandomEvent(); } Plugin.Log.LogInfo((object)$"Admin peer {sender} force-stopped the active raid."); } } private static void OnServerReceiveImportRequest(long sender) { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer() && IsSenderAdmin(sender)) { int num = RaidManager.ImportCustomRaidsCfgFolder(); Plugin.Log.LogInfo((object)$"Admin peer {sender} triggered CustomRaids .cfg import ({num} raids imported)."); BroadcastDatabaseToAllClients(); } } private static void OnClientReceiveAdminStatus(long sender, bool isAdmin) { LocalIsAdmin = isAdmin; if (isAdmin) { Plugin.Log.LogInfo((object)"Server verified RaidMaster Admin privileges."); } } private static void OnClientReceiveTelemetry(long sender, string json) { if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer()) { LiveTelemetry liveTelemetry = JsonUtility.FromJson<LiveTelemetry>(json); if (liveTelemetry != null) { LatestTelemetry = liveTelemetry; } } } private static void OnClientReceiveNarrativeOverride(long sender, string json) { if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer()) { RaidDefinition raidDefinition = JsonUtility.FromJson<RaidDefinition>(json); if (raidDefinition != null) { int skippedWaves = 0; RaidManager.ApplyTemporaryOverrideEvent(RaidManager.BuildRandomEvent(raidDefinition, ref skippedWaves)); } } } private static bool IsSenderAdmin(long sender) { if ((Object)(object)ZNet.instance == (Object)null) { return false; } if (sender == ZRoutedRpc.instance.GetServerPeerID()) { return true; } return IsPeerAdmin(ZNet.instance.GetPeer(sender)); } private static bool IsPeerAdmin(ZNetPeer peer) { if (peer == null || peer.m_socket == null || (Object)(object)ZNet.instance == (Object)null) { return false; } string hostName = peer.m_socket.GetHostName(); if (ZNet.instance.IsAdmin(hostName)) { return true; } if (ZNet.instance.m_adminList != null) { return ZNet.instance.m_adminList.Contains(hostName); } return false; } private static ZPackage BuildCompressedPackage(string text) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown byte[] bytes = Encoding.UTF8.GetBytes(text); using MemoryStream memoryStream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, leaveOpen: true)) { gZipStream.Write(bytes, 0, bytes.Length); } ZPackage val = new ZPackage(); val.Write(memoryStream.ToArray()); return val; } private static string ReadCompressedPackage(ZPackage pkg) { using MemoryStream stream = new MemoryStream(pkg.ReadByteArray()); using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); gZipStream.CopyTo(memoryStream); return Encoding.UTF8.GetString(memoryStream.ToArray()); } } } namespace RaidMaster.Models { public static class DefaultRaidPresets { private static readonly List<string> AllLandBiomes = new List<string> { "Meadows", "BlackForest", "Swamp", "Mountain", "Plains", "Mistlands", "AshLands", "DeepNorth" }; public static RaidDatabase BuildDefaultDatabase() { RaidDatabase obj = new RaidDatabase { SchemaVersion = 1, Global = new GlobalRaidSettings { AutoRaidsPaused = false, UseIndividualRaidChecks = false, CheckIntervalMinutes = 15f, TriggerChancePercent = 50f, MinCooldownMinutes = 15f, Progression = ProgressionMode.PlayerKeys, SiegeBreaker = SiegeBreakerMode.Off, OverrideGlobalSpawnRadius = false, GlobalSpawnRadiusMin = 40f, GlobalSpawnRadiusMax = 80f, KeepVanillaNonRandomEvents = true }, Raids = new List<RaidDefinition>() }; AddStandardSplitRaids(obj.Raids); AddVeteranEscalations(obj.Raids); AddWildernessAmbushes(obj.Raids); AddApocalypseRaids(obj.Raids);