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;
};
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
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
disableSerialization;
_display = GETUVAR(GVAR(display),displayNull);
@ -33,8 +37,6 @@ tvClear _ctrl;
// Update the tree from the unit list
_cachedGrps = [];
{
// Exclude any currently dead/disabled units
if ((alive _x) && (simulationEnabled _x) && !(_x getVariable [QGVAR(isSpectator), false])) then {
_grp = group _x;
_node = 0;
// If group already exists, find existing node
@ -62,8 +64,11 @@ _cachedGrps = [];
_ctrl tvSort [[_node],false];
_ctrl tvExpand [_node];
};
} forEach GVAR(unitList);
if ((tvCurSel _ctrl) isEqualTo []) then {
[0,objNull] call FUNC(updateCamera);
};
// Sort group nodes by side
_ctrl tvSortByValue [[],false];

View File

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

View File

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