Skip to content

Commit

Permalink
Merge pull request #18 from Vapok/feature/MeadowsBackpack
Browse files Browse the repository at this point in the history
v1.5.0 Adventure Mode
  • Loading branch information
Vapok authored Jan 28, 2023
2 parents a06a484 + 537a2b8 commit 0ce1e38
Show file tree
Hide file tree
Showing 212 changed files with 234,162 additions and 94,641 deletions.
62 changes: 48 additions & 14 deletions AdventureBackpacks/AdventureBackpacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
*
*/

using System;
using System.Reflection;
using AdventureBackpacks.Assets;
using AdventureBackpacks.Assets.Factories;
using AdventureBackpacks.Configuration;
using AdventureBackpacks.Extensions;
using BepInEx;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Vapok.Common.Abstractions;
using Vapok.Common.Managers;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.LocalizationManager;
using Vapok.Common.Tools;

namespace AdventureBackpacks
Expand All @@ -34,7 +37,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo
//Module Constants
private const string _pluginId = "vapok.mods.adventurebackpacks";
private const string _displayName = "AdventureBackpacks";
private const string _version = "1.0.4";
private const string _version = "1.5.0";

//Interface Properties
public string PluginId => _pluginId;
Expand All @@ -44,6 +47,8 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo

//Class Properties
public static ILogIt Log => _log;
public static bool ValheimAwake = false;
public static Waiting Waiter;

//Class Privates
private static AdventureBackpacks _instance;
Expand All @@ -57,28 +62,29 @@ private void Awake()
{
//I'm awake!
_instance = this;

//Initialize Managers
Initializer.LoadManagers();

//Register Configuration Settings
_config = new ConfigRegistry(_instance);

//Register Logger
LogManager.Init(PluginId,out _log);

//Register Translations
Localizer.Load();

//Load Assets
Backpacks.LoadAssets();

//Enable BoneReorder
BoneReorder.ApplyOnEquipmentChanged(Info.Metadata.GUID);

PrefabManager.Initalized = true;

//Waiting For Startup
Waiter = new Waiting();

Waiter.StatusChanged += InitializeBackpacks;

//Patch Harmony
_harmony = new Harmony(Info.Metadata.GUID);
_harmony.PatchAll();
_harmony.PatchAll(Assembly.GetExecutingAssembly());

//???

//Profit
}

Expand All @@ -98,11 +104,39 @@ private void Update()
}

}

public void InitializeBackpacks(object send, EventArgs args)
{
if (ValheimAwake)
return;

//Load Assets
var backpackFactory = new BackpackFactory(_log, _config);
backpackFactory.CreateAssets();

//Setup Types
Backpacks.LoadBackpackTypes(BackpackFactory.BackpackTypes());

//Enable BoneReorder
BoneReorder.ApplyOnEquipmentChanged(Info.Metadata.GUID);

ValheimAwake = true;
}

private void OnDestroy()
{
_instance = null;
_harmony?.UnpatchSelf();
}

public class Waiting
{
public void ValheimIsAwake(bool awakeFlag)
{
if (awakeFlag)
StatusChanged?.Invoke(this, EventArgs.Empty);
}
public event EventHandler StatusChanged;
}
}
}
17 changes: 17 additions & 0 deletions AdventureBackpacks/AdventureBackpacks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,28 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Backpacks.cs" />
<Compile Include="Assets\Effects\BackpackEffects.cs" />
<Compile Include="Assets\Effects\Demister.cs" />
<Compile Include="Assets\Effects\FeatherFall.cs" />
<Compile Include="Assets\Effects\Waterproof.cs" />
<Compile Include="Assets\Factories\AssetFactory.cs" />
<Compile Include="Assets\Factories\BackpackFactory.cs" />
<Compile Include="Assets\Items\AssetItem.cs" />
<Compile Include="Assets\Items\BackpackItem.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackBlackForest.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackMeadows.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackMistlands.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackMountains.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackPlains.cs" />
<Compile Include="Assets\Items\BackpackItems\BackpackSwamp.cs" />
<Compile Include="Assets\Items\BackpackItems\LegacyIronBackpack.cs" />
<Compile Include="Assets\Items\BackpackItems\LegacySilverBackpack.cs" />
<Compile Include="Components\BackpackComponent.cs" />
<Compile Include="Configuration\ConfigRegistry.cs" />
<Compile Include="Extensions\InventoryExtensions.cs" />
<Compile Include="Extensions\ItemDataExtensions.cs" />
<Compile Include="Extensions\PlayerExtensions.cs" />
<Compile Include="Patches\FejdStartup.cs" />
<Compile Include="Patches\GuiBar.cs" />
<Compile Include="Patches\Humanoid.cs" />
<Compile Include="Patches\Inventory.cs" />
Expand Down
Loading

0 comments on commit 0ce1e38

Please sign in to comment.