Overwrite BI unload all vehicles

Use ACE own interraction to unload all vehicles as BI action unload all vehicles do.
This commit is contained in:
Vdauphin 2020-11-06 22:16:13 +01:00
parent a420865b5b
commit b9eb48c64d
6 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,6 @@
class CfgActions {
class None;
class UnloadAllVehicles: None {
show = 0;
};
};

View File

@ -1,6 +1,7 @@
PREP(addCargoItem);
PREP(addCargoVehiclesActions);
PREP(canLoadItemIn);
PREP(canShowUnloadAllVehicles);
PREP(canUnloadItem);
PREP(getCargoSpaceLeft);
PREP(getSizeItem);
@ -17,5 +18,6 @@ PREP(setSize);
PREP(setSpace);
PREP(startLoadIn);
PREP(startUnload);
PREP(unloadAllVehicles);
PREP(unloadItem);
PREP(validateCargoSpace);

View File

@ -78,6 +78,18 @@ GVAR(vehicleAction) = [
}
] call EFUNC(interact_menu,createAction);
GVAR(unloadAllVehiclesAction) = [
QGVAR(unloadAllvehicles), localize "STR_A3_ACTION_UNLOAD_ALL_VEHICLES", "\A3\Ui_f\data\IGUI\Cfg\Actions\unloadAllVehicles_ca.paa",
{
params ["_target"];
[_target] call FUNC(unloadAllVehicles);
},
{
params ["_target", "_player"];
[_target, _player] call FUNC(canShowUnloadAllVehicles);
}
] call EFUNC(interact_menu,createAction);
GVAR(objectAction) = [
QGVAR(load), localize LSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa",
{
@ -101,6 +113,10 @@ GVAR(objectAction) = [
LINKFUNC(addCargoVehiclesActions)
] call EFUNC(interact_menu,createAction);
{
[_x, 1, ["ACE_SelfActions"], GVAR(unloadAllVehiclesAction), true] call EFUNC(interact_menu,addActionToClass);
} forEach ["LandVehicle", "Ship", "Air"];
// find all remaining configured classes and init them, see XEH_preStart.sqf
private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]);
{

View File

@ -19,3 +19,4 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "menu.hpp"
#include "CfgActions.hpp"

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Vdauphin
* Checks if unload all vehicles interaction can be show.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can show menu <BOOL>
*
* Example:
* [vehicle player, player] call ace_cargo_fnc_canShowUnloadAllVehicles
*
* Public: No
*/
params [
"_vehicle",
["_unit", player, [objNull]]
];
driver _vehicle isEqualTo _unit &&
{isClass (configfile >> "CfgVehicles" >> typeOf _vehicle >> "VehicleTransport" >> "Carrier")} &&
{!(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []]) isEqualTo [])}

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Vdauphin
* Unload all vehicles but not ACE Cargo.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Loaded vehiclesnot part of ACE Cargo <ARRAY>
*
* Example:
* [vehicle player] call ace_cargo_fnc_unloadAllVehicles
*
* Public: No
*/
params ["_vehicle"];
private _loadedVehicles = getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []]);
private _unloadingInterval = getNumber (configfile >> "CfgVehicles" >> typeOf _vehicle >> "VehicleTransport" >> "Carrier" >> "unloadingInterval");
{
[{objnull setVehicleCargo _this}, _x, _forEachIndex * _unloadingInterval] call CBA_fnc_waitAndExecute;
} forEach _loadedVehicles;
_loadedVehicles