Server.LootPackEntry.Construct C# (CSharp) Méthode

Construct() public méthode

public Construct ( Server.Mobile from, bool spawning ) : Item
from Server.Mobile
spawning bool
Résultat Item
		public Item Construct( Mobile from, bool spawning )
		{
			if ( m_AtSpawnTime != spawning )
				return null;

			int totalChance = 0;

			for ( int i = 0; i < m_Items.Length; ++i )
				totalChance += m_Items[i].Chance;

			int rnd = Utility.Random( totalChance );

			for ( int i = 0; i < m_Items.Length; ++i )
			{
				LootPackItem item = m_Items[i];

				if ( rnd < item.Chance )
					return Mutate( from,  item.Construct() );

				rnd -= item.Chance;
			}

			return null;
		}

Usage Example

Exemple #1
0
        public void Generate(Mobile from, Container cont, bool spawning)
        {
            if (cont == null)
            {
                return;
            }

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

                bool shouldAdd = (entry.Chance > Utility.Random(10000));

                if (!shouldAdd)
                {
                    continue;
                }

                Item item = entry.Construct(from, spawning);

                if (item != null)
                {
                    if (!item.Stackable || !cont.TryDropItem(from, item, false))
                    {
                        cont.DropItem(item);
                    }
                }
            }
        }
All Usage Examples Of Server.LootPackEntry::Construct