Server.Items.SalvageBag.SalvageCloth C# (CSharp) Méthode

SalvageCloth() private méthode

private SalvageCloth ( Server.Mobile from ) : void
from Server.Mobile
Résultat void
        private void SalvageCloth( Mobile from )
        {
            Scissors scissors = from.Backpack.FindItemByType( typeof( Scissors ) ) as Scissors;
            if( scissors == null )
            {
                from.SendLocalizedMessage( 1079823 ); // You need scissors in order to salvage cloth.
                return;
            }

            int salvaged = 0;
            int notSalvaged = 0;
			
			Container sBag = this;
			
			List<Item> scissorables = sBag.FindItemsByType<Item>();

			for ( int i = scissorables.Count - 1; i >= 0; --i )
			{
				Item item = scissorables[i];

				if ( item is IScissorable )
				{
					IScissorable scissorable = (IScissorable)item;

					if ( Scissors.CanScissor( from, scissorable ) && scissorable.Scissor( from, scissors ) )
						++salvaged;
					else
						++notSalvaged;
				}
			}
			
            from.SendLocalizedMessage( 1079974, String.Format( "{0}\t{1}", salvaged, salvaged + notSalvaged ) ); // Salvaged: ~1_COUNT~/~2_NUM~ tailored items
			
			Container pack = from.Backpack;
			
			foreach (Item i in ((Container)this).FindItemsByType(typeof(Item), true))
			{
				if( ( i is Leather ) || ( i is Cloth ) || ( i is SpinedLeather ) || ( i is HornedLeather ) || ( i is BarbedLeather ) || ( i is Bandage ) || ( i is Bone ) )
				{
					from.AddToBackpack( i );
				}
			}	
        }

Usage Example

Exemple #1
0
            public override void OnClick()
            {
                if (m_Bag.Deleted)
                {
                    return;
                }

                Mobile from = Owner.From;

                if (from.CheckAlive())
                {
                    m_Bag.SalvageCloth(from);
                }
            }