Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Threading;
- using ConquerServer.Network;
- namespace ConquerServer.Features
- {
- public class FloorCleaner
- {
- private const int CleanIntervalSeconds = 300;
- private static Timer _cleanTimer;
- /// <summary>
- /// Timer ⌛ Conquer Lab Page
- /// </summary>
- public static void Initialize()
- {
- _cleanTimer = new Timer(CleanFloor, null, CleanIntervalSeconds * 1000, CleanIntervalSeconds * 1000);
- Console.WriteLine("[System]: Auto Floor Cleaner initialized.");
- }
- private static void CleanFloor(object state)
- {
- int itemsRemoved = 0;
- // All (Maps)
- foreach (var map in Kernel.Maps.Values)
- {
- foreach (var item in map.FloorItems.Values.ToList())
- {
- if (map.RemoveFloorItem(item))
- {
- itemsRemoved++;
- }
- }
- }
- // (Global Message) Players
- if (itemsRemoved > 0)
- {
- Kernel.SendGlobalMessage($"[System]: {itemsRemoved} items cleaned from the floor to reduce lag.", MsgTalk.Channel.Service, MsgTalk.Color.Red);
- Console.WriteLine($"[System]: Floor cleaned. Removed {itemsRemoved} items.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment