I'll perform a forensic analysis of the RaidableBases plugin to identify potential performance issues and resource-intensive operations. Let me examine the code systematically. Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Ran tool Ran tool Read file: c:\Temp\RaidableBases.cs Based on my forensic analysis of the RaidableBases plugin, I've identified several critical performance issues that are likely causing the lag and bandwidth problems you're experiencing. Here's my comprehensive findings: ## **CRITICAL PERFORMANCE ISSUES IDENTIFIED** ### **1. MASSIVE GRID GENERATION (Lines 600-700)** ```csharp for (float x = minPos; x < maxPos; x += CELL_SIZE) // Credits to Jake_Rich for helping me with this! { for (float z = minPos; z < maxPos; z += CELL_SIZE) { // This creates a massive grid across the entire world // For a 4500x4500 world, this creates ~130,000 potential spawn points } } ``` **Impact**: This creates an enormous grid of potential spawn locations across the entire world map, consuming massive memory and CPU resources. ### **2. FREQUENT COROUTINE EXECUTION (Lines 1050-1100)** ```csharp private IEnumerator FindEventPosition() { while (!Instance.IsUnloading) { if (++checks >= spawnChecks) { yield return instruction0; // 0.1 second delays checks = 0; } // Continuous loop checking for spawn positions } } ``` **Impact**: This runs continuously with very short delays (0.1 seconds), constantly consuming CPU cycles. ### **3. ELEVATOR UI SPAM (Lines 1780-1820)** ```csharp if (options.Enabled) { InvokeRepeating(ShowHealthUI, 10, 1); // Runs every 1 second } ``` **Impact**: Each elevator runs UI updates every second for all nearby players, creating constant UI spam and network traffic. ### **4. BROADCAST MESSAGES TO ALL PLAYERS (Lines 1030-1040)** ```csharp if (config.EventMessages.AnnounceBuy) { foreach (var target in BasePlayer.activePlayerList) { Message(target, "BuyBaseAnnouncement", rb.owner.displayName, rb.Position, Instance.FormatGridReference(target, rb.Position)); } } ``` **Impact**: Sends messages to ALL online players whenever a base is spawned, creating unnecessary network traffic. ### **5. CONTINUOUS AUTOMATED SPAWNING (Lines 1500-1600)** ```csharp private IEnumerator MaintainCoroutine() { while (!Instance.IsUnloading) { // Continuous spawning logic yield return instruction5; // 5 second delays } } ``` **Impact**: Runs continuously with 5-second intervals, constantly trying to spawn new bases. ### **6. PHYSICS RAYCASTS IN ELEVATORS (Lines 1720-1740)** ```csharp if (!Physics.Raycast(serverPosition, Vector3.up, out hit, 21f) || (hitEntity = hit.GetEntity()).IsNull()) { return; } ``` **Impact**: Multiple physics raycasts per elevator movement, which can be expensive when many elevators are active. ## **RECOMMENDED OPTIMIZATIONS** ### **Immediate Fixes:** 1. **Increase Coroutine Delays:** - Change `instruction0` from 0.1s to 1.0s - Change `instruction5` from 5s to 15s - Change elevator UI updates from 1s to 5s 2. **Limit Grid Generation:** - Reduce `CELL_SIZE` from 12.5f to 25f or 50f - Add maximum spawn point limits 3. **Optimize Player Broadcasting:** - Only send announcements to players within a certain radius - Use server-wide announcements sparingly 4. **Add Performance Checks:** - Monitor frame rate and pause operations when FPS drops - Implement maximum concurrent base limits ### **Configuration Recommendations:** ```csharp // Add these settings to your config "Performance": { "MaxConcurrentBases": 5, "MaxSpawnPoints": 1000, "CoroutineDelay": 2.0, "ElevatorUIDelay": 5.0, "AnnouncementRadius": 1000.0 } ``` ### **Memory Management Issues:** 1. **Large Collections**: The plugin maintains massive dictionaries and lists that grow over time 2. **Unused Coroutines**: Many coroutines may not be properly cleaned up 3. **UI Memory Leaks**: Elevator UI elements may not be properly disposed ## **IMMEDIATE ACTION ITEMS:** 1. **Disable automated spawning temporarily** to test if it resolves the lag 2. **Reduce the number of concurrent bases** to 2-3 maximum 3. **Increase all timer delays** by 3-5x 4. **Monitor server performance** with these changes 5. **Consider disabling elevators** if they're not essential The plugin is extremely resource-intensive due to its continuous spawning system and massive grid generation. The combination of frequent coroutines, physics calculations, and UI updates creates a perfect storm for performance issues. Would you like me to help you implement any of these optimizations or create a performance monitoring system for the plugin?