Skip to content

Commit

Permalink
Merge pull request #6 from paddywaan/main
Browse files Browse the repository at this point in the history
paddywaan PR: Fixed incorrect library requirement in publish.ps1.
  • Loading branch information
Emrik-North committed Sep 18, 2021
2 parents fa2dd2a + f555b7e commit 335c3b7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Environment.props
Expand Up @@ -2,6 +2,6 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Needs to be your path to the base Valheim folder -->
<VALHEIM_INSTALL>D:\Games\SteamLibrary\steamapps\common\Valheim</VALHEIM_INSTALL>
<VALHEIM_INSTALL>C:\Program Files (x86)\Steam\steamapps\common\Valheim</VALHEIM_INSTALL>
</PropertyGroup>
</Project>
39 changes: 33 additions & 6 deletions JotunnBackpacks/JotunnBackpacks.cs
Expand Up @@ -25,6 +25,7 @@
using HarmonyLib;
using ExtendedItemDataFramework;
using Log = Jotunn.Logger;
using BepInEx.Logging;

/* TODOS
* • Hotkey to drop backpack to be able to run faster out of danger, like in Outward!
Expand Down Expand Up @@ -57,7 +58,8 @@ internal class JotunnBackpacks : BaseUnityPlugin
public static ConfigEntry<KeyCode> hotKey_open;
public static ConfigEntry<KeyCode> hotKey_drop;
public static ConfigEntry<bool> outwardMode; // TODO: This should enable and disable outward mode. Make it a button in config menu.
public static ConfigEntry<Vector2> backpackSize;
public static ConfigEntry<Vector2> ironbackpackSize;
public static ConfigEntry<Vector2> arcticbackpackSize;
public static ConfigEntry<float> weightMultiplier;
public static ConfigEntry<int> carryBonusRugged;
public static ConfigEntry<int> carryBonusArctic;
Expand All @@ -71,9 +73,12 @@ internal class JotunnBackpacks : BaseUnityPlugin
public static string backpackInventoryName = "$ui_backpack_inventoryname";
public static bool opening = false;

private static ManualLogSource _logger;

// Awake() is run when the game loads up.
private void Awake()
{
_logger = base.Logger;
CreateConfigValues();
BackpackAssets.LoadAssets();
BackpackAssets.AddStatusEffects();
Expand Down Expand Up @@ -113,8 +118,13 @@ private void CreateConfigValues()
new ConfigurationManagerAttributes { Order = 1 }));

// These configs are enforced by the server, but can be edited locally if in single-player.
backpackSize = Config.Bind(
"Server-enforceable config", "Backpack Size", new Vector2(6, 3),
ironbackpackSize = Config.Bind(
"Server-enforceable config", "Rugged Backpack Size", new Vector2(6, 2),
new ConfigDescription("Backpack size (width, height).\nMax width is 8 unless you want to break things.",
null,
new ConfigurationManagerAttributes { IsAdminOnly = true, Order = 6 }));
arcticbackpackSize = Config.Bind(
"Server-enforceable config", "Arctic Backpack Size", new Vector2(6, 3),
new ConfigDescription("Backpack size (width, height).\nMax width is 8 unless you want to break things.",
null,
new ConfigurationManagerAttributes { IsAdminOnly = true, Order = 6 }));
Expand Down Expand Up @@ -157,15 +167,32 @@ private static void OnNewExtendedItemData(ExtendedItemData itemData)
// I check whether the item created is of a type contained in backpackTypes
if (backpackTypes.Contains(itemData.m_shared.m_name))
{
_logger.LogWarning($"{itemData.m_shared.m_name}");
// Create an instance of an Inventory class
Inventory inventoryInstance = NewInventoryInstance();

Inventory inventoryInstance = new Inventory(
backpackInventoryName,
null,
(int)ironbackpackSize.Value.x,
(int)ironbackpackSize.Value.y
);
if (itemData.m_shared.m_name.Equals("$item_cape_silverbackpack"))
{
inventoryInstance = new Inventory(
backpackInventoryName,
null,
(int)arcticbackpackSize.Value.x,
(int)arcticbackpackSize.Value.y
);
}

// Add an empty BackpackComponent to the backpack item
var component = itemData.AddComponent<BackpackComponent>();

// Assign the Inventory instance to the backpack item's BackpackComponent
component.SetInventory(inventoryInstance);
}


}

Expand All @@ -174,8 +201,8 @@ public static Inventory NewInventoryInstance()
return new Inventory(
backpackInventoryName,
null,
(int)backpackSize.Value.x,
(int)backpackSize.Value.y
(int)ironbackpackSize.Value.x,
(int)ironbackpackSize.Value.y
);

}
Expand Down
38 changes: 25 additions & 13 deletions JotunnBackpacks/JotunnBackpacks.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\JotunnLib.2.1.2\build\JotunnLib.props" Condition="Exists('..\packages\JotunnLib.2.1.2\build\JotunnLib.props')" />
<Import Project="..\packages\JotunnLib.2.3.1\build\JotunnLib.props" Condition="Exists('..\packages\JotunnLib.2.3.1\build\JotunnLib.props')" />
<Import Project="..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.5.0.2\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -41,23 +41,35 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HarmonyX.2.4.2\lib\net45\0Harmony.dll</HintPath>
<Reference Include="0Harmony, Version=2.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HarmonyX.2.5.4\lib\net45\0Harmony.dll</HintPath>
</Reference>
<Reference Include="ExtendedItemDataFramework">
<HintPath>..\packages\ExtendedItemDataFramework.1.0.2\ExtendedItemDataFramework.dll</HintPath>
<HintPath>$(VALHEIM_INSTALL)\BepInEx\Plugins\ExtendedItemDataFramework.dll</HintPath>
</Reference>
<Reference Include="Jotunn, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ValheimModding-Jotunn-2.2.0\plugins\Jotunn.dll</HintPath>
<Reference Include="Jotunn, Version=2.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\JotunnLib.2.3.1\lib\net462\Jotunn.dll</HintPath>
</Reference>
<Reference Include="MonoMod, Version=21.4.21.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.21.4.21.3\lib\net40\MonoMod.exe</HintPath>
<Reference Include="Mono.Cecil, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="MonoMod.RuntimeDetour, Version=21.4.21.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.RuntimeDetour.21.4.21.3\lib\net40\MonoMod.RuntimeDetour.dll</HintPath>
<Reference Include="Mono.Cecil.Mdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="MonoMod.Utils, Version=21.4.21.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.Utils.21.4.21.3\lib\net40\MonoMod.Utils.dll</HintPath>
<Reference Include="Mono.Cecil.Pdb, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.11.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="MonoMod, Version=21.8.19.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.21.8.19.1\lib\net40\MonoMod.exe</HintPath>
</Reference>
<Reference Include="MonoMod.RuntimeDetour, Version=21.8.19.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.RuntimeDetour.21.8.19.1\lib\net40\MonoMod.RuntimeDetour.dll</HintPath>
</Reference>
<Reference Include="MonoMod.Utils, Version=21.8.19.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoMod.Utils.21.8.19.1\lib\net40\MonoMod.Utils.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -112,6 +124,6 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\JotunnLib.2.1.2\build\JotunnLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\JotunnLib.2.1.2\build\JotunnLib.props'))" />
<Error Condition="!Exists('..\packages\JotunnLib.2.3.1\build\JotunnLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\JotunnLib.2.3.1\build\JotunnLib.props'))" />
</Target>
</Project>
12 changes: 6 additions & 6 deletions JotunnBackpacks/packages.config
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HarmonyX" version="2.4.2" targetFramework="net462" />
<package id="JotunnLib" version="2.1.2" targetFramework="net462" />
<package id="Mono.Cecil" version="0.11.3" targetFramework="net40" />
<package id="MonoMod" version="21.4.21.3" targetFramework="net462" />
<package id="MonoMod.RuntimeDetour" version="21.4.21.3" targetFramework="net462" />
<package id="MonoMod.Utils" version="21.4.21.3" targetFramework="net462" />
<package id="HarmonyX" version="2.5.4" targetFramework="net462" />
<package id="JotunnLib" version="2.3.1" targetFramework="net462" />
<package id="Mono.Cecil" version="0.11.4" targetFramework="net462" />
<package id="MonoMod" version="21.8.19.1" targetFramework="net462" />
<package id="MonoMod.RuntimeDetour" version="21.8.19.1" targetFramework="net462" />
<package id="MonoMod.Utils" version="21.8.19.1" targetFramework="net462" />
</packages>
3 changes: 1 addition & 2 deletions publish.ps1
Expand Up @@ -21,8 +21,7 @@ Push-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Path)

# Test some preliminaries
("$TargetPath",
"$ValheimPath",
"$(Get-Location)\libraries"
"$ValheimPath"
) | % {
if (!(Test-Path "$_")) {Write-Error -ErrorAction Stop -Message "$_ folder is missing"}
}
Expand Down

0 comments on commit 335c3b7

Please sign in to comment.