Beispiel #1
0
        public virtual ComparisonCalculationBase GetItemCalculations(Item item, Character character, Character.CharacterSlot slot)
        {
            bool      useCache = character == _cachedCharacter && slot == _cachedSlot;
            Character characterWithSlotEmpty = null;

            if (!useCache)
            {
                characterWithSlotEmpty = character.Clone();
            }
            Character characterWithNewItem = character.Clone();

            if (slot != Character.CharacterSlot.Metas && slot != Character.CharacterSlot.Gems)
            {
                if (!useCache)
                {
                    characterWithSlotEmpty[slot] = null;
                }
                characterWithNewItem[slot] = item;
            }


            CharacterCalculationsBase characterStatsWithSlotEmpty;

            if (useCache)
            {
                characterStatsWithSlotEmpty = _cachedCharacterStatsWithSlotEmpty;
            }
            else
            {
                characterStatsWithSlotEmpty = GetCharacterCalculations(characterWithSlotEmpty);
                _cachedCharacter            = character;
                _cachedSlot = slot;
                _cachedCharacterStatsWithSlotEmpty = characterStatsWithSlotEmpty;
            }


            Item additionalItem = null;

            if (item.FitsInSlot(Character.CharacterSlot.Gems) || item.FitsInSlot(Character.CharacterSlot.Metas))
            {
                additionalItem = item;
            }
            CharacterCalculationsBase characterStatsWithNewItem = GetCharacterCalculations(characterWithNewItem, additionalItem);

            ComparisonCalculationBase itemCalc = CreateNewComparisonCalculation();

            itemCalc.Item          = item;
            itemCalc.Name          = item.Name;
            itemCalc.Equipped      = character[slot] == item;
            itemCalc.OverallPoints = characterStatsWithNewItem.OverallPoints - characterStatsWithSlotEmpty.OverallPoints;
            float[] subPoints = new float[characterStatsWithNewItem.SubPoints.Length];
            for (int i = 0; i < characterStatsWithNewItem.SubPoints.Length; i++)
            {
                subPoints[i] = characterStatsWithNewItem.SubPoints[i] - characterStatsWithSlotEmpty.SubPoints[i];
            }
            itemCalc.SubPoints = subPoints;

            characterStatsWithNewItem.ToString();

            return(itemCalc);
        }