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