Initial commit

This commit is contained in:
mk-56 2022-01-15 21:43:28 +01:00
parent b2a83f0ab9
commit 2a59735525
5 changed files with 89 additions and 49 deletions

View File

@ -15,9 +15,10 @@ namespace osu.Game.Rulesets.Catch.Mods
{
public override double ScoreMultiplier => 1.12;
private const float default_flashlight_size = 350;
public override bool DefaultComboDependency => true;
public override float DefaultRadius => 350;
public override Flashlight CreateFlashlight() => new CatchFlashlight(playfield);
public override Flashlight CreateFlashlight() => new CatchFlashlight(playfield, ChangeRadius.Value, InitialRadius.Value);
private CatchPlayfield playfield;
@ -31,10 +32,10 @@ namespace osu.Game.Rulesets.Catch.Mods
{
private readonly CatchPlayfield playfield;
public CatchFlashlight(CatchPlayfield playfield)
public CatchFlashlight(CatchPlayfield playfield, bool isRadiusBasedOnCombo, float initialRadius) : base(isRadiusBasedOnCombo, initialRadius)
{
this.playfield = playfield;
FlashlightSize = new Vector2(0, getSizeFor(0));
FlashlightSize = new Vector2(0, GetRadiusFor(0));
}
protected override void Update()
@ -44,19 +45,9 @@ namespace osu.Game.Rulesets.Catch.Mods
FlashlightPosition = playfield.CatcherArea.ToSpaceOfOtherDrawable(playfield.Catcher.DrawPosition, this);
}
private float getSizeFor(int combo)
{
if (combo > 200)
return default_flashlight_size * 0.8f;
else if (combo > 100)
return default_flashlight_size * 0.9f;
else
return default_flashlight_size;
}
protected override void OnComboChange(ValueChangedEvent<int> e)
{
this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
this.TransformTo(nameof(FlashlightSize), new Vector2(0, GetRadiusFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
}
protected override string FragmentShader => "CircularFlashlight";

View File

@ -16,17 +16,19 @@ namespace osu.Game.Rulesets.Mania.Mods
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModHidden) };
private const float default_flashlight_size = 180;
public override bool DefaultComboDependency => false;
public override float DefaultRadius => 180;
public override Flashlight CreateFlashlight() => new ManiaFlashlight();
public override Flashlight CreateFlashlight() => new ManiaFlashlight(ChangeRadius.Value, InitialRadius.Value);
private class ManiaFlashlight : Flashlight
{
private readonly LayoutValue flashlightProperties = new LayoutValue(Invalidation.DrawSize);
public ManiaFlashlight()
public ManiaFlashlight(bool isRadiusBasedOnCombo, float initialRadius)
: base(isRadiusBasedOnCombo, initialRadius)
{
FlashlightSize = new Vector2(0, default_flashlight_size);
FlashlightSize = new Vector2(DrawWidth, GetRadiusFor(0));
AddLayout(flashlightProperties);
}
@ -46,9 +48,12 @@ namespace osu.Game.Rulesets.Mania.Mods
protected override void OnComboChange(ValueChangedEvent<int> e)
{
this.TransformTo(nameof(FlashlightSize), new Vector2(DrawWidth, GetRadiusFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
}
protected override string FragmentShader => "RectangularFlashlight";
}
}
}

View File

@ -12,7 +12,6 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osuTK;
namespace osu.Game.Rulesets.Osu.Mods
@ -21,13 +20,16 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override double ScoreMultiplier => 1.12;
private const float default_flashlight_size = 180;
public override bool DefaultComboDependency => true;
//private const float default_flashlight_size = 180;
public override float DefaultRadius => 180;
private const double default_follow_delay = 120;
private OsuFlashlight flashlight;
public override Flashlight CreateFlashlight() => flashlight = new OsuFlashlight();
public override Flashlight CreateFlashlight() => flashlight = new OsuFlashlight(ChangeRadius.Value, InitialRadius.Value, FollowDelay.Value);
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
{
@ -35,13 +37,6 @@ namespace osu.Game.Rulesets.Osu.Mods
s.Tracking.ValueChanged += flashlight.OnSliderTrackingChange;
}
public override void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
base.ApplyToDrawableRuleset(drawableRuleset);
flashlight.FollowDelay = FollowDelay.Value;
}
[SettingSource("Follow delay", "Milliseconds until the flashlight reaches the cursor")]
public BindableNumber<double> FollowDelay { get; } = new BindableDouble(default_follow_delay)
{
@ -54,9 +49,15 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public double FollowDelay { private get; set; }
public OsuFlashlight()
//public float InitialRadius { private get; set; }
public bool ChangeRadius { private get; set; }
public OsuFlashlight(bool isRadiusBasedOnCombo, float initialRadius, double followDelay)
: base(isRadiusBasedOnCombo, initialRadius)
{
FlashlightSize = new Vector2(0, getSizeFor(0));
FollowDelay = followDelay;
FlashlightSize = new Vector2(0, GetRadiusFor(0));
}
public void OnSliderTrackingChange(ValueChangedEvent<bool> e)
@ -78,17 +79,20 @@ namespace osu.Game.Rulesets.Osu.Mods
private float getSizeFor(int combo)
{
if (combo > 200)
return default_flashlight_size * 0.8f;
else if (combo > 100)
return default_flashlight_size * 0.9f;
else
return default_flashlight_size;
if (ChangeRadius)
{
if (combo > 200)
return InitialRadius * 0.8f;
else if (combo > 100)
return InitialRadius * 0.9f;
}
return InitialRadius;
}
protected override void OnComboChange(ValueChangedEvent<int> e)
{
this.TransformTo(nameof(FlashlightSize), new Vector2(0, getSizeFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
this.TransformTo(nameof(FlashlightSize), new Vector2(0, GetRadiusFor(e.NewValue)), FLASHLIGHT_FADE_DURATION);
}
protected override string FragmentShader => "CircularFlashlight";

View File

@ -16,9 +16,12 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
public override double ScoreMultiplier => 1.12;
private const float default_flashlight_size = 250;
public override bool DefaultComboDependency => true;
public override Flashlight CreateFlashlight() => new TaikoFlashlight(playfield);
//private const float default_flashlight_size = 250;
public override float DefaultRadius => 250;
public override Flashlight CreateFlashlight() => new TaikoFlashlight(playfield, ChangeRadius.Value, InitialRadius.Value);
private TaikoPlayfield playfield;
@ -33,7 +36,8 @@ namespace osu.Game.Rulesets.Taiko.Mods
private readonly LayoutValue flashlightProperties = new LayoutValue(Invalidation.DrawSize);
private readonly TaikoPlayfield taikoPlayfield;
public TaikoFlashlight(TaikoPlayfield taikoPlayfield)
public TaikoFlashlight(TaikoPlayfield taikoPlayfield, bool isRadiusBasedOnCombo, float initialRadius)
: base(isRadiusBasedOnCombo, initialRadius)
{
this.taikoPlayfield = taikoPlayfield;
FlashlightSize = getSizeFor(0);
@ -43,15 +47,9 @@ namespace osu.Game.Rulesets.Taiko.Mods
private Vector2 getSizeFor(int combo)
{
float size = default_flashlight_size;
if (combo > 200)
size *= 0.8f;
else if (combo > 100)
size *= 0.9f;
// Preserve flashlight size through the playfield's aspect adjustment.
return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT);
// return new Vector2(0, size * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT);
return new Vector2(0, GetRadiusFor(combo) * taikoPlayfield.DrawHeight / TaikoPlayfield.DEFAULT_HEIGHT);
}
protected override void OnComboChange(ValueChangedEvent<int> e)

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.Timing;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.OpenGL.Vertices;
using osu.Game.Rulesets.Objects;
@ -32,8 +33,26 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Restricted view area.";
[SettingSource("Change radius based on combo", "Decrease the flashlight radius as combo increases.")]
public Bindable<bool> ChangeRadius { get; private set; }
[SettingSource("Initial radius", "Initial radius of the flashlight area.")]
public BindableNumber<float> InitialRadius { get; private set; }
public abstract float DefaultRadius { get; }
public abstract bool DefaultComboDependency { get; }
internal ModFlashlight()
{
InitialRadius = new BindableFloat
{
MinValue = 90f,
MaxValue = 250f,
Precision = 5f,
};
ChangeRadius = new BindableBool(DefaultComboDependency);
}
}
@ -93,6 +112,16 @@ namespace osu.Game.Rulesets.Mods
public List<BreakPeriod> Breaks;
public readonly bool IsRadiusBasedOnCombo;
public readonly float InitialRadius;
protected Flashlight(bool isRadiusBasedOnCombo, float initialRadius)
{
IsRadiusBasedOnCombo = isRadiusBasedOnCombo;
InitialRadius = initialRadius;
}
[BackgroundDependencyLoader]
private void load(ShaderManager shaderManager)
{
@ -124,6 +153,19 @@ namespace osu.Game.Rulesets.Mods
protected abstract string FragmentShader { get; }
protected float GetRadiusFor(int combo)
{
if (IsRadiusBasedOnCombo)
{
if (combo > 200)
return InitialRadius * 0.8f;
else if (combo > 100)
return InitialRadius * 0.9f;
}
return InitialRadius;
}
private Vector2 flashlightPosition;
protected Vector2 FlashlightPosition