#W# Spawn: Dungeon traps and chests are done. Finished up TerathanKeep also. Also added a TaskManager script.
This commit is contained in:
parent
e5029166e2
commit
f961f484a5
15 changed files with 2807 additions and 905 deletions
101
Projects/UOContent/Engines/TaskManager.cs
Normal file
101
Projects/UOContent/Engines/TaskManager.cs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
using Server.Engines.Spawners;
|
||||
|
||||
namespace Server.Engines.Tasks;
|
||||
|
||||
public static class TaskManager
|
||||
{
|
||||
private static Timer _timer30Min;
|
||||
private static Timer _timer1Hour;
|
||||
private static Timer _timer24Hour;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
// 30-Minute Recurring Timer
|
||||
_timer30Min = Timer.DelayCall(TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(30), () => On30MinuteTick(null));
|
||||
|
||||
// 1-Hour Recurring Timer
|
||||
_timer1Hour = Timer.DelayCall(TimeSpan.FromHours(1), TimeSpan.FromHours(1), () => On1HourTick(null));
|
||||
|
||||
// 24-Hour Recurring Timer
|
||||
_timer24Hour = Timer.DelayCall(TimeSpan.FromHours(24), TimeSpan.FromHours(24), () => On24HourTick(null));
|
||||
|
||||
// Register developer commands for manual testing
|
||||
CommandSystem.Register("ForceTask30", AccessLevel.Developer, e => On30MinuteTick(e.Mobile));
|
||||
CommandSystem.Register("ForceTask1H", AccessLevel.Developer, e => On1HourTick(e.Mobile));
|
||||
CommandSystem.Register("ForceTask24H", AccessLevel.Developer, e => On24HourTick(e.Mobile));
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 30-MINUTE INTERVAL LOGIC (Trap Reshuffle)
|
||||
// ==========================================
|
||||
public static void On30MinuteTick(Mobile from = null)
|
||||
{
|
||||
//RespawnTrapSpawners(from);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 1-HOUR INTERVAL LOGIC
|
||||
// ==========================================
|
||||
public static void On1HourTick(Mobile from = null)
|
||||
{
|
||||
// Add hourly tasks here
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 24-HOUR INTERVAL LOGIC
|
||||
// ==========================================
|
||||
public static void On24HourTick(Mobile from = null)
|
||||
{
|
||||
// Add daily tasks here
|
||||
}
|
||||
|
||||
private static void RespawnTrapSpawners(Mobile from = null)
|
||||
{
|
||||
List<RegionSpawner> trapSpawners = World.Items.Values
|
||||
.OfType<RegionSpawner>()
|
||||
.Where(spawner => spawner.Running && IsTrapSpawner(spawner))
|
||||
.ToList();
|
||||
|
||||
foreach (RegionSpawner spawner in trapSpawners)
|
||||
{
|
||||
spawner.Respawn();
|
||||
}
|
||||
|
||||
string logMsg = $"[TaskManager] Successfully respawned {trapSpawners.Count} trap region spawners.";
|
||||
|
||||
if (from != null)
|
||||
{
|
||||
from.SendMessage(0x35, logMsg);
|
||||
}
|
||||
|
||||
Utility.PushColor(ConsoleColor.Green);
|
||||
Console.WriteLine(logMsg);
|
||||
Utility.PopColor();
|
||||
}
|
||||
|
||||
private static bool IsTrapSpawner(RegionSpawner spawner)
|
||||
{
|
||||
if (spawner.Name != null && spawner.Name.Contains("Trap", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spawner.Entries != null)
|
||||
{
|
||||
foreach (var entry in spawner.Entries)
|
||||
{
|
||||
if (entry.SpawnedName != null && entry.SpawnedName.Contains("Trap", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,10 @@ namespace Server.Gumps
|
|||
y += 30;
|
||||
|
||||
AddButton(20, y, 4005, 4007, 4, GumpButtonType.Reply, 0);
|
||||
AddLabel(55, y, 1152, "Generate Traps and Chests (Json)");
|
||||
y += 30;
|
||||
|
||||
AddButton(20, y, 4005, 4007, 5, GumpButtonType.Reply, 0);
|
||||
AddLabel(55, y, 1152, "Wipe Wild Creatures (Cleanup)");
|
||||
y += 30;
|
||||
|
||||
|
|
@ -107,7 +111,11 @@ namespace Server.Gumps
|
|||
InvokeCommand("IS Data/Spawns/Overworld/**.json", from);
|
||||
InvokeCommand("IS Data/Spawns/Underworld/**.json", from);
|
||||
break;
|
||||
case 4: InvokeCommand("WipeWildMobs", from); break;
|
||||
case 4:
|
||||
InvokeCommand("IS Data/Spawns/traps.json", from);
|
||||
InvokeCommand("IS Data/Spawns/Chests/**.json", from);
|
||||
break;
|
||||
case 5: InvokeCommand("WipeWildMobs", from); break;
|
||||
|
||||
case 7:
|
||||
InvokeCommand("ClearAll", from);
|
||||
|
|
@ -123,6 +131,8 @@ namespace Server.Gumps
|
|||
InvokeCommand("Decorate", from);
|
||||
InvokeCommand("IS Data/Spawns/Overworld/**.json", from);
|
||||
InvokeCommand("IS Data/Spawns/Underworld/**.json", from);
|
||||
InvokeCommand("IS Data/Spawns/traps.json", from);
|
||||
InvokeCommand("IS Data/Spawns/Chests/**.json", from);
|
||||
|
||||
from.SendMessage(0x3F, "World population complete.");
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue