diff --git a/AdventureBackpacks/API/ABAPI.cs b/AdventureBackpacks/API/ABAPI.cs index a1a946d..77a75fa 100644 --- a/AdventureBackpacks/API/ABAPI.cs +++ b/AdventureBackpacks/API/ABAPI.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using JetBrains.Annotations; #if ! API +using AdventureBackpacks.Assets.Factories; using AdventureBackpacks.Extensions; using AdventureBackpacks.Features; #endif @@ -127,6 +128,19 @@ public static HashSet GetActiveBackpackStatusEffects() #endif } + /// + /// Retrieves all Status Effects Registered with Adventure Backpacks + /// + /// HashSet of Status Effects. + public static HashSet GetRegisterdStatusEffects() + { +#if ! API + return EffectsFactory.GetRegisteredEffects(); +#else +return null; +#endif + } + /// /// Method to activate the backpack on the local player's GUI and open it. Use in conjunction with CanOpenBackpack() /// @@ -137,6 +151,28 @@ public static void OpenBackpack(Player player, InventoryGui gui) #if ! API if (player != null) player.OpenBackpack(gui); +#endif + } + + /// + /// Use this method in the Awake() of your mod to register a Status Effect that can be utilized on Adventure Backpacks + /// + /// Create a new EffectDefinition that contains the overall parameters that are needed to register the new effect. + public static void RegisterEffect(EffectDefinition effectDefinition) + { +#if ! API + EffectsFactory.RegisterExternalEffect(effectDefinition); +#endif + } + + /// + /// Use this method in the Awake() of your mod to register a new Backpack that can be utilized on Adventure Backpacks. + /// + /// Create a new BackpackDefinition that contains the overall parameters that are needed to register the new backpack. + public static void RegisterBackpack(BackpackDefinition definition) + { +#if ! API + BackpackFactory.RegisterExternalBackpack(definition); #endif } } \ No newline at end of file diff --git a/AdventureBackpacks/API/Privates.cs b/AdventureBackpacks/API/Privates.cs index 8b6324c..15bf201 100644 --- a/AdventureBackpacks/API/Privates.cs +++ b/AdventureBackpacks/API/Privates.cs @@ -17,14 +17,14 @@ public partial class ABAPI private static Backpack? ConvertBackpackItem(BackpackComponent component) { var definition = GetBackPackDefinitionFromComponent(component); - if (!definition.HasValue) + if (definition == null) return null; var backpackItem = new Backpack { - Name = definition.Value.ItemName, + Name = definition.ItemName, ItemData = component.Item, - Definition = definition.Value, + Definition = definition, Inventory = component.GetInventory() }; return backpackItem; @@ -44,7 +44,7 @@ private static Dictionary GetBackpackSizing(BackpackItem backpack) return backpack.BackpackSize.ToDictionary(entry => entry.Key, entry => entry.Value.Value); } - private static BackpackDefinition? GetBackPackDefinitionFromComponent(BackpackComponent component) + private static BackpackDefinition GetBackPackDefinitionFromComponent(BackpackComponent component) { var isBackpack = component.Item.TryGetBackpackItem(out var backpack); if (isBackpack) diff --git a/AdventureBackpacks/API/Structs.cs b/AdventureBackpacks/API/Structs.cs index c1f9089..f663a8a 100644 --- a/AdventureBackpacks/API/Structs.cs +++ b/AdventureBackpacks/API/Structs.cs @@ -6,6 +6,8 @@ namespace AdventureBackpacks.API; /// /// This is a Flags enum for determining Backpack Biomes. This is not representative of Heightmap.Biomes. +/// This is instead a way of creating sets of Effects. Default Adventure Backpacks will utilize Biome names. +/// Custom External Effects can pick and choose between the Custom Effect flags as well. /// [Flags] public enum BackpackBiomes : uint @@ -39,9 +41,33 @@ public enum BackpackBiomes : uint /// Mistlands = 1 << 5, /// - /// Special Biome configured for Cheb's Necromancy + /// Ashland Backpack Effects /// - Necromancy = 1 << 6 + Ashlands = 1 << 6, + /// + /// DeepNorth Backpack Effects + /// + DeepNorth = 1 << 7, + /// + /// Custom Biome for use with External Effects + /// + EffectBiome1 = 1 << 20, + /// + /// Custom Biome for use with External Effects + /// + EffectBiome2 = 1 << 21, + /// + /// Custom Biome for use with External Effects + /// + EffectBiome3 = 1 << 22, + /// + /// Custom Biome for use with External Effects + /// + EffectBiome4 = 1 << 23, + /// + /// Custom Biome for use with External Effects + /// + EffectBiome5 = 1 << 24, } // ReSharper disable once InconsistentNaming @@ -72,41 +98,102 @@ public struct Backpack /// /// Backpack Definition Settings + /// Use this object to create backpack definitions for adding Backpacks to Adventure Backpacks. + /// You can use either the GameObject directly, or provide your AssetBundle object and the PrefabName. /// - public struct BackpackDefinition + public class BackpackDefinition { /// - /// Asset Bundle Name + /// Backpack GameObject + /// (Not required if AssetBundle and Prefab Name are provided) /// - public string AssetName; + public GameObject BackPackGo; /// - /// Folder containing the Asset Bundle + /// Asset Bundle containing the Backpack + /// (Not required if GameObject is provided) /// - public string AssetFolderName; + public AssetBundle AssetBundle; /// /// Prefab Name of the Backpack Asset + /// (Not required if GameObject is provided) /// public string PrefabName; /// /// Item Name of the Backpack. Use the $_name localize token. + /// (e.g. $vapok_mod_rugged_backpack) /// public string ItemName; /// + /// Custom Configuration Section Name in Adventure Backpacks. + /// If left empty, will use default section name. + /// (e.g. Backpack: {$backpack_itemname} ) + /// + public string ConfigSection = ""; + /// + /// Name of Crafting Table that the Backpack can be crafted at. + /// If left empty, will disable crafting at any table. + /// Can also include custom table names. + /// (e.g. piece_workbench, forge, piece_stonecutter) + /// + public string CraftingTable; + /// + /// Minimum Level of Crafting Table Station before Bag can be crafted + /// (e.g. 1, 2, etc.) + /// + public int StationLevel; + /// + /// Max Crafting Station Level to upgrade, and repair. + /// (e.g. 1, 2, etc.) + /// + public int MaxRequiredStationLevel; + /// + /// List of Recipe Ingredients. + /// + public readonly List RecipeIngredients = new (); + /// + /// List of Ingredients for Upgrading. + /// + public readonly List UpgradeIngredients = new (); + /// + /// List of Ingredients for Upgrading. + /// + public readonly List DropsFrom = new (); + /// + /// Dictionary of StatusEffect's to apply to the backpack when equipped. + /// Dictionary Key is the BackpackBiome that needs to be applied to the Backpack for Effect to be activated. + /// Dictionary Value is a Key Value Pair of a Status Effect to apply: + /// Key of the KVP is the actual Status Effect + /// Value of the KVP is the default int Quality level that of the backpack before the effect is applied. + /// (examples of the quality level: 1 - 4) + /// Use GetRegisteredStatusEffects() to determine which status effect Adventure Backpacks is aware of. + /// Use RegisterEffect() first to register new status effects. + /// + public readonly Dictionary> EffectsToApply = new (); + /// /// 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; + public Dictionary BackpackSizeByQuality = new (); + /// + /// When backpack is equipped, set what the Set Effect Status Effect Should. + /// If left empty, none will be equipped. + /// Note: Be sure this is one of the effects included in EffectsToApply. + /// + public StatusEffect ItemSetStatusEffect; /// /// Provides the configured weight multiplier that reduces the weight of the items in the backpack. + /// For registering a new backpack, this is the default value. /// public float WeightMultiplier; /// /// Provides the additional carry weight bonus applied to backpacks. + /// For registering a new backpack, this is the default value. /// public int CarryBonus; /// /// Provides the Speed Modification that is applied on the backpack. + /// For registering a new backpack, this is the default value. /// public float SpeedMod; /// @@ -115,8 +202,44 @@ public struct BackpackDefinition public bool EnableFreezing; /// /// Provides the configured biomes settings applied to the backpack. + /// This is flag enum. + /// (e.g. "BackpackBiomes.Meadows" or "BackpackBiomes.Meadows | BackpackBiomes.BlackForest" to select multiple biomes. /// public BackpackBiomes BackpackBiome; + + /// + /// Default Constructor + /// + public BackpackDefinition() + { + + } + + /// + /// Use this constructor when adding a backpack using the GameObject + /// The item should have ItemDrop.ItemData on the item, and it should be an item that is utilizing the Shoulder slot. + /// Equipped Detection won't detect if not in the shoulder slot. + /// TODO: Make this more flexible for additional slots through AzuEPI + /// + /// GameObject of + public BackpackDefinition(GameObject backPackGo) + { + BackPackGo = backPackGo; + } + + /// + /// Use this constructor when adding a backpack using the AssetBundle and Prefab Name + /// The item should have ItemDrop.ItemData on the item, and it should be an item that is utilizing the Shoulder slot. + /// Equipped Detection won't detect if not in the shoulder slot. + /// TODO: Make this more flexible for additional slots through AzuEPI + /// + /// Provide the Asset Bundle that contains the backpack prefab + /// Prefab name of the backpack + public BackpackDefinition(AssetBundle assetBundle, string prefabName) + { + AssetBundle = assetBundle; + PrefabName = prefabName; + } } @@ -136,10 +259,99 @@ public struct DropTarget /// /// Maximum number of items that can drop. /// - public int Max; + public int? Max; /// /// Configured Drop Chance /// public float Chance; - } + + /// + /// Drop Target Constructor + /// + /// Prefab name of Creature + /// Chance to Drop Float + /// Minimum amount to drop. + /// Max amount to drop. + public DropTarget(string creature, float chance, int min = 1, int? max = null) + { + Creature = creature; + Chance = chance; + Min = min; + Max = max; + } + } + + /// + /// Create anew EffectDefinition in order to register status effects. + /// + public struct EffectDefinition + { + /// + /// This is the Effect Name. + /// (e.g. "$some_effect_name"). + /// + public readonly string Name; + /// + /// This is the Localized Translated Effect Name. + /// This is used in places like the Configuration and in the HUD/GUI + /// (e.g. "Water Resistance"). + /// + public readonly string LocalizedName; + /// + /// This is the registered Effect name + /// (e.g. SetEffect_NecromancyArmor or SE_Demister) + /// + public readonly string EffectName; + /// + /// Description of the Status Effect. Shows up in Configuration. + /// + public readonly string Description; + /// + /// This is your actual Status Effect from your own asset bundle or from another source. + /// As long as it's of the type SE_Stats, you can use it. + /// + public readonly StatusEffect StatusEffect; + + /// + /// Create anew EffectDefinition in order to register status effects. + /// + /// + /// + /// + /// + /// + public EffectDefinition(string name, string localizedName, string effectName, string description, StatusEffect statusEffect) + { + Name = name; + LocalizedName = localizedName; + EffectName = effectName; + Description = description; + StatusEffect = statusEffect; + } + } + /// + /// Defines a Recipe Ingredient + /// + public struct RecipeIngredient + { + /// + /// Prefab Name of Item to include as a recipe ingredient + /// + public string ItemPrefabName; + /// + /// Amount of Item required. + /// + public int Quantity; + + /// + /// Create Ingredient Object + /// + /// Item Prefab Name + /// Amount of item to consume. + public RecipeIngredient(string itemPrefabName, int quantity) + { + ItemPrefabName = itemPrefabName; + Quantity = quantity; + } + } } \ No newline at end of file diff --git a/AdventureBackpacks/AdventureBackpacks.cs b/AdventureBackpacks/AdventureBackpacks.cs index 5fccf77..4c28235 100644 --- a/AdventureBackpacks/AdventureBackpacks.cs +++ b/AdventureBackpacks/AdventureBackpacks.cs @@ -4,12 +4,14 @@ using System.Reflection; using AdventureBackpacks.Assets; using AdventureBackpacks.Assets.Factories; +using AdventureBackpacks.Compats; using AdventureBackpacks.Configuration; using AdventureBackpacks.Extensions; using AdventureBackpacks.Features; using AdventureBackpacks.Patches; using APIManager; using BepInEx; +using BepInEx.Bootstrap; using HarmonyLib; using ItemManager; using JetBrains.Annotations; @@ -29,7 +31,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.7.0"; + private const string _version = "1.7.1"; //Interface Properties public string PluginId => _pluginId; @@ -78,11 +80,17 @@ private void Awake() _harmony = new Harmony(Info.Metadata.GUID); _harmony.PatchAll(Assembly.GetExecutingAssembly()); + if (Chainloader.PluginInfos.ContainsKey("com.chebgonaz.ChebsNecromancy")) + { + ChebsNecromancy.SetupNecromancyBackpackUsingApi(); + } + //??? //Profit } + private void Start() { Localizer.Waiter.StatusChanged += InitializeBackpacks; diff --git a/AdventureBackpacks/AdventureBackpacks.csproj b/AdventureBackpacks/AdventureBackpacks.csproj index 134403c..cac14ab 100644 --- a/AdventureBackpacks/AdventureBackpacks.csproj +++ b/AdventureBackpacks/AdventureBackpacks.csproj @@ -59,13 +59,13 @@ ..\..\References\APIManager\APIManager.dll - ..\..\References\Valheim\0.217.27\assembly_guiutils_publicized.dll + ..\..\References\Valheim\0.217.28\assembly_guiutils_publicized.dll - ..\..\References\Valheim\0.217.27\assembly_utils_publicized.dll + ..\..\References\Valheim\0.217.28\assembly_utils_publicized.dll - ..\..\References\Valheim\0.217.27\assembly_valheim_publicized.dll + ..\..\References\Valheim\0.217.28\assembly_valheim_publicized.dll ..\..\References\BepInEx\5.4.2201\BepInEx\core\BepInEx.dll @@ -102,8 +102,8 @@ ..\..\References\BepInEx\5.4.2201\unstripped_corlib\UnityEngine.UI.dll - - ..\packages\Vapok.Valheim.Common.1.5.21727\lib\net472\Vapok.Valheim.Common.dll + + ..\packages\Vapok.Valheim.Common.1.6.21728\lib\net472\Vapok.Valheim.Common.dll ..\packages\YamlDotNet.12.3.1\lib\net45\YamlDotNet.dll @@ -116,7 +116,6 @@ - @@ -129,7 +128,6 @@ - @@ -154,6 +152,11 @@ + + + + + diff --git a/AdventureBackpacks/Assets/Backpacks.cs b/AdventureBackpacks/Assets/Backpacks.cs index 5a0fc04..e39c8df 100644 --- a/AdventureBackpacks/Assets/Backpacks.cs +++ b/AdventureBackpacks/Assets/Backpacks.cs @@ -7,7 +7,6 @@ using AdventureBackpacks.Components; using AdventureBackpacks.Extensions; using BepInEx; -using BepInEx.Bootstrap; using Vapok.Common.Abstractions; using Vapok.Common.Managers; using Vapok.Common.Managers.StatusEffects; @@ -210,9 +209,13 @@ public static CustomSE UpdateStatusEffects(ItemDrop.ItemData itemData) return null; var backpackName = itemData.m_shared.m_name; + var backpackQuality = itemData.m_quality; + var statusEffects = new CustomSE(Enums.StatusEffects.Stats, $"SE_{backpackName}_{backpackQuality}"); + var defaultStatusName = $"{backpackName} $vapok_mod_level {backpackQuality} $vapok_mod_effect"; + if (backpack.ShowBackpackStatusEffect.Value) { @@ -220,7 +223,7 @@ public static CustomSE UpdateStatusEffects(ItemDrop.ItemData itemData) statusEffects.Effect.m_startMessageType = MessageHud.MessageType.TopLeft; statusEffects.Effect.m_startMessage = $"$vapok_mod_useful_backpack"; } - + var modifierList = new List(); //Set Armor Default itemData.m_shared.m_armor = itemData.m_shared.m_armorPerLevel * backpackQuality; @@ -244,20 +247,6 @@ public static CustomSE UpdateStatusEffects(ItemDrop.ItemData itemData) itemData.m_shared.m_setSize = 0; itemData.m_shared.m_setStatusEffect = null; } - - if (Chainloader.PluginInfos.ContainsKey("com.chebgonaz.ChebsNecromancy")) - { - var necroEffect = EffectsFactory.EffectList[BackpackEffect.NecromancyArmor]; - //Apply Necromancy Armor Set if configured. - if (necroEffect.HasActiveStatusEffect(itemData, out var necroSetEffect)) - { - itemData.m_shared.m_setStatusEffect = necroSetEffect; - } - else - { - itemData.m_shared.m_setStatusEffect = null; - } - } backpack.UpdateStatusEffects(backpackQuality, statusEffects, modifierList, itemData); @@ -269,6 +258,7 @@ public static CustomSE UpdateStatusEffects(ItemDrop.ItemData itemData) } itemData.AddSEToItem(statusEffects); + return statusEffects; } } diff --git a/AdventureBackpacks/Assets/Bundles/chebsbackpack b/AdventureBackpacks/Assets/Bundles/chebsbackpack new file mode 100644 index 0000000..868bf58 Binary files /dev/null and b/AdventureBackpacks/Assets/Bundles/chebsbackpack differ diff --git a/AdventureBackpacks/Assets/Bundles/vapokbackpacks b/AdventureBackpacks/Assets/Bundles/vapokbackpacks index 320ecc3..4736585 100644 Binary files a/AdventureBackpacks/Assets/Bundles/vapokbackpacks and b/AdventureBackpacks/Assets/Bundles/vapokbackpacks differ diff --git a/AdventureBackpacks/Assets/Effects/ColdResistance.cs b/AdventureBackpacks/Assets/Effects/ColdResistance.cs index d51bc5a..c5977b8 100644 --- a/AdventureBackpacks/Assets/Effects/ColdResistance.cs +++ b/AdventureBackpacks/Assets/Effects/ColdResistance.cs @@ -19,9 +19,15 @@ private void LoadExternalStatusEffect() se.Effect.m_name = "$vapok_mod_se_cold_immunity"; se.Effect.m_icon = cold.m_icon; _externalStatusEffect = se.Effect; + SetStatusEffect(_externalStatusEffect); } } - + + public override void LoadStatusEffect() + { + LoadExternalStatusEffect(); + } + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) { LoadExternalStatusEffect(); diff --git a/AdventureBackpacks/Assets/Effects/Demister.cs b/AdventureBackpacks/Assets/Effects/Demister.cs index 780595a..c24ced5 100644 --- a/AdventureBackpacks/Assets/Effects/Demister.cs +++ b/AdventureBackpacks/Assets/Effects/Demister.cs @@ -6,6 +6,12 @@ public Demister(string effectName, string effectDesc) : base(effectName, effectD { } + + public override void LoadStatusEffect() + { + SetStatusEffect("Demister"); + } + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) { SetStatusEffect("Demister"); diff --git a/AdventureBackpacks/Assets/Effects/EffectsBase.cs b/AdventureBackpacks/Assets/Effects/EffectsBase.cs index 46d9e65..e138360 100644 --- a/AdventureBackpacks/Assets/Effects/EffectsBase.cs +++ b/AdventureBackpacks/Assets/Effects/EffectsBase.cs @@ -27,11 +27,14 @@ public EffectsBase(string effectName, string effectDesc, bool IsItemSetStatusEff _description = string.IsNullOrEmpty(effectDesc) ? "Enables the effect." : effectDesc; _configSection = $"Effect: {effectName}"; _isSetItemStatusEffect = IsItemSetStatusEffect; - + + AdventureBackpacks.Waiter.StatusChanged += (_,_)=>LoadStatusEffect(); RegisterEffectConfiguration(); } + public abstract void LoadStatusEffect(); + public virtual StatusEffect GetStatusEffect() { return _statusEffect; @@ -127,7 +130,6 @@ public void RegisterEffectConfiguration() new ConfigurationManagerAttributes { Order = 1 })); //Waiting For Startup - ConfigRegistry.Waiter.StatusChanged += (_,_) => FillBiomeSettings(); ConfigRegistry.Waiter.StatusChanged += (_,_) => AdditionalConfiguration(_configSection); } @@ -139,10 +141,10 @@ private void FillBiomeSettings() { foreach (BackpackBiomes backpackBiome in Enum.GetValues(typeof(BackpackBiomes))) { - RegisterEffectBiomeQuality(backpackBiome); + RegisterEffectBiomeQuality(backpackBiome,0,false); } } - public void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQuality = 0) + public void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQuality = 0, bool fillUp = true) { if (biome == BackpackBiomes.None) return; @@ -163,5 +165,10 @@ public void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQuality } } } + + if (fillUp) + { + FillBiomeSettings(); + } } } \ No newline at end of file diff --git a/AdventureBackpacks/Assets/Effects/ExternalEffect.cs b/AdventureBackpacks/Assets/Effects/ExternalEffect.cs new file mode 100644 index 0000000..e928e96 --- /dev/null +++ b/AdventureBackpacks/Assets/Effects/ExternalEffect.cs @@ -0,0 +1,88 @@ +using System; +using AdventureBackpacks.API; +using AdventureBackpacks.Extensions; + +namespace AdventureBackpacks.Assets.Effects; + +public class ExternalEffect : EffectsBase +{ + private string _effectName = string.Empty; + private StatusEffect _externalStatusEffect; + private ABAPI.EffectDefinition _effectDefinition; + + public ExternalEffect(ABAPI.EffectDefinition effectDefinition) : base(effectDefinition.Name, effectDefinition.Description) + { + _effectDefinition = effectDefinition; + + if (_effectDefinition.StatusEffect == null) + { + AdventureBackpacks.Log.Error($"Status Effect is null {_effectName} - Disabling Status Effect"); + EnabledEffect.Value = false; + } + + if (!string.IsNullOrEmpty(_effectDefinition.EffectName)) + _effectName = _effectDefinition.EffectName; + } + + public override void AdditionalConfiguration(string configSection) + { + } + + private void LoadExternalStatusEffect() + { + try + { + if (_externalStatusEffect != null) return; + + _externalStatusEffect = _effectDefinition.StatusEffect; + SetStatusEffect(_externalStatusEffect); + } + catch (Exception e) + { + AdventureBackpacks.Log.Error($"Can't Load External Status Effect: {_effectName} - Message: {e.Message}"); + } + } + + public override void LoadStatusEffect() + { + LoadExternalStatusEffect(); + } + + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) + { + statusEffect = null; + if (!EnabledEffect.Value) + return false; + + LoadExternalStatusEffect(); + SetStatusEffect(_externalStatusEffect); + return base.HasActiveStatusEffect(human, out statusEffect); + } + + public override bool HasActiveStatusEffect(ItemDrop.ItemData item, out StatusEffect statusEffect) + { + statusEffect = null; + if (!EnabledEffect.Value) + return false; + + LoadExternalStatusEffect(); + SetStatusEffect(_externalStatusEffect); + return base.HasActiveStatusEffect(item, out statusEffect); + } + + public override bool IsEffectActive(Humanoid human) + { + if (human is Player player) + { + var equippedBackpack = player.GetEquippedBackpack(); + + if (equippedBackpack == null || !EnabledEffect.Value) + return false; + + var itemData = equippedBackpack.Item; + return IsEffectActive(itemData); + } + + return false; + } +} \ No newline at end of file diff --git a/AdventureBackpacks/Assets/Effects/FeatherFall.cs b/AdventureBackpacks/Assets/Effects/FeatherFall.cs index 85f4184..12d3270 100644 --- a/AdventureBackpacks/Assets/Effects/FeatherFall.cs +++ b/AdventureBackpacks/Assets/Effects/FeatherFall.cs @@ -6,6 +6,11 @@ public FeatherFall(string effectName, string effectDesc) : base(effectName, effe { } + public override void LoadStatusEffect() + { + SetStatusEffect("SlowFall"); + } + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) { SetStatusEffect("SlowFall"); diff --git a/AdventureBackpacks/Assets/Effects/FrostResistance.cs b/AdventureBackpacks/Assets/Effects/FrostResistance.cs index 5824a22..51e9454 100644 --- a/AdventureBackpacks/Assets/Effects/FrostResistance.cs +++ b/AdventureBackpacks/Assets/Effects/FrostResistance.cs @@ -20,9 +20,15 @@ private void LoadExternalStatusEffect() se.Effect.m_name = "$vapok_mod_se_frost_resistance"; se.Effect.m_icon = freezing.m_icon; _externalStatusEffect = se.Effect; + SetStatusEffect(_externalStatusEffect); } } - + + public override void LoadStatusEffect() + { + LoadExternalStatusEffect(); + } + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) { LoadExternalStatusEffect(); diff --git a/AdventureBackpacks/Assets/Effects/NecromancyArmor.cs b/AdventureBackpacks/Assets/Effects/NecromancyArmor.cs deleted file mode 100644 index 9294ea7..0000000 --- a/AdventureBackpacks/Assets/Effects/NecromancyArmor.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.IO; -using AdventureBackpacks.Extensions; -using BepInEx.Bootstrap; -using BepInEx.Configuration; -using UnityEngine; -using Vapok.Common.Managers.Configuration; -using Vapok.Common.Shared; - -namespace AdventureBackpacks.Assets.Effects; - -public class NecromancyArmor : EffectsBase -{ - private string _effectName = "SetEffect_NecromancyArmor"; - private const string AssetName = "chebgonaz"; - private const string AssetFolderName = "Assets"; - private string _assetBundlePath = ""; - private AssetBundle _assetBundle; - private const string NecromancySkillIdentifier = "friendlyskeletonwand_necromancy_skill"; - private Skills.SkillType SkillUID; - private StatusEffect _externalStatusEffect; - - public ConfigEntry NecromancySkillBonus { get; private set;} - - public NecromancyArmor(string effectName, string effectDesc) : base(effectName, effectDesc) - { - if (Chainloader.PluginInfos.ContainsKey("com.chebgonaz.ChebsNecromancy")) - { - var pluginInfo = Chainloader.PluginInfos["com.chebgonaz.ChebsNecromancy"]; - _assetBundlePath = Path.Combine(BepInEx.Paths.PluginPath,Path.GetDirectoryName(pluginInfo.Location) ?? "", AssetFolderName, AssetName); - - if (!File.Exists(_assetBundlePath)) - _assetBundlePath = Path.Combine(BepInEx.Paths.PluginPath,Path.GetDirectoryName(pluginInfo.Location) ?? "", AssetName); - - _assetBundle = !File.Exists(_assetBundlePath) ? null : AssetBundle.LoadFromFile(_assetBundlePath); - - if (_assetBundle == null) - { - AdventureBackpacks.Log.Error($"Can't find Asset Bundle for Status Effect: {_effectName} - Disabling Status Effect"); - EnabledEffect.Value = false; - } - - var num = Math.Abs(NecromancySkillIdentifier.GetStableHashCode()); - SkillUID = (Skills.SkillType)num; - } - } - - public override void AdditionalConfiguration(string configSection) - { - NecromancySkillBonus = ConfigSyncBase.SyncedConfig(configSection, "Spectral Shroud Skill Bonus", 10, - new ConfigDescription("How much wearing the item should raise the Necromancy level (set to 0 to have no set effect at all).", - null, - new ConfigurationManagerAttributes { Order = 2 })); - - NecromancySkillBonus.SettingChanged += Backpacks.UpdateItemDataConfigValues; - } - - private void LoadExternalStatusEffect() - { - try - { - if (_externalStatusEffect == null) - { - var seStat = _assetBundle.LoadAsset(_effectName); - if (seStat != null) - { - seStat.m_skillLevel = SkillUID; - seStat.m_skillLevelModifier = NecromancySkillBonus.Value; - } - _externalStatusEffect = seStat; - } - } - catch (Exception e) - { - AdventureBackpacks.Log.Error($"Can't Load External Status Effect: {_effectName} - Message: {e.Message}"); - } - } - - public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) - { - statusEffect = null; - if (!EnabledEffect.Value) - return false; - - LoadExternalStatusEffect(); - SetStatusEffect(_externalStatusEffect); - return base.HasActiveStatusEffect(human, out statusEffect); - } - - public override bool HasActiveStatusEffect(ItemDrop.ItemData item, out StatusEffect statusEffect) - { - statusEffect = null; - if (!EnabledEffect.Value) - return false; - - LoadExternalStatusEffect(); - SetStatusEffect(_externalStatusEffect); - return base.HasActiveStatusEffect(item, out statusEffect); - } - - public override bool IsEffectActive(Humanoid human) - { - if (human is Player player) - { - var equippedBackpack = player.GetEquippedBackpack(); - - if (equippedBackpack == null || !EnabledEffect.Value) - return false; - - var itemData = equippedBackpack.Item; - return IsEffectActive(itemData); - } - - return false; - } -} \ No newline at end of file diff --git a/AdventureBackpacks/Assets/Effects/TrollArmor.cs b/AdventureBackpacks/Assets/Effects/TrollArmor.cs index 85891bb..238fcce 100644 --- a/AdventureBackpacks/Assets/Effects/TrollArmor.cs +++ b/AdventureBackpacks/Assets/Effects/TrollArmor.cs @@ -9,6 +9,11 @@ public TrollArmor(string effectName, string effectDesc) : base(effectName, effec { } + public override void LoadStatusEffect() + { + SetStatusEffect(_effectName); + } + public override bool HasActiveStatusEffect(ItemDrop.ItemData item, out StatusEffect statusEffect) { SetStatusEffect(_effectName); diff --git a/AdventureBackpacks/Assets/Effects/Waterproof.cs b/AdventureBackpacks/Assets/Effects/Waterproof.cs index 2d69a21..536acd8 100644 --- a/AdventureBackpacks/Assets/Effects/Waterproof.cs +++ b/AdventureBackpacks/Assets/Effects/Waterproof.cs @@ -19,9 +19,15 @@ private void LoadExternalStatusEffect() se.Effect.m_name = "$vapok_mod_se_wet_resistance"; se.Effect.m_icon = wet.m_icon; _externalStatusEffect = se.Effect; + SetStatusEffect(_externalStatusEffect); } } - + + public override void LoadStatusEffect() + { + LoadExternalStatusEffect(); + } + public override bool HasActiveStatusEffect(Humanoid human, out StatusEffect statusEffect) { LoadExternalStatusEffect(); diff --git a/AdventureBackpacks/Assets/Factories/BackpackFactory.cs b/AdventureBackpacks/Assets/Factories/BackpackFactory.cs index 1e829a4..b95d62a 100644 --- a/AdventureBackpacks/Assets/Factories/BackpackFactory.cs +++ b/AdventureBackpacks/Assets/Factories/BackpackFactory.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; +using AdventureBackpacks.API; using AdventureBackpacks.Assets.Items; using AdventureBackpacks.Assets.Items.BackpackItems; -using BepInEx.Bootstrap; using Vapok.Common.Abstractions; using Vapok.Common.Managers.Configuration; @@ -11,10 +11,12 @@ namespace AdventureBackpacks.Assets.Factories; internal class BackpackFactory : AssetFactory { - private static List _backpackItems = new(); + private static HashSet _backpackItems = new(); private static bool _initialized; + private static List _externalBackpacks = new(); + + internal static IEnumerable BackpackItems => _backpackItems; - internal static List BackpackItems => _backpackItems; internal BackpackFactory(ILogIt logger, ConfigSyncBase configSync) : base(logger, configSync) { @@ -25,6 +27,12 @@ internal BackpackFactory(ILogIt logger, ConfigSyncBase configSync) : base(logger _initialized = true; } } + + public static void RegisterExternalBackpack(ABAPI.BackpackDefinition backpackDefinition) + { + _externalBackpacks.Add(backpackDefinition); + } + internal override void CreateAssets() { @@ -37,9 +45,16 @@ internal override void CreateAssets() _backpackItems.Add(new LegacyIronBackpack("CapeIronBackpack","$vapok_mod_item_rugged_backpack")); _backpackItems.Add(new LegacySilverBackpack("CapeSilverBackpack","$vapok_mod_item_arctic_backpack")); - if (Chainloader.PluginInfos.ContainsKey("com.chebgonaz.ChebsNecromancy")) + foreach (var backpackDefinition in _externalBackpacks) { - _backpackItems.Add(new BackpackNecromancy("BackpackNecromancy","$item_friendlyskeletonwand_spectralshroud_backpack")); + if (_backpackItems.Any(x => x.ItemName.Equals(backpackDefinition.ItemName))) return; + + var newBackpack = backpackDefinition.BackPackGo != null ? + new ExternalBackpack(backpackDefinition, backpackDefinition.BackPackGo) : + new ExternalBackpack(backpackDefinition); + + _backpackItems.Add(newBackpack); + } } diff --git a/AdventureBackpacks/Assets/Factories/EffectsFactory.cs b/AdventureBackpacks/Assets/Factories/EffectsFactory.cs index 8b3de78..b0636f9 100644 --- a/AdventureBackpacks/Assets/Factories/EffectsFactory.cs +++ b/AdventureBackpacks/Assets/Factories/EffectsFactory.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; +using System.Linq; +using AdventureBackpacks.API; using AdventureBackpacks.Assets.Effects; -using BepInEx.Bootstrap; using Vapok.Common.Abstractions; using Vapok.Common.Managers.Configuration; @@ -15,19 +16,48 @@ public enum BackpackEffect WaterResistance, FrostResistance, TrollArmor, - NecromancyArmor + NecromancyArmor, + ExternalEffect } public class EffectsFactory : FactoryBase { + + public static HashSet AllEffects => _allEffects; public static Dictionary EffectList => _effectList; private static Dictionary _effectList = new(); + private static HashSet _externalEffects = new(); + private static HashSet _allEffects = new(); + public EffectsFactory(ILogIt logger, ConfigSyncBase configs) : base(logger, configs) { } + public static HashSet GetRegisteredEffects() + { + var effects = new HashSet(); + + foreach (var effectsBase in _effectList) + { + effects.Add(effectsBase.Value.GetStatusEffect()); + } + + foreach (var effectsBase in _externalEffects) + { + effects.Add(effectsBase.GetStatusEffect()); + } + return effects; + } + public static void RegisterExternalEffect(ABAPI.EffectDefinition effectDefinition) + { + if (_externalEffects.Any(x => x.EffectName.Equals(effectDefinition.EffectName))) return; + + var externalEffect = new ExternalEffect(effectDefinition); + _externalEffects.Add(externalEffect); + } + public void RegisterEffects() { _effectList.Add(BackpackEffect.FeatherFall, new FeatherFall("Feather Fall", "When activated allows you to slow fall gracefully and without damage from high elevations.")); @@ -37,15 +67,29 @@ public void RegisterEffects() _effectList.Add(BackpackEffect.FrostResistance, new FrostResistance("Frost Resistance", "When activated allows you to stay warm in freezing conditions, negating the freezing debuff.")); _effectList.Add(BackpackEffect.TrollArmor, new TrollArmor("Troll Armor Set", "When activated the backpack acts as the Shoulder Set piece of the Troll Armor Set allowing the set to complete for the Sneak Effect")); - if (Chainloader.PluginInfos.ContainsKey("com.chebgonaz.ChebsNecromancy")) - { - _effectList.Add(BackpackEffect.NecromancyArmor, new NecromancyArmor("Necromancy Armor Effect", "When activated the backpack provides the Necromancy Armor effect from Cheb's Necromancy")); - } - foreach (BackpackEffect effect in Enum.GetValues(typeof(BackpackEffect))) - { - if (EffectList.ContainsKey(effect)) - EffectList[effect].RegisterEffectConfiguration(); + { + switch (effect) + { + case BackpackEffect.ExternalEffect: + foreach (var effectsBase in _externalEffects) + { + _allEffects.Add(effectsBase); + effectsBase.RegisterEffectConfiguration(); + } + break; + case BackpackEffect.FeatherFall: + case BackpackEffect.ColdResistance: + case BackpackEffect.Demister: + case BackpackEffect.WaterResistance: + case BackpackEffect.FrostResistance: + case BackpackEffect.TrollArmor: + case BackpackEffect.NecromancyArmor: + if (!EffectList.ContainsKey(effect)) continue; + _allEffects.Add(EffectList[effect]); + EffectList[effect].RegisterEffectConfiguration(); + break; + } } } } \ No newline at end of file diff --git a/AdventureBackpacks/Assets/Items/AssetItem.cs b/AdventureBackpacks/Assets/Items/AssetItem.cs index 03aab75..0390223 100644 --- a/AdventureBackpacks/Assets/Items/AssetItem.cs +++ b/AdventureBackpacks/Assets/Items/AssetItem.cs @@ -1,4 +1,6 @@ -using ItemManager; +using System; +using ItemManager; +using UnityEngine; using Vapok.Common.Managers.PieceManager; using CraftingTable = ItemManager.CraftingTable; @@ -24,15 +26,47 @@ internal abstract class AssetItem : IAssetItem public Item Item => _item; + internal AssetItem(GameObject goItem, string itemName) + { + _prefabName = goItem.name; + _itemName = itemName; + + _item = new Item(goItem) + { + Configurable = Configurability.Disabled + }; + + SetupItem(); + } + + internal AssetItem(AssetBundle bundle, string prefabName, string itemName) + { + _prefabName = prefabName; + _itemName = itemName; + + _item = new Item(bundle,prefabName) + { + Configurable = Configurability.Disabled + }; + + SetupItem(); + } + internal AssetItem(string prefabName, string itemName) { _prefabName = prefabName; _itemName = itemName; + _item = new Item(AssetName, PrefabName, AssetFolderName) { Configurable = Configurability.Disabled }; + SetupItem(); + } + + private void SetupItem() + { SetPersistence(); ResetPrefabArmor(); } @@ -42,6 +76,18 @@ internal void AssignCraftingTable(CraftingTable craftingTable, int stationLevel) _item.Crafting.Add(craftingTable,stationLevel); } + internal void AssignCraftingTable(string craftingTable, int stationLevel) + { + if (Enum.TryParse(craftingTable, true, out var tableEnum)) + { + _item.Crafting.Add(tableEnum,stationLevel); + } + else + { + _item.Crafting.Add(craftingTable,stationLevel); + } + } + internal void AddRecipeIngredient(string prefabName, int quantity) { _item.RequiredItems.Add(prefabName,quantity); diff --git a/AdventureBackpacks/Assets/Items/BackpackItem.cs b/AdventureBackpacks/Assets/Items/BackpackItem.cs index ba9b309..1ac3351 100644 --- a/AdventureBackpacks/Assets/Items/BackpackItem.cs +++ b/AdventureBackpacks/Assets/Items/BackpackItem.cs @@ -56,18 +56,47 @@ public int InceptionCounter internal ILogIt Log => _logger; + protected BackpackItem(ABAPI.BackpackDefinition definition, GameObject goItem) + : base(goItem,definition.ItemName) + { + _configSection = string.IsNullOrEmpty(definition.ConfigSection) ? $"Backpack: {definition.ItemName}" : definition.ConfigSection; + SetupLocalization(); + SetupBackpackDef(); + } + + protected BackpackItem(ABAPI.BackpackDefinition definition) + : base(definition.AssetBundle,definition.PrefabName,definition.ItemName) + { + _configSection = string.IsNullOrEmpty(definition.ConfigSection) ? $"Backpack: {definition.ItemName}" : definition.ConfigSection; + SetupLocalization(); + SetupBackpackDef(); + } + protected BackpackItem(string prefabName, string itemName, string configSection = "", bool externalLocalize = false) : base(prefabName,itemName) { _configSection = string.IsNullOrEmpty(configSection) ? $"Backpack: {itemName}" : configSection; _englishSection = english.Localize(_configSection); + if (externalLocalize) _localizedCategory = Localization.m_instance.Localize(_configSection); else _localizedCategory = Localization.instance.Localize(_configSection); + SetupBackpackDef(); + } + + internal void SetupLocalization() + { + _englishSection = english.Localize(_configSection); + _localizedCategory = Localization.m_instance.Localize(_configSection); + if (_localizedCategory.Equals(_configSection)) + _localizedCategory = Localization.instance.Localize(_configSection); + } + + private void SetupBackpackDef() + { Item.SectionName = _configSection; BackpackSize = new(); - InceptionTimer = new System.Timers.Timer(10000); InceptionTimer.AutoReset = false; InceptionTimer.Enabled = false; diff --git a/AdventureBackpacks/Assets/Items/BackpackItems/BackpackNecromancy.cs b/AdventureBackpacks/Assets/Items/BackpackItems/BackpackNecromancy.cs deleted file mode 100644 index c8819e6..0000000 --- a/AdventureBackpacks/Assets/Items/BackpackItems/BackpackNecromancy.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using AdventureBackpacks.API; -using AdventureBackpacks.Assets.Factories; -using ItemManager; -using Vapok.Common.Managers.StatusEffects; - -namespace AdventureBackpacks.Assets.Items.BackpackItems; - -internal class BackpackNecromancy : BackpackItem -{ - public BackpackNecromancy(string prefabName, string itemName) : base(prefabName, itemName,"",true) - { - RegisterConfigSettings(); - - Item.Configurable = Configurability.Recipe | Configurability.Drop; - AssignCraftingTable(CraftingTable.Workbench,1); - - Item.MaximumRequiredStationLevel = 4; - - AddRecipeIngredient("ChebGonaz_SpectralShroud",1); - AddRecipeIngredient("TrollHide",5); - - AddUpgradeIngredient("Chain", 1); - AddUpgradeIngredient("TrollHide", 5); - - Item.DropsFrom.Add("ChebGonaz_GuardianWraith", 0.002f, 1); - } - - internal sealed override void RegisterConfigSettings() - { - RegisterBackpackBiome(BackpackBiomes.Necromancy | BackpackBiomes.BlackForest); - RegisterBackpackSize(1,3,3); - RegisterBackpackSize(2,4,3); - RegisterBackpackSize(3,5,3); - RegisterBackpackSize(4,6,3); - RegisterWeightMultiplier(); - RegisterCarryBonus(20); - RegisterSpeedMod(); - RegisterShaderSwap(); - if ((BackpackBiome.Value & BackpackBiomes.Necromancy) != 0) - EffectsFactory.EffectList[BackpackEffect.NecromancyArmor].RegisterEffectBiomeQuality(BackpackBiomes.Necromancy, 1); - } - - internal override void UpdateStatusEffects(int quality, CustomSE statusEffects, List modifierList, ItemDrop.ItemData itemData) - { - itemData.m_shared.m_movementModifier = SpeedMod.Value/quality; - - ((SE_Stats)statusEffects.Effect).m_addMaxCarryWeight = CarryBonus.Value * quality; - } -} \ No newline at end of file diff --git a/AdventureBackpacks/Assets/Items/BackpackItems/ExternalBackpack.cs b/AdventureBackpacks/Assets/Items/BackpackItems/ExternalBackpack.cs new file mode 100644 index 0000000..f88e853 --- /dev/null +++ b/AdventureBackpacks/Assets/Items/BackpackItems/ExternalBackpack.cs @@ -0,0 +1,110 @@ +using System.Collections.Generic; +using AdventureBackpacks.API; +using AdventureBackpacks.Assets.Effects; +using AdventureBackpacks.Assets.Factories; +using ItemManager; +using UnityEngine; +using Vapok.Common.Managers.StatusEffects; + +namespace AdventureBackpacks.Assets.Items.BackpackItems; + +internal class ExternalBackpack : BackpackItem +{ + private readonly ABAPI.BackpackDefinition _backpackDefinition; + private static EffectsBase _setEffectsBase = null; + + public ExternalBackpack(ABAPI.BackpackDefinition backpackDefinition, GameObject goItem) : base(backpackDefinition, goItem) + { + _backpackDefinition = backpackDefinition; + SetupBackpack(); + } + public ExternalBackpack(ABAPI.BackpackDefinition backpackDefinition) : base(backpackDefinition) + { + _backpackDefinition = backpackDefinition; + SetupBackpack(); + } + + public void SetupBackpack() + { + RegisterConfigSettings(); + + Item.Configurable = Configurability.Recipe | Configurability.Drop; + + AssignCraftingTable(_backpackDefinition.CraftingTable,_backpackDefinition.StationLevel); + + Item.MaximumRequiredStationLevel = _backpackDefinition.MaxRequiredStationLevel; + + foreach (var ingredient in _backpackDefinition.RecipeIngredients) + { + AddRecipeIngredient(ingredient.ItemPrefabName,ingredient.Quantity); + } + + foreach (var ingredient in _backpackDefinition.UpgradeIngredients) + { + AddUpgradeIngredient(ingredient.ItemPrefabName,ingredient.Quantity); + } + + foreach (var target in _backpackDefinition.DropsFrom) + { + Item.DropsFrom.Add(target.Creature, target.Chance, target.Min, target.Max); + } + + AdventureBackpacks.Waiter.StatusChanged += (_, _) => RegisterEffects(); + } + + private void RegisterEffects() + { + foreach (var applyEffect in _backpackDefinition.EffectsToApply) + { + if ((BackpackBiome.Value & applyEffect.Key) == 0) continue; + + foreach (var effectsBase in EffectsFactory.AllEffects) + { + if (effectsBase.GetStatusEffect() == null) + effectsBase.LoadStatusEffect(); + + if (effectsBase.GetStatusEffect().m_name.Equals(applyEffect.Value.Key.m_name)) + { + if (_backpackDefinition.ItemSetStatusEffect != null && + _backpackDefinition.ItemSetStatusEffect.m_name.Equals(effectsBase.GetStatusEffect().m_name)) + _setEffectsBase = effectsBase; + + effectsBase.RegisterEffectBiomeQuality(applyEffect.Key, applyEffect.Value.Value); + } + } + } + } + + internal sealed override void RegisterConfigSettings() + { + RegisterBackpackBiome(_backpackDefinition.BackpackBiome); + foreach (var sizeConfig in _backpackDefinition.BackpackSizeByQuality) + { + RegisterBackpackSize(sizeConfig.Key,(int)sizeConfig.Value.x,(int)sizeConfig.Value.y); + } + RegisterStatusEffectInfo(); + RegisterWeightMultiplier(_backpackDefinition.WeightMultiplier); + RegisterCarryBonus(_backpackDefinition.CarryBonus); + RegisterSpeedMod(_backpackDefinition.SpeedMod); + RegisterShaderSwap(); + } + + internal override void UpdateStatusEffects(int quality, CustomSE statusEffects, List modifierList, ItemDrop.ItemData itemData) + { + itemData.m_shared.m_movementModifier = SpeedMod.Value/quality; + + if (_setEffectsBase != null) + { + if (_setEffectsBase.HasActiveStatusEffect(itemData, out var necroSetEffect)) + { + itemData.m_shared.m_setStatusEffect = necroSetEffect; + } + else + { + itemData.m_shared.m_setStatusEffect = null; + } + } + + ((SE_Stats)statusEffects.Effect).m_addMaxCarryWeight = CarryBonus.Value * quality; + } +} \ No newline at end of file diff --git a/AdventureBackpacks/Compats/ChebsNecromancy.cs b/AdventureBackpacks/Compats/ChebsNecromancy.cs new file mode 100644 index 0000000..eed20ea --- /dev/null +++ b/AdventureBackpacks/Compats/ChebsNecromancy.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.IO; +using AdventureBackpacks.API; +using AdventureBackpacks.Features; +using BepInEx; +using BepInEx.Bootstrap; +using UnityEngine; + +namespace AdventureBackpacks.Compats; + +public static class ChebsNecromancy +{ + public static void SetupNecromancyBackpackUsingApi() + { + var effectName = "SetEffect_NecromancyArmor"; + var assetName = "chebgonaz"; + var assetFolderName = "Assets"; + var assetBundlePath = ""; + AssetBundle assetBundle; + var necromancySkillIdentifier = "friendlyskeletonwand_necromancy_skill"; + Skills.SkillType skillUid; + StatusEffect externalStatusEffect = null; + + if (!ABAPI.IsLoaded()) return; + + var pluginInfo = Chainloader.PluginInfos["com.chebgonaz.ChebsNecromancy"]; + assetBundlePath = Path.Combine(Paths.PluginPath,Path.GetDirectoryName(pluginInfo.Location) ?? "", assetFolderName, assetName); + + if (!File.Exists(assetBundlePath)) + assetBundlePath = Path.Combine(Paths.PluginPath,Path.GetDirectoryName(pluginInfo.Location) ?? "", assetName); + + assetBundle = !File.Exists(assetBundlePath) ? null : AssetBundle.LoadFromFile(assetBundlePath); + + if (assetBundle == null) + { + AdventureBackpacks.Log.Error($"Can't find Asset Bundle for Status Effect: {effectName} - Effect Not Registered"); + return; + } + + var num = Math.Abs(necromancySkillIdentifier.GetStableHashCode()); + + skillUid = (Skills.SkillType)num; + + var seStat = assetBundle.LoadAsset(effectName); + if (seStat != null) + { + seStat.m_skillLevel = skillUid; + seStat.m_skillLevelModifier = 10; //This is obviously a value that can change, but let's keep it to the value in the mod using the API. + } + externalStatusEffect = seStat; + + //Register Effect First + var effectDefinition = new ABAPI.EffectDefinition( + "Necromancy Armor Effect", + "Necromancy Armor Effect", + effectName, + "When activated the backpack provides the Necromancy Armor effect from Cheb's Necromancy", + externalStatusEffect + ); + + ABAPI.RegisterEffect(effectDefinition); + + //Register Backpack + var backpackAssetBundle = Utilities.LoadAssetBundle("chebsbackpack","Assets.Bundles"); + + if (backpackAssetBundle == null) + { + AdventureBackpacks.Log.Warning($"Asset Bundle Not Found"); + return; + } + var backpackPrefab = "BackpackNecromancy"; + + var backpackDefinition = new ABAPI.BackpackDefinition(backpackAssetBundle, backpackPrefab); + + backpackDefinition.ItemName = "$item_friendlyskeletonwand_spectralshroud_backpack"; + backpackDefinition.CraftingTable = "piece_workbench"; + backpackDefinition.StationLevel = 1; + backpackDefinition.MaxRequiredStationLevel = 4; + backpackDefinition.RecipeIngredients.Add(new ABAPI.RecipeIngredient("ChebGonaz_SpectralShroud",1)); + backpackDefinition.RecipeIngredients.Add(new ABAPI.RecipeIngredient("TrollHide",5)); + backpackDefinition.UpgradeIngredients.Add(new ABAPI.RecipeIngredient("Chain", 1)); + backpackDefinition.UpgradeIngredients.Add(new ABAPI.RecipeIngredient("TrollHide", 5)); + backpackDefinition.DropsFrom.Add(new ABAPI.DropTarget("ChebGonaz_GuardianWraith",0.002f, 1)); + + backpackDefinition.BackpackBiome = BackpackBiomes.EffectBiome1 | BackpackBiomes.BlackForest; + backpackDefinition.BackpackSizeByQuality.Add(1,new Vector2(3,3)); + backpackDefinition.BackpackSizeByQuality.Add(2,new Vector2(4,3)); + backpackDefinition.BackpackSizeByQuality.Add(3,new Vector2(5,3)); + backpackDefinition.BackpackSizeByQuality.Add(4,new Vector2(6,3)); + backpackDefinition.WeightMultiplier = 20; + backpackDefinition.EffectsToApply.Add(BackpackBiomes.EffectBiome1,new KeyValuePair(externalStatusEffect,1)); + backpackDefinition.ItemSetStatusEffect = externalStatusEffect; + + ABAPI.RegisterBackpack(backpackDefinition); + } + +} \ No newline at end of file diff --git a/AdventureBackpacks/Features/Utilities.cs b/AdventureBackpacks/Features/Utilities.cs new file mode 100644 index 0000000..ec77b4d --- /dev/null +++ b/AdventureBackpacks/Features/Utilities.cs @@ -0,0 +1,12 @@ +using ItemManager; +using UnityEngine; + +namespace AdventureBackpacks.Features; + +public static class Utilities +{ + public static AssetBundle LoadAssetBundle(string filename, string folderName) + { + return PrefabManager.RegisterAssetBundle(filename, folderName); + } +} \ No newline at end of file diff --git a/AdventureBackpacks/Patches/FejdStartup.cs b/AdventureBackpacks/Patches/FejdStartup.cs index 3f62fd4..34a6fbf 100644 --- a/AdventureBackpacks/Patches/FejdStartup.cs +++ b/AdventureBackpacks/Patches/FejdStartup.cs @@ -4,12 +4,12 @@ namespace AdventureBackpacks.Patches; public class FejdStartupPatches { - [HarmonyPatch(typeof(FejdStartup), nameof(FejdStartup.Awake))] + [HarmonyPatch(typeof(FejdStartup), nameof(FejdStartup.Start))] [HarmonyAfter("org.bepinex.helpers.LocalizationManager")] [HarmonyBefore("org.bepinex.helpers.ItemManager")] public static class FejdStartupAwakePatch { - static void Prefix() + static void Postfix() { AdventureBackpacks.Waiter.ValheimIsAwake(true); } diff --git a/AdventureBackpacks/Properties/AssemblyInfo.cs b/AdventureBackpacks/Properties/AssemblyInfo.cs index cf419b1..f34aa75 100644 --- a/AdventureBackpacks/Properties/AssemblyInfo.cs +++ b/AdventureBackpacks/Properties/AssemblyInfo.cs @@ -32,9 +32,9 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] #if ! API -[assembly: AssemblyVersion("1.7.0.0")] -[assembly: AssemblyFileVersion("1.7.0.0")] +[assembly: AssemblyVersion("1.7.1.0")] +[assembly: AssemblyFileVersion("1.7.1.0")] #else -[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.0.0")] +[assembly: AssemblyVersion("1.1.0")] +[assembly: AssemblyFileVersion("1.1.0")] #endif diff --git a/AdventureBackpacks/packages.config b/AdventureBackpacks/packages.config index e4e1baa..f936a7c 100644 --- a/AdventureBackpacks/packages.config +++ b/AdventureBackpacks/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 09664cf..839b099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ -# 1.7.0 - Release of the Adventure Backpacks API +# 1.7.1 - Release of the Adventure Backpacks API - Effect and Backpack Creation +* API (v1.1) now supports bringing in custom effects and backpacks + * [Documentation](https://github.com/Vapok/AdventureBackpacks/blob/main/Docs/AdventureBackpacksAPI.md) + * [Download ABAPI.DLL from GitHub](https://github.com/Vapok/AdventureBackpacks/releases) +* Cheb's Necromany Backpack Integration converted to API +* Updated to 0.218.28 Valheim + +# 1.7.0 - Release of the Adventure Backpacks API * Initial Release of the ABAPI. * [Documentation](https://github.com/Vapok/AdventureBackpacks/blob/main/Docs/AdventureBackpacksAPI.md) * [Download ABAPI.DLL from GitHub](https://github.com/Vapok/AdventureBackpacks/releases) * Valheim Update 0.217.27 * Upgraded to .net 4.7.2 -
Changelog History (click to expand) diff --git a/Docs/AdventureBackpacksAPI.md b/Docs/AdventureBackpacksAPI.md index e504893..21f7731 100644 --- a/Docs/AdventureBackpacksAPI.md +++ b/Docs/AdventureBackpacksAPI.md @@ -8,41 +8,74 @@ - [GetActiveBackpackStatusEffects()](#M-AdventureBackpacks-API-ABAPI-GetActiveBackpackStatusEffects 'AdventureBackpacks.API.ABAPI.GetActiveBackpackStatusEffects') - [GetBackpack(itemData)](#M-AdventureBackpacks-API-ABAPI-GetBackpack-ItemDrop-ItemData- 'AdventureBackpacks.API.ABAPI.GetBackpack(ItemDrop.ItemData)') - [GetEquippedBackpack(player)](#M-AdventureBackpacks-API-ABAPI-GetEquippedBackpack-Player- 'AdventureBackpacks.API.ABAPI.GetEquippedBackpack(Player)') + - [GetRegisterdStatusEffects()](#M-AdventureBackpacks-API-ABAPI-GetRegisterdStatusEffects 'AdventureBackpacks.API.ABAPI.GetRegisterdStatusEffects') - [IsBackpack(itemData)](#M-AdventureBackpacks-API-ABAPI-IsBackpack-ItemDrop-ItemData- 'AdventureBackpacks.API.ABAPI.IsBackpack(ItemDrop.ItemData)') - [IsBackpackEquipped(player)](#M-AdventureBackpacks-API-ABAPI-IsBackpackEquipped-Player- 'AdventureBackpacks.API.ABAPI.IsBackpackEquipped(Player)') - [IsLoaded()](#M-AdventureBackpacks-API-ABAPI-IsLoaded 'AdventureBackpacks.API.ABAPI.IsLoaded') - [IsThisBackpackEquipped(player,itemData)](#M-AdventureBackpacks-API-ABAPI-IsThisBackpackEquipped-Player,ItemDrop-ItemData- 'AdventureBackpacks.API.ABAPI.IsThisBackpackEquipped(Player,ItemDrop.ItemData)') - [OpenBackpack(player,gui)](#M-AdventureBackpacks-API-ABAPI-OpenBackpack-Player,InventoryGui- 'AdventureBackpacks.API.ABAPI.OpenBackpack(Player,InventoryGui)') + - [RegisterBackpack(definition)](#M-AdventureBackpacks-API-ABAPI-RegisterBackpack-AdventureBackpacks-API-ABAPI-BackpackDefinition- 'AdventureBackpacks.API.ABAPI.RegisterBackpack(AdventureBackpacks.API.ABAPI.BackpackDefinition)') + - [RegisterEffect(effectDefinition)](#M-AdventureBackpacks-API-ABAPI-RegisterEffect-AdventureBackpacks-API-ABAPI-EffectDefinition- 'AdventureBackpacks.API.ABAPI.RegisterEffect(AdventureBackpacks.API.ABAPI.EffectDefinition)') - [Backpack](#T-AdventureBackpacks-API-ABAPI-Backpack 'AdventureBackpacks.API.ABAPI.Backpack') - [Definition](#F-AdventureBackpacks-API-ABAPI-Backpack-Definition 'AdventureBackpacks.API.ABAPI.Backpack.Definition') - [Inventory](#F-AdventureBackpacks-API-ABAPI-Backpack-Inventory 'AdventureBackpacks.API.ABAPI.Backpack.Inventory') - [ItemData](#F-AdventureBackpacks-API-ABAPI-Backpack-ItemData 'AdventureBackpacks.API.ABAPI.Backpack.ItemData') - [Name](#F-AdventureBackpacks-API-ABAPI-Backpack-Name 'AdventureBackpacks.API.ABAPI.Backpack.Name') - [BackpackBiomes](#T-AdventureBackpacks-API-BackpackBiomes 'AdventureBackpacks.API.BackpackBiomes') + - [Ashlands](#F-AdventureBackpacks-API-BackpackBiomes-Ashlands 'AdventureBackpacks.API.BackpackBiomes.Ashlands') - [BlackForest](#F-AdventureBackpacks-API-BackpackBiomes-BlackForest 'AdventureBackpacks.API.BackpackBiomes.BlackForest') + - [DeepNorth](#F-AdventureBackpacks-API-BackpackBiomes-DeepNorth 'AdventureBackpacks.API.BackpackBiomes.DeepNorth') + - [EffectBiome1](#F-AdventureBackpacks-API-BackpackBiomes-EffectBiome1 'AdventureBackpacks.API.BackpackBiomes.EffectBiome1') + - [EffectBiome2](#F-AdventureBackpacks-API-BackpackBiomes-EffectBiome2 'AdventureBackpacks.API.BackpackBiomes.EffectBiome2') + - [EffectBiome3](#F-AdventureBackpacks-API-BackpackBiomes-EffectBiome3 'AdventureBackpacks.API.BackpackBiomes.EffectBiome3') + - [EffectBiome4](#F-AdventureBackpacks-API-BackpackBiomes-EffectBiome4 'AdventureBackpacks.API.BackpackBiomes.EffectBiome4') + - [EffectBiome5](#F-AdventureBackpacks-API-BackpackBiomes-EffectBiome5 'AdventureBackpacks.API.BackpackBiomes.EffectBiome5') - [Meadows](#F-AdventureBackpacks-API-BackpackBiomes-Meadows 'AdventureBackpacks.API.BackpackBiomes.Meadows') - [Mistlands](#F-AdventureBackpacks-API-BackpackBiomes-Mistlands 'AdventureBackpacks.API.BackpackBiomes.Mistlands') - [Mountains](#F-AdventureBackpacks-API-BackpackBiomes-Mountains 'AdventureBackpacks.API.BackpackBiomes.Mountains') - - [Necromancy](#F-AdventureBackpacks-API-BackpackBiomes-Necromancy 'AdventureBackpacks.API.BackpackBiomes.Necromancy') - [None](#F-AdventureBackpacks-API-BackpackBiomes-None 'AdventureBackpacks.API.BackpackBiomes.None') - [Plains](#F-AdventureBackpacks-API-BackpackBiomes-Plains 'AdventureBackpacks.API.BackpackBiomes.Plains') - [Swamp](#F-AdventureBackpacks-API-BackpackBiomes-Swamp 'AdventureBackpacks.API.BackpackBiomes.Swamp') - [BackpackDefinition](#T-AdventureBackpacks-API-ABAPI-BackpackDefinition 'AdventureBackpacks.API.ABAPI.BackpackDefinition') - - [AssetFolderName](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-AssetFolderName 'AdventureBackpacks.API.ABAPI.BackpackDefinition.AssetFolderName') - - [AssetName](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-AssetName 'AdventureBackpacks.API.ABAPI.BackpackDefinition.AssetName') + - [#ctor()](#M-AdventureBackpacks-API-ABAPI-BackpackDefinition-#ctor 'AdventureBackpacks.API.ABAPI.BackpackDefinition.#ctor') + - [#ctor(backPackGo)](#M-AdventureBackpacks-API-ABAPI-BackpackDefinition-#ctor-UnityEngine-GameObject- 'AdventureBackpacks.API.ABAPI.BackpackDefinition.#ctor(UnityEngine.GameObject)') + - [#ctor(assetBundle,prefabName)](#M-AdventureBackpacks-API-ABAPI-BackpackDefinition-#ctor-UnityEngine-AssetBundle,System-String- 'AdventureBackpacks.API.ABAPI.BackpackDefinition.#ctor(UnityEngine.AssetBundle,System.String)') + - [AssetBundle](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-AssetBundle 'AdventureBackpacks.API.ABAPI.BackpackDefinition.AssetBundle') + - [BackPackGo](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-BackPackGo 'AdventureBackpacks.API.ABAPI.BackpackDefinition.BackPackGo') - [BackpackBiome](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-BackpackBiome 'AdventureBackpacks.API.ABAPI.BackpackDefinition.BackpackBiome') - [BackpackSizeByQuality](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-BackpackSizeByQuality 'AdventureBackpacks.API.ABAPI.BackpackDefinition.BackpackSizeByQuality') - [CarryBonus](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-CarryBonus 'AdventureBackpacks.API.ABAPI.BackpackDefinition.CarryBonus') + - [ConfigSection](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-ConfigSection 'AdventureBackpacks.API.ABAPI.BackpackDefinition.ConfigSection') + - [CraftingTable](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-CraftingTable 'AdventureBackpacks.API.ABAPI.BackpackDefinition.CraftingTable') + - [DropsFrom](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-DropsFrom 'AdventureBackpacks.API.ABAPI.BackpackDefinition.DropsFrom') + - [EffectsToApply](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-EffectsToApply 'AdventureBackpacks.API.ABAPI.BackpackDefinition.EffectsToApply') - [EnableFreezing](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-EnableFreezing 'AdventureBackpacks.API.ABAPI.BackpackDefinition.EnableFreezing') - [ItemName](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-ItemName 'AdventureBackpacks.API.ABAPI.BackpackDefinition.ItemName') + - [ItemSetStatusEffect](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-ItemSetStatusEffect 'AdventureBackpacks.API.ABAPI.BackpackDefinition.ItemSetStatusEffect') + - [MaxRequiredStationLevel](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-MaxRequiredStationLevel 'AdventureBackpacks.API.ABAPI.BackpackDefinition.MaxRequiredStationLevel') - [PrefabName](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-PrefabName 'AdventureBackpacks.API.ABAPI.BackpackDefinition.PrefabName') + - [RecipeIngredients](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-RecipeIngredients 'AdventureBackpacks.API.ABAPI.BackpackDefinition.RecipeIngredients') - [SpeedMod](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-SpeedMod 'AdventureBackpacks.API.ABAPI.BackpackDefinition.SpeedMod') + - [StationLevel](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-StationLevel 'AdventureBackpacks.API.ABAPI.BackpackDefinition.StationLevel') + - [UpgradeIngredients](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-UpgradeIngredients 'AdventureBackpacks.API.ABAPI.BackpackDefinition.UpgradeIngredients') - [WeightMultiplier](#F-AdventureBackpacks-API-ABAPI-BackpackDefinition-WeightMultiplier 'AdventureBackpacks.API.ABAPI.BackpackDefinition.WeightMultiplier') - [DropTarget](#T-AdventureBackpacks-API-ABAPI-DropTarget 'AdventureBackpacks.API.ABAPI.DropTarget') + - [#ctor(creature,chance,min,max)](#M-AdventureBackpacks-API-ABAPI-DropTarget-#ctor-System-String,System-Single,System-Int32,System-Nullable{System-Int32}- 'AdventureBackpacks.API.ABAPI.DropTarget.#ctor(System.String,System.Single,System.Int32,System.Nullable{System.Int32})') - [Chance](#F-AdventureBackpacks-API-ABAPI-DropTarget-Chance 'AdventureBackpacks.API.ABAPI.DropTarget.Chance') - [Creature](#F-AdventureBackpacks-API-ABAPI-DropTarget-Creature 'AdventureBackpacks.API.ABAPI.DropTarget.Creature') - [Max](#F-AdventureBackpacks-API-ABAPI-DropTarget-Max 'AdventureBackpacks.API.ABAPI.DropTarget.Max') - [Min](#F-AdventureBackpacks-API-ABAPI-DropTarget-Min 'AdventureBackpacks.API.ABAPI.DropTarget.Min') +- [EffectDefinition](#T-AdventureBackpacks-API-ABAPI-EffectDefinition 'AdventureBackpacks.API.ABAPI.EffectDefinition') + - [#ctor(name,localizedName,effectName,description,statusEffect)](#M-AdventureBackpacks-API-ABAPI-EffectDefinition-#ctor-System-String,System-String,System-String,System-String,StatusEffect- 'AdventureBackpacks.API.ABAPI.EffectDefinition.#ctor(System.String,System.String,System.String,System.String,StatusEffect)') + - [Description](#F-AdventureBackpacks-API-ABAPI-EffectDefinition-Description 'AdventureBackpacks.API.ABAPI.EffectDefinition.Description') + - [EffectName](#F-AdventureBackpacks-API-ABAPI-EffectDefinition-EffectName 'AdventureBackpacks.API.ABAPI.EffectDefinition.EffectName') + - [LocalizedName](#F-AdventureBackpacks-API-ABAPI-EffectDefinition-LocalizedName 'AdventureBackpacks.API.ABAPI.EffectDefinition.LocalizedName') + - [Name](#F-AdventureBackpacks-API-ABAPI-EffectDefinition-Name 'AdventureBackpacks.API.ABAPI.EffectDefinition.Name') + - [StatusEffect](#F-AdventureBackpacks-API-ABAPI-EffectDefinition-StatusEffect 'AdventureBackpacks.API.ABAPI.EffectDefinition.StatusEffect') +- [RecipeIngredient](#T-AdventureBackpacks-API-ABAPI-RecipeIngredient 'AdventureBackpacks.API.ABAPI.RecipeIngredient') + - [#ctor(itemPrefabName,quantity)](#M-AdventureBackpacks-API-ABAPI-RecipeIngredient-#ctor-System-String,System-Int32- 'AdventureBackpacks.API.ABAPI.RecipeIngredient.#ctor(System.String,System.Int32)') + - [ItemPrefabName](#F-AdventureBackpacks-API-ABAPI-RecipeIngredient-ItemPrefabName 'AdventureBackpacks.API.ABAPI.RecipeIngredient.ItemPrefabName') + - [Quantity](#F-AdventureBackpacks-API-ABAPI-RecipeIngredient-Quantity 'AdventureBackpacks.API.ABAPI.RecipeIngredient.Quantity') ## ABAPI `type` @@ -121,6 +154,21 @@ Nullable Backpack Object | ---- | ---- | ----------- | | player | [Player](#T-Player 'Player') | Player, usually Player.m_localPlayer | + +### GetRegisterdStatusEffects() `method` + +##### Summary + +Retrieves all Status Effects Registered with Adventure Backpacks + +##### Returns + +HashSet of Status Effects. + +##### Parameters + +This method has no parameters. + ### IsBackpack(itemData) `method` @@ -202,6 +250,32 @@ Method to activate the backpack on the local player's GUI and open it. Use in co | player | [Player](#T-Player 'Player') | Player, usually Player.m_localPlayer | | gui | [InventoryGui](#T-InventoryGui 'InventoryGui') | The instance of InventoryGui | + +### RegisterBackpack(definition) `method` + +##### Summary + +Use this method in the Awake() of your mod to register a new Backpack that can be utilized on Adventure Backpacks. + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| definition | [AdventureBackpacks.API.ABAPI.BackpackDefinition](#T-AdventureBackpacks-API-ABAPI-BackpackDefinition 'AdventureBackpacks.API.ABAPI.BackpackDefinition') | Create a new BackpackDefinition that contains the overall parameters that are needed to register the new backpack. | + + +### RegisterEffect(effectDefinition) `method` + +##### Summary + +Use this method in the Awake() of your mod to register a Status Effect that can be utilized on Adventure Backpacks + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| effectDefinition | [AdventureBackpacks.API.ABAPI.EffectDefinition](#T-AdventureBackpacks-API-ABAPI-EffectDefinition 'AdventureBackpacks.API.ABAPI.EffectDefinition') | Create a new EffectDefinition that contains the overall parameters that are needed to register the new effect. | + ## Backpack `type` @@ -251,6 +325,15 @@ AdventureBackpacks.API ##### Summary This is a Flags enum for determining Backpack Biomes. This is not representative of Heightmap.Biomes. +This is instead a way of creating sets of Effects. Default Adventure Backpacks will utilize Biome names. +Custom External Effects can pick and choose between the Custom Effect flags as well. + + +### Ashlands `constants` + +##### Summary + +Ashland Backpack Effects ### BlackForest `constants` @@ -259,6 +342,48 @@ This is a Flags enum for determining Backpack Biomes. This is not representative Black Forest Backpack Effects + +### DeepNorth `constants` + +##### Summary + +DeepNorth Backpack Effects + + +### EffectBiome1 `constants` + +##### Summary + +Custom Biome for use with External Effects + + +### EffectBiome2 `constants` + +##### Summary + +Custom Biome for use with External Effects + + +### EffectBiome3 `constants` + +##### Summary + +Custom Biome for use with External Effects + + +### EffectBiome4 `constants` + +##### Summary + +Custom Biome for use with External Effects + + +### EffectBiome5 `constants` + +##### Summary + +Custom Biome for use with External Effects + ### Meadows `constants` @@ -280,13 +405,6 @@ Mistlands Backpack Effects Mountains Backpack Effects - -### Necromancy `constants` - -##### Summary - -Special Biome configured for Cheb's Necromancy - ### None `constants` @@ -318,20 +436,68 @@ AdventureBackpacks.API.ABAPI ##### Summary Backpack Definition Settings +Use this object to create backpack definitions for adding Backpacks to Adventure Backpacks. +You can use either the GameObject directly, or provide your AssetBundle object and the PrefabName. - -### AssetFolderName `constants` + +### #ctor() `constructor` ##### Summary -Folder containing the Asset Bundle +Default Constructor + +##### Parameters + +This constructor has no parameters. + + +### #ctor(backPackGo) `constructor` + +##### Summary + +Use this constructor when adding a backpack using the GameObject +The item should have ItemDrop.ItemData on the item, and it should be an item that is utilizing the Shoulder slot. +Equipped Detection won't detect if not in the shoulder slot. +TODO: Make this more flexible for additional slots through AzuEPI + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| backPackGo | [UnityEngine.GameObject](#T-UnityEngine-GameObject 'UnityEngine.GameObject') | GameObject of | - -### AssetName `constants` + +### #ctor(assetBundle,prefabName) `constructor` ##### Summary -Asset Bundle Name +Use this constructor when adding a backpack using the AssetBundle and Prefab Name +The item should have ItemDrop.ItemData on the item, and it should be an item that is utilizing the Shoulder slot. +Equipped Detection won't detect if not in the shoulder slot. +TODO: Make this more flexible for additional slots through AzuEPI + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| assetBundle | [UnityEngine.AssetBundle](#T-UnityEngine-AssetBundle 'UnityEngine.AssetBundle') | Provide the Asset Bundle that contains the backpack prefab | +| prefabName | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Prefab name of the backpack | + + +### AssetBundle `constants` + +##### Summary + +Asset Bundle containing the Backpack +(Not required if GameObject is provided) + + +### BackPackGo `constants` + +##### Summary + +Backpack GameObject +(Not required if AssetBundle and Prefab Name are provided) ### BackpackBiome `constants` @@ -339,6 +505,8 @@ Asset Bundle Name ##### Summary Provides the configured biomes settings applied to the backpack. +This is flag enum. +(e.g. "BackpackBiomes.Meadows" or "BackpackBiomes.Meadows | BackpackBiomes.BlackForest" to select multiple biomes. ### BackpackSizeByQuality `constants` @@ -355,6 +523,47 @@ Dictionary value is the Vector2 object. ##### Summary Provides the additional carry weight bonus applied to backpacks. +For registering a new backpack, this is the default value. + + +### ConfigSection `constants` + +##### Summary + +Custom Configuration Section Name in Adventure Backpacks. +If left empty, will use default section name. +(e.g. Backpack: {$backpack_itemname} ) + + +### CraftingTable `constants` + +##### Summary + +Name of Crafting Table that the Backpack can be crafted at. +If left empty, will disable crafting at any table. +Can also include custom table names. +(e.g. piece_workbench, forge, piece_stonecutter) + + +### DropsFrom `constants` + +##### Summary + +List of Ingredients for Upgrading. + + +### EffectsToApply `constants` + +##### Summary + +Dictionary of StatusEffect's to apply to the backpack when equipped. +Dictionary Key is the BackpackBiome that needs to be applied to the Backpack for Effect to be activated. +Dictionary Value is a Key Value Pair of a Status Effect to apply: +Key of the KVP is the actual Status Effect +Value of the KVP is the default int Quality level that of the backpack before the effect is applied. +(examples of the quality level: 1 - 4) +Use GetRegisteredStatusEffects() to determine which status effect Adventure Backpacks is aware of. +Use RegisterEffect() first to register new status effects. ### EnableFreezing `constants` @@ -369,6 +578,24 @@ Provides whether the wearer of the backpack will freeze or not. ##### Summary Item Name of the Backpack. Use the $_name localize token. +(e.g. $vapok_mod_rugged_backpack) + + +### ItemSetStatusEffect `constants` + +##### Summary + +When backpack is equipped, set what the Set Effect Status Effect Should. +If left empty, none will be equipped. +Note: Be sure this is one of the effects included in EffectsToApply. + + +### MaxRequiredStationLevel `constants` + +##### Summary + +Max Crafting Station Level to upgrade, and repair. +(e.g. 1, 2, etc.) ### PrefabName `constants` @@ -376,6 +603,14 @@ Item Name of the Backpack. Use the $_name localize token. ##### Summary Prefab Name of the Backpack Asset +(Not required if GameObject is provided) + + +### RecipeIngredients `constants` + +##### Summary + +List of Recipe Ingredients. ### SpeedMod `constants` @@ -383,6 +618,22 @@ Prefab Name of the Backpack Asset ##### Summary Provides the Speed Modification that is applied on the backpack. +For registering a new backpack, this is the default value. + + +### StationLevel `constants` + +##### Summary + +Minimum Level of Crafting Table Station before Bag can be crafted +(e.g. 1, 2, etc.) + + +### UpgradeIngredients `constants` + +##### Summary + +List of Ingredients for Upgrading. ### WeightMultiplier `constants` @@ -390,6 +641,7 @@ Provides the Speed Modification that is applied on the backpack. ##### Summary Provides the configured weight multiplier that reduces the weight of the items in the backpack. +For registering a new backpack, this is the default value. ## DropTarget `type` @@ -402,6 +654,22 @@ AdventureBackpacks.API.ABAPI Configuration of Drop Target + +### #ctor(creature,chance,min,max) `constructor` + +##### Summary + +Drop Target Constructor + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| creature | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Prefab name of Creature | +| chance | [System.Single](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Single 'System.Single') | Chance to Drop Float | +| min | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | Minimum amount to drop. | +| max | [System.Nullable{System.Int32}](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Nullable 'System.Nullable{System.Int32}') | Max amount to drop. | + ### Chance `constants` @@ -429,3 +697,110 @@ Maximum number of items that can drop. ##### Summary Min number of items that can drop. + + +## EffectDefinition `type` + +##### Namespace + +AdventureBackpacks.API.ABAPI + +##### Summary + +Create anew EffectDefinition in order to register status effects. + + +### #ctor(name,localizedName,effectName,description,statusEffect) `constructor` + +##### Summary + +Create anew EffectDefinition in order to register status effects. + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| name | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | | +| localizedName | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | | +| effectName | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | | +| description | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | | +| statusEffect | [StatusEffect](#T-StatusEffect 'StatusEffect') | | + + +### Description `constants` + +##### Summary + +Description of the Status Effect. Shows up in Configuration. + + +### EffectName `constants` + +##### Summary + +This is the registered Effect name +(e.g. SetEffect_NecromancyArmor or SE_Demister) + + +### LocalizedName `constants` + +##### Summary + +This is the Localized Translated Effect Name. +This is used in places like the Configuration and in the HUD/GUI +(e.g. "Water Resistance"). + + +### Name `constants` + +##### Summary + +This is the Effect Name. +(e.g. "$some_effect_name"). + + +### StatusEffect `constants` + +##### Summary + +This is your actual Status Effect from your own asset bundle or from another source. +As long as it's of the type SE_Stats, you can use it. + + +## RecipeIngredient `type` + +##### Namespace + +AdventureBackpacks.API.ABAPI + +##### Summary + +Defines a Recipe Ingredient + + +### #ctor(itemPrefabName,quantity) `constructor` + +##### Summary + +Create Ingredient Object + +##### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| itemPrefabName | [System.String](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.String 'System.String') | Item Prefab Name | +| quantity | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | Amount of item to consume. | + + +### ItemPrefabName `constants` + +##### Summary + +Prefab Name of Item to include as a recipe ingredient + + +### Quantity `constants` + +##### Summary + +Amount of Item required. diff --git a/README.md b/README.md index a78f52f..b33487f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ learn how to make your very own, Adventure Backpacks! Go forth and wander, ye w * Adventure Backpacks API Available * [Documentation](https://github.com/Vapok/AdventureBackpacks/blob/main/Docs/AdventureBackpacksAPI.md) * [Download ABAPI.DLL from GitHub](https://github.com/Vapok/AdventureBackpacks/releases) + * API Features Include: + * Registering Your Own Status Effects + * Registering your own Backpacks (including models) + * Getting Information about the Player worn backpack. + * Is Item a Backpack + * Is Backpack Equipped + * Get Backpack Information (including Inventory on any backpack item, not just equipped) + * Get Active Backpack Effects + * View which effects are registered to Adventure Backpacks * Each Backpack Biome can be fully configured for progression. * Configure Sizing * Each Quality Level of Backpack can have a different inventory grid size. Simply adjust the width and height in configuration for each quality level. diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets index 2ccf5f7..565233f 100644 Binary files a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets and b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets differ diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets.manifest b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets.manifest index c749ece..bc2b20f 100644 --- a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets.manifest +++ b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/StreamingAssets.manifest @@ -1,7 +1,11 @@ ManifestFileVersion: 0 -CRC: 1499047801 +CRC: 2266818252 AssetBundleManifest: AssetBundleInfos: Info_0: Name: vapokbackpacks Dependencies: {} + Info_1: + Name: chebsbackpack + Dependencies: + Dependency_0: vapokbackpacks diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack new file mode 100644 index 0000000..868bf58 Binary files /dev/null and b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack differ diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack.manifest b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack.manifest new file mode 100644 index 0000000..df08b96 --- /dev/null +++ b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/chebsbackpack.manifest @@ -0,0 +1,66 @@ +ManifestFileVersion: 0 +CRC: 1310559162 +Hashes: + AssetFileHash: + serializedVersion: 2 + Hash: 9d768e868084e4b3096b39b2a9e671a1 + TypeTreeHash: + serializedVersion: 2 + Hash: 1122f44c2c41cea464089586c22ad016 +HashAppended: 0 +ClassTypes: +- Class: 1 + Script: {instanceID: 0} +- Class: 4 + Script: {instanceID: 0} +- Class: 21 + Script: {instanceID: 0} +- Class: 23 + Script: {instanceID: 0} +- Class: 28 + Script: {instanceID: 0} +- Class: 33 + Script: {instanceID: 0} +- Class: 43 + Script: {instanceID: 0} +- Class: 48 + Script: {instanceID: 0} +- Class: 54 + Script: {instanceID: 0} +- Class: 65 + Script: {instanceID: 0} +- Class: 114 + Script: {fileID: 927819712, guid: c1b78fa918b030faf1c1f6f6164daeb2, type: 3} +- Class: 114 + Script: {fileID: 1109157524, guid: c1b78fa918b030faf1c1f6f6164daeb2, type: 3} +- Class: 114 + Script: {fileID: 825357479, guid: c1b78fa918b030faf1c1f6f6164daeb2, type: 3} +- Class: 114 + Script: {fileID: 1521249158, guid: c1b78fa918b030faf1c1f6f6164daeb2, type: 3} +- Class: 115 + Script: {instanceID: 0} +- Class: 137 + Script: {instanceID: 0} +- Class: 183 + Script: {instanceID: 0} +- Class: 198 + Script: {instanceID: 0} +- Class: 199 + Script: {instanceID: 0} +- Class: 213 + Script: {instanceID: 0} +SerializeReferenceClassIdentifiers: +- AssemblyName: assembly_valheim + ClassName: Attack +- AssemblyName: assembly_valheim + ClassName: EffectList +- AssemblyName: assembly_valheim + ClassName: HitData/DamageTypes +- AssemblyName: assembly_valheim + ClassName: ItemDrop/ItemData +- AssemblyName: assembly_valheim + ClassName: ItemDrop/ItemData/SharedData +Assets: +- Assets/vapok/Prefabs/BackpackNecromancy.prefab +Dependencies: +- M:/Code/VapokModBase/AdventureBackpacks/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks index 320ecc3..4736585 100644 Binary files a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks and b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks differ diff --git a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks.manifest b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks.manifest index a964853..4cf1df2 100644 --- a/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks.manifest +++ b/UnityProjects/vapoksbackpacks/vapoksbackpacks/Assets/StreamingAssets/vapokbackpacks.manifest @@ -1,9 +1,9 @@ ManifestFileVersion: 0 -CRC: 3115447487 +CRC: 444948837 Hashes: AssetFileHash: serializedVersion: 2 - Hash: 6b0398d2d5f2c973733c6a19afc1b6c2 + Hash: cc3e9f91f4b69e5af58915c98af71a55 TypeTreeHash: serializedVersion: 2 Hash: e8332a6d8fa8fcfcc86e8edfb27851a5 @@ -70,7 +70,6 @@ Assets: - Assets/Sprite/SilverBackpack_Icon.asset - Assets/Texture2D/NecromancyBackpack_Icon.png - Assets/Texture2D/SilverBackpack_Icon.png -- Assets/vapok/Prefabs/BackpackNecromancy.prefab - Assets/Shader/DoubleSided_Standard_Standard DS.shader - Assets/vapok/Prefabs/CapeSilverBackpack.prefab - Assets/Sprite/IronBackpack_Icon.asset diff --git a/manifest.json b/manifest.json index bf3b9f1..711dd4b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "AdventureBackpacks", - "version_number": "1.7.0", + "version_number": "1.7.1", "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": [