Skip to content

Commit

Permalink
Merge pull request #100 from LumpBloom7/AddSlideDelay
Browse files Browse the repository at this point in the history
Add Delay to slide animation
  • Loading branch information
LumpBloom7 authored Aug 6, 2020
2 parents 4501d01 + 9aa4d98 commit 15f9b74
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" />
Expand Down
53 changes: 4 additions & 49 deletions osu.Game.Rulesets.Sentakki/Beatmaps/SentakkiBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -16,8 +15,6 @@ public enum ConversionExperiments
none = 0,
twins = 1,
touch = 2,
patternv2 = 4,
slide = 8
}

public class SentakkiBeatmapConverter : BeatmapConverter<SentakkiHitObject>
Expand All @@ -30,62 +27,20 @@ public class SentakkiBeatmapConverter : BeatmapConverter<SentakkiHitObject>

private SentakkiPatternGenerator patternGen;

private readonly Random random;
private readonly Random random2;

public SentakkiBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
: base(beatmap, ruleset)
{
patternGen = new SentakkiPatternGenerator(beatmap);
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
int seed = ((int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20) + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate);
random = new Random(seed);
random2 = new Random(seed);
patternGen.Experiments.BindTo(EnabledExperiments);
}

protected override IEnumerable<SentakkiHitObject> ConvertHitObject(HitObject original, IBeatmap beatmap)
{
Vector2 CENTRE_POINT = new Vector2(256, 192);
Vector2 newPos = (original as IHasPosition)?.Position ?? Vector2.Zero;
newPos.Y = 384 - newPos.Y;

int lane = CENTRE_POINT.GetDegreesFromPosition(newPos).GetNoteLaneFromDegrees();
List<SentakkiHitObject> objects = new List<SentakkiHitObject>();

if (EnabledExperiments.Value.HasFlag(ConversionExperiments.patternv2))
{
if ((original as IHasCombo).NewCombo)
patternGen.CreateNewPattern();

foreach (var note in patternGen.GenerateNewNote(original).ToList())
yield return note;
}
else
{
switch (original)
{
case IHasPathWithRepeats _:
objects.AddRange(Conversions.CreateHoldNote(original, lane, beatmap, random, EnabledExperiments.Value));
break;

case IHasDuration _:
objects.Add(Conversions.CreateTouchHold(original));
break;

default:
if (EnabledExperiments.Value.HasFlag(ConversionExperiments.touch) && (random2.Next() % 10 == 0))
objects.AddRange(Conversions.CreateTouchNote(original, lane, random, EnabledExperiments.Value));
else
objects.AddRange(Conversions.CreateTapNote(original, lane, random, EnabledExperiments.Value));
break;
}

foreach (var hitObject in objects)
yield return hitObject;
if ((original as IHasCombo).NewCombo)
patternGen.CreateNewPattern();

yield break;
}
foreach (var note in patternGen.GenerateNewNote(original).ToList())
yield return note;
}

protected override Beatmap<SentakkiHitObject> CreateBeatmap() => new SentakkiBeatmap();
Expand Down
171 changes: 0 additions & 171 deletions osu.Game.Rulesets.Sentakki/Beatmaps/SentakkiNoteConversions.cs

This file was deleted.

11 changes: 9 additions & 2 deletions osu.Game.Rulesets.Sentakki/Beatmaps/SentakkiPatternGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public IEnumerable<SentakkiHitObject> GenerateNewNote(HitObject original)
{
case IHasPathWithRepeats hold:
breakNote = hold.NodeSamples.Any(samples => samples.Any(s => s.Name == HitSampleInfo.HIT_FINISH));
if (Experiments.Value.HasFlag(ConversionExperiments.slide) && hold.NodeSamples.Any(samples => samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE)) && hold.Duration > 400)
if (hold.NodeSamples.Any(samples => samples.Any(s => s.Name == HitSampleInfo.HIT_WHISTLE)) && hold.Duration >= 500)
{
notes.Add(createSlideNote(original, isBreak: breakNote));
}
Expand All @@ -94,7 +94,7 @@ public IEnumerable<SentakkiHitObject> GenerateNewNote(HitObject original)
break;

case IHasDuration _:
yield return Conversions.CreateTouchHold(original);
yield return CreateTouchHold(original);
break;

default:
Expand Down Expand Up @@ -125,6 +125,13 @@ public IEnumerable<SentakkiHitObject> GenerateNewNote(HitObject original)
}

// Individual note generation code, because it's cleaner
public static SentakkiHitObject CreateTouchHold(HitObject original) => new TouchHold
{
StartTime = original.StartTime,
EndTime = (original as IHasDuration).EndTime,
Samples = original.Samples,
};

private SentakkiHitObject createSlideNote(HitObject original, bool twin = false, bool isBreak = false)
{
int noteLane = getNewLane(twin);
Expand Down
22 changes: 1 addition & 21 deletions osu.Game.Rulesets.Sentakki/Mods/SentakkiModExperimental.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,14 @@ public class SentakkiModExperimental : Mod, IApplicableToBeatmapConverter
Default = false,
Value = true,
};

[SettingSource("Use pattern generator for osu converts", "Use a pattern generator to generate convert beatmaps")]
public BindableBool EnablePatternGen { get; } = new BindableBool
{
Default = false,
Value = true
};

[SettingSource("Enable Slide notes", "Allow SLIDEs to appear")]
public BindableBool EnableSlides { get; } = new BindableBool
{
Default = false,
Value = false
};


public void ApplyToBeatmapConverter(IBeatmapConverter beatmapConverter)
{
if (EnableTwins.Value)
(beatmapConverter as SentakkiBeatmapConverter).EnabledExperiments.Value |= ConversionExperiments.twins;

if (EnableTouch.Value)
(beatmapConverter as SentakkiBeatmapConverter).EnabledExperiments.Value |= ConversionExperiments.touch;

if (EnablePatternGen.Value)
(beatmapConverter as SentakkiBeatmapConverter).EnabledExperiments.Value |= ConversionExperiments.patternv2;

if (EnableSlides.Value)
(beatmapConverter as SentakkiBeatmapConverter).EnabledExperiments.Value |= ConversionExperiments.slide;
}
}
}
22 changes: 22 additions & 0 deletions osu.Game.Rulesets.Sentakki/Mods/SentakkiModRelax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void ApplyToPlayer(Player player)
sentakkiInputManager.AllowUserPresses = false;
}

private bool holdingSlide = false;
public void Update(Playfield playfield)
{
if (hasReplay)
Expand All @@ -69,6 +70,27 @@ public void Update(Playfield playfield)

switch (h)
{
case DrawableSlide slide:
foreach (var nested in slide.NestedHitObjects.Where(obj => obj.IsAlive && !h.IsHit && time >= h.HitObject.StartTime - relax_leniency))
{
switch (nested)
{
case DrawableSlideTap slideTap:
if (time < slideTap.HitObject.StartTime - relax_leniency)
break;
holdingSlide = true;
break;
case DrawableSlideNode slideNode:
if (time < slide.HitObject.StartTime)
break;
if (slideNode.IsHovered)
holdingSlide = true;
break;
}
}
requiresHold = holdingSlide;
break;

case DrawableTap tap:
if (tap.HitArea.IsHovered)
{
Expand Down
Loading

0 comments on commit 15f9b74

Please sign in to comment.