mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add WaitUntilAndExecute
This commit is contained in:
parent
3eae83439b
commit
203c4d8a6c
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
//IGNORE_PRIVATE_WARNING("_handleNetEvent", "_handleRequestAllSyncedEvents", "_handleRequestSyncedEvent", "_handleSyncedEvent");
|
//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:
|
//Handle the waitAndExec array:
|
||||||
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
|
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);
|
(_x select 0) call (_x select 1);
|
||||||
} forEach GVAR(nextFrameBufferA);
|
} 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:
|
//Swap double-buffer:
|
||||||
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
|
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
|
||||||
GVAR(nextFrameBufferB) = [];
|
GVAR(nextFrameBufferB) = [];
|
||||||
|
22
addons/common/functions/fnc_waitUnilAndExecute.sqf
Normal file
22
addons/common/functions/fnc_waitUnilAndExecute.sqf
Normal 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;
|
Loading…
Reference in New Issue
Block a user