public static void ReCalculateShipTonnaageAndHTK(Entity shipEntity)
        {
            ShipInfoDB           shipInfo           = shipEntity.GetDataBlob <ShipInfoDB>();
            ComponentInstancesDB componentInstances = shipEntity.GetDataBlob <ComponentInstancesDB>();
            float  totalTonnage = 0;
            int    totalHTK     = 0;
            double totalVolume  = 0;

            foreach (var componentDesign in componentInstances.GetComponentsByDesigns())
            {
                var componentVolume  = componentInstances.AllDesigns[componentDesign.Key].GetDataBlob <MassVolumeDB>().Volume;
                var componentTonnage = componentInstances.AllDesigns[componentDesign.Key].GetDataBlob <ComponentInfoDB>().SizeInTons;

                foreach (var componentInstance in componentDesign.Value)
                {
                    totalHTK     += componentInstance.GetDataBlob <ComponentInstanceInfoDB>().HTKRemaining;
                    totalVolume  += componentVolume;
                    totalTonnage += componentTonnage;
                    if (!componentInstances.ComponentDictionary.ContainsKey(componentInstance))
                    {
                        componentInstances.ComponentDictionary.Add(componentInstance, totalVolume);
                    }
                }
            }
            if (shipInfo.Tonnage != totalTonnage)
            {
                shipInfo.Tonnage = totalTonnage;
                ShipMovementProcessor.CalcMaxSpeedAndFuelUsage(shipEntity);
            }
            shipInfo.InternalHTK = totalHTK;
            MassVolumeDB mvDB = shipEntity.GetDataBlob <MassVolumeDB>();

            mvDB.Mass    = totalTonnage;
            mvDB.Volume  = totalVolume;
            mvDB.Density = MassVolumeDB.CalculateDensity(totalTonnage, totalVolume);
            mvDB.Radius  = MassVolumeDB.CalculateRadius(totalTonnage, mvDB.Density);
        }
        public static void ReCalculateShipTonnaageAndHTK(Entity shipEntity)
        {
            ShipInfoDB           shipInfo           = shipEntity.GetDataBlob <ShipInfoDB>();
            ComponentInstancesDB componentInstances = shipEntity.GetDataBlob <ComponentInstancesDB>();
            float  totalTonnage = 0;
            int    totalHTK     = 0;
            double totalVolume  = 0;

            foreach (KeyValuePair <Guid, List <ComponentInstance> > instance in componentInstances.GetComponentsByDesigns())
            {
                var componentVolume  = componentInstances.AllDesigns[instance.Key].VolumePerUnit;
                var componentTonnage = componentInstances.AllDesigns[instance.Key].MassPerUnit;

                foreach (var componentInstance in instance.Value)
                {
                    totalHTK     += componentInstance.HTKRemaining;
                    totalVolume  += componentVolume;
                    totalTonnage += componentTonnage;
                }
            }
            if (shipInfo.Tonnage != totalTonnage)
            {
                shipInfo.Tonnage = totalTonnage;
                if (shipEntity.HasDataBlob <WarpAbilityDB>())
                {
                    ShipMovementProcessor.CalcMaxWarpAndEnergyUsage(shipEntity);
                }
            }
            shipInfo.InternalHTK = totalHTK;
            MassVolumeDB mvDB = shipEntity.GetDataBlob <MassVolumeDB>();

            mvDB.MassDry     = totalTonnage;
            mvDB.Volume_m3   = totalVolume;
            mvDB.Density_gcm = MassVolumeDB.CalculateDensity(totalTonnage, totalVolume);
            mvDB.RadiusInAU  = MassVolumeDB.CalculateRadius_Au(totalTonnage, mvDB.Density_gcm);
        }