forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpinnerCentreLayer.cs
More file actions
69 lines (60 loc) · 2.06 KB
/
Copy pathSpinnerCentreLayer.cs
File metadata and controls
69 lines (60 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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.
using System;
using System.Numerics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public partial class SpinnerCentreLayer : CompositeDrawable, IHasAccentColour
{
private DrawableSpinner spinner = null!;
private CirclePiece circle = null!;
private GlowPiece glow = null!;
private SpriteIcon symbol = null!;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject)
{
spinner = (DrawableSpinner)drawableHitObject;
InternalChildren = new Drawable[]
{
glow = new GlowPiece(),
circle = new CirclePiece
{
Position = Vector2.Zero,
Anchor = Anchor.Centre,
},
new RingPiece(),
symbol = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(48),
Icon = FontAwesome.Solid.Asterisk,
Shadow = false,
},
};
}
protected override void Update()
{
base.Update();
symbol.Rotation = float.Lerp(symbol.Rotation, spinner.RotationTracker.Rotation * 0.5f, (float)Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));
}
private Colour4 accentColour;
public Colour4 AccentColour
{
get => accentColour;
set
{
accentColour = value;
circle.Colour = accentColour;
glow.Colour = accentColour;
}
}
}
}