-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Feature Camera Player EH #982
Changes from 1 commit
5ca1a28
99f32e7
9e07b1c
2289585
8696687
55f5e2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getActiveFeatureCamera | ||
|
||
Description: | ||
Returns active feature camera. | ||
|
||
Checks for the following feature cameras: | ||
- Curator | ||
- Arsenal camera (BIS_fnc_arsenal) | ||
- Nexus Spectator (BIS_fnc_EGSpectator) | ||
- Establishing shot (BIS_fnc_establishingShot) | ||
- Splendid camera (BIS_fnc_camera) | ||
- Animation viewer (BIS_fnc_animViewer) | ||
- Classic camera (BIS_fnc_cameraOld) | ||
|
||
And cameras registered via CBA_fnc_registerFeatureCamera. | ||
|
||
Parameters: | ||
None | ||
|
||
Returns: | ||
Active feature camera ("" if none) <STRING> | ||
|
||
Examples: | ||
(begin example) | ||
_result = [] call CBA_fnc_getActiveFeatureCamera | ||
(end) | ||
|
||
Author: | ||
Sniperwolf572, Jonpas | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(getActiveFeatureCamera); | ||
|
||
{ | ||
_x params ["_name", "_callback"]; | ||
|
||
if (call _callback) exitWith {_name}; | ||
"" | ||
} forEach GVAR(featureCameras); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_registerFeatureCamera | ||
|
||
Description: | ||
Registers a feature camera for use with CBA_fnc_getActiveFeatureCamera. | ||
|
||
Parameters: | ||
_name - Name (unique/tagged) <STRING> | ||
_callback - Activity check (should return true if active, false otherwise) <CODE> | ||
|
||
Returns: | ||
None | ||
|
||
Examples: | ||
(begin example) | ||
_result = [ | ||
"ace_spectator", | ||
{!isNull (missionNamespace getVariable ["ace_spectator_isSet", objNull])} | ||
] call CBA_fnc_registerFeatureCamera | ||
(end) | ||
|
||
Author: | ||
Sniperwolf572, Jonpas | ||
---------------------------------------------------------------------------- */ | ||
SCRIPT(registerFeatureCamera); | ||
|
||
GVAR(featureCameras) pushBackUnique _this; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,21 @@ Description: | |
Adds a player event handler. | ||
|
||
Possible events: | ||
"unit" - player controlled unit changed | ||
"weapon" - currently selected weapon change | ||
"loadout" - players loadout changed | ||
"vehicle" - players current vehicle changed | ||
"turret" - position in vehicle changed | ||
"visionMode" - player changed to normal/night/thermal view | ||
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.) | ||
"visibleMap" - opened or closed map | ||
"group" - player group changes | ||
"leader" - leader of player changes | ||
"unit" - player controlled unit changed | ||
"weapon" - currently selected weapon change | ||
"loadout" - players loadout changed | ||
"vehicle" - players current vehicle changed | ||
"turret" - position in vehicle changed | ||
"visionMode" - player changed to normal/night/thermal view | ||
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.) | ||
"featureCamera" - camera changed (Curator, Arsenal, Spectator etc.) | ||
"visibleMap" - opened or closed map | ||
"group" - player group changes | ||
"leader" - leader of player changes | ||
|
||
Parameters: | ||
_type - Event handler type. <STRING> | ||
_function - Function to add to event. <CODE> | ||
_type - Event handler type. <STRING> | ||
_function - Function to add to event. <CODE> | ||
_applyRetroactively - Call function immediately if player is defined already (optional, default: false) <BOOL> | ||
|
||
Returns: | ||
|
@@ -84,6 +85,12 @@ private _id = switch (_type) do { | |
}; | ||
[QGVAR(cameraViewEvent), _function] call CBA_fnc_addEventHandler // return id | ||
}; | ||
case "featurecamera": { | ||
if (_applyRetroactively && {!isNull (missionNamespace getVariable [QGVAR(oldUnit), objNull])}) then { | ||
[GVAR(oldUnit), call CBA_fnc_getActiveFeatureCamera] call _function; | ||
}; | ||
[QGVAR(featureCameraEvent), _function] call CBA_fnc_addEventHandler // return id | ||
}; | ||
case "visiblemap": { | ||
if (_applyRetroactively && {!isNull (missionNamespace getVariable [QGVAR(oldUnit), objNull])}) then { | ||
[GVAR(oldUnit), visibleMap] call _function; | ||
|
@@ -120,6 +127,7 @@ if (_id != -1) then { | |
GVAR(oldTurret) = []; | ||
GVAR(oldVisionMode) = -1; | ||
GVAR(oldCameraView) = ""; | ||
GVAR(oldFeatureCamera) = ""; | ||
GVAR(oldVisibleMap) = false; | ||
|
||
GVAR(playerEHInfo) pushBack addMissionEventHandler ["EachFrame", {call FUNC(playerEH_EachFrame)}]; | ||
|
@@ -192,6 +200,12 @@ if (_id != -1) then { | |
GVAR(oldCameraView) = _data; | ||
[QGVAR(cameraViewEvent), [_player, _data]] call CBA_fnc_localEvent; | ||
}; | ||
|
||
_data = call CBA_fnc_getActiveFeatureCamera; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. performance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a bunch of null checks (7 in vanilla). Aren't all Player EHs only added when they are needed already? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0.0301 - 0.031 ms on 10k/10k cycles. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0.03 ouhhhh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That wouldn't work for cases where we might want to use internal variable (ref ACE PR). |
||
if !(_data isEqualTo GVAR(oldFeatureCamera)) then { | ||
GVAR(oldFeatureCamera) = _data; | ||
[QGVAR(featureCameraEvent), [_player, _data]] call CBA_fnc_localEvent; | ||
}; | ||
}] call CBA_fnc_compileFinal; | ||
|
||
GVAR(playerEHInfo) pushBack addMissionEventHandler ["Map", {call FUNC(playerEH_Map)}]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add argument checking.