mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Interact Menu - Simplify fnc_renderActionPoints (#8186)
* Simplify fnc_renderActionPoints * Replace nil-count with forEach
This commit is contained in:
@ -35,51 +35,46 @@ private _fnc_renderNearbyActions = {
|
|||||||
private _target = _x;
|
private _target = _x;
|
||||||
|
|
||||||
// Quick oclussion test. Skip objects more than 1 m behind the camera plane
|
// Quick oclussion test. Skip objects more than 1 m behind the camera plane
|
||||||
private _lambda = ((getPosASL _x) vectorDiff GVAR(cameraPosASL)) vectorDotProduct GVAR(cameraDir);
|
private _lambda = getPosASL _target vectorDiff GVAR(cameraPosASL) vectorDotProduct GVAR(cameraDir);
|
||||||
if ((_lambda > -1) && {!isObjectHidden _target}) then {
|
if (
|
||||||
private _numInteractions = 0;
|
_lambda <= -1
|
||||||
|
|| {isObjectHidden _target}
|
||||||
// Prevent interacting with yourself or your own vehicle
|
// Prevent interacting with yourself or your own vehicle
|
||||||
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
|
|| {_target in [ACE_player, vehicle ACE_player]}
|
||||||
|
) then {continue};
|
||||||
|
|
||||||
// Iterate through object actions, find base level actions and render them if appropiate
|
private _hasInteractions = false;
|
||||||
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
|
||||||
{
|
|
||||||
// Only render them directly if they are base level actions
|
|
||||||
if ((_x select 1) isEqualTo []) then {
|
|
||||||
// Try to render the menu
|
|
||||||
private _action = _x;
|
|
||||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
|
||||||
_numInteractions = _numInteractions + 1;
|
|
||||||
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
nil
|
|
||||||
} count GVAR(objectActionList);
|
|
||||||
|
|
||||||
// Iterate through base level class actions and render them if appropiate
|
// Iterate through object actions, find base level actions and render them if appropiate
|
||||||
private _namespace = GVAR(ActNamespace);
|
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
||||||
private _classActions = _namespace getVariable typeOf _target;
|
{
|
||||||
|
// Only render them directly if they are base level actions
|
||||||
{
|
if (_x select 1 isNotEqualTo []) then {continue};
|
||||||
private _action = _x;
|
// Try to render the menu
|
||||||
// Try to render the menu
|
private _action = _x;
|
||||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||||
_numInteractions = _numInteractions + 1;
|
_hasInteractions = true;
|
||||||
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
||||||
};
|
|
||||||
nil
|
|
||||||
} count _classActions;
|
|
||||||
|
|
||||||
// Limit the amount of objects the player can interact with
|
|
||||||
if (_numInteractions > 0) then {
|
|
||||||
_numInteractObjects = _numInteractObjects + 1;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
} forEach GVAR(objectActionList);
|
||||||
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};
|
|
||||||
|
|
||||||
nil
|
// Iterate through base level class actions and render them if appropiate
|
||||||
} count _nearestObjects;
|
private _classActions = GVAR(ActNamespace) getVariable [typeOf _target, []];
|
||||||
|
{
|
||||||
|
private _action = _x;
|
||||||
|
// Try to render the menu
|
||||||
|
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||||
|
_hasInteractions = true;
|
||||||
|
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
||||||
|
};
|
||||||
|
} forEach _classActions;
|
||||||
|
|
||||||
|
// Limit the amount of objects the player can interact with
|
||||||
|
if (_hasInteractions) then {
|
||||||
|
INC(_numInteractObjects);
|
||||||
|
if (_numInteractObjects >= MAXINTERACTOBJECTS) then {break};
|
||||||
|
};
|
||||||
|
} forEach _nearestObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _fnc_renderLastFrameActions = {
|
private _fnc_renderLastFrameActions = {
|
||||||
@ -88,8 +83,7 @@ private _fnc_renderLastFrameActions = {
|
|||||||
|
|
||||||
GVAR(objectActionList) = _objectActionList;
|
GVAR(objectActionList) = _objectActionList;
|
||||||
[_target, _action] call FUNC(renderBaseMenu);
|
[_target, _action] call FUNC(renderBaseMenu);
|
||||||
nil
|
} forEach GVAR(foundActions);
|
||||||
} count GVAR(foundActions);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private _fnc_renderSelfActions = {
|
private _fnc_renderSelfActions = {
|
||||||
@ -112,16 +106,14 @@ private _fnc_renderSelfActions = {
|
|||||||
{
|
{
|
||||||
_action = _x;
|
_action = _x;
|
||||||
[_target, _action, _pos] call FUNC(renderBaseMenu);
|
[_target, _action, _pos] call FUNC(renderBaseMenu);
|
||||||
nil
|
} forEach _classActions;
|
||||||
} count _classActions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private _fnc_renderZeusActions = {
|
private _fnc_renderZeusActions = {
|
||||||
{
|
{
|
||||||
private _action = _x;
|
private _action = _x;
|
||||||
[_this, _action, [0.5, 0.5]] call FUNC(renderBaseMenu);
|
[_this, _action, [0.5, 0.5]] call FUNC(renderBaseMenu);
|
||||||
nil
|
} forEach GVAR(ZeusActions);
|
||||||
} count GVAR(ZeusActions);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -178,5 +170,4 @@ if (count GVAR(collectedActionPoints) > 1) then {
|
|||||||
{
|
{
|
||||||
_x params ["_z", "_sPos", "_activeActionTree"];
|
_x params ["_z", "_sPos", "_activeActionTree"];
|
||||||
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
||||||
nil
|
} forEach GVAR(collectedActionPoints);
|
||||||
} count GVAR(collectedActionPoints);
|
|
||||||
|
Reference in New Issue
Block a user