1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Implement RepeatSamples in IHasRepeats.

This commit is contained in:
smoogipooo 2017-04-21 16:18:34 +09:00
parent b4a4597366
commit ca824de91c
4 changed files with 32 additions and 10 deletions

View File

@ -33,6 +33,8 @@ namespace osu.Game.Rulesets.Osu.Objects
public double ProgressAt(double progress) => CurveObject.ProgressAt(progress);
public int RepeatAt(double progress) => CurveObject.RepeatAt(progress);
public List<List<SampleInfo>> RepeatSamples => CurveObject.RepeatSamples;
public List<Vector2> ControlPoints => CurveObject.ControlPoints;
public CurveType CurveType => CurveObject.CurveType;
public double Distance => CurveObject.Distance;

View File

@ -4,6 +4,10 @@
using OpenTK;
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
using osu.Game.Audio;
using System;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
namespace osu.Game.Rulesets.Objects
{
@ -34,6 +38,8 @@ namespace osu.Game.Rulesets.Objects
set { Curve.Distance = value; }
}
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public Vector2 PositionAt(double progress) => Curve.PositionAt(ProgressAt(progress));
public double ProgressAt(double progress)

View File

@ -4,6 +4,7 @@
using osu.Game.Audio;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Objects
@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Objects
/// <summary>
/// The time at which the HitObject starts.
/// </summary>
public double StartTime { get; set; }
public double StartTime;
/// <summary>
/// The samples to be played when this hit object is hit.
@ -36,17 +37,25 @@ namespace osu.Game.Rulesets.Objects
ControlPoint overridePoint;
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
foreach (var sample in Samples)
{
if (sample.Volume == 0)
sample.Volume = (overridePoint ?? timingPoint)?.SampleVolume ?? 0;
ControlPoint samplePoint = overridePoint ?? timingPoint;
// If the bank is not assigned a name, assign it from the control point
if (!string.IsNullOrEmpty(sample.Bank))
continue;
// Initialize first sample
foreach (SampleInfo sample in Samples)
initializeSampleInfo(sample, samplePoint);
sample.Bank = (overridePoint ?? timingPoint)?.SampleBank ?? @"normal";
}
// Initialize any repeat samples
var repeatData = this as IHasRepeats;
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => initializeSampleInfo(s, samplePoint)));
}
private void initializeSampleInfo(SampleInfo sample, ControlPoint controlPoint)
{
if (sample.Volume == 0)
sample.Volume = controlPoint?.SampleVolume ?? 0;
// If the bank is not assigned a name, assign it from the control point
if (string.IsNullOrEmpty(sample.Bank))
sample.Bank = controlPoint?.SampleBank ?? @"normal";
}
}
}

View File

@ -1,6 +1,9 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Audio;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Objects.Types
{
/// <summary>
@ -12,5 +15,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// The amount of times the HitObject repeats.
/// </summary>
int RepeatCount { get; }
List<List<SampleInfo>> RepeatSamples { get; }
}
}