Compare commits

..

9 Commits

Author SHA1 Message Date
ivan tkachenko 8c660e803c add new track Peretasovka 2025-06-17 18:14:29 +03:00
ivan tkachenko 44e0db2ba9 add new track RiseAndShine 2025-06-17 17:38:19 +03:00
ivan tkachenko cb85bcb72c add new track GodMode 2025-06-17 16:26:44 +03:00
ivan tkachenko e2ae6873b8 port MuzikaGromche to ogg format 2025-06-17 16:23:01 +03:00
ivan tkachenko 0b2b8992a5 add support for wav and ogg/vorbis audio files 2025-06-17 16:20:54 +03:00
ivan tkachenko ceb11e36f4 organize code into functions, add some comments, add a null check 2025-06-17 16:10:46 +03:00
ivan tkachenko 566bc0993e convert indentation to tabs 2025-06-17 15:52:10 +03:00
ivan tkachenko df4418b040 Add README, icon and manifest from Thunderstore bundle 2025-06-16 21:43:58 +03:00
ivan tkachenko ec18c12aa8 add more things to gitignore 2025-06-16 21:43:10 +03:00
16 changed files with 227 additions and 134 deletions

3
.gitignore vendored
View File

@ -5,4 +5,7 @@ riderModule.iml
/_ReSharper.Caches/
.idea/
*.dll
.vs/
dist/
MuzikaGromche.sln.DotSettings.user
MuzikaGromche.zip

View File

@ -1 +1,3 @@
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text

BIN
Assets/GodModeLoop.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/GodModeStart.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/MuzikaGromcheLoop.mp3 (Stored with Git LFS)

Binary file not shown.

BIN
Assets/MuzikaGromcheLoop.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/MuzikaGromcheStart.mp3 (Stored with Git LFS)

Binary file not shown.

BIN
Assets/MuzikaGromcheStart.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/PeretasovkaLoop.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/PeretasovkaStart.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/RiseAndShineLoop.ogg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/RiseAndShineStart.ogg (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -19,6 +19,7 @@ namespace MuzikaGromche
Name = "MuzikaGromche",
WindUpTimer = 46.3f,
Bpm = 130f,
AudioType = AudioType.OGGVORBIS,
},
new Track
{
@ -49,20 +50,89 @@ namespace MuzikaGromche
Name = "Durochka",
WindUpTimer = 37f,
Bpm = 130f,
}
},
new Track
{
Name = "GodMode",
WindUpTimer = 40.38f,
Bpm = 108f,
AudioType = AudioType.OGGVORBIS,
},
new Track
{
Name = "RiseAndShine",
WindUpTimer = 59.87f,
Bpm = 137.36f,
AudioType = AudioType.OGGVORBIS,
},
new Track
{
Name = "Peretasovka",
WindUpTimer = 59.04f,
Bpm = 130f,
AudioType = AudioType.OGGVORBIS,
},
];
public static Coroutine JesterLightSwitching;
public static Track CurrentTrack;
public static void StartLightSwitching(MonoBehaviour __instance)
{
StopLightSwitching(__instance);
JesterLightSwitching = __instance.StartCoroutine(rotateColors());
}
public static void StopLightSwitching(MonoBehaviour __instance)
{
if (JesterLightSwitching != null) {
__instance.StopCoroutine(JesterLightSwitching);
JesterLightSwitching = null;
}
}
public static void SetLightColor(Color color)
{
foreach (var light in RoundManager.Instance.allPoweredLights)
{
light.color = color;
}
}
public static void ResetLightColor()
{
SetLightColor(Color.white);
}
// TODO: Move to Track class to make them customizable per-song
static List<Color> colors = [Color.magenta, Color.cyan, Color.green, Color.yellow];
public static IEnumerator rotateColors()
{
Debug.Log("Starting color rotation");
var i = 0;
while (true)
{
var color = colors[i];
Debug.Log("Chose color " + color);
SetLightColor(color);
i = (i + 1) % colors.Count;
if (CurrentTrack != null) {
yield return new WaitForSeconds(60f / CurrentTrack.Bpm);
} else {
yield break;
}
}
}
private void Awake()
{
string text = Info.Location.TrimEnd((PluginInfo.PLUGIN_NAME + ".dll").ToCharArray());
UnityWebRequest[] requests = new UnityWebRequest[Tracks.Length * 2];
for (int i = 0; i < Tracks.Length; i++) {
Track track = Tracks[i];
requests[i * 2] = UnityWebRequestMultimedia.GetAudioClip($"File://{text}{track.Name}Start.mp3", AudioType.MPEG);
requests[i * 2 + 1] = UnityWebRequestMultimedia.GetAudioClip($"File://{text}{track.Name}Loop.mp3", AudioType.MPEG);
requests[i * 2] = UnityWebRequestMultimedia.GetAudioClip($"File://{text}{track.FileNameStart}", track.AudioType);
requests[i * 2 + 1] = UnityWebRequestMultimedia.GetAudioClip($"File://{text}{track.FileNameLoop}", track.AudioType);
requests[i * 2].SendWebRequest();
requests[i * 2 + 1].SendWebRequest();
}
@ -71,8 +141,9 @@ namespace MuzikaGromche
if (requests.All(request => request.result == UnityWebRequest.Result.Success)) {
for (int i = 0; i < Tracks.Length; i++) {
Tracks[i].LoadedStart = DownloadHandlerAudioClip.GetContent(requests[i * 2]);
Tracks[i].LoadedLoop = DownloadHandlerAudioClip.GetContent(requests[i * 2 + 1]);
Track track = Tracks[i];
track.LoadedStart = DownloadHandlerAudioClip.GetContent(requests[i * 2]);
track.LoadedLoop = DownloadHandlerAudioClip.GetContent(requests[i * 2 + 1]);
}
new Harmony(PluginInfo.PLUGIN_NAME).PatchAll(typeof(JesterPatch));
} else {
@ -84,10 +155,30 @@ namespace MuzikaGromche
public class Track
{
public string Name;
// Wind-up time can be shorter than the Start audio track, so that
// the "pop" effect can be baked in the Start audio and kept away
// from the looped part.
public float WindUpTimer;
// BPM for light switching in sync with the music. There is no offset,
// so the Loop track should start precisely on a beat.
public float Bpm;
// MPEG is basically mp3, and it can produce gaps at the start.
// WAV is OK, but takes a lot of space. Try OGGVORBIS instead.
public AudioType AudioType = AudioType.MPEG;
public AudioClip LoadedStart;
public AudioClip LoadedLoop;
public string FileNameStart => $"{Name}Start.{ext}";
public string FileNameLoop => $"{Name}Loop.{ext}";
private string ext => AudioType switch
{
AudioType.MPEG => "mp3",
AudioType.WAV => "wav",
AudioType.OGGVORBIS => "ogg",
_ => "",
};
}
[HarmonyPatch(typeof(JesterAI))]
@ -107,27 +198,6 @@ namespace MuzikaGromche
}
}
static List<Color> colors = [Color.magenta, Color.cyan, Color.green, Color.yellow];
public static IEnumerator rotateColors()
{
Debug.Log("Starting color rotation");
var i = 0;
while (true)
{
var color = colors[i];
Debug.Log("Chose color " + color);
foreach (var light in RoundManager.Instance.allPoweredLights)
{
light.color = color;
}
i += 1;
if (i >= colors.Count) i = 0;
yield return new WaitForSeconds(60f / Plugin.CurrentTrack.Bpm);
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void DoNotStopTheMusic(JesterAI __instance, State __state)
@ -170,24 +240,13 @@ namespace MuzikaGromche
if (__instance.currentBehaviourStateIndex is 2 && __state.prevStateindex != 2)
{
__instance.creatureVoice.Stop();
if (Plugin.JesterLightSwitching != null) {
__instance.StopCoroutine(Plugin.JesterLightSwitching);
Plugin.JesterLightSwitching = null;
}
Plugin.JesterLightSwitching = __instance.StartCoroutine(rotateColors());
Plugin.StartLightSwitching(__instance);
}
if (__instance.currentBehaviourStateIndex != 2 && __state.prevStateindex == 2)
{
if (Plugin.JesterLightSwitching != null) {
__instance.StopCoroutine(Plugin.JesterLightSwitching);
Plugin.JesterLightSwitching = null;
}
foreach (var light in RoundManager.Instance.allPoweredLights)
{
light.color = Color.white;
}
Plugin.StopLightSwitching(__instance);
Plugin.ResetLightColor();
}
if (__instance.currentBehaviourStateIndex is 2 && !__instance.creatureVoice.isPlaying)

1
README.md Normal file
View File

@ -0,0 +1 @@
Adds some content to your reverse teleports on Titan

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

10
manifest.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "MuzikaGromche",
"version_number": "13.37.6",
"author": "Oflor",
"description": "Glaza zakryvaj",
"website_url": "https://git.vilunov.me/nikita/muzika-gromche",
"dependencies": [
"BepInEx-BepInExPack-5.4.2100"
]
}