@@ -34,7 +34,7 @@ public class MyCameraPlugin : IPluginCameraBehaviour
3434 // Invoke ApplySettings event when you need to save your settings.
3535 // Do not invoke event every frame if possible.
3636 public event EventHandler ApplySettings ;
37- private BeatSaberStatus BS ;
37+ private BeatSaberStatus beatSaberStatus ;
3838
3939 // ID is used for the camera behaviour identification when the behaviour is selected by the user.
4040 // It has to be unique so there are no plugin collisions.
@@ -44,7 +44,7 @@ public class MyCameraPlugin : IPluginCameraBehaviour
4444 // Author name.
4545 public string author => "fries" ;
4646 // Plugin version.
47- public string version => "1.1.3 " ;
47+ public string version => "1.2.0 " ;
4848
4949 // Locally store the camera helper provided by LIV.
5050 PluginCameraHelper _helper ;
@@ -105,7 +105,7 @@ public void OnActivate(PluginCameraHelper helper)
105105
106106 _helper = helper ;
107107
108- BS = new BeatSaberStatus ( ) ;
108+ beatSaberStatus = new BeatSaberStatus ( ) ;
109109
110110 _helper . UpdateFov ( 60.0f ) ;
111111 UpdateCameraChange ( ) ;
@@ -178,16 +178,16 @@ public void UpdateCameraChange()
178178 if ( useHttpStatus )
179179 {
180180 // If HTTPStatus is available, see if we can extract some of the song details
181- Log ( "Song Name: " + BS . songName ) ;
182- Log ( "Song SubName: " + BS . songSubName ) ;
183- Log ( "Song AuthorName: " + BS . songAuthorName ) ;
184- Log ( "Level Author: " + BS . levelAuthorName ) ;
185- Log ( "Song Hash: " + BS . songHash ) ;
186- Log ( "Level ID: " + BS . levelId ) ;
181+ Log ( "Song Name: " + beatSaberStatus . songName ) ;
182+ Log ( "Song SubName: " + beatSaberStatus . songSubName ) ;
183+ Log ( "Song AuthorName: " + beatSaberStatus . songAuthorName ) ;
184+ Log ( "Level Author: " + beatSaberStatus . levelAuthorName ) ;
185+ Log ( "Song Hash: " + beatSaberStatus . songHash ) ;
186+ Log ( "Level ID: " + beatSaberStatus . levelId ) ;
187187
188188 // We need to check to see if there is a song-specific settings file, and if so, load that instead
189189 Log ( "Checking to see if there are song-specific Settings" ) ;
190- CameraPluginSettings . LoadSettings ( "settings." + BS . songHash + ".txt" ) ;
190+ CameraPluginSettings . LoadSettings ( "settings." + beatSaberStatus . songHash + ".txt" ) ;
191191
192192 if ( CameraPluginSettings . SongSpecific )
193193 {
@@ -200,7 +200,7 @@ public void UpdateCameraChange()
200200 }
201201 }
202202
203- if ( useHttpStatus && BS . paused )
203+ if ( useHttpStatus && beatSaberStatus . paused )
204204 {
205205 //We're paused, don't do anything
206206 }
@@ -213,45 +213,63 @@ public void UpdateCameraChange()
213213
214214 if ( transitionToMenu )
215215 {
216+ // Transition to the Menu Camera and mark that we've done so. Update currentCameraIndex to -1 so we don't skip over Index 0 when we move to another camera
217+ Log ( "Preparing to change to Menu Camera" ) ;
216218 transitionToMenu = false ;
217- currentCameraIndex = 0 ;
218-
219- //currentCameraData = CameraPluginSettings.CameraDataList[currentCameraIndex];
220- //currentCameraType = currentCameraData.Type;
221-
222- // I hate that this is hardcoded but unless we add a specific 'menu' camera in the base settings file it'll have to do for now
223- currentCameraData = new CameraData ( ) ;
224- currentCameraData . Name = "MenuCamera" ;
225- currentCameraData . Type = CameraType . LookAt ;
226- currentCameraData . PositionBinding = "playerWaist" ;
227- currentCameraData . PositionOffset = new Vector3 ( 2.0f , 1.0f , - 3.0f ) ;
228- currentCameraData . LookAt = new Vector3 ( - 2.0f , 0.0f , 5.0f ) ;
229- currentCameraType = currentCameraData . Type ;
230-
219+ currentCameraIndex = - 1 ;
220+ currentCameraData = CameraPluginSettings . MenuCamera ;
221+ currentCameraType = currentCameraData . Type ;
231222 }
232223 else
233224 {
225+ Log ( "Preparing to change to new Game Camera, currentCameraIndex = " + currentCameraIndex . ToString ( ) ) ;
234226 if ( CameraPluginSettings . SongSpecific )
235227 {
236- // Increment camera by 1
228+ Log ( "Song specific settings file active, increment to next camera" ) ;
229+ // Increment camera by 1 but make sure we don't skip over index 0 now
237230 if ( newCameraIndex < CameraPluginSettings . CameraDataList . Count )
238231 newCameraIndex ++ ;
239232 }
240233 else
241234 {
242- // Don't pick the same camera again for a few times
243- while ( previousCameraIndices . Contains ( newCameraIndex ) || ( currentCameraType == CameraType . Orbital && CameraPluginSettings . CameraDataList [ newCameraIndex ] . Type == CameraType . Orbital ) )
235+ Log ( "Default settings file active, preparing to pick next camera" ) ;
236+ // If we don't have enough cameras to truly randomize...uh...I guess don't
237+ if ( CameraPluginSettings . CameraDataList . Count > 2 )
244238 {
245- newCameraIndex = rand . Next ( ) % CameraPluginSettings . CameraDataList . Count ;
239+ // Don't pick the same camera again for a few times
240+ while ( previousCameraIndices . Contains ( newCameraIndex ) || ( currentCameraType == CameraType . Orbital && CameraPluginSettings . CameraDataList [ newCameraIndex ] . Type == CameraType . Orbital ) )
241+ {
242+ newCameraIndex = rand . Next ( ) % CameraPluginSettings . CameraDataList . Count ;
243+ }
244+ }
245+ else if ( CameraPluginSettings . CameraDataList . Count == 2 )
246+ {
247+ Log ( "Only 2 cameras available, swapping between them" ) ;
248+ // If you've got two cameras switch between them, otherwise just stick with the current one
249+ switch ( currentCameraIndex )
250+ {
251+ case 0 :
252+ newCameraIndex = 1 ;
253+ break ;
254+ case 1 :
255+ newCameraIndex = 0 ;
256+ break ;
257+ default :
258+ newCameraIndex = 0 ;
259+ break ;
260+ }
261+ }
262+ else
263+ {
264+ newCameraIndex = 0 ;
246265 }
247266 }
248267
249268 if ( previousCameraIndices . Count > 1 )
250- {
251269 previousCameraIndices . RemoveAt ( 0 ) ;
252- }
253270
254271 previousCameraIndices . Add ( newCameraIndex ) ;
272+
255273 currentCameraIndex = newCameraIndex ;
256274 currentCameraData = CameraPluginSettings . CameraDataList [ currentCameraIndex ] ;
257275 currentCameraType = currentCameraData . Type ;
@@ -267,9 +285,9 @@ public void UpdateCameraChange()
267285 var maxTime = currentCameraData . MaxTime ;
268286 nextChangeTimer = _elapsedTime + minTime + ( float ) ( rand . NextDouble ( ) * ( maxTime - minTime ) ) ;
269287 }
270- }
271288
272- Log ( "New Camera: " + newCameraIndex + ", " + currentCameraData . Name + ", " + currentCameraData . Type . ToString ( ) ) ;
289+ Log ( "New Camera: " + newCameraIndex + ", " + currentCameraData . Name + ", " + currentCameraData . Type . ToString ( ) + ", " + nextChangeTimer . ToString ( ) + "s" ) ;
290+ }
273291
274292 switch ( currentCameraType )
275293 {
@@ -324,7 +342,7 @@ public void UpdateCameraChange()
324342 public void OnUpdate ( )
325343 {
326344 // Allows us to track when HTTPStatus first makes a connecction
327- if ( ! useHttpStatus && BS . connected )
345+ if ( ! useHttpStatus && beatSaberStatus . connected )
328346 {
329347 useHttpStatus = true ;
330348 inMenu = true ;
@@ -333,14 +351,14 @@ public void OnUpdate()
333351
334352 if ( useHttpStatus )
335353 {
336- if ( CameraPluginSettings . Debug && BS . debug . Count > 0 )
354+ if ( CameraPluginSettings . Debug && beatSaberStatus . debug . Count > 0 )
337355 {
338356 // Write debug messages from HTTPStatus
339- Log ( BS . debug [ 0 ] ) ;
340- BS . debug . RemoveAt ( 0 ) ;
357+ Log ( beatSaberStatus . debug [ 0 ] ) ;
358+ beatSaberStatus . debug . RemoveAt ( 0 ) ;
341359 }
342360
343- if ( BS . menu )
361+ if ( beatSaberStatus . menu )
344362 {
345363 // This is a silly way to do this but it allows us to keep track of when we transition between menu and game mode
346364 // That still seems silly, but when juggling random songs, and song-specific camera update files it is helpful. Maybe.
@@ -353,7 +371,7 @@ public void OnUpdate()
353371 // Don't start the timer until we hit our first note, also check for pause
354372 // This allows us to have 'synced' song-specific camera files as different systems will load songs at different speeds
355373 // based on storage and cpu performance. Just...don't miss the first note I guess?
356- if ( BS . score > 0 && ! BS . paused )
374+ if ( beatSaberStatus . score > 0 && ! beatSaberStatus . paused )
357375 _elapsedTime += Time . deltaTime ;
358376 }
359377 }
0 commit comments