Files
CodenameEngine/source/funkin/scripting/events/CancellableEvent.hx
T
2022-10-09 22:12:53 +02:00

36 lines
982 B
Haxe

package funkin.scripting.events;
import funkin.scripting.ScriptPack;
@:allow(ScriptPack)
class CancellableEvent {
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = false;
/**
* Additional data if used in scripts
*/
public var data:Dynamic = {};
/**
* Prevents default action from occuring.
*/
public function cancel() {
cancelled = true;
}
/**
* Creates a new cancellable event.
* This allows scripts to call `cancel()` to cancel the event.
* @param continueCalls Whenever the `ScriptPack` should continue calling functions from other scripts after a script cancelled the event.
*/
public function new(continueCalls:Bool) {
__continueCalls = continueCalls;
}
public function toString():String {
var rep = '[CancellableEvent ${cancelled ? "(Cancelled)" : ""} - ]';
// TODO: List all fields
return rep;
}
}