Пример #1
0
        /*
         * public override void AddNameProperties( ObjectPropertyList list )
         * {
         * base.AddNameProperties( list );
         *
         * if (House != null && House.InternalizedVendors.Count > 0)
         *  list.Add( 1061833, House.InternalizedVendors.Count.ToString() ); // This packing crate contains ~1_COUNT~ vendors/barkeepers.
         * }
         */

        public override void DropItem(Item dropped)
        {
            // 1. Try to stack the item
            foreach (var item in Items)
            {
                if (item is PackingBox)
                {
                    var subItems = item.Items;

                    for (var i = 0; i < subItems.Count; i++)
                    {
                        var subItem = subItems[i];

                        if (subItem is not Container && subItem.StackWith(null, dropped, false))
                        {
                            return;
                        }
                    }
                }
            }

            // 2. Try to drop the item into an existing container
            foreach (var item in Items)
            {
                if (item is PackingBox packingBox)
                {
                    Container box      = packingBox;
                    var       subItems = box.Items;

                    if (subItems.Count < MaxItemsPerSubcontainer)
                    {
                        box.DropItem(dropped);
                        return;
                    }
                }
            }

            // 3. Drop the item into a new container
            Container subContainer = new PackingBox();

            subContainer.DropItem(dropped);

            var location = GetFreeLocation();

            if (location != Point3D.Zero)
            {
                AddItem(subContainer);
                subContainer.Location = location;
            }
            else
            {
                base.DropItem(subContainer);
            }
        }
Пример #2
0
        /*
         * public override void AddNameProperties( ObjectPropertyList list )
         * {
         *      base.AddNameProperties( list );
         *
         *      if ( House != null && House.InternalizedVendors.Count > 0 )
         *              list.Add( 1061833, House.InternalizedVendors.Count.ToString() ); // This packing crate contains ~1_COUNT~ vendors/barkeepers.
         * }
         */

        public override void DropItem(Item dropped)
        {
            // 1. Try to stack the item
            foreach (Item item in this.Items)
            {
                if (item is PackingBox)
                {
                    ArrayList subItems = item.Items;

                    for (int i = 0; i < subItems.Count; i++)
                    {
                        Item subItem = (Item)subItems[i];

                        if (!(subItem is Container) && subItem.StackWith(null, dropped, false))
                        {
                            return;
                        }
                    }
                }
            }

            // 2. Try to drop the item into an existing container
            foreach (Item item in this.Items)
            {
                if (item is PackingBox)
                {
                    Container box      = (Container)item;
                    ArrayList subItems = box.Items;

                    if (subItems.Count < MaxItemsPerSubcontainer)
                    {
                        box.DropItem(dropped);
                        return;
                    }
                }
            }

            // 3. Drop the item into a new container
            Container subContainer = new PackingBox();

            subContainer.DropItem(dropped);

            Point3D location = GetFreeLocation();

            if (location != Point3D.Zero)
            {
                this.AddItem(subContainer);
                subContainer.Location = location;
            }
            else
            {
                base.DropItem(subContainer);
            }
        }
		public override void DropItem( Item dropped )
		{
			// 1. Try to stack the item
			foreach ( Item item in this.Items )
			{
				if ( item is PackingBox )
				{
					ArrayList subItems = item.Items;

					for ( int i = 0; i < subItems.Count; i++ )
					{
						Item subItem = (Item) subItems[i];

						if ( !(subItem is Container) && subItem.StackWith( null, dropped, false ) )
							return;
					}
				}
			}

			// 2. Try to drop the item into an existing container
			foreach ( Item item in this.Items )
			{
				if ( item is PackingBox )
				{
					Container box = (Container) item;
					ArrayList subItems = box.Items;

					if ( subItems.Count < MaxItemsPerSubcontainer )
					{
						box.DropItem( dropped );
						return;
					}
				}
			}

			// 3. Drop the item into a new container
			Container subContainer = new PackingBox();
			subContainer.DropItem( dropped );

			Point3D location = GetFreeLocation();
			if ( location != Point3D.Zero )
			{
				this.AddItem( subContainer );
				subContainer.Location = location;
			}
			else
			{
				base.DropItem( subContainer );
			}
		}