-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHitObjectHighlight.cs
68 lines (56 loc) · 2.53 KB
/
HitObjectHighlight.cs
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
using StorybrewCommon.Mapset;
using StorybrewCommon.Scripting;
using StorybrewCommon.Storyboarding;
namespace StorybrewScripts
{
public class HitObjectHighlight : StoryboardObjectGenerator
{
[Configurable]
public int StartTime = 0;
[Configurable]
public int EndTime = 0;
[Configurable]
public int BeatDivisor = 8;
[Configurable]
public int FadeDuration = 200;
[Configurable]
public string SpritePath = "sb/glow.png";
[Configurable]
public double SpriteScale = 1;
public override void Generate()
{
var hitobjectLayer = GetLayer("");
foreach (var hitobject in Beatmap.HitObjects)
{
if ((StartTime != 0 || EndTime != 0) &&
(hitobject.StartTime < StartTime - 5 || EndTime - 5 <= hitobject.StartTime))
continue;
var hSprite = hitobjectLayer.CreateSprite(SpritePath, OsbOrigin.Centre, hitobject.Position);
if (FadeDuration > 0){
hSprite.Scale(OsbEasing.In, hitobject.StartTime, hitobject.EndTime + FadeDuration, SpriteScale, SpriteScale * 0.2);
hSprite.Fade(OsbEasing.In, hitobject.StartTime, hitobject.EndTime + FadeDuration, 1, 0);
}else{
hSprite.Scale(OsbEasing.In, hitobject.StartTime, hitobject.EndTime + 150, SpriteScale, SpriteScale*0.5);
hSprite.Fade(OsbEasing.In, hitobject.StartTime, hitobject.EndTime + 150, 1, 0.9);
}
hSprite.Additive(hitobject.StartTime, hitobject.EndTime + FadeDuration);
hSprite.Color(hitobject.StartTime, hitobject.Color);
if (hitobject is OsuSlider)
{
var timestep = Beatmap.GetTimingPointAt((int)hitobject.StartTime).BeatDuration / BeatDivisor;
var startTime = hitobject.StartTime;
while (true)
{
var endTime = startTime + timestep;
var complete = hitobject.EndTime - endTime < 5;
if (complete) endTime = hitobject.EndTime;
var startPosition = hSprite.PositionAt(startTime);
hSprite.Move(startTime, endTime, startPosition, hitobject.PositionAtTime(endTime));
if (complete) break;
startTime += timestep;
}
}
}
}
}
}