mirror of
https://github.com/osukey/osukey.git
synced 2025-05-16 11:07:35 +09:00
Determine SampleInfo defaults in DrawableHitObject
This commit is contained in:
parent
58859f2ffb
commit
cb7e192aff
@ -12,6 +12,7 @@ using osu.Game.Rulesets.Objects;
|
|||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects
|
namespace osu.Game.Rulesets.Catch.Objects
|
||||||
{
|
{
|
||||||
@ -29,9 +30,14 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
public double Velocity;
|
public double Velocity;
|
||||||
public double TickDistance;
|
public double TickDistance;
|
||||||
|
|
||||||
|
private ControlPointInfo controlPointInfo;
|
||||||
|
private BeatmapDifficulty difficulty;
|
||||||
|
|
||||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
this.controlPointInfo = controlPointInfo;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||||
@ -124,6 +130,8 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ticks.ForEach(t => t.ApplyDefaults(controlPointInfo, difficulty));
|
||||||
|
|
||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,16 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private double tickSpacing = 50;
|
private double tickSpacing = 50;
|
||||||
|
|
||||||
|
private ControlPointInfo controlPointInfo;
|
||||||
|
private BeatmapDifficulty difficulty;
|
||||||
|
|
||||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
this.controlPointInfo = controlPointInfo;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
||||||
|
|
||||||
@ -89,11 +95,15 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
|
|
||||||
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing)
|
||||||
{
|
{
|
||||||
ret.Add(new HoldNoteTick
|
var tick = new HoldNoteTick
|
||||||
{
|
{
|
||||||
StartTime = t,
|
StartTime = t,
|
||||||
Column = Column
|
Column = Column
|
||||||
});
|
};
|
||||||
|
|
||||||
|
tick.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
ret.Add(tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -57,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
Scale = s.Scale,
|
Scale = s.Scale,
|
||||||
ComboColour = s.ComboColour,
|
ComboColour = s.ComboColour,
|
||||||
Samples = s.Samples,
|
Samples = s.Samples,
|
||||||
|
SoundControlPoint = s.SoundControlPoint
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects
|
namespace osu.Game.Rulesets.Osu.Objects
|
||||||
{
|
{
|
||||||
@ -74,10 +75,16 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
public double Velocity;
|
public double Velocity;
|
||||||
public double TickDistance;
|
public double TickDistance;
|
||||||
|
|
||||||
|
private ControlPointInfo controlPointInfo;
|
||||||
|
private BeatmapDifficulty difficulty;
|
||||||
|
|
||||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
this.controlPointInfo = controlPointInfo;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
|
||||||
|
|
||||||
@ -124,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
var distanceProgress = d / length;
|
var distanceProgress = d / length;
|
||||||
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
var timeProgress = reversed ? 1 - distanceProgress : distanceProgress;
|
||||||
|
|
||||||
yield return new SliderTick
|
var ret = new SliderTick
|
||||||
{
|
{
|
||||||
RepeatIndex = repeat,
|
RepeatIndex = repeat,
|
||||||
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
StartTime = repeatStartTime + timeProgress * repeatDuration,
|
||||||
@ -139,6 +146,10 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
Volume = s.Volume
|
Volume = s.Volume
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ret.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
yield return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +169,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
var repeatStartTime = StartTime + repeat * repeatDuration;
|
var repeatStartTime = StartTime + repeat * repeatDuration;
|
||||||
var distanceProgress = d / length;
|
var distanceProgress = d / length;
|
||||||
|
|
||||||
yield return new RepeatPoint
|
var ret = new RepeatPoint
|
||||||
{
|
{
|
||||||
RepeatIndex = repeat,
|
RepeatIndex = repeat,
|
||||||
StartTime = repeatStartTime,
|
StartTime = repeatStartTime,
|
||||||
@ -167,6 +178,10 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
Scale = Scale,
|
Scale = Scale,
|
||||||
ComboColour = ComboColour,
|
ComboColour = ComboColour,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ret.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
yield return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,14 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private double tickSpacing = 100;
|
private double tickSpacing = 100;
|
||||||
|
|
||||||
|
private ControlPointInfo controlPointInfo;
|
||||||
|
private BeatmapDifficulty difficulty;
|
||||||
|
|
||||||
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.ApplyDefaults(controlPointInfo, difficulty);
|
base.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
this.controlPointInfo = controlPointInfo;
|
||||||
|
this.difficulty = difficulty;
|
||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
|
|
||||||
@ -77,7 +82,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
||||||
{
|
{
|
||||||
ret.Add(new DrumRollTick
|
var tick = new DrumRollTick
|
||||||
{
|
{
|
||||||
FirstTick = first,
|
FirstTick = first,
|
||||||
TickSpacing = tickSpacing,
|
TickSpacing = tickSpacing,
|
||||||
@ -89,12 +94,15 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
Name = @"slidertick",
|
Name = @"slidertick",
|
||||||
Volume = s.Volume
|
Volume = s.Volume
|
||||||
}))
|
}))
|
||||||
});
|
};
|
||||||
|
|
||||||
|
tick.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
|
||||||
|
ret.Add(tick);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,40 +15,19 @@ namespace osu.Game.Audio
|
|||||||
public const string HIT_NORMAL = @"hitnormal";
|
public const string HIT_NORMAL = @"hitnormal";
|
||||||
public const string HIT_CLAP = @"hitclap";
|
public const string HIT_CLAP = @"hitclap";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="SoundControlPoint"/> that is used for <see cref="Bank"/> and <see cref="Volume"/>
|
|
||||||
/// if the values have not already been provided by the hitobject.
|
|
||||||
/// </summary>
|
|
||||||
[JsonIgnore]
|
|
||||||
public SoundControlPoint ControlPoint;
|
|
||||||
|
|
||||||
private string bank;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bank to load the sample from.
|
/// The bank to load the sample from.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Bank
|
public string Bank;
|
||||||
{
|
|
||||||
get { return string.IsNullOrEmpty(bank) ? (ControlPoint?.SampleBank ?? "normal") : bank; }
|
|
||||||
set { bank = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldSerializeBank() => Bank != ControlPoint.SampleBank;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the sample to load.
|
/// The name of the sample to load.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name;
|
||||||
|
|
||||||
private int volume;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sample volume.
|
/// The sample volume.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Volume
|
public int Volume;
|
||||||
{
|
|
||||||
get { return volume == 0 ? (ControlPoint?.SampleVolume ?? 0) : volume; }
|
|
||||||
set { volume = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ShouldSerializeVolume() => Volume != ControlPoint.SampleVolume;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,16 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
{
|
{
|
||||||
public class SoundControlPoint : ControlPoint
|
public class SoundControlPoint : ControlPoint
|
||||||
{
|
{
|
||||||
|
public const string DEFAULT_BANK = "normal";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default sample bank at this control point.
|
/// The default sample bank at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SampleBank;
|
public string SampleBank = DEFAULT_BANK;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default sample volume at this control point.
|
/// The default sample volume at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SampleVolume;
|
public int SampleVolume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,12 +86,23 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
foreach (SampleInfo sample in HitObject.Samples)
|
foreach (SampleInfo sample in HitObject.Samples)
|
||||||
{
|
{
|
||||||
SampleChannel channel = audio.Sample.Get($@"Gameplay/{sample.Bank}-{sample.Name}");
|
if (HitObject.SoundControlPoint == null)
|
||||||
|
throw new ArgumentNullException(nameof(HitObject.SoundControlPoint), $"{nameof(HitObject)} must always have an attached {nameof(HitObject.SoundControlPoint)}.");
|
||||||
|
|
||||||
|
var bank = sample.Bank;
|
||||||
|
if (string.IsNullOrEmpty(bank))
|
||||||
|
bank = HitObject.SoundControlPoint.SampleBank;
|
||||||
|
|
||||||
|
int volume = sample.Volume;
|
||||||
|
if (volume == 0)
|
||||||
|
volume = HitObject.SoundControlPoint.SampleVolume;
|
||||||
|
|
||||||
|
SampleChannel channel = audio.Sample.Get($@"Gameplay/{bank}-{sample.Name}");
|
||||||
|
|
||||||
if (channel == null)
|
if (channel == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
channel.Volume.Value = sample.Volume;
|
channel.Volume.Value = volume;
|
||||||
Samples.Add(channel);
|
Samples.Add(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public SampleInfoList Samples = new SampleInfoList();
|
public SampleInfoList Samples = new SampleInfoList();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public SoundControlPoint SoundControlPoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this <see cref="HitObject"/> is in Kiai time.
|
/// Whether this <see cref="HitObject"/> is in Kiai time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -48,13 +51,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
EffectControlPoint effectPoint = controlPointInfo.EffectPointAt(StartTime);
|
||||||
|
|
||||||
Kiai = effectPoint.KiaiMode;
|
Kiai = effectPoint.KiaiMode;
|
||||||
|
SoundControlPoint = soundPoint;
|
||||||
// Initialize first sample
|
|
||||||
Samples.ForEach(s => s.ControlPoint = soundPoint);
|
|
||||||
|
|
||||||
// Initialize any repeat samples
|
|
||||||
var repeatData = this as IHasRepeats;
|
|
||||||
repeatData?.RepeatSamples?.ForEach(r => r.ForEach(s => s.ControlPoint = soundPoint));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user