Skip to content

Commit

Permalink
Merge pull request #2366 from tgi74/ctb_hr_mangling
Browse files Browse the repository at this point in the history
Add HardRock position mangling for CatchTheBeat
  • Loading branch information
peppy committed Apr 18, 2018
2 parents 0a292a6 + d307b8d commit 69a91c6
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,88 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using osu.Framework.MathUtils;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
using System;

namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModHardRock : ModHardRock
public class CatchModHardRock : ModHardRock, IApplicableToHitObject<CatchHitObject>
{
public override double ScoreMultiplier => 1.12;
public override bool Ranked => true;

private float lastStartX;
private int lastStartTime;

public void ApplyToHitObject(CatchHitObject hitObject)
{
float position = hitObject.X;
int startTime = (int)hitObject.StartTime;

if (lastStartX == 0)
{
lastStartX = position;
lastStartTime = startTime;
return;
}

float diff = lastStartX - position;
int timeDiff = startTime - lastStartTime;

if (timeDiff > 1000)
{
lastStartX = position;
lastStartTime = startTime;
return;
}

if (diff == 0)
{
bool right = RNG.NextBool();

float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4d)) / CatchPlayfield.BASE_WIDTH;

if (right)
{
if (position + rand <= 1)
position += rand;
else
position -= rand;
}
else
{
if (position - rand >= 0)
position -= rand;
else
position += rand;
}

hitObject.X = position;

return;
}

if (Math.Abs(diff) < timeDiff / 3d)
{
if (diff > 0)
{
if (position - diff > 0)
position -= diff;
}
else
{
if (position - diff < 1)
position -= diff;
}
}

hitObject.X = position;

lastStartX = position;
lastStartTime = startTime;
}
}
}

0 comments on commit 69a91c6

Please sign in to comment.