Merge pull request #542 from KillahPotatoes/v0.97S8-523
Build module - single item build, existing items movement
This commit is contained in:
commit
f6f07de9df
|
@ -38,9 +38,9 @@ So this is the core gameplay where all other modules are inject their functional
|
|||
|
||||
*Get all mobile respawn vehicles.*
|
||||
|
||||
* KPLIB_fnc_core_getNearestSector
|
||||
* KPLIB_fnc_core_getNearestMarker
|
||||
|
||||
*Get the nearest capturable sector.*
|
||||
*Get the marker from array of markers.*
|
||||
|
||||
* KPLIB_fnc_core_handleSector
|
||||
|
||||
|
|
|
@ -4,50 +4,28 @@
|
|||
File: fn_core_buildFob.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-05-11
|
||||
Last Update: 2018-11-09
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
Builds FOB on given position.
|
||||
Creates FOB on given position.
|
||||
|
||||
Parameter(s):
|
||||
_position - Object or position where FOB has to be built [OBJECT/ARRAY, defaults to []]
|
||||
_player - Player that initiated building. Mandatory for interactive build [OBJECT, defaults to objNull]
|
||||
_interactive - Should FOB be built interactively for player [BOOL, defaults to false]
|
||||
_buildPos - Object or position where FOB has to be built [ARRAY, defaults to []]
|
||||
|
||||
Returns:
|
||||
Spawned vehicle [OBJECT]
|
||||
Fob marker [STRING]
|
||||
*/
|
||||
|
||||
params [
|
||||
["_position", [], [[], objNull]],
|
||||
["_player", objNull, [objNull]],
|
||||
["_interactive", false, [false]]
|
||||
["_buildPos", [], [[]]]
|
||||
];
|
||||
|
||||
// Get position of build area
|
||||
private _buildPos = _position;
|
||||
// If our position is an object we will save it for later deletion
|
||||
private _box = objNull;
|
||||
|
||||
// If position is object, get position of object
|
||||
if(typeName _buildPos == typeName objNull) then {
|
||||
_box = _buildPos;
|
||||
_buildPos = getPosATL _box;
|
||||
};
|
||||
|
||||
// Build FOB
|
||||
if (_interactive) then {
|
||||
// TODO we should allow for manual placement of FOB building in interative mode here later
|
||||
deleteVehicle _box;
|
||||
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
|
||||
KPLIB_sectors_fobs pushBack _marker;
|
||||
["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent;
|
||||
} else {
|
||||
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
|
||||
KPLIB_sectors_fobs pushBack _marker;
|
||||
["KPLIB_fob_built", [_marker]] call CBA_fnc_localEvent;
|
||||
};
|
||||
private _marker = [_buildPos] call KPLIB_fnc_core_createFobMarker;
|
||||
KPLIB_sectors_fobs pushBack _marker;
|
||||
["KPLIB_fob_built", [_marker]] call CBA_fnc_globalEvent;
|
||||
|
||||
publicVariable "KPLIB_sectors_fobs";
|
||||
call KPLIB_fnc_core_updateFobMarkers;
|
||||
[] call KPLIB_fnc_core_updateFobMarkers;
|
||||
|
||||
_marker
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_core_canBuildFob.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-05-11
|
||||
Last Update: 2018-11-09
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -27,6 +27,6 @@ params [
|
|||
private _minSectorDist = KPLIB_param_fobRange + KPLIB_param_sectorCapRange;
|
||||
|
||||
(alive _box
|
||||
&& _box distance2D KPLIB_eden_startbase > 300
|
||||
&& ([_minSectorDist, getPos _box] call KPLIB_fnc_core_getNearestSector == ""))
|
||||
&& _box distance2D KPLIB_eden_startbase > 1000
|
||||
&& ([_minSectorDist, getPos _box, KPLIB_sectors_all + KPLIB_sectors_fobs] call KPLIB_fnc_core_getNearestMarker isEqualTo ""))
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
KPLIB_fnc_core_getNearestMarker
|
||||
|
||||
File: fn_core_getNearestMarker.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2017-11-26
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
Get the nearest marker from given array within range of position.
|
||||
|
||||
Parameter(s):
|
||||
_range - Range to search for sectors [NUMBER, defaults to 0]
|
||||
_centerPos - Center position from where to start searching for markers [POSITION, defaults to getPos player]
|
||||
_markers - Array of markers to check [ARRAY, defaults to KPLIB_sectors_all]
|
||||
|
||||
Returns:
|
||||
Nearest marker [STRING]
|
||||
*/
|
||||
|
||||
params [
|
||||
["_range", 0, [0]],
|
||||
["_centerPos", getPos player, [[]], 3],
|
||||
["_markers", KPLIB_sectors_all, [[]]]
|
||||
];
|
||||
|
||||
|
||||
private _markersWithinRange = _markers select {((markerPos _x) distance _centerPos) < _range};
|
||||
private _markersAscByRange = [_markersWithinRange, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy;
|
||||
// Return nearest marker
|
||||
if !(_markersAscByRange isEqualTo []) then {
|
||||
_markersAscByRange select 0
|
||||
} else {
|
||||
""
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
KPLIB_fnc_core_getNearestSector
|
||||
|
||||
File: fn_core_getNearestSector.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2017-11-26
|
||||
Last Update: 2018-11-09
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
Get the nearest capturable sector from the given position inside the given range.
|
||||
|
||||
Parameter(s):
|
||||
_range - Range to search for sectors [NUMBER, defaults to 0]
|
||||
_centerPos - Center position from where to start searching for sectors [POSITION, defaults to getPos player]
|
||||
|
||||
Returns:
|
||||
Nearest capturable sector [STRING]
|
||||
*/
|
||||
|
||||
params [
|
||||
["_range", 0, [0]],
|
||||
["_centerPos", getPos player, [[]], 3]
|
||||
];
|
||||
|
||||
private _return = "";
|
||||
private _foundSectors = KPLIB_sectors_all select {((markerPos _x) distance _centerPos) < _range};
|
||||
private _sortedSectors = [_foundSectors, [_centerPos], {(markerPos _x) distance _input0}, "ASCEND"] call BIS_fnc_sortBy;
|
||||
if !(_sortedSectors isEqualTo []) then {_return = _sortedSectors select 0;};
|
||||
|
||||
_return
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_core_handleVehicleSpawn.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-09-10
|
||||
Last Update: 2018-11-12
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -27,7 +27,7 @@ switch(typeOf _vehicle) do {
|
|||
// Add FOB build action globaly and for JIP
|
||||
[
|
||||
_vehicle,
|
||||
[localize "STR_KPLIB_ACTION_DEPLOY", {[param [0], param [1], param[3]] call KPLIB_fnc_core_buildFob}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10]
|
||||
[localize "STR_KPLIB_ACTION_DEPLOY", {["KPLIB_fob_build_requested", _this select 0] call CBA_fnc_localEvent}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10]
|
||||
] remoteExecCall ["addAction", 0, true];
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_core_preInit.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-10-18
|
||||
Last Update: 2018-11-27
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -22,6 +22,10 @@ if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [CORE] Module i
|
|||
// Process CBA Settings
|
||||
[] call KPLIB_fnc_core_settings;
|
||||
|
||||
if (isServer) then {
|
||||
["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
/*
|
||||
----- Module Globals -----
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_common_setupPlayerActions.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-05-28
|
||||
Last Update: 2018-11-12
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -17,12 +17,6 @@
|
|||
Function reached the end [BOOL]
|
||||
*/
|
||||
|
||||
// Actions avalible GLOBALLY on objects
|
||||
if (isServer) then {
|
||||
// Add actions to supported vehicles
|
||||
["KPLIB_vehicle_spawned", KPLIB_fnc_core_handleVehicleSpawn] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
// Actions avalible LOCALLY to player
|
||||
if(hasInterface) then {
|
||||
// FOB redeploy action
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_core_spawnCam.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2017-11-26
|
||||
Last Update: 2018-11-12
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -22,7 +22,7 @@ params [
|
|||
];
|
||||
|
||||
// Get the nearest sector from the current position for the spawn text display
|
||||
private _nearestSector = [2000] call KPLIB_fnc_core_getNearestSector;
|
||||
private _nearestSector = [2000] call KPLIB_fnc_core_getNearestMarker;
|
||||
if (_nearestSector != "") then {_nearestSector = format ["%1 %2", localize "STR_KPLIB_NEAR", markertext _nearestSector];};
|
||||
|
||||
// Get the current time for the spawn text display
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: functions.hpp
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2017-10-28
|
||||
Last Update: 2018-11-27
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -35,8 +35,8 @@ class core {
|
|||
// Get all mobile respawn vehicles
|
||||
class core_getMobSpawns {};
|
||||
|
||||
// Get the nearest capturable sector
|
||||
class core_getNearestSector {};
|
||||
// Get the nearest marker from array of markers
|
||||
class core_getNearestMarker {};
|
||||
|
||||
// Handle an activated sector
|
||||
class core_handleSector {};
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#include "script_components.hpp"
|
||||
#include "..\ui\defines.hpp"
|
||||
/*
|
||||
KPLIB_fnc_build_changeQueueMode
|
||||
|
||||
File: fn_build_changeQueueMode.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:
|
||||
Changes build system queue mode.
|
||||
|
||||
Parameter(s):
|
||||
_control - Clicked control [CONTROL, defaults to controlNull]
|
||||
|
||||
Returns:
|
||||
Queue mode was changed [BOOL]
|
||||
*/
|
||||
params [
|
||||
["_control", controlNull, [controlNull]]
|
||||
];
|
||||
|
||||
private _display = ctrlParent _control;
|
||||
private _confirmBtnControl = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM;
|
||||
|
||||
// TODO preserve and restore current build queue
|
||||
switch (_control getVariable ["KPLIB_mode", 0]) do {
|
||||
case 0: {
|
||||
_control ctrlSetText "Move mode";
|
||||
_control setVariable ["KPLIB_mode", 1];
|
||||
_confirmBtnControl ctrlEnable false;
|
||||
|
||||
private _currentItems = KPLIB_build_saveNamespace getVariable [player getVariable "KPLIB_fob", []];
|
||||
LSVAR("buildQueue", _currentItems);
|
||||
};
|
||||
|
||||
case 1: {
|
||||
_control ctrlSetText "Build mode";
|
||||
_control setVariable ["KPLIB_mode", 0];
|
||||
_confirmBtnControl ctrlEnable true;
|
||||
|
||||
LSVAR("buildQueue", []);
|
||||
};
|
||||
};
|
||||
|
||||
true
|
|
@ -0,0 +1,37 @@
|
|||
#include "script_components.hpp"
|
||||
/*
|
||||
KPLIB_fnc_build_confirmAll
|
||||
|
||||
File: fn_build_confirmAll.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-11-28
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
Confirms and builds every item in build queue.
|
||||
|
||||
Parameter(s):
|
||||
NONE
|
||||
|
||||
Returns:
|
||||
Items were built [BOOL]
|
||||
*/
|
||||
|
||||
private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]};
|
||||
LSVAR("buildQueue", LGVAR(buildQueue) - _validItems);
|
||||
|
||||
// TODO implement build queue handling (resource check etc.)
|
||||
systemChat "buildConfirm: Resource check not implemented yet!";
|
||||
{
|
||||
private _dirAndUp = [vectorDir _x, vectorUp _x];
|
||||
private _pos = getPosATL _x;
|
||||
private _class = typeOf _x;
|
||||
|
||||
deleteVehicle _x;
|
||||
|
||||
[[_class, _pos, 0, true], _dirAndUp, player] remoteExecCall ["KPLIB_fnc_build_confirmSingle", 2];
|
||||
|
||||
} forEach _validItems;
|
||||
|
||||
true
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
KPLIB_fnc_build_confirmSingle
|
||||
|
||||
File: fn_build_confirmSingle.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:
|
||||
Confirms single item from build queue.
|
||||
|
||||
Parameter(s):
|
||||
_createParams - Parameters for common_createVehicle [ARRAY, defaults to nil]
|
||||
_vectorDirAndUp - Vector dir and up for created object [ARRAY, defaults to nil]
|
||||
_player - Player that initiated the building of object [OBJECT, defaults to objNull]
|
||||
|
||||
Returns:
|
||||
Function reached the end [BOOL]
|
||||
*/
|
||||
params [
|
||||
["_createParams", nil, [[]]],
|
||||
["_vectorDirAndUp", nil, [[]], 2],
|
||||
["_player", objNull, [objNull]]
|
||||
];
|
||||
_createParams params ["_className", "_pos", "_dir", "_justBuild"];
|
||||
|
||||
private ["_obj"];
|
||||
|
||||
// TODO save only builings via Build module, units and vehicles should be moved to persistence module
|
||||
switch true do {
|
||||
case (_className isKindOf "Man"): {
|
||||
_obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit;
|
||||
_obj setPosATL _pos;
|
||||
_obj setVectorDirAndUp _vectorDirAndUp;
|
||||
|
||||
// Set watching direction
|
||||
if (_obj isEqualTo formLeader _obj) then {
|
||||
_obj setFormDir getDir _obj;
|
||||
};
|
||||
};
|
||||
|
||||
default {
|
||||
_obj = _createParams call KPLIB_fnc_common_createVehicle;
|
||||
_obj setVectorDirAndUp _vectorDirAndUp;
|
||||
};
|
||||
};
|
||||
|
||||
private _fob = _player getVariable ["KPLIB_fob", ""];
|
||||
|
||||
["KPLIB_build_item_built", [_obj, _fob]] call CBA_fnc_globalEvent;
|
||||
["KPLIB_build_item_built_local", [_obj, _fob], _player] call CBA_fnc_targetEvent;
|
|
@ -6,7 +6,7 @@
|
|||
File: fn_build_displayLoad.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-09-09
|
||||
Last Update: 2018-11-27
|
||||
Last Update: 2018-11-28
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -44,50 +44,6 @@ _itemsList ctrlAddEventHandler ["LBSelChanged", {
|
|||
ctrlSetFocus ((ctrlParent _control) displayCtrl _currentTabIDC);
|
||||
}];
|
||||
|
||||
// Add build confirmation handler
|
||||
private _confirmButton = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM;
|
||||
_confirmButton ctrlAddEventHandler ["buttonClick", {
|
||||
|
||||
private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]};
|
||||
LSVAR("buildQueue", LGVAR(buildQueue) - _validItems);
|
||||
|
||||
// TODO implement build queue handling (resource check etc.)
|
||||
systemChat "buildConfirm: Resource check not implemented yet!";
|
||||
{
|
||||
private _dirAndUp = [vectorDir _x, vectorUp _x];
|
||||
private _pos = getPosATL _x;
|
||||
private _class = typeOf _x;
|
||||
|
||||
deleteVehicle _x;
|
||||
|
||||
[[[_class, _pos, 0, true], _dirAndUp], {
|
||||
params ["_createParams", "_vectorDirAndUp"];
|
||||
_createParams params ["_className", "_pos"];
|
||||
|
||||
private ["_obj"];
|
||||
|
||||
// TODO save only builings via Build module, units and vehicles should be moved to persistence module
|
||||
// Confirmation handling must be moved to separate function
|
||||
switch true do {
|
||||
case (_className isKindOf "Man"): {
|
||||
_obj = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit;
|
||||
_obj setPosATL _pos;
|
||||
_obj setVectorDirAndUp _vectorDirAndUp;
|
||||
};
|
||||
|
||||
default {
|
||||
_obj = _createParams call KPLIB_fnc_common_createVehicle;
|
||||
_obj setVectorDirAndUp _vectorDirAndUp;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
["KPLIB_build_item_built", [_obj, player getVariable "KPLIB_fob"]] call CBA_fnc_localEvent;
|
||||
}] remoteExecCall ["call", 2];
|
||||
|
||||
} forEach _validItems;
|
||||
}];
|
||||
|
||||
// Add tab change handler
|
||||
{
|
||||
private _ctrl = _display displayCtrl _x;
|
||||
|
|
|
@ -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
|
|
@ -55,6 +55,11 @@ if (_moduleData isEqualTo []) then {
|
|||
_object = [createGroup KPLIB_preset_sidePlayers, _className] call KPLIB_fnc_common_createUnit;
|
||||
_object setPosWorld _posWorld;
|
||||
_object setVectorDirAndUp _vectorDirAndUp;
|
||||
|
||||
// Set watching direction
|
||||
if (_object isEqualTo formLeader _object) then {
|
||||
_object setFormDir getDir _object;
|
||||
};
|
||||
};
|
||||
|
||||
default {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: fn_build_preInit.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-10-18
|
||||
Last Update: 2018-11-12
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -34,26 +34,47 @@ KPLIB_build_ticker = -1;
|
|||
// Save data
|
||||
KPLIB_build_saveNamespace = locationNull;
|
||||
|
||||
// Register build item movement handler
|
||||
["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler;
|
||||
// Object from which FOB build event originated
|
||||
KPLIB_build_fobBuildObject = objNull;
|
||||
|
||||
// Register load event handler
|
||||
["KPLIB_doLoad", {[] call KPLIB_fnc_build_loadData}] call CBA_fnc_addEventHandler;
|
||||
if (isServer) then {
|
||||
// Register load event handler
|
||||
["KPLIB_doLoad", {[] call KPLIB_fnc_build_loadData}] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Register save event handler
|
||||
["KPLIB_doSave", {[] call KPLIB_fnc_build_saveData}] call CBA_fnc_addEventHandler;
|
||||
// Register save event handler
|
||||
["KPLIB_doSave", {[] call KPLIB_fnc_build_saveData}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["KPLIB_build_item_built", {
|
||||
params ["_object", "_fob"];
|
||||
["KPLIB_build_item_built", {
|
||||
params ["_object", "_fob"];
|
||||
if (_fob isEqualTo "") exitWith {};
|
||||
|
||||
// If fob has no save data, initialize it
|
||||
if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then {
|
||||
KPLIB_build_saveNamespace setVariable [_fob, []];
|
||||
};
|
||||
// If fob has no save data, initialize it
|
||||
if (isNil {KPLIB_build_saveNamespace getVariable _fob}) then {
|
||||
KPLIB_build_saveNamespace setVariable [_fob, []];
|
||||
};
|
||||
|
||||
(KPLIB_build_saveNamespace getVariable _fob) pushBackUnique _object;
|
||||
(KPLIB_build_saveNamespace getVariable _fob) pushBackUnique _object;
|
||||
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
if (hasInterface) then {
|
||||
// Register build item movement handler
|
||||
["KPLIB_build_item_moved", KPLIB_fnc_build_validatePosition] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Register Build module as FOB building provider
|
||||
["KPLIB_fob_build_requested", {
|
||||
params ["_object"];
|
||||
KPLIB_build_fobBuildObject = _object;
|
||||
// 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] remoteExec ["KPLIB_fnc_build_handleFobBuildConfirm", 2];
|
||||
}] call KPLIB_fnc_build_start_single;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
player addEventHandler ["Killed", KPLIB_fnc_build_stop];
|
||||
};
|
||||
|
||||
if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [BUILD] Module initialized", diag_tickTime];};
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
|
||||
#include "script_components.hpp"
|
||||
#include "..\ui\defines.hpp"
|
||||
/*
|
||||
KPLIB_fnc_build_start_single
|
||||
|
||||
File: fn_build_start_single.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-09-09
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
Starts KP Liberation building mode
|
||||
|
||||
Parameter(s):
|
||||
_center - Center of building area [POSITION, defaults to position player]
|
||||
_radius - Allowed building radius [NUMBER, defaults to KPLIB_param_fobRange]
|
||||
|
||||
Returns:
|
||||
Building logic object [LOCATION]
|
||||
*/
|
||||
|
||||
params [
|
||||
["_center", position player, [[]], 3],
|
||||
["_radius", (35 max KPLIB_param_fobRange/2), [0]],
|
||||
["_buildItem", [], [[]], 4],
|
||||
["_onConfirm", {}, [{}]]
|
||||
];
|
||||
|
||||
if !(_buildItem isEqualTypeParams ["", 0, 0, 0]) exitWith {
|
||||
diag_log format ["[KP LIBERATION] [%1] [BUILD] Incorrect build item passed to build_start_single '%2'!", diag_tickTime, _buildItem]
|
||||
};
|
||||
|
||||
|
||||
private _openEhId = ["KPLIB_build_display_open", {
|
||||
params ["_display"];
|
||||
|
||||
private _confirmCtrl = (_display displayCtrl KPLIB_IDC_BUILD_CONFIRM);
|
||||
|
||||
// Get pos of build mode selector
|
||||
private _confirmCtrlNewPos = (ctrlPosition ctrlParentControlsGroup (_display displayCtrl KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS));
|
||||
// Save only X, Y
|
||||
_confirmCtrlNewPos resize 2;
|
||||
// Get original W, H
|
||||
_confirmCtrlNewPos append ((ctrlPosition _confirmCtrl) select [2, 2]);
|
||||
// Set the position with original W, H
|
||||
_confirmCtrl ctrlSetPosition _confirmCtrlNewPos;
|
||||
_confirmCtrl ctrlCommit 0;
|
||||
|
||||
// Hide tabs, build list and background
|
||||
{
|
||||
(_display displayCtrl _x) ctrlShow false;
|
||||
} forEach KPLIB_BUILD_TABS_IDCS_ARRAY + [KPLIB_IDC_BUILD_ITEM_LIST, KPLIB_IDC_BUILD_DIALOG_AREA, KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS];
|
||||
|
||||
LSVAR("buildItem", _thisArgs);
|
||||
|
||||
}, _buildItem] call CBA_fnc_addEventHandlerArgs;
|
||||
|
||||
|
||||
// Handle item placement
|
||||
private _builtEhId = ["KPLIB_build_item_built_local", {
|
||||
_this call _thisArgs;
|
||||
[] call KPLIB_fnc_build_stop;
|
||||
}, _onConfirm] call CBA_fnc_addEventHandlerArgs;
|
||||
|
||||
|
||||
// Stop all single build event handlers
|
||||
["KPLIB_build_stop", {
|
||||
[_thisType, _thisId] call CBA_fnc_removeEventHandler;
|
||||
|
||||
_thisArgs params ["_openEhId", "_builtEhId"];
|
||||
|
||||
["KPLIB_build_display_open", _openEhId] call CBA_fnc_removeEventHandler;
|
||||
["KPLIB_build_item_built_local", _builtEhId] call CBA_fnc_removeEventHandler;
|
||||
|
||||
}, [_openEhId, _builtEhId]] call CBA_fnc_addEventHandlerArgs;
|
||||
|
||||
|
||||
// Start build mode
|
||||
[_center, _radius] call KPLIB_fnc_build_start
|
|
@ -4,7 +4,7 @@
|
|||
File: functions.hpp
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-07-01
|
||||
Last Update: 2018-11-12
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -26,6 +26,15 @@ class build {
|
|||
// Creates the build camera
|
||||
class build_camCreate {};
|
||||
|
||||
// Change queue mode between moving existing items and placing new
|
||||
class build_changeQueueMode {};
|
||||
|
||||
// Confirms all items in queue
|
||||
class build_confirmAll {};
|
||||
|
||||
// Confirms single item from queue
|
||||
class build_confirmSingle {};
|
||||
|
||||
// Display initialization
|
||||
class build_displayLoad {};
|
||||
|
||||
|
@ -50,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 {};
|
||||
|
||||
|
@ -90,6 +102,9 @@ class build {
|
|||
// Start building logic
|
||||
class build_start {};
|
||||
|
||||
// Start building logic for single item build
|
||||
class build_start_single {};
|
||||
|
||||
// Stop building logic
|
||||
class build_stop {};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: KPLIB_defines.hpp
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-07-01
|
||||
Last Update: 2018-11-27
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -42,7 +42,9 @@ class KPLIB_build {
|
|||
text = "$STR_KPLIB_DIALOG_BUILD_TITLE";
|
||||
};
|
||||
|
||||
class KP_DialogArea: KPGUI_PRE_DialogBackground_LeftPanel {};
|
||||
class KP_DialogArea: KPGUI_PRE_DialogBackground_LeftPanel {
|
||||
idc = KPLIB_IDC_BUILD_DIALOG_AREA;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
@ -113,19 +115,55 @@ class KPLIB_build {
|
|||
x = KP_GETCX(KP_X_VAL_LP,KP_WIDTH_VAL_LP,0,1);
|
||||
y = KP_GETCY(KP_Y_VAL_LP,KP_HEIGHT_VAL_LP,2,20);
|
||||
w = KP_GETW(KP_WIDTH_VAL_LP,1);
|
||||
h = KP_GETH(KP_HEIGHT_VAL_LP,20) * 19.55;
|
||||
h = KP_GETH(KP_HEIGHT_VAL_LP,(20/18));
|
||||
|
||||
columns[] = { 0, 0.65, 0.75, 0.85 };
|
||||
|
||||
onMouseZChanged = "['onMouseZChanged_BuildList', _this] call KPLIB_fnc_build_handleMouse";
|
||||
};
|
||||
|
||||
class KPLIB_ToolboxContainer: KPGUI_PRE_ControlsGroup {
|
||||
class VScrollbar: KPGUI_PRE_ScrollBar {
|
||||
width = 0;
|
||||
};
|
||||
class HScrollbar: KPGUI_PRE_ScrollBar {
|
||||
color[] = {1, 1, 1, 0.5};
|
||||
height = 0.02;
|
||||
};
|
||||
|
||||
x = KP_GETCX(KP_X_VAL_LP,KP_WIDTH_VAL_LP,0,1);
|
||||
y = KP_GETCY(KP_Y_VAL_LP,KP_HEIGHT_VAL_LP,0,20);
|
||||
w = KP_GETW(KP_WIDTH_VAL_LP,1);
|
||||
h = KP_GETH(KP_HEIGHT_VAL_LP,20);
|
||||
|
||||
// Toolbox Controls
|
||||
class Controls {
|
||||
// TODO move toolbox items creation to script
|
||||
class KPLIB_Toolbox_MoveItems: KPGUI_PRE_ActiveText {
|
||||
text = "Build mode";
|
||||
idc = KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS;
|
||||
|
||||
colorActive[] = {1, 1, 1, 1};
|
||||
colorText[] = {1, 1, 1, 0.75};
|
||||
colorDisabled[] = {1, 1, 1, 0.25};
|
||||
color[] = {1, 1, 1, 0.55};
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = KP_GETW(KP_WIDTH_VAL_LP,4);
|
||||
h = KP_GETH(KP_HEIGHT_VAL_LP,20) - 0.02;
|
||||
|
||||
onButtonClick = "_this call KPLIB_fnc_build_changeQueueMode"
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class KP_ApplyButton: KPGUI_PRE_DialogButton_LeftPanel {
|
||||
idc = KPLIB_IDC_BUILD_CONFIRM;
|
||||
text = "$STR_KPLIB_DIALOG_BUTTON_BUILD";
|
||||
|
||||
w = KP_GETWPLAIN(KP_WIDTH_VAL_LP,1);
|
||||
onButtonClick = "['build', _this] call KPLIB_fnc_build_displayScript";
|
||||
onButtonClick = "_this call KPLIB_fnc_build_confirmAll";
|
||||
};
|
||||
|
||||
class KPLIB_DialogCross: KPGUI_PRE_DialogCross_LeftPanel {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
File: defines.sqf
|
||||
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
|
||||
Date: 2018-07-01
|
||||
Last Update: 2018-11-09
|
||||
Last Update: 2018-11-29
|
||||
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Description:
|
||||
|
@ -25,9 +25,13 @@
|
|||
#define KPLIB_IDC_BUILD_TAB_SUPPORT 70106
|
||||
#define KPLIB_IDC_BUILD_TAB_SQUAD 70107
|
||||
|
||||
#define KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS 70111
|
||||
|
||||
#define KPLIB_IDC_BUILD_ITEM_LIST 70202
|
||||
|
||||
#define KPLIB_IDC_BUILD_CONFIRM 70301
|
||||
|
||||
#define KPLIB_IDC_BUILD_DIALOG_AREA 70401
|
||||
|
||||
// All tabs IDCs
|
||||
#define KPLIB_BUILD_TABS_IDCS_ARRAY [70100,70101,70102,70103,70104,70105,70106,70107]
|
||||
|
|
Loading…
Reference in New Issue