当前位置: 首页>>代码示例>>C#>>正文


C# Item.OnAdded方法代码示例

本文整理汇总了C#中Server.Item.OnAdded方法的典型用法代码示例。如果您正苦于以下问题:C# Item.OnAdded方法的具体用法?C# Item.OnAdded怎么用?C# Item.OnAdded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Item的用法示例。


在下文中一共展示了Item.OnAdded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddItem

        public virtual void AddItem( Item item )
        {
            if ( item == null || item.Deleted || item.m_Parent == this )
            {
                return;
            }
            else if ( item == this )
            {
                log.FatalFormat("Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )",
                                this.Serial.Value, this.GetType().Name,
                                item.Serial.Value, item.GetType().Name);
                return;
            }
            else if ( IsChildOf( item ) )
            {
                log.FatalFormat("Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )",
                                this.Serial.Value, this.GetType().Name,
                                item.Serial.Value, item.GetType().Name);
                return;
            }
            else if ( item.m_Parent is Mobile )
            {
                ((Mobile)item.m_Parent).RemoveItem( item );
            }
            else if ( item.m_Parent is Item )
            {
                ((Item)item.m_Parent).RemoveItem( item );
            }
            else
            {
                item.SendRemovePacket();
            }

            item.Parent = this;
            item.Map = m_Map;

            if ( m_Items == null )
                m_Items = new ArrayList( 4 );

            int oldCount = m_Items.Count;
            m_Items.Add( item );

            TotalItems = (TotalItems - oldCount) + m_Items.Count + item.TotalItems - (item.IsVirtualItem ? 1 : 0);
            TotalWeight += item.TotalWeight + item.PileWeight;
            TotalGold += item.TotalGold;

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );
        }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:51,代码来源:Item.cs

示例2: AddItem

        public virtual void AddItem( Item item )
        {
            if ( item == null || item.Deleted || item.m_Parent == this )
            {
                return;
            }
            else if ( item == this )
            {
                Console.WriteLine( "Warning: Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name );
                Console.WriteLine( new System.Diagnostics.StackTrace() );
                return;
            }
            else if ( IsChildOf( item ) )
            {
                Console.WriteLine( "Warning: Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name );
                Console.WriteLine( new System.Diagnostics.StackTrace() );
                return;
            }
            else if ( item.m_Parent is Mobile )
            {
                ( (Mobile) item.m_Parent ).RemoveItem( item );
            }
            else if ( item.m_Parent is Item )
            {
                ( (Item) item.m_Parent ).RemoveItem( item );
            }
            else
            {
                item.SendRemovePacket();
            }

            item.Parent = this;
            item.Map = m_Map;

            if ( m_Items == null )
                m_Items = new List<Item>( 4 );

            int oldCount = m_Items.Count;
            m_Items.Add( item );

            TotalItems = ( TotalItems - oldCount ) + m_Items.Count + item.TotalItems - ( item.IsVirtualItem ? 1 : 0 );
            TotalWeight += item.TotalWeight + item.PileWeight;

            if ( !( item is Container && ( (Container) item ).UseLockedRestriction && ( (Container) item ).IsLockedContainer ) )
                TotalGold += item.TotalGold;

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:51,代码来源:Item.cs

示例3: AddItem

        public void AddItem( Item item )
        {
            if ( item == null || item.Deleted )
                return;

            if ( item.Parent == this )
                return;
            else if ( item.Parent is Mobile )
                ((Mobile)item.Parent).RemoveItem( item );
            else if ( item.Parent is Item )
                ((Item)item.Parent).RemoveItem( item );
            else
                item.SendRemovePacket();

            item.Parent = this;
            item.Map = m_Map;

            m_Items.Add( item );

            if ( !(item is BankBox) )
            {
                TotalWeight += item.TotalWeight + item.PileWeight;
                TotalGold += item.TotalGold;
            }

            item.Delta( ItemDelta.Update );

            item.OnAdded( this );
            OnItemAdded( item );

            if ( item.PhysicalResistance != 0 || item.FireResistance != 0 || item.ColdResistance != 0 ||
                item.PoisonResistance != 0 || item.EnergyResistance != 0 )
                UpdateResistances();
        }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:34,代码来源:Mobile.cs

示例4: AddItem

		public virtual void AddItem(Item item) // FreezeDried needs modifications
		{
			if (item == null || item.Deleted || item.m_Parent == this)
			{
				return;
			}
			if (item == this)
			{
				Console.WriteLine("Warning: Adding item to itself: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name);
				Console.WriteLine(new System.Diagnostics.StackTrace());
				return;
			}
			if (IsChildOf(item))
			{
				Console.WriteLine("Warning: Adding parent item to child: [0x{0:X} {1}].AddItem( [0x{2:X} {3}] )", this.Serial.Value, this.GetType().Name, item.Serial.Value, item.GetType().Name);
				Console.WriteLine(new System.Diagnostics.StackTrace());
				return;
			}

			CheckRehydrate();

			if (item.m_Parent is Mobile)
			{
				((Mobile)item.m_Parent).RemoveItem(item);
			}
			else if (item.m_Parent is Item)
			{
				((Item)item.m_Parent).RemoveItem(item);
			}
			else
			{
				item.SendRemovePacket();
			}

			item.Parent = this;
			item.Map = m_Map;

			if (m_Items == null)
				m_Items = new ArrayList(4);

			int oldCount = m_Items.Count;
			m_Items.Add(item);

			TotalItems = (TotalItems - oldCount) + m_Items.Count + item.TotalItems - (item.IsVirtualItem ? 1 : 0);
			TotalWeight += item.TotalWeight + item.PileWeight;
			TotalGold += item.TotalGold;

			item.Delta(ItemDelta.Update);

			item.OnAdded(this);
			OnItemAdded(item);
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:52,代码来源:Item.cs


注:本文中的Server.Item.OnAdded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。