mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 11:27:29 +08:00
Accuracy info and other features (#84)
* tweaks slide fade in * judge accuracy info * Update SlideArrowAnimation.cs
This commit is contained in:
125
AquaMai/Visual/SlideFadeInTweak.cs
Normal file
125
AquaMai/Visual/SlideFadeInTweak.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using MAI2.Util;
|
||||
using Manager;
|
||||
using Monitor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AquaMai.Visual;
|
||||
|
||||
public class SlideFadeInTweak
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(SlideRoot), "UpdateAlpha")]
|
||||
private static bool UpdateAlphaOverwrite(
|
||||
SlideRoot __instance,
|
||||
ref bool ___UpdateAlphaFlag,
|
||||
float ___StartMsec, float ___AppearMsec, float ___StarLaunchMsec, float ___DefaultMsec,
|
||||
int ____dispLaneNum, bool ___BreakFlag,
|
||||
List<SpriteRenderer> ____spriteRenders, List<BreakSlide> ____breakSpriteRenders
|
||||
)
|
||||
{
|
||||
if (!___UpdateAlphaFlag)
|
||||
return false;
|
||||
|
||||
var currentMsec = NotesManager.GetCurrentMsec();
|
||||
var slideSpeed = (int) Singleton<GamePlayManager>.Instance.GetGameScore(__instance.MonitorId).UserOption.SlideSpeed;
|
||||
var defaultFadeInLength = (21 - slideSpeed) / 10.5f * ___DefaultMsec;
|
||||
var fadeInFirstMsec = Math.Max(___StartMsec, ___AppearMsec - defaultFadeInLength);
|
||||
var fadeInSecondMsec = Math.Max(___AppearMsec, ___StarLaunchMsec - defaultFadeInLength);
|
||||
// var fadeInSecondMsec = ___AppearMsec;
|
||||
var color = new Color(1f, 1f, 1f, 1f);
|
||||
|
||||
if (currentMsec >= ___StarLaunchMsec)
|
||||
{
|
||||
___UpdateAlphaFlag = false;
|
||||
}
|
||||
else if (currentMsec < fadeInFirstMsec)
|
||||
{
|
||||
color.a = 0.0f;
|
||||
}
|
||||
else if (fadeInFirstMsec <= currentMsec && currentMsec < ___AppearMsec)
|
||||
{
|
||||
var fadeInLength = Math.Min(200.0f, ___AppearMsec - fadeInFirstMsec);
|
||||
color.a = 0.5f * Math.Min(1f, (currentMsec - fadeInFirstMsec) / fadeInLength);
|
||||
}
|
||||
else if (___AppearMsec <= currentMsec && currentMsec < fadeInSecondMsec)
|
||||
{
|
||||
color.a = 0.5f;
|
||||
}
|
||||
else if (fadeInSecondMsec <= currentMsec && currentMsec < ___StarLaunchMsec)
|
||||
{
|
||||
var fadeInLength = Math.Min(200.0f, ___StarLaunchMsec - fadeInSecondMsec);
|
||||
// var fadeInLength = ___StarLaunchMsec - fadeInSecondMsec;
|
||||
color.a = 0.5f + 0.5f * Math.Min(1f, (currentMsec - fadeInSecondMsec) / fadeInLength);
|
||||
}
|
||||
|
||||
if (!___BreakFlag)
|
||||
{
|
||||
for (var index = 0; index < ____dispLaneNum; ++index)
|
||||
{
|
||||
if (index >= ____spriteRenders.Count) break;
|
||||
____spriteRenders[index].color = color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var index = 0; index < ____dispLaneNum; ++index)
|
||||
{
|
||||
if (index >= ____breakSpriteRenders.Count) break;
|
||||
____breakSpriteRenders[index].SpriteRender.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(SlideFan), "UpdateAlpha")]
|
||||
private static bool UpdateFanAlphaOverwrite(
|
||||
SlideRoot __instance,
|
||||
float ___StartMsec, float ___AppearMsec, float ___StarLaunchMsec, float ___DefaultMsec,
|
||||
Color ____defaultColor, SpriteRenderer[] ____spriteLines
|
||||
)
|
||||
{
|
||||
var currentMsec = NotesManager.GetCurrentMsec();
|
||||
|
||||
var slideSpeed = (int) Singleton<GamePlayManager>.Instance.GetGameScore(__instance.MonitorId).UserOption.SlideSpeed;
|
||||
var defaultFadeInLength = (21 - slideSpeed) / 10.5f * ___DefaultMsec;
|
||||
var fadeInFirstMsec = Math.Max(___StartMsec, ___AppearMsec - defaultFadeInLength);
|
||||
var fadeInSecondMsec = Math.Max(___AppearMsec, ___StarLaunchMsec - defaultFadeInLength);
|
||||
// var fadeInSecondMsec = ___AppearMsec;
|
||||
var color = ____defaultColor;
|
||||
|
||||
if (currentMsec < fadeInFirstMsec)
|
||||
{
|
||||
color.a = 0.0f;
|
||||
}
|
||||
else if (fadeInFirstMsec <= currentMsec && currentMsec < ___AppearMsec)
|
||||
{
|
||||
var fadeInLength = Math.Min(200.0f, ___AppearMsec - fadeInFirstMsec);
|
||||
color.a = 0.3f * Math.Min(1f, (currentMsec - fadeInFirstMsec) / fadeInLength);
|
||||
}
|
||||
else if (___AppearMsec <= currentMsec && currentMsec < fadeInSecondMsec)
|
||||
{
|
||||
color.a = 0.3f;
|
||||
}
|
||||
else if (fadeInSecondMsec <= currentMsec && currentMsec < ___StarLaunchMsec)
|
||||
{
|
||||
var fadeInLength = Math.Min(200.0f, ___StarLaunchMsec - fadeInSecondMsec);
|
||||
// var fadeInLength = ___StarLaunchMsec - fadeInSecondMsec;
|
||||
color.a = 0.3f + 0.3f * Math.Min(1f, (currentMsec - fadeInSecondMsec) / fadeInLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
color.a = 0.6f;
|
||||
}
|
||||
|
||||
foreach (SpriteRenderer spriteLine in ____spriteLines)
|
||||
spriteLine.color = color;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user