Improved camUnit handling

This commit is contained in:
SilentSpike 2015-07-18 16:50:11 +01:00
parent bfd9be9ce1
commit 60b3c6c0f8
4 changed files with 37 additions and 39 deletions

View File

@ -59,13 +59,5 @@ switch (GVAR(camMode)) do {
[GVAR(camera), GVAR(camTilt), GVAR(camBank)] call BIS_fnc_setPitchBank; [GVAR(camera), GVAR(camTilt), GVAR(camBank)] call BIS_fnc_setPitchBank;
}; };
case 1: { // Internal case 1: { // Internal
// Update view when state of unit changes
if !(
(alive GVAR(camUnit)) &&
{vehicle GVAR(camUnit) == GVAR(camUnit)} &&
{GVAR(camUnit) in GVAR(unitList)}
) then {
[] call FUNC(updateCamera);
};
}; };
}; };

View File

@ -19,6 +19,10 @@
// Kill PFH when display is closed // Kill PFH when display is closed
if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
// Remove all dead and null units from the list
GVAR(unitList) = GVAR(unitList) - allDead;
GVAR(unitList) = GVAR(unitList) - [objNull];
// Fetch tree // Fetch tree
disableSerialization; disableSerialization;
_display = GETUVAR(GVAR(display),displayNull); _display = GETUVAR(GVAR(display),displayNull);
@ -33,8 +37,6 @@ tvClear _ctrl;
// Update the tree from the unit list // Update the tree from the unit list
_cachedGrps = []; _cachedGrps = [];
{ {
// Exclude any currently dead/disabled units
if ((alive _x) && (simulationEnabled _x) && !(_x getVariable [QGVAR(isSpectator), false])) then {
_grp = group _x; _grp = group _x;
_node = 0; _node = 0;
// If group already exists, find existing node // If group already exists, find existing node
@ -62,8 +64,11 @@ _cachedGrps = [];
_ctrl tvSort [[_node],false]; _ctrl tvSort [[_node],false];
_ctrl tvExpand [_node]; _ctrl tvExpand [_node];
};
} forEach GVAR(unitList); } forEach GVAR(unitList);
if ((tvCurSel _ctrl) isEqualTo []) then {
[0,objNull] call FUNC(updateCamera);
};
// Sort group nodes by side // Sort group nodes by side
_ctrl tvSortByValue [[],false]; _ctrl tvSortByValue [[],false];

View File

@ -11,19 +11,19 @@ if (_newMode != GVAR(camMode)) then {
// When no units available to spectate, exit to freecam // When no units available to spectate, exit to freecam
if (GVAR(unitList) isEqualTo []) then { if (GVAR(unitList) isEqualTo []) then {
GVAR(camMode) = 0; GVAR(camMode) = 0;
GVAR(camUnit) = objNull;
}; };
if (GVAR(camMode) == 0) then { // Free if (GVAR(camMode) == 0) then { // Free
// Preserve camUnit value for consistency when manually changing view
GVAR(camera) cameraEffect ["internal", "back"]; GVAR(camera) cameraEffect ["internal", "back"];
GVAR(camUnit) = GVAR(camera);
// HUD stuff // HUD stuff
showCinemaBorder false; showCinemaBorder false;
cameraEffectEnableHUD false; cameraEffectEnableHUD false;
} else { } else {
// First ensure valid unit is selected // When null unit is given choose random
if !(_newUnit in GVAR(unitList)) then { if (isNull _newUnit) then {
_newUnit = GVAR(unitList) select floor(random(count GVAR(unitList))); _newUnit = GVAR(unitList) select floor(random(count GVAR(unitList)));
}; };

View File

@ -61,6 +61,7 @@ if (GVAR(filterSides) == 0) then {
(alive _x) && (alive _x) &&
{(_x isKindOf "CAManBase")} && {(_x isKindOf "CAManBase")} &&
{(side _x) in _sides} && // Side filter {(side _x) in _sides} && // Side filter
{simulationEnabled _x}
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? {!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen?
) then { ) then {
GVAR(unitList) pushBack _x; GVAR(unitList) pushBack _x;