mirror of
https://github.com/ppy/osu.git
synced 2025-03-16 05:37:19 +08:00
Cleanup implementation of coop key mod
This is how I intended the functionality to be implemented.
This commit is contained in:
parent
9f98983550
commit
d2b1e27527
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
/// <summary>
|
||||
/// The definitions for each stage in a <see cref="ManiaPlayfield"/>.
|
||||
/// </summary>
|
||||
public readonly List<StageDefinition> Stages;
|
||||
public List<StageDefinition> Stages = new List<StageDefinition>();
|
||||
|
||||
/// <summary>
|
||||
/// Total number of columns represented by all stages in this <see cref="ManiaBeatmap"/>.
|
||||
@ -24,10 +24,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ManiaBeatmap"/>.
|
||||
/// </summary>
|
||||
/// <param name="stages">The initial stages.</param>
|
||||
public ManiaBeatmap(List<StageDefinition> stages)
|
||||
/// <param name="defaultStage">The initial stages.</param>
|
||||
public ManiaBeatmap(StageDefinition defaultStage)
|
||||
{
|
||||
Stages = stages;
|
||||
Stages.Add(defaultStage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
|
||||
|
||||
public int TargetColumns;
|
||||
public List<StageDefinition> StageDefinitions;
|
||||
public readonly bool IsForCurrentRuleset;
|
||||
|
||||
private Pattern lastPattern = new Pattern();
|
||||
@ -67,16 +66,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
return base.ConvertBeatmap(original);
|
||||
}
|
||||
|
||||
protected override Beatmap<ManiaHitObject> CreateBeatmap()
|
||||
{
|
||||
if (StageDefinitions == null)
|
||||
StageDefinitions = new List<StageDefinition>
|
||||
{
|
||||
new StageDefinition { Columns = TargetColumns }
|
||||
};
|
||||
|
||||
return beatmap = new ManiaBeatmap(StageDefinitions);
|
||||
}
|
||||
protected override Beatmap<ManiaHitObject> CreateBeatmap() => beatmap = new ManiaBeatmap(new StageDefinition { Columns = TargetColumns });
|
||||
|
||||
protected override IEnumerable<ManiaHitObject> ConvertHitObject(HitObject original, Beatmap beatmap)
|
||||
{
|
||||
|
@ -1,15 +1,18 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModKeyCoop : Mod, IApplicableToBeatmapConverter<ManiaHitObject>
|
||||
public class ManiaModKeyCoop : Mod, IApplicableToBeatmapConverter<ManiaHitObject>, IApplicableToRulesetContainer<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "KeyCoop";
|
||||
public override string ShortenedName => "2P";
|
||||
@ -25,16 +28,21 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
if (mbc.IsForCurrentRuleset)
|
||||
return;
|
||||
|
||||
int originTargetColumns = mbc.TargetColumns;
|
||||
mbc.TargetColumns *= 2;
|
||||
}
|
||||
|
||||
var newStages = new List<StageDefinition>
|
||||
public void ApplyToRulesetContainer(RulesetContainer<ManiaHitObject> rulesetContainer)
|
||||
{
|
||||
var mrc = (ManiaRulesetContainer)rulesetContainer;
|
||||
|
||||
var newDefinitions = new List<StageDefinition>();
|
||||
foreach (var existing in mrc.Beatmap.Stages)
|
||||
{
|
||||
new StageDefinition { Columns = originTargetColumns },
|
||||
new StageDefinition { Columns = originTargetColumns },
|
||||
};
|
||||
newDefinitions.Add(new StageDefinition { Columns = (int)Math.Ceiling(existing.Columns / 2f) });
|
||||
newDefinitions.Add(new StageDefinition { Columns = (int)Math.Floor(existing.Columns / 2f) });
|
||||
}
|
||||
|
||||
mbc.StageDefinitions = newStages;
|
||||
mbc.TargetColumns = originTargetColumns * 2;
|
||||
mrc.Beatmap.Stages = newDefinitions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user