2022-03-11 01:30:01 -05:00
|
|
|
package funkin.modding.module;
|
|
|
|
|
|
|
|
import funkin.modding.IScriptedClass.IPlayStateScriptedClass;
|
2022-03-14 20:48:45 -04:00
|
|
|
import funkin.modding.IScriptedClass.IStateChangingScriptedClass;
|
2022-04-18 19:36:09 -04:00
|
|
|
import funkin.modding.events.ScriptEvent;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A module is a scripted class which receives all events without requiring a specific context.
|
|
|
|
* You may have the module active at all times, or only when another script enables it.
|
|
|
|
*/
|
2022-03-14 20:48:45 -04:00
|
|
|
class Module implements IPlayStateScriptedClass implements IStateChangingScriptedClass
|
2022-03-11 01:30:01 -05:00
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Whether the module is currently active.
|
|
|
|
*/
|
|
|
|
public var active(default, set):Bool = true;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
function set_active(value:Bool):Bool
|
|
|
|
{
|
2023-02-28 21:06:09 -05:00
|
|
|
return this.active = value;
|
2023-01-22 19:55:30 -05:00
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public var moduleId(default, null):String = 'UNKNOWN';
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Determines the order in which modules receive events.
|
|
|
|
* You can modify this to change the order in which a given module receives events.
|
2023-06-08 16:30:45 -04:00
|
|
|
*
|
2023-01-22 19:55:30 -05:00
|
|
|
* Priority 1 is processed before Priority 1000, etc.
|
|
|
|
*/
|
|
|
|
public var priority(default, set):Int;
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
function set_priority(value:Int):Int
|
|
|
|
{
|
|
|
|
this.priority = value;
|
|
|
|
@:privateAccess
|
|
|
|
ModuleHandler.reorderModuleCache();
|
|
|
|
return value;
|
|
|
|
}
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Called when the module is initialized.
|
|
|
|
* It may not be safe to reference other modules here since they may not be loaded yet.
|
2023-06-08 16:30:45 -04:00
|
|
|
*
|
2023-01-22 19:55:30 -05:00
|
|
|
* NOTE: To make the module start inactive, call `this.active = false` in the constructor.
|
|
|
|
*/
|
|
|
|
public function new(moduleId:String, priority:Int = 1000):Void
|
|
|
|
{
|
|
|
|
this.moduleId = moduleId;
|
|
|
|
this.priority = priority;
|
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function toString()
|
|
|
|
{
|
|
|
|
return 'Module(' + this.moduleId + ')';
|
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// TODO: Half of these aren't actually being called!!!!!!!
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onScriptEvent(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Called when the module is first created.
|
|
|
|
* This happens before the title screen appears!
|
|
|
|
*/
|
|
|
|
public function onCreate(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Called when a module is destroyed.
|
|
|
|
* This currently only happens when reloading modules with F5.
|
|
|
|
*/
|
|
|
|
public function onDestroy(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onUpdate(event:UpdateScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onPause(event:PauseScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onResume(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onSongStart(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onSongEnd(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onGameOver(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onNoteHit(event:NoteScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onNoteMiss(event:NoteScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onNoteGhostMiss(event:GhostMissNoteScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onStepHit(event:SongTimeScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onBeatHit(event:SongTimeScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onSongEvent(event:SongEventScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onCountdownStart(event:CountdownScriptEvent) {}
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onCountdownStep(event:CountdownScriptEvent) {}
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onCountdownEnd(event:CountdownScriptEvent) {}
|
2022-03-14 20:48:45 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onSongLoaded(event:SongLoadScriptEvent) {}
|
2022-03-14 20:48:45 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onStateChangeBegin(event:StateChangeScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public function onStateChangeEnd(event:StateChangeScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-06-09 15:44:29 -04:00
|
|
|
public function onSubStateOpenBegin(event:SubStateScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-06-09 15:44:29 -04:00
|
|
|
public function onSubStateOpenEnd(event:SubStateScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-06-09 15:44:29 -04:00
|
|
|
public function onSubStateCloseBegin(event:SubStateScriptEvent) {}
|
2022-04-18 19:36:09 -04:00
|
|
|
|
2023-06-09 15:44:29 -04:00
|
|
|
public function onSubStateCloseEnd(event:SubStateScriptEvent) {}
|
2023-01-22 19:55:30 -05:00
|
|
|
|
|
|
|
public function onSongRetry(event:ScriptEvent) {}
|
2022-03-11 01:30:01 -05:00
|
|
|
}
|