Add() public méthode

public Add ( int itemID, int x, int y, int z ) : void
itemID int
x int
y int
z int
Résultat void
Exemple #1
0
 public static void TileAdd(this MultiComponentList mcl, int itemID, Rectangle3D bounds)
 {
     for (var z = bounds.Start.Z; z < bounds.End.Z; z++)
     {
         for (var x = bounds.Start.X; x < bounds.End.X; x++)
         {
             for (var y = bounds.Start.Y; y < bounds.End.Y; y++)
             {
                 mcl.Add(itemID, x, y, z);
             }
         }
     }
 }
        public MultiComponentList GetEmptyFoundation()
        {
            // Copy original foundation layout
            MultiComponentList mcl = new MultiComponentList( MultiData.GetComponents( ItemID ) );

            mcl.Resize( mcl.Width, mcl.Height + 1 );

            int xCenter = mcl.Center.X;
            int yCenter = mcl.Center.Y;
            int y = mcl.Height - 1;

            ApplyFoundation( m_Type, mcl );

            for ( int x = 1; x < mcl.Width; ++x )
                mcl.Add( 0x751, x - xCenter, y - yCenter, 0 );

            return mcl;
        }
        public static bool DeleteStairs( MultiComponentList mcl, int id, int x, int y, int z )
        {
            int ax = x + mcl.Center.X;
            int ay = y + mcl.Center.Y;

            if ( ax < 0 || ay < 0 || ax >= mcl.Width || ay >= (mcl.Height - 1) || z < 7 || ((z - 7) % 5) != 0 )
                return false;

            if ( IsStairBlock( id ) )
            {
                Tile[] tiles = mcl.Tiles[ax][ay];

                for ( int i = 0; i < tiles.Length; ++i )
                {
                    Tile tile = tiles[i];

                    if ( tile.Z == (z + 5) )
                    {
                        id = tile.ID;
                        z = tile.Z;

                        if ( !IsStairBlock( id ) )
                            break;
                    }
                }
            }

            int dir = 0;

            if ( !IsStair( id, ref dir ) )
                return false;

            int height = ((z - 7) % 20) / 5;

            int xStart, yStart;
            int xInc, yInc;

            switch ( dir )
            {
                default:
                case 0: // North
                {
                    xStart = x;
                    yStart = y + height;
                    xInc = 0;
                    yInc = -1;
                    break;
                }
                case 1: // West
                {
                    xStart = x + height;
                    yStart = y;
                    xInc = -1;
                    yInc = 0;
                    break;
                }
                case 2: // South
                {
                    xStart = x;
                    yStart = y - height;
                    xInc = 0;
                    yInc = 1;
                    break;
                }
                case 3: // East
                {
                    xStart = x - height;
                    yStart = y;
                    xInc = 1;
                    yInc = 0;
                    break;
                }
            }

            int zStart = z - (height * 5);

            for ( int i = 0; i < 4; ++i )
            {
                x = xStart + (i * xInc);
                y = yStart + (i * yInc);

                for ( int j = 0; j <= i; ++j )
                    mcl.RemoveXYZH( x, y, zStart + (j * 5), 5 );

                ax = x + mcl.Center.X;
                ay = y + mcl.Center.Y;

                if ( ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1 )
                {
                    Tile[] tiles = mcl.Tiles[ax][ay];

                    bool hasBaseFloor = false;

                    for ( int j = 0; !hasBaseFloor && j < tiles.Length; ++j )
                        hasBaseFloor = ( tiles[j].Z == 7 && (tiles[j].ID & 0x3FFF) != 1 );

                    if ( !hasBaseFloor )
                        mcl.Add( 0x31F4, x, y, 7 );
                }
            }

            return true;
        }
        public static void ApplyFoundation( FoundationType type, MultiComponentList mcl )
        {
            int east, south, post, corner;

            GetFoundationGraphics( type, out east, out south, out post, out corner );

            int xCenter = mcl.Center.X;
            int yCenter = mcl.Center.Y;

            mcl.Add( post, 0 - xCenter, 0 - yCenter, 0 );
            mcl.Add( corner, mcl.Width - 1 - xCenter, mcl.Height - 2 - yCenter, 0 );

            for ( int x = 1; x < mcl.Width; ++x )
            {
                mcl.Add( south, x - xCenter, 0 - yCenter, 0 );

                if ( x < mcl.Width-1 )
                    mcl.Add( south, x - xCenter, mcl.Height - 2 - yCenter, 0 );
            }

            for ( int y = 1; y < mcl.Height - 1; ++y )
            {
                mcl.Add( east, 0 - xCenter, y - yCenter, 0 );

                if ( y < mcl.Height - 2 )
                    mcl.Add( east, mcl.Width - 1 - xCenter, y - yCenter, 0 );
            }
        }
        public static void AddStairsTo( ref MultiComponentList mcl )
        {
            // copy the original..
            mcl = new MultiComponentList( mcl );

            mcl.Resize( mcl.Width, mcl.Height + 1 );

            int xCenter = mcl.Center.X;
            int yCenter = mcl.Center.Y;
            int y = mcl.Height - 1;

            for ( int x = 0; x < mcl.Width; ++x )
                mcl.Add( 0x63, x - xCenter, y - yCenter, 0 );
        }
        public override void SetInitialState()
        {
            m_Current = new DesignState(this, GetEmptyFoundation());

            // explicitly unused in StaticHousing
			m_Design = null;
			m_Backup = null;
            
            //init the other two design states just so they don't crash the base's serilization      
            MultiComponentList y = new MultiComponentList(m_Current.Components);
            MultiComponentList x = new MultiComponentList(StaticHouseHelper.GetComponents(m_HouseBlueprintID));
            
            //merge x into y.
            //first, remove all in y
            for (int i = y.List.Length - 1; i >= 0; i--)
            {
                y.Remove(y.List[i].m_ItemID, y.List[i].m_OffsetX, y.List[i].m_OffsetY, y.List[i].m_OffsetZ);
            }

            //then add all the ones we want to the list
            for (int i = 0; i < x.List.Length; ++i)
            {
                y.Add(x.List[i].m_ItemID, x.List[i].m_OffsetX, x.List[i].m_OffsetY, x.List[i].m_OffsetZ,true);
            }

            m_Current.Components = y;

			return;
        }
Exemple #7
0
        public static MultiComponentList GetComponents(this IAddon addon)
        {
            if (addon == null)
            {
                return(null);
            }

            var hash = ComputeHash(addon);

            var mcl = ComponentsCache.GetValue(hash);

            if (mcl != null)
            {
                return(mcl);
            }

            mcl = new MultiComponentList(MultiComponentList.Empty);

            int x1 = 0, y1 = 0, x2 = 0, y2 = 0;

            IList comp;

            if (addon.GetPropertyValue("Components", out comp))
            {
                Point3D off;

                foreach (var c in comp)
                {
                    if (c.GetPropertyValue("Offset", out off))
                    {
                        x1 = Math.Min(off.X, x1);
                        y1 = Math.Min(off.Y, y1);

                        x2 = Math.Max(off.X, x2);
                        y2 = Math.Max(off.Y, y2);
                    }
                }
            }

            mcl.Resize(1 + (x2 - x1), 1 + (y2 - y1));

            if (comp != null)
            {
                Point3D off;

                foreach (var c in comp.OfType <Item>())
                {
                    if (c.GetPropertyValue("Offset", out off))
                    {
                        off = off.Clone3D(Math.Abs(x1), Math.Abs(y1));

                        mcl.Add(c.ItemID, off.X, off.Y, off.Z);
                    }
                }
            }

            if (addon is Item)
            {
                ((Item)addon).Delete();
            }

            return(ComponentsCache[hash] = mcl);
        }