From 1240cb21024c3b715a6dacb2bec170a588a08791 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 1 Sep 2021 20:58:21 -0400 Subject: fix translations not initialized for temporary content packs --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/SMAPI/Framework/ModLoading/ModMetadata.cs') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 0ace084f..9e6bc61f 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -83,6 +83,9 @@ namespace StardewModdingAPI.Framework.ModLoading /// public bool IsContentPack => this.Manifest?.ContentPackFor != null; + /// The fake content packs created by this mod, if any. + public ISet> FakeContentPacks { get; } = new HashSet>(); + /********* ** Public methods @@ -244,6 +247,21 @@ namespace StardewModdingAPI.Framework.ModLoading return Path.Combine(rootFolderName, this.RelativeDirectoryPath); } + /// Get the currently live fake content packs created by this mod. + public IEnumerable GetFakeContentPacks() + { + foreach (var reference in this.FakeContentPacks.ToArray()) + { + if (!reference.TryGetTarget(out ContentPack pack)) + { + this.FakeContentPacks.Remove(reference); + continue; + } + + yield return pack; + } + } + /********* ** Private methods -- cgit