using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using PapersTweaks;
using PapersTweaks.Patches;
using Unity.Netcode;
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("PapersTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Paperbark's opinionated tweaks for Lethal Company")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+759647f63932bb600a3ffc17ef4e40f0699167d8")]
[assembly: AssemblyProduct("PapersTweaks")]
[assembly: AssemblyTitle("PapersTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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;
}
}
}
internal class PluginUtils
{
public static EnemyType GetEnemyType(string name)
{
try
{
return Resources.FindObjectsOfTypeAll<EnemyType>().Single((EnemyType enemyType) => ((Object)enemyType).name == name);
}
catch
{
Plugin.logger.LogError((object)("Failed to find enemy type with name \"" + name + "\", please report this as a bug."));
}
return null;
}
}
namespace PapersTweaks
{
[BepInPlugin("horse.paperbark.PapersTweaks", "PapersTweaks", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "horse.paperbark.PapersTweaks";
public const string modName = "PapersTweaks";
public const string modVersion = "1.0.0";
private static Harmony _harmony = new Harmony("horse.paperbark.PapersTweaks");
internal static ManualLogSource logger = Logger.CreateLogSource("horse.paperbark.PapersTweaks");
internal static PluginConfig BoundConfig { get; private set; } = null;
private void Awake()
{
BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
ApplyPatches();
logger.LogInfo((object)"Paper's Tweaks 1.0.0 is loaded! /)");
}
private static void ApplyPatches()
{
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(BushWolfEnemyPatch));
_harmony.PatchAll(typeof(ButlerEnemyAIPatch));
_harmony.PatchAll(typeof(ButlerBeesEnemyAIPatch));
}
}
internal class PluginConfig
{
public readonly ConfigEntry<bool> vainInfestationEnabled;
public readonly ConfigEntry<int> vainInfestationChance;
public readonly ConfigEntry<int> vainInfestationSizeMin;
public readonly ConfigEntry<int> vainInfestationSizeMax;
public readonly ConfigEntry<int> bushWolfHealth;
public readonly ConfigEntry<int> butlerHealth;
public readonly ConfigEntry<int> butlerMaxCount;
public readonly ConfigEntry<bool> removeButlerBees;
public PluginConfig(ConfigFile config)
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_0186: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Expected O, but got Unknown
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Expected O, but got Unknown
//IL_01d1: Expected O, but got Unknown
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Expected O, but got Unknown
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: 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_020d: Expected O, but got Unknown
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Expected O, but got Unknown
//IL_021c: Expected O, but got Unknown
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Expected O, but got Unknown
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: 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_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Expected O, but got Unknown
//IL_0266: Expected O, but got Unknown
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Expected O, but got Unknown
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Expected O, but got Unknown
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Expected O, but got Unknown
//IL_02b0: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Expected O, but got Unknown
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Expected O, but got Unknown
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Expected O, but got Unknown
//IL_02fa: Expected O, but got Unknown
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Expected O, but got Unknown
//IL_0306: 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_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Expected O, but got Unknown
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Expected O, but got Unknown
config.SaveOnConfigSet = false;
vainInfestationEnabled = config.Bind<bool>("Tweaks.VainInfestation", "Enabled", true, "Whether random Vain Shroud infestations should replace the vanilla spreading mechanics");
vainInfestationChance = config.Bind<int>("Tweaks.VainInfestation", "Chance", 5, "The chance a moon is infested each day (0 - 100)");
vainInfestationSizeMin = config.Bind<int>("Tweaks.VainInfestation", "MinSize", 5, "Minimum size of vain shroud patches");
vainInfestationSizeMax = config.Bind<int>("Tweaks.VainInfestation", "MaxSize", 15, "Maximum size of vain shroud patches");
bushWolfHealth = config.Bind<int>("Tweaks.BushWolf", "Health", 3, "The amount of health Kidnapper Foxes have. Set to 0 to disable this tweak.");
butlerHealth = config.Bind<int>("Tweaks.Butler", "Health", 4, "The amount of health Butlers have in multiplayer. Set to 0 to disable this tweak.");
butlerMaxCount = config.Bind<int>("Tweaks.Butler", "MaxCount", 2, "The maximum number of Butlers which can spawn. Set to 0 to disable this tweak.");
removeButlerBees = config.Bind<bool>("Tweaks.Butler", "Remove Butler Bees", true, "Prevents Butler Bees from spawning when a butler Dies.");
ClearOrphanedEntries(config);
config.Save();
config.SaveOnConfigSet = true;
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(vainInfestationEnabled, new BoolCheckBoxOptions
{
Section = "Vain Shroud Infestations",
Name = "Enabled",
Description = "When enabled, Vain Shrouds have a random chance of occuring each round instead of vanilla's spawning where they stay between days."
}));
ConfigEntry<int> obj = vainInfestationChance;
IntSliderOptions val = new IntSliderOptions
{
Section = "Vain Shroud Infestations",
Name = "Chance",
Description = "The chance (as a percentage) for a moon to have Vain Shrouds. Enable infestations and set to 0 to completely disable Vain Shroud spawning."
};
((BaseRangeOptions<int>)val).Min = 0;
((BaseRangeOptions<int>)val).Max = 100;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj, val));
ConfigEntry<int> obj2 = vainInfestationSizeMin;
IntSliderOptions val2 = new IntSliderOptions
{
Section = "Vain Shroud Infestations",
Name = "Min Size",
Description = "The smallest amount of Vain Shrouds that can spawn, as the number of spawning iterations."
};
((BaseRangeOptions<int>)val2).Min = 0;
((BaseRangeOptions<int>)val2).Max = 20;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj2, val2));
ConfigEntry<int> obj3 = vainInfestationSizeMax;
IntSliderOptions val3 = new IntSliderOptions
{
Section = "Vain Shroud Infestations",
Name = "Max Size",
Description = "The largest amount of Vain Shrouds that can spawn, as the number of spawning iterations."
};
((BaseRangeOptions<int>)val3).Min = 0;
((BaseRangeOptions<int>)val3).Max = 20;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj3, val3));
ConfigEntry<int> obj4 = bushWolfHealth;
IntSliderOptions val4 = new IntSliderOptions
{
Section = "Kidnapper Fox",
Name = "Health",
Description = "The amount of health Kidnapper Foxes should spawn with. Set to 0 to disable this tweak and use vanilla's default."
};
((BaseRangeOptions<int>)val4).Min = 0;
((BaseRangeOptions<int>)val4).Max = 7;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj4, val4));
ConfigEntry<int> obj5 = butlerHealth;
IntSliderOptions val5 = new IntSliderOptions
{
Section = "Butler",
Name = "Health",
Description = "The amount of health Butlers should spawn with. Set to 0 to disable this tweak and use vanilla's default."
};
((BaseRangeOptions<int>)val5).Min = 0;
((BaseRangeOptions<int>)val5).Max = 8;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj5, val5));
ConfigEntry<int> obj6 = butlerMaxCount;
IntSliderOptions val6 = new IntSliderOptions
{
Section = "Butler",
Name = "Max Spawns",
Description = "The maximum number of Butlers which can spawn. Set to 0 to disable this tweak and use vanilla's default."
};
((BaseRangeOptions<int>)val6).Min = 0;
((BaseRangeOptions<int>)val6).Max = 7;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(obj6, val6));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(removeButlerBees, new BoolCheckBoxOptions
{
Section = "Butler",
Name = "No Butler Bees",
Description = "When enabled, Butlers will not spawn bees when they die."
}));
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PapersTweaks";
public const string PLUGIN_NAME = "PapersTweaks";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace PapersTweaks.Patches
{
[HarmonyPatch(typeof(BushWolfEnemy))]
internal class BushWolfEnemyPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(BushWolfEnemy __instance)
{
if (Plugin.BoundConfig.bushWolfHealth.Value > 0)
{
Plugin.logger.LogInfo((object)("Set Kidnapper Fox HP to " + Plugin.BoundConfig.bushWolfHealth.Value + ", was " + ((EnemyAI)__instance).enemyHP));
((EnemyAI)__instance).enemyHP = Plugin.BoundConfig.bushWolfHealth.Value;
}
}
}
[HarmonyPatch(typeof(ButlerBeesEnemyAI))]
internal class ButlerBeesEnemyAIPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ButlerBeesEnemyAI __instance)
{
if (((NetworkBehaviour)__instance).IsServer && Plugin.BoundConfig.removeButlerBees.Value)
{
if (((EnemyAI)__instance).thisNetworkObject.IsSpawned)
{
Plugin.logger.LogInfo((object)"ButlerBees forcefully despawned");
((EnemyAI)__instance).thisNetworkObject.Despawn(true);
}
else
{
Plugin.logger.LogInfo((object)"ButlerBees not despawned, they haven't spawned yet");
}
}
}
}
[HarmonyPatch(typeof(ButlerEnemyAI))]
internal class ButlerEnemyAIPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ButlerEnemyAI __instance)
{
Plugin.logger.LogInfo((object)"Butler start patch");
if (Plugin.BoundConfig.removeButlerBees.Value)
{
__instance.buzzingAmbience.playOnAwake = false;
__instance.buzzingAmbience.mute = true;
__instance.buzzingAmbience.Stop();
}
if (Plugin.BoundConfig.butlerHealth.Value > 0)
{
int enemyHP = Math.Min(Plugin.BoundConfig.butlerHealth.Value, ((EnemyAI)__instance).enemyHP);
Plugin.logger.LogInfo((object)("Set Butler HP to " + enemyHP + ", was " + ((EnemyAI)__instance).enemyHP));
((EnemyAI)__instance).enemyHP = enemyHP;
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
if (Plugin.BoundConfig.butlerMaxCount.Value > 0)
{
EnemyType enemyType = PluginUtils.GetEnemyType("Butler");
if ((Object)(object)enemyType != (Object)null)
{
Plugin.logger.LogInfo((object)("Set Butler max count to " + Plugin.BoundConfig.butlerMaxCount.Value));
enemyType.MaxCount = Plugin.BoundConfig.butlerMaxCount.Value;
}
}
}
[HarmonyPatch("SetPlanetsMold")]
[HarmonyPostfix]
private static void SetPlanetsMoldPatch(StartOfRound __instance, ref SelectableLevel[] ___levels, ref int ___randomMapSeed)
{
if (Plugin.BoundConfig.vainInfestationEnabled.Value && ((NetworkBehaviour)__instance).IsServer)
{
RandomiseInfestationMoldSpread(___levels, ___randomMapSeed);
}
}
[HarmonyPatch("LoadPlanetsMoldSpreadData")]
[HarmonyPostfix]
private static void LoadPlanetsMoldSpreadDataPatch(StartOfRound __instance, ref SelectableLevel[] ___levels, ref int ___randomMapSeed)
{
if (Plugin.BoundConfig.vainInfestationEnabled.Value && ((NetworkBehaviour)__instance).IsServer)
{
RandomiseInfestationMoldSpread(___levels, ___randomMapSeed);
}
}
private static void RandomiseInfestationMoldSpread(SelectableLevel[] levels, int randomMapSeed)
{
Plugin.logger.LogInfo((object)"Randomising vain shroud infestations for all levels");
Random random = new Random(randomMapSeed + 32);
foreach (SelectableLevel val in levels)
{
val.moldStartPosition = -1;
if (val.canSpawnMold && random.Next(0, 100) < Plugin.BoundConfig.vainInfestationChance.Value)
{
val.moldSpreadIterations = random.Next(Plugin.BoundConfig.vainInfestationSizeMin.Value, Plugin.BoundConfig.vainInfestationSizeMax.Value);
Plugin.logger.LogInfo((object)(" - " + val.PlanetName + " is infested with vain shrouds"));
}
else
{
val.moldSpreadIterations = 0;
}
}
}
}
}