From b64585e81eb6d0798ad9a95d8162b84aeb3f2b04 Mon Sep 17 00:00:00 2001 From: Derrick Timmermans Date: Fri, 21 Oct 2022 08:49:41 +0200 Subject: [PATCH] Enable NRT In line with what was done with sentakki --- Directory.Build.props | 1 + .../Beatmaps/HishigataBeatmapConverter.cs | 4 ++-- .../HishigataDifficultyCalculator.cs | 2 +- .../HishigataRuleset.cs | 2 +- .../LinearMath/LineSegment.cs | 20 ++++++++-------- .../Mods/HishigataModHardRock.cs | 4 +--- .../Drawables/DrawableHishigataBonus.cs | 4 ++-- .../Drawables/DrawableHishigataHitObject.cs | 15 ++++-------- .../Drawables/DrawableHishigataNote.cs | 14 +++-------- .../Objects/HishigataBonus.cs | 2 -- .../Objects/HishigataHitObject.cs | 1 + .../Objects/HishigataNote.cs | 7 ------ .../Replays/HishigataReplayFrame.cs | 2 +- .../UI/DrawableHishigataRuleset.cs | 7 +++--- .../UI/HishigataPlayfield.cs | 24 ++++++------------- osu.Game.Rulesets.Hishigata/UI/Lane.cs | 8 +++---- .../UI/PoolableHitExplosion.cs | 8 ++++--- 17 files changed, 47 insertions(+), 78 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6eb88ed..865f0ee 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,6 +4,7 @@ true true true + enable Derrick Timmermans MIT diff --git a/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs b/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs index 79a781d..262e17c 100644 --- a/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs +++ b/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs @@ -30,7 +30,7 @@ protected override IEnumerable ConvertHitObject(HitObject or int seed = ((int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20) + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate); Random rng = new Random(seed); - Vector2 position = (original as IHasPosition).Position; + Vector2 position = ((IHasPosition)original).Position; float angle = getHitObjectAngle(position) / 90; int lane = (int)Math.Round(angle); @@ -78,7 +78,7 @@ protected override IEnumerable ConvertHitObject(HitObject or } } - private float getHitObjectAngle(Vector2 target) + private static float getHitObjectAngle(Vector2 target) { Vector2 direction = target - new Vector2(256, 192); float angle = MathHelper.RadiansToDegrees(MathF.Atan2(direction.Y, direction.X)); diff --git a/osu.Game.Rulesets.Hishigata/Difficulty/HishigataDifficultyCalculator.cs b/osu.Game.Rulesets.Hishigata/Difficulty/HishigataDifficultyCalculator.cs index 4a14b7d..6152a05 100644 --- a/osu.Game.Rulesets.Hishigata/Difficulty/HishigataDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Hishigata/Difficulty/HishigataDifficultyCalculator.cs @@ -18,7 +18,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat int maxCombo = 0; foreach (HishigataHitObject h in beatmap.HitObjects) { - if (!(h is HishigataBonus)) ++maxCombo; + if (h is not HishigataBonus) ++maxCombo; } return new DifficultyAttributes diff --git a/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs b/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs index 88ac96b..e0a6fb2 100644 --- a/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs +++ b/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs @@ -30,7 +30,7 @@ public class HishigataRuleset : Ruleset public override ScoreProcessor CreateScoreProcessor() => new HishigataScoreProcessor(this); - public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => new DrawableHishigataRuleset(this, beatmap, mods); + public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList? mods = null) => new DrawableHishigataRuleset(this, beatmap, mods); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new HishigataBeatmapConverter(beatmap, this); diff --git a/osu.Game.Rulesets.Hishigata/LinearMath/LineSegment.cs b/osu.Game.Rulesets.Hishigata/LinearMath/LineSegment.cs index a7e27a4..73dd971 100644 --- a/osu.Game.Rulesets.Hishigata/LinearMath/LineSegment.cs +++ b/osu.Game.Rulesets.Hishigata/LinearMath/LineSegment.cs @@ -21,24 +21,24 @@ public bool TryIntersect(LineSegment other, out Vector2 point) { if (Dx == 0 || other.Dx == 0) { - var m1 = Dx / Dy; - var m2 = other.Dx / other.Dy; + float m1 = Dx / Dy; + float m2 = other.Dx / other.Dy; - var b1 = PointA.X - (m1 * PointA.Y); - var b2 = other.PointA.X - (m2 * other.PointA.Y); + float b1 = PointA.X - (m1 * PointA.Y); + float b2 = other.PointA.X - (m2 * other.PointA.Y); - var y = (b2 - b1) / (m1 - m2); + float y = (b2 - b1) / (m1 - m2); point = new Vector2((m1 * y) + b1, y); } else { - var m1 = Dy / Dx; - var m2 = other.Dy / other.Dx; + float m1 = Dy / Dx; + float m2 = other.Dy / other.Dx; - var b1 = PointA.Y - (m1 * PointA.X); - var b2 = other.PointA.Y - (m2 * other.PointA.X); + float b1 = PointA.Y - (m1 * PointA.X); + float b2 = other.PointA.Y - (m2 * other.PointA.X); - var x = (b2 - b1) / (m1 - m2); + float x = (b2 - b1) / (m1 - m2); point = new Vector2(x, (m1 * x) + b1); } diff --git a/osu.Game.Rulesets.Hishigata/Mods/HishigataModHardRock.cs b/osu.Game.Rulesets.Hishigata/Mods/HishigataModHardRock.cs index 19dc2a9..3932572 100644 --- a/osu.Game.Rulesets.Hishigata/Mods/HishigataModHardRock.cs +++ b/osu.Game.Rulesets.Hishigata/Mods/HishigataModHardRock.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; -using System.Linq; using osu.Game.Rulesets.Hishigata.Objects; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; @@ -12,7 +10,7 @@ public class HishigataModHardRock : ModHardRock, IApplicableToHitObject public void ApplyToHitObject(HitObject hitObject) { - var hishiObj = hitObject as HishigataHitObject; + var hishiObj = (HishigataHitObject)hitObject; if (hishiObj.Lane == 0) hishiObj.Lane = 2; else if (hishiObj.Lane == 2) hishiObj.Lane = 0; } diff --git a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataBonus.cs b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataBonus.cs index 82bf51e..9d30159 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataBonus.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataBonus.cs @@ -7,8 +7,8 @@ public class DrawableHishigataBonus : DrawableHishigataHitObject public DrawableHishigataBonus() : this(null) { } - public DrawableHishigataBonus(HishigataHitObject hitObject = null) - : base(hitObject) + public DrawableHishigataBonus(HishigataHitObject? hitObject = null) + : base(hitObject!) { Colour = Color4.Gold; } diff --git a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataHitObject.cs b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataHitObject.cs index fb9a6bd..c9d1272 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataHitObject.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataHitObject.cs @@ -1,14 +1,9 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Scoring; using osuTK; using osuTK.Graphics; @@ -17,14 +12,14 @@ namespace osu.Game.Rulesets.Hishigata.Objects.Drawables public class DrawableHishigataHitObject : DrawableHitObject { protected override double InitialLifetimeOffset => HitObject.TimePreempt; - protected Sprite Note; + protected Sprite Note = null!; - public DrawableHishigataHitObject() : base(null) + public DrawableHishigataHitObject() : this(null) { } - public DrawableHishigataHitObject(HishigataHitObject hitObject = null) - : base(hitObject) + public DrawableHishigataHitObject(HishigataHitObject? hitObject = null) + : base(hitObject!) { } @@ -42,7 +37,7 @@ private void load(TextureStore textures) }); } - public Func CanBeHit; + public Func? CanBeHit; protected override void CheckForResult(bool userTriggered, double timeOffset) { diff --git a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataNote.cs b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataNote.cs index d625e01..01bb185 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataNote.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/Drawables/DrawableHishigataNote.cs @@ -1,13 +1,5 @@ -using System; -using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Scoring; using osuTK; using osuTK.Graphics; @@ -18,12 +10,12 @@ public class DrawableHishigataNote : DrawableHishigataHitObject public new HishigataNote HitObject => (HishigataNote)base.HitObject; protected override double InitialLifetimeOffset => HitObject.TimePreempt + (HitObject.IsFeign ? 200 : 0); - public DrawableHishigataNote() : base(null) + public DrawableHishigataNote() : this(null) { } - public DrawableHishigataNote(HishigataHitObject hitObject = null) - : base(hitObject) + public DrawableHishigataNote(HishigataHitObject? hitObject = null) + : base(hitObject!) { } diff --git a/osu.Game.Rulesets.Hishigata/Objects/HishigataBonus.cs b/osu.Game.Rulesets.Hishigata/Objects/HishigataBonus.cs index e1cd88e..f5bf1a5 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/HishigataBonus.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/HishigataBonus.cs @@ -18,7 +18,6 @@ public HishigataBonus() public override Judgement CreateJudgement() => new HishigataBonusJudgement(); -#nullable enable private class BonusHitSampleInfo : HitSampleInfo, IEquatable { private const string lookup_name = "Gameplay/catch-banana"; @@ -47,6 +46,5 @@ public override bool Equals(object? obj) public override int GetHashCode() => lookup_name.GetHashCode(); } - //#nullable restore } } diff --git a/osu.Game.Rulesets.Hishigata/Objects/HishigataHitObject.cs b/osu.Game.Rulesets.Hishigata/Objects/HishigataHitObject.cs index f4f1c09..99b243c 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/HishigataHitObject.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/HishigataHitObject.cs @@ -12,6 +12,7 @@ public class HishigataHitObject : HitObject public double TimePreempt; public BindableInt LaneBindable = new BindableInt(); + public int Lane { get => LaneBindable.Value; diff --git a/osu.Game.Rulesets.Hishigata/Objects/HishigataNote.cs b/osu.Game.Rulesets.Hishigata/Objects/HishigataNote.cs index 2ae521a..bbf314b 100644 --- a/osu.Game.Rulesets.Hishigata/Objects/HishigataNote.cs +++ b/osu.Game.Rulesets.Hishigata/Objects/HishigataNote.cs @@ -1,10 +1,3 @@ -using System; -using osu.Framework.Bindables; -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Judgements; -using osu.Game.Rulesets.Objects; - namespace osu.Game.Rulesets.Hishigata.Objects { public class HishigataNote : HishigataHitObject diff --git a/osu.Game.Rulesets.Hishigata/Replays/HishigataReplayFrame.cs b/osu.Game.Rulesets.Hishigata/Replays/HishigataReplayFrame.cs index fb8b692..3686da1 100644 --- a/osu.Game.Rulesets.Hishigata/Replays/HishigataReplayFrame.cs +++ b/osu.Game.Rulesets.Hishigata/Replays/HishigataReplayFrame.cs @@ -20,7 +20,7 @@ public HishigataReplayFrame(double time, params HishigataAction[] actions) Actions.AddRange(actions); } - public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null) + public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame? lastFrame = null) { if (currentFrame.MouseLeft1) Actions.Add(HishigataAction.Up); if (currentFrame.MouseLeft2) Actions.Add(HishigataAction.Right); diff --git a/osu.Game.Rulesets.Hishigata/UI/DrawableHishigataRuleset.cs b/osu.Game.Rulesets.Hishigata/UI/DrawableHishigataRuleset.cs index 117cb6d..6fb21f0 100644 --- a/osu.Game.Rulesets.Hishigata/UI/DrawableHishigataRuleset.cs +++ b/osu.Game.Rulesets.Hishigata/UI/DrawableHishigataRuleset.cs @@ -5,7 +5,6 @@ using osu.Game.Input.Handlers; using osu.Game.Replays; using osu.Game.Rulesets.Hishigata.Objects; -using osu.Game.Rulesets.Hishigata.Objects.Drawables; using osu.Game.Rulesets.Hishigata.Replays; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; @@ -17,7 +16,7 @@ namespace osu.Game.Rulesets.Hishigata.UI [Cached] public class DrawableHishigataRuleset : DrawableRuleset { - public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) + public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IReadOnlyList? mods = null) : base(ruleset, beatmap, mods) { } @@ -26,9 +25,9 @@ public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IRea protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new HishigataFramedReplayInputHandler(replay); - public override DrawableHitObject CreateDrawableRepresentation(HishigataHitObject h) => null; + public override DrawableHitObject CreateDrawableRepresentation(HishigataHitObject h) => null!; - protected override PassThroughInputManager CreateInputManager() => new HishigataInputManager(Ruleset?.RulesetInfo); + protected override PassThroughInputManager CreateInputManager() => new HishigataInputManager(Ruleset.RulesetInfo); protected override ReplayRecorder CreateReplayRecorder(Score score) => new HishigataReplayRecorder(score); } diff --git a/osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs b/osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs index 4e5dc86..7c3bf25 100644 --- a/osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs +++ b/osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs @@ -6,10 +6,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Hishigata.Objects; -using osu.Game.Rulesets.Hishigata.Objects.Drawables; using osu.Game.Rulesets.Hishigata.UI.Components; using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using osuTK; using osuTK.Graphics; @@ -19,16 +17,16 @@ namespace osu.Game.Rulesets.Hishigata.UI [Cached] public class HishigataPlayfield : Playfield { - private HishigataInputManager hishigataActionInputManager; - internal HishigataInputManager HishigataActionInputManager => hishigataActionInputManager ??= GetContainingInputManager() as HishigataInputManager; + private HishigataInputManager hishigataActionInputManager = null!; + internal HishigataInputManager HishigataActionInputManager => hishigataActionInputManager ??= (HishigataInputManager)GetContainingInputManager(); public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; private readonly List lanes = new List(); - private Container playfieldContainer; + private Container playfieldContainer = null!; [Cached] - private PlayerVisual playerObject; + private PlayerVisual playerObject = null!; public HishigataPlayfield() { @@ -75,18 +73,10 @@ public HishigataPlayfield() public override void Add(HitObject hitObject) { - var hishiObj = hitObject as HishigataHitObject; + var hishiObj = (HishigataHitObject)hitObject; lanes[hishiObj.Lane].Add(hitObject); } - public override void Add(DrawableHitObject hitObject) - { - var hishigataObject = hitObject as DrawableHishigataHitObject; - - hishigataObject.CanBeHit = playerObject.CanBeHit; - lanes[hishigataObject.HitObject.Lane].Add(hitObject); - } - private int? touchedLane; protected override void Update() @@ -97,8 +87,8 @@ protected override void Update() if (touchInput.ActiveSources.Any()) { - var focusedTouch = touchInput.GetTouchPosition(touchInput.ActiveSources.Last()); - var TouchAngle = ToScreenSpace(OriginPosition).GetDegreesFromPosition(focusedTouch.Value); + var focusedTouch = touchInput.GetTouchPosition(touchInput.ActiveSources.Last())!; + float TouchAngle = ToScreenSpace(OriginPosition).GetDegreesFromPosition(focusedTouch.Value); for (int i = 0; i < 4; ++i) { diff --git a/osu.Game.Rulesets.Hishigata/UI/Lane.cs b/osu.Game.Rulesets.Hishigata/UI/Lane.cs index 8ef129d..f44799b 100644 --- a/osu.Game.Rulesets.Hishigata/UI/Lane.cs +++ b/osu.Game.Rulesets.Hishigata/UI/Lane.cs @@ -15,9 +15,9 @@ namespace osu.Game.Rulesets.Hishigata.UI { public class Lane : Playfield { - private readonly Container hitExplosionContainer; + private readonly Container hitExplosionContainer = null!; - private readonly DrawablePool hitExplosionPool; + private readonly DrawablePool hitExplosionPool = null!; public Lane() { @@ -31,7 +31,7 @@ public Lane() NewResult += onNewResult; } - private Func checkHittable; + private Func checkHittable = null!; [BackgroundDependencyLoader] private void load(PlayerVisual playerobj) @@ -58,7 +58,7 @@ protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObje private void onNewResult(DrawableHitObject h, JudgementResult judgement) { if (judgement.IsHit) - hitExplosionContainer.Add(hitExplosionPool.Get(e => e.Apply(h as DrawableHishigataHitObject))); + hitExplosionContainer.Add(hitExplosionPool.Get().Apply((DrawableHishigataHitObject)h)); } protected override HitObjectLifetimeEntry CreateLifetimeEntry(HitObject hitObject) => new HishigataHitObjectLifetimeEntry(hitObject); diff --git a/osu.Game.Rulesets.Hishigata/UI/PoolableHitExplosion.cs b/osu.Game.Rulesets.Hishigata/UI/PoolableHitExplosion.cs index 6b465c0..7c6c12c 100644 --- a/osu.Game.Rulesets.Hishigata/UI/PoolableHitExplosion.cs +++ b/osu.Game.Rulesets.Hishigata/UI/PoolableHitExplosion.cs @@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Hishigata.UI { public class PoolableHitExplosion : PoolableDrawable { - private Box left; - private Box right; + private Box left = null!; + private Box right = null!; private double duration; @@ -41,10 +41,12 @@ private void load() }; } - public void Apply(DrawableHishigataHitObject h) + public PoolableHitExplosion Apply(DrawableHishigataHitObject h) { duration = h.HitObject.TimePreempt / 3; Colour = h.Colour; + + return this; } protected override void PrepareForUse()