Use class with other osu! mods

This commit is contained in:
smoogipoo 2020-11-05 15:52:06 +09:00
parent 628b8be15d
commit 77a618dd71
3 changed files with 19 additions and 64 deletions

View File

@ -2,11 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
@ -17,7 +14,7 @@ namespace osu.Game.Rulesets.Osu.Mods
/// <summary>
/// Adjusts the size of hit objects during their fade in animation.
/// </summary>
public abstract class OsuModObjectScaleTween : Mod, IReadFromConfig, IApplicableToDrawableHitObjects
public abstract class OsuModObjectScaleTween : ModWithVisibilityAdjustment
{
public override ModType Type => ModType.Fun;
@ -27,33 +24,19 @@ public abstract class OsuModObjectScaleTween : Mod, IReadFromConfig, IApplicable
protected virtual float EndScale => 1;
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpinIn), typeof(OsuModTraceable) };
public void ReadFromConfig(OsuConfigManager config)
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
base.ApplyNormalVisibilityState(hitObject, state);
applyCustomState(hitObject, state);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
private void applyCustomState(DrawableHitObject drawable, ArmedState state)
{
foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0))
{
switch (drawable)
{
case DrawableSpinner _:
continue;
if (drawable is DrawableSpinner)
return;
default:
drawable.ApplyCustomUpdateState += ApplyCustomState;
break;
}
}
}
protected virtual void ApplyCustomState(DrawableHitObject drawable, ArmedState state)
{
var h = (OsuHitObject)drawable.HitObject;
// apply grow effect

View File

@ -2,12 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
@ -16,7 +12,7 @@
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModSpinIn : Mod, IApplicableToDrawableHitObjects, IReadFromConfig
public class OsuModSpinIn : ModWithVisibilityAdjustment
{
public override string Name => "Spin In";
public override string Acronym => "SI";
@ -31,31 +27,17 @@ public class OsuModSpinIn : Mod, IApplicableToDrawableHitObjects, IReadFromConfi
private const int rotate_offset = 360;
private const float rotate_starting_width = 2;
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config)
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0))
{
switch (drawable)
{
case DrawableSpinner _:
continue;
default:
drawable.ApplyCustomUpdateState += applyZoomState;
break;
}
}
base.ApplyNormalVisibilityState(hitObject, state);
applyZoomState(hitObject, state);
}
private void applyZoomState(DrawableHitObject drawable, ArmedState state)
{
if (drawable is DrawableSpinner)
return;
var h = (OsuHitObject)drawable.HitObject;
switch (drawable)

View File

@ -2,12 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Bindables;
using System.Collections.Generic;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
@ -15,7 +11,7 @@
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModTraceable : Mod, IReadFromConfig, IApplicableToDrawableHitObjects
internal class OsuModTraceable : ModWithVisibilityAdjustment
{
public override string Name => "Traceable";
public override string Acronym => "TC";
@ -24,20 +20,14 @@ internal class OsuModTraceable : Mod, IReadFromConfig, IApplicableToDrawableHitO
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModHidden), typeof(OsuModSpinIn), typeof(OsuModObjectScaleTween) };
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config)
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
base.ApplyNormalVisibilityState(hitObject, state);
applyTraceableState(hitObject, state);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0))
drawable.ApplyCustomUpdateState += ApplyTraceableState;
}
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
private void applyTraceableState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableOsuHitObject))
return;