From 0b27f50804f9c543507571fd6e58cf1aac6aecf3 Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Thu, 28 Sep 2023 10:47:22 -0400 Subject: [PATCH 01/10] Working building. --- AdventureBackpacks/AdventureBackpacks.cs | 2 +- AdventureBackpacks/AdventureBackpacks.csproj | 26 +++++++++---------- AdventureBackpacks/App.config | 2 +- AdventureBackpacks/Properties/AssemblyInfo.cs | 4 +-- CHANGELOG.md | 3 +++ manifest.json | 4 +-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index 6c0f1a8..dfd93fc 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -28,7 +28,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo //Module Constants private const string _pluginId = "vapok.mods.adventurebackpacks"; private const string _displayName = "Adventure Backpacks"; - private const string _version = "1.6.26"; + private const string _version = "1.6.27"; //Interface Properties public string PluginId => _pluginId; diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index d536b90..e167f08 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -36,22 +36,22 @@ - ..\..\References\BepInEx\5.4.2101\BepInEx\core\0Harmony.dll + ..\..\References\BepInEx\5.4.2200\BepInEx\core\0Harmony.dll - ..\..\References\Valheim\0.217.14\assembly_guiutils_publicized.dll + ..\..\References\Valheim\0.217.20\assembly_guiutils_publicized.dll - ..\..\References\Valheim\0.217.14\assembly_utils_publicized.dll + ..\..\References\Valheim\0.217.20\assembly_utils_publicized.dll - ..\..\References\Valheim\0.217.14\assembly_valheim_publicized.dll + ..\..\References\Valheim\0.217.20\assembly_valheim_publicized.dll - ..\..\References\BepInEx\5.4.2101\BepInEx\core\BepInEx.dll + ..\..\References\BepInEx\5.4.2200\BepInEx\core\BepInEx.dll - ..\..\References\BepInEx\5.4.2101\BepInEx\core\BepInEx.Harmony.dll + ..\..\References\BepInEx\5.4.2200\BepInEx\core\BepInEx.Harmony.dll ..\..\References\ServerSync\ServerSync.dll @@ -62,25 +62,25 @@ - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.AnimationModule.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.AnimationModule.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.AssetBundleModule.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.AssetBundleModule.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.CoreModule.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.CoreModule.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.InputLegacyModule.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.InputLegacyModule.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.PhysicsModule.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.PhysicsModule.dll - ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.UI.dll + ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.UI.dll ..\packages\Vapok.Valheim.Common.1.3.21714\lib\net462\Vapok.Valheim.Common.dll diff --git a/AdventureBackpacks/App.config b/AdventureBackpacks/App.config index abc2200..5de7e84 100644 --- a/AdventureBackpacks/App.config +++ b/AdventureBackpacks/App.config @@ -7,7 +7,7 @@ - + diff --git a/AdventureBackpacks/Properties/AssemblyInfo.cs b/AdventureBackpacks/Properties/AssemblyInfo.cs index e01566e..8f35b0e 100644 --- a/AdventureBackpacks/Properties/AssemblyInfo.cs +++ b/AdventureBackpacks/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.26.0")] -[assembly: AssemblyFileVersion("1.6.26.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.27.0")] +[assembly: AssemblyFileVersion("1.6.27.0")] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a3e86c0..d6c73de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.6.27 - 0.217.19 Update +* Updates for Valheim 0.217.19 + # 1.6.26 - Hotfix to address Critical Crashing Bug * Turns out adding a container on Players, make them interactable which crashes the player object. * Disabled the interaction function on containers when the container is Player(Clone) diff --git a/manifest.json b/manifest.json index 8aa8dbe..eda077e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "name": "AdventureBackpacks", - "version_number": "1.6.26", + "version_number": "1.6.27", "website_url": "https://github.com/Vapok/AdventureBackpacks", "description": "A Valheim Mod to add a catalogue of Adventuring Backpacks to the Game. These packs will grow and become more useful as the game progresses.", "dependencies": [ - "denikson-BepInExPack_Valheim-5.4.2102" + "denikson-BepInExPack_Valheim-5.4.2200" ] } \ No newline at end of file From b16fea74e1a9383512c122b00f714b35d822d336 Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Sat, 7 Oct 2023 12:35:04 -0400 Subject: [PATCH 02/10] Updates for 0.217.24 --- AdventureBackpacks/AdventureBackpacks.csproj | 6 +++--- CHANGELOG.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index e167f08..e494f24 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -39,13 +39,13 @@ ..\..\References\BepInEx\5.4.2200\BepInEx\core\0Harmony.dll - ..\..\References\Valheim\0.217.20\assembly_guiutils_publicized.dll + ..\..\References\Valheim\0.217.24\assembly_guiutils_publicized.dll - ..\..\References\Valheim\0.217.20\assembly_utils_publicized.dll + ..\..\References\Valheim\0.217.24\assembly_utils_publicized.dll - ..\..\References\Valheim\0.217.20\assembly_valheim_publicized.dll + ..\..\References\Valheim\0.217.24\assembly_valheim_publicized.dll ..\..\References\BepInEx\5.4.2200\BepInEx\core\BepInEx.dll diff --git a/CHANGELOG.md b/CHANGELOG.md index d6c73de..2fbb1c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# 1.6.27 - 0.217.19 Update -* Updates for Valheim 0.217.19 +# 1.6.27 - 0.217.24 Update +* Updates for Valheim 0.217.24 # 1.6.26 - Hotfix to address Critical Crashing Bug * Turns out adding a container on Players, make them interactable which crashes the player object. From 1b25fc810c14db1cb76c952dd2e9cac8bf9f4a20 Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Fri, 29 Sep 2023 00:48:02 -0400 Subject: [PATCH 03/10] Fixing the backpack container bug and release 1.6.27 # Conflicts: # CHANGELOG.md --- .../Components/BackpackComponent.cs | 9 +++++++++ AdventureBackpacks/Extensions/PlayerExtensions.cs | 14 ++++++++++++++ AdventureBackpacks/Patches/Humanoid.cs | 8 +------- AdventureBackpacks/Patches/InventoryGui.cs | 15 ++++++++++++++- CHANGELOG.md | 11 ++++++++++- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/AdventureBackpacks/Components/BackpackComponent.cs b/AdventureBackpacks/Components/BackpackComponent.cs index a8da656..db69122 100644 --- a/AdventureBackpacks/Components/BackpackComponent.cs +++ b/AdventureBackpacks/Components/BackpackComponent.cs @@ -28,6 +28,15 @@ public Inventory GetInventory() return _backpackInventory; } + public void UpdateContainerSizing(Container backpackContainer) + { + var inventory = GetInventory(); + backpackContainer.m_inventory = inventory; + backpackContainer.m_width = inventory.m_width; + backpackContainer.m_height = inventory.m_height; + backpackContainer.m_bkg = Item.m_shared.m_icons[0]; + } + public string Serialize() { _log.Debug($"[Serialize()] Starting.."); diff --git a/AdventureBackpacks/Extensions/PlayerExtensions.cs b/AdventureBackpacks/Extensions/PlayerExtensions.cs index 20eaf0a..4c8695e 100644 --- a/AdventureBackpacks/Extensions/PlayerExtensions.cs +++ b/AdventureBackpacks/Extensions/PlayerExtensions.cs @@ -18,6 +18,20 @@ public static bool IsBackpackEquipped(this Player player) return player.m_shoulderItem.IsBackpack(); } + public static bool IsThisBackpackEquipped(this Player player, ItemDrop.ItemData itemData ) + { + if (player == null || player.GetInventory() == null) + return false; + + if (player.m_shoulderItem == null) + return false; + + if (!player.m_shoulderItem.IsBackpack()) + return false; + + return player.m_shoulderItem.Equals(itemData); + } + public static BackpackComponent GetEquippedBackpack(this Player player) { if (player == null || player.GetInventory() == null) diff --git a/AdventureBackpacks/Patches/Humanoid.cs b/AdventureBackpacks/Patches/Humanoid.cs index 70f2df7..969f31d 100644 --- a/AdventureBackpacks/Patches/Humanoid.cs +++ b/AdventureBackpacks/Patches/Humanoid.cs @@ -140,14 +140,8 @@ static void Postfix(ItemDrop.ItemData __0, bool __result) InventoryGuiPatches.BackpackEquipped = true; var backpackContainer = player.gameObject.GetComponent(); - var backpack = item.Data().GetOrCreate(); - - var inventory = backpack.GetInventory(); - backpackContainer.m_inventory = inventory; - backpackContainer.m_width = inventory.m_width; - backpackContainer.m_height = inventory.m_height; - backpackContainer.m_bkg = backpack.Item.m_shared.m_icons[0]; + backpack.UpdateContainerSizing(backpackContainer); } } } diff --git a/AdventureBackpacks/Patches/InventoryGui.cs b/AdventureBackpacks/Patches/InventoryGui.cs index 08bcf7f..7521efe 100644 --- a/AdventureBackpacks/Patches/InventoryGui.cs +++ b/AdventureBackpacks/Patches/InventoryGui.cs @@ -26,11 +26,23 @@ static class InventoryGuiDoCraftingPrefix [UsedImplicitly] static void Postfix(InventoryGui __instance) { + if ( Player.m_localPlayer == null) + return; + var player = Player.m_localPlayer; + if (__instance.m_craftUpgradeItem != null && __instance.m_craftUpgradeItem.IsBackpack()) { var backpack = __instance.m_craftUpgradeItem.Data().Get(); + if (backpack == null) + return; + + var backpackContainer = player.gameObject.GetComponent(); backpack?.Load(); - Player.m_localPlayer.UpdateEquipmentStatusEffects(); + + if (player.IsThisBackpackEquipped(backpack.Item)) + backpack?.UpdateContainerSizing(backpackContainer); + + player.UpdateEquipmentStatusEffects(); } } } @@ -447,6 +459,7 @@ CodeInstruction FindInstructionWithLabel(List codeInstructions, AdventureBackpacks.Log.Warning($" patchedShowBackpackMethod {patchedShowBackpackMethod}"); AdventureBackpacks.Log.Warning($" patchedDetectInputHideMethod {patchedDetectInputHideMethod}"); AdventureBackpacks.Log.Warning($" patchedDetectInputShowMethod {patchedDetectInputShowMethod}"); + AdventureBackpacks.Log.Error($"Please inform Mod Author."); Thread.Sleep(5000); } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fbb1c4..886e5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # 1.6.27 - 0.217.24 Update * Updates for Valheim 0.217.24 +# 1.6.27 - Bug Fix +* Fixed: In a rare case, when a bag is upgraded, and then you die before unequipping your bag, it can potentially lose the contents of the backpack. + * This is fixed in this version. + # 1.6.26 - Hotfix to address Critical Crashing Bug * Turns out adding a container on Players, make them interactable which crashes the player object. * Disabled the interaction function on containers when the container is Player(Clone) @@ -12,6 +16,9 @@ * Craft From Containers needs 1 update in order to work (They need to not check for Piece component) * Fixes a Compatibility issue with Valheim+ Where Transpilers were fighting for attention. +
+Changelog History (click to expand) + # 1.6.24 - Updates and Compatibilities * Fixing a Player Load error on Startup when wearing a backpack. @@ -271,4 +278,6 @@ * This is a full refactor and completely re-writen version of JotunnBackpacks. * Adventure Backpacks will seamlessly convert Jotunn Backpacks into new Adventure Backpacks. * As such, Jotunn Backpacks is incompatible with Adventure Backpacks - * Utilizing the same Prefab Name, to get technical. \ No newline at end of file + * Utilizing the same Prefab Name, to get technical. + +
\ No newline at end of file From 074dbd8e909ba3562426052aebc882489e53f6dc Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Sat, 7 Oct 2023 12:39:09 -0400 Subject: [PATCH 04/10] Release 1.6.28 for 0.217.24 --- AdventureBackpacks/AdventureBackpacks.cs | 2 +- AdventureBackpacks/Properties/AssemblyInfo.cs | 4 ++-- CHANGELOG.md | 2 +- manifest.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index dfd93fc..4ea4bc8 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -28,7 +28,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo //Module Constants private const string _pluginId = "vapok.mods.adventurebackpacks"; private const string _displayName = "Adventure Backpacks"; - private const string _version = "1.6.27"; + private const string _version = "1.6.28"; //Interface Properties public string PluginId => _pluginId; diff --git a/AdventureBackpacks/Properties/AssemblyInfo.cs b/AdventureBackpacks/Properties/AssemblyInfo.cs index 8f35b0e..410bc91 100644 --- a/AdventureBackpacks/Properties/AssemblyInfo.cs +++ b/AdventureBackpacks/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.27.0")] -[assembly: AssemblyFileVersion("1.6.27.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.28.0")] +[assembly: AssemblyFileVersion("1.6.28.0")] \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 886e5f5..a8b5480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 1.6.27 - 0.217.24 Update +# 1.6.28 - 0.217.24 Update * Updates for Valheim 0.217.24 # 1.6.27 - Bug Fix diff --git a/manifest.json b/manifest.json index eda077e..cff9e60 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "AdventureBackpacks", - "version_number": "1.6.27", + "version_number": "1.6.28", "website_url": "https://github.com/Vapok/AdventureBackpacks", "description": "A Valheim Mod to add a catalogue of Adventuring Backpacks to the Game. These packs will grow and become more useful as the game progresses.", "dependencies": [ From 9a872bd7e6cc67212d609242b09d1e2bf0538527 Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Sat, 7 Oct 2023 16:27:05 -0400 Subject: [PATCH 05/10] 1.6.29 Update --- AdventureBackpacks/AdventureBackpacks.cs | 2 +- AdventureBackpacks/AdventureBackpacks.csproj | 4 ++-- AdventureBackpacks/Properties/AssemblyInfo.cs | 4 ++-- AdventureBackpacks/packages.config | 2 +- CHANGELOG.md | 3 +++ manifest.json | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index 4ea4bc8..bcb6a35 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -28,7 +28,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo //Module Constants private const string _pluginId = "vapok.mods.adventurebackpacks"; private const string _displayName = "Adventure Backpacks"; - private const string _version = "1.6.28"; + private const string _version = "1.6.29"; //Interface Properties public string PluginId => _pluginId; diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index e494f24..49fde02 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -82,8 +82,8 @@ ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.UI.dll - - ..\packages\Vapok.Valheim.Common.1.3.21714\lib\net462\Vapok.Valheim.Common.dll + + ..\packages\Vapok.Valheim.Common.1.4.21724\lib\net462\Vapok.Valheim.Common.dll ..\packages\YamlDotNet.12.3.1\lib\net45\YamlDotNet.dll diff --git a/AdventureBackpacks/Properties/AssemblyInfo.cs b/AdventureBackpacks/Properties/AssemblyInfo.cs index 410bc91..9b31be8 100644 --- a/AdventureBackpacks/Properties/AssemblyInfo.cs +++ b/AdventureBackpacks/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.28.0")] -[assembly: AssemblyFileVersion("1.6.28.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.29.0")] +[assembly: AssemblyFileVersion("1.6.29.0")] \ No newline at end of file diff --git a/AdventureBackpacks/packages.config b/AdventureBackpacks/packages.config index 8b614ff..29f79f3 100644 --- a/AdventureBackpacks/packages.config +++ b/AdventureBackpacks/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b5480..3734f1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.6.29 - Multiplayer Issue +* Fixing ServerSync + # 1.6.28 - 0.217.24 Update * Updates for Valheim 0.217.24 diff --git a/manifest.json b/manifest.json index cff9e60..39ccbfb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "AdventureBackpacks", - "version_number": "1.6.28", + "version_number": "1.6.29", "website_url": "https://github.com/Vapok/AdventureBackpacks", "description": "A Valheim Mod to add a catalogue of Adventuring Backpacks to the Game. These packs will grow and become more useful as the game progresses.", "dependencies": [ From 9285226b52fe01550fbfda64deb66a9a4c6c11e2 Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Mon, 30 Oct 2023 00:52:10 -0400 Subject: [PATCH 06/10] Initial Update for 0.217.27 --- AdventureBackpacks/AdventureBackpacks.cs | 2 +- AdventureBackpacks/AdventureBackpacks.csproj | 32 +++++++++---------- AdventureBackpacks/Properties/AssemblyInfo.cs | 4 +-- AdventureBackpacks/packages.config | 2 +- CHANGELOG.md | 11 +++++-- manifest.json | 4 +-- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index bcb6a35..7195cef 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -28,7 +28,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo //Module Constants private const string _pluginId = "vapok.mods.adventurebackpacks"; private const string _displayName = "Adventure Backpacks"; - private const string _version = "1.6.29"; + private const string _version = "1.6.30"; //Interface Properties public string PluginId => _pluginId; diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index 49fde02..1af7231 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -9,7 +9,7 @@ Properties AdventureBackpacks AdventureBackpacks - v4.6.2 + v4.7.2 512 latest @@ -36,22 +36,22 @@ - ..\..\References\BepInEx\5.4.2200\BepInEx\core\0Harmony.dll + ..\..\References\BepInEx\5.4.2201\BepInEx\core\0Harmony.dll - ..\..\References\Valheim\0.217.24\assembly_guiutils_publicized.dll + ..\..\References\Valheim\0.217.27\assembly_guiutils_publicized.dll - ..\..\References\Valheim\0.217.24\assembly_utils_publicized.dll + ..\..\References\Valheim\0.217.27\assembly_utils_publicized.dll - ..\..\References\Valheim\0.217.24\assembly_valheim_publicized.dll + ..\..\References\Valheim\0.217.27\assembly_valheim_publicized.dll - ..\..\References\BepInEx\5.4.2200\BepInEx\core\BepInEx.dll + ..\..\References\BepInEx\5.4.2201\BepInEx\core\BepInEx.dll - ..\..\References\BepInEx\5.4.2200\BepInEx\core\BepInEx.Harmony.dll + ..\..\References\BepInEx\5.4.2201\BepInEx\core\BepInEx.Harmony.dll ..\..\References\ServerSync\ServerSync.dll @@ -62,28 +62,28 @@ - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.AnimationModule.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.AnimationModule.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.AssetBundleModule.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.AssetBundleModule.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.CoreModule.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.CoreModule.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.InputLegacyModule.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.InputLegacyModule.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.PhysicsModule.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.PhysicsModule.dll - ..\..\References\BepInEx\5.4.2200\unstripped_corlib\UnityEngine.UI.dll + ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.UI.dll - - ..\packages\Vapok.Valheim.Common.1.4.21724\lib\net462\Vapok.Valheim.Common.dll + + ..\packages\Vapok.Valheim.Common.1.5.21727\lib\net472\Vapok.Valheim.Common.dll ..\packages\YamlDotNet.12.3.1\lib\net45\YamlDotNet.dll diff --git a/AdventureBackpacks/Properties/AssemblyInfo.cs b/AdventureBackpacks/Properties/AssemblyInfo.cs index 9b31be8..a1ff172 100644 --- a/AdventureBackpacks/Properties/AssemblyInfo.cs +++ b/AdventureBackpacks/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.29.0")] -[assembly: AssemblyFileVersion("1.6.29.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.30.0")] +[assembly: AssemblyFileVersion("1.6.30.0")] \ No newline at end of file diff --git a/AdventureBackpacks/packages.config b/AdventureBackpacks/packages.config index 29f79f3..bc3da95 100644 --- a/AdventureBackpacks/packages.config +++ b/AdventureBackpacks/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3734f1d..b6f83ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 1.6.30 - Valheim Update 0.217.27 +* Updated for most recent Valheim. +* Upgraded to .net 4.7.2 + + +
+Changelog History (click to expand) + # 1.6.29 - Multiplayer Issue * Fixing ServerSync @@ -19,9 +27,6 @@ * Craft From Containers needs 1 update in order to work (They need to not check for Piece component) * Fixes a Compatibility issue with Valheim+ Where Transpilers were fighting for attention. -
-Changelog History (click to expand) - # 1.6.24 - Updates and Compatibilities * Fixing a Player Load error on Startup when wearing a backpack. diff --git a/manifest.json b/manifest.json index 39ccbfb..25c8554 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "name": "AdventureBackpacks", - "version_number": "1.6.29", + "version_number": "1.6.30", "website_url": "https://github.com/Vapok/AdventureBackpacks", "description": "A Valheim Mod to add a catalogue of Adventuring Backpacks to the Game. These packs will grow and become more useful as the game progresses.", "dependencies": [ - "denikson-BepInExPack_Valheim-5.4.2200" + "denikson-BepInExPack_Valheim-5.4.2201" ] } \ No newline at end of file From 6fceb1e42892011c8e8a8ae19ec7c88a0fe9313f Mon Sep 17 00:00:00 2001 From: Pete Navarra Date: Mon, 30 Oct 2023 23:13:59 -0400 Subject: [PATCH 07/10] Version 1.0 of AB API --- AdventureBackpacks.sln | 12 +- AdventureBackpacks.sln.DotSettings | 2 + AdventureBackpacks/API/ABAPI.cs | 142 ++++++ AdventureBackpacks/API/Privates.cs | 72 +++ AdventureBackpacks/API/Structs.cs | 145 ++++++ AdventureBackpacks/AdventureBackpacks.cs | 18 +- AdventureBackpacks/AdventureBackpacks.csproj | 40 +- .../Assets/Effects/EffectsBase.cs | 2 +- .../Assets/Factories/BackpackFactory.cs | 16 +- AdventureBackpacks/Assets/Items/AssetItem.cs | 4 +- .../Assets/Items/BackpackItem.cs | 2 +- .../BackpackItems/BackpackBlackForest.cs | 1 + .../Items/BackpackItems/BackpackMeadows.cs | 1 + .../Items/BackpackItems/BackpackMistlands.cs | 1 + .../Items/BackpackItems/BackpackMountains.cs | 1 + .../Items/BackpackItems/BackpackNecromancy.cs | 1 + .../Items/BackpackItems/BackpackPlains.cs | 1 + .../Items/BackpackItems/BackpackSwamp.cs | 1 + AdventureBackpacks/ILRepack.targets | 7 +- AdventureBackpacks/Patches/Humanoid.cs | 1 - AdventureBackpacks/Patches/Player.cs | 1 - AdventureBackpacks/Properties/AssemblyInfo.cs | 7 +- AdventureBackpacks/packages.config | 1 + Docs/AdventureBackpacksAPI.md | 431 ++++++++++++++++++ 24 files changed, 871 insertions(+), 39 deletions(-) create mode 100644 AdventureBackpacks.sln.DotSettings create mode 100644 AdventureBackpacks/API/ABAPI.cs create mode 100644 AdventureBackpacks/API/Privates.cs create mode 100644 AdventureBackpacks/API/Structs.cs create mode 100644 Docs/AdventureBackpacksAPI.md diff --git a/AdventureBackpacks.sln b/AdventureBackpacks.sln index 731d37c..1e32489 100644 --- a/AdventureBackpacks.sln +++ b/AdventureBackpacks.sln @@ -28,20 +28,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Translations", "Translation Translations\AdventureBackpacks.Polish.json = Translations\AdventureBackpacks.Polish.json EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{D68E7D37-E82E-4419-BA0E-18C7EAD3F38B}" + ProjectSection(SolutionItems) = preProject + Docs\AdventureBackpacksAPI.md = Docs\AdventureBackpacksAPI.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU + API|Any CPU = API|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {997CB563-FCC7-44B7-8F71-069747D27CC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {997CB563-FCC7-44B7-8F71-069747D27CC5}.Debug|Any CPU.Build.0 = Debug|Any CPU {997CB563-FCC7-44B7-8F71-069747D27CC5}.Release|Any CPU.ActiveCfg = Release|Any CPU {997CB563-FCC7-44B7-8F71-069747D27CC5}.Release|Any CPU.Build.0 = Release|Any CPU - {6215C559-83D3-4512-AD75-9F6DBD452083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6215C559-83D3-4512-AD75-9F6DBD452083}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6215C559-83D3-4512-AD75-9F6DBD452083}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6215C559-83D3-4512-AD75-9F6DBD452083}.Release|Any CPU.Build.0 = Release|Any CPU + {997CB563-FCC7-44B7-8F71-069747D27CC5}.API|Any CPU.ActiveCfg = API|Any CPU + {997CB563-FCC7-44B7-8F71-069747D27CC5}.API|Any CPU.Build.0 = API|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {453B1EE0-9980-4B66-93B3-2DDBD21FEE03} = {125A2AE5-FB75-4EED-B971-3E0C9C056DA0} diff --git a/AdventureBackpacks.sln.DotSettings b/AdventureBackpacks.sln.DotSettings new file mode 100644 index 0000000..d4e9b67 --- /dev/null +++ b/AdventureBackpacks.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/AdventureBackpacks/API/ABAPI.cs b/AdventureBackpacks/API/ABAPI.cs new file mode 100644 index 0000000..a1a946d --- /dev/null +++ b/AdventureBackpacks/API/ABAPI.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using JetBrains.Annotations; +#if ! API +using AdventureBackpacks.Extensions; +using AdventureBackpacks.Features; +#endif + +namespace AdventureBackpacks.API; + +/// +/// Adventure Backpacks API. Be sure to include the AdventureBackpacksAPI.dll as a dependency to your project. +/// +[PublicAPI] +// ReSharper disable once InconsistentNaming +public partial class ABAPI +{ + /// + /// Notifies if the ABAPI is active or not. + /// + /// true of false + public static bool IsLoaded() + { +#if ! API + return true; +#else +return false; +#endif + } + + /// + /// When provided with an ItemData object, will detect whether the Item is an Adventure Backpack or not. + /// + /// This is the ItemDrop.ItemData object of the item. + /// true or false + public static bool IsBackpack(ItemDrop.ItemData itemData) + { +#if ! API + return itemData != null && itemData.IsBackpack(); +#else +return false; +#endif + } + + + /// + /// Determines if the Player provided is currently wearing a backpack. + /// + /// Player, usually Player.m_localPlayer + /// true or false + public static bool IsBackpackEquipped(Player player) + { +#if ! API + return player != null && player.IsBackpackEquipped(); +#else +return false; +#endif + } + + /// + /// Determines if the player is capable of currently opening the equipped backpack. + /// + /// Player, usually Player.m_localPlayer + /// true or false + public static bool CanOpenBackpack(Player player) + { +#if ! API + return player != null && player.CanOpenBackpack(); +#else +return false; +#endif + } + + /// + /// Determines if the player provided is wearing the item provided and that it's a backpack. + /// + /// Player, usually Player.m_localPlayer + /// Any ItemData + /// true or false. If item provided is not a backpack, will return false. + public static bool IsThisBackpackEquipped(Player player, ItemDrop.ItemData itemData) + { +#if ! API + return player != null && player.IsThisBackpackEquipped(itemData); +#else +return false; +#endif + } + + /// + /// Returns a Backpack object if the provided Player is currently wearing a backpack. + /// + /// Player, usually Player.m_localPlayer + /// Nullable Backpack Object + public static Backpack? GetEquippedBackpack(Player player) + { +#if ! API + var backpackComponent = player.GetEquippedBackpack(); + return ConvertBackpackItem(backpackComponent); +#else +return null; +#endif + } + + /// + /// Returns Backpack object of the provided itemData. Operates similarly to a TryGet but with a nullable type. + /// + /// ItemDrop.ItemData object + /// Nullable Backpack Object. Check HasValue. + public static Backpack? GetBackpack(ItemDrop.ItemData itemData) + { +#if ! API + return ConvertBackpackItem(itemData); +#else +return null; +#endif + } + + /// + /// Retrieves the current Active Backpack StatusEffects running in the local players game. + /// + /// HashSet of Status Effects. + public static HashSet GetActiveBackpackStatusEffects() + { +#if ! API + return EquipmentEffectCache.ActiveEffects; +#else +return null; +#endif + } + + /// + /// Method to activate the backpack on the local player's GUI and open it. Use in conjunction with CanOpenBackpack() + /// + /// Player, usually Player.m_localPlayer + /// The instance of InventoryGui + public static void OpenBackpack(Player player, InventoryGui gui) + { +#if ! API + if (player != null) + player.OpenBackpack(gui); +#endif + } +} \ No newline at end of file diff --git a/AdventureBackpacks/API/Privates.cs b/AdventureBackpacks/API/Privates.cs new file mode 100644 index 0000000..8b6324c --- /dev/null +++ b/AdventureBackpacks/API/Privates.cs @@ -0,0 +1,72 @@ +#if ! API +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Vapok.Common.Managers;using AdventureBackpacks.Assets; +using AdventureBackpacks.Assets.Items; +using AdventureBackpacks.Components; +using AdventureBackpacks.Extensions; + + +namespace AdventureBackpacks.API; + + +// ReSharper disable once InconsistentNaming +public partial class ABAPI +{ + private static Backpack? ConvertBackpackItem(BackpackComponent component) + { + var definition = GetBackPackDefinitionFromComponent(component); + if (!definition.HasValue) + return null; + + var backpackItem = new Backpack + { + Name = definition.Value.ItemName, + ItemData = component.Item, + Definition = definition.Value, + Inventory = component.GetInventory() + }; + return backpackItem; + } + + private static Backpack? ConvertBackpackItem(ItemDrop.ItemData itemData) + { + if (!itemData.IsBackpack()) + return null; + + var component = itemData.Data().GetOrCreate(); + return ConvertBackpackItem(component); + } + + private static Dictionary GetBackpackSizing(BackpackItem backpack) + { + return backpack.BackpackSize.ToDictionary(entry => entry.Key, entry => entry.Value.Value); + } + + private static BackpackDefinition? GetBackPackDefinitionFromComponent(BackpackComponent component) + { + var isBackpack = component.Item.TryGetBackpackItem(out var backpack); + if (isBackpack) + return null; + + return GetBackPackDefinition(backpack); + } + + private static BackpackDefinition GetBackPackDefinition(BackpackItem backpack) + { + var definition = new BackpackDefinition + { + ItemName = backpack.ItemName, + PrefabName = backpack.PrefabName, + BackpackSizeByQuality = GetBackpackSizing(backpack), + WeightMultiplier = backpack.WeightMultiplier.Value, + CarryBonus = backpack.CarryBonus.Value, + SpeedMod = backpack.SpeedMod.Value, + EnableFreezing = backpack.EnableFreezing.Value, + BackpackBiome = backpack.BackpackBiome.Value + }; + return definition; + } +} +#endif diff --git a/AdventureBackpacks/API/Structs.cs b/AdventureBackpacks/API/Structs.cs new file mode 100644 index 0000000..c1f9089 --- /dev/null +++ b/AdventureBackpacks/API/Structs.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace AdventureBackpacks.API; + +/// +/// This is a Flags enum for determining Backpack Biomes. This is not representative of Heightmap.Biomes. +/// +[Flags] +public enum BackpackBiomes : uint +{ + /// + /// None, no backpack effects are applied. + /// + None = 0, + /// + /// Meadows Backpack Effects + /// + Meadows = 1 << 0, + /// + /// Black Forest Backpack Effects + /// + BlackForest = 1 << 1, + /// + /// Swamp Backpack Effects + /// + Swamp = 1 << 2, + /// + /// Mountains Backpack Effects + /// + Mountains = 1 << 3, + /// + /// Plains Backpack Effects + /// + Plains = 1 << 4, + /// + /// Mistlands Backpack Effects + /// + Mistlands = 1 << 5, + /// + /// Special Biome configured for Cheb's Necromancy + /// + Necromancy = 1 << 6 +} + +// ReSharper disable once InconsistentNaming +public partial class ABAPI +{ + /// + /// Instanced Backpack Information + /// + public struct Backpack + { + /// + /// Backpack Name + /// + public string Name; + /// + /// ItemData representative of the Backpack + /// + public ItemDrop.ItemData ItemData; + /// + /// Inventory object of the configured backpack + /// + public Inventory Inventory; + /// + /// Definition of the Backpack item + /// + public BackpackDefinition Definition; + } + + /// + /// Backpack Definition Settings + /// + public struct BackpackDefinition + { + /// + /// Asset Bundle Name + /// + public string AssetName; + /// + /// Folder containing the Asset Bundle + /// + public string AssetFolderName; + /// + /// Prefab Name of the Backpack Asset + /// + public string PrefabName; + /// + /// Item Name of the Backpack. Use the $_name localize token. + /// + public string ItemName; + /// + /// Dictionary of Vector2's that contain the x and y sizing of the backpack at each Quality level' + /// Dictionary key is the Item's Quality level. + /// Dictionary value is the Vector2 object. + /// + public Dictionary BackpackSizeByQuality; + /// + /// Provides the configured weight multiplier that reduces the weight of the items in the backpack. + /// + public float WeightMultiplier; + /// + /// Provides the additional carry weight bonus applied to backpacks. + /// + public int CarryBonus; + /// + /// Provides the Speed Modification that is applied on the backpack. + /// + public float SpeedMod; + /// + /// Provides whether the wearer of the backpack will freeze or not. + /// + public bool EnableFreezing; + /// + /// Provides the configured biomes settings applied to the backpack. + /// + public BackpackBiomes BackpackBiome; + + } + + /// + /// Configuration of Drop Target + /// + public struct DropTarget + { + /// + /// Prefab name of creature + /// + public string Creature; + /// + /// Min number of items that can drop. + /// + public int Min; + /// + /// Maximum number of items that can drop. + /// + public int Max; + /// + /// Configured Drop Chance + /// + public float Chance; + } +} \ No newline at end of file diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index 7195cef..de6ce39 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -8,6 +8,7 @@ using AdventureBackpacks.Extensions; using AdventureBackpacks.Features; using AdventureBackpacks.Patches; +using APIManager; using BepInEx; using HarmonyLib; using ItemManager; @@ -58,6 +59,8 @@ private void Awake() //I'm awake! _instance = this; + Patcher.Patch(); + //Waiting For Startup Waiter = new Waiting(); //Initialize Managers @@ -70,11 +73,6 @@ private void Awake() LogManager.Init(PluginId,out _log); PrefabManager.Initalized = true; - - Localizer.Waiter.StatusChanged += InitializeBackpacks; - - //Initialized Features - QuickTransfer.FeatureInitialized = true; //Patch Harmony _harmony = new Harmony(Info.Metadata.GUID); @@ -84,7 +82,15 @@ private void Awake() //Profit } - + + private void Start() + { + Localizer.Waiter.StatusChanged += InitializeBackpacks; + + //Initialized Features + QuickTransfer.FeatureInitialized = true; + } + private void Update() { if (!Player.m_localPlayer || !ZNetScene.instance) diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index 1af7231..134403c 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -34,10 +34,30 @@ 4 true + + v4.7.2 + AdventureBackpacksAPI + true + full + bin\API\ + API;TRACE + true + pdbonly + AnyCPU + prompt + true + true + $(MSBuildProjectDirectory)\..\Docs\AdventureBackpacksAPI.md + bin\API\AdventureBackpacksAPI.xml + True + ..\..\References\BepInEx\5.4.2201\BepInEx\core\0Harmony.dll + + ..\..\References\APIManager\APIManager.dll + ..\..\References\Valheim\0.217.27\assembly_guiutils_publicized.dll @@ -89,7 +109,7 @@ ..\packages\YamlDotNet.12.3.1\lib\net45\YamlDotNet.dll - + @@ -133,20 +153,28 @@ - + + + + + + + - + - - + + + + @@ -164,7 +192,9 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + +