using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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;
}
}
}
[BepInPlugin("com.peak.itemmultiplier", "Item Multiplier Mod", "1.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_00d4: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Expected O, but got Unknown
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: 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_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: 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_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: 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_0282: 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_02cf: 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)(object)list[i] == (Object)null))
{
Transform val2 = spawnSpots[i % spawnSpots.Count];
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)(object)val != (Object)null)
{
Transform transform = ((Component)component).transform;
Vector3 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;
}
if ((Object)(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;
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class IgnoresAccessChecksToAttribute : Attribute
{
public string AssemblyName { get; }
public IgnoresAccessChecksToAttribute(string assemblyName)
{
AssemblyName = assemblyName;
}
}
}