@@ -16,6 +16,7 @@ import funkin.backend.FunkinText;
1616import funkin .backend .chart .Chart ;
1717import funkin .backend .chart .ChartData ;
1818import funkin .backend .chart .EventsData ;
19+ import funkin .backend .utils .XMLUtil .XMLImportedScriptInfo ;
1920import funkin .backend .scripting .DummyScript ;
2021import funkin .backend .scripting .Script ;
2122import funkin .backend .scripting .ScriptPack ;
@@ -31,6 +32,7 @@ import funkin.game.SplashHandler;
3132import funkin .game .cutscenes .* ;
3233import funkin .game .scoring .* ;
3334import funkin .game .scoring .RatingManager .Rating ;
35+ import funkin .game .stage .Stage ;
3436import funkin .menus .* ;
3537import funkin .backend .week .WeekData ;
3638import funkin .savedata .FunkinSave ;
@@ -42,7 +44,7 @@ using StringTools;
4244@:access (funkin.game. StrumLine )
4345class PlayState extends MusicBeatState
4446{
45- public static final __instanceFields = Type .getInstanceFields (PlayState );
47+ public static final __instanceFields : Map < String , Bool > = [ for ( f in Type .getInstanceFields (PlayState )) f => true ] ;
4648 /**
4749 * Current PlayState instance.
4850 */
@@ -744,7 +746,7 @@ class PlayState extends MusicBeatState
744746 cameraFocusOffset = FlxPoint .get ();
745747
746748 if (SONG .stage == null || SONG .stage .trim () == " " ) SONG .stage = Flags .DEFAULT_STAGE ;
747- add (stage = new Stage (SONG .stage ));
749+ add (stage = new Stage (SONG .stage , setupStage ));
748750
749751 if (! chartingMode || Options .charterEnablePlaytestScripts ) {
750752 switch (SONG .meta .name ) {
@@ -2309,6 +2311,33 @@ class PlayState extends MusicBeatState
23092311 return campaignAccuracyCount == 0 ? 0 : campaignAccuracyTotal / campaignAccuracyCount ;
23102312 #end
23112313
2314+ // region INITIAL SETUP
2315+ private function setupStage (stage : Stage ): Bool {
2316+ stage .prepareInfos = (node ) -> {
2317+ return XMLImportedScriptInfo .prepareInfos (node , scripts , (infos ) -> stage .xmlImportedScripts .push (infos ));
2318+ };
2319+ stage .onStageScriptLoad = (stageScript ) -> scripts .add (stageScript );
2320+ stage .onStartCamSet = (startCam , defaultZoom ) -> {
2321+ camFollow .x = startCam .x ; camFollow .y = startCam .y ;
2322+ defaultCamZoom = defaultZoom ;
2323+ };
2324+ stage .onXMLLoaded = (event ) -> return gameAndCharsEvent (" onStageXMLParsed" , event ).value3 ; // temporary
2325+ stage .onRatingSet = (x , y ) -> {
2326+ comboGroup .setPosition (x , y );
2327+ add (comboGroup ); // unnecessary since it's getting added later
2328+ return comboGroup ;
2329+ };
2330+ stage .onNodeLoaded = (node , sprite ) -> {
2331+ return gameAndCharsEvent (" onStageNodeParsed" , EventManager .get (DynamicEvent ).recycle (stage , node , sprite , node .name )).value3 ; // temporary
2332+ };
2333+ stage .onPostStageCreation = (event ) -> gameAndCharsEvent (" onPostStageCreation" , event );
2334+ stage .removeInfo = (scriptInfo ) -> scripts .remove (scriptInfo );
2335+ stage .onStageDestroy = (_ ) -> gameAndCharsCall (" onStageDestroy" , [_ ]);
2336+ stage .onSilentDestroy = (stageScript ) -> scripts .remove (stageScript );
2337+ return true ;
2338+ }
2339+ // endregion
2340+
23122341 /**
23132342 * Load a week into PlayState.
23142343 * @param weekData Week Data
0 commit comments