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 dfd93fc..5fccf77 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;
@@ -28,7 +29,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.7.0";
//Interface Properties
public string PluginId => _pluginId;
@@ -58,6 +59,8 @@ private void Awake()
//I'm awake!
_instance = this;
+ Patcher.Patch(new []{"AdventureBackpacks.API"});
+
//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 d536b90..134403c 100644
--- a/AdventureBackpacks/AdventureBackpacks.csproj
+++ b/AdventureBackpacks/AdventureBackpacks.csproj
@@ -9,7 +9,7 @@
Properties
AdventureBackpacks
AdventureBackpacks
- v4.6.2
+ v4.7.2
512
latest
@@ -34,24 +34,44 @@
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.2101\BepInEx\core\0Harmony.dll
+ ..\..\References\BepInEx\5.4.2201\BepInEx\core\0Harmony.dll
+
+
+ ..\..\References\APIManager\APIManager.dll
- ..\..\References\Valheim\0.217.14\assembly_guiutils_publicized.dll
+ ..\..\References\Valheim\0.217.27\assembly_guiutils_publicized.dll
- ..\..\References\Valheim\0.217.14\assembly_utils_publicized.dll
+ ..\..\References\Valheim\0.217.27\assembly_utils_publicized.dll
- ..\..\References\Valheim\0.217.14\assembly_valheim_publicized.dll
+ ..\..\References\Valheim\0.217.27\assembly_valheim_publicized.dll
- ..\..\References\BepInEx\5.4.2101\BepInEx\core\BepInEx.dll
+ ..\..\References\BepInEx\5.4.2201\BepInEx\core\BepInEx.dll
- ..\..\References\BepInEx\5.4.2101\BepInEx\core\BepInEx.Harmony.dll
+ ..\..\References\BepInEx\5.4.2201\BepInEx\core\BepInEx.Harmony.dll
..\..\References\ServerSync\ServerSync.dll
@@ -62,34 +82,34 @@
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.AnimationModule.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.AnimationModule.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.AssetBundleModule.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.AssetBundleModule.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.CoreModule.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.CoreModule.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.InputLegacyModule.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.InputLegacyModule.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.PhysicsModule.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.PhysicsModule.dll
- ..\..\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.UI.dll
+ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.UI.dll
-
- ..\packages\Vapok.Valheim.Common.1.3.21714\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
-
+
@@ -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}.
+
+