namespace Server.Engines.Spawners;
public abstract partial class BaseSpawner
{
///
/// Called after the timer starts (Start(), Running = true, NextSpawn on a stopped spawner).
/// Not called for construction (InitSpawn) or deserialization; subclasses initialise
/// run state in their constructor and [AfterDeserialization].
///
protected virtual void OnStarted()
{
}
/// Called after the timer stops (Stop(), Running = false), and only if it was running.
protected virtual void OnStopped()
{
}
/// Veto point before an entry's entity is constructed. Return false to skip this attempt.
protected virtual bool OnBeforeSpawn(SpawnerEntry entry) => true;
///
/// Runs after property application and before positioning, so computed properties apply first.
/// The entity is not yet in , has no Spawner set, and is still on
/// the internal map.
///
protected virtual void OnConfigureSpawned(SpawnerEntry entry, ISpawnable spawned)
{
}
/// Entry-aware positioning. Default delegates to the entry-agnostic overload.
protected virtual Point3D GetSpawnPosition(SpawnerEntry entry, ISpawnable spawned, Map map) =>
GetSpawnPosition(spawned, map);
/// Runs after the entity is in the world and linked to this spawner.
protected virtual void OnSpawned(SpawnerEntry entry, ISpawnable spawned)
{
}
/// A spawned creature died (before base death deletes it and unlinks the spawner).
protected virtual void OnSpawnedDeath(SpawnerEntry entry, ISpawnable spawned, Mobile killer)
{
}
/// Entry point for BaseCreature.OnDeath. Resolves the entry and dispatches the hook.
public void NotifySpawnedDeath(ISpawnable spawned, Mobile killer)
{
if (spawned != null && Spawned != null && Spawned.TryGetValue(spawned, out var entry))
{
OnSpawnedDeath(entry, spawned, killer);
}
}
}