private void load() { maskingContainer.BorderColour = colours.Yellow; ruleset = rulesets.GetRuleset(Item.RulesetID); var rulesetInstance = ruleset?.CreateInstance(); requiredMods = Item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).ToArray(); }
public IEnumerable <DifficultyAttributes> CalculateAllLegacyCombinations(CancellationToken cancellationToken = default) { var rulesetInstance = ruleset.CreateInstance(); foreach (var combination in CreateDifficultyAdjustmentModCombinations()) { Mod classicMod = rulesetInstance.CreateAllMods().SingleOrDefault(m => m is ModClassic); var finalCombination = ModUtils.FlattenMod(combination); if (classicMod != null) { finalCombination = finalCombination.Append(classicMod); } yield return(Calculate(finalCombination.ToArray(), cancellationToken)); } }
public virtual IBeatmap GetPlayableBeatmap(IRulesetInfo ruleset, IReadOnlyList <Mod> mods, CancellationToken token) { var rulesetInstance = ruleset.CreateInstance(); if (rulesetInstance == null) { throw new RulesetLoadException("Creating ruleset instance failed when attempting to create playable beatmap."); } IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance); // Check if the beatmap can be converted if (Beatmap.HitObjects.Count > 0 && !converter.CanConvert()) { throw new BeatmapInvalidForRulesetException($"{nameof(Beatmaps.Beatmap)} can not be converted for the ruleset (ruleset: {ruleset.InstantiationInfo}, converter: {converter})."); } // Apply conversion mods foreach (var mod in mods.OfType <IApplicableToBeatmapConverter>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmapConverter(converter); } // Convert IBeatmap converted = converter.Convert(token); // Apply conversion mods to the result foreach (var mod in mods.OfType <IApplicableAfterBeatmapConversion>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmap(converted); } // Apply difficulty mods if (mods.Any(m => m is IApplicableToDifficulty)) { foreach (var mod in mods.OfType <IApplicableToDifficulty>()) { token.ThrowIfCancellationRequested(); mod.ApplyToDifficulty(converted.Difficulty); } } IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted); foreach (var mod in mods.OfType <IApplicableToBeatmapProcessor>()) { mod.ApplyToBeatmapProcessor(processor); } processor?.PreProcess(); // Compute default values for hitobjects, including creating nested hitobjects in-case they're needed foreach (var obj in converted.HitObjects) { token.ThrowIfCancellationRequested(); obj.ApplyDefaults(converted.ControlPointInfo, converted.Difficulty, token); } foreach (var mod in mods.OfType <IApplicableToHitObject>()) { foreach (var obj in converted.HitObjects) { token.ThrowIfCancellationRequested(); mod.ApplyToHitObject(obj); } } processor?.PostProcess(); foreach (var mod in mods.OfType <IApplicableToBeatmap>()) { token.ThrowIfCancellationRequested(); mod.ApplyToBeatmap(converted); } return(converted); }