diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 254b847..b6de3df 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -1,6 +1,8 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography; using BepInEx; using HarmonyLib; using UnityEngine; @@ -129,7 +131,17 @@ namespace MuzikaGromche { // ...and start modded music var seed = RoundManager.Instance.dungeonGenerator.Generator.ChosenSeed; - var trackId = seed % Plugin.Tracks.Length; + var sha = SHA256.Create(); + var hash = sha.ComputeHash(BitConverter.GetBytes(seed)); + var trackId = 0; + foreach (var t in hash) + { + // modulus division on byte array + trackId *= 256 % Plugin.Tracks.Length; + trackId %= Plugin.Tracks.Length; + trackId += t % Plugin.Tracks.Length; + trackId %= Plugin.Tracks.Length; + } Debug.Log($"Seed is {seed}, chosen track is {trackId} out of {Plugin.Tracks.Length} tracks"); Plugin.CurrentTrack = Plugin.Tracks[trackId]; __instance.popUpTimer = Plugin.CurrentTrack.WindUpTimer;