コード例 #1
0
ファイル: Utility.cs プロジェクト: Pumpk1ns/outlands
        public static Item Dupe(Item item)
        {
            if (item == null)
            {
                return(null);
            }

            Item copy = item;

            Type            t = copy.GetType();
            ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

            if (c != null)
            {
                try
                {
                    object o = c.Invoke(null);

                    if (o != null && o is Item)
                    {
                        Item newItem = (Item)o;

                        CopyProperties(newItem, copy);
                        copy.OnAfterDuped(newItem);
                        newItem.Parent = null;

                        //newItem.InvalidateProperties();

                        return(newItem);
                    }
                }

                catch
                {
                    return(null);
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: NubiaHelper.cs プロジェクト: bsenyuva/terranubia3
        public static Item CopyItem(Item original)
        {
            if (original == null)
            {
                return(null);
            }
            bool done = false;

            Item copy = (Item)original;
            //Container pack;

            Type t = copy.GetType();

            //ConstructorInfo[] info = t.GetConstructors();
            ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

            if (c != null)
            {
                try
                {
                    //from.SendMessage( "Copie du parchemin..." );
                    object o = c.Invoke(null);

                    if (o != null && o is Item)
                    {
                        Item newItem = (Item)o;
                        CopyProperties(newItem, copy);//copy.Dupe( item, copy.Amount );
                        copy.OnAfterDuped(newItem);
                        newItem.Parent = null;

                        /*if ( cible.Backpack != null )
                         *  cible.Backpack.DropItem( newItem );
                         * else
                         *  newItem.MoveToWorld( m_Owner.Location, m_Owner.Map );*/

                        /*if( newItem is BaseParchemin )
                         * {
                         *  BaseParchemin n = newItem as BaseParchemin;
                         *  n.Maitrise = 0.0;
                         *  n.Owner = null;
                         * }*/
                        return(newItem);
                    }
                    //from.SendMessage( "Finie !" );
                    //cible.SendMessage("Le parchemin de la technique apprise est dans votre sac...");
                    done = true;
                }
                catch
                {
                    //from.SendMessage( "Error!" );
                    return(null);
                }
            }

            if (!done)
            {
                Console.WriteLine("Unable to dupe.  Item must have a 0 parameter constructor.");
                return(null);
            }
            return(null);
        }
コード例 #3
0
ファイル: Mobile.cs プロジェクト: Ravenwolfe/xrunuo
        public static Item LiftItemDupe( Item oldItem, int amount )
        {
            Item item;
            try
            {
                item = (Item) Activator.CreateInstance( oldItem.GetType() );
            }
            catch
            {
                Console.WriteLine( "Warning: 0x{0:X}: Item must have a zero paramater constructor to be separated from a stack. '{1}'.", oldItem.Serial.Value, oldItem.GetType().Name );
                return null;
            }
            item.Visible = oldItem.Visible;
            item.Movable = oldItem.Movable;
            item.LootType = oldItem.LootType;
            item.Direction = oldItem.Direction;
            item.Hue = oldItem.PrivateHue;
            item.ItemID = oldItem.ItemID;
            item.Location = oldItem.Location;
            item.Layer = oldItem.Layer;
            item.Name = oldItem.Name;
            item.Weight = oldItem.Weight;
            item.Amount = oldItem.Amount - amount;
            item.Map = oldItem.Map;
            item.QuestItem = oldItem.QuestItem;

            oldItem.Amount = amount;
            oldItem.OnAfterDuped( item );

            if ( oldItem.Parent is Mobile )
                ( (Mobile) oldItem.Parent ).AddItem( item );
            else if ( oldItem.Parent is Item )
                ( (Item) oldItem.Parent ).AddItem( item );

            item.Delta( ItemDelta.Update );

            return item;
        }
コード例 #4
0
		private void Dupe(Container pack, Item copy)
		{
			bool done = false;

			Type t = copy.GetType();

			ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

			if (c != null)
			{
				try
				{
					object o = c.Invoke(null);

					if (o != null && o is Item)
					{
						Item newItem = (Item)o;
						CopyProperties(newItem, copy);
						copy.OnAfterDuped(newItem);
						newItem.Parent = null;

						pack.DropItem(newItem);

						newItem.InvalidateProperties();

						if(copy is Container)
						{
							DupeContainer((Container)copy, (Container)newItem);
						}
					}
					done = true;
				}
				catch { }
			}

			if (!done)
			{
				Console.WriteLine("Unable to copy an item in a Pandora's Gift Box. All items must have a 0 parameter constructor.");
			}
		}