/// <summary> /// Copy constructor /// </summary> /// <param name="other">armor settings</param> public FilterArmorSettings(FilterArmorSettings other) { if (other == null) { return; } HeadArmor = other.HeadArmor; ArmorBodyArmor = other.ArmorBodyArmor; LegArmor = other.LegArmor; ArmArmor = other.ArmArmor; ManeuverBonus = other.ManeuverBonus; SpeedBonus = other.SpeedBonus; ChargeBonus = other.ChargeBonus; ArmorWeight = other.ArmorWeight; }
/// <summary> /// Returns value for armor using its properties and filter settings /// </summary> /// <param name="sourceItem">Armor item</param> /// <param name="slot">Armor equipment slot</param> /// <returns>calculated value for armor</returns> public float CalculateArmorValue(EquipmentElement sourceItem, FilterArmorSettings filterArmor) { ArmorComponent armorComponentItem = sourceItem.Item.ArmorComponent; float sum = Math.Abs(filterArmor.HeadArmor) + Math.Abs(filterArmor.ArmArmor) + Math.Abs(filterArmor.ArmorBodyArmor) + Math.Abs(filterArmor.ArmorWeight) + Math.Abs(filterArmor.LegArmor); ItemModifier mod = sourceItem.ItemModifier; int HeadArmor = armorComponentItem.HeadArmor, BodyArmor = armorComponentItem.BodyArmor, LegArmor = armorComponentItem.LegArmor, ArmArmor = armorComponentItem.ArmArmor; float Weight = sourceItem.Weight; if (mod != null) { // Since armor values are positive numbers, we need to check // if the given values have positive number before we apply // any modifiers to it. if (HeadArmor > 0f) { HeadArmor = mod.ModifyArmor(HeadArmor); } if (BodyArmor > 0f) { BodyArmor = mod.ModifyArmor(BodyArmor); } if (LegArmor > 0f) { LegArmor = mod.ModifyArmor(LegArmor); } if (ArmArmor > 0f) { ArmArmor = mod.ModifyArmor(ArmArmor); } //Weight *= mod.WeightMultiplier; HeadArmor = HeadArmor < 0 ? 0 : HeadArmor; BodyArmor = BodyArmor < 0 ? 0 : BodyArmor; LegArmor = LegArmor < 0 ? 0 : LegArmor; ArmArmor = ArmArmor < 0 ? 0 : ArmArmor; } float value = ( HeadArmor * filterArmor.HeadArmor + BodyArmor * filterArmor.ArmorBodyArmor + LegArmor * filterArmor.LegArmor + ArmArmor * filterArmor.ArmArmor + Weight * filterArmor.ArmorWeight ) / sum; #if DEBUG InformationManager.DisplayMessage(new InformationMessage(String.Format("{0}: HA {1}, BA {2}, LA {3}, AA {4}, W {5}", sourceItem.Item.Name, HeadArmor, BodyArmor, LegArmor, ArmArmor, Weight))); InformationManager.DisplayMessage(new InformationMessage("Total score: " + value)); #endif return(value); }