Skip to content

Commit

Permalink
Add ability to preserve player speed
Browse files Browse the repository at this point in the history
  • Loading branch information
EVAST9919 committed Oct 6, 2024
1 parent fe3d24e commit 12d1111
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 10 deletions.
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Touhosu.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,15 @@ private void load()
<s:Boolean x:Key="/Default/UserDictionary/Words/=beatmap_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bindable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Catmull/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=daycore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Drawables/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gameplay/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hitobjects/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=keymods/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kiai/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Leaderboard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Leaderboards/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=nightcore/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Playfield/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=resampler/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ruleset/@EntryIndexedValue">True</s:Boolean>
Expand Down
22 changes: 20 additions & 2 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModDaycore.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
using osu.Game.Rulesets.Mods;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Touhosu.UI;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModDaycore : ModDaycore
public class TouhosuModDaycore : ModDaycore, IApplicableToDrawableRuleset<TouhosuHitObject>
{
public override double ScoreMultiplier => 0.3;

[SettingSource("Preserve player speed", "Turn on to make player speed be unaffected by the song speed.", SettingControlType = typeof(SettingsCheckbox))]
public BindableBool PreserveSpeed { get; } = new BindableBool();

public void ApplyToDrawableRuleset(DrawableRuleset<TouhosuHitObject> drawableRuleset)
{
if (!PreserveSpeed.Value)
return;

var playfiled = (TouhosuPlayfield)drawableRuleset.Playfield;
playfiled.SpeedMultiplier = 1.0 / SpeedChange.Value;
}
}
}
22 changes: 20 additions & 2 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModDoubleTime.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
using osu.Game.Rulesets.Mods;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Touhosu.UI;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModDoubleTime : ModDoubleTime
public class TouhosuModDoubleTime : ModDoubleTime, IApplicableToDrawableRuleset<TouhosuHitObject>
{
public override double ScoreMultiplier => 1.1f;

[SettingSource("Preserve player speed", "Turn on to make player speed be unaffected by the song speed.", SettingControlType = typeof(SettingsCheckbox))]
public BindableBool PreserveSpeed { get; } = new BindableBool();

public void ApplyToDrawableRuleset(DrawableRuleset<TouhosuHitObject> drawableRuleset)
{
if (!PreserveSpeed.Value)
return;

var playfiled = (TouhosuPlayfield)drawableRuleset.Playfield;
playfiled.SpeedMultiplier = 1.0 / SpeedChange.Value;
}
}
}
22 changes: 20 additions & 2 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModHalfTime.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
using osu.Game.Rulesets.Mods;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Touhosu.UI;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModHalfTime : ModHalfTime
public class TouhosuModHalfTime : ModHalfTime, IApplicableToDrawableRuleset<TouhosuHitObject>
{
public override double ScoreMultiplier => 0.3;

[SettingSource("Preserve player speed", "Turn on to make player speed be unaffected by the song speed.", SettingControlType = typeof(SettingsCheckbox))]
public BindableBool PreserveSpeed { get; } = new BindableBool();

public void ApplyToDrawableRuleset(DrawableRuleset<TouhosuHitObject> drawableRuleset)
{
if (!PreserveSpeed.Value)
return;

var playfiled = (TouhosuPlayfield)drawableRuleset.Playfield;
playfiled.SpeedMultiplier = 1.0 / SpeedChange.Value;
}
}
}
21 changes: 20 additions & 1 deletion osu.Game.Rulesets.Touhosu/Mods/TouhosuModNightcore.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Touhosu.UI;
using osu.Game.Rulesets.UI;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModNightcore : ModNightcore<TouhosuHitObject>
{
public override double ScoreMultiplier => 1.1f;

[SettingSource("Preserve player speed", "Turn on to make player speed be unaffected by the song speed.", SettingControlType = typeof(SettingsCheckbox))]
public BindableBool PreserveSpeed { get; } = new BindableBool();

public new void ApplyToDrawableRuleset(DrawableRuleset<TouhosuHitObject> drawableRuleset)
{
base.ApplyToDrawableRuleset(drawableRuleset);

if (!PreserveSpeed.Value)
return;

var playfiled = (TouhosuPlayfield)drawableRuleset.Playfield;
playfiled.SpeedMultiplier = 1.0 / SpeedChange.Value;
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Touhosu/TouhosuRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace osu.Game.Rulesets.Touhosu
{
public class TouhosuRuleset : Ruleset
public partial class TouhosuRuleset : Ruleset
{
private DrawableTouhosuRuleset ruleset;

Expand Down
6 changes: 4 additions & 2 deletions osu.Game.Rulesets.Touhosu/UI/Objects/TouhosuPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace osu.Game.Rulesets.Touhosu.UI.Objects
{
public class TouhosuPlayer : CompositeDrawable, IKeyBindingHandler<TouhosuAction>
public partial class TouhosuPlayer : CompositeDrawable, IKeyBindingHandler<TouhosuAction>
{
public static readonly float HITBOX_SIZE = 7;

Expand All @@ -38,6 +38,8 @@ public HitObjectContainer HitObjects
}
}

public double SpeedMultiplier { get; set; } = 1.0;

public override bool RemoveCompletedTransforms => false;

private int horizontalDirection;
Expand Down Expand Up @@ -178,7 +180,7 @@ protected override void Update()
}
else
{
move(Clock.ElapsedFrameTime, horizontalDirection, verticalDirection);
move(Clock.ElapsedFrameTime * SpeedMultiplier, horizontalDirection, verticalDirection);
}

if (isDead)
Expand Down
6 changes: 6 additions & 0 deletions osu.Game.Rulesets.Touhosu/UI/TouhosuPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public partial class TouhosuPlayfield : Playfield
public static readonly Vector2 FULL_SIZE = new Vector2(512, 384);
public static readonly Vector2 PLAYFIELD_SIZE = new Vector2(307, 384);

public double SpeedMultiplier
{
get => Player.SpeedMultiplier;
set => Player.SpeedMultiplier = value;
}

private Sample grazeSample;

public TouhosuPlayer Player;
Expand Down

0 comments on commit 12d1111

Please sign in to comment.