Adds better type support for pooled enumerables. Refactors code. (#16)

This commit is contained in:
Kamron Batman 2018-08-09 14:08:34 -07:00 • committed by GitHub
parent 62b95f4d74
commit b06f5bf60d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 252 additions and 243 deletions

View file

@ -251,16 +251,12 @@ namespace Server.Factions
bool mobs = type.IsSubclassOf( typeof( Mobile ) );
bool items = type.IsSubclassOf( typeof( Item ) );
IPooledEnumerable eable;
if ( mobs )
eable = mob.GetMobilesInRange( range );
else if ( items )
eable = mob.GetItemsInRange( range );
else
if ( !(items || mobs) )
return false;
foreach ( object obj in eable )
IPooledEnumerable<IEntity> eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs);
foreach ( IEntity obj in eable )
{
if ( type.IsAssignableFrom( obj.GetType() ) )
{
@ -275,15 +271,15 @@ namespace Server.Factions
public static bool IsNearType( Mobile mob, Type[] types, int range )
{
IPooledEnumerable eable = mob.GetObjectsInRange( range );
IPooledEnumerable<IEntity> eable = mob.GetObjectsInRange( range );
foreach( object obj in eable )
foreach( IEntity obj in eable )
{
Type objType = obj.GetType();
for( int i = 0; i < types.Length; i++ )
{
if( types[i].IsAssignableFrom( objType ) )
if ( types[i].IsAssignableFrom( objType ) )
{
eable.Free();
return true;
@ -1434,4 +1430,4 @@ namespace Server.Factions
}
}
}
}
}