using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MolkyValuables")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Molky")]
[assembly: AssemblyTitle("Molky")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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;
}
}
}
public class ItemJett : MonoBehaviour
{
private ItemEquippable itemEquippable;
private ItemToggle itemToggle;
private AudioSource audioSource;
private bool prevToggleState = false;
private Vector3 startPos;
private Quaternion StartRot;
private void Start()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
try
{
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
itemToggle = ((Component)this).GetComponent<ItemToggle>();
audioSource = ((Component)this).GetComponent<AudioSource>();
startPos = ((Component)this).transform.position;
StartRot = ((Component)this).transform.rotation;
}
catch (Exception ex)
{
Debug.LogError((object)("[ItemJett] Erreur dans Start() : " + ex.Message));
}
}
private void Update()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
try
{
if (itemToggle.toggleState != prevToggleState)
{
if (SemiFunc.RunIsShop())
{
RevivePlayers();
((Component)this).transform.position = startPos;
((Component)this).transform.rotation = StartRot;
}
else
{
audioSource.Play();
Object.Destroy((Object)(object)((Component)this).gameObject);
RevivePlayers();
}
}
}
catch (Exception ex)
{
Debug.LogError((object)("[ItemJett] Erreur dans Update() : " + ex.Message));
}
}
private void RevivePlayers()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
try
{
List<PhysGrabObject> list = SemiFunc.PhysGrabObjectGetAllWithinRange(2f, ((Component)this).transform.position, false, default(LayerMask), (PhysGrabObject)null);
foreach (PhysGrabObject item in list)
{
PlayerDeathHead val = ((item != null) ? ((Component)item).GetComponent<PlayerDeathHead>() : null);
if ((Object)(object)val != (Object)null)
{
val.FlashEyeRPC(true);
val.Revive();
}
}
}
catch (Exception ex)
{
Debug.LogError((object)("[ItemJett] Erreur dans RevivePlayers() : " + ex.Message));
}
}
}
namespace Molky
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Molky";
public const string PLUGIN_NAME = "Molky";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace MolkyValuables
{
[BepInPlugin("Molky.MolkyValuables", "MolkyValuables", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugins : BaseUnityPlugin
{
[HarmonyPatch(typeof(ShopManager), "ShopInitialize")]
public static class ShopManager_ShopInitialize_Patch
{
[HarmonyPostfix]
public static void ShopManager_ShopInitialize_Postfix()
{
if (!SemiFunc.RunIsShop())
{
return;
}
Logger.LogInfo((object)"\ud83d\udecd\ufe0f Shop has been initialized — now attempting to add a custom item...");
if ((Object)(object)Instance._assetBundle == (Object)null)
{
Logger.LogError((object)"AssetBundle not loaded, cannot add items to the shop.");
return;
}
GameObject val = Instance._assetBundle.LoadAsset<GameObject>("Item Jett");
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)"Failed to load Item Jett.");
}
ItemAttributes val2 = val.GetComponent<ItemAttributes>();
if ((Object)(object)val2 == (Object)null)
{
Logger.LogWarning((object)"Item Jett does not have an ItemAttributes component. Attempting to add it manually...");
val2 = val.AddComponent<ItemAttributes>();
}
if ((Object)(object)val2 != (Object)null)
{
TryAddItemToShop(val2, 33f);
}
else
{
Logger.LogError((object)"Failed to add ItemAttributes component to Item Jett.");
}
}
}
private AssetBundle? _assetBundle;
internal static Plugins Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Logger.LogInfo((object)$"{((BaseUnityPlugin)Instance).Info.Metadata.GUID} v{((BaseUnityPlugin)Instance).Info.Metadata.Version} has loaded!");
Patch();
}
internal void Patch()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_002a: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)Instance).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Logger.LogInfo((object)"Patching MolkyValuables...");
LoadAssets();
Harmony.PatchAll();
Logger.LogInfo((object)"Patching completed.");
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void LoadAssets()
{
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location);
string text = Path.Combine(directoryName, "molkyvaluables");
_assetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)_assetBundle == (Object)null)
{
Logger.LogError((object)("Échec du chargement de l'AssetBundle: " + text));
return;
}
Logger.LogInfo((object)"Loading Molky Valuables...");
List<string> list = new List<string> { "Valuable Macron", "Valuable Miku" };
List<string> valuableAssetNames = new List<string> { "Valuables - Generic" };
foreach (string item in list)
{
RegisterValuable(_assetBundle, item, valuableAssetNames);
}
Logger.LogInfo((object)"Loaded Molky Valuables!");
Logger.LogInfo((object)"Loading Molky Items...");
List<string> list2 = new List<string> { "Item Jett" };
foreach (string item2 in list2)
{
RegisterItem(_assetBundle, item2);
}
Logger.LogInfo((object)"Loaded Molky Items!");
}
private void RegisterValuable(AssetBundle assetBundle, string valuableName, List<string> valuableAssetNames)
{
GameObject val = assetBundle.LoadAsset<GameObject>(valuableName);
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)("Échec du chargement de l'objet précieux: " + valuableName));
}
else
{
Valuables.RegisterValuable(val, valuableAssetNames);
}
}
private void RegisterItem(AssetBundle assetBundle, string itemName)
{
Item val = assetBundle.LoadAsset<Item>(itemName);
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)("Échec du chargement de l'item: " + itemName));
}
else
{
Items.RegisterItem(val);
}
}
public static void TryAddItemToShop(ItemAttributes item, float chancePercent)
{
try
{
if ((Object)(object)item == (Object)null)
{
Logger.LogWarning((object)"Item is null, cannot add to shop.");
return;
}
FieldInfo field = typeof(ItemAttributes).GetField("roomVolumeCheck", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field == null)
{
Logger.LogError((object)"❌ Could not find 'roomVolumeCheck' field in ItemAttributes.");
}
else
{
object? value = field.GetValue(item);
RoomVolumeCheck val = (RoomVolumeCheck)((value is RoomVolumeCheck) ? value : null);
if ((Object)(object)val == (Object)null)
{
Logger.LogWarning((object)"⚠\ufe0f Item is missing roomVolumeCheck. Attempting to clone from another item...");
RoomVolumeCheck val2 = Object.FindObjectOfType<RoomVolumeCheck>();
if ((Object)(object)val2 != (Object)null)
{
RoomVolumeCheck val3 = ((Component)item).gameObject.AddComponent<RoomVolumeCheck>();
FieldInfo[] fields = typeof(RoomVolumeCheck).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
fieldInfo.SetValue(val3, fieldInfo.GetValue(val2));
}
field.SetValue(item, val3);
Logger.LogInfo((object)"✅ roomVolumeCheck cloned and injected successfully.");
}
else
{
Logger.LogError((object)"❌ No RoomVolumeCheck found in the scene to clone from.");
}
}
else
{
Logger.LogInfo((object)"ℹ\ufe0f roomVolumeCheck already exists, no injection needed.");
}
}
float num = Random.Range(0f, 100f);
if (num <= chancePercent)
{
ItemManager.instance.AddSpawnedItem(item);
Logger.LogInfo((object)$"✅ Item successfully added to the shop (chance: {chancePercent}%, roll: {num:F2}).");
}
else
{
Logger.LogInfo((object)$"❌ Failed to add item to the shop (chance: {chancePercent}%, roll: {num:F2}).");
}
}
catch (Exception arg)
{
Logger.LogError((object)$"❗ Exception in TryAddItemToShop: {arg}");
}
}
}
}