making stages easier to be properly destroyed
This commit is contained in:
@@ -1060,14 +1060,22 @@ class PlayState extends MusicBeatState
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
var notNull = stage != null;
|
||||
if (notNull) PlayState.instance.gameAndCharsCall("onStageDestroy", [stage]);
|
||||
scripts.call("destroy");
|
||||
for(g in __cachedGraphics)
|
||||
g.useCount--;
|
||||
|
||||
for (g in __cachedGraphics) g.useCount--;
|
||||
@:privateAccess {
|
||||
for (strumLine in strumLines.members) FlxG.sound.destroySound(strumLine.vocals);
|
||||
if (FlxG.sound.music != inst) FlxG.sound.destroySound(inst);
|
||||
FlxG.sound.destroySound(vocals);
|
||||
}
|
||||
|
||||
if (notNull) {
|
||||
stage.destroySilently();
|
||||
remove(stage, true);
|
||||
}
|
||||
|
||||
scripts = FlxDestroyUtil.destroy(scripts);
|
||||
|
||||
super.destroy();
|
||||
|
||||
@@ -206,7 +206,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
}
|
||||
|
||||
// idk lemme check anyways just in case scripts did smth - Nex
|
||||
if (event != null) PlayState.instance.scripts.event("onPostStageCreation", event);
|
||||
if (event != null) PlayState.instance.gameAndCharsEvent("onPostStageCreation", event);
|
||||
|
||||
// shortlived scripts destroy when the stage finishes setting up - Nex
|
||||
for (info in xmlImportedScripts) if (info.shortLived) {
|
||||
@@ -349,17 +349,37 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same of destroy, but doesn't call the various script events.
|
||||
* @param destroySprites Whether the stage sprites should be destroyed
|
||||
* @param destroyScript Whether the stage script should be destroyed
|
||||
**/
|
||||
public function destroySilently(destroySprites:Bool = true, destroyScript:Bool = true) {
|
||||
if (destroyScript && stageScript != null) {
|
||||
if (PlayState.instance == state && PlayState.instance.scripts != null) PlayState.instance.scripts.remove(stageScript);
|
||||
stageScript.destroy();
|
||||
}
|
||||
|
||||
if (destroySprites)
|
||||
for (e in stageSprites)
|
||||
e?.destroy();
|
||||
|
||||
startCam.put();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
if (PlayState.instance == state && PlayState.instance.scripts != null) PlayState.instance.gameAndCharsCall("onStageDestroy", [this]);
|
||||
stageScript?.call("destroy");
|
||||
destroySilently();
|
||||
}
|
||||
|
||||
public function beatHit(curBeat:Int) {}
|
||||
|
||||
public function stepHit(curStep:Int) {}
|
||||
|
||||
public function measureHit(curMeasure:Int) {}
|
||||
|
||||
public override function destroy() {
|
||||
startCam.put();
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of stages that are available to be used.
|
||||
* @param mods Whenever only the mods folder should be checked
|
||||
|
||||
Reference in New Issue
Block a user