-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathCatchModMovingFast.cs
More file actions
83 lines (70 loc) · 2.92 KB
/
CatchModMovingFast.cs
File metadata and controls
83 lines (70 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) ppy Pty Ltd <[email protected]>. 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.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Rulesets.Catch.Mods
{
public partial class CatchModMovingFast : Mod, IApplicableToDrawableRuleset<CatchHitObject>, IApplicableToPlayer
{
public override string Name => "Moving Fast";
public override string Acronym => "MF";
public override LocalisableString Description => "Dashing by default, slow down!";
public override ModType Type => ModType.Fun;
public override double ScoreMultiplier(IReadOnlyCollection<Mod> mods) => 1;
public override IconUsage? Icon => OsuIcon.ModMovingFast;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(ModRelax) };
private DrawableCatchRuleset drawableRuleset = null!;
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
{
this.drawableRuleset = (DrawableCatchRuleset)drawableRuleset;
}
public void ApplyToPlayer(Player player)
{
if (!drawableRuleset.HasReplayLoaded.Value)
{
var catchPlayfield = (CatchPlayfield)drawableRuleset.Playfield;
catchPlayfield.Catcher.Dashing = true;
catchPlayfield.CatcherArea.Add(new InvertDashInputHelper(catchPlayfield.CatcherArea));
}
}
private partial class InvertDashInputHelper : Drawable, IKeyBindingHandler<CatchAction>
{
private readonly CatcherArea catcherArea;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public InvertDashInputHelper(CatcherArea catcherArea)
{
this.catcherArea = catcherArea;
RelativeSizeAxes = Axes.Both;
}
public bool OnPressed(KeyBindingPressEvent<CatchAction> e)
{
switch (e.Action)
{
case CatchAction.MoveLeft or CatchAction.MoveRight:
break;
case CatchAction.Dash:
catcherArea.Catcher.Dashing = false;
return true;
}
return false;
}
public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
{
if (e.Action == CatchAction.Dash)
catcherArea.Catcher.Dashing = true;
}
}
}
}