using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Nessie.ATLYSS.EasySettings;
using UnityEngine;
using UnityEngine.Events;
[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("LemmeKissDaNPC")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e351ff4e692d57474dbfb50b8c2903e5a7b129bc")]
[assembly: AssemblyProduct("LemmeKissDaNPC")]
[assembly: AssemblyTitle("LemmeKissDaNPC")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.zcraftelite.lemmekissdanpc", "Lemme Kiss Da NPC", "1.2.0")]
public class LemmeKissDaNPC : BaseUnityPlugin
{
private HashSet<string> processedNpcsWithoutCollider = new HashSet<string>();
private bool skritProcessed;
private static ConfigEntry<bool> ConfigEnableEasterEgg;
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
InitConfig();
Settings.OnInitialized.AddListener(new UnityAction(AddSettings));
Settings.OnApplySettings.AddListener((UnityAction)delegate
{
((BaseUnityPlugin)this).Config.Save();
});
}
private void Start()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"LemmeKissDaNPC Loaded!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"LemmeKissDaNPC is version 1.2.0.");
FuckSkritOver();
((MonoBehaviour)this).StartCoroutine(CheckAndModifyNpcColliders());
}
private void InitConfig()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
ConfigDefinition val = new ConfigDefinition("Easter Egg", "EnableEasterEgg");
ConfigDescription val2 = new ConfigDescription("Enable or disable the Skrit Easter Egg.", (AcceptableValueBase)null, Array.Empty<object>());
ConfigEnableEasterEgg = ((BaseUnityPlugin)this).Config.Bind<bool>(val, true, val2);
}
private void AddSettings()
{
SettingsTab modTab = Settings.ModTab;
modTab.AddHeader("Lemme Kiss Da NPC");
modTab.AddToggle("Enable Easter Egg", ConfigEnableEasterEgg);
}
private bool IsEasterEggEnabled()
{
return ConfigEnableEasterEgg.Value;
}
private IEnumerator CheckAndModifyNpcColliders()
{
while (true)
{
yield return (object)new WaitForSeconds(1f);
CapsuleCollider[] array = Object.FindObjectsOfType<CapsuleCollider>();
foreach (CapsuleCollider val in array)
{
GameObject gameObject = ((Component)val).gameObject;
if (!((Object)gameObject).name.StartsWith("_npc_") || processedNpcsWithoutCollider.Contains(((Object)gameObject).name))
{
continue;
}
if (val.radius != 0f || val.height != 0f || ((Collider)val).enabled)
{
val.radius = 0f;
val.height = 0f;
((Collider)val).enabled = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Modified CapsuleCollider for " + ((Object)gameObject).name + "."));
}
Transform val2 = gameObject.transform.Find("_jumpOffCollider");
if ((Object)(object)val2 != (Object)null)
{
CapsuleCollider component = ((Component)val2).GetComponent<CapsuleCollider>();
if ((Object)(object)component != (Object)null && (component.radius != 0f || component.height != 0f || ((Collider)component).enabled))
{
component.radius = 0f;
component.height = 0f;
((Collider)component).enabled = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Modified CapsuleCollider for " + ((Object)gameObject).name + "'s _jumpOffCollider."));
}
}
Transform val3 = gameObject.transform.Find("_collider");
if ((Object)(object)val3 != (Object)null)
{
CapsuleCollider component2 = ((Component)val3).GetComponent<CapsuleCollider>();
if ((Object)(object)component2 != (Object)null && (component2.radius != 0f || component2.height != 0f || ((Collider)component2).enabled))
{
component2.radius = 0f;
component2.height = 0f;
((Collider)component2).enabled = false;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Modified CapsuleCollider for " + ((Object)gameObject).name + "'s _collider."));
}
}
}
GameObject[] array2 = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val4 in array2)
{
if (((Object)val4).name.StartsWith("_npc_") && !processedNpcsWithoutCollider.Contains(((Object)val4).name) && (Object)(object)val4.GetComponent<CapsuleCollider>() == (Object)null)
{
processedNpcsWithoutCollider.Add(((Object)val4).name);
}
}
}
}
private void FuckSkritOver()
{
((MonoBehaviour)this).StartCoroutine(CheckAndModifySkrit());
}
private IEnumerator CheckAndModifySkrit()
{
while (!skritProcessed)
{
yield return (object)new WaitForSeconds(1f);
if (!IsEasterEggEnabled())
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Easter egg is disabled in the config.");
skritProcessed = true;
break;
}
GameObject val = GameObject.Find("_npc_Skrit");
if (!((Object)(object)val != (Object)null))
{
continue;
}
NetNPC component = val.GetComponent<NetNPC>();
if ((Object)(object)component != (Object)null)
{
if (Random.Range(0f, 1f) < 0.1f)
{
string[] array = new string[5] { "Skrit <color=red>(Smelly Gambler)</color>", "Skrit <color=black>(Submissive Bitch)</color>", "Skrit <color=green>(Stinker Dinker)</color>", "Skrit <color=purple>(Toxic Stench)</color>", "Skirt <color=yellow>(Gambler)</color>" };
string text = array[Random.Range(0, array.Length)];
FieldInfo field = typeof(NetNPC).GetField("_npcName", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(component, text);
((BaseUnityPlugin)this).Logger.LogInfo((object)"YOU GOT THE EASTER EGG :O");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Changed poor Skrit's name to: " + text));
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Failed to access _npcName field via reflection.");
}
}
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"_npc_Skrit does not have a NetNPC component!");
}
skritProcessed = true;
}
}
}