character array for NoteHitEvent + Fixed old code

This commit is contained in:
Yoshman29
2022-12-30 01:24:36 +01:00
parent 59215bec41
commit 67c021e426
7 changed files with 89 additions and 94 deletions
@@ -1,5 +1,7 @@
package funkin.scripting.events;
import funkin.scripting.events.PlayAnimEvent.PlayAnimContext;
class DirectionAnimEvent extends CancellableEvent {
/**
Default animation that will be played
@@ -17,6 +19,10 @@ class DirectionAnimEvent extends CancellableEvent {
Whenever the animation will play reversed or not.
**/
public var reversed:Bool;
/**
Context of the animation. Is either equal to `SING` or `MISS`.
**/
public var context:PlayAnimContext;
/**
Whenever the animation will play reversed or not.
**/
@@ -26,11 +32,12 @@ class DirectionAnimEvent extends CancellableEvent {
**/
public var frame:Int;
public function new(animName:String, direction:Int, suffix:String = "", reversed:Bool = false, frame:Int = 0) {
public function new(animName:String, direction:Int, suffix:String = "", context:PlayAnimContext = SING, reversed:Bool = false, frame:Int = 0) {
super();
this.animName = animName;
this.direction = direction;
this.suffix = suffix;
this.context = context;
this.reversed = reversed;
this.force = true;
this.frame = frame;
@@ -21,10 +21,11 @@ class MenuChangeEvent extends CancellableEvent {
*/
public var playMenuSFX:Bool = true;
public function new(oldValue:Int, value:Int, change:Int) {
public function new(oldValue:Int, value:Int, change:Int, playMenuSFX:Bool = true) {
super();
this.value = value;
this.oldValue = value;
this.change = change;
this.playMenuSFX = playMenuSFX;
}
}
+15 -4
View File
@@ -28,9 +28,13 @@ class NoteHitEvent extends CancellableEvent {
*/
public var note:Note;
/**
* Character that pressed the note
* Character that pressed the note.
*/
public var character:Character;
public var character(get, set):Character;
/**
* Characters that pressed the note.
*/
public var characters:Array<Character>;
/**
* Whenever the Character is a player
*/
@@ -91,14 +95,14 @@ class NoteHitEvent extends CancellableEvent {
/**
* Creates a new NoteHitEvent.
*/
public function new(note:Note, character:Character, player:Bool, noteType:String,
public function new(note:Note, characters:Array<Character>, player:Bool, noteType:String,
direction:Int, healthGain:Float, unmuteVocals:Bool = true, score:Int = 350,
animSuffix:String = "", rating:String = "sick", ?accuracy:Null<Float>, ratingPrefix:String = "",
ratingSuffix:String = "") {
super();
this.note = note;
this.character = character;
this.characters = characters;
this.player = player;
this.noteType = noteType;
this.direction = direction;
@@ -176,4 +180,11 @@ class NoteHitEvent extends CancellableEvent {
}
@:dox(hide)
public function cancelStrumGlow() {preventStrumGlow();}
private inline function get_character()
return characters[0];
private function set_character(char:Character) {
characters = [char];
return char;
}
}