private void SetBalancedThrust(ThrustDirection direction, float value) { if (IsClosed) { return; } if (_maxEffectiveThrust[direction] - _currentlyUtilizedThrust[direction] > value) { InsufficientThrustAvailable?.Invoke(direction); } foreach (ControllableThruster thruster in _thrusters[direction]) { thruster.SetThrust(value / _thrusters[direction].Count); } _currentlyUtilizedThrust[direction] = value; }
private void SetRollingThrust(ThrustDirection direction, float value) { if (IsClosed) { return; } float tmpValue = value; _currentlyUtilizedThrust[direction] = 0; foreach (ControllableThruster thruster in _thrusters[direction]) { if (Math.Abs(value) <= 0) { thruster.SetThrust(0); continue; } float availableThrust = thruster.MaxThrust() - thruster.CurrentThrust(); if (availableThrust <= 0) { continue; } if (availableThrust > tmpValue) { thruster.SetThrust(thruster.CurrentThrust() + tmpValue); tmpValue = 0; } else { thruster.SetThrust(thruster.MaxThrust()); tmpValue -= thruster.MaxThrust(); } if (tmpValue > 0) { continue; } thruster.SetThrust(0); } if (tmpValue > 0) { InsufficientThrustAvailable?.Invoke(direction); _currentlyUtilizedThrust[direction] = value - tmpValue; return; } _currentlyUtilizedThrust[direction] = value; }