public static Rectangle2D FixRect( Rectangle2D rect ) { Point3D pointOne = Point3D.Zero; Point3D pointTwo = Point3D.Zero; if ( rect.Start.X < rect.End.X ) { pointOne.X = rect.Start.X; pointTwo.X = rect.End.X; } else { pointOne.X = rect.End.X; pointTwo.X = rect.Start.X; } if ( rect.Start.Y < rect.End.Y ) { pointOne.Y = rect.Start.Y; pointTwo.Y = rect.End.Y; } else { pointOne.Y = rect.End.Y; pointTwo.Y = rect.Start.Y; } return new Rectangle2D( pointOne, pointTwo ); }
public GoldPrintCarpetAddon( Rectangle2D rect ) { for ( int x = 0; x < rect.Width; x++ ) for ( int y = 0; y < rect.Height; y++ ) { if ( y == 0 && x != 0 && x != rect.Width - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.Top ) ), x, y, 0 ); if ( y == rect.Height - 1 && x != 0 && x != rect.Width - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.Bottom ) ), x, y, 0 ); if ( x == 0 && y != 0 && y != rect.Height - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.Left ) ), x, y, 0 ); if ( x == rect.Width - 1 && y != 0 && y != rect.Height - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.Right ) ), x, y, 0 ); if ( y == 0 && x == 0 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.TopLeft ) ), x, y, 0 ); if ( y == 0 && x == rect.Width - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.TopRight ) ), x, y, 0 ); if ( y == rect.Height - 1 && x == 0 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.BottomLeft ) ), x, y, 0 ); if ( y == rect.Height - 1 && x == rect.Width - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.BottomRight ) ), x, y, 0 ); if ( y != 0 && x != 0 && x != rect.Width - 1 && y != rect.Height - 1 ) AddComponent( new AddonComponent( RugPieceId( RugPiece.Center ) ), x, y, 0 ); } Hue = 1710; // Set Hue of Rug Here }
public TheHuntRegion(TheHuntStone pTheHuntStone, string name, Map map, Rectangle2D[] area) : base(name, map, 50, area) { this.TheHuntStone = pTheHuntStone; this.playerMobileBackupList = new List<Mobile>(); }
public PresetMapEntry( int name, int width, int height, int xLeft, int yTop, int xRight, int yBottom ) { m_Name = name; m_Width = width; m_Height = height; m_Bounds = new Rectangle2D( xLeft, yTop, xRight - xLeft, yBottom - yTop ); }
public CorgulWarpRegion(CorgulAltar ped, Rectangle2D rec) : base("Corgul Warp Region", ped.Map, Region.DefaultPriority, new Rectangle2D[] { rec }) { m_Pedestal = ped; m_Bounds = rec; //MarkBounds(rec); }
public CorgulRegion(Rectangle2D rec, CorgulAltar altar) : base("Corgul Boss Region", altar.Map, Region.DefaultPriority, new Rectangle2D[] { rec }) { //MarkBounds(rec); m_Altar = altar; m_Bounds = rec; }
public static void OnExportBounds2D(Mobile m, string speech) { if (m == null || m.Deleted || !(m is PlayerMobile)) { return; } if (String.IsNullOrWhiteSpace(speech)) { speech = TimeStamp.UtcNow.ToString(); } BoundingBoxPicker.Begin( m, (from, map, start, end, state) => { var r = new Rectangle2D(start, end.Clone3D(1, 1)); using ( StreamWriter w = IOUtility.EnsureFile( VitaNexCore.DataDirectory + "/Exported Bounds/2D/" + IOUtility.GetSafeFileName(speech) + ".txt").AppendText()) { w.WriteLine("new Rectangle2D({0}, {1}, {2}, {3}),", r.Start.X, r.Start.Y, r.Width, r.Height); w.Close(); } }, null); }
public override void OnExit( Mobile m ) { if ( m.IsPlayer && !m.Alive ) { Rectangle2D rect = new Rectangle2D( 342, 168, 16, 16 ); int x = Utility.Random( rect.X, rect.Width ); int y = Utility.Random( rect.Y, rect.Height ); if ( x >= 345 && x <= 352 && y >= 173 && y <= 179 ) { x = 353; y = 172; } m.MoveToWorld( new Point3D( x, y, -1 ), Map.Malas ); if ( m.Corpse != null ) { Region region = Region.Find( m.Corpse.Location, Map.Malas ); if ( region.Name == "Doom Dark Guardians Room" ) { m.Corpse.MoveToWorld( new Point3D( x, y, -1 ), Map.Malas ); } } } }
public override void SetDisplay(int x1, int y1, int x2, int y2, int w, int h) { Width = w; Height = h; Bounds = new Rectangle2D(5121 ,2305, 1020, 1788); }
public void MarkBounds(Rectangle2D rec) { m_Markers = new List<Item>(); int w = rec.X + rec.Width; int h = rec.Y + rec.Height; int t = 0; for (int x = rec.X; x <= w; x++) { for (int y = rec.Y; y <= h; y++) { if (x == rec.X || x == rec.X + rec.Width || y == rec.Y || y == rec.Y + rec.Height) { if (t >= 10) { MarkerItem i = new MarkerItem(14089); i.MoveToWorld(new Point3D(x, y, 0), this.Map); m_Markers.Add(i); t = 0; } else t++; } } } }
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 override void CraftInit( Mobile from ) { // Unlike the others, world map is not based on crafted location Facet = from.Map; double skillValue = from.Skills[SkillName.Cartography].Value; int x20 = (int)(skillValue * 20); int size = 25 + (int)(skillValue * 6.6); if ( size < 200 ) size = 200; else if ( size > 400 ) size = 400; if (Facet == Map.Trammel || Facet == Map.Felucca) { if (Server.Spells.SpellHelper.IsAnyT2A(Facet, from.Location)) { Bounds = new Rectangle2D(5120, 2304, 1024, 1792); Width = size; Height = size; } else SetDisplay(1344 - x20, 1600 - x20, 1472 + x20, 1728 + x20, size, size); } else SetDisplayByFacet(); }
public void Ensure() { m_Blocks = new List<Item>(); foreach ( Rectangle3D r3d in Area ) { Rectangle2D r2d = new Rectangle2D( r3d.Start, r3d.End ); foreach ( Item item in Map.GetItemsInBounds( r2d ) ) { if ( item is Static ) m_Blocks.Add( item ); } } if ( m_Blocks.Count == 0 ) { m_Blocks = null; return; } foreach ( Item item in m_Blocks ) { item.Hue = 0x807; item.Visible = false; } m_FadingTimer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 0.33 ), new TimerCallback( OnTick ) ); }
public static void OnExportBounds2D(Mobile m, string speech, string comment) { if (m == null || m.Deleted || !(m is PlayerMobile)) { return; } if (String.IsNullOrWhiteSpace(speech)) { speech = "Bounds"; } BoundingBoxPicker.Begin( m, (from, map, start, end, state) => { var r = new Rectangle2D(start, end.Clone2D(1, 1)); IOUtility.EnsureFile( VitaNexCore.DataDirectory + "/Exported Bounds/2D/" + IOUtility.GetSafeFileName(speech) + ".txt") .AppendText( false, String.Format( "new Rectangle2D({0}, {1}, {2}, {3}), //{4}", // r.Start.X, r.Start.Y, r.Width, r.Height, comment ?? String.Empty)); }, null); }
public static bool FindEntity( Type type, Point3D p, Map map, bool mob ) { IPooledEnumerable loc; Rectangle2D rect = new Rectangle2D( p.X, p.Y, 1, 1 ); if( mob ) loc = map.GetMobilesInBounds( rect ); else loc = map.GetItemsInBounds( rect ); bool found = false; try { foreach( object o in loc ) if( o != null && o.GetType() == type || o.GetType().IsSubclassOf( type ) ) { found = true; break; } } catch { } loc.Free(); return found; }
/*public override bool AllowReds{ get{ return true; } }*/ public SafeZone( Rectangle2D area, Point3D goloc, Map map ) : base(null, map, SafeZonePriority, area) { GoLocation = goloc; Register(); }
public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds ) { for ( int i = 0; i < m_Facets.Length; ++i ) { Rectangle2D area = new Rectangle2D(); bool isValid = false; for ( int j = 0; j < 10; ++j ) { area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height ); if ( !CheckWeatherConflict( m_Facets[i], null, area ) ) isValid = true; if ( isValid ) break; } if ( !isValid ) continue; Weather w = new Weather( m_Facets[i], new Rectangle2D[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) ); w.m_Bounds = bounds; w.m_MoveSpeed = moveSpeed; } }
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 RVSRegion(RVSController dc, Map RegionMap, Rectangle2D RegionPoint, String regionName) : base(String.Format("RVSRegion{0}", Count.ToString()), RegionMap, 100, RegionPoint) { Controller = dc; this.RegionName = regionName; this.Register(); Count += 1; }
public ChessControl() : base(3796) { Movable = false; Hue = 1285; Name = "Battle Chess"; m_Bounds = new Rectangle2D( 0, 0, 0, 0 ); }
public SafeZone( Rectangle2D area, Point3D goloc, Map map, bool isGuarded ) : base( null, map, SafeZonePriority, area ) { GoLocation = goloc; this.Disabled = !isGuarded; Register(); }
public SerpentPillar( string word, Rectangle2D destination, bool active ) : base( 0x233F ) { Movable = false; m_Active = active; m_Word = word; m_Destination = destination; }
public override void OnLocationChange( Point3D oldLocation ) { if ( !Enabled ) return; regionpoint = new Rectangle2D( X - 5, Y - 5, 11, 11 ); StartManaRegen(); }
private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state ) { Utility.FixPoints( ref start, ref end ); Rectangle2D rect = new Rectangle2D(start, end); #region MobileSaver from.SendMessage( "Extracting Mobiles" ); foreach ( Mobile m in map.GetMobilesInBounds( rect ) ) { if ( m != null && m is BaseCreature ) { int saveflag = MobileSaver.GetSaveFlag( m ); if ( saveflag > 0 ) { DesignItem designItem = new DesignItem(); designItem.ItemID = (short)0x1; designItem.X = m.X; designItem.Y = m.Y; designItem.Z = m.Z + saveflag; designItem.Hue = (short)m.Hue; } } } #endregion for ( int x = 0; x <= rect.Width; ++x ) { for ( int y = 0; y <= rect.Height; ++y ) { int tileX = rect.Start.X + x; int tileY = rect.Start.Y + y; Sector sector = map.GetSector( tileX, tileY ); for ( int i = 0; i < sector.Items.Count; ++i ) { Item item = (Item)sector.Items[i]; if(_args.UseMinZ && item.Z < _args.MinZ) continue; else if(_args.UseMaxZ && item.Z > _args.MaxZ) continue; if ( item.Visible && item.X == tileX && item.Y == tileY && !((item is BaseMulti) || (item is HouseSign)) ) { _itemSerials.Add(item.Serial.Value); } } } } if(_itemSerials.Count > 0) SendResponse(new SelectItemsResponse((int[])_itemSerials.ToArray(typeof(int)))); else SendResponse(null); }
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 static IEnumerable<Point2D> Intersect(Triangle2D t, Rectangle2D r) { return Line2D.Intersect( new[] {t._AB, t._BC, t._CA}, new[] { new Line2D(r.X, r.Y, r.X + r.Width, r.Y), new Line2D(r.X + r.Width, r.Y, r.X + r.Width, r.Y + r.Height), new Line2D(r.X, r.Y, r.X, r.Y + r.Height), new Line2D(r.X, r.Y + r.Height, r.X + r.Width, r.Y + r.Height) }); }
public MaginciaHousingPlot(string identifier, Rectangle2D bounds, bool prime, Map map) { m_Identifier = identifier; m_Bounds = bounds; m_IsPrimeSpot = prime; m_Map = map; m_Writ = null; m_Complete = false; m_Expires = DateTime.MinValue; }
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 PeerlessInstance( PeerlessPlatform platform, Map map, Item light, Point3D entranceLoc, Point3D bossSpawnLoc, Rectangle2D regionBounds ) { m_Owner = platform; m_Map = map; m_Light = light; m_EntranceLocation = entranceLoc; m_BossSpawnLocation = bossSpawnLoc; m_RegionBounds = regionBounds; Initialize(); }
public ChessRegion( Map map, ChessGame game, bool allowSpectators, Rectangle2D bounds, int height ) : base("Chessboard", map, 100, GetArea(bounds)) { m_Game = game; m_AllowSpectators = allowSpectators; // Make the region larger so that people can't cast invisibility outside m_Bounds = new Rectangle2D( bounds.X - 12, bounds.Y - 12, bounds.Width + 24, bounds.Height + 24 ); m_BoardBounds = bounds; m_Height = height; }
public static IEnumerable <NetState> SelectClients(Sector s, Rectangle2D bounds) { return(s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile.Location))); }
public static IEnumerable <IEntity> SelectEntities(Sector s, bool items, bool mobiles, Rectangle2D bounds) { var eable = Enumerable.Empty <IEntity>(); if (mobiles) { eable = eable.Union(s.Mobiles.Where(o => o?.Deleted == false)); } if (items) { eable = eable.Union(s.Items.Where(o => o?.Deleted == false && o.Parent == null)); } return(eable.Where(o => bounds.Contains(o.Location))); }
public static IEnumerable <IEntity> SelectEntities(Sector s, Rectangle2D bounds) => SelectEntities(s, true, true, bounds);
public static IEnumerable <T> SelectItems <T>(Sector s, Rectangle2D bounds) where T : Item { return(s.Items.OfType <T>() .Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o.Location))); }
public static IEnumerable <T> SelectMobiles <T>(Sector s, Rectangle2D bounds) where T : Mobile { return(s.Mobiles.OfType <T>().Where(o => !o.Deleted && bounds.Contains(o.Location))); }
public override void Write(Rectangle2D value) { this.Write(value.Start); this.Write(value.End); }
public bool LineOfSight(Point3D org, Point3D dest) { if (this == Map.Internal) { return(false); } if (!org.InRange(dest, m_MaxLOSDistance)) { return(false); } Point3D end = dest; if (org.X > dest.X || (org.X == dest.X && org.Y > dest.Y) || (org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z)) { Point3D swap = org; org = dest; dest = swap; } double rise, run, zslp; double sq3d; double x, y, z; int xd, yd, zd; int ix, iy, iz; int height; bool found; Point3D p; Point3DList path = m_PathList; TileFlag flags; if (org == dest) { return(true); } if (path.Count > 0) { path.Clear(); } xd = dest.X - org.X; yd = dest.Y - org.Y; zd = dest.Z - org.Z; zslp = Math.Sqrt(xd * xd + yd * yd); if (zd != 0) { sq3d = Math.Sqrt(zslp * zslp + zd * zd); } else { sq3d = zslp; } rise = ((float)yd) / sq3d; run = ((float)xd) / sq3d; zslp = ((float)zd) / sq3d; y = org.Y; z = org.Z; x = org.X; while (Utility.NumberBetween(x, dest.X, org.X, 0.5) && Utility.NumberBetween(y, dest.Y, org.Y, 0.5) && Utility.NumberBetween(z, dest.Z, org.Z, 0.5)) { ix = (int)Math.Round(x); iy = (int)Math.Round(y); iz = (int)Math.Round(z); if (path.Count > 0) { p = path.Last; if (p.X != ix || p.Y != iy || p.Z != iz) { path.Add(ix, iy, iz); } } else { path.Add(ix, iy, iz); } x += run; y += rise; z += zslp; } if (path.Count == 0) { return(true); // should never happen, but to be safe. } p = path.Last; if (p != dest) { path.Add(dest); } Point3D pTop = org, pBottom = dest; Utility.FixPoints(ref pTop, ref pBottom); int pathCount = path.Count; for (int i = 0; i < pathCount; ++i) { Point3D point = path[i]; Tile landTile = Tiles.GetLandTile(point.X, point.Y); int landZ = 0, landAvg = 0, landTop = 0; GetAverageZ(point.X, point.Y, ref landZ, ref landAvg, ref landTop); if (landZ <= point.Z && landTop >= point.Z && (point.X != end.X || point.Y != end.Y || landZ > end.Z || landTop < end.Z) && !landTile.Ignored) { return(false); } Tile[] statics = Tiles.GetStaticTiles(point.X, point.Y, true); bool contains = false; int ltID = landTile.ID; for (int j = 0; !contains && j < m_InvalidLandTiles.Length; ++j) { contains = (ltID == m_InvalidLandTiles[j]); } if (contains && statics.Length == 0) { foreach (Item item in GetItemsInRange(point, 0)) { if (item.Visible) { contains = false; } if (!contains) { break; } } if (contains) { return(false); } } for (int j = 0; j < statics.Length; ++j) { Tile t = statics[j]; ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; flags = id.Flags; height = id.CalcHeight; if (t.Z <= point.Z && t.Z + height >= point.Z && (flags & (TileFlag.Window | TileFlag.NoShoot)) != 0) { if (point.X == end.X && point.Y == end.Y && t.Z <= end.Z && t.Z + height >= end.Z) { continue; } return(false); } } } Rectangle2D rect = new Rectangle2D(pTop.X, pTop.Y, (pBottom.X - pTop.X) + 1, (pBottom.Y - pTop.Y) + 1); foreach (Item i in GetItemsInBounds(rect)) { if (!i.Visible) { continue; } if (i is BaseMulti || i.ItemID > TileData.MaxItemValue) { continue; } ItemData id = i.ItemData; flags = id.Flags; if ((flags & (TileFlag.Window | TileFlag.NoShoot)) == 0) { continue; } height = id.CalcHeight; found = false; int count = path.Count; for (int j = 0; j < count; ++j) { Point3D point = path[j]; Point3D loc = i.Location; if (loc.X == point.X && loc.Y == point.Y && loc.Z <= point.Z && loc.Z + height >= point.Z) { if (loc.X == end.X && loc.Y == end.Y && loc.Z <= end.Z && loc.Z + height >= end.Z) { continue; } found = true; break; } } if (!found) { continue; } return(false); } return(true); }
public abstract void Write(Rectangle2D value);
public static void GenerateAddon(Mobile from, Map map, Point3D start, Point3D end, object state) { if (state == null || !(state is string)) { return; } Rectangle2D bounds = new Rectangle2D(start, end); StringBuilder components = new StringBuilder(); StringBuilder specialcomponents = new StringBuilder(); // Now with 33% more automation! List <Item> items = new List <Item>(); int lowestX = 65555, lowestY = 65555; Item item = null; foreach (Item found in map.GetItemsInBounds(bounds)) { if (found != null) { items.Add(found); } } // Get X/Y for adjustment, not center it like normal addons. I like the positive only values for working with the file it's self. for (int i = 0; i < items.Count; i++) { if (items[i].X < lowestX) { lowestX = items[i].X; } if (items[i].Y < lowestY) { lowestY = items[i].Y; } } for (int i = 0; i < items.Count; i++) { item = items[i]; if (item is SleepingTreeAddon) { specialcomponents.Append(@" Components.Add( new SleepingTreeAddon() );" ); } else if (item is AddonComponentBarrier) { specialcomponents.Append(@" Components.Add( new AddonComponentBarrier() );" ); } else if (item is AddonComponentLever) { specialcomponents.Append(@" Components.Add( new AddonComponentBarrier() );" ); } else if (item is BaseDoor) { BaseDoor door = (BaseDoor)item; components.Append(String.Format(@" AddComponent( new DoorAddonComponent( new Point3D{0}, {1}, {2}, {3}, {4}, {5}, {6} ), {7}, {8}, {9} );" , door.Offset, door.ClosedID, door.OpenedID, door.ClosedSound, door.OpenedSound, door.Locked.ToString().ToLower(), door.Hue, (item.X - start.X - lowestX), (item.Y - start.Y - lowestY), item.Z)); } else { components.Append(String.Format(@" AddComponent( new HuedAddonComponent( {0}, {1} ), {2}, {3}, {4} );" , item.Hue, item.ItemID, (item.X - start.X), (item.Y - start.Y), item.Z)); } } components.Append(String.Format(@" ")); string file = String.Copy(Template); string name = (state as string); file = file.Replace("{nameaddon}", (name + "Addon")); file = file.Replace("{namedeed}", (name + "AddonDeed")); file = file.Replace("{components}", components.ToString()); file = file.Replace("{specialcomponents}", specialcomponents.ToString()); if (!Directory.Exists("Scripts.Workbench")) { Directory.CreateDirectory("Scripts.Workbench"); } if (!Directory.Exists("Scripts.Workbench/Addons")) { Directory.CreateDirectory("Scripts.Workbench/Addons"); } string filepath = "Scripts.Workbench/Addons/" + (state as string) + ".cs"; if (File.Exists(filepath)) { File.Delete(filepath); } StreamWriter sw = new StreamWriter(filepath); sw.Write(file.ToString()); sw.Close(); }
public static Rectangle3D ConvertTo3D(Rectangle2D rect) { return(new Rectangle3D(new Point3D(rect.Start, MinZ), new Point3D(rect.End, MaxZ))); }
public static void TileAdd(this MultiComponentList mcl, int itemID, Rectangle2D bounds, int z = 0, int d = 1) { TileAdd(mcl, itemID, bounds.ToRectangle3D(z, d)); }
public static Map.PooledEnumerable <T> GetItems <T>(Map map, Rectangle2D bounds) where T : Item => Map.PooledEnumerable <T> .Instantiate(map, bounds, SelectItems <T>);
public static Map.PooledEnumerable <StaticTile[]> GetMultiTiles(Map map, Rectangle2D bounds) => Map.PooledEnumerable <StaticTile[]> .Instantiate(map, bounds, MultiTileSelector ?? SelectMultiTiles);
public static int GetAverageZ(this Map map, Rectangle2D b) { return(GetAverageZ(map, b.EnumeratePoints())); }
public static Map.PooledEnumerable <BaseMulti> GetMultis(Map map, Rectangle2D bounds) => Map.PooledEnumerable <BaseMulti> .Instantiate(map, bounds, MultiSelector ?? SelectMultis);
public static int GetTopZ(this Rectangle2D b, Map map) { return(GetTopZ(map, b.EnumeratePoints())); }
public static Map.PooledEnumerable <Mobile> GetMobiles(Map map, Rectangle2D bounds) => GetMobiles <Mobile>(map, bounds);
public static void Delete(Rectangle2D region) { for (int rx = 0; rx < region.Width; ++rx) { for (int ry = 0; ry < region.Height; ++ry) { int vx = rx + region.X; int vy = ry + region.Y; StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(vx, vy); for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; int id = tile.ID; int z = tile.Z; if (IsWestFrame(id)) { if (IsEastFrame(vx + 2, vy, z)) { DeleteDoor(vx + 1, vy, z); } else if (IsEastFrame(vx + 3, vy, z)) { /*BaseDoor first = */ DeleteDoor(vx + 1, vy, z); /*BaseDoor second = */ DeleteDoor(vx + 2, vy, z); /*if (first != null && second != null) * { * first.Link = second; * second.Link = first; * } * else * { * if (first != null) * first.Delete(); * if (second != null) * second.Delete(); * }*/ } } else if (IsNorthFrame(id)) { if (IsSouthFrame(vx, vy + 2, z)) { DeleteDoor(vx, vy + 1, z); } else if (IsSouthFrame(vx, vy + 3, z)) { /*BaseDoor first = */ DeleteDoor(vx, vy + 1, z); /*BaseDoor second = */ DeleteDoor(vx, vy + 2, z); /*if (first != null && second != null) * { * first.Link = second; * second.Link = first; * } * else * { * if (first != null) * first.Delete(); * if (second != null) * second.Delete(); * }*/ } } } } } }
public static Map.PooledEnumerable <NetState> GetClients(Map map, Rectangle2D bounds) => Map.PooledEnumerable <NetState> .Instantiate(map, bounds, ClientSelector ?? SelectClients);
public static Map.PooledEnumerable <T> GetMobiles <T>(Map map, Rectangle2D bounds) where T : Mobile => Map.PooledEnumerable <T> .Instantiate(map, bounds, SelectMobiles <T>);
public static void Generate(Rectangle2D region) { for (int rx = 0; rx < region.Width; ++rx) { for (int ry = 0; ry < region.Height; ++ry) { int vx = rx + region.X; int vy = ry + region.Y; StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(vx, vy); for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; int id = tile.ID; int z = tile.Z; if (IsWestFrame(id)) { if (IsEastFrame(vx + 2, vy, z)) { AddDoor(vx + 1, vy, z, DoorFacing.WestCW); } else if (IsEastFrame(vx + 3, vy, z)) { BaseDoor first = AddDoor(vx + 1, vy, z, DoorFacing.WestCW); BaseDoor second = AddDoor(vx + 2, vy, z, DoorFacing.EastCCW); if (first != null && second != null) { first.Link = second; second.Link = first; } else { if (first != null) { first.Delete(); } if (second != null) { second.Delete(); } } } } else if (IsNorthFrame(id)) { if (IsSouthFrame(vx, vy + 2, z)) { AddDoor(vx, vy + 1, z, DoorFacing.SouthCW); } else if (IsSouthFrame(vx, vy + 3, z)) { BaseDoor first = AddDoor(vx, vy + 1, z, DoorFacing.NorthCCW); BaseDoor second = AddDoor(vx, vy + 2, z, DoorFacing.SouthCW); if (first != null && second != null) { first.Link = second; second.Link = first; } else { if (first != null) { first.Delete(); } if (second != null) { second.Delete(); } } } } } } } }
public static Map.PooledEnumerable <IEntity> GetEntities( Map map, Rectangle2D bounds, bool items = true, bool mobiles = true ) => Map.PooledEnumerable <IEntity> .Instantiate(map, bounds, EntitySelector ?? SelectEntities);
public void Write(Rectangle2D value) { Write(value.Start); Write(value.End); }
public static IEnumerable <BaseMulti> SelectMultis(Sector s, Rectangle2D bounds) { return(s.Multis.Where(o => o?.Deleted == false && bounds.Contains(o.Location))); }