using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AK;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using GTFO.API;
using Gear;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ManifestInfo
{
internal const string TSName = "BiotrackerExplode";
internal const string TSDescription = "Causes the biotracker to maybe explode. Make sure your biotracking is on point!";
internal const string TSVersion = "1.0.0";
internal const string TSAuthor = "Giginss";
internal const string TSWebsite = "https://github.com/GreatWyrm/BiotrackerExplodes";
}
namespace BiotrackerExplode
{
[HarmonyPatch]
public class BiotrackerPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EnemyScanner), "UpdateTagProgress")]
public static void Postfix(EnemyScanner __instance, int maxTags)
{
if (__instance.m_lastTagging && !__instance.m_tagging && !__instance.m_lastRecharging && __instance.m_recharging)
{
Plugin.EvaluatePings(__instance.m_taggableEnemies);
}
}
}
public class Networking
{
private static CellSoundPlayer soundPlayer;
private static readonly string NetworkEvent = "BiotrackerExplode";
public static void Init()
{
NetworkAPI.RegisterEvent<Vector3>(NetworkEvent, (Action<ulong, Vector3>)OnExplosionReceive);
LevelAPI.OnEnterLevel += SetupCellSound;
}
public static void SetupCellSound()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if (soundPlayer == null)
{
soundPlayer = new CellSoundPlayer();
}
}
public static void BroadcastAndPlayToSelf(Vector3 position)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
NetworkAPI.InvokeEvent<Vector3>(NetworkEvent, position, (SNet_ChannelType)2);
soundPlayer.Post(EVENTS.STICKYMINEEXPLODE, position);
}
public static void OnExplosionReceive(ulong id, Vector3 position)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
soundPlayer.Post(EVENTS.STICKYMINEEXPLODE, position);
}
}
[BepInPlugin("dev.Giginss.gtfo.BiotrackerExplode", "BiotrackerExplode", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string GUID = "dev.Giginss.gtfo.BiotrackerExplode";
public const string MOD_NAME = "BiotrackerExplode";
public const string VERSION = "1.0.0";
internal static ManualLogSource L;
private static readonly Harmony _harmony = new Harmony("dev.Giginss.gtfo.BiotrackerExplode");
private static ConfigEntry<double> explodeChance;
private static ConfigEntry<int> explodeThreshold;
private static ConfigEntry<bool> includeScouts;
private static ConfigEntry<bool> willExplodeSelf;
private static Random _random = new Random();
public override void Load()
{
L = ((BasePlugin)this).Log;
explodeChance = ((BasePlugin)this).Config.Bind<double>("Exploding Biotracker", "ExplosionChance", 0.05, "The chance for the biotracker to explode when you don't get above the threshold");
explodeThreshold = ((BasePlugin)this).Config.Bind<int>("Exploding Biotracker", "ExplosionThreshold", 1, "The amount of enemies to be equal to or below for the chance to explode to be rolled");
includeScouts = ((BasePlugin)this).Config.Bind<bool>("Exploding Biotracker", "IncludeScouts", false, "Whether or not to include scouts when tallying the amount of enemies that were pinged.");
willExplodeSelf = ((BasePlugin)this).Config.Bind<bool>("Exploding Biotracker", "IsLethal", true, "Whether or not exploding will kill the player using the biotracker");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Networking.Init();
L.LogInfo((object)"Exploding biotracker loaded!");
}
public static void EvaluatePings(List<EnemyAgent> enemies)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
L.LogInfo((object)"Evaluating biotracker pings");
int num = enemies.Count;
if (!includeScouts.Value)
{
int num2 = 0;
for (int i = 0; i < enemies.Count; i++)
{
if (enemies[i].IsScout)
{
num2++;
}
}
num -= num2;
}
if (num <= 0 || num > explodeThreshold.Value)
{
return;
}
L.LogInfo((object)"Below threshold!");
if (!(_random.NextDouble() < explodeChance.Value))
{
return;
}
L.LogInfo((object)"Rolled chance, exploding!");
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
if (!((Object)(object)localPlayerAgent == (Object)null))
{
Networking.BroadcastAndPlayToSelf(((Agent)localPlayerAgent).m_position);
if (willExplodeSelf.Value)
{
localPlayerAgent.Damage.OnIncomingDamage(((Dam_SyncedDamageBase)localPlayerAgent.Damage).Health + 1f, ((Dam_SyncedDamageBase)localPlayerAgent.Damage).Health + 1f, (Agent)null);
}
}
}
}
}