2024-05-31 12:02:28 +00:00
|
|
|
package funkin.play.notes.notekind;
|
|
|
|
|
|
|
|
import funkin.modding.IScriptedClass.INoteScriptedClass;
|
|
|
|
import funkin.modding.events.ScriptEvent;
|
2024-06-21 22:20:58 +00:00
|
|
|
import flixel.math.FlxMath;
|
2024-05-31 12:02:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for note scripts
|
|
|
|
*/
|
2024-05-31 14:55:42 +00:00
|
|
|
class NoteKind implements INoteScriptedClass
|
2024-05-31 12:02:28 +00:00
|
|
|
{
|
|
|
|
/**
|
2024-06-01 17:47:45 +00:00
|
|
|
* The name of the note kind
|
2024-05-31 12:02:28 +00:00
|
|
|
*/
|
|
|
|
public var noteKind:String;
|
|
|
|
|
|
|
|
/**
|
2024-06-01 17:47:45 +00:00
|
|
|
* Description used in chart editor
|
2024-05-31 12:02:28 +00:00
|
|
|
*/
|
2024-06-01 17:47:45 +00:00
|
|
|
public var description:String;
|
2024-05-31 12:02:28 +00:00
|
|
|
|
2024-06-01 17:47:45 +00:00
|
|
|
/**
|
|
|
|
* Custom note style
|
|
|
|
*/
|
2024-06-11 21:45:08 +00:00
|
|
|
public var noteStyleId:Null<String>;
|
2024-06-01 17:47:45 +00:00
|
|
|
|
2024-06-21 21:54:29 +00:00
|
|
|
/**
|
|
|
|
* Custom parameters for the chart editor
|
|
|
|
*/
|
|
|
|
public var params:Array<NoteKindParam>;
|
|
|
|
|
|
|
|
public function new(noteKind:String, description:String = "", ?noteStyleId:String, ?params:Array<NoteKindParam>)
|
2024-05-31 12:02:28 +00:00
|
|
|
{
|
|
|
|
this.noteKind = noteKind;
|
|
|
|
this.description = description;
|
2024-06-01 17:47:45 +00:00
|
|
|
this.noteStyleId = noteStyleId;
|
2024-06-21 21:54:29 +00:00
|
|
|
this.params = params ?? [];
|
2024-05-31 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function toString():String
|
|
|
|
{
|
|
|
|
return noteKind;
|
|
|
|
}
|
|
|
|
|
2024-05-31 18:28:56 +00:00
|
|
|
/**
|
|
|
|
* Retrieve all notes of this kind
|
|
|
|
* @return Array<NoteSprite>
|
|
|
|
*/
|
|
|
|
function getNotes():Array<NoteSprite>
|
|
|
|
{
|
|
|
|
var allNotes:Array<NoteSprite> = PlayState.instance.playerStrumline.notes.members.concat(PlayState.instance.opponentStrumline.notes.members);
|
|
|
|
return allNotes.filter(function(note:NoteSprite) {
|
|
|
|
return note != null && note.noteData.kind == this.noteKind;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-05-31 12:02:28 +00:00
|
|
|
public function onScriptEvent(event:ScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onCreate(event:ScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onDestroy(event:ScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onUpdate(event:UpdateScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onNoteIncoming(event:NoteScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onNoteHit(event:HitNoteScriptEvent):Void {}
|
|
|
|
|
|
|
|
public function onNoteMiss(event:NoteScriptEvent):Void {}
|
|
|
|
}
|
2024-06-21 21:54:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract for setting the type of the `NoteKindParam`
|
|
|
|
* This was supposed to be an enum but polymod kept being annoying
|
|
|
|
*/
|
2024-06-21 22:20:58 +00:00
|
|
|
abstract NoteKindParamType(String) to String
|
2024-06-21 21:54:29 +00:00
|
|
|
{
|
2024-06-22 08:52:26 +00:00
|
|
|
public static final STRING:String = 'String';
|
2024-06-21 21:54:29 +00:00
|
|
|
|
2024-06-22 08:52:26 +00:00
|
|
|
public static final INT:String = 'Int';
|
2024-06-21 21:54:29 +00:00
|
|
|
|
2024-06-22 08:52:26 +00:00
|
|
|
public static final FLOAT:String = 'Float';
|
2024-06-21 21:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef NoteKindParamData =
|
|
|
|
{
|
|
|
|
/**
|
2024-06-21 22:20:58 +00:00
|
|
|
* If `min` is null, there is no minimum
|
2024-06-21 21:54:29 +00:00
|
|
|
*/
|
2024-06-22 13:38:04 +00:00
|
|
|
?min:Null<Float>,
|
2024-06-21 21:54:29 +00:00
|
|
|
|
|
|
|
/**
|
2024-06-21 22:20:58 +00:00
|
|
|
* If `max` is null, there is no maximum
|
2024-06-21 21:54:29 +00:00
|
|
|
*/
|
2024-06-22 13:38:04 +00:00
|
|
|
?max:Null<Float>,
|
2024-06-21 21:54:29 +00:00
|
|
|
|
2024-06-22 13:48:07 +00:00
|
|
|
/**
|
|
|
|
* If `step` is null, it will use 1.0
|
|
|
|
*/
|
|
|
|
?step:Null<Float>,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If `precision` is null, there will be 0 decimal places
|
|
|
|
*/
|
|
|
|
?precision:Null<Int>,
|
|
|
|
|
2024-06-23 13:25:53 +00:00
|
|
|
?defaultValue:Dynamic
|
2024-06-21 21:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Typedef for creating custom parameters in the chart editor
|
|
|
|
*/
|
|
|
|
typedef NoteKindParam =
|
|
|
|
{
|
2024-06-22 13:38:04 +00:00
|
|
|
name:String,
|
|
|
|
description:String,
|
|
|
|
type:NoteKindParamType,
|
2024-06-23 13:25:53 +00:00
|
|
|
?data:NoteKindParamData
|
2024-06-21 21:54:29 +00:00
|
|
|
}
|