static void evaluateWeaponAttackOnVehicle(float expectedDamage, Weapon w, ref DamageExpectationRecord damageExpectationRecord, Vector3 attackerPosition, Vehicle targetVehicle, Vector3 targetPosition, Quaternion targetRotation) { // use hit table to figure out where this will go Dictionary <VehicleChassisLocations, float> locations = GetLocationDictionary(attackerPosition, targetVehicle, targetPosition, targetRotation); foreach (KeyValuePair <VehicleChassisLocations, float> locKVP in locations) { VehicleChassisLocations loc = locKVP.Key; float probability = locKVP.Value; DamageExpectationRecord locRecord = new DamageExpectationRecord(); damageExpectationRecord.AddChildRecord(probability, locRecord); float existingArmor = targetVehicle.ArmorForLocation((int)loc); float armorThatWillBeRemoved = Mathf.Min(existingArmor, expectedDamage); float damageRemaining = expectedDamage - existingArmor; locRecord.AddVehicleArmorDamage(armorThatWillBeRemoved, loc); if (damageRemaining > 0) { // some goes in to the structure float currentStructure = targetVehicle.GetCurrentStructure(loc); float structureDamage = Mathf.Min(damageRemaining, currentStructure); //float damageAfterStructure = damageRemaining - structureDamage; locRecord.AddVehicleStructureDamage(structureDamage, loc); } } }
public void flattenInto(DamageExpectationRecord target, DamageExpectationRecord source, float probability) { foreach (KeyValuePair <ComponentLocator, float> kvp in source.componentDamageDictionary) { ComponentLocator key = kvp.Key; float dmg = kvp.Value; target.AddComponentDamage(dmg * probability, key); } foreach (ChassisLocations loc in source.chassisLocationDictionary.Keys) { float dmg = source.chassisLocationDictionary[loc]; target.AddStructureDamage(dmg * probability, loc); } foreach (ArmorLocation loc in source.armorLocationDictionary.Keys) { float dmg = source.armorLocationDictionary[loc]; target.AddArmorDamage(dmg * probability, loc); } foreach (VehicleChassisLocations loc in source.vehicleChassisLocationDictionary.Keys) { float dmg = source.vehicleChassisLocationDictionary[loc]; target.AddVehicleStructureDamage(dmg * probability, loc); } foreach (VehicleChassisLocations loc in source.vehicleArmorLocationDictionary.Keys) { float dmg = source.vehicleArmorLocationDictionary[loc]; target.AddVehicleArmorDamage(dmg * probability, loc); } target.AddPilotDamage(pilotDamage * probability); target.lethalProbability += lethalProbability * probability; for (int childIndex = 0; childIndex < source.children.Count; ++childIndex) { ChildWithProbability c = source.children[childIndex]; flattenInto(target, c.DamageExpectationRecord, c.Probability); } }