public async void Initialize() { if (CreateHsvConfigsFolderIfYeetedByPlayer()) { await SaveConfig(Path.Combine(_hsvConfigsFolderPath, "HitScoreVisualizerConfig (default).json"), Configuration.Default).ConfigureAwait(false); var oldHsvConfigPath = Path.Combine(UnityGame.UserDataPath, "HitScoreVisualizerConfig.json"); if (File.Exists(oldHsvConfigPath)) { try { var destinationHsvConfigPath = Path.Combine(_hsvConfigsFolderPath, "HitScoreVisualizerConfig (imported).json"); File.Move(oldHsvConfigPath, destinationHsvConfigPath); _hsvConfig.ConfigFilePath = destinationHsvConfigPath; } catch (Exception e) { _siraLog.Warn(e); } } } if (_hsvConfig.ConfigFilePath == null) { return; } var fullPath = Path.Combine(_hsvConfigsFolderPath, _hsvConfig.ConfigFilePath); if (!File.Exists(fullPath)) { _hsvConfig.ConfigFilePath = null; return; } var userConfig = await LoadConfig(_hsvConfig.ConfigFilePath).ConfigureAwait(false); if (userConfig == null) { _siraLog.Warn($"Couldn't load userConfig at {fullPath}"); return; } var configFileInfo = new ConfigFileInfo(Path.GetFileNameWithoutExtension(_hsvConfig.ConfigFilePath), _hsvConfig.ConfigFilePath) { Configuration = userConfig, State = GetConfigState(userConfig, Path.GetFileNameWithoutExtension(_hsvConfig.ConfigFilePath), true) }; await SelectUserConfig(configFileInfo).ConfigureAwait(false); }
internal void UnpickConfig() { if (HasConfigCurrently) { UnityMainThreadTaskScheduler.Factory.StartNew(() => { if (customListTableData == null) { _siraLog.Warn($"{nameof(customListTableData)} is null."); return; } customListTableData.tableView.ClearSelection(); }); _configProvider.UnselectUserConfig(); NotifyPropertyChanged(nameof(HasConfigCurrently)); NotifyPropertyChanged(nameof(LoadedConfigText)); } }
public void SetPartEventList(List <PartEvents> partEventsList, SaberType saberType) { _partEventsList = partEventsList; _saberType = saberType; if (!_pluginConfig.EnableEvents) { return; } if (_gameCoreSceneSetupData == null) { return; } IsActive = true; _lastNoteTime = _beatmapData.CastChecked <BeatmapData>()?.GetLastNoteTime(); if (!_lastNoteTime.HasValue) { _logger.Warn("Couldn't get last note time. Certain level end events won't work"); } // OnSlice LevelEnded Combobreak _beatmapObjectManager.noteWasCutEvent += OnNoteCut; _beatmapObjectManager.noteWasMissedEvent += OnNoteMiss; // Sabers clashing if (_obstacleSaberSparkleEffectManager) { _obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent += SaberStartCollide; _obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent += SaberEndCollide; } // OnLevelFail _energyCounter.gameEnergyDidReach0Event += InvokeOnLevelFail; // MultiplierUp _scoreController.multiplierDidChangeEvent += MultiplayerDidChange; // Accuracy changed _scoreCounter.relativeScoreOrImmediateRankDidChangeEvent += ScoreChanged; // Combo changed _comboController.comboDidChangeEvent += OnComboDidChangeEvent; InvokeOnLevelStart(); }
private async Task <ModelComposition> LoadModelCompositionFromBundleAsync(AssetBundle bundle, string saberName) { if (string.IsNullOrWhiteSpace(saberName)) { _logger.Warn("SaberName needs to be unique and non-empty"); return(null); } var(loader, modelCreator) = GetLoaderAndCreatorForCurrentSystem(); var storeAsset = await loader.LoadStoreAssetFromBundleAsync(bundle, saberName); if (storeAsset == null) { return(null); } var model = modelCreator.GetComposition(storeAsset); return(model); }
public void Initialize() { var is360Level = _beatmapData.spawnRotationEventsCount > 0; var pos = is360Level ? _config.Chart360LevelPosition : _config.ChartStandardLevelPosition; var rot = is360Level ? Quaternion.Euler(_config.Chart360LevelRotation) : Quaternion.Euler(_config.ChartStandardLevelRotation); _floatingScreen = FloatingScreen.CreateFloatingScreen(_config.ChartSize, false, pos, rot, curvatureRadius: 0f, hasBackground: _config.HasBackground); _floatingScreen.SetRootViewController(this, AnimationType.None); _floatingScreen.name = nameof(SongChartVisualizer); if (_config.HasBackground) { var imageView = _floatingScreen.GetComponentInChildren <ImageView>(); imageView.material = _assetLoader.UINoGlowMaterial; imageView.color = _config.CombinedBackgroundColor; transform.SetParent(imageView.transform); } if (_audioTimeSyncController.songLength < 0) { _shouldNotRunTick = true; return; } // _siraLog.Debug($"There are {_beatmapData.beatmapObjectsData.Count(x => x.beatmapObjectType == BeatmapObjectType.Note)} notes"); // _siraLog.Debug($"There are {_beatmapData.beatmapLinesData.Count} lines"); _npsSections = GetNpsSections(_beatmapData); #if DEBUG for (var i = 0; i < _npsSections.Count; i++) { var npsInfos = _npsSections[i]; _siraLog.Debug($"Nps at section {i + 1}: {npsInfos.Nps} (from [{npsInfos.FromTime}] to [{npsInfos.ToTime}])"); } #endif _siraLog.Debug("Loading assetbundle.."); var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream("SongChartVisualizer.UI.linegraph")) { _assetBundle = AssetBundle.LoadFromStream(stream); } if (!_assetBundle) { _siraLog.Warn("Failed to load AssetBundle! The chart will not work properly.."); } else { var prefab = _assetBundle.LoadAsset <GameObject>("LineGraph"); var sprite = _assetBundle.LoadAsset <Sprite>("Circle"); var go = Instantiate(prefab, transform); go.transform.Translate(0.04f, 0, 0); _windowGraph = go.AddComponent <WindowGraph>(); _windowGraph.circleSprite = sprite; _windowGraph.transform.localScale /= 10; var npsValues = _npsSections.Select(info => info.Nps).ToList(); _windowGraph.ShowGraph(npsValues, false, linkColor: _config.LineColor); _currentSectionIdx = 0; _currentSection = _npsSections[_currentSectionIdx]; CreateSelfCursor(_config.PointerColor); if (_config.PeakWarning) { var highestValue = _npsSections.Max(info => info.Nps); _hardestSectionIdx = _npsSections.FindIndex(info => Math.Abs(info.Nps - highestValue) < 0.001f); PrepareWarningText(); FadeInTextIfNeeded(); } } }