Use waitAndExecute for fatigue loop (#4453)

* Use waitAndExecute for fatigue loop

Close #4379
- Will use CBA_missionTime so it repsects pause and time accl
- Possible performance improvment over using a PFEH

* Rename main loop function
This commit is contained in:
PabstMirror 2016-09-23 16:40:52 -05:00 committed by GitHub
parent a7c75a3bf6
commit 0b3d38a72f
3 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,6 @@ PREP(getMetabolicCosts);
PREP(handleEffects);
PREP(handlePlayerChanged);
PREP(handleStaminaBar);
PREP(mainLoop);
PREP(moduleSettings);
PREP(pfhMain);
PREP(removeDutyFactor);

View File

@ -37,8 +37,8 @@ if (!hasInterface) exitWith {};
}] call FUNC(addDutyFactor);
};
// - Add main PFH -------------------------------------------------------------
[FUNC(pfhMain), 1, []] call CBA_fnc_addPerFrameHandler;
// - Add main loop at 1 second interval -------------------------------------------------------------
[FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;
["ace_settingChanged", {

View File

@ -1,6 +1,6 @@
/*
* Author: BaerMitUmlaut
* Main perFrameHandler that updates fatigue values.
* Main looping function that updates fatigue values.
*
* Arguments:
* None
@ -9,7 +9,9 @@
* None
*/
#include "script_component.hpp"
if (!alive ACE_player) exitWith {}; // Dead people don't breath, Will also handle null (Map intros)
if (!alive ACE_player) exitWith { // Dead people don't breath, Will also handle null (Map intros)
[FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute;
};
private _currentWork = REE;
private _currentSpeed = (vectorMagnitude (velocity ACE_player)) min 6;
@ -61,3 +63,5 @@ private _perceivedFatigue = 1 - (_anReservePercentage min _aeReservePercentage);
if (GVAR(enableStaminaBar)) then {
[GVAR(anReserve) / AN_MAXRESERVE] call FUNC(handleStaminaBar);
};
[FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute;