attempt undo (#193)

This commit is contained in:
CharlesCatYT
2023-07-20 20:50:37 -07:00
committed by GitHub
parent 4db9cf7cee
commit 8a2ac9e1d4
6 changed files with 154 additions and 184 deletions
+33 -17
View File
@@ -79,6 +79,11 @@ class PlayState extends MusicBeatState
*/
public static var coopMode:Bool = false;
/**
* Script Pack of all the scripts being ran.
*/
public var scripts:ScriptPack;
/**
* Array of all the players in the stage.
*/
@@ -505,7 +510,7 @@ class PlayState extends MusicBeatState
if (FlxG.sound.music != null) FlxG.sound.music.stop();
PauseSubState.script = "";
loadScript();
(scripts = new ScriptPack("PlayState")).setParent(this);
camGame = camera;
FlxG.cameras.add(camHUD = new HudCamera(), false);
@@ -555,29 +560,19 @@ class PlayState extends MusicBeatState
// case "":
// ADD YOUR HARDCODED SCRIPTS HERE!
default:
for(content in [Paths.getScriptPaths('assets/songs/${SONG.meta.name.toLowerCase()}/scripts'), Paths.getScriptPaths('assets/data/charts/')])
for(file in content) {
var old = Assets.forceAssetLibrary;
Assets.forceAssetLibrary = file.library;
addScript(file.file);
Assets.forceAssetLibrary = old;
}
for(content in [Paths.getFolderContent('songs/${SONG.meta.name.toLowerCase()}/scripts', true, fromMods ? MODS : BOTH), Paths.getFolderContent('data/charts/', true, fromMods ? MODS : BOTH)])
for(file in content) addScript(file);
var songEvents:Array<String> = [];
for (event in SONG.events)
if (!songEvents.contains(event.name)) songEvents.push(event.name);
for (file in Paths.getScriptPaths('assets/data/events/')) {
var old = Assets.forceAssetLibrary;
Assets.forceAssetLibrary = file.library;
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file.file));
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) addScript(file.file);
Assets.forceAssetLibrary = old;
for (file in Paths.getFolderContent('data/events/', true, fromMods ? MODS : BOTH)) {
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
if (EventsData.eventsList.contains(fileName) && songEvents.contains(fileName)) addScript(file);
}
}
}
add(comboGroup);
#end
@@ -649,6 +644,7 @@ class PlayState extends MusicBeatState
add(splashHandler);
scripts.load();
scripts.call("create");
#end
// CAMERA & HUD INITIALISATION
@@ -725,6 +721,7 @@ class PlayState extends MusicBeatState
#end
startingSong = true;
super.create();
for(s in introSprites)
@@ -743,6 +740,8 @@ class PlayState extends MusicBeatState
updateDiscordPresence();
__updateNote_event = EventManager.get(NoteUpdateEvent);
scripts.call("postCreate");
}
/**
@@ -895,9 +894,11 @@ class PlayState extends MusicBeatState
}
public override function destroy() {
scripts.call("destroy");
for(g in __cachedGraphics)
g.useCount--;
super.destroy();
scripts = FlxDestroyUtil.destroy(scripts);
@:privateAccess {
FlxG.sound.destroySound(inst);
FlxG.sound.destroySound(vocals);
@@ -1071,9 +1072,11 @@ class PlayState extends MusicBeatState
@:dox(hide)
override public function update(elapsed:Float)
{
scripts.call("update", [elapsed]);
if (inCutscene) {
super.update(elapsed);
scripts.call("postUpdate", [elapsed]);
return;
}
@@ -1191,6 +1194,13 @@ class PlayState extends MusicBeatState
scripts.call("postUpdate", [elapsed]);
}
override function draw() {
var e = scripts.event("draw", EventManager.get(DrawEvent).recycle());
if (!e.cancelled)
super.draw();
scripts.event("postDraw", e);
}
public function executeEvent(event:ChartEvent) {
if (event == null) return;
if (event.params == null) return;
@@ -1614,6 +1624,12 @@ class PlayState extends MusicBeatState
scripts.call("beatHit", [curBeat]);
}
public function addScript(file:String) {
var ext = Path.extension(file).toLowerCase();
if (Script.scriptExtensions.contains(ext))
scripts.add(Script.create(file));
}
// GETTERS & SETTERS
#if REGION
private inline function get_player():StrumLine