remove other usages of hitobject SampleControlPoint

This commit is contained in:
OliBomby 2023-04-25 16:01:43 +02:00
parent a634617157
commit ebe1d852f5
5 changed files with 7 additions and 14 deletions

View File

@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Edit.Checks
yield break; yield break;
// Samples that allow themselves to be overridden by control points have a volume of 0. // Samples that allow themselves to be overridden by control points have a volume of 0.
int maxVolume = sampledHitObject.Samples.Max(sample => sample.Volume > 0 ? sample.Volume : sampledHitObject.SampleControlPoint.SampleVolume); int maxVolume = sampledHitObject.Samples.Max(sample => sample.Volume);
double samplePlayTime = sampledHitObject.GetEndTime(); double samplePlayTime = sampledHitObject.GetEndTime();
EdgeType edgeType = getEdgeAtTime(hitObject, samplePlayTime); EdgeType edgeType = getEdgeAtTime(hitObject, samplePlayTime);

View File

@ -74,9 +74,9 @@ namespace osu.Game.Rulesets.Edit
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param> /// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
protected void BeginPlacement(bool commitStart = false) protected void BeginPlacement(bool commitStart = false)
{ {
var nearestSampleControlPoint = beatmap.HitObjects.LastOrDefault(h => h.GetEndTime() < HitObject.StartTime)?.SampleControlPoint?.DeepClone() as SampleControlPoint; // Take the hitnormal sample of the last hit object
var lastHitNormal = beatmap.HitObjects.LastOrDefault(h => h.GetEndTime() < HitObject.StartTime)?.Samples?.FirstOrDefault(o => o.Name == HitSampleInfo.HIT_NORMAL);
HitObject.SampleControlPoint = nearestSampleControlPoint ?? new SampleControlPoint(); HitObject.Samples.Add(lastHitNormal);
placementHandler.BeginPlacement(HitObject); placementHandler.BeginPlacement(HitObject);
if (commitStart) if (commitStart)

View File

@ -357,13 +357,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
if (samples.Length <= 0) if (samples.Length <= 0)
return; return;
if (HitObject.SampleControlPoint == null) Samples.Samples = samples.Cast<ISampleInfo>().ToArray();
{
throw new InvalidOperationException($"{nameof(HitObject)}s must always have an attached {nameof(HitObject.SampleControlPoint)}."
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
}
Samples.Samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).Cast<ISampleInfo>().ToArray();
} }
private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples(); private void onSamplesChanged(object sender, NotifyCollectionChangedEventArgs e) => LoadSamples();

View File

@ -52,7 +52,6 @@ namespace osu.Game.Rulesets.UI
return; return;
var samples = nextObject.Samples var samples = nextObject.Samples
.Select(s => nextObject.SampleControlPoint.ApplyTo(s))
.Cast<ISampleInfo>() .Cast<ISampleInfo>()
.ToArray(); .ToArray();

View File

@ -293,10 +293,10 @@ namespace osu.Game.Rulesets.UI
{ {
// prepare sample pools ahead of time so we're not initialising at runtime. // prepare sample pools ahead of time so we're not initialising at runtime.
foreach (var sample in hitObject.Samples) foreach (var sample in hitObject.Samples)
prepareSamplePool(hitObject.SampleControlPoint.ApplyTo(sample)); prepareSamplePool(sample);
foreach (var sample in hitObject.AuxiliarySamples) foreach (var sample in hitObject.AuxiliarySamples)
prepareSamplePool(hitObject.SampleControlPoint.ApplyTo(sample)); prepareSamplePool(sample);
foreach (var nestedObject in hitObject.NestedHitObjects) foreach (var nestedObject in hitObject.NestedHitObjects)
preloadSamples(nestedObject); preloadSamples(nestedObject);