Use BindTo instead of taking the game's beatmap bindable.

This commit is contained in:
smoogipooo 2017-05-22 17:01:43 +09:00
parent 609aac6453
commit f81ffa636d
1 changed files with 4 additions and 3 deletions

View File

@ -11,7 +11,8 @@ namespace osu.Game.Graphics.Containers
{ {
public class BeatSyncedContainer : Container public class BeatSyncedContainer : Container
{ {
private Bindable<WorkingBeatmap> beatmap; private Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
private int lastBeat; private int lastBeat;
private double lastTimingPointStart; private double lastTimingPointStart;
//This is to avoid sending new beats when not at the very start of the beat //This is to avoid sending new beats when not at the very start of the beat
@ -20,7 +21,7 @@ public class BeatSyncedContainer : Container
protected override void Update() protected override void Update()
{ {
if (beatmap.Value == null) if (beatmap.Value?.Track == null)
return; return;
double trackCurrentTime = beatmap.Value.Track.CurrentTime; double trackCurrentTime = beatmap.Value.Track.CurrentTime;
@ -53,7 +54,7 @@ protected virtual void OnNewBeat(int newBeat, double beatLength, TimeSignatures
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase game) private void load(OsuGameBase game)
{ {
beatmap = game.Beatmap; beatmap.BindTo(game.Beatmap);
} }
} }
} }