2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-05-25 18:11:29 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.MathUtils;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Beatmaps
|
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public class CatchBeatmapProcessor : BeatmapProcessor
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-29 11:45:48 +08:00
|
|
|
|
public const int RNG_SEED = 1337;
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public CatchBeatmapProcessor(IBeatmap beatmap)
|
|
|
|
|
: base(beatmap)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 11:45:48 +08:00
|
|
|
|
public override void PostProcess()
|
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
base.PostProcess();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-29 11:45:48 +08:00
|
|
|
|
applyPositionOffsets();
|
|
|
|
|
|
2018-06-29 12:52:13 +08:00
|
|
|
|
initialiseHyperDash((List<CatchHitObject>)Beatmap.HitObjects);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
int index = 0;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
foreach (var obj in Beatmap.HitObjects.OfType<CatchHitObject>())
|
2018-06-26 19:13:55 +08:00
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
obj.IndexInBeatmap = index++;
|
2018-06-26 19:13:55 +08:00
|
|
|
|
if (obj.LastInCombo && obj.NestedHitObjects.LastOrDefault() is IHasComboInformation lastNested)
|
|
|
|
|
lastNested.LastInCombo = true;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-13 19:11:27 +08:00
|
|
|
|
private void applyPositionOffsets()
|
2018-05-25 18:11:29 +08:00
|
|
|
|
{
|
|
|
|
|
var rng = new FastRandom(RNG_SEED);
|
|
|
|
|
// todo: HardRock displacement should be applied here
|
|
|
|
|
|
|
|
|
|
foreach (var obj in Beatmap.HitObjects)
|
|
|
|
|
{
|
|
|
|
|
switch (obj)
|
|
|
|
|
{
|
|
|
|
|
case BananaShower bananaShower:
|
2018-06-29 14:01:33 +08:00
|
|
|
|
foreach (var banana in bananaShower.NestedHitObjects.OfType<Banana>())
|
2018-05-25 18:11:29 +08:00
|
|
|
|
{
|
2018-06-29 14:01:33 +08:00
|
|
|
|
banana.X = (float)rng.NextDouble();
|
2018-06-13 17:39:26 +08:00
|
|
|
|
rng.Next(); // osu!stable retrieved a random banana type
|
|
|
|
|
rng.Next(); // osu!stable retrieved a random banana rotation
|
2018-06-13 20:10:54 +08:00
|
|
|
|
rng.Next(); // osu!stable retrieved a random banana colour
|
2018-05-25 18:11:29 +08:00
|
|
|
|
}
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-25 18:11:29 +08:00
|
|
|
|
break;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-05-25 18:11:29 +08:00
|
|
|
|
case JuiceStream juiceStream:
|
|
|
|
|
foreach (var nested in juiceStream.NestedHitObjects)
|
|
|
|
|
{
|
2018-06-20 17:29:23 +08:00
|
|
|
|
var hitObject = (CatchHitObject)nested;
|
|
|
|
|
if (hitObject is TinyDroplet)
|
|
|
|
|
hitObject.X += rng.Next(-20, 20) / CatchPlayfield.BASE_WIDTH;
|
|
|
|
|
else if (hitObject is Droplet)
|
2018-06-13 18:52:04 +08:00
|
|
|
|
rng.Next(); // osu!stable retrieved a random droplet rotation
|
2018-06-20 17:29:23 +08:00
|
|
|
|
hitObject.X = MathHelper.Clamp(hitObject.X, 0, 1);
|
2018-05-25 18:11:29 +08:00
|
|
|
|
}
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-25 18:11:29 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private void initialiseHyperDash(List<CatchHitObject> objects)
|
|
|
|
|
{
|
2018-09-13 01:48:35 +08:00
|
|
|
|
List<CatchHitObject> objectWithDroplets = new List<CatchHitObject>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-13 01:48:35 +08:00
|
|
|
|
foreach (var currentObject in objects)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-09-13 01:48:35 +08:00
|
|
|
|
if (currentObject is Fruit)
|
|
|
|
|
objectWithDroplets.Add(currentObject);
|
|
|
|
|
if (currentObject is JuiceStream)
|
|
|
|
|
foreach (var currentJuiceElement in currentObject.NestedHitObjects)
|
|
|
|
|
if (!(currentJuiceElement is TinyDroplet))
|
|
|
|
|
objectWithDroplets.Add((CatchHitObject)currentJuiceElement);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-13 23:15:46 +08:00
|
|
|
|
objectWithDroplets.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
|
|
|
|
|
2018-09-13 23:01:33 +08:00
|
|
|
|
double halfCatcherWidth = CatcherArea.GetCatcherSize(Beatmap.BeatmapInfo.BaseDifficulty) / 2;
|
2018-09-13 01:48:35 +08:00
|
|
|
|
int lastDirection = 0;
|
|
|
|
|
double lastExcess = halfCatcherWidth;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-09-13 01:48:35 +08:00
|
|
|
|
for (int i = 0; i < objectWithDroplets.Count - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
CatchHitObject currentObject = objectWithDroplets[i];
|
|
|
|
|
CatchHitObject nextObject = objectWithDroplets[i + 1];
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
int thisDirection = nextObject.X > currentObject.X ? 1 : -1;
|
2019-03-03 19:21:39 +08:00
|
|
|
|
double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 1/4th of a frame of grace time, taken from osu-stable
|
2018-04-13 17:19:50 +08:00
|
|
|
|
double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth);
|
2018-09-13 01:48:35 +08:00
|
|
|
|
float distanceToHyper = (float)(timeToNext * CatcherArea.Catcher.BASE_SPEED - distanceToNext);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-09-13 01:48:35 +08:00
|
|
|
|
if (distanceToHyper < 0)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
currentObject.HyperDashTarget = nextObject;
|
|
|
|
|
lastExcess = halfCatcherWidth;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-09-13 01:48:35 +08:00
|
|
|
|
currentObject.DistanceToHyperDash = distanceToHyper;
|
|
|
|
|
lastExcess = MathHelper.Clamp(distanceToHyper, 0, halfCatcherWidth);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastDirection = thisDirection;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|