Use bindables for hitobject events

This commit is contained in:
smoogipoo
2018-11-09 13:58:46 +09:00
parent 0833ba2692
commit cc8531790a
12 changed files with 150 additions and 96 deletions

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Configuration;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using OpenTK;
@ -14,26 +14,15 @@ namespace osu.Game.Rulesets.Osu.Objects
{
public const double OBJECT_RADIUS = 64;
public event Action<Vector2> PositionChanged;
public event Action<int> StackHeightChanged;
public event Action<float> ScaleChanged;
public double TimePreempt = 600;
public double TimeFadeIn = 400;
private Vector2 position;
public readonly Bindable<Vector2> PositionBindable = new Bindable<Vector2>();
public virtual Vector2 Position
{
get => position;
set
{
if (position == value)
return;
position = value;
PositionChanged?.Invoke(value);
}
get => PositionBindable;
set => PositionBindable.Value = value;
}
public float X => Position.X;
@ -45,38 +34,24 @@ namespace osu.Game.Rulesets.Osu.Objects
public Vector2 StackedEndPosition => EndPosition + StackOffset;
private int stackHeight;
public readonly Bindable<int> StackHeightBindable = new Bindable<int>();
public int StackHeight
{
get => stackHeight;
set
{
if (stackHeight == value)
return;
stackHeight = value;
StackHeightChanged?.Invoke(value);
}
get => StackHeightBindable;
set => StackHeightBindable.Value = value;
}
public Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f);
public double Radius => OBJECT_RADIUS * Scale;
private float scale = 1;
public readonly Bindable<float> ScaleBindable = new Bindable<float>(1);
public float Scale
{
get => scale;
set
{
if (scale == value)
return;
scale = value;
ScaleChanged?.Invoke(value);
}
get => ScaleBindable;
set => ScaleBindable.Value = value;
}
public virtual bool NewCombo { get; set; }