Server.Items.FillableContent.Construct C# (CSharp) Méthode

Construct() public méthode

public Construct ( ) : Item
Résultat Item
		public virtual Item Construct()
		{
			int index = Utility.Random( m_Weight );

			for( int i = 0; i < m_Entries.Length; ++i )
			{
				FillableEntry entry = m_Entries[ i ];

				if( index < entry.Weight )
					return entry.Construct();

				index -= entry.Weight;
			}

			return null;
		}

Usage Example

        public virtual void GenerateContent()
        {
            if (m_Content == null || Deleted)
            {
                return;
            }

            int toSpawn = GetSpawnCount();

            for (int i = 0; i < toSpawn; ++i)
            {
                Item item = m_Content.Construct();

                if (item == null)
                {
                    continue;
                }

                if (!Items.Not(subItem => subItem is Container).Any(subItem => subItem.StackWith(null, item, false)) ||
                    !item.Deleted)
                {
                    DropItem(item);
                }
            }
        }
All Usage Examples Of Server.Items.FillableContent::Construct