Mirror for Friday Night Funkin
at main 213 lines 5.6 kB view raw
1package funkin.modding.module; 2 3import funkin.modding.IScriptedClass.IPlayStateScriptedClass; 4import funkin.modding.IScriptedClass.IStateChangingScriptedClass; 5import funkin.modding.events.ScriptEvent; 6 7/** 8 * A module is a scripted class which receives all events without requiring a specific context. 9 * You may have the module active at all times, or only when another script enables it. 10 */ 11class Module implements IPlayStateScriptedClass implements IStateChangingScriptedClass 12{ 13 /** 14 * Whether the module is currently active. 15 */ 16 public var active(default, set):Bool = true; 17 18 function set_active(value:Bool):Bool 19 { 20 return this.active = value; 21 } 22 23 public var moduleId(default, null):String = 'UNKNOWN'; 24 25 /** 26 * Determines the order in which modules receive events. 27 * You can modify this to change the order in which a given module receives events. 28 * 29 * Priority 1 is processed before Priority 1000, etc. 30 */ 31 public var priority(default, set):Int; 32 33 function set_priority(value:Int):Int 34 { 35 this.priority = value; 36 @:privateAccess 37 ModuleHandler.reorderModuleCache(); 38 return value; 39 } 40 41 /** 42 * Called when the module is initialized. 43 * It may not be safe to reference other modules here since they may not be loaded yet. 44 * 45 * NOTE: To make the module start inactive, call `this.active = false` in the constructor. 46 */ 47 public function new(moduleId:String, priority:Int = 1000):Void 48 { 49 this.moduleId = moduleId; 50 this.priority = priority; 51 } 52 53 public function toString() 54 { 55 return 'Module(' + this.moduleId + ')'; 56 } 57 58 // TODO: Half of these aren't actually being called!!!!!!! 59 60 /** 61 * Called when ANY script event is dispatched. 62 */ 63 public function onScriptEvent(event:ScriptEvent) {} 64 65 /** 66 * Called when the module is first created. 67 * This happens before the title screen appears! 68 */ 69 public function onCreate(event:ScriptEvent) {} 70 71 /** 72 * Called when a module is destroyed. 73 * This currently only happens when reloading modules with F5. 74 */ 75 public function onDestroy(event:ScriptEvent) {} 76 77 /** 78 * Called every frame. 79 */ 80 public function onUpdate(event:UpdateScriptEvent) {} 81 82 /** 83 * Called when the game is paused. 84 */ 85 public function onPause(event:PauseScriptEvent) {} 86 87 /** 88 * Called when the game is resumed. 89 */ 90 public function onResume(event:ScriptEvent) {} 91 92 /** 93 * Called when the song begins. 94 */ 95 public function onSongStart(event:ScriptEvent) {} 96 97 /** 98 * Called when the song ends. 99 */ 100 public function onSongEnd(event:ScriptEvent) {} 101 102 /** 103 * Called when the player dies. 104 */ 105 public function onGameOver(event:ScriptEvent) {} 106 107 /** 108 * Called when a note on the strumline has been rendered and is now onscreen. 109 * This gets dispatched for both the player and opponent strumlines. 110 */ 111 public function onNoteIncoming(event:NoteScriptEvent) {} 112 113 /** 114 * Called when a note has been hit. 115 * This gets dispatched for both the player and opponent strumlines. 116 */ 117 public function onNoteHit(event:HitNoteScriptEvent) {} 118 119 /** 120 * Called when a note has been missed. 121 * This gets dispatched for both the player and opponent strumlines. 122 */ 123 public function onNoteMiss(event:NoteScriptEvent) {} 124 125 public function onNoteHoldDrop(event:HoldNoteScriptEvent) {} 126 127 /** 128 * Called when the player presses a key without any notes present. 129 */ 130 public function onNoteGhostMiss(event:GhostMissNoteScriptEvent) {} 131 132 /** 133 * Called when a step is hit in the song. 134 */ 135 public function onStepHit(event:SongTimeScriptEvent) {} 136 137 /** 138 * Called when a beat is hit in the song. 139 */ 140 public function onBeatHit(event:SongTimeScriptEvent) {} 141 142 /** 143 * Called when a song event is triggered. 144 */ 145 public function onSongEvent(event:SongEventScriptEvent) {} 146 147 /** 148 * Called when the countdown begins. 149 */ 150 public function onCountdownStart(event:CountdownScriptEvent) {} 151 152 /** 153 * Called for every step in the countdown. 154 */ 155 public function onCountdownStep(event:CountdownScriptEvent) {} 156 157 /** 158 * Called when the countdown ends, but BEFORE the song starts. 159 */ 160 public function onCountdownEnd(event:CountdownScriptEvent) {} 161 162 /** 163 * Called when the song's chart has been parsed and loaded. 164 */ 165 public function onSongLoaded(event:SongLoadScriptEvent) {} 166 167 /** 168 * Called when the game is about to switch to a new state. 169 */ 170 public function onStateChangeBegin(event:StateChangeScriptEvent) {} 171 172 /** 173 * Called after the game has switched to a new state. 174 */ 175 public function onStateChangeEnd(event:StateChangeScriptEvent) {} 176 177 /** 178 * Called when the game regains focus. 179 * This does not get called if "Auto Pause" is disabled. 180 */ 181 public function onFocusGained(event:FocusScriptEvent) {} 182 183 /** 184 * Called when the game loses focus. 185 * This does not get called if "Auto Pause" is disabled. 186 */ 187 public function onFocusLost(event:FocusScriptEvent) {} 188 189 /** 190 * Called when the game is about to open a substate. 191 */ 192 public function onSubStateOpenBegin(event:SubStateScriptEvent) {} 193 194 /** 195 * Called when a substate has been opened. 196 */ 197 public function onSubStateOpenEnd(event:SubStateScriptEvent) {} 198 199 /** 200 * Called when the game is about to close a substate. 201 */ 202 public function onSubStateCloseBegin(event:SubStateScriptEvent) {} 203 204 /** 205 * Called when a substate has been closed. 206 */ 207 public function onSubStateCloseEnd(event:SubStateScriptEvent) {} 208 209 /** 210 * Called when the song has been restarted. 211 */ 212 public function onSongRetry(event:SongRetryEvent) {} 213}