| 1372 | } |
| 1373 | |
| 1374 | F32 zNPCCommon::ThrottleAdjust(F32 dt, F32 spd_want, F32 accel) |
| 1375 | { |
| 1376 | NPCConfig* cfg = this->cfg_npc; |
| 1377 | F32 acc; |
| 1378 | S32 speedup = (spd_want > this->spd_throttle); |
| 1379 | |
| 1380 | acc = (accel < 0.0f) ? (dt * cfg->fac_accelMax) : (dt * accel); |
| 1381 | |
| 1382 | if (xeq(spd_want, this->spd_throttle, acc)) |
| 1383 | { |
| 1384 | this->spd_throttle = spd_want; |
| 1385 | return this->spd_throttle; |
| 1386 | } |
| 1387 | |
| 1388 | if (speedup) |
| 1389 | { |
| 1390 | this->spd_throttle += acc; |
| 1391 | this->spd_throttle = CLAMP(this->spd_throttle, 0.0f, spd_want); |
| 1392 | } |
| 1393 | else |
| 1394 | { |
| 1395 | this->spd_throttle -= acc; |
| 1396 | this->spd_throttle = MAX(spd_want, this->spd_throttle); |
| 1397 | } |
| 1398 | |
| 1399 | return this->spd_throttle; |
| 1400 | } |
| 1401 | |
| 1402 | F32 zNPCCommon::ThrottleAccel(F32 dt, S32 speedup, F32 pct_max) |
| 1403 | { |
no outgoing calls
no test coverage detected