Skip to content

Commit

Permalink
Merge pull request #169 from LumpBloom7/nullable-enable
Browse files Browse the repository at this point in the history
Enable NRT
  • Loading branch information
LumpBloom7 authored Oct 21, 2022
2 parents c681df7 + b64585e commit 56806fb
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 78 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Nullable>enable</Nullable>

<Authors>Derrick Timmermans</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override IEnumerable<HishigataHitObject> 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);

Expand Down Expand Up @@ -78,7 +78,7 @@ protected override IEnumerable<HishigataHitObject> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Hishigata/HishigataRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HishigataRuleset : Ruleset

public override ScoreProcessor CreateScoreProcessor() => new HishigataScoreProcessor(this);

public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableHishigataRuleset(this, beatmap, mods);
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod>? mods = null) => new DrawableHishigataRuleset(this, beatmap, mods);

public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new HishigataBeatmapConverter(beatmap, this);

Expand Down
20 changes: 10 additions & 10 deletions osu.Game.Rulesets.Hishigata/LinearMath/LineSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Rulesets.Hishigata/Mods/HishigataModHardRock.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,14 +12,14 @@ namespace osu.Game.Rulesets.Hishigata.Objects.Drawables
public class DrawableHishigataHitObject : DrawableHitObject<HishigataHitObject>
{
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!)
{
}

Expand All @@ -42,7 +37,7 @@ private void load(TextureStore textures)
});
}

public Func<DrawableHishigataHitObject, bool> CanBeHit;
public Func<DrawableHishigataHitObject, bool>? CanBeHit;

protected override void CheckForResult(bool userTriggered, double timeOffset)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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!)
{
}

Expand Down
2 changes: 0 additions & 2 deletions osu.Game.Rulesets.Hishigata/Objects/HishigataBonus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public HishigataBonus()

public override Judgement CreateJudgement() => new HishigataBonusJudgement();

#nullable enable
private class BonusHitSampleInfo : HitSampleInfo, IEquatable<BonusHitSampleInfo>
{
private const string lookup_name = "Gameplay/catch-banana";
Expand Down Expand Up @@ -47,6 +46,5 @@ public override bool Equals(object? obj)

public override int GetHashCode() => lookup_name.GetHashCode();
}
//#nullable restore
}
}
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Hishigata/Objects/HishigataHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class HishigataHitObject : HitObject
public double TimePreempt;

public BindableInt LaneBindable = new BindableInt();

public int Lane
{
get => LaneBindable.Value;
Expand Down
7 changes: 0 additions & 7 deletions osu.Game.Rulesets.Hishigata/Objects/HishigataNote.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions osu.Game.Rulesets.Hishigata/UI/DrawableHishigataRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +16,7 @@ namespace osu.Game.Rulesets.Hishigata.UI
[Cached]
public class DrawableHishigataRuleset : DrawableRuleset<HishigataHitObject>
{
public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
: base(ruleset, beatmap, mods)
{
}
Expand All @@ -26,9 +25,9 @@ public DrawableHishigataRuleset(HishigataRuleset ruleset, IBeatmap beatmap, IRea

protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new HishigataFramedReplayInputHandler(replay);

public override DrawableHitObject<HishigataHitObject> CreateDrawableRepresentation(HishigataHitObject h) => null;
public override DrawableHitObject<HishigataHitObject> 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);
}
Expand Down
24 changes: 7 additions & 17 deletions osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Lane> lanes = new List<Lane>();
private Container playfieldContainer;
private Container playfieldContainer = null!;

[Cached]
private PlayerVisual playerObject;
private PlayerVisual playerObject = null!;

public HishigataPlayfield()
{
Expand Down Expand Up @@ -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()
Expand All @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions osu.Game.Rulesets.Hishigata/UI/Lane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PoolableHitExplosion> hitExplosionPool;
private readonly DrawablePool<PoolableHitExplosion> hitExplosionPool = null!;

public Lane()
{
Expand All @@ -31,7 +31,7 @@ public Lane()
NewResult += onNewResult;
}

private Func<DrawableHishigataHitObject, bool> checkHittable;
private Func<DrawableHishigataHitObject, bool> checkHittable = null!;

[BackgroundDependencyLoader]
private void load(PlayerVisual playerobj)
Expand All @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions osu.Game.Rulesets.Hishigata/UI/PoolableHitExplosion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 56806fb

Please sign in to comment.