more optimization
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package funkin.scripting;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxState;
|
||||
import funkin.scripting.events.*;
|
||||
|
||||
class EventManager {
|
||||
@@ -19,4 +21,19 @@ class EventManager {
|
||||
|
||||
return cast eventValues[index];
|
||||
}
|
||||
|
||||
public static function reset() {
|
||||
for(v in eventValues)
|
||||
v.destroy();
|
||||
eventValues = [];
|
||||
eventKeys = [];
|
||||
}
|
||||
|
||||
public static function init() {
|
||||
|
||||
FlxG.signals.preStateCreate.add(onStateSwitch);
|
||||
}
|
||||
|
||||
private static inline function onStateSwitch(newState:FlxState)
|
||||
reset();
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package funkin.scripting.events;
|
||||
|
||||
import funkin.scripting.ScriptPack;
|
||||
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
|
||||
|
||||
@:allow(ScriptPack)
|
||||
@:autoBuild(funkin.macros.EventMacro.build())
|
||||
class CancellableEvent {
|
||||
class CancellableEvent implements IFlxDestroyable {
|
||||
@:dox(hide) public var cancelled:Bool = false;
|
||||
@:dox(hide) private var __continueCalls:Bool = true;
|
||||
|
||||
@@ -49,4 +49,8 @@ class CancellableEvent {
|
||||
var rep = '[${claName[claName.length-1]}${cancelled ? " (Cancelled)" : ""}]';
|
||||
return rep;
|
||||
}
|
||||
|
||||
public function destroy() {
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user