2022-09-19 03:08:34 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-09-19 03:10:01 +08:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics;
|
2022-09-19 13:06:07 +08:00
|
|
|
|
using osuTK;
|
2022-09-19 03:10:01 +08:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
2022-09-19 03:08:34 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|
|
|
|
{
|
|
|
|
|
public class DefaultSmoke : Smoke
|
|
|
|
|
{
|
2022-09-19 03:10:01 +08:00
|
|
|
|
private const double fade_out_delay = 8000;
|
|
|
|
|
private const double fade_out_speed = 3;
|
|
|
|
|
private const double fade_out_duration = 50;
|
|
|
|
|
private const float alpha = 0.5f;
|
|
|
|
|
|
|
|
|
|
protected override double LifetimeAfterSmokeEnd => fade_out_delay + fade_out_duration + (SmokeEndTime - SmokeStartTime) / fade_out_speed;
|
|
|
|
|
|
2022-09-19 03:08:34 +08:00
|
|
|
|
public DefaultSmoke()
|
|
|
|
|
{
|
2022-09-19 03:10:01 +08:00
|
|
|
|
Radius = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DrawNode CreateDrawNode() => new DefaultSmokeDrawNode(this);
|
|
|
|
|
|
|
|
|
|
private class DefaultSmokeDrawNode : SmokeDrawNode
|
|
|
|
|
{
|
|
|
|
|
private double fadeOutTime;
|
|
|
|
|
|
|
|
|
|
public DefaultSmokeDrawNode(ITexturedShaderDrawable source)
|
|
|
|
|
: base(source)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 19:54:49 +08:00
|
|
|
|
public override void ApplyState()
|
2022-09-19 03:10:01 +08:00
|
|
|
|
{
|
2022-09-20 19:54:49 +08:00
|
|
|
|
base.ApplyState();
|
2022-09-19 03:10:01 +08:00
|
|
|
|
|
|
|
|
|
fadeOutTime = SmokeStartTime + fade_out_speed * (CurrentTime - (SmokeEndTime + fade_out_delay));
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 19:39:12 +08:00
|
|
|
|
protected override Color4 PointColour(SmokePoint point)
|
2022-09-19 03:10:01 +08:00
|
|
|
|
{
|
|
|
|
|
var color = Color4.White;
|
|
|
|
|
color.A = alpha;
|
|
|
|
|
|
2022-09-19 13:06:07 +08:00
|
|
|
|
double timeDoingFadeOut = fadeOutTime - point.Time;
|
2022-09-19 09:32:33 +08:00
|
|
|
|
|
2022-09-19 03:10:01 +08:00
|
|
|
|
if (timeDoingFadeOut > 0)
|
|
|
|
|
{
|
|
|
|
|
float fraction = Math.Clamp((float)(1 - (timeDoingFadeOut / fade_out_duration)), 0, 1);
|
|
|
|
|
fraction = MathF.Pow(fraction, 5);
|
|
|
|
|
color.A *= fraction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return color;
|
|
|
|
|
}
|
2022-09-19 13:06:07 +08:00
|
|
|
|
|
2022-09-19 13:14:54 +08:00
|
|
|
|
protected override float PointScale(SmokePoint point) => 1f;
|
2022-09-19 13:06:07 +08:00
|
|
|
|
|
2022-09-19 13:14:54 +08:00
|
|
|
|
protected override Vector2 PointDirection(SmokePoint point) => point.Direction;
|
2022-09-19 03:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|