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+f6faf96811a7147cd7af7204ae8bfb972e97704a")]
[assembly: AssemblyProduct("LemmeKissDaNPC")]
[assembly: AssemblyTitle("LemmeKissDaNPC")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.zcraftelite.lemmekissdanpc", "Lemme Kiss Da NPC", "1.3.0")]
public class LemmeKissDaNPC : BaseUnityPlugin
{
private HashSet<string> processedNpcsWithoutCollider = new HashSet<string>();
private bool skritProcessed;
private static ConfigEntry<bool> ConfigEnableEasterEgg;
private Dictionary<string, (bool hasMainColliderChecked, bool hasJumpOffColliderChecked, bool hasWeirdColliderChecked)> npcColliderStatus = new Dictionary<string, (bool, bool, bool)>();
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.3.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);
GameObject[] array = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val in array)
{
if (!((Object)val).name.StartsWith("_npc_"))
{
continue;
}
if (!npcColliderStatus.ContainsKey(((Object)val).name))
{
npcColliderStatus[((Object)val).name] = (false, false, false);
}
(bool, bool, bool) value = npcColliderStatus[((Object)val).name];
if (!value.Item1 && (Object)(object)val.GetComponent<CapsuleCollider>() == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("No CapsuleCollider found for " + ((Object)val).name + "."));
value.Item1 = true;
}
if (!value.Item2)
{
Transform val2 = val.transform.Find("_jumpOffCollider");
if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).GetComponent<CapsuleCollider>() == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("No _jumpOffCollider found for " + ((Object)val).name + "."));
value.Item2 = true;
}
}
if (!value.Item3)
{
Transform val3 = val.transform.Find("_collider");
if ((Object)(object)val3 == (Object)null || (Object)(object)((Component)val3).GetComponent<CapsuleCollider>() == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("No _collider found for " + ((Object)val).name + "."));
value.Item3 = true;
}
}
npcColliderStatus[((Object)val).name] = value;
}
}
}
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;
}
}
}