ISpawner Interface
Implementation in BaseCreature methods do provide support for ISpawner interfaces, it defaults to SpawnEntry. This logic makes the ISpawner interface useless for custom spawners, even if implemented correctly. The following changes properly call Remove( object ), and implement UnlinkOnTaming checks to all ISpawner interfaces.
Changed to ..
It's also true for BaseCreature.OnRegionChange(), however support would require changes for ISpawner, and SpawnEntry. The issue is the highlighted portion, where ISpawner does not support Region, but SpawnEntry does.
The last change propagates other changes, cases where BaseRegion needs to be changed to Region. (SpawnEntry & SpawnDefinition)
4 Files are modified by the following patch diff:
BaseCreature.cs
Region.cs
SpawnEntry.cs
SpawnDefinition.cs
I'm not sure if the second set of changes to ISpawner is the right way to go, but there needs to be some way to use ISpawner instead of SpawnEntry.
Implementation in BaseCreature methods do provide support for ISpawner interfaces, it defaults to SpawnEntry. This logic makes the ISpawner interface useless for custom spawners, even if implemented correctly. The following changes properly call Remove( object ), and implement UnlinkOnTaming checks to all ISpawner interfaces.
Code:
public bool SetControlMaster( Mobile m )
{
....
[COLOR="Red"]SpawnEntry se = this.Spawner as SpawnEntry;
if ( se != null && se.UnlinkOnTaming )[/COLOR]
{
this.Spawner.Remove( this );
this.Spawner = null;
}
....
Changed to ..
Code:
public bool SetControlMaster( Mobile m )
{
....
[COLOR="SeaGreen"]if ( Spawner != null && Spawner.UnlinkOnTaming )[/COLOR]
{
this.Spawner.Remove( this );
this.Spawner = null;
}
....
It's also true for BaseCreature.OnRegionChange(), however support would require changes for ISpawner, and SpawnEntry. The issue is the highlighted portion, where ISpawner does not support Region, but SpawnEntry does.
Code:
public override void OnRegionChange( Region Old, Region New )
{
base.OnRegionChange( Old, New );
if ( this.Controlled )
{
ISpawner spawner = this.Spawner as ISpawner;
if ( spawner != null && !spawner.UnlinkOnTaming && ( New == null || [COLOR="DeepSkyBlue"]!New.AcceptsSpawnsFrom( spawner.Region )[/COLOR] ) )
{
this.Spawner.Remove( this );
this.Spawner = null;
}
}
}
Code:
public interface ISpawner
{
bool UnlinkOnTaming{ get; }
Point3D Home{ get; }
int Range{ get; }
[COLOR="DeepSkyBlue"]Region Region{ get; }[/COLOR]
void Remove( object spawn );
}
The last change propagates other changes, cases where BaseRegion needs to be changed to Region. (SpawnEntry & SpawnDefinition)
4 Files are modified by the following patch diff:
BaseCreature.cs
Region.cs
SpawnEntry.cs
SpawnDefinition.cs
I'm not sure if the second set of changes to ISpawner is the right way to go, but there needs to be some way to use ISpawner instead of SpawnEntry.