Skip to content

Commit

Permalink
Merge pull request #56 from Vapok/vapok/r1.6.2
Browse files Browse the repository at this point in the history
# 1.6.2.0 - Bug Fixes and Mod Compatibility
  • Loading branch information
Vapok authored Feb 9, 2023
2 parents a237937 + 1fcc543 commit 7acf4a6
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 12 deletions.
5 changes: 5 additions & 0 deletions AdventureBackpacks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Translations", "Translation
Translations\AdventureBackpacks.Norwegian.json = Translations\AdventureBackpacks.Norwegian.json
Translations\AdventureBackpacks.Russian.json = Translations\AdventureBackpacks.Russian.json
Translations\AdventureBackpacks.Korean.json = Translations\AdventureBackpacks.Korean.json
Translations\AdventureBackpacks.Czech.json = Translations\AdventureBackpacks.Czech.json
EndProjectSection
EndProject
Global
Expand All @@ -29,6 +30,10 @@ Global
{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
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{453B1EE0-9980-4B66-93B3-2DDBD21FEE03} = {125A2AE5-FB75-4EED-B971-3E0C9C056DA0}
Expand Down
4 changes: 3 additions & 1 deletion AdventureBackpacks/AdventureBackpacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using AdventureBackpacks.Configuration;
using AdventureBackpacks.Extensions;
using AdventureBackpacks.Features;
using AdventureBackpacks.Patches;
using BepInEx;
using HarmonyLib;
using ItemManager;
Expand All @@ -34,7 +35,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.1";
private const string _version = "1.6.2";

//Interface Properties
public string PluginId => _pluginId;
Expand Down Expand Up @@ -113,6 +114,7 @@ private void Update()
Player.m_localPlayer.QuickDropBackpack();
}

InventoryPatches.ProcessItemsAddedCache();
}

public void InitializeBackpacks(object send, EventArgs args)
Expand Down
7 changes: 6 additions & 1 deletion AdventureBackpacks/Extensions/PlayerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public static void OpenBackpack(this Player player, bool track = true)
if (backpackContainer == null)
backpackContainer = player.gameObject.AddComponent<Container>();

backpackContainer.m_inventory = GetEquippedBackpack(player).GetInventory();
var backpack = GetEquippedBackpack(player);
var inventory = backpack.GetInventory();
backpackContainer.m_inventory = inventory;
backpackContainer.m_width = inventory.m_width;
backpackContainer.m_height = inventory.m_height;
backpackContainer.m_bkg = backpack.Item.m_shared.m_icons[0];

InventoryGuiPatches.BackpackIsOpen = true;
InventoryGuiPatches.BackpackIsOpening = track;
Expand Down
65 changes: 62 additions & 3 deletions AdventureBackpacks/Patches/Inventory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AdventureBackpacks.Assets;
using AdventureBackpacks.Components;
using AdventureBackpacks.Extensions;
Expand All @@ -12,7 +13,38 @@ public static class InventoryPatches
{
private static bool _movingItemBetweenContainers = false;
private static bool _droppingOutside = false;


public static Dictionary<Guid,Tuple<ItemDrop.ItemData, DateTime>> ItemsAddedCache = new();

private static bool TryGetItemFromCache(this ItemDrop.ItemData item, out Guid guid)
{
foreach (var cacheItem in ItemsAddedCache)
{
if (cacheItem.Value.Item1.Equals(item))
{
guid = cacheItem.Key;
AdventureBackpacks.Log.Debug($"Guid {guid} Found!");
return true;
}
}
AdventureBackpacks.Log.Debug($"Guid Not Found!");
guid = Guid.Empty;
return false;
}
public static void ProcessItemsAddedCache()
{
for (int i = 0; i < ItemsAddedCache.Count; i++)
{
var itemData = ItemsAddedCache.First();
TimeSpan timeDifference = DateTime.Now.Subtract(itemData.Value.Item2);
if (timeDifference.TotalSeconds > 0.5)
{
AdventureBackpacks.Log.Debug($"Process Cache Removing {itemData.Key} for Date {itemData.Value.Item2} with a difference of {timeDifference.TotalSeconds} total seconds.");
ItemsAddedCache.Remove(itemData.Key);
}
}
}

[HarmonyPatch(typeof(Inventory), nameof(Inventory.Changed))]
static class InventoryChangedPatch
{
Expand Down Expand Up @@ -108,6 +140,7 @@ static bool Prefix(Inventory __instance, ItemDrop.ItemData item)
}
}


private static bool RemoveItemPrefix(Inventory __instance, ItemDrop.ItemData item)
{
if (__instance == null || Player.m_localPlayer == null)
Expand All @@ -123,6 +156,13 @@ private static bool RemoveItemPrefix(Inventory __instance, ItemDrop.ItemData ite

if (item.TryGetBackpackItem(out var backpackItem))
{
AdventureBackpacks.Log.Debug($"Checking for Backpack {item.m_shared.m_name}");
if (TryGetItemFromCache(item, out var guid))
{
AdventureBackpacks.Log.Debug($"Exiting RemoveItem for {guid}");
return true;
}

var backpack = item.Data().Get<BackpackComponent>();
if (backpack == null)
return true;
Expand All @@ -141,12 +181,31 @@ private static bool RemoveItemPrefix(Inventory __instance, ItemDrop.ItemData ite
[HarmonyPriority(Priority.First)]
static class AddItemPatch
{
static bool Prefix(Inventory __instance, ItemDrop.ItemData item)
static bool Prefix(Inventory __instance, ItemDrop.ItemData item, ref bool __result)
{
if (item == null)
return false;

if (item.IsBackpack())
{
var noInception = Backpacks.CheckForInception(__instance, item);
if (noInception)
{
if (!_movingItemBetweenContainers)
{
var guid = Guid.NewGuid();
var tuple = new Tuple<ItemDrop.ItemData, DateTime>(item, DateTime.Now);
AdventureBackpacks.Log.Debug($"Added Backpack {guid} at {tuple.Item2}");
ItemsAddedCache.Add(guid,tuple);
}

}
__result = noInception;

return Backpacks.CheckForInception(__instance, item);
return noInception;
}

return true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions AdventureBackpacks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]
[assembly: AssemblyVersion("1.6.2.0")]
[assembly: AssemblyFileVersion("1.6.2.0")]
10 changes: 10 additions & 0 deletions PATCHNOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Adventure Backpacks Patchnotes

# 1.6.2.0 - Bug Fixes and Mod Compatibility
* The last udpate introduced a Language Translation issue where it stopped loading Translation files.
* This has been resolved. Apologies to my non-english friends!
* Adding in Language Translation Support for Czech
* Additional Mod Compatibility changes.
* Quick Stack Store would cause Thor to empty backpacks when using the Take All / Store All commands.
* This has been fixed.
* This **might** also fix an item dupping issue that is being experienced with Multi-User-Chests (not validated yet)
* This update also attempts to fix the Grid Not Displaying on Level 1 Wisppacks when opened on initial load of Valheim.

# 1.6.1.0 - Module Compatibility on Right Click Quick Transfer
* Reworked Logic to make Right Click Quick Transfer friendly to other inventory mods.
* Adds Compatibility to **[Auto Split Stack](https://www.nexusmods.com/valheim/mods/76?tab=files&file_id=7184)**, as well as **[Quick Stack Sort](https://www.nexusmods.com/valheim/mods/2094?tab=description)**
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ stage of maturity. This includes a backpack progression that will start at Meado


# Current Patch Notes
# 1.6.1.0 - Module Compatibility on Right Click Quick Transfer
* Reworked Logic to make Right Click Quick Transfer friendly to other inventory mods.
* Adds Compatibility to **[Auto Split Stack](https://www.nexusmods.com/valheim/mods/76?tab=files&file_id=7184)**, as well as **[Quick Stack Sort](https://www.nexusmods.com/valheim/mods/2094?tab=description)**
* May add additional compatibility to other mods not tested.
# 1.6.2.0 - Bug Fixes and Mod Compatibility
* The last udpate introduced a Language Translation issue where it stopped loading Translation files.
* This has been resolved. Apologies to my non-english friends!
* Additional Mod Compatibility changes.
* Quick Stack Store would cause Thor to empty backpacks when using the Take All / Store All commands.
* This has been fixed.
* This **might** also fix an item dupping issue that is being experienced with Multi-User-Chests (not validated yet)
* This update also attempts to fix the Grid Not Displaying on Level 1 Wisppacks when opened on initial load of Valheim.

## 1.5.0.0
* Initial Release of Adventuring Backpacks introducing 6 New Backpack Prefabs (4 New Models and Designs)
Expand Down
38 changes: 38 additions & 0 deletions Translations/AdventureBackpacks.Czech.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"vapok_mod_item_backpack_meadows": "Brašna",
"vapok_mod_item_backpack_meadows_description": "Malá brašna, do které se vejdou věci.",

"vapok_mod_item_backpack_blackforest": "Kožený batoh",
"vapok_mod_item_backpack_blackforest_description": "Kožený batoh s přezkami a jemnými koženými řemínky.",

"vapok_mod_item_backpack_swamp": "Voděodolný batoh",
"vapok_mod_item_backpack_swamp_description": "Voděodolný batoh uzavřený pomocí vodotěsných krevních vaků.",

"vapok_mod_item_backpack_mountains": "Zimní batoh",
"vapok_mod_item_backpack_mountains_description": "Zimní batoh vhodný na dlouhé túry po horách.",

"vapok_mod_item_backpack_plains": "Loxý batoh",
"vapok_mod_item_backpack_plains_description": "Dobrodružný batoh vyrobený z extrémně odolné kůže z loxu.",

"vapok_mod_item_backpack_mistlands": "Mystický batoh",
"vapok_mod_item_backpack_mistlands_description": "Precizně zpracovaný mystický batoh. S vlastní krabičkou na drobnosti. Nikdo si není jistý, jak funguje.",

"vapok_mod_item_rugged_backpack": "2 Kožený batoh",
"vapok_mod_item_rugged_backpack_description": "2 Kožený batoh s přezkami a jemnými koženými řemínky.",

"vapok_mod_item_arctic_backpack": "2 Zimní batoh",
"vapok_mod_item_arctic_backpack_description": "2 Zimní batoh vhodný na dlouhé túry po horách.",

"vapok_mod_no_inception1": "Nepokoušej bohy.",
"vapok_mod_no_inception2": "Byl jsi varován.",
"vapok_mod_no_inception3": "Rozhněval jsi bohy!",
"vapok_mod_no_inception4": "Povzdech... Thor se o tebe brzy postará.",
"vapok_mod_no_inception5": "Thor tě připravil o tvou moc!!!",

"vapok_mod_thor_saves_contents": "V tom batohu byly záhadné věci. Thor si je schoval pro sebe.",

"vapok_mod_useful_backpack": "Tvůj batoh se zdá být užitečný",
"vapok_mod_you_droped_bag": "Upustil jsi batoh na zem!",
"vapok_mod_level": "Level",
"vapok_mod_effect": "Effekt"
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AdventureBackpacks",
"version_number": "1.6.1",
"version_number": "1.6.2",
"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": [
Expand Down

0 comments on commit 7acf4a6

Please sign in to comment.