Skip to content

Commit dc58d75

Browse files
HAHOOSHAHOOS
authored andcommitted
Add project files.
1 parent b87a85f commit dc58d75

4 files changed

Lines changed: 184 additions & 0 deletions

File tree

KeepInventory.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.35004.147
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeepInventory", "KeepInventory\KeepInventory.csproj", "{982D6000-0B26-4D26-ADB7-7DAF2E4FA14F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{982D6000-0B26-4D26-ADB7-7DAF2E4FA14F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{982D6000-0B26-4D26-ADB7-7DAF2E4FA14F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{982D6000-0B26-4D26-ADB7-7DAF2E4FA14F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{982D6000-0B26-4D26-ADB7-7DAF2E4FA14F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {A93F4A6E-5CE2-4682-838F-72FC72E10763}
24+
EndGlobalSection
25+
EndGlobal

KeepInventory/KeepInventory.csproj

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Reference Include="Assembly-CSharp">
11+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll</HintPath>
12+
</Reference>
13+
<Reference Include="BoneLib">
14+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\Mods\BoneLib.dll</HintPath>
15+
</Reference>
16+
<Reference Include="Il2CppInterop.Runtime">
17+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\net6\Il2CppInterop.Runtime.dll</HintPath>
18+
</Reference>
19+
<Reference Include="Il2Cppmscorlib">
20+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll</HintPath>
21+
</Reference>
22+
<Reference Include="Il2CppSLZ.Marrow">
23+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\Il2CppAssemblies\Il2CppSLZ.Marrow.dll</HintPath>
24+
</Reference>
25+
<Reference Include="Il2CppUniTask">
26+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\Il2CppAssemblies\Il2CppUniTask.dll</HintPath>
27+
</Reference>
28+
<Reference Include="MelonLoader">
29+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\net6\MelonLoader.dll</HintPath>
30+
</Reference>
31+
<Reference Include="UnityEngine.CoreModule">
32+
<HintPath>G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll</HintPath>
33+
</Reference>
34+
</ItemGroup>
35+
36+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
37+
<Exec Command="ECHO Copying KeepInventory.dll to G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\Mods&#xD;&#xA;COPY &quot;$(TargetPath)&quot; &quot;G:\OculusLibrary\Software\stress-level-zero-inc-bonelab\Mods\$(ProjectName).dll&quot;" />
38+
</Target>
39+
40+
</Project>

KeepInventory/Main.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using MelonLoader;
2+
using BoneLib;
3+
using BoneLib.BoneMenu;
4+
using UnityEngine;
5+
using Il2CppSLZ.Marrow;
6+
using Il2CppSLZ.Marrow.Warehouse;
7+
using Il2CppSLZ.Marrow.Pool;
8+
9+
[assembly: MelonInfo(typeof(global::HAHOOS.KeepInventory.Main), "Keep Inventory", "1.0.0", "HAHOOS")]
10+
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
11+
[assembly: MelonAuthorColor(0,255,165,0)]
12+
[assembly: MelonColor(0, 255, 72, 59)]
13+
14+
namespace HAHOOS.KeepInventory
15+
{
16+
public class Main : MelonMod
17+
{
18+
19+
public Dictionary<string, Barcode> slots = new Dictionary<string, Barcode>();
20+
private bool IsDebug = true;
21+
22+
public override void OnInitializeMelon()
23+
{
24+
LoggerInstance.Msg("Setting up KeepInventory");
25+
SetupMenu();
26+
27+
Hooking.OnLevelLoaded += LevelLoadedEvent;
28+
Hooking.OnLevelUnloaded += LevelUnloadedEvent;
29+
30+
}
31+
32+
private void LevelUnloadedEvent()
33+
{
34+
if (Settings.Enabled)
35+
{
36+
slots.Clear();
37+
LoggerInstance.Msg("Saving inventory...");
38+
if (Player.RigManager == null)
39+
{
40+
LoggerInstance.Msg("RigManager does not exist");
41+
return;
42+
}
43+
if (Player.RigManager.inventory == null)
44+
{
45+
LoggerInstance.Msg("Inventory does not exist");
46+
return;
47+
}
48+
foreach (var item in Player.RigManager.inventory.bodySlots)
49+
{
50+
if (item.inventorySlotReceiver != null)
51+
{
52+
if (item.inventorySlotReceiver._weaponHost != null)
53+
{
54+
var poolee = item.inventorySlotReceiver._weaponHost.GetTransform().GetComponent<Poolee>();
55+
if (poolee != null)
56+
{
57+
var barcode = poolee.SpawnableCrate.Barcode;
58+
slots.Add(item.name, barcode);
59+
}
60+
}
61+
62+
}
63+
}
64+
if (IsDebug) LoggerInstance.Msg("Successfully saved inventory");
65+
}
66+
}
67+
68+
private void LevelLoadedEvent(LevelInfo obj)
69+
{
70+
if (Settings.Enabled)
71+
{
72+
LoggerInstance.Msg("Loading inventory...");
73+
if (slots.Count >= 1)
74+
{
75+
var list = Player.RigManager.inventory.bodySlots.ToList();
76+
foreach (var item in slots)
77+
{
78+
var slot = list.Find((slot) => slot.name == item.Key);
79+
if (slot != null){
80+
if(slot.inventorySlotReceiver != null)
81+
{
82+
slot.inventorySlotReceiver.SpawnInSlotAsync(item.Value);
83+
}
84+
}
85+
}
86+
LoggerInstance.Msg(" Loaded inventory");
87+
}
88+
else
89+
{
90+
LoggerInstance.Msg("Saved Inventory not found");
91+
}
92+
}
93+
else
94+
{
95+
if (IsDebug) LoggerInstance.Msg("[DEBUG] Saving/Loading Inventory has been disabled, check the mod settings to enable again");
96+
}
97+
}
98+
99+
public void SetupMenu()
100+
{
101+
var mainPage = Page.Root.CreatePage("HAHOOS", Color.white);
102+
var modPage = mainPage.CreatePage("KeepInventory", new Color(255, 72, 59));
103+
modPage.CreateBool("Enabled", Color.green, Settings.Enabled, (value)=>Settings.Enabled=value);
104+
}
105+
}
106+
}

KeepInventory/Settings.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace HAHOOS.KeepInventory
8+
{
9+
internal static class Settings
10+
{
11+
public static bool Enabled { get; set; } = true;
12+
}
13+
}

0 commit comments

Comments
 (0)