public static float GetEmptyHardpointMass(MechDef mechDef)
 {
     if (!_inFinish)
     {
         HardpointInfo stockHardpoints   = GetStockHardpoints(mechDef);
         HardpointInfo currentHardpoints = GetHardpoints(mechDef);
         HardpointInfo emptyHardpoints   = stockHardpoints - currentHardpoints;
         return(emptyHardpoints.HardpointMass);
     }
     else
     {
         return(0);
     }
 }
            public static bool GetHardpointCountForLocation_Prefix(MechDef mechDef, ChassisLocations loc,
                                                                   ref int numBallistic, ref int numEnergy, ref int numMissile, ref int numSmall)
            {
                try
                {
                    HardpointInfo stockHardpoints = GetStockHardpointsByLocation(mechDef, loc);

                    numBallistic += stockHardpoints.NumBallistic;
                    numEnergy    += stockHardpoints.NumEnergy;
                    numMissile   += stockHardpoints.NumMissile;
                    numSmall     += stockHardpoints.NumSmall;

                    return(false);
                }
                catch (Exception e)
                {
                    _harmonyManager.Log(e);
                    return(true);
                }
            }
            public static void Postfix(
                MechLabLocationWidget __instance,
                MechComponentDef newComponentDef,
                MechLabPanel ___mechLab,
                LocationDef ___chassisLocationDef,
                List <MechLabItemSlotElement> ___localInventory,
                TextMeshProUGUI ___locationName,
                ref bool __result)
            {
                try
                {
                    if (__result)
                    {
                        ChassisLocations location           = ___chassisLocationDef.Location;
                        MechDef          mechDef            = ___mechLab.activeMechDef;
                        HardpointInfo    stockHardpointInfo = GetStockHardpointsByLocation(mechDef, location);
                        HardpointInfo    localHardpointInfo = ___localInventory
                                                              .Select(x => x.ComponentRef.Def)
                                                              .Concat(new[] { newComponentDef })
                                                              .Select(x => new HardpointInfo(x))
                                                              .Aggregate((x, y) => x + y);

                        _harmonyManager.DebugLog("Hardpoint info: " + localHardpointInfo.NumMissileTubes + ", " +
                                                 stockHardpointInfo.NumMissileTubes + ", " +
                                                 localHardpointInfo.NumEnergyLarge + ", " +
                                                 stockHardpointInfo.NumEnergyLarge);

                        if (localHardpointInfo.NumMissileTubes > stockHardpointInfo.NumMissileTubes)
                        {
                            __instance.SetDropErrorMessage(
                                "Cannot add {0} to {1}: Over allocated {2}/{3} missile tubes.",
                                newComponentDef.Description.Name,
                                ___locationName.text,
                                localHardpointInfo.NumMissileTubes,
                                stockHardpointInfo.NumMissileTubes);
                            __result = false;
                        }
                        else if (localHardpointInfo.NumEnergyLarge > stockHardpointInfo.NumEnergyLarge)
                        {
                            __instance.SetDropErrorMessage(
                                "Cannot add {0} to {1}: Over allocated {2}/{3} large energy weapons.",
                                newComponentDef.Description.Name,
                                ___locationName.text,
                                localHardpointInfo.NumEnergyLarge,
                                stockHardpointInfo.NumEnergyLarge);
                            __result = false;
                        }
                        else
                        {
                            int allowedJumpJets = mechDef.AllowedJumpJets();
                            int currentJumpJets = localHardpointInfo.NumJumpJets;
                            if (currentJumpJets > allowedJumpJets)
                            {
                                __instance.SetDropErrorMessage(
                                    "Cannot add {0} to {1}: Over allocated {2}/{3} jump jets.",
                                    newComponentDef.Description.Name,
                                    ___locationName.text,
                                    localHardpointInfo.NumEnergyLarge,
                                    stockHardpointInfo.NumEnergyLarge);
                                __result = false;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _harmonyManager.Log(e);
                }
            }