Adding hideUnit functions to ace_common

This commit is contained in:
SilentSpike 2015-07-03 02:14:58 +01:00
parent 13f5b08892
commit d036639b46
4 changed files with 75 additions and 1 deletions

View File

@ -6,7 +6,7 @@
//Singe PFEH to handle execNextFrame and waitAndExec:
[{
private ["_entry"];
//Handle the waitAndExec array:
while {((count GVAR(waitAndExecArray)) > 0) && {((GVAR(waitAndExecArray) select 0) select 0) <= ACE_Time}} do {
_entry = GVAR(waitAndExecArray) deleteAt 0;
@ -56,6 +56,10 @@
["setFuel", {(_this select 0) setFuel (_this select 1)}] call FUNC(addEventhandler);
["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler);
if (isServer) then {
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
};
// hack to get PFH to work in briefing
[QGVAR(onBriefingPFH), "onEachFrame", {
if (ACE_time > 0) exitWith {

View File

@ -102,6 +102,7 @@ PREP(goKneeling);
PREP(hadamardProduct);
PREP(hasItem);
PREP(hasMagazine);
PREP(hideUnit);
PREP(inheritsFrom);
PREP(insertionSort);
PREP(interpolateFromArray);
@ -179,6 +180,7 @@ PREP(toBin);
PREP(toBitmask);
PREP(toHex);
PREP(toNumber);
PREP(unhideUnit);
PREP(uniqueElementsOnly);
PREP(unloadPerson);
PREP(unloadPersonLocal);

View File

@ -0,0 +1,34 @@
/*
* Author: SilentSpike (based on muteUnit)
* Globally hides a unit. This allows the handling of more than one reason to hide an object globally.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Reason to hide the unit <STRING>
*
* Return Value:
* nil
*
* Example:
* [ACE_Player, "SpectatorMode"] call ace_common_fnc_hideUnit
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_reason);
if (isNull _unit) exitWith {};
private "_setHiddenReasons";
_setHiddenReasons = _unit getVariable [QGVAR(setHiddenReasons), []];
if !(_reason in _setHiddenReasons) then {
_setHiddenReasons pushBack _reason;
_unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true];
};
if !(isObjectHidden _unit) then {
["hideObjectGlobal",[_unit,true]] call FUNC(serverEvent);
};

View File

@ -0,0 +1,34 @@
/*
* Author: SilentSpike (based on unmuteUnit)
* Globally unhides a unit. Only unhides if the last reason was removed.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Reason to unhide the unit <STRING>
*
* Return Value:
* nil
*
* Example:
* [ACE_Player, "SpectatorMode"] call ace_common_fnc_unhideUnit
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_reason);
if (isNull _unit) exitWith {};
private "_setHiddenReasons";
_setHiddenReasons = _unit getVariable [QGVAR(setHiddenReasons), []];
if (_reason in _setHiddenReasons) then {
_setHiddenReasons deleteAt (_setHiddenReasons find _reason);
_unit setVariable [QGVAR(setHiddenReasons), _setHiddenReasons, true];
};
if (_setHiddenReasons isEqualTo []) then {
["hideObjectGlobal",[_unit,false]] call FUNC(serverEvent);
};