mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:25:05 +08:00
Added seed setting, fixed mod ignoring IncreaseFirstObjectVisibility
This commit is contained in:
parent
d20b5c2d5a
commit
15e7cce264
@ -6,15 +6,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
@ -37,6 +45,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public override string Description => @"Practice keeping up with the beat of the song.";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
[SettingSource("Seed", "Seed for random circle placement", SettingControlType = typeof(OsuModTargetSettingsControl))]
|
||||
public Bindable<int?> Seed { get; } = new Bindable<int?>
|
||||
{
|
||||
Default = null,
|
||||
Value = null
|
||||
};
|
||||
|
||||
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
||||
{
|
||||
// Sudden death
|
||||
@ -50,7 +65,14 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
public override void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
base.ApplyToBeatmap(beatmap);
|
||||
Seed.Value ??= RNG.Next();
|
||||
|
||||
var rng = new Random(Seed.Value.GetValueOrDefault());
|
||||
|
||||
float nextSingle(float max = 1f)
|
||||
{
|
||||
return (float)(rng.NextDouble() * max);
|
||||
}
|
||||
|
||||
var osuBeatmap = (OsuBeatmap)beatmap;
|
||||
var origHitObjects = osuBeatmap.HitObjects.OrderBy(x => x.StartTime).ToList();
|
||||
@ -153,13 +175,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
}
|
||||
|
||||
// Position all hit circles
|
||||
var direction = MathHelper.TwoPi * RNG.NextSingle();
|
||||
var direction = MathHelper.TwoPi * nextSingle();
|
||||
for (int i = 0; i < hitObjects.Count; i++)
|
||||
{
|
||||
var x = hitObjects[i];
|
||||
if (i == 0)
|
||||
{
|
||||
x.Position = new Vector2(RNG.NextSingle(OsuPlayfield.BASE_SIZE.X), RNG.NextSingle(OsuPlayfield.BASE_SIZE.Y));
|
||||
x.Position = new Vector2(nextSingle(OsuPlayfield.BASE_SIZE.X), nextSingle(OsuPlayfield.BASE_SIZE.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -185,13 +207,15 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
x.Position = newPosition;
|
||||
|
||||
if (x.LastInCombo)
|
||||
direction = MathHelper.TwoPi * RNG.NextSingle();
|
||||
direction = MathHelper.TwoPi * nextSingle();
|
||||
else
|
||||
direction += distance / MAX_DISTANCE * (RNG.NextSingle() * MathHelper.TwoPi - MathHelper.Pi);
|
||||
direction += distance / MAX_DISTANCE * (nextSingle() * MathHelper.TwoPi - MathHelper.Pi);
|
||||
}
|
||||
}
|
||||
|
||||
osuBeatmap.HitObjects = hitObjects;
|
||||
|
||||
base.ApplyToBeatmap(beatmap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -233,7 +257,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
return samples;
|
||||
}
|
||||
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
||||
protected override void ApplyIncreasedVisibilityState(DrawableHitObject drawable, ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
@ -389,4 +413,84 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuModTargetSettingsControl : SettingsItem<int?>
|
||||
{
|
||||
protected override Drawable CreateControl() => new SeedControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding { Top = 5 }
|
||||
};
|
||||
|
||||
private sealed class SeedControl : CompositeDrawable, IHasCurrentValue<int?>
|
||||
{
|
||||
private readonly BindableWithCurrent<int?> current = new BindableWithCurrent<int?>();
|
||||
|
||||
public Bindable<int?> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set
|
||||
{
|
||||
current.Current = value;
|
||||
seedNumberBox.Text = value.Value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly OsuNumberBox seedNumberBox;
|
||||
|
||||
public SeedControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(),
|
||||
new Dimension(GridSizeMode.Absolute, 120)
|
||||
},
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize)
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
seedNumberBox = new OsuNumberBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CommitOnFocusLost = true,
|
||||
},
|
||||
new TriangleButton
|
||||
{
|
||||
Width = 120,
|
||||
Text = "Randomise",
|
||||
Action = () => current.Value = RNG.Next(),
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
seedNumberBox.Current.BindValueChanged(e =>
|
||||
{
|
||||
if (int.TryParse(e.NewValue, out var intVal))
|
||||
current.Value = intVal;
|
||||
else
|
||||
current.Value = null;
|
||||
});
|
||||
current.BindValueChanged(e =>
|
||||
{
|
||||
seedNumberBox.Text = e.NewValue.ToString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user