Add ruleset templates structure

This commit is contained in:
smoogipoo
2021-04-05 11:41:40 +09:00
parent 47c0e672d6
commit 37f8b62200
109 changed files with 7990 additions and 0 deletions

View File

@ -0,0 +1,32 @@
// 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.Collections.Generic;
using System.Threading;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.EmptyScrolling.Objects;
namespace osu.Game.Rulesets.EmptyScrolling.Beatmaps
{
public class EmptyScrollingBeatmapConverter : BeatmapConverter<EmptyScrollingHitObject>
{
public EmptyScrollingBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
: base(beatmap, ruleset)
{
}
// todo: Check for conversion types that should be supported (ie. Beatmap.HitObjects.Any(h => h is IHasXPosition))
// https://github.com/ppy/osu/tree/master/osu.Game/Rulesets/Objects/Types
public override bool CanConvert() => true;
protected override IEnumerable<EmptyScrollingHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken)
{
yield return new EmptyScrollingHitObject
{
Samples = original.Samples,
StartTime = original.StartTime,
};
}
}
}

View File

@ -0,0 +1,30 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.EmptyScrolling
{
public class EmptyScrollingDifficultyCalculator : DifficultyCalculator
{
public EmptyScrollingDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
}
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
{
return new DifficultyAttributes(mods, skills, 0);
}
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate) => Enumerable.Empty<DifficultyHitObject>();
protected override Skill[] CreateSkills(IBeatmap beatmap, Mod[] mods) => new Skill[0];
}
}

View File

@ -0,0 +1,26 @@
// 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.ComponentModel;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.EmptyScrolling
{
public class EmptyScrollingInputManager : RulesetInputManager<EmptyScrollingAction>
{
public EmptyScrollingInputManager(RulesetInfo ruleset)
: base(ruleset, 0, SimultaneousBindingMode.Unique)
{
}
}
public enum EmptyScrollingAction
{
[Description("Button 1")]
Button1,
[Description("Button 2")]
Button2,
}
}

View File

@ -0,0 +1,57 @@
// 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.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.EmptyScrolling.Beatmaps;
using osu.Game.Rulesets.EmptyScrolling.Mods;
using osu.Game.Rulesets.EmptyScrolling.UI;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.EmptyScrolling
{
public class EmptyScrollingRuleset : Ruleset
{
public override string Description => "a very emptyscrolling ruleset";
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableEmptyScrollingRuleset(this, beatmap, mods);
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new EmptyScrollingBeatmapConverter(beatmap, this);
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new EmptyScrollingDifficultyCalculator(this, beatmap);
public override IEnumerable<Mod> GetModsFor(ModType type)
{
switch (type)
{
case ModType.Automation:
return new[] { new EmptyScrollingModAutoplay() };
default:
return new Mod[] { null };
}
}
public override string ShortName => "emptyscrolling";
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{
new KeyBinding(InputKey.Z, EmptyScrollingAction.Button1),
new KeyBinding(InputKey.X, EmptyScrollingAction.Button2),
};
public override Drawable CreateIcon() => new SpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = ShortName[0].ToString(),
Font = OsuFont.Default.With(size: 18),
};
}
}

View File

@ -0,0 +1,25 @@
// 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 osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.EmptyScrolling.Objects;
using osu.Game.Rulesets.EmptyScrolling.Replays;
using osu.Game.Scoring;
using osu.Game.Users;
using System.Collections.Generic;
namespace osu.Game.Rulesets.EmptyScrolling.Mods
{
public class EmptyScrollingModAutoplay : ModAutoplay<EmptyScrollingHitObject>
{
public override Score CreateReplayScore(IBeatmap beatmap, IReadOnlyList<Mod> mods) => new Score
{
ScoreInfo = new ScoreInfo
{
User = new User { Username = "sample" },
},
Replay = new EmptyScrollingAutoGenerator(beatmap).Generate(),
};
}
}

View File

@ -0,0 +1,48 @@
// 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 osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.EmptyScrolling.Objects.Drawables
{
public class DrawableEmptyScrollingHitObject : DrawableHitObject<EmptyScrollingHitObject>
{
public DrawableEmptyScrollingHitObject(EmptyScrollingHitObject hitObject)
: base(hitObject)
{
Size = new Vector2(40);
Origin = Anchor.Centre;
// todo: add visuals.
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (timeOffset >= 0)
// todo: implement judgement logic
ApplyResult(r => r.Type = HitResult.Perfect);
}
protected override void UpdateHitStateTransforms(ArmedState state)
{
const double duration = 1000;
switch (state)
{
case ArmedState.Hit:
this.FadeOut(duration, Easing.OutQuint).Expire();
break;
case ArmedState.Miss:
this.FadeColour(Color4.Red, duration);
this.FadeOut(duration, Easing.InQuint).Expire();
break;
}
}
}
}

View File

@ -0,0 +1,13 @@
// 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 osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.EmptyScrolling.Objects
{
public class EmptyScrollingHitObject : HitObject
{
public override Judgement CreateJudgement() => new Judgement();
}
}

View File

@ -0,0 +1,41 @@
// 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.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.EmptyScrolling.Objects;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.EmptyScrolling.Replays
{
public class EmptyScrollingAutoGenerator : AutoGenerator
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public new Beatmap<EmptyScrollingHitObject> Beatmap => (Beatmap<EmptyScrollingHitObject>)base.Beatmap;
public EmptyScrollingAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
public override Replay Generate()
{
Frames.Add(new EmptyScrollingReplayFrame());
foreach (EmptyScrollingHitObject hitObject in Beatmap.HitObjects)
{
Frames.Add(new EmptyScrollingReplayFrame
{
Time = hitObject.StartTime
// todo: add required inputs and extra frames.
});
}
return Replay;
}
}
}

View File

@ -0,0 +1,29 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Input.StateChanges;
using osu.Game.Replays;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.EmptyScrolling.Replays
{
public class EmptyScrollingFramedReplayInputHandler : FramedReplayInputHandler<EmptyScrollingReplayFrame>
{
public EmptyScrollingFramedReplayInputHandler(Replay replay)
: base(replay)
{
}
protected override bool IsImportant(EmptyScrollingReplayFrame frame) => frame.Actions.Any();
public override void CollectPendingInputs(List<IInput> inputs)
{
inputs.Add(new ReplayState<EmptyScrollingAction>
{
PressedActions = CurrentFrame?.Actions ?? new List<EmptyScrollingAction>(),
});
}
}
}

View File

@ -0,0 +1,19 @@
// 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.Collections.Generic;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.EmptyScrolling.Replays
{
public class EmptyScrollingReplayFrame : ReplayFrame
{
public List<EmptyScrollingAction> Actions = new List<EmptyScrollingAction>();
public EmptyScrollingReplayFrame(EmptyScrollingAction? button = null)
{
if (button.HasValue)
Actions.Add(button.Value);
}
}
}

View File

@ -0,0 +1,38 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Input.Handlers;
using osu.Game.Replays;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.EmptyScrolling.Objects;
using osu.Game.Rulesets.EmptyScrolling.Objects.Drawables;
using osu.Game.Rulesets.EmptyScrolling.Replays;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.EmptyScrolling.UI
{
[Cached]
public class DrawableEmptyScrollingRuleset : DrawableScrollingRuleset<EmptyScrollingHitObject>
{
public DrawableEmptyScrollingRuleset(EmptyScrollingRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
{
Direction.Value = ScrollingDirection.Left;
TimeRange.Value = 6000;
}
protected override Playfield CreatePlayfield() => new EmptyScrollingPlayfield();
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new EmptyScrollingFramedReplayInputHandler(replay);
public override DrawableHitObject<EmptyScrollingHitObject> CreateDrawableRepresentation(EmptyScrollingHitObject h) => new DrawableEmptyScrollingHitObject(h);
protected override PassThroughInputManager CreateInputManager() => new EmptyScrollingInputManager(Ruleset?.RulesetInfo);
}
}

View File

@ -0,0 +1,22 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.EmptyScrolling.UI
{
[Cached]
public class EmptyScrollingPlayfield : ScrollingPlayfield
{
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Drawable[]
{
HitObjectContainer,
});
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Project">
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyTitle>osu.Game.Rulesets.Sample</AssemblyTitle>
<OutputType>Library</OutputType>
<PlatformTarget>AnyCPU</PlatformTarget>
<RootNamespace>osu.Game.Rulesets.EmptyScrolling</RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game" Version="2021.331.0" />
</ItemGroup>
</Project>