Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
im an expert in stupidity
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 29, 2023
1 parent 7df297f commit e6e5751
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 40 deletions.
28 changes: 9 additions & 19 deletions source/funkin/objects/NotesGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class NotesGroup extends FlxGroup
hitNote(note, isPlayState ? game.boyfriend : null, inBotplay, getPref("botplay"));
ModdingUtil.addCall('goodNoteHit', [note]);
ModdingUtil.addCall('noteHit', [note, true]);
removeNote(note);
note.removeNote();
}

goodSustainPress = function (sustain:Sustain) {
Expand All @@ -124,7 +124,7 @@ class NotesGroup extends FlxGroup
hitNote(note, isPlayState ? game.dad : null, dadBotplay);
ModdingUtil.addCall('opponentNoteHit', [note]);
ModdingUtil.addCall('noteHit', [note, false]);
removeNote(note);
note.removeNote();
}

opponentSustainPress = function (sustain:Sustain) {
Expand Down Expand Up @@ -311,10 +311,6 @@ class NotesGroup extends FlxGroup
if (callback != null) Reflect.callMethod(this, callback, args ?? []); // Prevent null
}

public inline function removeNote(note:BasicNote) {
note.removeNote();
}

//Makes the conductor song go vroom vroom
function updateConductor(elapsed:Float = 0) {
if (Conductor.inst.playing) {
Expand Down Expand Up @@ -394,7 +390,7 @@ class NotesGroup extends FlxGroup
if (note.activeNote || note.isSustainNote) return;
if (!isCpuNote(note) && note.mustHit)
checkCallback(noteMiss, [note.noteData%Conductor.NOTE_DATA_LENGTH, note]);
removeNote(note);
note.removeNote();
}

public function sustainMiss(note:Sustain) {
Expand Down Expand Up @@ -422,18 +418,18 @@ class NotesGroup extends FlxGroup
inline checkStrumAnims();
}

public var holdingArray:Array<Bool> = [];
//public var holdingArray:Array<Bool> = [];
public var controlArray:Array<Bool> = [];

private inline function pushControls(strums:StrumLineGroup, value:Bool) {
for (i in strums) {
holdingArray.push(value ? false : i.getControl());
//holdingArray.push(value ? false : i.getControl());
controlArray.push(value ? false : i.getControl("-P"));
}
}

private inline function controls():Void {
holdingArray = [];
//holdingArray = [];
controlArray = [];
pushControls(playerStrums, inBotplay);
pushControls(opponentStrums, dadBotplay);
Expand Down Expand Up @@ -493,7 +489,7 @@ class NotesGroup extends FlxGroup
});

if (controlArray.contains(true)) {
forEachArray(removeList, function (badNote) removeNote(badNote));
for (badNote in removeList) badNote.removeNote();
final onGhost = isPlayState ? PlayState.instance.ghostTapEnabled : true;

possibleNotes.sort(CoolUtil.sortByStrumTime);
Expand All @@ -504,10 +500,10 @@ class NotesGroup extends FlxGroup
}
}

forEachArray(possibleNotes, function (possibleNote) {
for (possibleNote in possibleNotes) {
if (possibleNote.targetStrum.getControl("-P"))
checkCallback(possibleNote.mustPress ? goodNoteHit : opponentNoteHit, [possibleNote]);
});
}
}
else if (!onGhost) {
checkCallback(badNoteHit);
Expand All @@ -516,12 +512,6 @@ class NotesGroup extends FlxGroup
}
}

inline function forEachArray(array:Array<Dynamic>, func:Dynamic) {
var i:Int = 0;
while (i < array.length)
func(array[i++]);
}

function checkStrumAnims():Void {
final checkStrums:Array<NoteStrum> = (inBotplay ? [] : playerStrums.members).concat(dadBotplay ? [] : opponentStrums.members);
for (strum in checkStrums) {
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class BasicNote extends SmartSprite implements INoteData {
public var moving:Bool = true;
public var susLength:Float = 0.0;

public inline function removeNote() {
public function removeNote() {
alive = exists = false;
FlxG.signals.preUpdate.addOnce(function () {
if (NotesGroup.instance != null) NotesGroup.instance.notes.remove(this, true);
Expand Down
3 changes: 2 additions & 1 deletion source/funkin/objects/note/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Note extends BasicNote {

override function update(elapsed:Float) {
super.update(elapsed);
calcHit();
if (targetStrum != null)
calcHit();
}

public var canBeHit:Bool = false;
Expand Down
6 changes: 4 additions & 2 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class Sustain extends BasicNote {
override function update(elapsed:Float) {
super.update(elapsed);

if (missedPress && !activeNote) {
removeNote();
if (targetStrum != null) {
if (missedPress && !activeNote) {
removeNote();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ class PlayState extends MusicBeatState {
// For backwards compatibility and my own sanity, its ugly i know!!
public var notes(get,never):FlxTypedGroup<BasicNote>; inline function get_notes()return notesGroup.notes;
public var unspawnNotes(get,never):Array<BasicNote>; inline function get_unspawnNotes()return notesGroup.unspawnNotes;
public var holdingArray(get,never):Array<Bool>; inline function get_holdingArray()return notesGroup.holdingArray;
//public var holdingArray(get,never):Array<Bool>; inline function get_holdingArray()return notesGroup.holdingArray;
public var controlArray(get,never):Array<Bool>; inline function get_controlArray()return notesGroup.controlArray;
public var strumLineNotes(get,never):Array<NoteStrum>; inline function get_strumLineNotes()return notesGroup.strumLineNotes;
public var playerStrums(get,never):StrumLineGroup; inline function get_playerStrums()return notesGroup.playerStrums;
Expand Down
32 changes: 17 additions & 15 deletions source/funkin/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ class ChartingState extends MusicBeatState {

noteTile = new FlxSprite().makeGraphic(GRID_SIZE, GRID_SIZE, FlxColor.WHITE);
noteTile.alpha = 0.6;
noteTile._dynamic.update = function (elapsed) {
var eventsOverlap = getGridOverlap(FlxG.mouse, eventsGrid.grid);
if (getGridOverlap(FlxG.mouse, mainGrid.grid) || eventsOverlap) {
noteTile.visible = true;
var tilePos = getGridCoords(FlxG.mouse, eventsOverlap ? eventsGrid.grid : mainGrid.grid, !FlxG.keys.pressed.SHIFT);
noteTile.setPosition(tilePos.x, tilePos.y);
} else noteTile.visible = false;
}
add(noteTile);

strumBar = new ChartStrumLine();
Expand All @@ -104,13 +96,12 @@ class ChartingState extends MusicBeatState {
final _grid = mainGrid.grid;
songTxt = new FlxFunkText(_grid.x + _grid.width + 25, _grid.y + 25, "swag", FlxPoint.get(FlxG.width*0.5,FlxG.height*0.5), 25);
songTxt._dynamic.update = function (elapsed) {
var info = "Time: " + FlxStringUtil.formatTime(Conductor.songPosition * 0.001, true) + " / " + instStr + "\n" +
"Step: " + Math.max(0, curStep) + "\n" +
"Beat: " + Math.max(0, curBeat) + "\n" +
"Section: " + Math.max(0, curSection) + "\n\n" +
"Position: " + Math.floor(Conductor.songPosition) + "\n" +
"BPM: " + Conductor.bpm;
songTxt.text = info;
songTxt.text = "Time: " + FlxStringUtil.formatTime(Conductor.songPosition * 0.001, true) + " / " + instStr + "\n" +
"Step: " + Math.max(0, curStep) + "\n" +
"Beat: " + Math.max(0, curBeat) + "\n" +
"Section: " + Math.max(0, curSection) + "\n\n" +
"Position: " + Math.floor(Conductor.songPosition) + "\n" +
"BPM: " + Conductor.bpm;
}
add(songTxt);

Expand Down Expand Up @@ -368,6 +359,7 @@ class ChartingState extends MusicBeatState {
}

public function addNote() {
trace(noteTile);
final strumTime:Float = getYtime(noteTile.y + GRID_SIZE) + sectionTime - Conductor.stepCrochet;
final noteData:Int = Math.floor((noteTile.x - mainGrid.grid.x) / GRID_SIZE);
final note:Array<Dynamic> = [strumTime, noteData, 0, ChartTabs.curType];
Expand Down Expand Up @@ -589,8 +581,18 @@ class ChartingState extends MusicBeatState {
}
}

inline function updateNoteTile() {
var eventsOverlap = getGridOverlap(FlxG.mouse, eventsGrid.grid);
if (getGridOverlap(FlxG.mouse, mainGrid.grid) || eventsOverlap) {
noteTile.visible = true;
var tilePos = getGridCoords(FlxG.mouse, eventsOverlap ? eventsGrid.grid : mainGrid.grid, !FlxG.keys.pressed.SHIFT);
noteTile.setPosition(tilePos.x, tilePos.y);
} else noteTile.visible = false;
}

override function update(elapsed:Float) {
super.update(elapsed);
updateNoteTile();
updatePosition();
checkNoteSound();
if (!tabs.getFocus()) keys();
Expand Down
9 changes: 8 additions & 1 deletion source/funkin/states/editors/chart/ChartGridBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ class ChartGridBase extends FlxTypedGroup<Dynamic> {
&& obj1.y > obj2.y && obj1.y < obj2.y + (GRID_SIZE * Conductor.STEPS_PER_MEASURE);
}

static final gridPos:FlxPoint = FlxPoint.get();

public static inline function getGridCoords(obj1:Dynamic, obj2:Dynamic, snapY:Bool = true) {
final tileX = obj2.x + Math.floor((obj1.x - obj2.x) / GRID_SIZE) * GRID_SIZE;
final tileY = snapY ? obj2.y + (Math.floor((obj1.y - obj2.y) / GRID_SIZE) * GRID_SIZE) : obj1.y;
return new FlxPoint(tileX, tileY);
gridPos.set(tileX, tileY);
return gridPos;
}
}

Expand Down Expand Up @@ -220,6 +223,8 @@ class ChartNote extends Note {
public var typeText:Null<FunkinText> = null;
public var gridNoteData:Int = 0;

override function removeNote() {}

public function init(?chartData:Array<Dynamic>, ?skin:String, position:FlxPoint) {
this.chartData = chartData;

Expand Down Expand Up @@ -248,6 +253,8 @@ class ChartSustain extends Sustain {
public var chartParent:Null<ChartNote> = null;
public var gridNoteData:Int = 0;

override function removeNote() {}

public function init(?chartData:Array<Dynamic>, ?skin:String, position:FlxPoint, ?parent:ChartNote) {
this.chartData = chartData;
this.chartParent = parent;
Expand Down

0 comments on commit e6e5751

Please sign in to comment.