Skip to content

Commit

Permalink
Fix bugs and perfect range
Browse files Browse the repository at this point in the history
  • Loading branch information
Azn9 committed Feb 19, 2023
1 parent 76ab3bd commit 75e6d37
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
30 changes: 15 additions & 15 deletions AccuracyIndicator/Indicator/InGameIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ private void Start()
_canvas.AddComponent<GraphicRaycaster>();
_canvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;

// -0.14 | -0.04 | -0.025 | 0.025 | 0.04 | 0.14
// -0.14 | -0.05 | -0.025 | 0.025 | 0.05 | 0.14
// Total length: 0.28 = 730px
// Ok : 0.08 = 208px
// Ok : 0.1 = 260px
// Perfect : 0.05 = 130px

Utils.CreateBars(_canvas, 0, DefaultY, 730, 208, 130);
Utils.CreateBars(_canvas, 0, DefaultY, 730, 260, 130);

var arrow = new GameObject("Arrow");
arrow.transform.SetParent(_canvas.transform);
Expand Down Expand Up @@ -76,7 +76,7 @@ public void AddHit(float time)
var color = time switch
{
< 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F),
< 0.04f and > -0.04f => new Color(0.29F, 0.68F, 0.31F),
< 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F),
_ => new Color(1f, 0.59F, 0)
};

Expand All @@ -90,19 +90,19 @@ public void AddHit(float time)

_hitEntries.Add(new HitEntry(Time.time, time, hitIndicator, hitRi));

if (time is >= -0.14f and <= 0.14f)
{
// -140 = 0
// -135 = 1
// ...
if (time is < -0.14f or > 0.14f)
return;

// -140 = 0
// -135 = 1
// ...

// time * 1000 is >= -140 and <= 140
// (time * 1000) / 5 is >= -28 and <= 28
// (time * 1000) / 5 + 28 is >= 0 and <= 56
// time * 1000 is >= -140 and <= 140
// (time * 1000) / 5 is >= -28 and <= 28
// (time * 1000) / 5 + 28 is >= 0 and <= 56

var timeRange = (int)(time * 1000) / 5 + 28;
_hitReport[timeRange].Cast<ReportRange>().Amount++;
}
var timeRange = (int)(time * 1000) / 5 + 28;
_hitReport[timeRange].Cast<ReportRange>().Amount++;
}

private void Update()
Expand Down
2 changes: 1 addition & 1 deletion AccuracyIndicator/Indicator/VictoryIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void Render()
ri.color = time switch
{
< 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F),
< 0.04f and > -0.04f => new Color(0.29F, 0.68F, 0.31F),
< 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F),
_ => new Color(1f, 0.59F, 0)
};

Expand Down
7 changes: 6 additions & 1 deletion AccuracyIndicator/Patch/SceneChangePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public static void OnSceneWasUnloaded(string sceneName)
{
case "GameMain":
if (Main.IndicatorObj != null)
{
Object.Destroy(Main.IndicatorObj);
Main.IndicatorObj = null;
}

break;
}
}
Expand All @@ -39,7 +43,7 @@ private static void Postfix()
var report = Main.InGameIndicator.GetReport();

Object.Destroy(Main.InGameIndicator);

var victoryIndicator = Main.IndicatorObj.AddComponent<VictoryIndicator>();

victoryIndicator.SetMeanDelay(meanDelay);
Expand All @@ -54,6 +58,7 @@ internal static class FailPatch
private static void Postfix()
{
Object.Destroy(Main.IndicatorObj);
Main.IndicatorObj = null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions AccuracyIndicator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

[assembly: MelonInfo(typeof(Main), "Accuracy Indicator", "1.0.0", "Azn9", "https://github.com/Azn9/MDAccuracyIndicatorMod")]
[assembly: MelonInfo(typeof(Main), "Accuracy Indicator", "1.1.0", "Azn9", "https://github.com/Azn9/MDAccuracyIndicatorMod")]
[assembly: MelonGame("PeroPeroGames", "MuseDash")]

0 comments on commit 75e6d37

Please sign in to comment.