Initial commit
This commit is contained in:
Executable
+75
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Mobiles;
|
||||
using Server.Regions;
|
||||
|
||||
namespace Server.CustomSystems
|
||||
{
|
||||
public static class RoyalMintSpawner
|
||||
{
|
||||
private static bool _initialized = false;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_initialized)
|
||||
return;
|
||||
|
||||
_initialized = true;
|
||||
|
||||
EventSink.WorldLoad += new WorldLoadEventHandler(OnWorldLoad);
|
||||
EventSink.WorldSave += new WorldSaveEventHandler(OnWorldSave);
|
||||
}
|
||||
|
||||
private static void OnWorldLoad()
|
||||
{
|
||||
SpawnOfficials();
|
||||
}
|
||||
|
||||
private static void OnWorldSave(WorldSaveEventArgs e)
|
||||
{
|
||||
SpawnOfficials();
|
||||
}
|
||||
|
||||
private static void SpawnOfficials()
|
||||
{
|
||||
foreach (Map map in Map.AllMaps)
|
||||
{
|
||||
if (map == null || map == Map.Internal)
|
||||
continue;
|
||||
|
||||
foreach (Region region in map.Regions.Values)
|
||||
{
|
||||
if (region == null || region.Name == null)
|
||||
continue;
|
||||
|
||||
if (!region.Name.ToLower().Contains("bank"))
|
||||
continue;
|
||||
|
||||
// Check if one already exists
|
||||
bool exists = false;
|
||||
|
||||
foreach (Mobile m in World.Mobiles.Values)
|
||||
{
|
||||
if (m is RoyalMintOfficial && m.Map == map && region.Contains(m.Location))
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
Point3D loc = region.Area.Length > 0
|
||||
? region.Area[0].Start
|
||||
: new Point3D(0, 0, 0);
|
||||
|
||||
var npc = new RoyalMintOfficial();
|
||||
npc.MoveToWorld(loc, map);
|
||||
|
||||
Console.WriteLine("[RoyalMint] Spawned Mint Official at " + region.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user