2015-03-03 02:29:57 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: esteldunedain
|
2015-03-03 02:29:57 +00:00
|
|
|
* Collect a entire tree of active actions
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Object <OBJECT>
|
|
|
|
* 1: Original action tree <ARRAY>
|
2015-03-20 02:32:44 +00:00
|
|
|
* 2: Parent path <ARRAY>
|
2015-03-03 02:29:57 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* Active children <ARRAY>
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-20 02:32:44 +00:00
|
|
|
EXPLODE_3_PVT(_this,_object,_origAction,_parentPath);
|
2015-03-03 02:29:57 +00:00
|
|
|
EXPLODE_2_PVT(_origAction,_origActionData,_origActionChildren);
|
|
|
|
|
2015-03-21 01:44:25 +00:00
|
|
|
private ["_target","_player","_fullPath","_activeChildren","_dynamicChildren","_action","_actionData","_x"];
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
_target = _object;
|
|
|
|
_player = ACE_player;
|
|
|
|
|
2015-04-17 02:53:54 +00:00
|
|
|
// Check if the function should be modified first
|
|
|
|
if !((_origActionData select 10) isEqualTo {}) then {
|
|
|
|
// It should, so make a copy and pass it to the modifierFunction
|
|
|
|
_origActionData = +_origActionData;
|
|
|
|
[_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10);
|
|
|
|
};
|
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Return nothing if the action itself is not active
|
2015-03-20 02:32:44 +00:00
|
|
|
if !([_target, ACE_player, _origActionData select 6] call (_origActionData select 4)) exitWith {
|
2015-03-03 02:29:57 +00:00
|
|
|
[]
|
|
|
|
};
|
|
|
|
|
2015-03-21 01:44:25 +00:00
|
|
|
_fullPath = +_parentPath;
|
|
|
|
_fullPath pushBack (_origActionData select 0);
|
2015-03-03 02:29:57 +00:00
|
|
|
_activeChildren = [];
|
|
|
|
|
2015-03-19 16:00:10 +00:00
|
|
|
// If there's a statement to dynamically insert children then execute it
|
2015-03-20 02:32:44 +00:00
|
|
|
if !({} isEqualTo (_origActionData select 5)) then {
|
2015-03-21 01:44:25 +00:00
|
|
|
_dynamicChildren = [_target, ACE_player, _origActionData select 6] call (_origActionData select 5);
|
2015-03-19 16:00:10 +00:00
|
|
|
|
2015-03-21 01:44:25 +00:00
|
|
|
// Collect dynamic children class actions
|
|
|
|
{
|
|
|
|
_action = [_x select 2, _x, _fullPath] call FUNC(collectActiveActionTree);
|
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
|
|
|
};
|
|
|
|
} forEach _dynamicChildren;
|
|
|
|
};
|
2015-03-20 02:32:44 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
// Collect children class actions
|
|
|
|
{
|
2015-03-20 02:32:44 +00:00
|
|
|
_action = [_object, _x, _fullPath] call FUNC(collectActiveActionTree);
|
2015-03-03 02:29:57 +00:00
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
|
|
|
};
|
|
|
|
} forEach _origActionChildren;
|
|
|
|
|
|
|
|
// Collect children object actions
|
|
|
|
{
|
2015-03-20 02:32:44 +00:00
|
|
|
EXPLODE_2_PVT(_x,_actionData,_pPath);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
// Check if the action is children of the original action
|
2015-03-20 02:32:44 +00:00
|
|
|
if (count _pPath == count _fullPath &&
|
|
|
|
{_pPath isEqualTo _fullPath}) then {
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-05-14 19:56:32 +00:00
|
|
|
_action = [_object, [_actionData,[]], _fullPath] call FUNC(collectActiveActionTree);
|
2015-03-20 02:32:44 +00:00
|
|
|
if ((count _action) > 0) then {
|
|
|
|
_activeChildren pushBack _action;
|
2015-03-03 02:29:57 +00:00
|
|
|
};
|
|
|
|
};
|
2015-05-14 19:56:32 +00:00
|
|
|
} forEach GVAR(objectActionList);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
// If the original action has no statement, and no children, don't display it
|
|
|
|
if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) exitWith {
|
|
|
|
// @todo: Account for showDisabled?
|
|
|
|
[]
|
|
|
|
};
|
2015-03-19 17:45:05 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-03-17 03:37:28 +00:00
|
|
|
[_origActionData, _activeChildren, _object]
|