2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-03-24 15:27:27 +00:00
|
|
|
/*
|
|
|
|
* Author: NouberNou and esteldunedain
|
|
|
|
* Render all action points
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-24 15:27:27 +00:00
|
|
|
* None
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-03-24 15:27:27 +00:00
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* call ACE_interact_menu_fnc_renderActionPoints
|
|
|
|
*
|
2015-03-24 15:27:27 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
GVAR(currentOptions) = [];
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _player = ACE_player;
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-02-18 23:20:02 +00:00
|
|
|
GVAR(cameraPosASL) = AGLtoASL (positionCameraToWorld [0, 0, 0]);
|
|
|
|
GVAR(cameraDir) = (AGLtoASL (positionCameraToWorld [0, 0, 1])) vectorDiff GVAR(cameraPosASL);
|
2015-05-02 17:37:58 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _fnc_renderNearbyActions = {
|
2015-03-24 15:27:27 +00:00
|
|
|
// Render all nearby interaction menus
|
|
|
|
#define MAXINTERACTOBJECTS 3
|
|
|
|
|
2015-04-20 04:16:51 +00:00
|
|
|
GVAR(foundActions) = [];
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(lastTimeSearchedActions) = diag_tickTime;
|
2015-04-20 04:16:51 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _numInteractObjects = 0;
|
|
|
|
private _nearestObjects = nearestObjects [ACE_player, ["All"], 13];
|
2015-03-24 15:27:27 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _target = _x;
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2015-04-15 02:32:03 +00:00
|
|
|
// Quick oclussion test. Skip objects more than 1 m behind the camera plane
|
2016-02-18 23:20:02 +00:00
|
|
|
private _lambda = ((getPosASL _x) vectorDiff GVAR(cameraPosASL)) vectorDotProduct GVAR(cameraDir);
|
2015-11-29 03:35:25 +00:00
|
|
|
if ((_lambda > -1) && {!isObjectHidden _target}) then {
|
2016-01-08 04:43:37 +00:00
|
|
|
private _numInteractions = 0;
|
2015-04-15 02:22:08 +00:00
|
|
|
// Prevent interacting with yourself or your own vehicle
|
|
|
|
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
|
2015-04-15 01:53:10 +00:00
|
|
|
|
2015-04-15 02:22:08 +00:00
|
|
|
// Iterate through object actions, find base level actions and render them if appropiate
|
|
|
|
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
|
|
|
{
|
|
|
|
// Only render them directly if they are base level actions
|
2016-01-08 04:43:37 +00:00
|
|
|
if ((_x select 1) isEqualTo []) then {
|
2015-04-15 02:22:08 +00:00
|
|
|
// Try to render the menu
|
2016-01-08 04:43:37 +00:00
|
|
|
private _action = _x;
|
2015-04-15 02:22:08 +00:00
|
|
|
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
|
|
|
_numInteractions = _numInteractions + 1;
|
2015-07-16 20:28:27 +00:00
|
|
|
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
2015-04-15 02:22:08 +00:00
|
|
|
};
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count GVAR(objectActionList);
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2015-04-15 02:22:08 +00:00
|
|
|
// Iterate through base level class actions and render them if appropiate
|
2016-03-06 05:22:38 +00:00
|
|
|
private _namespace = GVAR(ActNamespace);
|
|
|
|
private _classActions = _namespace getVariable typeOf _target;
|
|
|
|
|
2015-04-15 02:22:08 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _action = _x;
|
2015-04-15 02:22:08 +00:00
|
|
|
// Try to render the menu
|
2015-03-24 15:27:27 +00:00
|
|
|
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
|
|
|
_numInteractions = _numInteractions + 1;
|
2015-07-16 20:28:27 +00:00
|
|
|
GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)];
|
2015-03-24 15:27:27 +00:00
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count _classActions;
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2015-04-15 02:22:08 +00:00
|
|
|
// Limit the amount of objects the player can interact with
|
|
|
|
if (_numInteractions > 0) then {
|
|
|
|
_numInteractObjects = _numInteractObjects + 1;
|
2015-03-24 15:27:27 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-04-15 02:32:03 +00:00
|
|
|
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count _nearestObjects;
|
2015-03-24 15:27:27 +00:00
|
|
|
};
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _fnc_renderLastFrameActions = {
|
2015-04-20 04:16:51 +00:00
|
|
|
{
|
2015-08-04 22:46:57 +00:00
|
|
|
_x params ["_target", "_action", "_objectActionList"];
|
2015-07-16 20:28:27 +00:00
|
|
|
|
|
|
|
GVAR(objectActionList) = _objectActionList;
|
|
|
|
[_target, _action] call FUNC(renderBaseMenu);
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count GVAR(foundActions);
|
2015-04-20 04:16:51 +00:00
|
|
|
};
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _fnc_renderSelfActions = {
|
|
|
|
private _target = _this;
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
// Set object actions for collectActiveActionTree
|
2015-03-24 15:27:27 +00:00
|
|
|
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
|
|
|
|
|
|
|
|
// Iterate through base level class actions and render them if appropiate
|
2016-03-06 05:22:38 +00:00
|
|
|
private _namespace = GVAR(ActSelfNamespace);
|
|
|
|
private _classActions = _namespace getVariable typeOf _target;
|
2016-01-08 04:43:37 +00:00
|
|
|
|
|
|
|
private _pos = if !(GVAR(useCursorMenu)) then {
|
|
|
|
//Convert to ASL, add offset and then convert back to AGL (handles waves when over water)
|
|
|
|
ASLtoAGL ((AGLtoASL (positionCameraToWorld [0, 0, 0])) vectorAdd GVAR(selfMenuOffset));
|
2015-05-12 21:04:42 +00:00
|
|
|
} else {
|
|
|
|
[0.5, 0.5]
|
|
|
|
};
|
2015-05-14 13:54:22 +00:00
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
{
|
|
|
|
_action = _x;
|
|
|
|
[_target, _action, _pos] call FUNC(renderBaseMenu);
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count _classActions;
|
2015-03-24 15:27:27 +00:00
|
|
|
};
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _fnc_renderZeusActions = {
|
2015-06-04 22:11:35 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _action = _x;
|
2015-06-08 12:12:27 +00:00
|
|
|
[_this, _action, [0.5, 0.5]] call FUNC(renderBaseMenu);
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count GVAR(ZeusActions);
|
2015-06-04 22:11:35 +00:00
|
|
|
};
|
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2015-05-02 17:37:58 +00:00
|
|
|
GVAR(collectedActionPoints) resize 0;
|
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
// Render nearby actions, unit self actions or vehicle self actions as appropiate
|
|
|
|
if (GVAR(openedMenuType) == 0) then {
|
2015-06-04 22:11:35 +00:00
|
|
|
if (isNull curatorCamera) then {
|
2017-08-22 21:07:45 +00:00
|
|
|
if (!(isNull (ACE_controlledUAV select 0))) then {
|
|
|
|
// Render UAV self actions when in control of UAV AI
|
|
|
|
(ACE_controlledUAV select 0) call _fnc_renderSelfActions;
|
|
|
|
} else {
|
|
|
|
if (vehicle ACE_player == ACE_player) then {
|
|
|
|
if (diag_tickTime > GVAR(lastTimeSearchedActions) + 0.20) then {
|
|
|
|
// Once every 0.2 secs, collect nearby objects active and visible action points and render them
|
|
|
|
call _fnc_renderNearbyActions;
|
|
|
|
} else {
|
|
|
|
// The rest of the frames just draw the same action points rendered the last frame
|
|
|
|
call _fnc_renderLastFrameActions;
|
|
|
|
};
|
2015-06-04 22:11:35 +00:00
|
|
|
} else {
|
2017-08-22 21:07:45 +00:00
|
|
|
// Render vehicle self actions when in vehicle
|
|
|
|
(vehicle ACE_player) call _fnc_renderSelfActions;
|
2015-06-04 22:11:35 +00:00
|
|
|
};
|
2015-04-20 04:16:51 +00:00
|
|
|
};
|
2015-03-24 15:27:27 +00:00
|
|
|
} else {
|
2015-06-04 22:11:35 +00:00
|
|
|
// Render zeus actions when zeus open
|
|
|
|
(getAssignedCuratorLogic player) call _fnc_renderZeusActions;
|
2015-03-24 15:27:27 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
ACE_player call _fnc_renderSelfActions;
|
|
|
|
};
|
2015-05-02 17:37:58 +00:00
|
|
|
|
|
|
|
if (count GVAR(collectedActionPoints) > 1) then {
|
|
|
|
// Do the oclusion pass
|
|
|
|
|
|
|
|
// Order action points according to z
|
2015-05-14 13:54:22 +00:00
|
|
|
GVAR(collectedActionPoints) sort true;
|
2015-05-02 17:37:58 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
for [{private _i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do {
|
|
|
|
for [{private _j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do {
|
2015-05-02 17:37:58 +00:00
|
|
|
// Check if action point _i is ocluded by _j
|
2016-01-08 04:43:37 +00:00
|
|
|
private _delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1));
|
2015-05-02 17:37:58 +00:00
|
|
|
|
|
|
|
// If _i is inside a cone with 20º half angle with origin on _j
|
2016-07-03 03:46:36 +00:00
|
|
|
if ((_delta select 2 > 0.94) && {((GVAR(collectedActionPoints) select _i select 1) distance2d (GVAR(collectedActionPoints) select _j select 1)) < 0.1}) exitWith {
|
2015-05-02 17:37:58 +00:00
|
|
|
GVAR(collectedActionPoints) deleteAt _i;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Render the non-ocluded points
|
|
|
|
{
|
2015-08-04 22:46:57 +00:00
|
|
|
_x params ["_z", "_sPos", "_activeActionTree"];
|
2015-05-02 17:37:58 +00:00
|
|
|
[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu);
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count GVAR(collectedActionPoints);
|