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

View File

@ -2,12 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
@ -16,7 +12,7 @@ using osuTK;
namespace osu.Game.Rulesets.Osu.Mods 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 Name => "Spin In";
public override string Acronym => "SI"; public override string Acronym => "SI";
@ -31,31 +27,17 @@ namespace osu.Game.Rulesets.Osu.Mods
private const int rotate_offset = 360; private const int rotate_offset = 360;
private const float rotate_starting_width = 2; private const float rotate_starting_width = 2;
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>(); protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
public void ReadFromConfig(OsuConfigManager config)
{ {
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility); base.ApplyNormalVisibilityState(hitObject, state);
} applyZoomState(hitObject, state);
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;
}
}
} }
private void applyZoomState(DrawableHitObject drawable, ArmedState state) private void applyZoomState(DrawableHitObject drawable, ArmedState state)
{ {
if (drawable is DrawableSpinner)
return;
var h = (OsuHitObject)drawable.HitObject; var h = (OsuHitObject)drawable.HitObject;
switch (drawable) switch (drawable)

View File

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