% ============================================================================
% UpdateRocket.m
% Author: Brent Dingle, Ph.D.
% Creation Date: 2020
%
% ============================================================================
function rock = UpdateRocket(sim, curRock, thrust)
  % check if we have fuel to apply the suggested/desired thrust
  if (curRock.fuelMass <= 0)
    curRock.thrust = 0;
  else
    curRock.thrust = thrust;
  endif
  
  % calculate accel
  curRock.accel = GetAcceleration(sim, curRock);
  
  % update other state variables of the rocket based on dt
  % update velocity and height
  curRock.height = curRock.height + (curRock.vel * sim.dt);
  curRock.vel    = curRock.vel + (curRock.accel * sim.dt);
  
  % fuel mass is a little trickier, 
  % curRock.thrust must be set at this point
  curRock.fuelMass = UpdateMass(sim, curRock);
  
  
  % finally, return the new rocket state
  rock = curRock;
  
endfunction