本文整理汇总了C#中Server.Map.GetObjectsInBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetObjectsInBounds方法的具体用法?C# Map.GetObjectsInBounds怎么用?C# Map.GetObjectsInBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Map
的用法示例。
在下文中一共展示了Map.GetObjectsInBounds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTarget
public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
{
try
{
object[] states = (object[]) state;
BaseCommand command = (BaseCommand) states[0];
string[] args = (string[]) states[1];
ObjectConditional cond = ObjectConditional.Parse( from, ref args );
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
bool items, mobiles;
if ( !CheckObjectTypes( command, cond, out items, out mobiles ) )
{
return;
}
IEnumerable<object> eable;
if ( items && mobiles )
{
eable = map.GetObjectsInBounds( rect );
}
else if ( items )
{
eable = map.GetItemsInBounds( rect );
}
else if ( mobiles )
{
eable = map.GetMobilesInBounds( rect );
}
else
{
return;
}
ArrayList objs = new ArrayList();
foreach ( object obj in eable )
{
if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
{
continue;
}
if ( cond.CheckCondition( obj ) )
{
objs.Add( obj );
}
}
RunCommand( from, objs, command, args );
}
catch ( Exception ex )
{
from.SendMessage( ex.Message );
}
}
示例2: DoWipe
public static void DoWipe( Mobile from, Map map, Point3D start, Point3D end, WipeType type )
{
CommandLogging.WriteLine( from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format( from ), start, end, type, map );
bool mobiles = ( ( type & WipeType.Mobiles ) != 0 );
bool multis = ( ( type & WipeType.Multis ) != 0 );
bool items = ( ( type & WipeType.Items ) != 0 );
ArrayList toDelete = new ArrayList();
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
IEnumerable<object> eable;
if ( ( items || multis ) && mobiles )
{
eable = map.GetObjectsInBounds( rect );
}
else if ( items || multis )
{
eable = map.GetItemsInBounds( rect );
}
else if ( mobiles )
{
eable = map.GetMobilesInBounds( rect );
}
else
{
return;
}
foreach ( object obj in eable )
{
if ( items && ( obj is Item ) && !( ( obj is BaseMulti ) || ( obj is HouseSign ) ) )
{
toDelete.Add( obj );
}
else if ( multis && ( obj is BaseMulti ) )
{
toDelete.Add( obj );
}
else if ( mobiles && ( obj is Mobile ) && !( (Mobile) obj ).IsPlayer )
{
toDelete.Add( obj );
}
}
for ( int i = 0; i < toDelete.Count; ++i )
{
if ( toDelete[i] is Item )
{
( (Item) toDelete[i] ).Delete();
}
else if ( toDelete[i] is Mobile )
{
( (Mobile) toDelete[i] ).Delete();
}
}
}
示例3: OnTarget
public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
{
try
{
if ( from.AccessLevel < MaxLengthOverride && Math.Max(end.X - start.X, end.Y - start.Y) > MaxLength )
{
from.SendMessage("Maximum bounding box size exceeded.");
return;
}
object[] states = (object[])state;
BaseCommand command = (BaseCommand)states[0];
string[] args = (string[])states[1];
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
Extensions ext = Extensions.Parse( from, ref args );
bool items, mobiles;
if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
return;
IPooledEnumerable eable;
if ( items && mobiles )
eable = map.GetObjectsInBounds( rect );
else if ( items )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else
return;
ArrayList objs = new ArrayList();
foreach ( object obj in eable )
{
if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
continue;
if ( ext.IsValid( obj ) )
objs.Add( obj );
}
eable.Free();
ext.Filter( objs );
RunCommand( from, objs, command, args );
}
catch ( Exception ex )
{
from.SendMessage( ex.Message );
}
}
示例4: OnTarget
public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
{
try
{
if (from.AccessLevel < MIN_MAX_EDGE_OVERRIDE_ACCESS_LEVEL &&
Math.Max(end.X - start.X, end.Y - start.Y) > MAX_EDGE_LENGTH)
{
from.SendMessage("Maximum bounding box size exceeded.");
return;
}
object[] states = (object[])state;
BaseCommand command = (BaseCommand)states[0];
string[] args = (string[])states[1];
ObjectConditional cond = ObjectConditional.Parse( from, ref args );
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
bool items, mobiles;
if ( !CheckObjectTypes( command, cond, out items, out mobiles ) )
return;
IPooledEnumerable eable;
if ( items && mobiles )
eable = map.GetObjectsInBounds( rect );
else if ( items )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else
return;
ArrayList objs = new ArrayList();
foreach ( object obj in eable )
{
if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
continue;
if ( cond.CheckCondition( obj ) )
objs.Add( obj );
}
eable.Free();
RunCommand( from, objs, command, args );
}
catch ( Exception ex )
{
from.SendMessage( ex.Message );
}
}
示例5: DoWipe
public static void DoWipe( Mobile from, Map map, Point3D start, Point3D end, WipeType type )
{
CommandLogging.WriteLine( from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format( from ), start, end, type, map );
bool mobiles = ( (type & WipeType.Mobiles) != 0 );
bool multis = ( (type & WipeType.Multis) != 0 );
bool items = ( (type & WipeType.Items) != 0 );
List<IEntity> toDelete = new List<IEntity>();
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
IPooledEnumerable eable;
if ( (items || multis) && mobiles )
eable = map.GetObjectsInBounds( rect );
else if ( items || multis )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else
return;
foreach ( IEntity obj in eable )
{
if ( items && (obj is Item) && ((Item)obj).CommandDelete && !((obj is BaseMulti) || (obj is HouseSign)) )
toDelete.Add( obj );
else if ( multis && (obj is BaseMulti) )
toDelete.Add( obj );
else if ( mobiles && (obj is Mobile) && !((Mobile)obj).Player )
toDelete.Add( obj );
}
eable.Free();
foreach (IEntity d in toDelete)
d.Delete();
}
示例6: CollectionBox_Callback
public static void CollectionBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
{
// Create rec and retrieve items within from bounding box callback
// result
Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
IPooledEnumerable eable = map.GetObjectsInBounds(rect);
Archive archive = state as Archive;
if (archive == null || archive.Deleted)
return;
// temp list for the items & Mobules we want to archive
ArrayList temp = new ArrayList();
// Loop through and add objects returned
foreach (object obj in eable)
{
Item item = obj as Item;
Mobile mobile = obj as Mobile;
if (item == null && mobile == null)
continue;
// no deleted items
if (item != null && (item.Deleted))
continue;
// no deleted items or players
if (mobile != null && (mobile.Deleted || mobile is Server.Mobiles.PlayerMobile))
continue;
// add the item to the temp storage
temp.Add(obj);
}
eable.Free();
// items this pass
int mCount = 0, iCount = 0;
foreach (object obj in temp)
{
Item item = obj as Item;
Mobile mobile = obj as Mobile;
if (item != null)
{ // move the item to the internal map at the original location
item.MoveItemToIntStorage(true);
// add the item to the archive
archive.AddItem(item);
iCount++;
}
else if (mobile != null)
{ // move the mobile to the internal map at the original location
mobile.MoveMobileToIntStorage(true);
// add the item to the archive
archive.AddMobile(mobile);
mCount++;
}
}
from.SendMessage("{0} items and {1} mobiles added to this archive.", iCount, mCount);
from.SendMessage("Archive now contains {0} objects total.", archive.ObjectCount);
}