bool convert_metal(float metal) { metal_pump.RequestTransfer(metal); if (metal_pump.TransferResource()) { if (metal > 0) { if (metal_pump.PartialTransfer) { metal_pump.Revert(); metal_pump.Clear(); return(false); } TanksMass += metal_pump.Result * metal_pump.Resource.density; } else { if (metal_pump.PartialTransfer && metal_pump.Ratio < 0.999f) { Utils.Message("Not enough storage for {0}. The excess was disposed of.", BuildTanksFrom); } TanksMass += metal * metal_pump.Resource.density; } if (TanksMass < 0) { TanksMass = 0; } } return(true); }
public float CompressGas() { if (part.vessel == null || part.vessel.mainBody == null) { return(0); } if (!part.vessel.mainBody.atmosphere) { return(0); } var pressure = part.vessel.mainBody.GetPressure(part.vessel.altitude); if (pressure < 1e-6) { return(0); } pressure /= Math.Max(part.vessel.mainBody.atmospherePressureSeaLevel, 101.325); socket.RequestTransfer(ConsumptionRate * TimeWarp.fixedDeltaTime); if (!socket.TransferResource()) { return(0); } OutputFraction = socket.Ratio; return((float)(pressure * ConversionRate * socket.Result)); }
void FixedUpdate() { if (target != null) { AddForceAlongGrapples(target, GrappleForce); if (socket != null) { socket.RequestTransfer(GrappleEnergyConsumption * TimeWarp.fixedDeltaTime); if (!socket.TransferResource() || socket.PartialTransfer) { target = null; state = State.Idle; if (armAnimator != null) { armAnimator.Close(); } } } } }