change vehicle flag actions to use class inheritance instead of object
This commit is contained in:
@@ -16,94 +16,86 @@ private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_
|
|||||||
private _parentClass = _x;
|
private _parentClass = _x;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// add CBA class event handler to add actions to vehicles after they are initialized
|
// create the root action
|
||||||
// all classes that inherit from the base classes will also have this applied
|
|
||||||
// an exclusion function is present for manually excluding specific classes
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
[_parentClass, "InitPost", {
|
private _rootActionID = QGVAR(SetVehicleFlagAction);
|
||||||
|
private _flagRootAction = [
|
||||||
|
_rootActionID, // id
|
||||||
|
"Set Vehicle Flag", // displayed title
|
||||||
////////////////////////////////////////////////////////////////////////
|
"\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon
|
||||||
// create the root action
|
{true}, // statement
|
||||||
////////////////////////////////////////////////////////////////////////
|
{
|
||||||
private _rootActionID = "SetVehicleFlag";
|
params ["_target", "_player", "_params"];
|
||||||
private _flagRootAction = [
|
// _params params ["_parentActionID", "_flagCategories"];
|
||||||
_rootActionID, // id
|
|
||||||
"Set Vehicle Flag", // displayed title
|
|
||||||
"\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon
|
|
||||||
{true}, // statement
|
|
||||||
{
|
|
||||||
params ["_target", "_player", "_params"];
|
|
||||||
// _params params ["_parentActionID", "_flagCategories"];
|
|
||||||
|
|
||||||
// check if vehicle is excluded
|
|
||||||
private _excluded = [typeOf _target] call FUNC(isClassExcluded);
|
|
||||||
if (_excluded || !alive _target) exitWith {false};
|
|
||||||
|
|
||||||
true;
|
|
||||||
}, // condition
|
|
||||||
{
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// create the flag category actions (with nested flag actions)
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
params ["_target", "_player", "_params"];
|
|
||||||
_params params ["_rootActionID"];
|
|
||||||
|
|
||||||
private _vehicleFlagsCfg = call FUNC(getVehicleFlagsCfg);
|
|
||||||
if (isNull _vehicleFlagsCfg) exitWith {[]};
|
|
||||||
private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren;
|
|
||||||
|
|
||||||
// return category child actions with individual flag actions nested as children
|
|
||||||
[_rootActionID, _flagCategoryCfgs] call FUNC(getActionsFlagCategories);
|
|
||||||
|
|
||||||
}, // child code
|
|
||||||
[_rootActionID], // params
|
|
||||||
nil, // position
|
|
||||||
4, // distance
|
|
||||||
[false, false, false, false, false], // other params
|
|
||||||
nil // modifier function code
|
|
||||||
] call ace_interact_menu_fnc_createAction;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// add root action to add flags
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
[
|
|
||||||
(_this select 0), // object
|
|
||||||
0, // action 0 or self-action 1
|
|
||||||
["ACE_MainActions"], // parent
|
|
||||||
_flagRootAction // action
|
|
||||||
] call ace_interact_menu_fnc_addActionToObject;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// add action to remove flag under the root action
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
// create action
|
|
||||||
private _removeFlagAction = [
|
|
||||||
_rootActionID + "_removeflag", // id
|
|
||||||
"Remove Flag", // displayed title
|
|
||||||
"\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon
|
|
||||||
{
|
|
||||||
params ["_target", "_player", "_params"];
|
|
||||||
_target forceFlagTexture "";
|
|
||||||
}, // statement
|
|
||||||
{
|
|
||||||
params ["_target", "_player", "_params"];
|
|
||||||
alive _target && getForcedFlagTexture _target != "";
|
|
||||||
}, // condition
|
|
||||||
nil // child code
|
|
||||||
] call ace_interact_menu_fnc_createAction;
|
|
||||||
|
|
||||||
// add the action to the vehicle
|
|
||||||
// in this class event handler, this#0 will be the vehicle
|
|
||||||
[
|
|
||||||
(_this select 0), // object
|
|
||||||
0, // action 0 or self-action 1
|
|
||||||
["ACE_MainActions", _rootActionID], // parent
|
|
||||||
_removeFlagAction // action
|
|
||||||
] call ace_interact_menu_fnc_addActionToObject;
|
|
||||||
|
|
||||||
}, true, [], true] call CBA_fnc_addClassEventHandler;
|
// check if vehicle is excluded
|
||||||
|
private _excluded = [typeOf _target] call FUNC(isClassExcluded);
|
||||||
|
if (_excluded || !alive _target) exitWith {false};
|
||||||
|
|
||||||
|
true;
|
||||||
|
}, // condition
|
||||||
|
{
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// create the flag category actions (with nested flag actions)
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
params ["_target", "_player", "_params"];
|
||||||
|
_params params ["_rootActionID"];
|
||||||
|
|
||||||
|
private _vehicleFlagsCfg = call FUNC(getVehicleFlagsCfg);
|
||||||
|
if (isNull _vehicleFlagsCfg) exitWith {[]};
|
||||||
|
private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren;
|
||||||
|
|
||||||
|
// return category child actions with individual flag actions nested as children
|
||||||
|
[_rootActionID, _flagCategoryCfgs] call FUNC(getActionsFlagCategories);
|
||||||
|
|
||||||
|
}, // child code
|
||||||
|
[_rootActionID], // params
|
||||||
|
nil, // position
|
||||||
|
4, // distance
|
||||||
|
[false, false, false, false, false], // other params
|
||||||
|
nil // modifier function code
|
||||||
|
] call ace_interact_menu_fnc_createAction;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// add root action to add flags
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
[
|
||||||
|
_parentClass, // parent classname
|
||||||
|
0, // action 0 or self-action 1
|
||||||
|
["ACE_MainActions"], // parent
|
||||||
|
_flagRootAction, // action
|
||||||
|
true // apply to child classes
|
||||||
|
] call ace_interact_menu_fnc_addActionToClass;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// add action to remove flag under the root action
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// create action
|
||||||
|
private _removeFlagAction = [
|
||||||
|
_rootActionID + "_removeflag", // id
|
||||||
|
"Remove Flag", // displayed title
|
||||||
|
"\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon
|
||||||
|
{
|
||||||
|
params ["_target", "_player", "_params"];
|
||||||
|
_target forceFlagTexture "";
|
||||||
|
}, // statement
|
||||||
|
{
|
||||||
|
params ["_target", "_player", "_params"];
|
||||||
|
alive _target && getForcedFlagTexture _target != "";
|
||||||
|
}, // condition
|
||||||
|
nil // child code
|
||||||
|
] call ace_interact_menu_fnc_createAction;
|
||||||
|
|
||||||
|
// add the action to the vehicle
|
||||||
|
// in this class event handler, this#0 will be the vehicle
|
||||||
|
[
|
||||||
|
_parentClass, // parent classname
|
||||||
|
0, // action 0 or self-action 1
|
||||||
|
["ACE_MainActions", _rootActionID], // parent
|
||||||
|
_removeFlagAction, // action
|
||||||
|
true // apply to child classes
|
||||||
|
] call ace_interact_menu_fnc_addActionToClass;
|
||||||
|
|
||||||
} forEach _baseClassesToApplyActionsFor;
|
} forEach _baseClassesToApplyActionsFor;
|
||||||
|
|
||||||
nil;
|
nil;
|
||||||
Reference in New Issue
Block a user