private void SpawnOne()
{
// Create NPC
var creature = new NPC(this.RaceId);
// Warp to spawn point
var pos = this.GetRandomPosition();
if (!creature.Warp(this.RegionId, pos.X, pos.Y))
{
Log.Error("CreatureSpawner: Failed to spawn '{0}'s, region '{1}' doesn't exist.", this.RaceId, this.RegionId);
return;
}
// Save spawn location
creature.SpawnLocation = new Location(this.RegionId, pos.X, pos.Y);
// Random title
if (_titles != null && _titles.Length != 0)
{
var title = (ushort)(_titles[RandomProvider.Get().Next(_titles.Length)]);
if (title != 0)
{
creature.Titles.Enable(title);
creature.Titles.ChangeTitle(title, false);
}
}
// Maintenance
creature.SpawnId = this.Id;
creature.Disappears += this.OnDisappears;
// Add to list to keep track of all creatures
lock (_creatures)
_creatures.Add(creature);
}