using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BarberFixes;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ClaySurgeonMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A different take on the Barber")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+17f606f363f2258c0e0374efce368b370c5b9d8a")]
[assembly: AssemblyProduct("ClaySurgeonMod")]
[assembly: AssemblyTitle("ClaySurgeonMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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;
}
}
}
namespace ClaySurgeonMod
{
[BepInPlugin("dopadream.lethalcompany.ClaySurgeonMod", "Clay Surgeon", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInIncompatibility("dopadream.lethalcompany.barbermaterialtweaks")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
private class ClaySurgeonPatches
{
[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
[HarmonyPostfix]
private static void RoundManagerPostRefresh(RoundManager __instance, ref int ___enemyRushIndex)
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
DateTime dateTime = new DateTime(DateTime.Now.Year, 10, 31);
bool num = DateTime.Today == dateTime;
Random random = new Random(StartOfRound.Instance.randomMapSeed + 5781);
if (((!num || random.Next(0, 210) >= 3) && random.Next(0, 1000) >= 15) || ___enemyRushIndex != -1 || !configInfestations.Value)
{
return;
}
for (int i = 0; i < __instance.currentLevel.Enemies.Count; i++)
{
if (__instance.currentLevel.Enemies[i].enemyType.enemyName == "Clay Surgeon" && __instance.currentLevel.Enemies[i].enemyType.MaxCount > 0)
{
Logger.LogDebug((object)"Clay infestation started!");
((Component)__instance.indoorFog).gameObject.SetActive(random.Next(0, 100) < 20);
___enemyRushIndex = i;
__instance.currentMaxInsidePower = 30f;
break;
}
}
}
[HarmonyPatch(typeof(QuickMenuManager), "Start")]
[HarmonyPostfix]
private static void QuickMenuManagerPostStart(QuickMenuManager __instance)
{
allEnemiesList.Clear();
List<SpawnableEnemyWithRarity>[] array = new List<SpawnableEnemyWithRarity>[1] { __instance.testAllEnemiesLevel.Enemies };
if (!configSpawnOverride.Value)
{
return;
}
List<SpawnableEnemyWithRarity>[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
foreach (SpawnableEnemyWithRarity item in array2[i])
{
if (allEnemiesList.ContainsKey(((Object)item.enemyType).name))
{
if ((Object)(object)allEnemiesList[((Object)item.enemyType).name] == (Object)(object)item.enemyType)
{
Logger.LogWarning((object)("allEnemiesList: Tried to cache reference to \"" + ((Object)item.enemyType).name + "\" more than once"));
}
else
{
Logger.LogWarning((object)("allEnemiesList: Tried to cache two different enemies by same name (" + ((Object)item.enemyType).name + ")"));
}
}
else if (item.enemyType.enemyName == "Clay Surgeon")
{
item.enemyType.spawnInGroupsOf = 2;
item.enemyType.MaxCount = 8;
item.enemyType.probabilityCurve = dummyType.probabilityCurve;
item.enemyType.numberSpawnedFalloff = dummyType.numberSpawnedFalloff;
item.enemyType.useNumberSpawnedFalloff = true;
item.enemyType.numberSpawned = 0;
Logger.LogDebug((object)"Barber spawn settings overriden!");
return;
}
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Awake")]
[HarmonyPostfix]
private static void ClaySurgeonAIPostWake(ClaySurgeonAI __instance)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
Object.Destroy((Object)(object)((Component)((EnemyAI)__instance).creatureAnimator).gameObject);
Transform transform = Object.Instantiate<GameObject>(clayPrefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation, ((Component)__instance).transform.Find("MeshContainer")).transform;
((EnemyAI)__instance).creatureAnimator = ((Component)transform).GetComponentInChildren<Animator>();
__instance.skin = ((Component)transform).GetComponentInChildren<SkinnedMeshRenderer>();
((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>().headerText = "Clay Surgeon";
((EnemyAI)__instance).skinnedMeshRenderers = ((Component)transform).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
((EnemyAI)__instance).meshRenderers = ((Component)transform).gameObject.GetComponentsInChildren<MeshRenderer>();
((Component)transform).GetComponentInChildren<EnemyAnimationEvent>().mainScript = ((Component)__instance).gameObject.GetComponentInChildren<EnemyAnimationEvent>().mainScript;
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Start")]
[HarmonyPostfix]
private static void ClaySurgeonAIPostStart(ClaySurgeonAI __instance)
{
Material[] array = (Material[])(object)new Material[((Renderer)__instance.skin).sharedMaterials.Length];
for (int i = 0; i < array.Length; i++)
{
array[i] = ((Renderer)__instance.skin).materials[i];
}
((Renderer)__instance.skin).sharedMaterials = array;
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Update")]
[HarmonyPostfix]
private static void ClaySurgeonAIPostUpdate(ClaySurgeonAI __instance)
{
AudioSource[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<AudioSource>();
foreach (AudioSource val in componentsInChildren)
{
if (((Object)val.clip).name == "ClaySurgeonAmbience")
{
val.volume = configAmbience.Value;
break;
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "SetVisibility")]
[HarmonyPostfix]
private static void ClaySurgeonAIPostSetVis(ClaySurgeonAI __instance)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
float num = Vector3.Distance(((Component)StartOfRound.Instance.audioListener).transform.position, ((Component)__instance).transform.position + Vector3.up * 0.7f);
Material[] sharedMaterials = ((Renderer)__instance.skin).sharedMaterials;
Material[] array = sharedMaterials;
for (int i = 0; i < array.Length; i++)
{
array[i].SetFloat("_AlphaCutoff", (num - __instance.minDistance) / (__instance.maxDistance - __instance.minDistance));
}
((Renderer)__instance.skin).material.SetFloat("_IridescenceMask", configIridescence.Value);
((Renderer)__instance.skin).sharedMaterials = sharedMaterials;
}
[HarmonyPatch(typeof(DanceClock), "Tick")]
[HarmonyPrefix]
private static bool DanceClockPreTick()
{
if (configCurve.Value)
{
float currentInterval = Mathf.Clamp(curveDummyType.probabilityCurve.Evaluate((float)TimeOfDay.Instance.hour / (float)TimeOfDay.Instance.numberOfHours), 1.25f, 2.75f);
ClaySurgeonAI[] array = Object.FindObjectsOfType<ClaySurgeonAI>();
for (int i = 0; i < array.Length; i++)
{
array[i].currentInterval = currentInterval;
}
return false;
}
return true;
}
[HarmonyPatch(typeof(Terminal), "Awake")]
[HarmonyPostfix]
private static void TerminalPostWake(Terminal __instance)
{
TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords;
foreach (TerminalNode enemyFile in __instance.enemyFiles)
{
if (enemyFile.creatureFileID != 24)
{
continue;
}
enemyFile.displayVideo = clayNode.displayVideo;
enemyFile.displayText = clayNode.displayText;
enemyFile.creatureName = clayNode.creatureName;
TerminalKeyword[] array = allKeywords;
foreach (TerminalKeyword val in array)
{
if (val.word == "barber")
{
val.word = "clay surgeon";
return;
}
}
Logger.LogDebug((object)"Barber bestiary entry replaced!");
break;
}
}
}
private const string PLUGIN_GUID = "dopadream.lethalcompany.ClaySurgeonMod";
private const string PLUGIN_NAME = "Clay Surgeon";
private const string PLUGIN_VERSION = "1.2.1";
private const string LETHAL_CONFIG = "ainavt.lc.lethalconfig";
internal static ManualLogSource Logger;
internal static GameObject clayPrefab;
internal static GameObject barberPrefab;
internal static TerminalNode clayNode;
internal static EnemyType dummyType;
internal static EnemyType curveDummyType;
internal static Dictionary<string, EnemyType> allEnemiesList = new Dictionary<string, EnemyType>();
internal static ConfigEntry<bool> configSpawnOverride;
internal static ConfigEntry<bool> configInfestations;
internal static ConfigEntry<bool> configCurve;
internal static ConfigEntry<float> configAmbience;
internal static ConfigEntry<float> configIridescence;
protected const string anchorPath = "MeshContainer";
protected const string animPath = "MeshContainer/AnimContainer";
internal void initLethalConfig()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(configSpawnOverride, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(configInfestations, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(configCurve, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(configAmbience, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(configIridescence, false));
LethalConfigManager.SkipAutoGen();
}
private void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
configSpawnOverride = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Override Spawn Settings", true, new ConfigDescription("Overrides spawning logic of Clay Surgeons (Barbers). With this enabled, they will spawn in pairs and be more common. Disable if you want to customize their spawning yourself through plugins such as LethalQuantities.", (AcceptableValueBase)null, Array.Empty<object>()));
configInfestations = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Clay Infestations", true, new ConfigDescription("Adds a chance for Hoarding bug/Nutcracker infestations to be Clay Surgeon Infestations instead.", (AcceptableValueBase)null, Array.Empty<object>()));
configCurve = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Curved Acceleration", true, new ConfigDescription("Makes the Clay Surgeon accelerate at a curve rather than a flat rate per hour.", (AcceptableValueBase)null, Array.Empty<object>()));
configAmbience = ((BaseUnityPlugin)this).Config.Bind<float>("Aesthetics", "Proximity Ambience Volume", 0.35f, new ConfigDescription("Controls the volume of the Clay Surgeon's proximity ambience.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
configIridescence = ((BaseUnityPlugin)this).Config.Bind<float>("Aesthetics", "Iridescence", 0.25f, new ConfigDescription("Controls the iridescence of the Clay Surgeon's clay material.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
{
initLethalConfig();
}
try
{
AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "claysurgeonmod"));
Object obj2 = obj.LoadAsset("ClaySurgeonNew", typeof(GameObject));
clayPrefab = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
Object obj3 = obj.LoadAsset("ClaySurgeonFile", typeof(TerminalNode));
clayNode = (TerminalNode)(object)((obj3 is TerminalNode) ? obj3 : null);
Object obj4 = obj.LoadAsset("DummyEnemyType", typeof(EnemyType));
dummyType = (EnemyType)(object)((obj4 is EnemyType) ? obj4 : null);
Object obj5 = obj.LoadAsset("CurveDummyType", typeof(EnemyType));
curveDummyType = (EnemyType)(object)((obj5 is EnemyType) ? obj5 : null);
}
catch
{
Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?");
return;
}
new Harmony("dopadream.lethalcompany.ClaySurgeonMod").PatchAll();
Logger.LogInfo((object)"Clay Surgeon v1.2.1 loaded");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ClaySurgeonMod";
public const string PLUGIN_NAME = "ClaySurgeonMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}