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 Il2CppInterop.Runtime.InteropTypes;
using Il2CppSLZ.Marrow.Warehouse;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Randomiser;
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), "Randomiser", "1.0.0", "freakycheesy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Randomiser")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Randomiser")]
[assembly: AssemblyTitle("Randomiser")]
[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 Randomiser
{
public class Core : MelonMod
{
public static MelonPreferences_Entry<bool> Enabled;
public static List<CrateSpawner> CrateSpawnerList = new List<CrateSpawner>();
public static string[] BANNEDITEMS = new string[6] { "vfx", "fragment", "cardboard", "-", "avatar", "level" };
private AssetWarehouse warehouse => AssetWarehouse.Instance;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Initialized and Patched " + ((object)this).GetType().FullName + ".");
CreateBoneMenu();
Hooking.OnLevelLoading += Hooking_OnLevelLoading;
}
private void Hooking_OnLevelLoading(LevelInfo obj)
{
CrateSpawnerLists();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
CrateSpawnerLists();
}
private void CrateSpawnerLists()
{
CrateSpawnerList = ((IEnumerable<CrateSpawner>)Resources.FindObjectsOfTypeAll<CrateSpawner>()).ToList();
EditAllCrateSpawners();
}
public void EditAllCrateSpawners()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Expected O, but got Unknown
if (!Enabled.Value || CrateSpawnerList.Count <= 0 || !AssetWarehouse.ready)
{
return;
}
MelonLogger.Msg("Editing All Crates");
warehouse.GetCrates<SpawnableCrate>((ICrateFilter<SpawnableCrate>)null);
Pallet val = default(Pallet);
foreach (CrateSpawner crateSpawner in CrateSpawnerList)
{
if (!warehouse.TryGetPallet(new Barcode("SLZ.BONELAB.Content"), ref val))
{
break;
}
((MelonBase)this).LoggerInstance.Msg(((Scannable)val).Barcode.ID);
List<Crate> list = new List<Crate>();
for (int i = 0; i < val.Crates.Count; i++)
{
if (Object.op_Implicit((Object)(object)((Il2CppObjectBase)val.Crates[i]).TryCast<SpawnableCrate>()))
{
list.Add(val.Crates[i]);
}
}
Crate val2 = GenerateCrate(list);
MelonLogger.Msg(((Scannable)val2).Barcode.ID);
crateSpawner.spawnableCrateReference = new SpawnableCrateReference
{
_barcode = ((Scannable)val2)._barcode,
Barcode = ((Scannable)val2).Barcode
};
crateSpawner._spawnable.crateRef = new SpawnableCrateReference
{
_barcode = ((Scannable)val2)._barcode,
Barcode = ((Scannable)val2).Barcode
};
crateSpawner.crateQuery = new CrateQuery
{
_barcode = ((Scannable)val2).Barcode,
Barcode = ((Scannable)val2).Barcode
};
crateSpawner.SetSpawnable();
}
}
private static Crate GenerateCrate(List<Crate> crates)
{
Crate val = crates[Random.Range(0, crates.Count - 1)];
if (CheckForBannedKeywords(val))
{
return GenerateCrate(crates);
}
return val;
}
private static bool CheckForBannedKeywords(Crate crate)
{
bool result = false;
string[] bANNEDITEMS = BANNEDITEMS;
foreach (string value in bANNEDITEMS)
{
if (((Scannable)crate).Barcode.ID.Contains(value, StringComparison.CurrentCultureIgnoreCase))
{
result = true;
}
}
return result;
}
private void CreateBoneMenu()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
((MelonBase)this).HarmonyInstance.PatchAll();
Enabled = MelonPreferences.CreateCategory("Randomiser").CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
Page val = Page.Root.CreatePage("Randomiser", Color.green, 0, true);
val.CreateBool("Enabled", Color.green, Enabled.Value, (Action<bool>)delegate(bool a)
{
Enabled.Value = a;
MelonPreferences.Save();
});
}
}
}