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(handleEffects);
PREP(handlePlayerChanged); PREP(handlePlayerChanged);
PREP(handleStaminaBar); PREP(handleStaminaBar);
PREP(mainLoop);
PREP(moduleSettings); PREP(moduleSettings);
PREP(pfhMain);
PREP(removeDutyFactor); PREP(removeDutyFactor);

View File

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

View File

@ -1,6 +1,6 @@
/* /*
* Author: BaerMitUmlaut * Author: BaerMitUmlaut
* Main perFrameHandler that updates fatigue values. * Main looping function that updates fatigue values.
* *
* Arguments: * Arguments:
* None * None
@ -9,7 +9,9 @@
* None * None
*/ */
#include "script_component.hpp" #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 _currentWork = REE;
private _currentSpeed = (vectorMagnitude (velocity ACE_player)) min 6; private _currentSpeed = (vectorMagnitude (velocity ACE_player)) min 6;
@ -61,3 +63,5 @@ private _perceivedFatigue = 1 - (_anReservePercentage min _aeReservePercentage);
if (GVAR(enableStaminaBar)) then { if (GVAR(enableStaminaBar)) then {
[GVAR(anReserve) / AN_MAXRESERVE] call FUNC(handleStaminaBar); [GVAR(anReserve) / AN_MAXRESERVE] call FUNC(handleStaminaBar);
}; };
[FUNC(mainLoop), [], 1] call CBA_fnc_waitAndExecute;