Upgrades spawners to have parameters/properties and optimized timers (#6)

Upgrades spawners to have:
- [X] Parameter support
- [X] Property support
- [X] Optimized timers
- [X] Support for Proximity Spawners
- [X] Probabilities
This commit is contained in:
Kamron Batman 2018-02-20 22:33:25 -08:00 • committed by GitHub
parent 20ae1b3989
commit 1030bb7675
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1043 additions and 735 deletions

View file

@ -27,6 +27,7 @@ namespace Server
Serial Serial{ get; }
Point3D Location{ get; }
Map Map{ get; }
void MoveToWorld(Point3D location, Map map);
bool Deleted { get; }
void Delete();
@ -105,6 +106,12 @@ namespace Server
}
}
public virtual void MoveToWorld(Point3D newLocation, Map map)
{
m_Location = newLocation;
m_Map = map;
}
public bool Deleted {
get {
return m_Deleted;
@ -119,4 +126,4 @@ namespace Server
{
}
}
}
}

View file

@ -101,6 +101,7 @@ namespace Server
bool UnlinkOnTaming { get; }
Point3D HomeLocation { get; }
int HomeRange { get; }
Region Region { get; }
void Remove(ISpawnable spawn);
}
@ -108,9 +109,8 @@ namespace Server
public interface ISpawnable : IEntity
{
void OnBeforeSpawn(Point3D location, Map map);
void MoveToWorld(Point3D location, Map map);
void OnAfterSpawn();
ISpawner Spawner { get; set; }
}
}
}

View file

@ -63,6 +63,7 @@ namespace Server
public abstract Rectangle3D ReadRect3D();
public abstract Map ReadMap();
public abstract IEntity ReadEntity();
public abstract Item ReadItem();
public abstract Mobile ReadMobile();
public abstract BaseGuild ReadGuild();
@ -134,6 +135,7 @@ namespace Server
public abstract void Write( Rectangle3D value );
public abstract void Write( Map value );
public abstract void WriteEntity( IEntity value );
public abstract void Write( Item value );
public abstract void Write( Mobile value );
public abstract void Write( BaseGuild value );
@ -189,7 +191,7 @@ namespace Server
public abstract void WriteGuildSet<T>( HashSet<T> set ) where T : BaseGuild;
public abstract void WriteGuildSet<T>( HashSet<T> set, bool tidy ) where T : BaseGuild;
// Compiler won't notice their 'where' to differentiate the generic methods.
// Compiler won't notice there 'where' to differentiate the generic methods.
}
public class BinaryFileWriter : GenericWriter
@ -591,6 +593,14 @@ namespace Server
Write( (byte)0xFF );
}
public override void WriteEntity( IEntity value )
{
if ( value == null || value.Deleted )
Write( Serial.MinusOne );
else
Write( value.Serial );
}
public override void Write( Item value )
{
if( value == null || value.Deleted )
@ -1126,6 +1136,16 @@ namespace Server
return Map.Maps[ReadByte()];
}
public override IEntity ReadEntity()
{
Serial serial = ReadInt();
IEntity entity = World.FindEntity( serial );
if ( entity == null )
return new Entity( serial, new Point3D( 0, 0, 0 ), Map.Internal );
else
return entity;
}
public override Item ReadItem()
{
return World.FindItem( ReadInt() );
@ -1725,6 +1745,14 @@ namespace Server
Write( (byte)0xFF );
}
public override void WriteEntity( IEntity value )
{
if ( value == null || value.Deleted )
Write( Serial.MinusOne );
else
Write( value.Serial );
}
public override void Write( Item value )
{
if( value == null || value.Deleted )