// ReSharper disable InconsistentNaming internal static void Prefix(FlyingScoreEffect __instance, ref Vector3 targetPos) // ReSharper restore InconsistentNaming { if (ConfigProvider.CurrentConfig?.UseFixedPos ?? false) { var transform = __instance.transform; // Set current and target position to the desired fixed position transform.position = ConfigProvider.CurrentConfig.FixedPos; targetPos = transform.position; // If there's an existing judgment effect, clear that first if (_currentEffect != null) { // Remove it gracefully by setting its duration to 0 _currentEffect.SetField("_duration", 0f); // We don't need to clear currentEffect when it disappears, because we'll be setting it to the new effect anyway _currentEffect.didFinishEvent -= HandleEffectDidFinish; } // Save the existing effect to clear if a new one spawns _currentEffect = __instance; // In case it despawns before the next note is hit, don't try to clear it _currentEffect.didFinishEvent += HandleEffectDidFinish; } }
public static void Judge(FlyingScoreEffect scoreEffect, int score, int before, int after, int accuracy) { var instance = ConfigProvider.CurrentConfig; if (instance == null) { return; } // as of 0.13, the TextMeshPro is private; use reflection to grab it out of a private field var text = FlyingScoreEffectText(ref scoreEffect); // enable rich text text.richText = true; // disable word wrap, make sure full text displays text.enableWordWrapping = false; text.overflowMode = TextOverflowModes.Overflow; // save in case we need to fade var index = instance.Judgments !.FindIndex(j => j.Threshold <= score); var judgment = index >= 0 ? instance.Judgments[index] : Judgment.Default; Color color; if (judgment.Fade) { var fadeJudgment = instance.Judgments[index - 1]; var baseColor = judgment.Color.ToColor(); var fadeColor = fadeJudgment.Color.ToColor(); var lerpDistance = Mathf.InverseLerp(judgment.Threshold, fadeJudgment.Threshold, score); color = Color.Lerp(baseColor, fadeColor, lerpDistance); } else { color = judgment.Color.ToColor(); } FieldAccessor <FlyingScoreEffect, Color> .Set(scoreEffect, "_color", color); scoreEffect.SetField("_color", color); text.text = instance.DisplayMode switch { "format" => DisplayModeFormat(score, before, after, accuracy, judgment, instance), "textOnly" => judgment.Text, "numeric" => score.ToString(), "scoreOnTop" => $"{score}\n{judgment.Text}\n", _ => $"{judgment.Text}\n{score}\n" }; }