using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("EatTheHaters")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EatTheHaters")]
[assembly: AssemblyTitle("EatTheHaters")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace PufferAIBlacklist
{
[BepInPlugin("com.nilaier.eatthehaters", "Eat The Haters", "1.0.0")]
public class PufferAIBlacklistMod : BaseUnityPlugin
{
private static HashSet<ulong>? blacklistedSteamIDs;
private ConfigEntry<string>? blacklistedSteamIDsConfig;
private static ConfigEntry<bool>? angerModeConfig;
private void Awake()
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
blacklistedSteamIDsConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "BlacklistedSteamIDs", "76561199228939460,76561198204803576", "A comma-separated list of blacklisted SteamIDs (SteamID64 format). You can look up SteamID64 values on websites like https://steamid.io/lookup");
angerModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AngerMode", false, "Enable this to make the PufferAI actively seek out blacklisted players instead of avoiding them.");
blacklistedSteamIDs = new HashSet<ulong>(from s in blacklistedSteamIDsConfig.Value.Split(',')
select ulong.Parse(s.Trim()));
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loaded {blacklistedSteamIDs.Count} blacklisted SteamIDs from config file.");
Harmony val = new Harmony("com.nilaier.eatthehaters");
val.PatchAll(typeof(PufferAIBlacklistMod));
}
[HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")]
[HarmonyPrefix]
private static bool PufferAI_OnCollideWithPlayer_Prefix(PufferAI __instance, Collider other)
{
PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
ulong playerSteamId = val.playerSteamId;
if (!blacklistedSteamIDs.Contains(playerSteamId))
{
return false;
}
}
return true;
}
[HarmonyPatch(typeof(PufferAI), "AvoidClosestPlayer")]
[HarmonyPrefix]
private static bool PufferAI_AvoidClosestPlayer_Prefix(PufferAI __instance)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (angerModeConfig.Value)
{
object? value = AccessTools.Field(((object)__instance).GetType(), "closestSeenPlayer").GetValue(__instance);
PlayerControllerB val = (PlayerControllerB)((value is PlayerControllerB) ? value : null);
if ((Object)(object)val != (Object)null)
{
ulong playerSteamId = val.playerSteamId;
if (blacklistedSteamIDs.Contains(playerSteamId))
{
((EnemyAI)__instance).targetNode = ((Component)val).transform;
((EnemyAI)__instance).SetDestinationToPosition(((Component)val).transform.position, false);
return false;
}
}
}
return true;
}
[HarmonyPatch(typeof(PufferAI), "DoAIInterval")]
[HarmonyPrefix]
private static bool PufferAI_DoAIInterval_Prefix(PufferAI __instance)
{
if (((EnemyAI)__instance).currentBehaviourStateIndex == 0)
{
PlayerControllerB val = ((EnemyAI)__instance).CheckLineOfSightForPlayer(45f, 20, -1);
if ((Object)(object)val != (Object)null)
{
ulong playerSteamId = val.playerSteamId;
if (blacklistedSteamIDs.Contains(playerSteamId))
{
return true;
}
return false;
}
}
return true;
}
}
}