events but cooler

This commit is contained in:
Yoshman29
2022-10-10 13:31:55 +02:00
parent 8091f5463a
commit 50976d770b
11 changed files with 135 additions and 87 deletions
@@ -30,9 +30,16 @@ class CancellableEvent {
*/
public function new() {}
/**
* Returns a string representation of the event, in this format:
* `[CancellableEvent]`
* `[CancellableEvent (Cancelled)]`
* @return String
*/
public function toString():String {
var rep = '[CancellableEvent ${cancelled ? "(Cancelled)" : ""} - ]';
// TODO: List all fields
var fields = Reflect.fields(this);
var claName = Type.getClassName(Type.getClass(this)).split(".");
var rep = '[${claName[claName.length-1]}${cancelled ? " (Cancelled)" : ""}]';
return rep;
}
}
+59 -13
View File
@@ -5,28 +5,47 @@ import funkin.game.Character;
class NoteHitEvent extends CancellableEvent {
@:dox(hide) public var animCancelled:Bool = false;
public var note:Note;
public var character:Character;
public var player:Bool;
public var noteType:String;
public var direction:Int;
@:dox(hide) public var deleteNote:Bool = true;
@:dox(hide) public var unmuteVocals:Bool = true;
@:dox(hide) public var enableCamZooming:Bool = true;
/**
* Creates a new NoteHitEvent with the following values:
* @param note
* @param character
* @param player
* @param noteType
* Note that has been pressed
*/
public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int) {
public var note:Note;
/**
* Character that pressed the note
*/
public var character:Character;
/**
* Whenever the Character is the player
*/
public var player:Bool;
/**
* Note Type name (null if default note)
*/
public var noteType:String;
/**
* Direction of the press (0 = Left, 1 = Down, 2 = Up, 3 = Right)
*/
public var direction:Int;
/**
* The amount of health that'll be gained from pressing that note.
*/
public var healthGain:Float;
/**
* Creates a new NoteHitEvent.
*/
public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int, healthGain:Float) {
super();
this.note = note;
this.character = character;
this.player = player;
this.noteType = noteType;
this.direction = direction;
this.direction = cast direction;
this.healthGain = healthGain;
}
/**
@@ -38,4 +57,31 @@ class NoteHitEvent extends CancellableEvent {
@:dox(hide)
public function cancelAnim() {preventAnim();}
/**
* Prevents the note from being deleted.
*/
public function preventDeletion() {
deleteNote = false;
}
@:dox(hide)
public function cancelDeletion() {preventDeletion();}
/**
* Prevents the vocals volume from being set to 1 after pressing the note.
*/
public function preventVocalsUnmute() {
unmuteVocals = false;
}
@:dox(hide)
public function cancelVocalsUnmute() {preventVocalsUnmute();}
/**
* Prevents the camera zoom every 4 beats from enabling.
*/
public function preventCamZooming() {
enableCamZooming = false;
}
@:dox(hide)
public function cancelCamZooming() {preventCamZooming();}
}