This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Schmovin.hx
178 lines (150 loc) · 4.31 KB
/
Schmovin.hx
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
* @ Author: 4mbr0s3 2
* @ Create Time: 2021-06-22 11:55:58
* @ Modified by: 4mbr0s3 2
* @ Modified time: 2021-11-14 10:33:21
*/
package schmovin;
import Song.SwagSong;
import flixel.FlxBasic;
import flixel.FlxCamera;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.util.FlxColor;
import groovin.mod.Mod;
import groovin.mod.ModHooks;
import groovin.mod_options.GroovinModOptionsClasses.GroovinModOption;
import groovin.mod_options.GroovinModOptionsClasses.GroovinModOptionSectionTitle;
import groovin.mod_options.GroovinModOptionsClasses.GroovinModOptionSlider;
import groovin.util.GroovinConductor;
using SchmovinUtil.SchmovinUtil;
class Schmovin extends Mod
{
private var instance:SchmovinInstance;
public static var holdNoteSubdivisions:Int = 4;
override function GetCredits():String
{
return '4mbr0s3 2';
}
override function Initialize()
{
Hook(ModHooks.HookAfterCameras);
Hook(ModHooks.HookUpdate);
Hook(ModHooks.HookPostNotePosition);
Hook(ModHooks.HookPreDraw);
Hook(ModHooks.HookPostDraw);
Hook(ModHooks.HookPostUI);
Hook(ModHooks.HookOnCountdown);
Hook(ModHooks.HookSetupCharacters);
Hook(ModHooks.HookOnExitPlayState);
}
override function ShouldRun():Bool
{
if (Std.is(FlxG.state.subState, PauseSubState))
return true;
return FlxG.state.subState == null;
}
override function OnGameOver(state:PlayState)
{
instance.Destroy();
}
function InitializeGroovinSchmovinAdapter()
{
SchmovinAdapter.SetInstance(new GroovinSchmovinAdapter());
}
override function AfterCameras(camGame:FlxCamera, camHUD:FlxCamera)
{
InitializeGroovinSchmovinAdapter();
instance = SchmovinInstance.Create();
instance.state = cast FlxG.state;
instance.camHUD = camHUD;
instance.camGame = camGame;
InitializeCamBelowGame();
instance.InitializeCameras();
instance.InitializeSchmovin();
}
function InitializeCamBelowGame()
{
instance.camBelowGame = new FlxCamera();
instance.camBelowGame.bgColor = FlxColor.TRANSPARENT;
FlxG.cameras.add(instance.camBelowGame);
instance.layerBelowGame = new FlxTypedGroup<FlxBasic>();
instance.layerBelowGame.cameras = [instance.camBelowGame];
instance.state.add(instance.layerBelowGame);
}
override function OnExitPlayState(nextState:FlxState)
{
Log('PlayState exited...');
instance.Destroy();
}
function InitializeAboveHUD()
{
instance.layerAboveHUD = new FlxTypedGroup<FlxBasic>();
instance.layerAboveHUD.cameras = [instance.camHUD];
instance.state.add(instance.layerAboveHUD);
}
override function PostUI(state:PlayState)
{
state.strumLineNotes.cameras = [instance.camNotes];
state.notes.cameras = [instance.camNotes];
FlxCamera.defaultCameras = [instance.camGameCopy];
InitializeAboveHUD();
}
override function PreDraw(state:PlayState)
{
if (instance.camPath == null)
return;
instance.notePathRenderer.PreDraw();
}
override function PostDraw(state:PlayState)
{
if (instance.camPath == null)
return;
instance.holdNoteRenderer.PreDraw();
}
override function OnCountdown(state:PlayState)
{
instance.InitializeFakeExplosionReceptors();
}
override function Update(elapsed:Float)
{
instance.Update(elapsed);
UpdateReceptors();
}
function UpdateReceptors()
{
var currentBeat = GetCurrentBeat();
for (receptorIndex in 0...instance.state.strumLineNotes.length)
{
var receptor = instance.state.strumLineNotes.members[receptorIndex];
instance.timeline.UpdateNotes(currentBeat, receptor, SchmovinUtil.GetPlayerOfTotalColumn(receptorIndex), receptorIndex);
}
instance.UpdateFakeExplosionReceptors();
}
override function IsVisibleOnModList():Bool
{
return false;
}
public static function GetCurrentBeat()
{
return SchmovinAdapter.GetInstance().GetCurrentBeat();
}
override function RegisterModOptions():Array<GroovinModOption<Dynamic>>
{
return [
new GroovinModOptionSectionTitle(this, 'Visual'),
new GroovinModOptionSlider(this, 'maxSustainSubdivisions', 'Maximum Sustain Subdivisions', 4, 1, 4, (v) ->
{
holdNoteSubdivisions = cast v;
}, 1, 4, '', true),
];
}
override function PostNotePosition(state:PlayState, strumLine:FlxSprite, daNote:Note, SONG:SwagSong):Bool
{
if (daNote.alive && daNote.visible)
instance.timeline.UpdateNotes(GetCurrentBeat(), daNote, daNote.GetPlayer());
return true;
}
}