Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed PositionToEnd refferences to Angle #51

Merged
merged 11 commits into from
Apr 7, 2020
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.tau/Beatmaps/tauBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected override IEnumerable<TauHitObject> ConvertHitObject(HitObject original
default:
return new TauHitObject
{
Samples = original is IHasCurve ? ((IHasCurve)original).NodeSamples[0] : original.Samples,
Samples = original is IHasCurve curve ? curve.NodeSamples[0] : original.Samples,
StartTime = original.StartTime,
PositionToEnd = position,
Angle = position.GetHitObjectAngle(),
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
}.Yield();
Expand Down
11 changes: 7 additions & 4 deletions osu.Game.Rulesets.tau/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using osuTK;
using Vector2 = osuTK.Vector2;

namespace osu.Game.Rulesets.Tau
{
Expand All @@ -11,11 +12,13 @@ public static class Extensions
public static float GetDegreesFromPosition(this Vector2 target, Vector2 self)
{
Vector2 offset = self - target;
float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;

return degrees;
return (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y));
}

public static float GetHitObjectAngle(this Vector2 target, Vector2 self) => target.GetDegreesFromPosition(self) * 4;
public static float GetHitObjectAngle(this Vector2 target)
{
Vector2 offset = new Vector2(256, 192) - target; // Using centre of playfield.
return (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, -offset.Y));
}
}
}
13 changes: 6 additions & 7 deletions osu.Game.Rulesets.tau/Objects/Drawables/DrawabletauHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,24 @@ public DrawabletauHitObject(TauHitObject hitObject)
Alpha = 0.05f
});

hitObject.Angle = hitObject.PositionToEnd.GetHitObjectAngle(Vector2.Zero);
Box.Rotation = hitObject.Angle;

Position = Vector2.Zero;
}

private Bindable<float> size;
private Bindable<float> size = new Bindable<float>(10); // Change as you see fit.

[BackgroundDependencyLoader]
[BackgroundDependencyLoader(true)]
private void load(TauRulesetConfigManager config)
{
size = config.GetBindable<float>(TauRulesetSettings.BeatSize);
config?.BindWith(TauRulesetSettings.BeatSize, size);
size.BindValueChanged(value => this.Size = new Vector2(value.NewValue), true);
}

protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();
var b = HitObject.PositionToEnd.GetHitObjectAngle(Vector2.Zero);
var b = HitObject.Angle;
var a = b *= (float)(Math.PI / 180);

Box.FadeIn(HitObject.TimeFadeIn);
Expand Down Expand Up @@ -128,7 +127,7 @@ protected override void UpdateStateTransforms(ArmedState state)
break;

case ArmedState.Hit:
var b = HitObject.PositionToEnd.GetHitObjectAngle(Vector2.Zero);
var b = HitObject.Angle;
var a = b *= (float)(Math.PI / 180);

Box.ScaleTo(2f, time_fade_hit, Easing.OutCubic)
Expand All @@ -141,7 +140,7 @@ protected override void UpdateStateTransforms(ArmedState state)
break;

case ArmedState.Miss:
var c = HitObject.PositionToEnd.GetHitObjectAngle(Vector2.Zero);
var c = HitObject.Angle;
var d = c *= (float)(Math.PI / 180);

Box.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.tau/Replays/tauAutoGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public override Replay Generate()
//Make the cursor stay at the last note's position if there's enough time between the notes
if (i > 0 && h.StartTime - Beatmap.HitObjects[i - 1].StartTime > reactionTime)
{
float b = Beatmap.HitObjects[i - 1].PositionToEnd.GetHitObjectAngle(Vector2.Zero) * MathF.PI / 180;
float b = Beatmap.HitObjects[i - 1].Angle * MathF.PI / 180;

Replay.Frames.Add(new TauReplayFrame(h.StartTime - reactionTime, new Vector2(offset - (cursorDistance * MathF.Cos(b)), offset - (cursorDistance * MathF.Sin(b)))));

buttonIndex = (int)TauAction.LeftButton;
}

float a = h.PositionToEnd.GetHitObjectAngle(Vector2.Zero) * MathF.PI / 180;
float a = h.Angle * MathF.PI / 180;

Replay.Frames.Add(new TauReplayFrame(h.StartTime, new Vector2(offset - (cursorDistance * MathF.Cos(a)), offset - (cursorDistance * MathF.Sin(a))), (TauAction)(buttonIndex++ % 2)));
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.tau/UI/Cursor/tauCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public GameplayCursor(float cs)

protected override bool OnMouseMove(MouseMoveEvent e)
{
var angle = e.MousePosition.GetDegreesFromPosition(AnchorPosition) - 25;
var angle = e.MousePosition.GetDegreesFromPosition(AnchorPosition);

Rotation = angle;

Expand Down
28 changes: 13 additions & 15 deletions osu.Game.Rulesets.tau/UI/tauPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ public TauPlayfield()
});
}

[Resolved]
private TauRulesetConfigManager config { get; set; }
protected Bindable<float> PlayfieldDimLevel = new Bindable<float>(1); // Change the default as you see fit

protected override void LoadComplete()
[BackgroundDependencyLoader(true)]
private void load(TauRulesetConfigManager config)
{
base.LoadComplete();

PlayfieldDimLevel = config.GetBindable<float>(TauRulesetSettings.PlayfieldDim);
config?.BindWith(TauRulesetSettings.PlayfieldDim, PlayfieldDimLevel);
PlayfieldDimLevel.ValueChanged += _ => updateVisuals();
}

protected override void LoadComplete()
{
base.LoadComplete();
updateVisuals();
}

protected Bindable<float> PlayfieldDimLevel { get; private set; }

private void updateVisuals()
{
playfieldBackground.FadeTo(PlayfieldDimLevel.Value, 100);
Expand All @@ -151,8 +151,7 @@ private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)

var tauObj = (DrawabletauHitObject)judgedObject;

var b = tauObj.HitObject.PositionToEnd.GetHitObjectAngle(Vector2.Zero);
var a = b *= (float)(Math.PI / 180);
var a = tauObj.HitObject.Angle * (float)(Math.PI / 180);

DrawableTauJudgement explosion = new DrawableTauJudgement(result, tauObj)
{
Expand All @@ -179,7 +178,7 @@ private class VisualisationContainer : BeatSyncedContainer
private LogoVisualisation visualisation;
private bool firstKiaiBeat = true;
private int kiaiBeatIndex;
protected Bindable<bool> ShowVisualisation;
private readonly Bindable<bool> ShowVisualisation = new Bindable<bool>(true);

[BackgroundDependencyLoader(true)]
private void load(TauRulesetConfigManager settings)
Expand All @@ -200,16 +199,15 @@ private void load(TauRulesetConfigManager settings)
Colour = Color4.Transparent
};

ShowVisualisation = settings.GetBindable<bool>(TauRulesetSettings.ShowVisualizer);

ShowVisualisation.ValueChanged += value => { visualisation.FadeTo(value.NewValue ? 1 : 0, 500); };
ShowVisualisation.TriggerChange();
settings?.BindWith(TauRulesetSettings.ShowVisualizer, ShowVisualisation);
ShowVisualisation.BindValueChanged(value => { visualisation.FadeTo(value.NewValue ? 1 : 0, 500); });
}

protected override void LoadComplete()
{
base.LoadComplete();
visualisation.AccentColour = Color4.White;
ShowVisualisation.TriggerChange();
}

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
Expand Down