Ejemplo n.º 1
0
        public void Push(SuitBuildableMyWorldObject item, EquippableSlotFlags slot)
        {
            cache[nextOpenCacheIndex].Piece      = item;
            cache[nextOpenCacheIndex].Slot       = slot;
            cache[nextOpenCacheIndex].SpellCount = item.SpellsToUseInSearch.Count;

            occupiedSlots |= slot;

            for (int i = 0; i < item.SpellsToUseInSearch.Count; i++)
            {
                spells[nextOpenSpellIndex] = item.SpellsToUseInSearch[i];
                nextOpenSpellIndex++;
            }

            nextOpenCacheIndex++;

            if (item.ItemSetId != -1)
            {
                armorSetCountById[item.ItemSetId]++;
            }

            if (item.CalcedStartingArmorLevel > 0)
            {
                TotalBaseArmorLevel += (item.CalcedStartingArmorLevel * slot.GetTotalBitsSet());
            }

            if (slot.IsBodyArmor())
            {
                TotalBodyArmorPieces++;
            }
        }
Ejemplo n.º 2
0
        public bool ItemPassesRules(SuitBuildableMyWorldObject item)
        {
            if (CantripsToLookFor.Count > 0)
            {
                foreach (Spell cantrip in CantripsToLookFor)
                {
                    foreach (Spell itemSpell in item.CachedSpells)
                    {
                        if (itemSpell.IsSameOrSurpasses(cantrip))
                        {
                            goto end;
                        }
                    }
                }

                end :;
            }

            // If we're don't want to use any set pieces, remove them
            if (PrimaryArmorSet == 0 && SecondaryArmorSet == 0 && item.EquippableSlots.IsBodyArmor() && item.ItemSetId != 0)
            {
                return(false);
            }

            // If we're building a two set armor suit, and we don't want any blanks or fillers, remove any pieces of armor of other sets
            if (PrimaryArmorSet != 0 && SecondaryArmorSet != 0 && PrimaryArmorSet != 255 && SecondaryArmorSet != 255 &&
                item.EquippableSlots.IsBodyArmor() && item.ItemSetId != PrimaryArmorSet && item.ItemSetId != SecondaryArmorSet)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public bool PutItemInBuckets(SuitBuildableMyWorldObject piece, EquippableSlotFlags slot)
        {
            bool foundBucket = false;

            foreach (Bucket bucket in this)
            {
                if ((slot & bucket.Slot) == bucket.Slot)
                {
                    foundBucket = true;
                    bucket.Add(piece);
                }
            }

            return(foundBucket);
        }
Ejemplo n.º 4
0
        public bool CanGetBeneficialSpellFrom(SuitBuildableMyWorldObject item)
        {
            // This whole approach needs to be optimized.
            // This is the biggest time waster in the entire search process.

            foreach (Spell itemSpell in item.SpellsToUseInSearch)
            //for (int i = 0 ; i < item.Spells.Count ; i++) // This is actually slower
            {
                for (int j = 0; j < nextOpenSpellIndex; j++)                 // For here is faster than foreach
                {
                    if (spells[j].IsSameOrSurpasses(itemSpell))
                    {
                        goto end;
                    }
                }

                return(true);

                end :;
            }

            return(false);
        }
Ejemplo n.º 5
0
 public bool PutItemInBuckets(SuitBuildableMyWorldObject piece)
 {
     return(PutItemInBuckets(piece, piece.EquippableSlots));
 }