@@ -4,95 +4,11 @@ open System.IO
4
4
open System.Runtime .Serialization .Formatters .Binary
5
5
open BaboonAPI.Hooks .Tracks
6
6
open BaboonAPI.Internal
7
- open BaboonAPI.Utility
8
- open BaboonAPI.Utility .Unity
7
+ open BaboonAPI.Internal .BaseGame
9
8
open BepInEx.Logging
10
9
open HarmonyLib
11
10
open UnityEngine
12
11
13
- type internal BaseGameLoadedTrack ( trackref : string , bundle : AssetBundle ) =
14
- interface LoadedTromboneTrack with
15
- member this.LoadAudio () =
16
- let obj = bundle.LoadAsset< GameObject>( $" music_{trackref}" )
17
- let src = obj.GetComponent< AudioSource>()
18
- { Clip = src.clip; Volume = src.volume }
19
-
20
- member this.LoadBackground _ctx =
21
- bundle.LoadAsset< GameObject> $" BGCam_{trackref}"
22
-
23
- member this.Dispose () =
24
- bundle.Unload true
25
-
26
- member this.SetUpBackgroundDelayed _ _ =
27
- ()
28
-
29
- member this.trackref = trackref
30
-
31
- interface PauseAware with
32
- member this.CanResume = true
33
-
34
- member this.OnPause _ = ()
35
-
36
- member this.OnResume _ = ()
37
-
38
- type internal BaseGameTrack ( data : string []) =
39
- interface TromboneTrack with
40
- member _.trackname_long = data[ 0 ]
41
- member _.trackname_short = data[ 1 ]
42
- member _.trackref = data[ 2 ]
43
- member _.year = data[ 3 ]
44
- member _.artist = data[ 4 ]
45
- member _.genre = data[ 5 ]
46
- member _.desc = data[ 6 ]
47
- member _.difficulty = int data[ 7 ]
48
- member _.length = int data[ 8 ]
49
- member _.tempo = int data[ 9 ]
50
-
51
- member this.LoadTrack () =
52
- let trackref = ( this :> TromboneTrack) .trackref
53
- let bundle = AssetBundle.LoadFromFile $" {Application.streamingAssetsPath}/trackassets/{trackref}"
54
- new BaseGameLoadedTrack ( trackref, bundle)
55
-
56
- member this.IsVisible () =
57
- let trackref = ( this :> TromboneTrack) .trackref
58
- match trackref with
59
- | " einefinal" -> GlobalVariables.localsave.progression_ trombone_ champ
60
- | _ -> true
61
-
62
- member this.LoadChart () =
63
- let trackref = ( this :> TromboneTrack) .trackref
64
- let path = $" {Application.streamingAssetsPath}/leveldata/{trackref}.tmb"
65
- use stream = File.Open( path, FileMode.Open)
66
- BinaryFormatter() .Deserialize( stream) :?> SavedLevel
67
-
68
- interface Previewable with
69
- member this.LoadClip () =
70
- let trackref = ( this :> TromboneTrack) .trackref
71
- let path = $" {Application.streamingAssetsPath}/trackclips/{trackref}-sample.ogg"
72
-
73
- loadAudioClip ( path, AudioType.OGGVORBIS)
74
- |> Coroutines.map ( Result.map ( fun audioClip -> { Clip = audioClip; Volume = 0.9 f }))
75
-
76
- interface Graphable with
77
- member this.CreateGraph () =
78
- match ( this :> TromboneTrack) .trackref with
79
- | " warmup" -> Some ( SongGraph.all 10 )
80
- | " einefinal" -> Some ( SongGraph.all 104 )
81
- | _ -> None
82
-
83
- type internal BaseGameTrackRegistry ( songs : SongData ) =
84
- /// List of base game trackrefs
85
- member _.trackrefs =
86
- songs.data_ tracktitles
87
- |> Seq.map ( fun data -> data[ 2 ])
88
- |> Seq.toList
89
-
90
- interface TrackRegistrationEvent.Listener with
91
- override this.OnRegisterTracks () = seq {
92
- for array in songs.data_ tracktitles do
93
- yield BaseGameTrack array
94
- }
95
-
96
12
[<HarmonyPatch( typeof< SaverLoader>, " loadLevelData" ) >]
97
13
type LoaderPatch () =
98
14
static let logger = Logger.CreateLogSource " BaboonAPI.BaseTracksLoader"
0 commit comments