@@ -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}
0 commit comments