Added draw stuff, and custom fields to notes

And added onPostStrumCreation
This commit is contained in:
NeeEoo
2023-05-30 17:34:08 +02:00
parent a46238c9d1
commit e3a88da009
9 changed files with 41 additions and 16 deletions
+4 -1
View File
@@ -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) {
@@ -0,0 +1,4 @@
package funkin.backend.scripting.events;
final class DrawEvent extends CancellableEvent {
}
+13 -11
View File
@@ -29,6 +29,8 @@ using StringTools;
@:allow(funkin.game.PlayState)
class Character extends FunkinSprite implements IBeatReceiver implements IOffsetCompatible
{
public var extra:Map<String, Dynamic> = [];
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();
}
+1 -1
View File
@@ -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;
+2
View File
@@ -14,6 +14,8 @@ using StringTools;
@:allow(funkin.game.PlayState)
class Note extends FlxSprite
{
public var extra:Map<String, Dynamic> = [];
public var strumTime:Float = 0;
public var mustPress(get, never):Bool;
+2 -2
View File
@@ -58,7 +58,7 @@ class NoteGroup extends FlxTypedGroup<Note> {
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<Note> {
if (note.alive) noteFunc(note);
}, recursive);
}
public override function remove(Object:Note, Splice:Bool = false):Note
{
if (members == null)
+8 -1
View File
@@ -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;
+2
View File
@@ -4,6 +4,8 @@ import flixel.math.FlxPoint;
import funkin.backend.system.Conductor;
class Strum extends FlxSprite {
public var extra:Map<String, Dynamic> = [];
public var cpu = false;
public var lastHit:Float = -5000;
+5
View File
@@ -70,6 +70,8 @@ class StrumLine extends FlxTypedGroup<Strum> {
*/
public var strumAnimPrefix = ["left", "down", "up", "right"];
public var extra:Map<String, Dynamic> = [];
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<Strum> {
babyArrow.playAnim('static');
insert(i, babyArrow);
PlayState.instance.scripts.event("onPostStrumCreation", event);
return babyArrow;
}