mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improve class initialization (#6085)
This commit is contained in:
parent
bca8b01860
commit
ee7a1f6acb
@ -569,16 +569,6 @@ class CfgVehicles {
|
||||
GVAR(size) = 50;
|
||||
};
|
||||
|
||||
class Ruins_F;
|
||||
class Land_Cargo20_military_ruins_F: Ruins_F {
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
};
|
||||
|
||||
GVAR(space) = 49;
|
||||
GVAR(size) = 50;
|
||||
};
|
||||
|
||||
class Land_Cargo20_orange_F: Cargo_base_F {
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
@ -685,15 +675,6 @@ class CfgVehicles {
|
||||
GVAR(size) = 100;
|
||||
};
|
||||
|
||||
class Land_Cargo40_military_ruins_F: Ruins_F {
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
};
|
||||
|
||||
GVAR(space) = 99;
|
||||
GVAR(size) = 100;
|
||||
};
|
||||
|
||||
class Land_Cargo40_orange_F: Cargo_base_F {
|
||||
class EventHandlers {
|
||||
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
|
||||
|
@ -61,23 +61,91 @@
|
||||
[QGVAR(initObject), DFUNC(initObject)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(initVehicle), DFUNC(initVehicle)] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Add all the vehicle init EHs (require initPost for set/get variables)
|
||||
["LandVehicle", "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["Air", "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["Ship_F", "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
|
||||
// Add all the object init EHs
|
||||
["StaticWeapon", "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["Land_PortableLight_single_F", "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["ACE_ConcertinaWireCoil", "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
GVAR(vehicleAction) = [
|
||||
QGVAR(openMenu), localize LSTRING(openMenu), "",
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(interactionVehicle) = _target;
|
||||
GVAR(interactionParadrop) = false;
|
||||
createDialog QGVAR(menu);
|
||||
},
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(enable) &&
|
||||
{(_target getVariable [QGVAR(hasCargo), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(hasCargo)) == 1])} &&
|
||||
{locked _target < 2} &&
|
||||
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} &&
|
||||
{alive _target} &&
|
||||
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
|
||||
}
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
|
||||
// Add all the vehicle/object init EHs
|
||||
["ThingX", "initPost", {
|
||||
_this call DFUNC(initObject); _this call DFUNC(initVehicle);
|
||||
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["Land_PaperBox_closed_F", "initPost", {
|
||||
_this call DFUNC(initObject); _this call DFUNC(initVehicle);
|
||||
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
["PlasticCase_01_base_F", "initPost", {
|
||||
_this call DFUNC(initObject); _this call DFUNC(initVehicle);
|
||||
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
GVAR(objectAction) = [
|
||||
QGVAR(load), localize LSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa",
|
||||
{
|
||||
params ["_target", "_player"];
|
||||
[_player, _target] call FUNC(startLoadIn);
|
||||
},
|
||||
{
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(enable) &&
|
||||
{(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} &&
|
||||
{locked _target < 2} &&
|
||||
{alive _target} &&
|
||||
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
||||
{0 < {
|
||||
private _type = typeOf _x;
|
||||
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
|
||||
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
|
||||
(_hasCargoPublic || _hasCargoConfig) && {_x != _target} &&
|
||||
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
||||
} count (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)])}
|
||||
},
|
||||
LINKFUNC(addCargoVehiclesActions)
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
|
||||
|
||||
private _initVehicleClasses = ["ThingX", "LandVehicle", "Air", "Ship_F"];
|
||||
private _initObjectClasses = ["ThingX", "StaticWeapon"];
|
||||
{
|
||||
[_x, "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
} forEach _initVehicleClasses;
|
||||
{
|
||||
[_x, "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
} forEach _initObjectClasses;
|
||||
|
||||
// find all remaining configured classes and init them
|
||||
{
|
||||
private _class = configName _x;
|
||||
// init vehicle
|
||||
if (
|
||||
1 == getNumber (_x >> QGVAR(hasCargo))
|
||||
&& {{if (_class isKindOf _x) exitWith {false}; true} forEach _initVehicleClasses}
|
||||
) then {
|
||||
if (_class isKindOf "Static") then {
|
||||
if (2 == getNumber (_x >> "scope")) then {
|
||||
[_class, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
|
||||
GVAR(initializedVehicleClasses) pushBack _class;
|
||||
};
|
||||
} else {
|
||||
[_class, "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
_initVehicleClasses pushBack _class;
|
||||
};
|
||||
};
|
||||
// init object
|
||||
if (
|
||||
1 == getNumber (_x >> QGVAR(canLoad))
|
||||
&& {{if (_class isKindOf _x) exitWith {false}; true} forEach _initObjectClasses}
|
||||
) then {
|
||||
if (_class isKindOf "Static") then {
|
||||
if (2 == getNumber (_x >> "scope")) then {
|
||||
[_class, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToClass);
|
||||
GVAR(initializedItemClasses) pushBack _class;
|
||||
};
|
||||
} else {
|
||||
[_class, "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
||||
_initObjectClasses pushBack _class;
|
||||
};
|
||||
};
|
||||
} forEach ("true" configClasses (configFile >> "CfgVehicles"));
|
||||
|
@ -41,38 +41,9 @@ if (_object getVariable [QGVAR(initObject),false]) exitWith {};
|
||||
if (_canLoadConfig) then {
|
||||
GVAR(initializedItemClasses) pushBack _type;
|
||||
TRACE_1("Adding load cargo action to class", _type);
|
||||
[_type, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
_object setVariable [QGVAR(initObject),true];
|
||||
TRACE_1("Adding load cargo action to object", _object);
|
||||
[_object, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToObject);
|
||||
};
|
||||
|
||||
// Vehicles with passengers inside are prevented from being loaded in `fnc_canLoadItemIn`
|
||||
private _condition = {
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(enable) &&
|
||||
{(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} &&
|
||||
{locked _target < 2} &&
|
||||
{alive _target} &&
|
||||
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
||||
{0 < {
|
||||
private _type = typeOf _x;
|
||||
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
|
||||
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
|
||||
(_hasCargoPublic || _hasCargoConfig) && {_x != _target} &&
|
||||
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
||||
} count (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)])}
|
||||
};
|
||||
private _statement = {
|
||||
params ["_target", "_player"];
|
||||
[_player, _target] call FUNC(startLoadIn);
|
||||
};
|
||||
private _text = localize LSTRING(loadObject);
|
||||
private _icon = "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa";
|
||||
|
||||
private _action = [QGVAR(load), _text, _icon, _statement, _condition, {call FUNC(addCargoVehiclesActions)}] call EFUNC(interact_menu,createAction);
|
||||
if (_canLoadConfig) then {
|
||||
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
[_object, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
|
||||
};
|
||||
|
||||
|
@ -61,34 +61,11 @@ if (_vehicle getVariable [QGVAR(initVehicle),false]) exitWith {};
|
||||
if (_hasCargoConfig) then {
|
||||
GVAR(initializedVehicleClasses) pushBack _type;
|
||||
TRACE_1("Adding unload cargo action to class", _type);
|
||||
[_type, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
_vehicle setVariable [QGVAR(initVehicle),true];
|
||||
TRACE_1("Adding unload cargo action to object", _vehicle);
|
||||
};
|
||||
|
||||
private _condition = {
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(enable) &&
|
||||
{(_target getVariable [QGVAR(hasCargo), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(hasCargo)) == 1])} &&
|
||||
{locked _target < 2} &&
|
||||
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} &&
|
||||
{alive _target} &&
|
||||
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
|
||||
};
|
||||
private _statement = {
|
||||
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
GVAR(interactionVehicle) = _target;
|
||||
GVAR(interactionParadrop) = false;
|
||||
createDialog QGVAR(menu);
|
||||
};
|
||||
private _text = localize LSTRING(openMenu);
|
||||
private _icon = "";
|
||||
|
||||
private _action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
|
||||
if (_hasCargoConfig) then {
|
||||
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
||||
} else {
|
||||
[_vehicle, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
|
||||
[_vehicle, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToObject);
|
||||
};
|
||||
|
||||
// Add the paradrop self interaction for planes and helicopters
|
||||
|
Loading…
Reference in New Issue
Block a user