Skip to content

Commit a9d131b

Browse files
committed
FUCK.
1 parent 1e8a801 commit a9d131b

File tree

5 files changed

+478
-3
lines changed

5 files changed

+478
-3
lines changed

source/objects/Note.hx

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,230 @@ class Note extends NoteObject
7676
public var autoGenerated:Bool = false;
7777
public static var pixelNotesDivisionValue:Array<Int> = [4, 18];
7878

79+
public var noteReflection(get, set):Dynamic;
80+
81+
private function get_noteReflection():Dynamic {
82+
return {
83+
strumTime: this.strumTime,
84+
mustPress: this.mustPress,
85+
canBeHit: this.canBeHit,
86+
tooLate: this.tooLate,
87+
wasGoodHit: this.wasGoodHit,
88+
missed: this.missed,
89+
ignoreNote: this.ignoreNote,
90+
hitByOpponent: this.hitByOpponent,
91+
noteType: this.noteType,
92+
alpha: this.alpha,
93+
x: this.x,
94+
y: this.y,
95+
rgb: {
96+
r: this.rgbShader.r,
97+
g: this.rgbShader.g,
98+
b: this.rgbShader.b
99+
},
100+
texture: this.texture
101+
};
102+
}
103+
104+
private function set_noteReflection(value:Dynamic):Dynamic {
105+
try {
106+
if (value.strumTime != null) this.strumTime = value.strumTime;
107+
} catch (e:Dynamic) {
108+
if (Std.is(value.strumTime, Float)) {
109+
trace("An error occurred while setting the value of strumTime.");
110+
} else {
111+
trace("Cannot set strumTime to " + value.strumTime + ", because strumTime is Float and your value is " + Type.typeof(value.strumTime) + ".");
112+
}
113+
}
114+
115+
try {
116+
if (value.mustPress != null) this.mustPress = value.mustPress;
117+
} catch (e:Dynamic) {
118+
if (Std.is(value.mustPress, Bool)) {
119+
trace("An error occurred while setting the value of mustPress.");
120+
} else {
121+
trace("Cannot set mustPress to " + value.mustPress + ", because mustPress is Bool and your value is " + Type.typeof(value.mustPress) + ".");
122+
}
123+
}
124+
125+
try {
126+
if (value.canBeHit != null) this.canBeHit = value.canBeHit;
127+
} catch (e:Dynamic) {
128+
if (Std.is(value.canBeHit, Bool)) {
129+
trace("An error occurred while setting the value of canBeHit.");
130+
} else {
131+
trace("Cannot set canBeHit to " + value.canBeHit + ", because canBeHit is Bool and your value is " + Type.typeof(value.canBeHit) + ".");
132+
}
133+
}
134+
135+
try {
136+
if (value.tooLate != null) this.tooLate = value.tooLate;
137+
} catch (e:Dynamic) {
138+
if (Std.is(value.tooLate, Bool)) {
139+
trace("An error occurred while setting the value of tooLate.");
140+
} else {
141+
trace("Cannot set tooLate to " + value.tooLate + ", because tooLate is Bool and your value is " + Type.typeof(value.tooLate) + ".");
142+
}
143+
}
144+
145+
try {
146+
if (value.wasGoodHit != null) this.wasGoodHit = value.wasGoodHit;
147+
} catch (e:Dynamic) {
148+
if (Std.is(value.wasGoodHit, Bool)) {
149+
trace("An error occurred while setting the value of wasGoodHit.");
150+
} else {
151+
trace("Cannot set wasGoodHit to " + value.wasGoodHit + ", because wasGoodHit is Bool and your value is " + Type.typeof(value.wasGoodHit) + ".");
152+
}
153+
}
154+
155+
try {
156+
if (value.missed != null) this.missed = value.missed;
157+
} catch (e:Dynamic) {
158+
if (Std.is(value.missed, Bool)) {
159+
trace("An error occurred while setting the value of missed.");
160+
} else {
161+
trace("Cannot set missed to " + value.missed + ", because missed is Bool and your value is " + Type.typeof(value.missed) + ".");
162+
}
163+
}
164+
165+
try {
166+
if (value.ignoreNote != null) this.ignoreNote = value.ignoreNote;
167+
} catch (e:Dynamic) {
168+
if (Std.is(value.ignoreNote, Bool)) {
169+
trace("An error occurred while setting the value of ignoreNote.");
170+
} else {
171+
trace("Cannot set ignoreNote to " + value.ignoreNote + ", because ignoreNote is Bool and your value is " + Type.typeof(value.ignoreNote) + ".");
172+
}
173+
}
174+
175+
try {
176+
if (value.hitByOpponent != null) this.hitByOpponent = value.hitByOpponent;
177+
} catch (e:Dynamic) {
178+
if (Std.is(value.hitByOpponent, Bool)) {
179+
trace("An error occurred while setting the value of hitByOpponent.");
180+
} else {
181+
trace("Cannot set hitByOpponent to " + value.hitByOpponent + ", because hitByOpponent is Bool and your value is " + Type.typeof(value.hitByOpponent) + ".");
182+
}
183+
}
184+
185+
try {
186+
if (value.noteType != null) this.noteType = value.noteType;
187+
} catch (e:Dynamic) {
188+
if (Std.is(value.noteType, String)) {
189+
trace("An error occurred while setting the value of noteType.");
190+
} else {
191+
trace("Cannot set noteType to " + value.noteType + ", because noteType is String and your value is " + Type.typeof(value.noteType) + ".");
192+
}
193+
}
194+
195+
try {
196+
if (value.alpha != null) this.alpha = value.alpha;
197+
} catch (e:Dynamic) {
198+
if (Std.is(value.alpha, Float)) {
199+
trace("An error occurred while setting the value of alpha.");
200+
} else {
201+
trace("Cannot set alpha to " + value.alpha + ", because alpha is Float and your value is " + Type.typeof(value.alpha) + ".");
202+
}
203+
}
204+
205+
try {
206+
if (value.x != null) this.x = value.x;
207+
} catch (e:Dynamic) {
208+
if (Std.is(value.x, Float)) {
209+
trace("An error occurred while setting the value of x.");
210+
} else {
211+
trace("Cannot set x to " + value.x + ", because x is Float and your value is " + Type.typeof(value.x) + ".");
212+
}
213+
}
214+
215+
try {
216+
if (value.y != null) this.y = value.y;
217+
} catch (e:Dynamic) {
218+
if (Std.is(value.y, Float)) {
219+
trace("An error occurred while setting the value of y.");
220+
} else {
221+
trace("Cannot set y to " + value.y + ", because y is Float and your value is " + Type.typeof(value.y) + ".");
222+
}
223+
}
224+
225+
try {
226+
if (value.rgb != null) {
227+
if (value.rgb.r != null) {
228+
try {
229+
this.rgbShader.r = value.rgb.r;
230+
} catch (e:Dynamic) {
231+
if (Std.is(value.rgb.r, Int)) {
232+
trace("An error occurred while setting the value of rgb.r.");
233+
} else {
234+
trace("Cannot set rgb.r to " + value.rgb.r + ", because rgb.r is Int and your value is " + Type.typeof(value.rgb.r) + ".");
235+
}
236+
}
237+
}
238+
if (value.rgb.g != null) {
239+
try {
240+
this.rgbShader.g = value.rgb.g;
241+
} catch (e:Dynamic) {
242+
if (Std.is(value.rgb.g, Int)) {
243+
trace("An error occurred while setting the value of rgb.g.");
244+
} else {
245+
trace("Cannot set rgb.g to " + value.rgb.g + ", because rgb.g is Int and your value is " + Type.typeof(value.rgb.g) + ".");
246+
}
247+
}
248+
}
249+
if (value.rgb.b != null) {
250+
try {
251+
this.rgbShader.b = value.rgb.b;
252+
} catch (e:Dynamic) {
253+
if (Std.is(value.rgb.b, Int)) {
254+
trace("An error occurred while setting the value of rgb.b.");
255+
} else {
256+
trace("Cannot set rgb.b to " + value.rgb.b + ", because rgb.b is Int and your value is " + Type.typeof(value.rgb.b) + ".");
257+
}
258+
}
259+
}
260+
}
261+
} catch (e:Dynamic) {
262+
trace("An error occurred while setting the value of rgb.");
263+
}
264+
265+
try {
266+
if (value.texture != null) this.texture = value.texture;
267+
} catch (e:Dynamic) {
268+
if (Std.is(value.texture, String)) {
269+
trace("An error occurred while setting the value of texture.");
270+
} else {
271+
trace("Cannot set texture to " + value.texture + ", because texture is String and your value is " + Type.typeof(value.texture) + ".");
272+
}
273+
}
274+
275+
// Handle extra variables
276+
if (value != null) {
277+
for (field in Reflect.fields(value)) {
278+
if (!Reflect.hasField(this, field) && !Reflect.hasField(value, field)) {
279+
if (extraData == null) extraData = new Map<String, Dynamic>();
280+
extraData.set(field, Reflect.field(value, field));
281+
trace("This variable '" + field + "' of type '" + Type.typeof(Reflect.field(value, field)) + "' doesn't exist.");
282+
} else {
283+
try {
284+
Reflect.setField(this, field, Reflect.field(value, field));
285+
} catch (e:Dynamic) {
286+
if (Type.typeof(Reflect.field(this, field)) == Type.typeof(Reflect.field(value, field))) {
287+
trace("An error occurred while setting the value of " + field + ".");
288+
} else {
289+
trace("Cannot set " + field + " to " + Reflect.field(value, field) + ", because " + field + " is " + Type.typeof(Reflect.field(this, field)) + " and your value is " + Type.typeof(Reflect.field(value, field)) + ".");
290+
}
291+
}
292+
}
293+
}
294+
// Remove the map from the object
295+
extraData = null;
296+
}
297+
298+
return value;
299+
}
300+
301+
302+
79303
public static var minManiaUI_integer:Int = minMania + 1;
80304
public static var maxManiaUI_integer:Int = maxMania + 1;
81305

source/psychlua/LuaUtils.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package psychlua;
1+
package psychlua;
22

33
import backend.WeekData;
44
import objects.Character;

source/states/PlayState.hx

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3596,7 +3596,7 @@ class PlayState extends MusicBeatState
35963596
});
35973597

35983598
field.noteSpawned.add((dunceNote:Note, field:PlayField) -> {
3599-
callOnScripts('onSpawnNote', [dunceNote]);
3599+
callOnScripts('onSpawnNote', [dunceNote.noteReflection]);
36003600
#if LUA_ALLOWED
36013601
callOnLuas('onSpawnNote', [
36023602
allNotes.indexOf(dunceNote),
@@ -3611,7 +3611,7 @@ class PlayState extends MusicBeatState
36113611
var index:Int = unspawnNotes.indexOf(dunceNote);
36123612
unspawnNotes.splice(index, 1);
36133613

3614-
callOnScripts('onSpawnNotePost', [dunceNote]);
3614+
callOnScripts('onSpawnNotePost', [dunceNote.noteReflection]);
36153615
});
36163616

36173617

@@ -3824,6 +3824,8 @@ class PlayState extends MusicBeatState
38243824
updateVisualPosition();
38253825
modManager.update(elapsed, curDecBeat, curDecStep);
38263826

3827+
modchartSync(true);
3828+
38273829
// TODO: Figure this out
38283830
/*for (note in 0...playerStrums.members.length) {
38293831
modManager.setValue('psychTransform${note}X', playerStrums.members[note].x, 1);
@@ -7302,6 +7304,88 @@ class PlayState extends MusicBeatState
73027304
setOnScripts('totalNotesHit', totalNotesHit);
73037305
updateScore(badHit, scoreBop); // score will only update after rating is calculated, if it's a badHit, it shouldn't bounce
73047306
}
7307+
// Simplified version of applyModchartTransform, which will be used on update functions to find and sync the strumLineNotes
7308+
// with the Modchart System.
7309+
public function modchartSync(directChange:Bool = false):Void {
7310+
for (strumNote in strumLineNotes.members) {
7311+
if (strumNote != null) {
7312+
for (field in playfields.members) {
7313+
if (field.strumNotes.contains(strumNote)) {
7314+
var i = field.strumNotes.indexOf(strumNote);
7315+
if (i != -1) {
7316+
if (directChange) {
7317+
// Directly change the x, y, angle, and alpha of the strumNote in the field
7318+
strumNote.x = field.baseXPositions[i];
7319+
strumNote.y = ClientPrefs.data.downScroll ? (FlxG.height - 150) : 50;
7320+
strumNote.angle = modManager.getValue('localRotate${i}', field.playerId);
7321+
// strumNote.alpha = modManager.getValue('alpha${i}', field.playerId);
7322+
} else {
7323+
// Sync X position
7324+
var offsetX = strumNote.x - field.baseXPositions[i];
7325+
modManager.setValue('transform${i}X', offsetX, field.playerId);
7326+
strumNote.x = strumNote.x;
7327+
7328+
// Sync Y position
7329+
var baseY = ClientPrefs.data.downScroll ? (FlxG.height - 150) : 50;
7330+
var offsetY = strumNote.y - baseY;
7331+
modManager.setValue('transform${i}Y', offsetY, field.playerId);
7332+
strumNote.y = strumNote.y;
7333+
7334+
// Sync angle
7335+
modManager.setValue('localRotate${i}', strumNote.angle, field.playerId);
7336+
strumNote.angle = strumNote.angle;
7337+
7338+
// // Sync alpha
7339+
// modManager.setValue('alpha${i}', strumNote.alpha, field.playerId);
7340+
// strumNote.alpha = strumNote.alpha;
7341+
}
7342+
}
7343+
}
7344+
}
7345+
}
7346+
}
7347+
}
7348+
7349+
7350+
public function applyModchartTransform(property:String, value:Float, noteData:Int, player:Int, field:PlayField):Void {
7351+
// Calculate offsets based on property
7352+
switch (property.toLowerCase()) {
7353+
case "x":
7354+
var baseX:Float = field.baseXPositions[noteData];
7355+
var offsetX = value - baseX;
7356+
7357+
// Apply the transform while preserving any alternate (-a) transforms
7358+
var currentAltValue = modManager.getValue('transform${noteData}X-a', player);
7359+
modManager.setValue('transform${noteData}X', offsetX - currentAltValue, player);
7360+
7361+
trace('Legacy Script -> Modchart: Strum ${noteData} X changed: base=${baseX}, new=${value}, transform=${offsetX - currentAltValue}');
7362+
7363+
case "y":
7364+
var baseY:Float = ClientPrefs.data.downScroll ? (FlxG.height - 150) : 50;
7365+
var offsetY = value - baseY;
7366+
7367+
var currentAltValue = modManager.getValue('transform${noteData}Y-a', player);
7368+
modManager.setValue('transform${noteData}Y', offsetY - currentAltValue, player);
7369+
7370+
trace('Legacy Script -> Modchart: Strum ${noteData} Y changed: base=${baseY}, new=${value}, transform=${offsetY - currentAltValue}');
7371+
7372+
case "angle":
7373+
// For angles, we can use the builtin localRotate modifier
7374+
modManager.setValue('localRotate${noteData}', value, player);
7375+
7376+
trace('Legacy Script -> Modchart: Strum ${noteData} angle changed: new=${value}');
7377+
7378+
case "alpha":
7379+
// For alpha, use the alpha modifier while preserving alternate values
7380+
var currentAltValue = modManager.getValue('alpha${noteData}-a', player);
7381+
modManager.setValue('alpha${noteData}', value - currentAltValue, player);
7382+
7383+
trace('Legacy Script -> Modchart: Strum ${noteData} alpha changed: new=${value}');
7384+
7385+
default:
7386+
trace('Unsupported property for modchart propagation: ${property}');
7387+
}
7388+
}
73057389

73067390
#if ACHIEVEMENTS_ALLOWED
73077391
private function checkForAchievement(achievesToCheck:Array<String> = null)

source/yutautil/MiniClass.hx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package yutautil;
2+
3+
import haxe.ds.StringMap;
4+
5+
class MiniClass {
6+
private var fields:StringMap<Dynamic>;
7+
8+
public function new() {
9+
fields = new StringMap<Dynamic>();
10+
}
11+
12+
public function addField(fieldName:String, value:Dynamic):Void {
13+
fields.set(fieldName, value);
14+
}
15+
16+
public function getField(fieldName:String):Dynamic {
17+
return fields.get(fieldName);
18+
}
19+
20+
public function removeField(fieldName:String):Void {
21+
fields.remove(fieldName);
22+
}
23+
24+
public function hasField(fieldName:String):Bool {
25+
return fields.exists(fieldName);
26+
}
27+
28+
public function invokeMethod(methodName:String, args:Array<Dynamic>):Dynamic {
29+
var method = fields.get(methodName);
30+
if (method != null && Reflect.isFunction(method)) {
31+
return Reflect.callMethod(this, method, args);
32+
}
33+
throw 'Method not found or is not callable: ' + methodName;
34+
}
35+
}
36+

0 commit comments

Comments
 (0)