diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-12-14 22:11:25 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-12-14 22:11:25 -0500 |
commit | 5ea5932661316e2504833951188eae4118f460f3 (patch) | |
tree | 3bb6886aa4e17e6c2dbafa4ddb9579d1f25a8d99 /src/SMAPI | |
parent | 16f986c51b9c87c2253a39fd771dcc24f7c43db4 (diff) | |
download | SMAPI-5ea5932661316e2504833951188eae4118f460f3.tar.gz SMAPI-5ea5932661316e2504833951188eae4118f460f3.tar.bz2 SMAPI-5ea5932661316e2504833951188eae4118f460f3.zip |
add asset propagation for bundles
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 84102828..97093636 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Xna.Framework.Graphics; +using Netcode; using StardewModdingAPI.Framework.Reflection; using StardewValley; using StardewValley.BellsAndWhistles; @@ -11,6 +12,7 @@ using StardewValley.Characters; using StardewValley.GameData.Movies; using StardewValley.Locations; using StardewValley.Menus; +using StardewValley.Network; using StardewValley.Objects; using StardewValley.Projectiles; using StardewValley.TerrainFeatures; @@ -227,6 +229,29 @@ namespace StardewModdingAPI.Metadata Game1.bigCraftablesInformation = content.Load<Dictionary<int, string>>(key); return true; + case "data\\bundles": // NetWorldState constructor + { + var bundles = this.Reflection.GetField<NetBundles>(Game1.netWorldState.Value, "bundles").GetValue(); + var rewards = this.Reflection.GetField<NetIntDictionary<bool, NetBool>>(Game1.netWorldState.Value, "bundleRewards").GetValue(); + foreach (var pair in content.Load<Dictionary<string, string>>(key)) + { + int bundleKey = int.Parse(pair.Key.Split('/')[1]); + int rewardsCount = pair.Value.Split('/')[2].Split(' ').Length; + + // add bundles + if (bundles.TryGetValue(bundleKey, out bool[] values)) + bundles.Remove(bundleKey); + else + values = new bool[0]; + bundles[bundleKey] = values.Concat(Enumerable.Repeat(false, rewardsCount - values.Length)).ToArray(); + + // add bundle rewards + if (!rewards.ContainsKey(bundleKey)) + rewards[bundleKey] = false; + } + } + break; + case "data\\clothinginformation": // Game1.LoadContent Game1.clothingInformation = content.Load<Dictionary<int, string>>(key); return true; |