diff --git a/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs b/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs index 5e6499d4c..6b5efb428 100644 --- a/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs +++ b/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs @@ -356,7 +356,7 @@ namespace HeavenStudio if (game == null) { Debug.LogWarning($"Unknown game {gameName} found in remix.json! Adding game..."); - game = new Minigames.Minigame(gameName, DisplayName(gameName) + " \n[inferred from remix.json]", "", false, true, new List()); + game = new Minigames.Minigame(gameName, DisplayName(gameName) + " \n[inferred from remix.json]", "", false, false, new List(), inferred: true); EventCaller.instance.minigames.Add(game); if (Editor.Editor.instance != null) Editor.Editor.instance.AddIcon(game); diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 0d7aafb1e..7c68ea783 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -709,18 +709,13 @@ namespace HeavenStudio { if (gameInfo.fxOnly) { - var gameEntities = Beatmap.entities.FindAll(c => { - var gameName = c.datamodel.Split(0); - var newGameInfo = GetGameInfo(gameName); - if (newGameInfo == null) - return false; - else - return !newGameInfo.fxOnly; - }).ToList(); - if (gameEntities.Count != 0) - name = gameEntities[0].datamodel.Split(0); - else - name = "noGame"; + var gameInfos = Beatmap.entities + .Select(x => x.datamodel.Split(0)) + .Select(x => GetGameInfo(x)) + .Where(x => x != null) + .Where(x => !x.fxOnly) + .Select(x => x.LoadableName); + name = gameInfos.FirstOrDefault() ?? "noGame"; } else { @@ -729,6 +724,7 @@ namespace HeavenStudio //game is packed in an assetbundle, load from that instead return gameInfo.GetCommonAssetBundle().LoadAsset(name); } + name = gameInfo.LoadableName; } } return Resources.Load($"Games/{name}"); diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index b34445ba1..d349a301d 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -33,11 +33,13 @@ namespace HeavenStudio public string defaultLocale = "en"; public string wantAssetBundle = ""; public List supportedLocales; + public bool inferred; public bool usesAssetBundle => (wantAssetBundle != ""); public bool hasLocales => (supportedLocales.Count > 0); public bool AssetsLoaded => (((hasLocales && localeLoaded && currentLoadedLocale == defaultLocale) || (!hasLocales)) && commonLoaded); public bool SequencesPreloaded => soundSequences != null; + public string LoadableName => inferred ? "noGame" : name; private AssetBundle bundleCommon = null; private bool commonLoaded = false; @@ -55,7 +57,7 @@ namespace HeavenStudio set => soundSequences = value; } - public Minigame(string name, string displayName, string color, bool threeD, bool fxOnly, List actions, List tags = null, string assetBundle = "", string defaultLocale = "en", List supportedLocales = null) + public Minigame(string name, string displayName, string color, bool threeD, bool fxOnly, List actions, List tags = null, string assetBundle = "", string defaultLocale = "en", List supportedLocales = null, bool inferred = false) { this.name = name; this.displayName = displayName; @@ -68,6 +70,7 @@ namespace HeavenStudio this.wantAssetBundle = assetBundle; this.defaultLocale = defaultLocale; this.supportedLocales = supportedLocales ?? new List(); + this.inferred = inferred; } public AssetBundle GetLocalizedAssetBundle()