public Task GetSongsListAsync(bool useCustomMenuSongs) => Task.Run(() => { if (!Directory.Exists(Path.Combine(UserDataPath, MenuSongsPath))) { Directory.CreateDirectory(Path.Combine(UserDataPath, MenuSongsPath)); } if (useCustomMenuSongs && this.GetAllCustomMenuSongsAsync().Any()) { this.filePathPicker = new RandomObjectPicker <string>(this.GetAllCustomMenuSongsAsync().ToArray(), 0f); } else { this.filePathPicker = new RandomObjectPicker <string>(this.GetAllCustomSongsAsync().ToArray(), 0f); } this._overrideCustomSongsList = !this.filePathPicker.GetField <string[], RandomObjectPicker <string> >("_objects").Any(); });
public static void OverrideEnvironmentScene() { if (overrideMode == EnvOverrideMode.Off) { SetSceneName(defaultSceneInfo, DEFAULT); SetSceneName(niceSceneInfo, NICE); SetSceneName(bigMirrorSceneInfo, BIGMIRROR); SetSceneName(triangleSceneInfo, TRIANGLE); SetSceneName(kdaSceneInfo, KDA); } else { string sceneName = ""; switch (overrideMode) { case EnvOverrideMode.Default: sceneName = DEFAULT; break; case EnvOverrideMode.Nice: sceneName = NICE; break; case EnvOverrideMode.BigMirror: sceneName = BIGMIRROR; break; case EnvOverrideMode.Triangle: sceneName = TRIANGLE; break; case EnvOverrideMode.KDA: sceneName = KDA; break; case EnvOverrideMode.Random: sceneName = new RandomObjectPicker <string>(new string[] { DEFAULT, NICE, BIGMIRROR, TRIANGLE, KDA }, 0).PickRandomObject(); break; } SetSceneName(defaultSceneInfo, sceneName); SetSceneName(niceSceneInfo, sceneName); SetSceneName(bigMirrorSceneInfo, sceneName); SetSceneName(triangleSceneInfo, sceneName); SetSceneName(kdaSceneInfo, sceneName); } }
private async Task Init() { _siraLog.Debug("Loading music."); var badMusic = new List <FileInfo>(); var stopwatch = Stopwatch.StartNew(); var loadedCustoms = new List <AudioContainer>(); foreach (var musicPath in _config.EnabledMusicFiles) { if (!musicPath.Exists || musicPath.Extension != ".ogg") { badMusic.Add(musicPath); continue; } try { _siraLog.Debug($"Loading {musicPath.FullName}"); AudioClip audioClip = await _cachedMediaAsyncLoader.LoadAudioClipAsync(musicPath.FullName, _cancellationTokenSource.Token); var name = musicPath.Name.Remove(musicPath.Name.IndexOf(musicPath.Extension)); var maybeImage = musicPath.Directory.EnumerateFiles().FirstOrDefault(ef => ef.Name.Remove(ef.Name.IndexOf(ef.Extension)) == name && (ef.Extension == ".png" || ef.Extension == ".jpg")); Texture2D?texHolder = null; if (maybeImage != null && maybeImage.Exists) { texHolder = (await _cachedMediaAsyncLoader.LoadSpriteAsync(maybeImage !.FullName, _cancellationTokenSource.Token)).texture; } loadedCustoms.Add(new AudioContainer(name, audioClip, texHolder)); } catch (Exception e) { _siraLog.Error(e.Message); badMusic.Add(musicPath); } } foreach (var bad in badMusic) { // If any of the music files failed to load or do not exist, remove them. _config.EnabledMusicFiles.Remove(bad); } stopwatch.Stop(); _siraLog.Debug($"Finished Loading Music in {stopwatch.Elapsed} seconds"); _randomObjectPicker = new RandomObjectPicker <AudioContainer>(loadedCustoms.ToArray(), 0.07f); Loaded?.Invoke(); }
public void Tick() { if (!_didInit) { if (_beatmapLevelsModel.customLevelPackCollection != null) { _didInit = true; List <IPreviewBeatmapLevel> levels = new List <IPreviewBeatmapLevel>(); var packs = _beatmapLevelsModel.customLevelPackCollection.beatmapLevelPacks; foreach (var pack in packs) { foreach (var level in pack.beatmapLevelCollection.beatmapLevels) { levels.Add(level); } } _randomObjectPicker = new RandomObjectPicker <IPreviewBeatmapLevel>(levels.ToArray(), 2.5f); Loaded?.Invoke(); } } }
private static bool Prefix(NoteCutSoundEffectManager __instance, BeatmapObjectData beatmapObjectData, ref AudioTimeSyncController ____audioTimeSyncController, ref float ____prevNoteATime, ref float ____prevNoteBTime, ref NoteCutSoundEffect ____prevNoteASoundEffect, ref NoteCutSoundEffect ____prevNoteBSoundEffect, ref NoteCutSoundEffect.Pool ____noteCutSoundEffectPool, ref PlayerController ____playerController, ref float ____beatAlignOffset, ref RandomObjectPicker <AudioClip> ____randomShortCutSoundPicker, ref RandomObjectPicker <AudioClip> ____randomLongCutSoundPicker, ref BeatmapObjectSpawnController ____beatmapObjectSpawnController) { if (beatmapObjectData.beatmapObjectType != BeatmapObjectType.Note) { return(false); } NoteData noteData = (NoteData)beatmapObjectData; float timeScale = ____audioTimeSyncController.timeScale; if (noteData.noteType != NoteType.NoteA && noteData.noteType != NoteType.NoteB) { return(false); } if ((noteData.noteType == NoteType.NoteA && ((noteData.time > ____prevNoteATime) && noteData.time < ____prevNoteATime + 0.001f)) || (noteData.noteType == NoteType.NoteB && ((noteData.time > ____prevNoteBTime) && noteData.time < ____prevNoteBTime + 0.001f))) { return(false); } bool flag = false; if (noteData.time < ____prevNoteATime + 0.001f || noteData.time < ____prevNoteBTime + 0.001f) { if (noteData.noteType == NoteType.NoteA && ____prevNoteBSoundEffect.enabled) { ____prevNoteBSoundEffect.volumeMultiplier = 0.9f; flag = true; } else if (noteData.noteType == NoteType.NoteB && ____prevNoteASoundEffect.enabled) { ____prevNoteASoundEffect.volumeMultiplier = 0.9f; flag = true; } } NoteCutSoundEffect noteCutSoundEffect = ____noteCutSoundEffectPool.Spawn(); noteCutSoundEffect.transform.SetPositionAndRotation(__instance.transform.localPosition, Quaternion.identity); noteCutSoundEffect.didFinishEvent += __instance.HandleCutSoundEffectDidFinish; Saber saber = null; if (noteData.noteType == NoteType.NoteA) { ____prevNoteATime = noteData.time; saber = ____playerController.leftSaber; ____prevNoteASoundEffect = noteCutSoundEffect; } else if (noteData.noteType == NoteType.NoteB) { ____prevNoteBTime = noteData.time; saber = ____playerController.rightSaber; ____prevNoteBSoundEffect = noteCutSoundEffect; } if (noteData.noteType == NoteType.NoteA || noteData.noteType == NoteType.NoteB) { bool flag2 = noteData.timeToPrevBasicNote < ____beatAlignOffset; AudioClip audioClip = flag2 ? ____randomShortCutSoundPicker.PickRandomObject() : ____randomLongCutSoundPicker.PickRandomObject(); float volumeMultiplier = 1f; if (flag) { volumeMultiplier = 0.9f; } else if (flag2) { volumeMultiplier = 0.9f; } noteCutSoundEffect.Init(audioClip, (double)(noteData.time / timeScale) + ____audioTimeSyncController.dspTimeOffset, ____beatAlignOffset, ____beatmapObjectSpawnController.missedTimeOffset, noteData.timeToPrevBasicNote / timeScale, noteData.timeToNextBasicNote / timeScale, saber, noteData, __instance.handleWrongSaberTypeAsGood, volumeMultiplier, __instance.useTestAudioClip); } HashSet <NoteCutSoundEffect> activeItems = ____noteCutSoundEffectPool.activeItems; NoteCutSoundEffect noteCutSoundEffect2 = null; float num = float.MaxValue; foreach (NoteCutSoundEffect noteCutSoundEffect3 in activeItems) { if (noteCutSoundEffect3.noteData.time < num) { num = noteCutSoundEffect3.noteData.time; noteCutSoundEffect2 = noteCutSoundEffect3; } } if (activeItems.Count > 64) { noteCutSoundEffect2.StopPlayingAndFinish(); } return(false); }
private void Awake() { _randomObjectPicker = new RandomObjectPicker <AudioClip>(_audioClips, 0.1f); }
static FireworksItemControllerOverride() { randomSparkColorPicker = new RandomObjectPicker <Color>(sparkColors, 0.1f); randomLightColorPicker = new RandomObjectPicker <Color>(lightColors, 0.1f); }