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 System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("EggsplosiveDay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds an Eggsplosive day to Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("EggsplosiveDay")]
[assembly: AssemblyTitle("EggsplosiveDay")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.1")]
namespace EggsplosiveDay
{
[BepInPlugin("EggsplosiveDay", "EggsplosiveDay", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
private Harmony _harmony = new Harmony("EggsplosiveDay");
public static ManualLogSource Logger;
public static ConfigEntry<int> Chance;
public static ConfigEntry<string> Item;
public static ConfigEntry<int> Rarity;
public static ConfigEntry<bool> Debug;
public static ConfigEntry<string> SpawnType;
public static Plugin Instance { get; private set; }
private void Awake()
{
Logger = Logger.CreateLogSource("EggsplosiveDay");
Logger.LogInfo((object)"\r\n-\"-.\r\n .'=^=^='.\r\n /=^=^=^=^=\\\r\n :^= Eggs =^;\r\n |^ Day ^|\r\n :^=^=^=^=^=^:\r\n \\=^=^=^=^=/\r\n `.=^=^=.'\r\n `~~~` \r\nPlugin EggsplosiveDay is loading.");
Logger.LogInfo((object)"Loaded EggsplosiveDay. Patching.");
Instance = this;
Chance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Chance", 20, "Default: 20\n(1 in 20) chance every day");
Item = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Item", "Easter egg", "Default: Easter egg");
Debug = ((BaseUnityPlugin)this).Config.Bind<bool>("DebugMode", "Debug", true, "Default: True");
SpawnType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SpawnType", "zero", "Default:zero\nAccepted Values are zero,dynamic,default\nzero sets all other item rarities to zero\ndefault leaves other item rarities as it is\ndynamic sets the other item rarities 100 - ChanceConfig = Other Item rarity");
Rarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Rarity", 100, "Default: 100\nOnly value 0-100 are accepted");
_harmony.PatchAll(typeof(Plugin));
}
[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
[HarmonyPrefix]
private static bool Roll(ref SelectableLevel newLevel)
{
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Expected O, but got Unknown
int num = Random.Range(1, Chance.Value);
if (Debug.Value)
{
Logger.LogInfo((object)$"Rolled a {num}");
Logger.LogInfo((object)$"Config: Chance:{Chance.Value}\nItem:{Item.Value},Rarity:{Rarity.Value},SpawnType:{SpawnType.Value}");
}
if (num == 1)
{
if (Debug.Value)
{
Logger.LogInfo((object)"Roll is 1. Activating egg-only spawn modifications.");
}
if (Rarity.Value < 0 || Rarity.Value > 100)
{
Rarity.Value = 100;
}
List<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>();
foreach (SpawnableItemWithRarity item in newLevel.spawnableScrap)
{
if (SpawnType.Value == "zero")
{
item.rarity = 0;
}
else if (SpawnType.Value == "dynamic")
{
item.rarity = 100 - Rarity.Value;
}
if (item.spawnableItem.itemName == Item.Value)
{
item.rarity = Rarity.Value;
}
}
if (!newLevel.spawnableScrap.Any((SpawnableItemWithRarity s) => s.spawnableItem.itemName == Item.Value))
{
foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
{
if (items.itemName == Item.Value)
{
list.Add(new SpawnableItemWithRarity
{
spawnableItem = items,
rarity = Rarity.Value
});
}
}
}
newLevel.spawnableScrap.AddRange(list);
}
else if (Debug.Value)
{
Logger.LogInfo((object)"Roll did not meet condition (1). Skipping the modification.");
}
return true;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "EggsplosiveDay";
public const string PLUGIN_NAME = "EggsplosiveDay";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute([In] int obj0)
{
Version = obj0;
}
}
}