Move expire to DrawableHitObject

This commit is contained in:
Dean Herbert 2019-09-12 19:29:08 +09:00
parent 7f2d14416a
commit f21e47d6d2
12 changed files with 43 additions and 36 deletions

View File

@ -71,11 +71,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
switch (state) switch (state)
{ {
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out).Expire(); this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
break; break;
case ArmedState.Hit: case ArmedState.Hit:
this.FadeOut().Expire(); this.FadeOut();
break; break;
} }
} }

View File

@ -51,11 +51,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
switch (state) switch (state)
{ {
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(150, Easing.In).Expire(); this.FadeOut(150, Easing.In);
break; break;
case ArmedState.Hit: case ArmedState.Hit:
this.FadeOut(150, Easing.OutQuint).Expire(); this.FadeOut(150, Easing.OutQuint);
break; break;
} }
} }

View File

@ -86,6 +86,26 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true); AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
} }
public override double LifetimeStart
{
get => base.LifetimeStart;
set
{
base.LifetimeStart = value;
ApproachCircle.LifetimeStart = value;
}
}
public override double LifetimeEnd
{
get => base.LifetimeEnd;
set
{
base.LifetimeEnd = value;
ApproachCircle.LifetimeEnd = value;
}
}
protected override void CheckForResult(bool userTriggered, double timeOffset) protected override void CheckForResult(bool userTriggered, double timeOffset)
{ {
Debug.Assert(HitObject.HitWindows != null); Debug.Assert(HitObject.HitWindows != null);
@ -132,22 +152,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Expire(true); Expire(true);
hitArea.HitAction = null; hitArea.HitAction = null;
// override lifetime end as FadeIn may have been changed externally, causing out expiration to be too early.
LifetimeEnd = HitObject.StartTime + HitObject.HitWindows.WindowFor(HitResult.Miss);
break; break;
case ArmedState.Miss: case ArmedState.Miss:
ApproachCircle.FadeOut(50); ApproachCircle.FadeOut(50);
this.FadeOut(100); this.FadeOut(100);
Expire();
break; break;
case ArmedState.Hit: case ArmedState.Hit:
ApproachCircle.FadeOut(50); ApproachCircle.FadeOut(50);
// todo: temporary / arbitrary // todo: temporary / arbitrary
this.Delay(800).Expire(); this.Delay(800).FadeOut();
break; break;
} }
} }

View File

@ -41,6 +41,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength); protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);
protected override void LoadComplete()
{
base.LoadComplete();
// Manually set to reduce the number of future alive objects to a bare minimum.
LifetimeStart = HitObject.StartTime - HitObject.TimePreempt;
}
protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement); protected override JudgementResult CreateResult(Judgement judgement) => new OsuJudgementResult(HitObject, judgement);
} }
} }

View File

@ -219,10 +219,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
break; break;
} }
this.FadeOut(fade_out_time, Easing.OutQuint).Expire(); this.FadeOut(fade_out_time, Easing.OutQuint);
} }
Expire(true);
} }
public Drawable ProxiedLayer => HeadCircle.ApproachCircle; public Drawable ProxiedLayer => HeadCircle.ApproachCircle;

View File

@ -219,10 +219,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
switch (state) switch (state)
{ {
case ArmedState.Idle:
Expire(true);
break;
case ArmedState.Hit: case ArmedState.Hit:
sequence.ScaleTo(Scale * 1.2f, 320, Easing.Out); sequence.ScaleTo(Scale * 1.2f, 320, Easing.Out);
break; break;
@ -231,8 +227,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
sequence.ScaleTo(Scale * 0.8f, 320, Easing.In); sequence.ScaleTo(Scale * 0.8f, 320, Easing.In);
break; break;
} }
Expire();
} }
} }
} }

View File

@ -70,13 +70,7 @@ namespace osu.Game.Rulesets.Osu.UI
base.Add(h); base.Add(h);
} }
private void addApproachCircleProxy(Drawable d) private void addApproachCircleProxy(Drawable d) => approachCircles.Add(d.CreateProxy());
{
var proxy = d.CreateProxy();
proxy.LifetimeStart = d.LifetimeStart;
proxy.LifetimeEnd = d.LifetimeEnd;
approachCircles.Add(proxy);
}
public override void PostProcess() public override void PostProcess()
{ {

View File

@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
case ArmedState.Hit: case ArmedState.Hit:
case ArmedState.Miss: case ArmedState.Miss:
this.Delay(HitObject.Duration).FadeOut(100).Expire(); this.Delay(HitObject.Duration).FadeOut(100);
break; break;
} }
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
switch (state) switch (state)
{ {
case ArmedState.Hit: case ArmedState.Hit:
this.ScaleTo(0, 100, Easing.OutQuint).Expire(); this.ScaleTo(0, 100, Easing.OutQuint);
break; break;
} }
} }

View File

@ -105,12 +105,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
validActionPressed = false; validActionPressed = false;
UnproxyContent(); UnproxyContent();
this.Delay(HitObject.HitWindows.WindowFor(HitResult.Miss)).Expire();
break; break;
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(100) this.FadeOut(100);
.Expire();
break; break;
case ArmedState.Hit: case ArmedState.Hit:
@ -129,9 +127,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
.Then() .Then()
.MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In); .MoveToY(gravity_travel_height * 2, gravity_time * 2, Easing.In);
this.FadeOut(800) this.FadeOut(800);
.Expire();
break; break;
} }
} }

View File

@ -208,8 +208,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
this.FadeOut(transition_duration, Easing.Out); this.FadeOut(transition_duration, Easing.Out);
bodyContainer.ScaleTo(1.4f, transition_duration); bodyContainer.ScaleTo(1.4f, transition_duration);
Expire();
} }
break; break;

View File

@ -153,7 +153,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
if (UseTransformStateManagement) if (UseTransformStateManagement)
{ {
lifetimeStart = null;
LifetimeEnd = double.MaxValue; LifetimeEnd = double.MaxValue;
double transformTime = HitObject.StartTime - InitialLifetimeOffset; double transformTime = HitObject.StartTime - InitialLifetimeOffset;
@ -173,6 +172,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
state.Value = newState; state.Value = newState;
} }
} }
if (state.Value != ArmedState.Idle && LifetimeEnd == double.MaxValue)
Expire();
} }
else else
state.Value = newState; state.Value = newState;
@ -203,6 +205,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <summary> /// <summary>
/// Apply transforms based on the current <see cref="ArmedState"/>. Previous states are automatically cleared. /// Apply transforms based on the current <see cref="ArmedState"/>. Previous states are automatically cleared.
/// In the case of a non-idle <see cref="ArmedState"/>, and if <see cref="Drawable.LifetimeEnd"/> was not set during this call, <see cref="Drawable.Expire"/> will be invoked.
/// </summary> /// </summary>
/// <param name="state">The new armed state.</param> /// <param name="state">The new armed state.</param>
protected virtual void UpdateStateTransforms(ArmedState state) protected virtual void UpdateStateTransforms(ArmedState state)