static public float EvaluateFirepowerReductionFromAttack(AbstractActor attacker, Vector3 attackerPosition, ICombatant target, Vector3 targetPosition, Quaternion targetRotation, List <Weapon> weapons, MeleeAttackType attackType)
        {
            AbstractActor actor = target as AbstractActor;

            if (actor == null)
            {
                return(0.0f);
            }

            DamageExpectationRecord damageExpectationRecord = EvaluateAttack(attacker, attackerPosition, target, targetPosition, targetRotation, weapons, attackType);

            float dmg = 0.0f;
            List <ComponentLocator> weaponList = GetWeaponComponentLocatorList(actor);

            for (int weaponIndex = 0; weaponIndex < weaponList.Count; ++weaponIndex)
            {
                ComponentLocator compLoc  = weaponList[weaponIndex];
                MechComponent    mechComp = compLoc.GetComponent();
                Weapon           w        = mechComp as Weapon;

                if (w.CanFire)
                {
                    float weaponBaseDamage = w.ShotsWhenFired * w.DamagePerShot;
                    if (w.DamageLevel == ComponentDamageLevel.Functional)
                    {
                        int expDmg = Mathf.RoundToInt(damageExpectationRecord.GetComponentDamageForLocation(compLoc));
                        if (expDmg == 1)
                        {
                            // that's like half damage
                            dmg += weaponBaseDamage * 0.5f;
                        }
                        else if (expDmg > 1)
                        {
                            dmg += weaponBaseDamage;
                        }
                    }
                    else if (w.DamageLevel == ComponentDamageLevel.Penalized)
                    {
                        int expDmg = Mathf.RoundToInt(damageExpectationRecord.GetComponentDamageForLocation(compLoc));
                        if (expDmg >= 1)
                        {
                            dmg += weaponBaseDamage;
                        }
                    }
                }
            }
            return(dmg);
        }
        static void evaluateWeaponAttackOnMech(float expectedDamage, Weapon w, ref DamageExpectationRecord damageExpectationRecord, Vector3 attackerPosition, Mech targetMech, Vector3 targetPosition, Quaternion targetRotation)
        {
            // use hit table to figure out where this will go
            Dictionary <ArmorLocation, float> locations = GetLocationDictionary(attackerPosition, targetMech, targetPosition, targetRotation);

            foreach (KeyValuePair <ArmorLocation, float> locKVP in locations)
            {
                ArmorLocation loc         = locKVP.Key;
                float         probability = locKVP.Value;

                DamageExpectationRecord locRecord = new DamageExpectationRecord();
                damageExpectationRecord.AddChildRecord(probability, locRecord);

                float existingArmor          = targetMech.ArmorForLocation((int)loc);
                float armorThatWillBeRemoved = Mathf.Min(existingArmor, expectedDamage);
                float damageRemaining        = expectedDamage - existingArmor;
                locRecord.AddArmorDamage(armorThatWillBeRemoved, loc);

                ChassisLocations sLoc = MechStructureRules.GetChassisLocationFromArmorLocation((ArmorLocation)loc);

                // there's a chance this hit will be a critical hit
                if (!targetMech.IsLocationDestroyed(sLoc))
                {
                    float critChance = targetMech.Combat.CritChance.GetCritChance(targetMech, sLoc, w);

                    if (critChance > 0)
                    {
                        DamageExpectationRecord critRecord = new DamageExpectationRecord();
                        locRecord.AddChildRecord(critChance, critRecord);

                        // iterate over components, apply one point of damage to each location.

                        Dictionary <ComponentLocator, float> componentDict = getComponentDictionary(targetMech, sLoc);

                        float probOfHittingAmmo = 0.0f;
                        foreach (KeyValuePair <ComponentLocator, float> componentKVP in componentDict)
                        {
                            ComponentLocator compLoc              = componentKVP.Key;
                            MechComponent    component            = compLoc.GetComponent();
                            float            componentProbability = componentKVP.Value;

                            DamageExpectationRecord componentRecord = new DamageExpectationRecord();
                            critRecord.AddChildRecord(componentProbability, componentRecord);

                            componentRecord.AddComponentDamage(1.0f, compLoc);

                            // if this component is ammo, there's a chance we could lose this location and all child locations
                            if (component.componentType == ComponentType.AmmunitionBox)
                            {
                                AmmunitionBox abComponent   = component as AmmunitionBox;
                                int           remainingAmmo = abComponent.CurrentAmmo;
                                int           capacity      = abComponent.ammunitionBoxDef.Capacity;
                                float         percentage    = ((float)remainingAmmo) / ((float)capacity);

                                if (percentage > 0.5f)
                                {
                                    probOfHittingAmmo += componentProbability;
                                }
                            }
                        }
                        if (probOfHittingAmmo > 0.0f)
                        {
                            DamageExpectationRecord ammoBlownRecord = new DamageExpectationRecord();
                            locRecord.AddChildRecord(probOfHittingAmmo, ammoBlownRecord);

                            foreach (KeyValuePair <ComponentLocator, float> componentKVP in componentDict)
                            {
                                ComponentLocator compLoc = componentKVP.Key;
                                ammoBlownRecord.AddComponentDamage(2.0f, compLoc);
                            }
                        }
                    }
                }

                if (damageRemaining > 0)
                {
                    // some goes in to the structure
                    float currentStructure = targetMech.GetCurrentStructure(sLoc);

                    float structureDamage      = Mathf.Min(damageRemaining, currentStructure);
                    float damageAfterStructure = damageRemaining - structureDamage;

                    locRecord.AddStructureDamage(structureDamage, sLoc);

                    if (damageAfterStructure > 0)
                    {
                        // some hits a component
                        Dictionary <ComponentLocator, float> componentDict = getComponentDictionary(targetMech, sLoc);

                        float probOfHittingAmmo = 0.0f;

                        foreach (KeyValuePair <ComponentLocator, float> componentKVP in componentDict)
                        {
                            ComponentLocator compLoc              = componentKVP.Key;
                            MechComponent    component            = compLoc.GetComponent();
                            float            componentProbability = componentKVP.Value;

                            DamageExpectationRecord componentRecord = new DamageExpectationRecord();
                            locRecord.AddChildRecord(componentProbability, componentRecord);

                            componentRecord.AddComponentDamage(1.0f, compLoc);

                            // if this component is ammo, there's a chance we could lose this location and all child locations
                            if (component.componentType == ComponentType.AmmunitionBox)
                            {
                                AmmunitionBox abComponent   = component as AmmunitionBox;
                                int           remainingAmmo = abComponent.CurrentAmmo;
                                int           capacity      = abComponent.ammunitionBoxDef.Capacity;
                                float         percentage    = ((float)remainingAmmo) / ((float)capacity);

                                if (percentage > 0.5f)
                                {
                                    probOfHittingAmmo += componentProbability;
                                }
                            }
                        }

                        if (probOfHittingAmmo > 0)
                        {
                            DamageExpectationRecord ammoBlownRecord = new DamageExpectationRecord();
                            locRecord.AddChildRecord(probOfHittingAmmo, ammoBlownRecord);

                            foreach (KeyValuePair <ComponentLocator, float> componentKVP in componentDict)
                            {
                                ComponentLocator compLoc = componentKVP.Key;
                                ammoBlownRecord.AddComponentDamage(2.0f, compLoc);
                            }
                        }
                    }
                }
            }
        }