add WaitUntilAndExecute

This commit is contained in:
jokoho48 2015-08-24 17:10:54 +02:00
parent 3eae83439b
commit 203c4d8a6c
2 changed files with 36 additions and 2 deletions

View File

@ -3,9 +3,9 @@
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
//Singe PFEH to handle execNextFrame and waitAndExec:
//Singe PFEH to handle execNextFrame, waitAndExec and waitUntilAndExec:
[{
private ["_entry"];
private ["_entry", "_deleted"];
//Handle the waitAndExec array:
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
@ -17,6 +17,18 @@
{
(_x select 0) call (_x select 1);
} forEach GVAR(nextFrameBufferA);
_deleted = 0;
{
_x params ["_condition", "_code", "_args"];
if ((_args call _condition)) then {
GVAR(waitUntilAndExecArray) deleteAt (_forEachIndex + _deleted);
_deleted = _deleted + 1;
_args call _code;
};
} forEach GVAR(waitUntilAndExecArray);
//Swap double-buffer:
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
GVAR(nextFrameBufferB) = [];

View File

@ -0,0 +1,22 @@
/*
* Author: joko // Jonas
*
* Executes a code once with after the Condition is True, using a PFH
*
* Argument:
* 0: Condition <CODE>
* 1: Code to execute <CODE>
* 2: Parameters to run the code with <ARRAY,ANY,NIL>
*
* Return value:
* None
*
* Example:
* [{(_this select 0) == vehicle (_this select 0)}, {(_this select 0) setDamage 1;}, [ACE_player], false] call ace_common_fnc_waitAndExecute
*
* Public: No
*/
#include "script_component.hpp"
GVAR(waitUntilAndExecArray) pushBack _this;