1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-24 08:42:55 +08:00
osu-lazer/osu.Game/Screens/Play/KiaiGameplayFountains.cs
Dean Herbert 8e25c94452
Fix kiai fountains sometimes not displaying when they should
The previous logic was very wrong, as the check would only occur on each
beat. But that's not how kiai sections work – they can be placed at any
timestamp, even if that doesn't align with a beat.

In addition, the rate limiting has been removed because it didn't exist
on stable and causes some fountains to be missed. Overlap scenarios are
already handled internally by the `StarFountain` class.

Closes https://github.com/ppy/osu/issues/31855.
2025-02-18 14:12:16 +09:00

97 lines
2.9 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Menu;
namespace osu.Game.Screens.Play
{
public partial class KiaiGameplayFountains : BeatSyncedContainer
{
private StarFountain leftFountain = null!;
private StarFountain rightFountain = null!;
private Bindable<bool> kiaiStarFountains = null!;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
kiaiStarFountains = config.GetBindable<bool>(OsuSetting.StarFountains);
RelativeSizeAxes = Axes.Both;
Children = new[]
{
leftFountain = new GameplayStarFountain
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
X = 75,
},
rightFountain = new GameplayStarFountain
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
X = -75,
},
};
}
private bool isTriggered;
protected override void Update()
{
base.Update();
if (!kiaiStarFountains.Value)
return;
if (EffectPoint.KiaiMode && !isTriggered)
{
Logger.Log("shooting");
bool isNearEffectPoint = Math.Abs(BeatSyncSource.Clock.CurrentTime - EffectPoint.Time) < 500;
if (isNearEffectPoint)
Shoot();
}
isTriggered = EffectPoint.KiaiMode;
}
public void Shoot()
{
leftFountain.Shoot(1);
rightFountain.Shoot(-1);
}
public partial class GameplayStarFountain : StarFountain
{
protected override StarFountainSpewer CreateSpewer() => new GameplayStarFountainSpewer();
private partial class GameplayStarFountainSpewer : StarFountainSpewer
{
protected override double ShootDuration => 400;
public GameplayStarFountainSpewer()
: base(perSecond: 180)
{
}
protected override float GetCurrentAngle()
{
const float x_velocity_from_direction = 450;
const float x_velocity_to_direction = 600;
return LastShootDirection * RNG.NextSingle(x_velocity_from_direction, x_velocity_to_direction);
}
}
}
}
}