Exemplo n.º 1
0
        public bool CanGetBeneficialSpellFrom(LeanMyWorldObject item)
        {
            if (nextOpenCacheIndex == 0)
            {
                return(true);
            }

            return((spellBitmaps[nextOpenCacheIndex - 1] | item.SpellBitmap) != spellBitmaps[nextOpenCacheIndex - 1]);

            // Used for the old search compare method
            // 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 j = 0; j < nextOpenSpellIndex; j++) // For here is faster than foreach
             *      {
             *              if (spells[j].IsSameOrSurpasses(itemSpell))
             *                      goto end;
             *      }
             *
             *      return true;
             *
             *      end: ;
             * }
             *
             * return false;*/
        }
Exemplo n.º 2
0
        public static bool PutItemInBuckets(this ICollection <Bucket> value, LeanMyWorldObject piece, EquipMask slot)
        {
            bool foundBucket = false;

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

            return(foundBucket);
        }
Exemplo n.º 3
0
        public void Push(LeanMyWorldObject item, EquippableSlotFlags slot)
        {
            slotCache[nextOpenCacheIndex].Piece = item;
            slotCache[nextOpenCacheIndex].Slot  = slot;
            //slotCache[nextOpenCacheIndex].SpellCount = item.SpellsToUseInSearch.Count; // Used for the old search compare method

            occupiedSlots |= slot;

            // Used for the old search compare method

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

            if (nextOpenCacheIndex == 0)
            {
                spellBitmaps[nextOpenCacheIndex] = item.SpellBitmap;
            }
            else
            {
                spellBitmaps[nextOpenCacheIndex] = spellBitmaps[nextOpenCacheIndex - 1] | item.SpellBitmap;
            }

            nextOpenCacheIndex++;

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

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

            if (slot.IsBodyArmor())
            {
                TotalBodyArmorPieces++;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Before you use this function, BuiltItemSearchCache() must have been called on this object.
        /// </summary>
        /// <param name="compareItem"></param>
        /// <returns></returns>
        public bool IsSurpassedBy(LeanMyWorldObject compareItem)
        {
            // Items must be of the same armor set
            if (compareItem.ItemSetId != ItemSetId)
            {
                return(false);
            }

            // This checks to see that the compare item covers at least all the slots that the passed item does
            if (compareItem.Coverage.IsBodyArmor() && Coverage.IsBodyArmor())
            {
                if ((compareItem.Coverage & Coverage) != Coverage)
                {
                    return(false);
                }
            }
            else if ((compareItem.EquippableSlots & EquippableSlots) != EquippableSlots)
            {
                return(false);
            }

            // Find the highest level spell on this item
            Spell.CantripLevels highestCantrip = Spell.CantripLevels.None;

            foreach (Spell itemSpell in ExtendedMyWorldObject.CachedSpells)
            {
                if (itemSpell.CantripLevel > highestCantrip)
                {
                    highestCantrip = itemSpell.CantripLevel;
                }
            }

            // Does this item have spells that equal or surpass this items at the highest cantrip level found?
            foreach (Spell itemSpell in ExtendedMyWorldObject.CachedSpells)
            {
                if (itemSpell.CantripLevel < highestCantrip)
                {
                    continue;
                }

                foreach (Spell compareSpell in compareItem.ExtendedMyWorldObject.CachedSpells)
                {
                    if (compareSpell.Surpasses(itemSpell))
                    {
                        return(true);
                    }

                    if (compareSpell.IsSameOrSurpasses(itemSpell))
                    {
                        goto next;
                    }
                }

                return(false);

                next :;
            }

            if (compareItem.CalcedStartingArmorLevel > CalcedStartingArmorLevel)
            {
                return(true);
            }

            if (compareItem.damRating > damRating && damRating > 0)
            {
                return(true);
            }
            if (compareItem.damResistRating > damResistRating && damResistRating > 0)
            {
                return(true);
            }
            if (compareItem.critRating > critRating && critRating > 0)
            {
                return(true);
            }
            if (compareItem.critResistRating > critResistRating && critResistRating > 0)
            {
                return(true);
            }
            if (compareItem.critDamRating > critDamRating && critDamRating > 0)
            {
                return(true);
            }
            if (compareItem.critDamResistRating > critDamResistRating && critDamResistRating > 0)
            {
                return(true);
            }
            if (compareItem.healBoostRating > healBoostRating && healBoostRating > 0)
            {
                return(true);
            }
            if (compareItem.vitalityRating > vitalityRating && vitalityRating > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
 public static bool PutItemInBuckets(this ICollection <Bucket> value, LeanMyWorldObject piece)
 {
     return(value.PutItemInBuckets(piece, piece.EquippableSlots));
 }
Exemplo n.º 6
0
        public static bool ItemIsSurpassed(this ICollection <LeanMyWorldObject> value, LeanMyWorldObject piece)
        {
            if (piece.ObjectClass != (int)ObjectClass.Armor && piece.ObjectClass != (int)ObjectClass.Clothing && piece.ObjectClass != (int)ObjectClass.Jewelry)
            {
                return(false);
            }

            foreach (var compareItem in value)
            {
                if (compareItem == piece)
                {
                    continue;
                }

                if (piece.IsSurpassedBy(compareItem))
                {
                    return(true);
                }
            }

            return(false);
        }