-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from LumpBloom7/Converter-update
Update new converter to support twins
- Loading branch information
Showing
6 changed files
with
241 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
osu.Game.Rulesets.Sentakki/Beatmaps/Converter/TwinFlags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace osu.Game.Rulesets.Sentakki.Beatmaps.Converter; | ||
|
||
[Flags] | ||
public enum TwinFlags | ||
{ | ||
None = 0, | ||
Mirror = 1 << 1, // The lane is horizontally mirrored from the main note | ||
Cycle = 1 << 2, // Cycles between 1 or more different lanes, prechosen | ||
SpinCW = 1 << 3, // Increments lane by 1 clockwise | ||
SpinCCW = 1 << 4, // Decrements lane by 1 counterclockwise | ||
Copy = 1 << 5, // Simply copies the main note, but with an offset | ||
} |
97 changes: 97 additions & 0 deletions
97
osu.Game.Rulesets.Sentakki/Beatmaps/Converter/TwinPattern.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Markdig.Extensions.Yaml; | ||
using osu.Framework.Extensions.EnumExtensions; | ||
using osu.Game.Rulesets.Objects; | ||
using osu.Game.Rulesets.Sentakki.Objects; | ||
using osu.Game.Beatmaps; | ||
|
||
namespace osu.Game.Rulesets.Sentakki.Beatmaps.Converter; | ||
|
||
public class TwinPattern | ||
{ | ||
private static readonly TwinFlags[] allowedFlags = new TwinFlags[]{ | ||
TwinFlags.None, | ||
TwinFlags.SpinCW, | ||
TwinFlags.SpinCCW, | ||
TwinFlags.Cycle, | ||
TwinFlags.Copy, | ||
TwinFlags.Mirror, | ||
TwinFlags.Copy | TwinFlags.Mirror | ||
}; | ||
|
||
private TwinFlags flags; | ||
|
||
private List<int> cycleLanes = new List<int>(); | ||
private int cycleIndex = 0; | ||
|
||
private int originLane = 0; | ||
|
||
private int spinIncrement = 0; | ||
|
||
private int copyOffset = 1; | ||
|
||
private Random rng; | ||
|
||
public TwinPattern(Random rng) | ||
{ | ||
this.rng = rng; | ||
|
||
NewPattern(); | ||
} | ||
|
||
public void NewPattern() | ||
{ | ||
flags = allowedFlags[rng.Next(0, allowedFlags.Length)]; | ||
originLane = rng.Next(0, 8); | ||
|
||
if (flags.HasFlagFast(TwinFlags.Cycle)) | ||
{ | ||
cycleLanes.Clear(); | ||
cycleLanes.Add(rng.Next(0, 8)); | ||
cycleIndex = 0; | ||
|
||
float prob = 0.75f; | ||
|
||
while (true) | ||
{ | ||
if (rng.NextSingle() > prob) | ||
break; | ||
|
||
cycleLanes.Add(rng.Next(0, 8)); | ||
prob *= 0.5f; | ||
} | ||
} | ||
else if (flags.HasFlagFast(TwinFlags.Copy)) | ||
{ | ||
copyOffset = rng.Next(1, 7); | ||
} | ||
} | ||
|
||
public int getNextLane(int currentLane) | ||
{ | ||
if (flags.HasFlagFast(TwinFlags.Cycle)) | ||
{ | ||
int tmp = originLane + cycleLanes[cycleIndex]; | ||
cycleIndex = (cycleIndex + 1) % cycleLanes.Count; | ||
|
||
return tmp; | ||
} | ||
|
||
if (flags.HasFlagFast(TwinFlags.SpinCW)) | ||
return originLane + (++spinIncrement); | ||
|
||
if (flags.HasFlagFast(TwinFlags.SpinCCW)) | ||
return originLane + (--spinIncrement); | ||
|
||
|
||
int result = currentLane; | ||
if (flags.HasFlagFast(TwinFlags.Copy)) | ||
result += copyOffset; | ||
|
||
if (flags.HasFlagFast(TwinFlags.Mirror)) | ||
result = 7 - result; | ||
|
||
return result.NormalizePath(); | ||
} | ||
} |
Oops, something went wrong.