@@ -35,14 +35,16 @@ internal class MainCamera : MonoBehaviour
35
35
private ActivePlayerSpaceManager _activePlayerSpaceManager ;
36
36
private ActiveOriginManager _activeOriginManager ;
37
37
private ActiveCameraManager _activeCameraManager ;
38
- private IFPFCSettings _fpfcSettings ;
39
- private BeatSaberUtilities _beatSaberUtilities ;
40
38
41
39
private Transform _playerSpace ;
42
40
private Transform _origin ;
43
41
private Camera _camera ;
44
42
private TrackedPoseDriver _trackedPoseDriver ;
45
43
44
+ protected IFPFCSettings fpfcSettings { get ; private set ; }
45
+
46
+ protected BeatSaberUtilities beatSaberUtilities { get ; private set ; }
47
+
46
48
protected virtual ( Transform playerSpace , Transform origin ) GetPlayerSpaceAndOrigin ( )
47
49
{
48
50
VRCenterAdjust center = transform . GetComponentInParent < VRCenterAdjust > ( ) ;
@@ -58,6 +60,23 @@ protected virtual (Transform playerSpace, Transform origin) GetPlayerSpaceAndOri
58
60
}
59
61
}
60
62
63
+ protected virtual int GetCameraMask ( int mask )
64
+ {
65
+ mask |= AvatarLayers . kAlwaysVisibleMask ;
66
+
67
+ // FPFC basically ends up being a 3rd person camera
68
+ if ( fpfcSettings . Enabled || ! beatSaberUtilities . hasFocus )
69
+ {
70
+ mask |= AvatarLayers . kOnlyInThirdPersonMask ;
71
+ }
72
+ else
73
+ {
74
+ mask &= ~ AvatarLayers . kOnlyInThirdPersonMask ;
75
+ }
76
+
77
+ return mask ;
78
+ }
79
+
61
80
protected void Awake ( )
62
81
{
63
82
_camera = GetComponent < Camera > ( ) ;
@@ -72,17 +91,17 @@ protected void OnEnable()
72
91
_settings . cameraNearClipPlane . changed += OnCameraNearClipPlaneChanged ;
73
92
}
74
93
75
- if ( _fpfcSettings != null )
94
+ if ( fpfcSettings != null )
76
95
{
77
- _fpfcSettings . Changed -= OnFpfcSettingsChanged ;
78
- _fpfcSettings . Changed += OnFpfcSettingsChanged ;
96
+ fpfcSettings . Changed -= OnFpfcSettingsChanged ;
97
+ fpfcSettings . Changed += OnFpfcSettingsChanged ;
79
98
}
80
99
81
- if ( _beatSaberUtilities != null )
100
+ if ( beatSaberUtilities != null )
82
101
{
83
- _beatSaberUtilities . focusChanged -= OnFocusChanged ;
84
- _beatSaberUtilities . focusChanged += OnFocusChanged ;
85
- OnFocusChanged ( _beatSaberUtilities . hasFocus ) ;
102
+ beatSaberUtilities . focusChanged -= OnFocusChanged ;
103
+ beatSaberUtilities . focusChanged += OnFocusChanged ;
104
+ OnFocusChanged ( beatSaberUtilities . hasFocus ) ;
86
105
}
87
106
88
107
UpdateCameraMask ( ) ;
@@ -104,8 +123,8 @@ private void Construct(
104
123
_activePlayerSpaceManager = activePlayerSpaceManager ;
105
124
_activeOriginManager = activeOriginManager ;
106
125
_activeCameraManager = activeCameraManager ;
107
- _fpfcSettings = fpfcSettings ;
108
- _beatSaberUtilities = beatSaberUtilities ;
126
+ this . fpfcSettings = fpfcSettings ;
127
+ this . beatSaberUtilities = beatSaberUtilities ;
109
128
}
110
129
111
130
protected void Start ( )
@@ -128,14 +147,14 @@ protected void OnDisable()
128
147
_settings . cameraNearClipPlane . changed -= OnCameraNearClipPlaneChanged ;
129
148
}
130
149
131
- if ( _fpfcSettings != null )
150
+ if ( fpfcSettings != null )
132
151
{
133
- _fpfcSettings . Changed -= OnFpfcSettingsChanged ;
152
+ fpfcSettings . Changed -= OnFpfcSettingsChanged ;
134
153
}
135
154
136
- if ( _beatSaberUtilities != null )
155
+ if ( beatSaberUtilities != null )
137
156
{
138
- _beatSaberUtilities . focusChanged -= OnFocusChanged ;
157
+ beatSaberUtilities . focusChanged -= OnFocusChanged ;
139
158
}
140
159
}
141
160
@@ -169,26 +188,14 @@ private void OnFocusChanged(bool hasFocus)
169
188
170
189
private void UpdateCameraMask ( )
171
190
{
172
- if ( _logger == null || _settings == null || _fpfcSettings == null )
191
+ if ( _logger == null || _settings == null || fpfcSettings == null )
173
192
{
174
193
return ;
175
194
}
176
195
177
196
_logger . LogTrace ( $ "Setting avatar culling mask and near clip plane on '{ _camera . name } '") ;
178
197
179
- int mask = _camera . cullingMask | AvatarLayers . kAlwaysVisibleMask ;
180
-
181
- // FPFC basically ends up being a 3rd person camera
182
- if ( _fpfcSettings . Enabled || ! _beatSaberUtilities . hasFocus )
183
- {
184
- mask |= AvatarLayers . kOnlyInThirdPersonMask ;
185
- }
186
- else
187
- {
188
- mask &= ~ AvatarLayers . kOnlyInThirdPersonMask ;
189
- }
190
-
191
- _camera . cullingMask = mask ;
198
+ _camera . cullingMask = GetCameraMask ( _camera . cullingMask ) ;
192
199
_camera . nearClipPlane = _settings . cameraNearClipPlane ;
193
200
}
194
201
0 commit comments