using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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;
public static ConfigEntry<bool> ExplodyLuggage;
public static ConfigEntry<bool> SuperBeanMode;
public static ConfigEntry<float> BeanChance;
public static ConfigEntry<float> ExplodyPower;
public static ConfigEntry<bool> RandomOpenings;
public static ConfigEntry<float> RandomOpeningChance;
public static ConfigEntry<int> AdditionalBeans;
public static ConfigEntry<float> AdditionalMultiplierForEachPlayer;
private void Awake()
{
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Expected O, but got Unknown
//IL_0244: 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)");
AdditionalMultiplierForEachPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Additional Multiplier For Each Player", 0f, (ConfigDescription)null);
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");
BeanChance = ((BaseUnityPlugin)this).Config.Bind<float>("Toasts Extras", "Bean Replacement % Chance", 0f, new ConfigDescription("The chance for beans to replace an item", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
SuperBeanMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Toasts Extras", "Super Bean Mode", false, "Beans that spawn in luggage will explode out always");
AdditionalBeans = ((BaseUnityPlugin)this).Config.Bind<int>("Toasts Extras", "Additional Beans", 0, new ConfigDescription("how many Additional beans are in each luggage", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>()));
ExplodyLuggage = ((BaseUnityPlugin)this).Config.Bind<bool>("Toasts Extras", "Explody Mode", false, "All items explode out of luggages");
ExplodyPower = ((BaseUnityPlugin)this).Config.Bind<float>("Toasts Extras", "Explody Power", 20000f, new ConfigDescription("How powerful items are flung out of luggages", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50000f), Array.Empty<object>()));
RandomOpenings = ((BaseUnityPlugin)this).Config.Bind<bool>("Toasts Extras", "Random Openings", false, "If on items from luggages will be spawned randomly around them");
RandomOpeningChance = ((BaseUnityPlugin)this).Config.Bind<float>("Toasts Extras", "Random Openings % Chance (procs 50 times a second)", 0f, new ConfigDescription("Chance for a random opening to happen each frame", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
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)
{
default:
Log.LogInfo((object)("[" + name + "] Unknown spawner type, multiplier disabled"));
return false;
case "GroundPlaceSpawner":
return EnableGroundSpawner.Value;
case "BerryVine":
return EnableBerryVine.Value;
case "BerryBush":
return EnableBerryBush.Value;
case "RespawnChest":
return EnableRespawnChest.Value;
case "Luggage":
return EnableLuggage.Value;
}
}
}
[HarmonyPatch(typeof(Spawner), "SpawnItems")]
public static class SpawnerPatch
{
public static bool Prefix(Spawner __instance, List<Transform> spawnSpots, ref List<PhotonView> __result)
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0501: Unknown result type (might be due to invalid IL or missing references)
//IL_0506: Unknown result type (might be due to invalid IL or missing references)
//IL_050d: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0559: Unknown result type (might be due to invalid IL or missing references)
//IL_0565: Unknown result type (might be due to invalid IL or missing references)
//IL_056a: Unknown result type (might be due to invalid IL or missing references)
//IL_056f: Unknown result type (might be due to invalid IL or missing references)
//IL_0573: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0583: Unknown result type (might be due to invalid IL or missing references)
//IL_058a: Unknown result type (might be due to invalid IL or missing references)
//IL_058f: Unknown result type (might be due to invalid IL or missing references)
//IL_0594: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Unknown result type (might be due to invalid IL or missing references)
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
//IL_05c1: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_066e: Unknown result type (might be due to invalid IL or missing references)
//IL_0675: Unknown result type (might be due to invalid IL or missing references)
//IL_067f: Unknown result type (might be due to invalid IL or missing references)
//IL_0684: Unknown result type (might be due to invalid IL or missing references)
//IL_0698: Unknown result type (might be due to invalid IL or missing references)
//IL_06af: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0430: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Unknown result type (might be due to invalid IL or missing references)
//IL_0489: 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 + ItemMultiplierMod.AdditionalMultiplierForEachPlayer.Value * (float)Character.AllCharacters.Count}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 num = ItemMultiplierMod.ItemMultiplier.Value + ItemMultiplierMod.AdditionalMultiplierForEachPlayer.Value * (float)Character.AllCharacters.Count;
int num2 = Mathf.RoundToInt((float)spawnSpots.Count * num);
ItemMultiplierMod.Log.LogInfo((object)$"[{name}] Spawning {num2} items (original: {spawnSpots.Count}, multiplier: {num}x)");
List<GameObject> list = (List<GameObject>)method.Invoke(__instance, new object[2] { num2, flag });
int i;
Vector3 val4;
Vector3 val6 = default(Vector3);
for (i = 0; i < num2 && i < list.Count; i++)
{
if ((Object)(object)list[i] == (Object)null)
{
continue;
}
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(1f, 2f), Random.Range(-0.5f, 0.5f));
}
bool flag3 = false;
Item component;
if (Random.Range(0f, 100f) < ItemMultiplierMod.BeanChance.Value)
{
component = PhotonNetwork.InstantiateItemRoom("MagicBean", val3, val2.rotation).GetComponent<Item>();
flag3 = true;
((ItemComponent)((Component)component).GetComponent<MagicBean>()).GetData<OptionableBoolItemData>((DataEntryKey)8).HasData = true;
}
else
{
component = PhotonNetwork.InstantiateItemRoom(((Object)list[i]).name, val3, val2.rotation).GetComponent<Item>();
}
__result.Add(((Component)component).GetComponent<PhotonView>());
if ((Object)(object)val != (Object)null)
{
Transform transform = ((Component)component).transform;
val4 = val.position - ((Component)component).transform.position;
transform.up = ((Vector3)(ref val4)).normalized;
}
if (flag2)
{
Vector3 val5 = val2.position - component.Center();
Transform transform2 = ((Component)component).transform;
transform2.position += val5 + Vector3.up * (float)i * 0.25f;
}
if ((Object)(object)component != (Object)null)
{
if (ItemMultiplierMod.ExplodyLuggage.Value || (flag3 && ItemMultiplierMod.SuperBeanMode.Value))
{
((Vector3)(ref val6))..ctor(Random.Range(0f - ItemMultiplierMod.ExplodyPower.Value, ItemMultiplierMod.ExplodyPower.Value), Random.Range(0f, ItemMultiplierMod.ExplodyPower.Value), Random.Range(0f - ItemMultiplierMod.ExplodyPower.Value, ItemMultiplierMod.ExplodyPower.Value));
((Component)component).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
false,
((Component)component).transform.position + ((Vector3)(ref val6)).normalized * 5f,
((Component)component).transform.rotation
});
component.rig.AddForce(val6);
}
else
{
((Component)component).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
true,
((Component)component).transform.position,
((Component)component).transform.rotation
});
}
}
}
Vector3 val9 = default(Vector3);
for (int j = 0; j < ItemMultiplierMod.AdditionalBeans.Value; j++)
{
Transform val7 = spawnSpots[0];
Vector3 position = val7.position;
position += new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(1f, 2f), Random.Range(-0.5f, 0.5f));
Item component2 = PhotonNetwork.InstantiateItemRoom("MagicBean", position, val7.rotation).GetComponent<Item>();
bool flag4 = true;
((ItemComponent)((Component)component2).GetComponent<MagicBean>()).GetData<OptionableBoolItemData>((DataEntryKey)8).HasData = true;
__result.Add(((Component)component2).GetComponent<PhotonView>());
if ((Object)(object)val != (Object)null)
{
Transform transform3 = ((Component)component2).transform;
val4 = val.position - ((Component)component2).transform.position;
transform3.up = ((Vector3)(ref val4)).normalized;
}
if (flag2)
{
Vector3 val8 = val7.position - component2.Center();
Transform transform4 = ((Component)component2).transform;
transform4.position += val8 + Vector3.up * (float)i * 0.25f;
}
if ((Object)(object)component2 != (Object)null)
{
if (ItemMultiplierMod.ExplodyLuggage.Value || (flag4 && ItemMultiplierMod.SuperBeanMode.Value))
{
((Vector3)(ref val9))..ctor(Random.Range(0f - ItemMultiplierMod.ExplodyPower.Value, ItemMultiplierMod.ExplodyPower.Value), Random.Range(0f, ItemMultiplierMod.ExplodyPower.Value), Random.Range(0f - ItemMultiplierMod.ExplodyPower.Value, ItemMultiplierMod.ExplodyPower.Value));
((Component)component2).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
false,
((Component)component2).transform.position + ((Vector3)(ref val9)).normalized * 5f,
((Component)component2).transform.rotation
});
component2.rig.AddForce(val9);
}
else
{
((Component)component2).GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
true,
((Component)component2).transform.position,
((Component)component2).transform.rotation
});
}
}
}
return false;
}
}
[HarmonyPatch(typeof(Character), "Update")]
public static class SpawnerPatch2
{
public static void Prefix(Character __instance)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.IsLocal || !(Random.Range(0f, 100f) < ItemMultiplierMod.RandomOpeningChance.Value))
{
return;
}
Spawner[] array = Object.FindObjectsByType<Spawner>((FindObjectsSortMode)0);
Spawner val = array[Random.Range(0, array.Length)];
while (!ItemMultiplierMod.IsMultiplierEnabled(val))
{
val = array[Random.Range(0, array.Length)];
}
List<Transform> spawnSpots = val.spawnSpots.ToList();
Vector3 groundPos = HelperFunctions.GetGroundPos(((Component)val).transform.position + new Vector3((float)Random.Range(-100, 100), 100f, (float)Random.Range(-100, 100)), (LayerType)1, 0f);
foreach (Transform spawnSpot in val.spawnSpots)
{
spawnSpot.position = groundPos;
}
val.SpawnItems(val.spawnSpots);
val.spawnSpots = spawnSpots;
}
}