private int UpdateVesselInfo(VesselInfo vesselInfo, Vessel vessel) { int crewCapacity = 0; vesselInfo.ClearAmounts(); foreach (Part part in vessel.parts) { crewCapacity += part.CrewCapacity; if (part.protoModuleCrew.Any()) { vesselInfo.numCrew += part.protoModuleCrew.Count; ++vesselInfo.numOccupiedParts; } foreach (PartResource resource in part.Resources) { if (resource.flowState) { if (resource.info.id == globalSettings.FoodId) { vesselInfo.remainingFood += resource.amount; vesselInfo.maxFood += resource.maxAmount; } else if (resource.info.id == globalSettings.WaterId) { vesselInfo.remainingWater += resource.amount; vesselInfo.maxWater += resource.maxAmount; } else if (resource.info.id == globalSettings.OxygenId) { vesselInfo.remainingOxygen += resource.amount; vesselInfo.maxOxygen += resource.maxAmount; } else if (resource.info.id == globalSettings.ElectricityId) { vesselInfo.remainingElectricity += resource.amount; vesselInfo.maxElectricity += resource.maxAmount; } else if (resource.info.id == globalSettings.CO2Id) { vesselInfo.remainingCO2 += resource.amount; } else if (resource.info.id == globalSettings.WasteId) { vesselInfo.remainingWaste += resource.amount; } else if (resource.info.id == globalSettings.WasteWaterId) { vesselInfo.remainingWasteWater += resource.amount; } } } } return(crewCapacity); }
private int UpdateVesselInfo(VesselInfo vesselInfo, Vessel vessel) { int crewCapacity = 0; vesselInfo.ClearAmounts(); foreach (Part part in vessel.parts) { crewCapacity += part.CrewCapacity; if (part.protoModuleCrew.Any()) { vesselInfo.numCrew += part.protoModuleCrew.Count; ++vesselInfo.numOccupiedParts; } foreach (PartResource resource in part.Resources) { if (resource.flowState) { if (resource.info.id == globalSettings.FoodId) { vesselInfo.remainingFood += resource.amount; vesselInfo.maxFood += resource.maxAmount; } else if (resource.info.id == globalSettings.WaterId) { vesselInfo.remainingWater += resource.amount; vesselInfo.maxWater += resource.maxAmount; } else if (resource.info.id == globalSettings.OxygenId) { vesselInfo.remainingOxygen += resource.amount; vesselInfo.maxOxygen += resource.maxAmount; } else if (resource.info.id == globalSettings.ElectricityId) { vesselInfo.remainingElectricity += resource.amount; vesselInfo.maxElectricity += resource.maxAmount; } else if (resource.info.id == globalSettings.CO2Id) { vesselInfo.remainingCO2 += resource.amount; } else if (resource.info.id == globalSettings.WasteId) { vesselInfo.remainingWaste += resource.amount; } else if (resource.info.id == globalSettings.WasteWaterId) { vesselInfo.remainingWasteWater += resource.amount; } } } } return crewCapacity; }