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 ); } }
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(); } } }
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 ); } }
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 ); } }
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(); }
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); }