ACE3/addons/viewports/functions/fnc_getViewports.sqf
PabstMirror a4258f3587
Viewports (#8480)
* Viewports

* Support mem-points

* Update CfgVehicles.hpp

* Add some docs

* Cleanup Debugging

* Update addons/viewports/dev/debugPoints.sqf

Co-authored-by: Dystopian <sddex@ya.ru>

* Update addons/viewports/dev/debugPoints.sqf

Co-authored-by: Dystopian <sddex@ya.ru>

* Update addons/viewports/functions/fnc_eachFrame.sqf

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* configProperties / 3den macro

* Update viewports-framework.md

* Update viewports-framework.md

* Add compats for rhs btrs

* Update addons/viewports/dev/debugPoints.sqf

Co-authored-by: Drofseh <Drofseh@users.noreply.github.com>

Co-authored-by: Dystopian <sddex@ya.ru>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: Drofseh <Drofseh@users.noreply.github.com>
2022-05-17 11:55:09 -05:00

75 lines
2.8 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: PabstMirror
* Gets viewports for a vehicle from config. Caches results to a setVar on the vic.
*
* Arguments:
* 0: vehicle <OBJECT>
*
* Return Value:
* ARRAY
*
* Example:
* [vehicle player] call ace_viewports_fnc_getViewports
*
* Public: No
*/
params ["_vehicle"];
private _viewports = _vehicle getVariable [QGVAR(viewports), nil];
if (isNil "_viewports") then {
_viewports = (configProperties [(configOf _vehicle) >> "ace_viewports", "isClass _x", true]) apply {
// name [STRING] is just used for debug
private _name = configName _x;
// type [STRING] - Optional
private _type = getText (_x >> "type");
// camLocation [ARRAY or STRING] - Required
private _camLocation = if (isArray (_x >> "camLocation")) then {
getArray (_x >> "camLocation") // modelOffset
} else {
getText (_x >> "camLocation") // memPoint
};
// camAttach [ARRAY or NUMBER] - Required
private _camAttach = if (isArray (_x >> "camAttach")) then {
getArray (_x >> "camAttach") // turret
} else {
getNumber (_x >> "camAttach") // angle
};
// screenLocation [ARRAY or STRING] - Optional (will be converted to ARRAY here!)
private _screenLocation = if (isArray (_x >> "screenLocation")) then {
getArray (_x >> "screenLocation") // modelOffset
} else {
getText (_x >> "screenLocation") // memPoint
};
if (_screenLocation isEqualType "") then {
// screens should be on the hull (IE non-animated) so we can do all the mem-point calculations here
if (_screenLocation == "") exitWith { // use generic periscope drop height from cam
private _camLocArray = if (_camLocation isEqualType []) then {
_camLocation
} else {
_vehicle selectionPosition [_camLocation, "Memory"];
};
_screenLocation =_camLocArray vectorAdd [0,0,-0.175]
};
_screenLocation = _vehicle selectionPosition [_screenLocation, "Memory"];
};
// maxDistance [NUMBER] - Optional
private _maxDistance = getNumber (_x >> "maxDistance");
if (_maxDistance == 0) then {
_maxDistance = 0.8;
};
// compartments [ARRAY] - Optional
private _compartments = (getArray (_x >> "compartments")) apply {toLower _x};
// roles [ARRAY] - Optional
private _roles = (getArray (_x >> "roles")) apply {toLower _x};
[_name, _type, _camLocation, _camAttach, _screenLocation, _maxDistance, _compartments, _roles]
};
TRACE_3("getViewports",_vehicle,typeOf _vehicle,count _viewports);
_vehicle setVariable [QGVAR(viewports), _viewports];
};
_viewports