From 875efc883ea4f0d34892710d0a70a64f25de7061 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 16 Apr 2024 04:05:44 +0900 Subject: [PATCH] improved test score --- .../mods/basegame/particles/musical_note.tga | 3 +++ .../gameactors/FixtureMechanicalTines.kt | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 assets/mods/basegame/particles/musical_note.tga diff --git a/assets/mods/basegame/particles/musical_note.tga b/assets/mods/basegame/particles/musical_note.tga new file mode 100644 index 000000000..fbce0ba25 --- /dev/null +++ b/assets/mods/basegame/particles/musical_note.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:362cd0d815986b570cfcc626f524c11cb994186e2c24f203ffc6813d8ab3a993 +size 1554 diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureMechanicalTines.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureMechanicalTines.kt index 5aeefc9d2..14a556dde 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureMechanicalTines.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureMechanicalTines.kt @@ -108,29 +108,45 @@ class FixtureMechanicalTines : Electric { end3( 0,12,28,31,36) + List(16*TICK_DIVISOR - 5) { 0L } private fun prel(n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): List { - return toPianoRoll( + return toPianoRoll2( 1L shl n1, 1L shl n2, 1L shl n3, 1L shl n4, 1L shl n5, 1L shl n3, 1L shl n4, 1L shl n5, 1L shl n1, 1L shl n2, 1L shl n3, 1L shl n4, 1L shl n5, 1L shl n3, 1L shl n4, 1L shl n5) } private fun end1(n1: Int, n2: Int, n3: Int, n4: Int, n5: Int, n6: Int, n7: Int, n8: Int, n9: Int): List { - return toPianoRoll( + return toPianoRoll2( 1L shl n1, 1L shl n2, 1L shl n3, 1L shl n4, 1L shl n5, 1L shl n6, 1L shl n5, 1L shl n4, 1L shl n5, 1L shl n7, 1L shl n8, 1L shl n7, 1L shl n8, 1L shl n9, 1L shl n8, 1L shl n9) } private fun end2(n1: Int, n2: Int, n3: Int, n4: Int, n5: Int, n6: Int, n7: Int, n8: Int, n9: Int): List { return toPianoRoll( - 1L shl n1, 1L shl n2, 1L shl n3, 1L shl n4, 1L shl n5, 1L shl n6, 1L shl n5, 1L shl n4, - 1L shl n5, 1L shl n4, 1L shl n3, 1L shl n4, 1L shl n7, 1L shl n8, 1L shl n9, 1L shl n7) + 1L shl n1 to TICK_DIVISOR, 1L shl n2 to TICK_DIVISOR+1, 1L shl n3 to TICK_DIVISOR+1, 1L shl n4 to TICK_DIVISOR+1, + 1L shl n5 to TICK_DIVISOR+1, 1L shl n6 to TICK_DIVISOR+2, 1L shl n5 to TICK_DIVISOR+2, 1L shl n4 to TICK_DIVISOR+2, + 1L shl n5 to TICK_DIVISOR+3, 1L shl n4 to TICK_DIVISOR+3, 1L shl n3 to TICK_DIVISOR+4, 1L shl n4 to TICK_DIVISOR+4, + 1L shl n7 to TICK_DIVISOR+6, 1L shl n8 to TICK_DIVISOR+8, 1L shl n9 to TICK_DIVISOR+16, 1L shl n7 to TICK_DIVISOR+32) } private fun end3(vararg ns: Int): List { return ns.map { 1L shl it } // arpeggiate } + private fun toPianoRoll(vararg noteAndLen: Pair): List { + val ret = MutableList(noteAndLen.sumOf { it.second }) { 0 } + var c = 0 + noteAndLen.forEach { (note, len) -> + ret[c] = note + c += len + } + return ret + } + private fun toPianoRoll(vararg notes: Long) = List(notes.size * TICK_DIVISOR) { if (it % TICK_DIVISOR == 0) notes[it / TICK_DIVISOR] else 0 } + + private fun toPianoRoll2(vararg notes: Long) = List(notes.size * TICK_DIVISOR) { + if (it % TICK_DIVISOR == 0) notes[it / TICK_DIVISOR] else 0 + }.let { it.subList(0, 1) + List(3) { 0L } + it.subList(1, it.size) } } } \ No newline at end of file