Skip to content

Commit 81642f3

Browse files
committed
APNote Stuffs.
1 parent 10378ff commit 81642f3

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

source/Main.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ class Main extends Sprite
419419
{
420420
Application.current.window.alert(errMsg, "Error!");
421421
}
422+
423+
backend.MusicBeatState.playErrorSound = true;
422424
trace("Crash caused in: " + Type.getClassName(Type.getClass(FlxG.state)));
423425
// Handle different states
424426

source/archipelago/APNote.hx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,67 @@ class APNote extends objects.Note {
66

77

88
var APItem:NetworkItem;
9+
var APItemLocation:Int = 0;
910

10-
public function new(note:Note, item:NetworkItem = null) {
11+
public function new(note:objects.Note, location:Int, ?item:NetworkItem = null) {
1112
super(note.strumTime, note.noteData, note.prevNote, note.isSustainNote);
13+
this.ignoreNote = note.ignoreNote;
14+
this.noteType = note.noteType;
15+
16+
// Copy the properties from the original note to this new note, via reflection
17+
// This is a bit of a hack, but it works for now.
18+
trace("Copying properties from original note to new note...");
19+
for (field in Reflect.fields(note)) {
20+
if (field != "ignoreNote" && field != "noteType" && field != "strumTime" && field != "noteData" && field != "prevNote" && field != "isSustainNote") {
21+
Reflect.setField(this, field, Reflect.field(note, field));
22+
}
23+
}
1224
note.destroy();
25+
trace("Properties copied. Destroying original note...");
26+
27+
APItem = item;
28+
29+
APItemLocation = location;
30+
1331
}
32+
33+
// Replace notes with a certain amount of locations.
34+
public static function replaceNotes(notes:Array<objects.Note>, locations:Array<Int>, ?ignoreNonEmptyNoteType:Bool = false):Array<APNote> {
35+
var newNotes:Array<APNote> = [];
36+
var randomIndices:Array<Int> = [];
37+
38+
// Generate a list of random unique indices
39+
while (randomIndices.length < Math.min(locations.length, notes.length)) {
40+
var randomIndex = Std.random(notes.length);
41+
var note = notes[randomIndex];
42+
43+
var shouldIgnore:Bool = (note.ignoreNote || note.hitCausesMiss || note.isSustainNote || (ignoreNonEmptyNoteType && !note.noteType.isEmpty()));
44+
if (shouldIgnore) continue; // Skip if the note should be ignored
45+
46+
// Check if the note should be ignored
47+
if (!randomIndices.contains(randomIndex) &&
48+
!note.ignoreNote &&
49+
(!ignoreNonEmptyNoteType || note.noteType.isEmpty())) {
50+
randomIndices.push(randomIndex);
51+
}
52+
}
53+
54+
for (i in 0...randomIndices.length) {
55+
var note:objects.Note = notes[randomIndices[i]];
56+
var location:Int = locations[i % locations.length];
57+
var apNote = new APNote(note, location, null); // Create a new APNote with the location
58+
newNotes.push(apNote);
59+
notes[randomIndices[i]] = apNote; // Replace the original note with the APNote
60+
}
61+
62+
return newNotes;
63+
}
64+
65+
public function sendCheck():Void {
66+
if (APItemLocation != null) {
67+
APEntryState.apGame.info().LocationChecks([APItemLocation]);
68+
}
69+
}
70+
71+
1472
}

source/archipelago/APPlayState.hx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class APPlayState extends PlayState {
2626
public static var apGame:APGameState;
2727
public static var deathByLink:Bool = false;
2828
public static var deathByBlueBalls:Bool = false;
29+
30+
public var checkedNotes:Array<archipelago.APNote> = new Array<archipelago.APNote>();
31+
2932
public static var currentMod = "";
3033
public static var deathLinkPacket:Dynamic;
3134
public static var effectiveScrollSpeed:Float;

source/backend/MusicBeatState.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class MusicBeatState extends FlxState
1919
public static var pubCurDecStep:Float = 0;
2020
public static var pubCurDecBeat:Float = 0;
2121

22+
public static var playErrorSound:Bool = false;
23+
2224
public function handleFileDrop(file:String)
2325
{
2426
// trace('dropped files: ' + files);
@@ -107,6 +109,11 @@ class MusicBeatState extends FlxState
107109
{}
108110
});
109111
}
112+
if (playErrorSound)
113+
{
114+
playErrorSound = false;
115+
FlxG.sound.play(Paths.sound('error'), 1, false);
116+
}
110117
}
111118

112119
public static var firstRun:Bool = true;

source/yutautil/ExtendedDate.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ class ExtendedDate extends FlxBasic {
195195
return month == monthEaster && day == dayEaster;
196196
}
197197

198+
public function isHatsuneMikuDay():Bool {
199+
return this.getMonth() == 3 && this.getDate() == 9;
200+
}
201+
202+
public function isHatsuneMikuBirthday():Bool {
203+
return this.getMonth() == 8 && this.getDate() == 31;
204+
}
205+
198206
public function isNewYearsEve():Bool {
199207
return this.getMonth() == 11 && this.getDate() == 31;
200208
}

0 commit comments

Comments
 (0)