pooled events

This commit is contained in:
Yoshman29
2023-01-09 16:51:14 +01:00
parent e0c2a9da7a
commit 6060032235
35 changed files with 207 additions and 222 deletions
+1 -1
View File
@@ -1 +1 @@
1962
1965
+4 -4
View File
@@ -64,7 +64,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public inline function getCameraPosition() {
var midpoint = getMidpoint();
var event = new PointEvent(
var event = EventManager.get(PointEvent).recycle(
midpoint.x + (isPlayer ? -100 : 150) + globalOffset.x + cameraOffset.x,
midpoint.y - 100 + globalOffset.y + cameraOffset.y);
script.call("onGetCamPos", [event]);
@@ -76,7 +76,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, Reversed:Bool = false, Frame:Int = 0) {
var anims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"];
var event = new DirectionAnimEvent('${anims[direction]}$suffix', direction, suffix, Context, Reversed, Frame);
var event = EventManager.get(DirectionAnimEvent).recycle('${anims[direction]}$suffix', direction, suffix, Context, Reversed, Frame);
script.call("onPlaySingAnim", [event]);
if (!event.cancelled) playAnim(event.animName, event.force, Context, event.reversed, event.frame);
}
@@ -217,7 +217,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
{
if (!debugMode)
{
var event = new DanceEvent(danced);
var event = EventManager.get(DanceEvent).recycle(danced);
script.call("onDance", [event]);
if (event.cancelled) return;
@@ -328,7 +328,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void
{
var event = new PlayAnimEvent(AnimName, Force, Reversed, Frame, Context);
var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context);
script.call("onPlayAnim", [event]);
if (event.cancelled) return;
+1 -1
View File
@@ -98,7 +98,7 @@ class Note extends FlxSprite
this.noteData = noteData;
var customType = Paths.image('game/notes/${this.noteType}');
var event = new NoteCreationEvent(this, strumID, this.noteType, noteTypeID, mustPress, Assets.exists(customType) ? 'game/notes/${this.noteType}' : 'game/NOTE_assets', 0.7, animSuffix);
var event = EventManager.get(NoteCreationEvent).recycle(this, strumID, this.noteType, noteTypeID, mustPress, Assets.exists(customType) ? 'game/notes/${this.noteType}' : 'game/NOTE_assets', 0.7, animSuffix);
if (PlayState.instance != null)
event = PlayState.instance.scripts.event("onNoteCreation", event);
+16 -14
View File
@@ -460,7 +460,7 @@ class PlayState extends MusicBeatState
rating = e;
}
var event = scripts.event("onRatingUpdate", new RatingUpdateEvent(rating, curRating));
var event = scripts.event("onRatingUpdate", EventManager.get(RatingUpdateEvent).recycle(rating, curRating));
if (!event.cancelled)
curRating = event.rating;
}
@@ -730,11 +730,12 @@ class PlayState extends MusicBeatState
* Creates a fake countdown.
*/
public function countdown(swagCounter:Int) {
var event:CountdownEvent = scripts.event("onCountdown", new CountdownEvent(
var event:CountdownEvent = scripts.event("onCountdown", EventManager.get(CountdownEvent).recycle(
swagCounter,
introSprites[swagCounter],
1,
introSounds[swagCounter],
1, 0.6, true));
introSprites[swagCounter],
0.6, true, null, null, null));
var sprite:FlxSprite = null;
var sound:FlxSound = null;
@@ -935,7 +936,7 @@ class PlayState extends MusicBeatState
var babyArrow:Strum = new Strum((FlxG.width * 0.25) + (Note.swagWidth * (i - 2)) + ((FlxG.width / 2) * player), strumLine.y);
babyArrow.ID = i;
var event = scripts.event("onStrumCreation", new StrumCreationEvent(babyArrow, player, i));
var event = scripts.event("onStrumCreation", EventManager.get(StrumCreationEvent).recycle(babyArrow, player, i));
if (!event.cancelled) {
switch (curStage)
@@ -997,7 +998,7 @@ class PlayState extends MusicBeatState
override function openSubState(SubState:FlxSubState)
{
var event = scripts.event("onSubstateOpen", new StateEvent(SubState));
var event = scripts.event("onSubstateOpen", EventManager.get(StateEvent).recycle(SubState));
if (!postCreated)
FlxTransitionableState.skipNextTransIn = true;
@@ -1021,7 +1022,7 @@ class PlayState extends MusicBeatState
override function closeSubState()
{
var event = scripts.event("onSubstateClose", new StateEvent(subState));
var event = scripts.event("onSubstateClose", EventManager.get(StateEvent).recycle(subState));
if (event.cancelled) return;
if (paused)
@@ -1237,7 +1238,7 @@ class PlayState extends MusicBeatState
else
ratio = section.mustHitSection ? 1 : 0;
var event = scripts.event("onCameraMove", new CamMoveEvent(bfPos, dadPos, ratio, FlxPoint.get(FlxMath.lerp(dadPos.x, bfPos.x, ratio), FlxMath.lerp(dadPos.y, bfPos.y, ratio))));
var event = scripts.event("onCameraMove", EventManager.get(CamMoveEvent).recycle(FlxPoint.get(FlxMath.lerp(dadPos.x, bfPos.x, ratio), FlxMath.lerp(dadPos.y, bfPos.y, ratio)), bfPos, dadPos, ratio, ratio >= 0.5));
if (!event.cancelled) {
camFollow.setPosition(
@@ -1296,7 +1297,7 @@ class PlayState extends MusicBeatState
}
}
var event = PlayState.instance.scripts.event("onNoteUpdate", new NoteUpdateEvent(daNote, FlxG.elapsed, __updateNote_strum));
var event = PlayState.instance.scripts.event("onNoteUpdate", EventManager.get(NoteUpdateEvent).recycle(daNote, FlxG.elapsed, __updateNote_strum));
if (!event.cancelled) {
if (event.__updateHitWindow) {
if (daNote.mustPress)
@@ -1440,7 +1441,7 @@ class PlayState extends MusicBeatState
__justPressed.pushGroup(controls.NOTE_LEFT_P, controls.NOTE_DOWN_P, controls.NOTE_UP_P, controls.NOTE_RIGHT_P);
__justReleased.pushGroup(controls.NOTE_LEFT_R, controls.NOTE_DOWN_R, controls.NOTE_UP_R, controls.NOTE_RIGHT_R);
var event = scripts.event("onKeyShit", new InputSystemEvent(__pressed, __justPressed, __justReleased));
var event = scripts.event("onKeyShit", EventManager.get(InputSystemEvent).recycle(__pressed, __justPressed, __justReleased));
if (event.cancelled) return;
__pressed = CoolUtil.getDefault(event.pressed, []);
@@ -1487,7 +1488,7 @@ class PlayState extends MusicBeatState
{
if (!boyfriend.stunned)
{
var event:NoteHitEvent = scripts.event("onPlayerMiss", new NoteHitEvent(note, [boyfriend], true, note.noteType, note.strumID, -0.04, false, -10, "", "shit", 0));
var event:NoteHitEvent = scripts.event("onPlayerMiss", EventManager.get(NoteHitEvent).recycle(true, false, false, note, [boyfriend], true, note.noteType, "", "", "", note.strumID, -10, 0, -0.04, "shit"));
if (event.cancelled) return;
@@ -1563,9 +1564,10 @@ class PlayState extends MusicBeatState
var event:NoteHitEvent;
if (note.mustPress)
event = scripts.event("onPlayerHit", new NoteHitEvent(note, [boyfriend], true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004, score, note.animSuffix, daRating, note.isSustainNote ? null : accuracy, "game/score/", ''));
// event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(note, [boyfriend], true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004, score, note.animSuffix, daRating, note.isSustainNote ? null : accuracy, "game/score/", ''));
event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, true, !note.isSustainNote, note, [boyfriend], true, note.noteType, "", "game/score/", "", note.strumID, score, accuracy, note.noteData > 0 ? 0.023 : 0.004, daRating));
else
event = scripts.event("onDadHit", new NoteHitEvent(note, [dad], false, note.noteType, note.strumID, 0, 0, note.animSuffix, daRating, null, "game/score/", ''));
event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, [dad], false, note.noteType, "", "game/score/", "", note.strumID, 0, null, 0, daRating));
if (!event.cancelled) {
if (event.accuracy != null) {
@@ -1680,7 +1682,7 @@ class PlayState extends MusicBeatState
}
public function deleteNote(note:Note) {
var event:SimpleNoteEvent = scripts.event("onNoteDelete", new SimpleNoteEvent(note));
var event:SimpleNoteEvent = scripts.event("onNoteDelete", EventManager.get(SimpleNoteEvent).recycle(note));
if (!event.cancelled) {
scripts.call("onNoteDelete", [note]);
note.kill();
+3 -1
View File
@@ -6,6 +6,8 @@ import funkin.system.CoolUtil;
import funkin.system.Logs;
import funkin.game.PlayState;
import funkin.scripting.EventManager;
using StringTools;
using funkin.system.CoolUtil;
#end
#end
@@ -1,7 +1,9 @@
package funkin.macros;
#if !macro
import haxe.macro.Expr.Field;
import haxe.macro.Context;
#end
#if sys
import sys.io.File;
#end
+115
View File
@@ -0,0 +1,115 @@
package funkin.macros;
#if macro
class EventMacro {
public static function build():Array<Field> {
var fields = Context.getBuildFields();
var curClassRest = Context.getLocalClass();
if (curClassRest == null) return fields;
var curClass = curClassRest.get();
if (curClass == null || curClass.name == "CancellableEvent") return fields;
// gets all fields
var values:Array<EventVar> = [];
var hiddenValues:Array<EventVar> = [];
for(field in fields) {
if (field.access.contains(AStatic)) continue;
var hidden = false;
if (field.meta != null)
for(m in field.meta)
if (m.name == ":dox")
hidden = true;
if (!field.access.contains(APublic)) hidden = true;
switch(field.kind) {
case FVar(type, expr):
(hidden ? hiddenValues : values).push({
name: field.name,
type: type,
expr: expr
});
default:
continue;
}
}
// add recycle option
var func:Function = {
args: [for(a in values) {
value: a.expr,
type: a.type,
opt: false,
name: a.name
}],
expr: {
pos: Context.currentPos(),
expr: EBlock([])
}
};
var funcField:Field = {
pos: Context.currentPos(),
name: "recycle",
kind: FFun(func),
access: [APublic]
};
fields.push(funcField);
var p = new Printer();
switch(func.expr.expr) {
case EBlock(exprs):
// add a "set this" expr for each variable
for(v in values) {
var name = v.name;
exprs.push({
pos: Context.currentPos(),
expr: EBinop(OpAssign, {
pos: Context.currentPos(),
expr: EField({
pos: Context.currentPos(),
expr: EConst(CIdent("this"))
}, name)
}, {
pos: Context.currentPos(),
expr: EConst(CIdent(name))
})
});
}
// add a "set this" expr to reset each private/hidden variables
for(v in hiddenValues) {
var name = v.name;
exprs.push({
pos: Context.currentPos(),
expr: EBinop(OpAssign, {
pos: Context.currentPos(),
expr: EField({
pos: Context.currentPos(),
expr: EConst(CIdent("this"))
}, name)
}, v.expr)
});
}
exprs.push(macro return this);
exprs.insert(0, macro recycleBase());
default:
// nothing
}
return fields;
}
}
typedef EventVar = {
var name:String;
var type:ComplexType;
var expr:Expr;
}
#end
@@ -1,10 +1,5 @@
package funkin.macros;
#if macro
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Printer;
import haxe.macro.Type.ClassField;
import haxe.macro.TypeTools;
class FlxSpriteProxyMacro {
public static function build() {
+5
View File
@@ -0,0 +1,5 @@
#if macro
import haxe.macro.*;
import haxe.macro.Expr;
import haxe.macro.Type;
#end
+2 -2
View File
@@ -169,7 +169,7 @@ class MainMenuState extends MusicBeatState
{
var daChoice:String = optionShit[curSelected];
var event = event("onSelectItem", new NameEvent(daChoice));
var event = event("onSelectItem", EventManager.get(NameEvent).recycle(daChoice));
if (event.cancelled) return;
switch (daChoice)
{
@@ -192,7 +192,7 @@ class MainMenuState extends MusicBeatState
}
function changeItem(huh:Int = 0)
{
var event = event("onChangeItem", new MenuChangeEvent(curSelected, FlxMath.wrap(curSelected + huh, 0, menuItems.length-1), huh, huh != 0));
var event = event("onChangeItem", EventManager.get(MenuChangeEvent).recycle(curSelected, FlxMath.wrap(curSelected + huh, 0, menuItems.length-1), huh, huh != 0));
if (event.cancelled) return;
curSelected = event.value;
+2 -2
View File
@@ -45,7 +45,7 @@ class PauseSubState extends MusicBeatSubstate
pauseScript.setParent(this);
pauseScript.load();
var event = new PauseCreationEvent('breakfast', menuItems);
var event = EventManager.get(PauseCreationEvent).recycle('breakfast', menuItems);
pauseScript.call('create', [event]);
menuItems = event.options;
@@ -129,7 +129,7 @@ class PauseSubState extends MusicBeatSubstate
}
public function selectOption() {
var event = new NameEvent(menuItems[curSelected]);
var event = EventManager.get(NameEvent).recycle(menuItems[curSelected]);
pauseScript.call("onSelectOption", [event]);
if (event.cancelled) return;
+3 -3
View File
@@ -161,7 +161,7 @@ class StoryMenuState extends MusicBeatState {
public function changeWeek(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
var event = event("onChangeWeek", new MenuChangeEvent(curWeek, FlxMath.wrap(curWeek + change, 0, weeks.length-1), change));
var event = event("onChangeWeek", EventManager.get(MenuChangeEvent).recycle(curWeek, FlxMath.wrap(curWeek + change, 0, weeks.length-1), change));
if (event.cancelled) return;
curWeek = event.value;
@@ -181,7 +181,7 @@ class StoryMenuState extends MusicBeatState {
public function changeDifficulty(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
var event = event("onChangeDifficulty", new MenuChangeEvent(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1), change));
var event = event("onChangeDifficulty", EventManager.get(MenuChangeEvent).recycle(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1), change));
if (event.cancelled) return;
curDifficulty = event.value;
@@ -218,7 +218,7 @@ class StoryMenuState extends MusicBeatState {
public function selectWeek() {
var event = event("onWeekSelect", new WeekSelectEvent(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty], curWeek, curDifficulty));
var event = event("onWeekSelect", EventManager.get(WeekSelectEvent).recycle(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty], curWeek, curDifficulty));
if (event.cancelled) return;
canSelect = false;
+22
View File
@@ -0,0 +1,22 @@
package funkin.scripting;
import funkin.scripting.events.*;
class EventManager {
// map doesnt work for that
public static var eventValues:Array<CancellableEvent> = [];
public static var eventKeys:Array<Class<CancellableEvent>> = [];
public static function get<T:CancellableEvent>(cl:Class<T>):T {
var c:Class<CancellableEvent> = cast cl;
var index = eventKeys.indexOf(c);
if (index < 0) {
eventKeys.push(c);
eventValues.push(Type.createInstance(c, []));
return cast eventValues.last();
}
return cast eventValues[index];
}
}
@@ -30,13 +30,4 @@ class CamMoveEvent extends CancellableEvent {
* Whenever the camera focuses BF more than dad.
*/
public var focusBF:Bool = false;
public function new(bfCamPos:FlxPoint, dadCamPos:FlxPoint, ratio:Float, position:FlxPoint) {
super();
this.bfCamPos = bfCamPos;
this.dadCamPos = dadCamPos;
this.ratio = ratio;
this.position = position;
this.focusBF = ratio >= 0.5;
}
}
@@ -3,6 +3,7 @@ package funkin.scripting.events;
import funkin.scripting.ScriptPack;
@:allow(ScriptPack)
@:autoBuild(funkin.macros.EventMacro.build())
class CancellableEvent {
@:dox(hide) public var cancelled:Bool = false;
@:dox(hide) private var __continueCalls:Bool = true;
@@ -30,6 +31,12 @@ class CancellableEvent {
*/
public function new() {}
public function recycleBase() {
data = {};
cancelled = false;
__continueCalls = true;
}
/**
* Returns a string representation of the event, in this format:
* `[CancellableEvent]`
@@ -43,14 +43,4 @@ class CountdownEvent extends CancellableEvent {
* Created sound, only available in `onPostCountdown`
*/
public var sound:FlxSound;
public function new(swagCounter:Int, spritePath:String, soundPath:String, scale:Float = 1, volume:Float = 1, antialiasing:Bool = true) {
super();
this.swagCounter = swagCounter;
this.volume = volume;
this.soundPath = soundPath;
this.spritePath = spritePath;
this.scale = scale;
this.antialiasing = antialiasing;
}
}
@@ -2,8 +2,4 @@ package funkin.scripting.events;
class DanceEvent extends CancellableEvent {
public var danced:Bool;
public function new(danced:Bool = false) {
super();
this.danced = danced;
}
}
@@ -15,10 +15,6 @@ class DirectionAnimEvent extends CancellableEvent {
The suffix of the animation (ex: "-alt") - Defaults to ""
**/
public var suffix:String;
/**
Whenever the animation will play reversed or not.
**/
public var reversed:Bool;
/**
Context of the animation. Is either equal to `SING` or `MISS`.
**/
@@ -26,20 +22,13 @@ class DirectionAnimEvent extends CancellableEvent {
/**
Whenever the animation will play reversed or not.
**/
public var force:Bool;
public var reversed:Bool;
/**
At what frame the animation will start playing
**/
public var frame:Int;
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;
}
/**
Whenever the animation will play reversed or not.
**/
public var force:Bool = true;
}
@@ -18,11 +18,4 @@ class InputSystemEvent extends CancellableEvent {
* For example, `justReleased[0]` will return whenever the left strum was just released.
*/
public var justReleased:Array<Bool>;
public function new(pressed:Array<Bool>, justPressed:Array<Bool>, justReleased:Array<Bool>) {
super();
this.pressed = pressed;
this.justPressed = justPressed;
this.justReleased = justReleased;
}
}
@@ -1,16 +1,16 @@
package funkin.scripting.events;
class MenuChangeEvent extends CancellableEvent {
/**
* Value after the change
*/
public var value:Int;
/**
* Value before the change
*/
public var oldValue:Int;
/**
* Value after the change
*/
public var value:Int;
/**
* Amount of change
*/
@@ -20,12 +20,4 @@ class MenuChangeEvent extends CancellableEvent {
* Whenever the menu SFX should be played.
*/
public var playMenuSFX:Bool = true;
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;
}
}
@@ -5,9 +5,4 @@ class NameEvent extends CancellableEvent {
* Name
*/
public var name:String;
public function new(name:String) {
super();
this.name = name;
}
}
@@ -42,24 +42,4 @@ class NoteCreationEvent extends CancellableEvent {
* Sing animation suffix. "-alt" for alt anim or "" for normal notes.
*/
public var animSuffix:String;
/**
* [Description] Creates a new NoteCreationEvent
* @param note
* @param strumID
* @param noteType
* @param noteTypeID
* @param mustHit
*/
public function new(note:Note, strumID:Int, noteType:String, noteTypeID:Int, mustHit:Bool, noteSprite:String, noteScale:Float, animSuffix:String) {
super();
this.note = note;
this.strumID = strumID;
this.noteType = noteType;
this.noteTypeID = noteTypeID;
this.mustHit = mustHit;
this.noteSprite = noteSprite;
this.noteScale = noteScale;
this.animSuffix = animSuffix;
}
}
+6 -31
View File
@@ -75,14 +75,6 @@ class NoteHitEvent extends CancellableEvent {
* Rating name. Defaults to "sick", "good", "bad" and "shit". Customisable.
*/
public var rating:String = "sick";
/**
* Scale of ratings.
*/
public var ratingScale:Float = 0.7;
/**
* Whenever antialiasing should be enabled on ratings.
*/
public var ratingAntialiasing:Bool = true;
/**
* Scale of combo numbers.
*/
@@ -91,31 +83,14 @@ class NoteHitEvent extends CancellableEvent {
* Whenever antialiasing should be enabled on combo number.
*/
public var numAntialiasing:Bool = true;
/**
* Creates a new NoteHitEvent.
* Scale of ratings.
*/
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.characters = characters;
this.player = player;
this.noteType = noteType;
this.direction = direction;
this.healthGain = healthGain;
this.unmuteVocals = unmuteVocals;
this.score = score;
this.animSuffix = animSuffix;
this.countAsCombo = !note.isSustainNote && note.mustPress;
this.rating = rating;
this.accuracy = accuracy;
this.ratingPrefix = ratingPrefix;
this.ratingSuffix = ratingSuffix;
}
public var ratingScale:Float = 0.7;
/**
* Whenever antialiasing should be enabled on ratings.
*/
public var ratingAntialiasing:Bool = true;
/**
* Prevents the default sing animation from being played.
@@ -22,13 +22,6 @@ class NoteUpdateEvent extends CancellableEvent {
*/
public var strum:Strum;
public function new(note:Note, elapsed:Float, strum:Strum) {
super();
this.note = note;
this.elapsed = elapsed;
this.strum = strum;
}
/**
* Cancels the hit window update.
*/
@@ -13,11 +13,4 @@ class PauseCreationEvent extends CancellableEvent {
* All option names
*/
public var options:Array<String>;
public function new(music:String, options:Array<String>) {
super();
this.music = music;
this.options = options;
}
}
@@ -25,15 +25,6 @@ class PlayAnimEvent extends CancellableEvent {
Context of the animation
**/
public var context:PlayAnimContext;
public function new(animName:String, force:Bool, reverse:Bool, startingFrame:Int, context:PlayAnimContext) {
super();
this.animName = animName;
this.force = force;
this.reverse = reverse;
this.startingFrame = startingFrame;
this.context = context;
}
}
/**
@@ -9,9 +9,4 @@ class PointEvent extends CancellableEvent {
Y position
**/
public var y:Float;
public function new(x:Float, y:Float) {
super();
this.x = x;
this.y = y;
}
}
@@ -10,9 +10,4 @@ class RatingUpdateEvent extends CancellableEvent {
**/
public var oldRating:ComboRating;
public function new(rating:ComboRating, oldRating:ComboRating) {
super();
this.rating = rating;
this.oldRating = oldRating;
}
}
@@ -19,11 +19,4 @@ class ResizeEvent extends CancellableEvent {
* Old height (may be null)
*/
public var oldHeight:Null<Int>;
public function new(width:Int, height:Int, ?oldWidth:Int, ?oldHeight:Int) {
super();
this.width = width;
this.height = height;
this.oldWidth = oldWidth;
this.oldHeight = oldHeight;
}
}
@@ -7,9 +7,4 @@ class SimpleNoteEvent extends CancellableEvent {
Note that is affected.
**/
public var note:Note;
public function new(note:Note) {
super();
this.note = note;
}
}
@@ -7,9 +7,4 @@ class StateEvent extends CancellableEvent {
* Substate that is about to be opened/closed
*/
public var substate:FlxState;
public function new(substate:FlxState) {
super();
this.substate = substate;
}
}
@@ -3,7 +3,7 @@ package funkin.scripting.events;
import funkin.game.Strum;
class StrumCreationEvent extends CancellableEvent {
@:dox(hide) public var __doAnimation = !PlayState.isStoryMode;
@:dox(hide) public var __doAnimation = true;
/**
@@ -11,7 +11,7 @@ class StrumCreationEvent extends CancellableEvent {
*/
public var strum:Strum;
/**
/**s
* Player ID
*/
public var player:Int;
@@ -26,13 +26,6 @@ class StrumCreationEvent extends CancellableEvent {
*/
public var sprite:String = "game/NOTE_assets";
public function new(strum:Strum, player:Int, strumID:Int) {
super();
this.strum = strum;
this.player = player;
this.strumID = strumID;
}
/**
* Cancels the animation that makes the strum "land" in the strumline.
*/
@@ -22,13 +22,4 @@ class WeekSelectEvent extends CancellableEvent {
* At which emplacement the difficulty is. Goes from 0 to the number of weeks - 1.
*/
public var difficultyID:Int;
public override function new(week:WeekData, difficulty:String, weekID:Int, difficultyID:Int) {
super();
this.week = week;
this.difficulty = difficulty;
this.weekID = weekID;
this.difficultyID = difficultyID;
}
}
+3 -3
View File
@@ -178,14 +178,14 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
* SCRIPTING STUFF
*/
public override function openSubState(subState:FlxSubState) {
var e = event("onOpenSubState", new StateEvent(subState));
var e = event("onOpenSubState", EventManager.get(StateEvent).recycle(subState));
if (!e.cancelled)
super.openSubState(subState);
}
public override function onResize(w:Int, h:Int) {
super.onResize(w, h);
event("onResize", new ResizeEvent(w, h));
event("onResize", EventManager.get(ResizeEvent).recycle(w, h, null, null));
}
public override function destroy() {
@@ -202,7 +202,7 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
}
public override function switchTo(nextState:FlxState) {
var e = event("onStateSwitch", new StateEvent(nextState));
var e = event("onStateSwitch", EventManager.get(StateEvent).recycle(nextState));
if (e.cancelled)
return false;
return super.switchTo(nextState);
+3 -3
View File
@@ -181,14 +181,14 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
* SCRIPTING STUFF
*/
public override function openSubState(subState:FlxSubState) {
var e = event("onOpenSubState", new StateEvent(subState));
var e = event("onOpenSubState", EventManager.get(StateEvent).recycle(subState));
if (!e.cancelled)
super.openSubState(subState);
}
public override function onResize(w:Int, h:Int) {
super.onResize(w, h);
event("onResize", new ResizeEvent(w, h));
event("onResize", EventManager.get(ResizeEvent).recycle(w, h, null, null));
}
public override function destroy() {
@@ -198,7 +198,7 @@ class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
}
public override function switchTo(nextState:FlxState) {
var e = event("onStateSwitch", new StateEvent(nextState));
var e = event("onStateSwitch", EventManager.get(StateEvent).recycle(nextState));
if (e.cancelled)
return false;
return super.switchTo(nextState);