diff --git a/source/funkin/backend/MusicBeatState.hx b/source/funkin/backend/MusicBeatState.hx index 567cfbf9..31bd204b 100644 --- a/source/funkin/backend/MusicBeatState.hx +++ b/source/funkin/backend/MusicBeatState.hx @@ -241,7 +241,10 @@ class MusicBeatState extends FlxState implements IBeatReceiver public override function draw() { graphicCache.draw(); - super.draw(); + var e = event("draw", EventManager.get(DrawEvent).recycle()); + if (!e.cancelled) + super.draw(); + event("postDraw", e); } public override function switchTo(nextState:FlxState) { diff --git a/source/funkin/backend/scripting/events/DrawEvent.hx b/source/funkin/backend/scripting/events/DrawEvent.hx new file mode 100644 index 00000000..94e1aa8b --- /dev/null +++ b/source/funkin/backend/scripting/events/DrawEvent.hx @@ -0,0 +1,4 @@ +package funkin.backend.scripting.events; + +final class DrawEvent extends CancellableEvent { +} \ No newline at end of file diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 67673047..f2634d36 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -29,6 +29,8 @@ using StringTools; @:allow(funkin.game.PlayState) class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible { + public var extra:Map = []; + private var __stunnedTime:Float = 0; private var __lockAnimThisFrame:Bool = false; public var stunned(default, set):Bool = false; @@ -170,7 +172,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset isDanceLeftDanceRight = (hasAnimation("danceLeft") && hasAnimation("danceRight")); - + // alternative to xor operator // for people who dont believe it, heres the truth table // [ a ][ b ][ a!= b ] @@ -183,7 +185,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset // character is flipped CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT')); CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss')); - + switchOffset('singLEFT', 'singRIGHT'); switchOffset('singLEFTmiss', 'singRIGHTmiss'); } @@ -209,7 +211,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } private var danced:Bool = false; - + /** * FOR GF DANCING SHIT */ @@ -268,7 +270,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset tryDance(); } } - + public override function stepHit(curStep:Int) { script.call("stepHit", [curStep]); // nothing @@ -284,7 +286,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } return super.getScreenBounds(newRect, camera); } - + var __drawingShadowFrame = false; var __oldColorTransform = new ColorTransform(); public override function draw() { @@ -293,9 +295,9 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset var oldFrame = _frame; var oldPos = FlxPoint.get(frameOffset.x, frameOffset.y); - + __oldColorTransform.copyColorTransform(colorTransform); - + colorTransform.alphaMultiplier = 1; colorTransform.alphaOffset = 0; colorTransform.blueMultiplier = 0; @@ -312,7 +314,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset _frame = oldFrame; frameOffset.set(oldPos.x, oldPos.y); - + colorTransform.copyColorTransform(__oldColorTransform); oldPos.put(); @@ -341,17 +343,17 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (event.cancelled) return; super.playAnim(event.animName, event.force, event.context, event.reverse, event.startingFrame); - + offset.set(globalOffset.x * (isPlayer != playerOffsets ? 1 : -1), -globalOffset.y); if (event.context == SING || event.context == MISS) lastHit = Conductor.songPosition; } - + public override function destroy() { super.destroy(); - + cameraOffset.put(); globalOffset.put(); } diff --git a/source/funkin/game/HudCamera.hx b/source/funkin/game/HudCamera.hx index 452be12d..a88f9ff5 100644 --- a/source/funkin/game/HudCamera.hx +++ b/source/funkin/game/HudCamera.hx @@ -50,7 +50,7 @@ class HudCamera extends FlxCamera { if (downscroll) { var oldPoint = FlxPoint.get(pos.x, pos.y); pos.set(pos.x, height - pos.y - spr.height); - + oldPoint.put(); } return pos; diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index 356d57cf..3c7e8c4b 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -14,6 +14,8 @@ using StringTools; @:allow(funkin.game.PlayState) class Note extends FlxSprite { + public var extra:Map = []; + public var strumTime:Float = 0; public var mustPress(get, never):Bool; diff --git a/source/funkin/game/NoteGroup.hx b/source/funkin/game/NoteGroup.hx index a6e6e628..c822cd81 100644 --- a/source/funkin/game/NoteGroup.hx +++ b/source/funkin/game/NoteGroup.hx @@ -58,7 +58,7 @@ class NoteGroup extends FlxTypedGroup { public override function forEach(noteFunc:Note->Void, recursive:Bool = false) { i = length-1; __loopSprite = null; - + var oldCur = __currentlyLooping; __currentlyLooping = true; @@ -76,7 +76,7 @@ class NoteGroup extends FlxTypedGroup { if (note.alive) noteFunc(note); }, recursive); } - + public override function remove(Object:Note, Splice:Bool = false):Note { if (members == null) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 0d96e66f..0c7dcdfc 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -639,7 +639,7 @@ class PlayState extends MusicBeatState var event = EventManager.get(AmountEvent).recycle(4); if (!scripts.event("onPreGenerateStrums", event).cancelled) { generateStrums(event.amount); - scripts.call("onPostGenerateStrums"); + scripts.event("onPostGenerateStrums", event); } for(str in strumLines) @@ -1171,6 +1171,13 @@ class PlayState extends MusicBeatState scripts.call("postUpdate", [elapsed]); } + override function draw() { + var e = scripts.event("draw", EventManager.get(DrawEvent).recycle()); + if (!e.cancelled) + super.draw(); + scripts.event("postDraw", e); + } + public function executeEvent(event:ChartEvent) { if (event == null) return; if (event.params == null) return; diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index d4d8fe4a..cd5a8caf 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -4,6 +4,8 @@ import flixel.math.FlxPoint; import funkin.backend.system.Conductor; class Strum extends FlxSprite { + public var extra:Map = []; + public var cpu = false; public var lastHit:Float = -5000; diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index 96db83f1..6e8c23a6 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -70,6 +70,8 @@ class StrumLine extends FlxTypedGroup { */ public var strumAnimPrefix = ["left", "down", "up", "right"]; + public var extra:Map = []; + private function get_ghostTapping() { if (this.ghostTapping != null) return this.ghostTapping; if (PlayState.instance != null) return PlayState.instance.ghostTapping; @@ -284,6 +286,9 @@ class StrumLine extends FlxTypedGroup { babyArrow.playAnim('static'); insert(i, babyArrow); + + PlayState.instance.scripts.event("onPostStrumCreation", event); + return babyArrow; }