using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("4+ Friends Stamina")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("4+ Friends Stamina")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("47d8f5be-022f-4ab4-9462-5272099ea073")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace _4__Friends_Stats;
[BepInPlugin("bek.ItemMultiplierRescueClawFixed", "ItemMultiplierRescueClawFixed", "1.0")]
[BepInProcess("PEAK.exe")]
public class ItemMultiplierMod : BaseUnityPlugin
{
public static ManualLogSource Log;
public static ConfigEntry<float> ItemMultiplier;
public static ConfigEntry<bool> EnableLuggage;
public static ConfigEntry<bool> EnableRespawnChest;
public static ConfigEntry<bool> EnableBerryBush;
public static ConfigEntry<bool> EnableBerryVine;
public static ConfigEntry<bool> EnableGroundSpawner;
private void Awake()
{
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
Log = Logger.CreateLogSource("ItemMultiplier");
ItemMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ItemMultiplier", 2f, "Item spawn multiplier (2.0 = 2x items, 5.0 = 5x items)");
EnableLuggage = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawner Types", "EnableLuggage", true, "Enable multiplier for Luggage (chests)");
EnableRespawnChest = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawner Types", "EnableRespawnChest", false, "Enable multiplier for RespawnChest");
EnableBerryBush = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawner Types", "EnableBerryBush", false, "Enable multiplier for BerryBush");
EnableBerryVine = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawner Types", "EnableBerryVine", false, "Enable multiplier for BerryVine");
EnableGroundSpawner = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawner Types", "EnableGroundSpawner", false, "Enable multiplier for GroundPlaceSpawner");
new Harmony("com.peak.itemmultiplier").PatchAll();
Log.LogInfo((object)$"Item Multiplier Mod v1.1.0 loaded! Multiplier: {ItemMultiplier.Value}x");
Log.LogInfo((object)$"Enabled: Luggage={EnableLuggage.Value}, RespawnChest={EnableRespawnChest.Value}, Berry={EnableBerryBush.Value}/{EnableBerryVine.Value}, Ground={EnableGroundSpawner.Value}");
}
public static bool IsMultiplierEnabled(Spawner spawner)
{
string name = ((object)spawner).GetType().Name;
switch (name)
{
case "Luggage":
return EnableLuggage.Value;
case "RespawnChest":
return EnableRespawnChest.Value;
case "BerryBush":
return EnableBerryBush.Value;
case "BerryVine":
return EnableBerryVine.Value;
case "GroundPlaceSpawner":
return EnableGroundSpawner.Value;
default:
Log.LogInfo((object)("[" + name + "] Unknown spawner type, multiplier disabled"));
return false;
}
}
}
[HarmonyPatch(typeof(Spawner), "SpawnItems")]
public static class SpawnerPatch
{
public static bool Prefix(Spawner __instance, List<Transform> spawnSpots, ref List<PhotonView> __result)
{
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Expected O, but got Unknown
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Expected O, but got Unknown
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Expected O, but got Unknown
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0371: Unknown result type (might be due to invalid IL or missing references)
string name = ((object)__instance).GetType().Name;
if (!ItemMultiplierMod.IsMultiplierEnabled(__instance))
{
ItemMultiplierMod.Log.LogInfo((object)("[" + name + "] Multiplier disabled, using original spawn"));
return true;
}
ItemMultiplierMod.Log.LogInfo((object)$"[{name}] Multiplier enabled, applying {ItemMultiplierMod.ItemMultiplier.Value}x");
__result = new List<PhotonView>();
if (!PhotonNetwork.IsMasterClient)
{
return false;
}
if (spawnSpots.Count == 0)
{
return false;
}
MethodInfo method = typeof(Spawner).GetMethod("GetObjectsToSpawn", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field = typeof(Spawner).GetField("canRepeatSpawns", BindingFlags.Instance | BindingFlags.Public);
FieldInfo field2 = typeof(Spawner).GetField("centerItemsVisually", BindingFlags.Instance | BindingFlags.Public);
FieldInfo field3 = typeof(Spawner).GetField("spawnUpTowardsTarget", BindingFlags.Instance | BindingFlags.Public);
bool flag = (bool)field.GetValue(__instance);
bool flag2 = (bool)field2.GetValue(__instance);
Transform val = (Transform)field3.GetValue(__instance);
float value = ItemMultiplierMod.ItemMultiplier.Value;
int num = Mathf.RoundToInt((float)spawnSpots.Count * value);
ItemMultiplierMod.Log.LogInfo((object)$"[{name}] Spawning {num} items (original: {spawnSpots.Count}, multiplier: {value}x)");
List<GameObject> list = (List<GameObject>)method.Invoke(__instance, new object[2] { num, flag });
for (int i = 0; i < num && i < list.Count; i++)
{
if (!((Object)list[i] == (Object)null))
{
Transform val2 = spawnSpots[i % spawnSpots.Count];
val2.rotation = Quaternion.Euler(val2.eulerAngles + new Vector3(90f, 0f, 0f));
Vector3 val3 = val2.position;
if (i >= spawnSpots.Count)
{
val3 += new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(0f, 0.2f), Random.Range(-0.5f, 0.5f));
}
Item component = PhotonNetwork.InstantiateItemRoom(((Object)list[i]).name, val3, val2.rotation).GetComponent<Item>();
__result.Add(((Component)component).GetComponent<PhotonView>());
if ((Object)val != (Object)null)
{
Transform transform = ((Component)component).transform;
Vector3 val4 = val.position - ((Component)component).transform.position;
Vector3 val5 = val4;
transform.up = ((Vector3)(ref val5)).normalized;
}
if (flag2)
{
Vector3 val6 = val2.position - component.Center();
Transform transform2 = ((Component)component).transform;
transform2.position += val6;
}
if ((Object)component != (Object)null)
{
((Component)component).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
true,
((Component)component).transform.position,
((Component)component).transform.rotation
});
}
}
}
return false;
}
}