public static int GetStorageCapacityRemaining(List <IMyCargoContainer> blocks, Action <string> Echo) { float totalCapacity = BlockUtils.GetSumOfBlockAttribute <IMyCargoContainer>(b => b.GetInventory().MaxVolume.ToIntSafe(), blocks); float currentAmount = BlockUtils.GetSumOfBlockAttribute <IMyCargoContainer>(b => b.GetInventory().CurrentVolume.ToIntSafe(), blocks); int percent = (int)(currentAmount / (totalCapacity == 0 ? 1 : totalCapacity) * 100); return(percent); }
public static int GetBatteryPercentRemaining(List <IMyBatteryBlock> blocks) { float totalCapacity = BlockUtils.GetSumOfBlockAttribute <IMyBatteryBlock>(b => b.MaxStoredPower, blocks); float currentAmount = BlockUtils.GetSumOfBlockAttribute <IMyBatteryBlock>(b => b.CurrentStoredPower, blocks); int percent = (int)(currentAmount / totalCapacity * 100); return(percent); }
public static int GetThrustCapacityRemaining(List <IMyThrust> blocks, IMyShipController shipController, Action <string> Echo) { //TODO: Need to calculate this float localGravity = 9.81f; int newtonsRequiredToLiftShip = (int)(shipController.CalculateShipMass().TotalMass *localGravity); float maximumThrustInNewtons = BlockUtils.GetSumOfBlockAttribute <IMyThrust>(b => b.MaxEffectiveThrust, blocks); int percent = (int)(newtonsRequiredToLiftShip / maximumThrustInNewtons * 100); return(percent); }