forked from KillahPotatoes/KP-Liberation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request KillahPotatoes#542 from KillahPotatoes/v0.97S8-523
Build module - single item build, existing items movement
- Loading branch information
Showing
21 changed files
with
423 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Missionframework/modules/02_core/fnc/fn_core_getNearestMarker.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
"" | ||
}; |
31 changes: 0 additions & 31 deletions
31
Missionframework/modules/02_core/fnc/fn_core_getNearestSector.sqf
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Missionframework/modules/04_build/fnc/fn_build_changeQueueMode.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
37 changes: 37 additions & 0 deletions
37
Missionframework/modules/04_build/fnc/fn_build_confirmAll.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
52 changes: 52 additions & 0 deletions
52
Missionframework/modules/04_build/fnc/fn_build_confirmSingle.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Oops, something went wrong.