mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 06:19:55 +08:00
c361e6d3c2
This is a set of model changes which is supposed to facilitate support for custom sample sets to the beatmap editor that is on par with stable. It is the minimal set of changes. Because of this, it can probably be considered "ugly" or however else you want to put it - but before you say that, I want to try and pre-empt that criticism by explaining where the problems lie. Problem #1: duality in sample models --- There is currently a weird duality of what a `HitObject`'s samples will be. - If an object has just been placed in the editor, and not saved / decoded yet, it will use `HitSampleInfo`. - If an object has already been encoded to the beatmap at least once, it will use `ConvertHitObjectParser.LegacyHitSampleInfo`. As long as that state of affairs remains, `HitSampleInfo` must be able to represent anything that `LegacyHitSampleInfo` can, if feature parity is to be achieved. Problem 2: The 0 & 1 sample banks --- Custom sample banks of 2 and above are a pretty clean affair. They map to a suffix on the sample filename, and said samples are allowed to be looked up from the beatmap skin. `Suffix` already exists in `HitSampleInfo`. However, the 1 custom sample bank is evil. It uses *non-suffixed* samples, *allows lookups from the beatmap skins*, contrary to no bank / bank 0, which *also* uses non-suffixed samples, but *doesn't* allow them to be looked up from the beatmap skin. This is why `HitSampleInfo.UseBeatmapSamples` has been called to existence - without it there is no way to represent the ability of using or not using the beatmap skin assets. As has been stated previously in discussions about this feature, it's both a *mapping* and a *skinning* concern. There are many things you could do about either of these problems, but I am pretty sure tackling either one is going to take *many* more lines of code than this commit does. Which is why this is the starting point of negotiation.
87 lines
3.3 KiB
C#
87 lines
3.3 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using osu.Game.Audio;
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
using osu.Game.Rulesets.Catch.Judgements;
|
|
using osu.Game.Rulesets.Judgements;
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
using osu.Game.Skinning;
|
|
using osu.Game.Utils;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects
|
|
{
|
|
public class Banana : PalpableCatchHitObject, IHasComboInformation
|
|
{
|
|
/// <summary>
|
|
/// Index of banana in current shower.
|
|
/// </summary>
|
|
public int BananaIndex;
|
|
|
|
public override Judgement CreateJudgement() => new CatchBananaJudgement();
|
|
|
|
private static readonly IList<HitSampleInfo> default_banana_samples = new List<HitSampleInfo> { new BananaHitSampleInfo() }.AsReadOnly();
|
|
|
|
public Banana()
|
|
{
|
|
Samples = default_banana_samples;
|
|
}
|
|
|
|
// override any external colour changes with banananana
|
|
Color4 IHasComboInformation.GetComboColour(ISkin skin) => getBananaColour();
|
|
|
|
private Color4 getBananaColour()
|
|
{
|
|
switch (StatelessRNG.NextInt(3, RandomSeed))
|
|
{
|
|
default:
|
|
return new Color4(255, 240, 0, 255);
|
|
|
|
case 1:
|
|
return new Color4(255, 192, 0, 255);
|
|
|
|
case 2:
|
|
return new Color4(214, 221, 28, 255);
|
|
}
|
|
}
|
|
|
|
public class BananaHitSampleInfo : HitSampleInfo, IEquatable<BananaHitSampleInfo>
|
|
{
|
|
private static readonly string[] lookup_names = { "Gameplay/metronomelow", "Gameplay/catch-banana" };
|
|
|
|
public override IEnumerable<string> LookupNames => lookup_names;
|
|
|
|
public BananaHitSampleInfo()
|
|
: this(string.Empty)
|
|
{
|
|
}
|
|
|
|
public BananaHitSampleInfo(HitSampleInfo info)
|
|
: this(info.Name, info.Bank, info.Suffix, info.Volume, info.EditorAutoBank, info.UseBeatmapSamples)
|
|
{
|
|
}
|
|
|
|
private BananaHitSampleInfo(string name, string bank = SampleControlPoint.DEFAULT_BANK, string? suffix = null, int volume = 100, bool editorAutoBank = true, bool useBeatmapSamples = false)
|
|
: base(name, bank, suffix, volume, editorAutoBank, useBeatmapSamples)
|
|
{
|
|
}
|
|
|
|
public sealed override HitSampleInfo With(Optional<string> newName = default, Optional<string> newBank = default, Optional<string?> newSuffix = default, Optional<int> newVolume = default,
|
|
Optional<bool> newEditorAutoBank = default, Optional<bool> newUseBeatmapSamples = default)
|
|
=> new BananaHitSampleInfo(newName.GetOr(Name), newBank.GetOr(Bank), newSuffix.GetOr(Suffix), newVolume.GetOr(Volume),
|
|
newEditorAutoBank.GetOr(EditorAutoBank), newUseBeatmapSamples.GetOr(UseBeatmapSamples));
|
|
|
|
public bool Equals(BananaHitSampleInfo? other)
|
|
=> other != null;
|
|
|
|
public override bool Equals(object? obj)
|
|
=> obj is BananaHitSampleInfo other && Equals(other);
|
|
|
|
public override int GetHashCode() => lookup_names.GetHashCode();
|
|
}
|
|
}
|
|
}
|