using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppWebSocketSharp;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Port_A_Warehouse;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "Port-A-Warehouse", "1.0.0", "freakycheesy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Port_A_Warehouse")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ec73e78bedbb73a6db9bf95f8749950def04eb41")]
[assembly: AssemblyProduct("Port_A_Warehouse")]
[assembly: AssemblyTitle("Port_A_Warehouse")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Port_A_Warehouse
{
public class Core : MelonMod
{
public static Page Page;
public static Page PalletsPage;
public const int MaxElements = 10;
public static string SearchQuery;
public static bool ShowRedacted { get; set; } = true;
public static bool ShowUnlockable { get; set; } = true;
public static bool IncludeBarcodes { get; set; } = true;
public static bool IncludeTags { get; set; } = true;
public static bool IncludeAuthors { get; set; } = true;
public static bool IncludeTitles { get; set; } = true;
public static bool CaseSensitive { get; set; } = false;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Initialized.");
WarehouseData.OnCratesGenerated = (Action)Delegate.Combine(WarehouseData.OnCratesGenerated, new Action(CreateCratesPage));
Hooking.OnLevelLoaded += delegate
{
RemovePallets();
};
Hooking.OnLevelUnloaded += RemovePallets;
Hooking.OnUIRigCreated += RemovePallets;
BoneMenuCreator();
}
private void CreateCratesPage()
{
foreach (AvatarCrate avatarCrate in WarehouseData.AvatarCrates)
{
CreateCratePage<AvatarCrate>(avatarCrate);
}
foreach (SpawnableCrate spawnableCrate in WarehouseData.SpawnableCrates)
{
CreateCratePage<SpawnableCrate>(spawnableCrate);
}
foreach (LevelCrate levelCrate in WarehouseData.LevelCrates)
{
CreateCratePage<LevelCrate>(levelCrate);
}
}
private void PlayDisc<T>(T disc) where T : MonoDisc
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
string text = $"Music Player {((Scannable)(object)disc).Barcode}";
AudioSource val = GameObject.Find(text).GetComponent<AudioSource>();
if (val == null)
{
val = new GameObject(text).AddComponent<AudioSource>();
}
val.clip = ((MonoDisc)disc).AudioClip.Asset;
if (val.isPlaying)
{
val.Stop();
}
else
{
val.Play();
}
}
private void BoneMenuCreator()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
Page = Page.Root.CreatePage("Asset Warehouse", Color.red, 10, true);
Page.CreateFunction("Refresh", Color.green, (Action)Refresh);
Page.CreateString("Search Query", Color.green, SearchQuery, (Action<string>)Search);
FitlerOptions();
QueryOptions();
PalletsPage = Page.CreatePage("Pallets", Color.green, 10, true);
}
private static void QueryOptions()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
Page val = Page.CreatePage("Query Options", Color.white, 0, true);
val.CreateBool("Include Barcodes", Color.white, IncludeBarcodes, (Action<bool>)delegate(bool a)
{
IncludeBarcodes = a;
});
val.CreateBool("Include Tags", Color.white, IncludeTags, (Action<bool>)delegate(bool a)
{
IncludeTags = a;
});
val.CreateBool("Include Authors", Color.white, IncludeAuthors, (Action<bool>)delegate(bool a)
{
IncludeAuthors = a;
});
val.CreateBool("Include Titles", Color.white, IncludeTitles, (Action<bool>)delegate(bool a)
{
IncludeTitles = a;
});
val.CreateBool("Case Sensitive", Color.white, CaseSensitive, (Action<bool>)delegate(bool a)
{
CaseSensitive = a;
});
}
private static void FitlerOptions()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
Page val = Page.CreatePage("Filters", Color.white, 0, true);
val.CreateBool("Show Redacted", Color.white, ShowRedacted, (Action<bool>)delegate(bool a)
{
ShowRedacted = a;
});
val.CreateBool("Show Unlockable", Color.white, ShowUnlockable, (Action<bool>)delegate(bool a)
{
ShowUnlockable = a;
});
}
public void Refresh()
{
_RefreshThread();
}
private async void _RefreshThread()
{
RemovePallets();
WarehouseData.GenerateCratesData();
}
private static void RemovePallets()
{
PalletsPage.RemoveAll();
}
public void Search(string query)
{
SearchQuery = query;
Refresh();
}
private void CreateCratePage<T>(T crate) where T : Crate
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
Page val = PalletsPage.CreatePage("All Loaded Crates", Color.cyan, 10, true);
Pallet pallet = ((Crate)crate).Pallet;
Page val2 = PalletsPage.CreatePage(((Scannable)pallet)._title + "\n(" + ((Scannable)pallet)._barcode._id + ")", Color.green, 10, true);
Page val3 = val2.CreatePage(((object)crate).GetType().Name, Color.magenta, 10, true);
Page val4 = val3.CreatePage(((Scannable)(object)crate)._title + "\n(" + ((Scannable)(object)crate)._barcode._id + ")", Color.magenta, 10, true);
val4.CreateFunction(GetCrateActionName(crate), Color.white, (Action)delegate
{
UseCrate(crate);
});
val.CreatePageLink(val4);
}
public string GetCrateActionName<T>(T crate) where T : Crate
{
string result = string.Empty;
if (crate is LevelCrate)
{
result = "Load Level";
}
if (crate is AvatarCrate)
{
result = "Swap Avatar";
}
else if (crate is SpawnableCrate)
{
result = "Swap Spawn Gun Crate";
}
return result;
}
private void UseCrate<T>(T crate) where T : Crate
{
MelonLogger.Msg($"Trying to Activate Crate: {((Scannable)(object)crate).Barcode}({((object)crate).GetType().FullName})");
if (crate is LevelCrate)
{
LoadLevel((Crate)(object)crate);
}
if (crate is AvatarCrate)
{
SwapAvatar((Crate)(object)crate);
}
else if (crate is SpawnableCrate)
{
SelectSpawnable((Crate)(object)crate);
}
}
public void LoadLevel(Crate value)
{
SceneStreamer.Load(((Scannable)value).Barcode, (Barcode)null);
}
public void SelectSpawnable(Crate value)
{
SpawnGunPatch.SwapSpawnGunCrate((SpawnableCrate)(object)((value is SpawnableCrate) ? value : null));
}
public void SwapAvatar(Crate value)
{
Player.RigManager.SwapAvatarCrate(((Scannable)value).Barcode, false, (Action<bool>)null);
}
}
public static class Extensions
{
public static List<T> ToList<T>(this List<T> dirtyList)
{
List<T> list = new List<T>(dirtyList.Count);
Enumerator<T> enumerator = dirtyList.GetEnumerator();
while (enumerator.MoveNext())
{
T current = enumerator.Current;
list.Add(current);
}
List<T> result = list;
dirtyList.Clear();
return result;
}
public static List<T> FilterAndCleanScannables<T>(this List<T> Scannables) where T : Scannable
{
Scannables.RemoveAll((T x) => ((Scannable)x).Redacted && !Core.ShowRedacted);
Scannables.RemoveAll((T x) => ((Scannable)x).Unlockable && !Core.ShowUnlockable);
if (!Ext.IsNullOrEmpty(Core.SearchQuery))
{
StringComparison comparison = (Core.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
Predicate<Scannable> match = (Scannable x) => (x._barcode._id.Contains(Core.SearchQuery, comparison) && Core.IncludeBarcodes) || (x._title.Contains(Core.SearchQuery, comparison) && Core.IncludeTitles);
Scannables = Scannables.ToList().FindAll((Predicate<T>)(object)match);
}
return Scannables;
}
public static List<T> FilterAndCleanDataCards<T>(this List<T> DataCards) where T : DataCard
{
DataCards.FilterAndCleanScannables<T>();
if (!Ext.IsNullOrEmpty(Core.SearchQuery))
{
StringComparison comparison = (Core.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
Predicate<DataCard> match = (DataCard x) => x.Pallet.Author.Contains(Core.SearchQuery, comparison) && Core.IncludeAuthors;
DataCards = DataCards.FindAll((Predicate<T>)(object)match);
}
return DataCards;
}
public static List<T> FilterAndCleanCrates<T>(this List<T> Crates) where T : Crate
{
Crates.FilterAndCleanScannables<T>();
if (!Ext.IsNullOrEmpty(Core.SearchQuery))
{
StringComparison comparison = (Core.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase);
Predicate<Crate> match = (Crate x) => (x._tags.Contains(Core.SearchQuery) && Core.IncludeTags) || (x.Pallet.Author.Contains(Core.SearchQuery, comparison) && Core.IncludeAuthors);
Crates = Crates.FindAll((Predicate<T>)(object)match);
}
return Crates;
}
}
public static class SpawnGunPatch
{
public static void SwapSpawnGunCrate(SpawnableCrate crate)
{
foreach (SpawnGun item in Object.FindObjectsOfType<SpawnGun>())
{
item._lastSelectedCrate = crate;
item._selectedCrate = crate;
}
}
}
public static class WarehouseData
{
public static List<Crate> Crates = new List<Crate>();
public static List<LevelCrate> LevelCrates = new List<LevelCrate>();
public static List<SpawnableCrate> SpawnableCrates = new List<SpawnableCrate>();
public static List<AvatarCrate> AvatarCrates = new List<AvatarCrate>();
public static Action OnCratesGenerated;
public static async void GenerateCratesData()
{
try
{
GenerateCrateDataTask();
}
catch (Exception ex2)
{
Exception ex = ex2;
MelonLogger.Error("ERROR", ex);
}
}
private static void GenerateCrateDataTask()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
try
{
Notification val = new Notification();
val.ShowTitleOnPopup = true;
val.PopupLength = 0.3f;
val.Title = NotificationText.op_Implicit("Port-A-Warehouse");
val.Message = NotificationText.op_Implicit("Generating Crates (DON'T ENTER PALLETS, GAME WILL CRASH)");
Notifier.Send(val);
Crates = AssetWarehouse.Instance.GetCrates().ToList<Crate>().FilterAndCleanCrates<Crate>();
SpawnableCrates = AssetWarehouse.Instance.GetCrates<SpawnableCrate>((ICrateFilter<SpawnableCrate>)null).ToList<SpawnableCrate>().FilterAndCleanCrates<SpawnableCrate>();
AvatarCrates = AssetWarehouse.Instance.GetCrates<AvatarCrate>((ICrateFilter<AvatarCrate>)null).ToList<AvatarCrate>().FilterAndCleanCrates<AvatarCrate>();
LevelCrates = AssetWarehouse.Instance.GetCrates<LevelCrate>((ICrateFilter<LevelCrate>)null).ToList<LevelCrate>().FilterAndCleanCrates<LevelCrate>();
OnCratesGenerated?.Invoke();
MelonLogger.Msg("Generated Crates");
val.Message = NotificationText.op_Implicit("Generated Crates");
Notifier.Send(val);
}
catch (Exception ex)
{
MelonLogger.Error("ERROR", ex);
}
}
}
}