Move fob build confirm to external method

This commit is contained in:
Filip Maciejewski 2018-11-29 10:20:18 +01:00
parent 8117ee8ec2
commit cc4eea5baa
No known key found for this signature in database
GPG Key ID: 50E8C10C2DE0A9CA
3 changed files with 39 additions and 9 deletions

View File

@ -0,0 +1,35 @@
/*
KPLIB_fnc_build_handleFobBuildConfirm
File: fn_build_handleFobBuildConfirm.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-11-29
Last Update: 2018-11-29
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Handles FOB build confirmation
Parameter(s):
_fobBuilding - Building on which FOB will be created [OBJECT, defaults to objNull]
_fobBoxObject - Object from which FOB build orignated [OBJECT, defaults to objNull]
Returns:
Confirmation was handled [BOOL]
*/
params [
["_fobBuilding", objNull, [objNull]],
["_fobBoxObject", objNull, [objNull]]
];
if (isNull _fobBuilding) exitWith {diag_log format ["[KP LIBERATION] [%1] [BUILD] Null object passed, cannot create FOB", diag_tickTime]};
// Create FOB on position of building
private _fobName = [getPos _fobBuilding] call KPLIB_fnc_core_buildFob;
// Emit the built event with FOB and object to assign the object to freshly built FOB
["KPLIB_build_item_built", [_fobBuilding, _fobName]] call CBA_fnc_globalEvent;
// Remove FOB box from which FOB build originated
deleteVehicle _fobBoxObject;
true

View File

@ -69,15 +69,7 @@ if (hasInterface) then {
// Start single item build for fob building
[getPos _object, nil, [KPLIB_preset_fobBuilding, 0,0,0], {
// On confirm callback, create FOB on server
[[_this select 0, KPLIB_build_fobBuildObject], {
params ["_fobBuilding", "_fobBoxObject"];
// Build FOB when item placed
private _fobName = [getPos _fobBuilding] call KPLIB_fnc_core_buildFob;
// Emit the built event with FOB and object to assign the object to FOB
["KPLIB_build_item_built", [_fobBuilding, _fobName]] call CBA_fnc_globalEvent;
// Remove object
deleteVehicle _fobBoxObject;
}] remoteExec ["call", 2];
[_this select 0, KPLIB_build_fobBuildObject] remoteExec ["KPLIB_fnc_build_handleFobBuildConfirm", 2];
}] call KPLIB_fnc_build_start_single;
}] call CBA_fnc_addEventHandler;

View File

@ -59,6 +59,9 @@ class build {
// Handle object dragging/positon changing
class build_handleDrag {};
// Handles FOB build confirmation
class build_handleFobBuildConfirm {};
// Handle display keypresses
class build_handleKeys {};