using System.Drawing;
using System.Net.Mail;
using System.Numerics;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Timers;
using CustomRounds.Attributes;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;

namespace CustomRounds.Rounds;

[CustomRound(Name = nameof(FindChickenRound))]
public class FindChickenRoundTwo(Plugin plugin) : ICustomRound
{
    private bool _chickenKilled;
    private CChicken? _selectedChicken;
    private CCSPlayerController? _attacker;
    private readonly List<CChicken> _chickens = [];

    private int[] _chickensKilled = new int[64];
    private int _ticks;

    private readonly List<Vector> _positions =
    [
        new Vector(-783.96674f, -1672.4244f, -172.81104f),
        new Vector(-120.90859f, -1658.7909f, -167.96875f),
        new Vector(-135.26318f, -2343.2f, -167.96875f),
        new Vector(-766.5136f, -2373.4072f, -176.22192f),
    ];

    private readonly Dictionary<CChicken, Timer?> _timers = [];

    public void Start()
    {
        _ticks = 0;

        SpawnChickens();

        plugin.RegisterListener<Listeners.OnTick>(OnTick);
        VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
    }

    private HookResult OnTakeDamage(DynamicHook hook)
    {
        var entityInstance = hook.GetParam<CEntityInstance>(0);
        var info = hook.GetParam<CTakeDamageInfo>(1);

        var attacker = info.Attacker.Value;

        var isInstanceChicken = entityInstance.DesignerName.Contains("chicken");
        var isAttackerPlayer = attacker?.DesignerName.Contains("player");

        if (isInstanceChicken && isAttackerPlayer == true)
        {
            var cChicken = entityInstance.As<CChicken>();

            if (cChicken == _selectedChicken)
            {
                var player = attacker?.As<CCSPlayerPawn>().OriginalController.Value;
                _attacker = player;
                _chickenKilled = true;
            }
        }

        return HookResult.Continue;
    }

    private void OnTick()
    {
        foreach (var player in Utilities.GetPlayers())
        {
            var playerPawn = player.PlayerPawn.Value;
            if (playerPawn is null) continue;

            string text;
            if (!_chickenKilled)
            {
                if (_selectedChicken?.IsValid == false) continue;

                var chickenPosition = _selectedChicken?.AbsOrigin ?? Vector.Zero;
                var distance = Vector3.Distance(chickenPosition.ToVector3(), playerPawn.AbsOrigin!.ToVector3());

                var distanceStr = chickenPosition == Vector.Zero
                    ? "NONE"
                    : $"{distance:000}";

                if (distance <= 500)
                {
                    text = "ты уже близко!";
                }
                else
                {
                    text =
                        $"Найди <font color='yellow'>золотую</font> курицу!<br><b><font color='red'>{distanceStr}</font> метров до курицы</b>";
                }
            }
            else
            {
                if (TimeSpan.FromSeconds(_ticks / 64f).Seconds >= 5)
                {
                    End();
                    Server.ExecuteCommand("mp_restartgame 1");
                    continue;
                }

                text = $"Игрок <font color='green'>{_attacker?.PlayerName}</font> убил курицу";

                _ticks++;
            }

            player.PrintToCenterHtml($"<font class='fontSize-m'>{text}</font>");
        }
    }

    private void SpawnChickens()
    {
        RemoveChickens();

        float minX = float.MaxValue, minY = float.MaxValue, minZ = float.MaxValue;
        float maxX = float.MinValue, maxY = float.MinValue, maxZ = float.MinValue;

        foreach (var pos in _positions)
        {
            if (pos.X < minX) minX = pos.X;
            if (pos.Y < minY) minY = pos.Y;
            if (pos.Z < minZ) minZ = pos.Z;
            if (pos.X > maxX) maxX = pos.X;
            if (pos.Y > maxY) maxY = pos.Y;
            if (pos.Z > maxZ) maxZ = pos.Z;
        }

        var random = new Random();

        for (var i = 0; i < 100; i++)
        {
            var chicken = Utilities.CreateEntityByName<CChicken>("chicken");
            if (chicken is null) return;

            chicken.CurrentActivity = ChickenActivity.IDLE;
            chicken.DesiredActivity = ChickenActivity.IDLE;
            chicken.DispatchSpawn();

            var randomX = (float)(random.NextDouble() * (maxX - minX) + minX);
            var randomY = (float)(random.NextDouble() * (maxY - minY) + minY);
            var randomZ = (float)(random.NextDouble() * (maxZ - minZ) + minZ);
            chicken.Teleport(new Vector(randomX, randomY, randomZ));

            chicken.CurrentActivity = ChickenActivity.IDLE;
            chicken.DesiredActivity = ChickenActivity.IDLE;

            _timers.Add(chicken, plugin.AddTimer(0.5f, () =>
            {
                if (!chicken.IsValid) return;

                chicken.CurrentActivity = ChickenActivity.IDLE;
                chicken.DesiredActivity = ChickenActivity.IDLE;
            }, TimerFlags.REPEAT | TimerFlags.STOP_ON_MAPCHANGE));

            _chickens.Add(chicken);
        }

        var selectedChicken = _chickens[random.Next(_chickens.Count)];

        selectedChicken.Render = Color.Gold;

        _selectedChicken = selectedChicken;
    }

    private void RemoveChickens()
    {
        foreach (var chicken in _chickens.Where(u => u.IsValid))
        {
            chicken.Remove();
        }
    }

    public void End()
    {
        _chickenKilled = false;
        _attacker = null;
        _selectedChicken = null;

        plugin.RemoveListener<Listeners.OnTick>(OnTick);
        VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Unhook(OnTakeDamage, HookMode.Pre);

        foreach (var (key, _) in _timers)
        {
            _timers[key]?.Kill();
            _timers[key] = null;

            if (key.IsValid)
            {
                key.Remove();
            }
        }
    }
}

мне нужно сделать так, вот по этому брифу 

2. ЧЕЛЛЕНДЖ “НАЙДИ СВОЮ ЦЫПОЧКУ”

Спавнится на карте 2 соперника, противоположных команд (Т и КТ), в руках револьверы (или авп, смотря с чего менее удобно стрелять, и с какого оружия больше риск задеть соседних куриц), включается таймер (02:00) перед ними толпа куриц (около 200сот),  среди них есть особые желтые курицы 

Их в толпе спавнятся по 10 штук каждые 20 секунд
 Каждая такая курица приносит 5 очков, если убиваешь любую другую, получаешь минус одно очко, так же минусуется если убиваешь нужную, но задеваются соседние
Игроки должны за выделенное время убить как можно больше этих желтых куриц, но так же они могут стрелять друг в друга, мешая собирать этих куриц, 
после убийства соперника, тот отправляется на респавн и ждет кд 5 секунд замороженным, пока противник продолжает набивать очки по золотым курицам.
Побеждает игрок с наибольшим количеством очков по окончанию таймера
(Убийство противника очков не приносит, но отправляет того на точку спавна, стоять замороженным 5 секунд)
количество очков должно быть либо на плашке как в предыдущем челлендже, либо писаться чатом 


вот я еще раунд делал, может посмотреть что-то из него

using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using CustomRounds.Attributes;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;

namespace CustomRounds.Rounds;

public class SavedValue<T>(T value)
{
    public T Value { get; set; } = value;
    private readonly T _savedValue = value;

    public void Reset()
    {
        Value = _savedValue;
    }

    public override string ToString()
    {
        return $"Value: {Value}, SavedValue: {_savedValue}";
    }
}

public class Data
{
    public int Kills { get; set; }
    public TimeSpan Time { get; set; }
}

[CustomRound(Name = nameof(ChickenRound))]
public class ChickenRound(Plugin plugin, Config<MainConfig> config) : ICustomRound
{
    private const int MaxChickens = 5;
    private const string MagicZoneModel = "models/props/de_mirage/roof_plank_a.vmdl";

    private readonly List<CChicken> _chickens = [];
    private readonly List<CParticleSystem> _particles = [];

    private readonly MemoryFunctionVoid<CBaseEntity, CBaseEntity, IntPtr, IntPtr> _setParent =
        new("48 85 F6 74 ? 48 8B 47 10 F6 40 31 02 75 ? 48 8B 46 10 F6 40 31 02 75 ? B8 ? ? ? ?");

    // private readonly Vector[] _positions =
    // [
    //     new Vector(-467.8291f, -1556.3018f, -39.96875f),
    //     new Vector(48.475086f, -1678.1808f, -167.96875f),
    //     new Vector(138.41733f, -1429.3252f, -175.96875f),
    //     new Vector(139.6984f, -1996.8335f, -167.96875f),
    //     new Vector(70.29725f, -1988.7999f, -167.96875f),
    //     new Vector(-719.18335f, -2424.963f, -169.53558f),
    //     new Vector(-803.7273f, -1891.9352f, -179.96875f),
    //     new Vector(-745.54913f, -1534.501f, -167.96875f),
    //     new Vector(-287.9016f, -1715.9772f, -167.96875f)
    // ];

    private readonly SavedValue<float> _spawnRate = new(2);
    private readonly SavedValue<float> _spawnInterval = new(5);
    private readonly SavedValue<int> _countdown = new(5);
    private readonly SavedValue<int> _currentChicken = new(0);
    private readonly SavedValue<int> _wave = new(0);
    private string _additionalText = string.Empty;

    private SavedValue<int> _remainingTimeInTicks = new(0);
    private readonly SavedValue<bool> _mathStart = new(false);

    private SavedConVar<bool> _friendlyFire = new("mp_friendlyfire");

    //private readonly List<CDynamicProp> _targetEntities = [];
    private CDynamicProp? _targetEntity;
    private Timer? _spawnTimer;
    private Timer? _countdownTimer;
    private Timer? _textClearTimer;
    private readonly List<Timer?> _gayTimer = [];

    private readonly Dictionary<CChicken, DateTime> _chickenLastJumpTime = new();

    private readonly Dictionary<CsTeam, Data> _teamsData = new()
    {
        [CsTeam.Terrorist] = new Data(),
        [CsTeam.CounterTerrorist] = new Data()
    };

    public void Start()
    {
        _friendlyFire.Set(true);
        
        foreach (var (key, value) in _teamsData)
        {
            _teamsData[key] = new Data();
        }

        _remainingTimeInTicks = new SavedValue<int>(config.Value.WaveSettings.RoundTimeSeconds * 64);

        Reset();
        RemoveChickens();
        VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);

        //var players = Utilities.GetPlayers();

        // foreach (var (player, spawnPoint) in players.Zip(_spawnPoints, (p, s) => (p, s)))
        // {
        //     var playerPawn = player.PlayerPawn.Value;
        //     if (playerPawn is null) continue;
        //
        //     playerPawn.Teleport(spawnPoint);
        // }

        plugin.RegisterEvent<EventRoundFreezeEnd>(EventRoundFreezeEnd);
        plugin.RegisterEventHandler<EventItemPickup>(EventItemPickup);
        plugin.RegisterListener<Listeners.OnTick>(OnTick);
    }

    private HookResult EventItemPickup(EventItemPickup @event, GameEventInfo info)
    {
        var player = @event.Userid;
        if (player is null) return HookResult.Continue;

        var weapon = config.Value.Weapon;
        if (!weapon.Contains(@event.Item)) return HookResult.Continue;

        var playerWeapons = player.PlayerPawn.Value?.WeaponServices?.MyWeapons;
        if (playerWeapons is null) return HookResult.Continue;

        foreach (var playerWeapon in playerWeapons)
        {
            var baseWeapon = playerWeapon.Value;
            if (baseWeapon is null || !baseWeapon.IsValid || !baseWeapon.DesignerName.Contains(weapon)) continue;

            baseWeapon.ReserveAmmo[0] = 0;

            var csWeapon = baseWeapon.As<CCSWeaponBase>();
            csWeapon.ReserveAmmo[0] = 0;
        }

        return HookResult.Continue;
    }

    private void OnTick()
    {
        if (!_mathStart.Value) return;

        var time = TimeSpan.FromSeconds(_remainingTimeInTicks.Value / 64f);

        foreach (var player in Utilities.GetPlayers())
        {
            player.PrintToCenterHtml(
                $"<font class='fontSize-m'>Оставшееся время: <font color='red'>{time.Minutes:D2}:{time.Seconds:D2}</font>{(!string.IsNullOrEmpty(_additionalText) ? $"<br>{_additionalText}</font>" : string.Empty)}");

            if (player is { IsValid: true })
            {
                if (player.PawnIsAlive)
                {
                    var kills = "none";
                    if (_teamsData.TryGetValue(player.Team, out var data))
                        kills = $"{data.Kills}";

                    player.PrintToCenter($"Убито куриц: {kills}");
                }
                else
                {
                    var observerServices = player.ObserverPawn.Value?.ObserverServices;
                    if (observerServices != null &&
                        observerServices.ObserverMode != (int)ObserverMode_t.OBS_MODE_NONE &&
                        observerServices.ObserverMode is (int)ObserverMode_t.OBS_MODE_IN_EYE
                            or (int)ObserverMode_t.OBS_MODE_CHASE)
                    {
                        var handle = observerServices.ObserverTarget.Value?.Handle;
                        if (handle is null) continue;

                        var baseController = new CCSPlayerPawn(handle.Value).Controller.Value?.Handle;
                        if (baseController is null) continue;

                        var target = new CCSPlayerController(baseController.Value);
                        if (target is { IsValid: true, PawnIsAlive: true })
                        {
                            var kills = "none";
                            if (_teamsData.TryGetValue(target.Team, out var data))
                                kills = $"{data.Kills}";

                            player.PrintToCenter($"Игрок {target.PlayerName}\nУбито куриц: {kills}");
                        }
                    }
                }
            }
        }

        _remainingTimeInTicks.Value--;

        if (_remainingTimeInTicks.Value <= 0)
        {
            End();
        }
    }

    private void SetAdditionalText(string text)
    {
        _additionalText = text;

        _textClearTimer?.Kill();
        _textClearTimer = plugin.AddTimer(5, () => _additionalText = string.Empty);
    }

    private HookResult EventRoundFreezeEnd(EventRoundFreezeEnd @event, GameEventInfo info)
    {
        _countdownTimer?.Kill();
        _countdownTimer = plugin.AddTimer(1, () =>
        {
            if (_countdown.Value <= 5)
            {
                foreach (var player in Utilities.GetPlayers())
                {
                    player.PrintToCenter($"{_countdown.Value}");
                }
            }

            if (_countdown.Value <= 0)
            {
                var weaponName = config.Value.Weapon;
                _mathStart.Value = true;

                var players = Utilities.GetPlayers().Where(u => u.IsValid && u.PawnIsAlive).ToList();
                foreach (var player in players)
                {
                    player.RemoveWeapons();

                    player.GiveNamedItem(CsItem.Knife);
                    var weapon = player.GiveNamedItem<CCSWeaponBase>(weaponName);

                    if (weapon is null) continue;

                    weapon.ReserveAmmo[0] = 0;
                }

                var targetEntity = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
                if (targetEntity is not null)
                {
                    targetEntity.TakesDamage = false;
                    targetEntity.DispatchSpawn();
                    targetEntity.Teleport(new Vector(-389.2817f, -1998.5457f, -178.95122f));
                    targetEntity.RenderMode = RenderMode_t.kRenderNone;
                }

                _targetEntity = targetEntity;

                Server.PrintToChatAll($"[{ChatColors.Blue}CustomRounds\x01] CHICKEN ROUND");

                SpawnWeaponsOnGround(players.First(), weaponName);
                Callback();
                _countdownTimer?.Kill();
            }

            _countdown.Value--;
        }, TimerFlags.REPEAT | TimerFlags.STOP_ON_MAPCHANGE);
        return HookResult.Continue;
    }

    private void SpawnWeaponsOnGround(CCSPlayerController player, string weapon)
    {
        if (!player.IsValid) return;

        var weaponService = player.PlayerPawn.Value?.WeaponServices;
        if (weaponService is null) return;

        weaponService.PreventWeaponPickup = true;
        foreach (var spawn in config.Value.ParsedWeaponSpawns)
        {
            var weaponBase = player.GiveNamedItem<CCSWeaponBase>(weapon);

            weaponBase?.Teleport(spawn);

            if (weaponBase is null) continue;
            weaponBase.ReserveAmmo[0] = 0;
        }

        weaponService.PreventWeaponPickup = false;
    }

    private void RemoveChickens()
    {
        foreach (var entityInstance in Utilities.GetAllEntities()
                     .Where(e => e.DesignerName.Contains("chicken") && e.IsValid))
        {
            entityInstance.Remove();
        }
    }

    private HookResult OnTakeDamage(DynamicHook hook)
    {
        var entityInstance = hook.GetParam<CEntityInstance>(0);
        var info = hook.GetParam<CTakeDamageInfo>(1);

        var attacker = info.Attacker.Value;

        var isInstanceChicken = entityInstance.DesignerName.Contains("chicken");
        var isAttackerPlayer = attacker?.DesignerName.Contains("player");
        var isAttackerChicken = attacker?.DesignerName.Contains("chicken");

        if (isInstanceChicken && isAttackerPlayer == true)
        {
            var cChicken = entityInstance.As<CChicken>();
            CreateParticle(cChicken);
            Explode(cChicken);

            //var targetEntity = _targetEntities.MinBy(e => Vector3.Distance(e!.AbsOrigin!.ToVector3(), cChicken.AbsOrigin!.ToVector3()));

            ChangeChickenLeader(cChicken, _targetEntity?.EntityHandle.Raw ?? 1302);

            var player = attacker?.As<CCSPlayerPawn>().OriginalController.Value;
            if (player != null && _teamsData.TryGetValue(player.Team, out var data))
            {
                data.Kills++;
            }

            return HookResult.Continue;
        }

        if (isInstanceChicken && attacker?.DesignerName.Contains("env_explosion") == true ||
            isInstanceChicken && isAttackerChicken == true)
        {
            info.Damage = 0;
            return HookResult.Changed;
        }

        return HookResult.Continue;
    }

    private void CreateParticle(CBaseEntity chicken)
    {
        if (!chicken.IsValid) return;
        var particle = Utilities.CreateEntityByName<CParticleSystem>("info_particle_system");
        if (particle is null) return;

        particle.EffectName = Plugin.ExplosionHeGrenade;
        particle.DispatchSpawn();
        particle.Teleport(chicken.AbsOrigin);

        Server.NextFrame(() => particle.AcceptInput("Start"));

        _particles.Add(particle);
    }

    private void Callback()
    {
        var waveSettings = config.Value.WaveSettings;
        var value = _wave.Value;
        if (value >= waveSettings.ChickenCounts.Count)
            return;

        var chickensToSpawn = waveSettings.ChickenCounts[value];
        var distribution = DistributeChickens(chickensToSpawn, config.Value.ParsedChickenSpawns.Count);

        SetAdditionalText(
            $"Волна <font color='#228B22'>{value + 1}</font>: Спавнится <font color='#800080'>{chickensToSpawn}</font> куриц");

        for (int i = 0; i < distribution.Count; i++)
        {
            for (int j = 0; j < distribution[i]; j++)
            {
                var position = config.Value.ParsedChickenSpawns[i];

                position.X += Random.Shared.NextSingle() * 60 - 30;
                position.Y += Random.Shared.NextSingle() * 60 - 30;
                
                CreateChickenAtPosition(position);
            }
        }

        _wave.Value++;
        _spawnTimer = plugin.AddTimer(waveSettings.IntervalSeconds, Callback);
    }
    
    private List<int> DistributeChickens(int totalChickens, int numberOfSpawns)
    {
        var chickensPerSpawn = new List<int>(new int[numberOfSpawns]);
        var remainingChickens = totalChickens;

        for (var i = 0; i < totalChickens; i++)
        {
            chickensPerSpawn[i % numberOfSpawns]++;
        }

        return chickensPerSpawn;
    }

    private void CreateChickenAtPosition(Vector position)
    {
        var chicken = Utilities.CreateEntityByName<CChicken>("chicken");
        if (chicken is null) return;

        // var targetEntity = _targetEntities.MinBy(e => Vector3.Distance(e!.AbsOrigin!.ToVector3(), position.ToVector3()));
        var raw = _targetEntity?.EntityHandle.Raw;
        if (raw is null) return;

        ChangeChickenLeader(chicken, raw.Value);
        chicken.DispatchSpawn();

        chicken.Teleport(position);
        ChangeChickenLeader(chicken, raw.Value);

        foreach (var chickenThinkFunction in chicken.ThinkFunctions)
        {
            chickenThinkFunction.NextThinkTick = Server.TickCount + 1;
        }

        chicken.CurrentActivity = ChickenActivity.RUN;
        chicken.DesiredActivity = ChickenActivity.RUN;
        chicken.ActiveFollowStartTime = Server.CurrentTime;
        chicken.TurnRate = 0;
        chicken.NextThinkTick = Server.TickCount + 1;

        var timer = plugin.AddTimer(0.5f, () => TimerChickenCallback(chicken, _targetEntity),
            TimerFlags.REPEAT | TimerFlags.STOP_ON_MAPCHANGE);

        _gayTimer.Add(timer);

        _currentChicken.Value++;
        _chickens.Add(chicken);
        _chickenLastJumpTime[chicken] = DateTime.UtcNow;
    }

    private void TimerChickenCallback(CChicken chicken, CDynamicProp? targetEntity)
    {
        if (!chicken.IsValid || targetEntity?.IsValid == false) return;

        var players = Utilities.GetPlayers().Where(u => u is { PawnIsAlive: true, IsValid: true });

        var nearestPlayer = players
            .Select(u => new
            {
                Player = u,
                Distance = Vector3.Distance(chicken.AbsOrigin!.ToVector3(),
                    u.PlayerPawn.Value.AbsOrigin!.ToVector3())
            })
            .OrderBy(u => u.Distance)
            .FirstOrDefault();

        if (nearestPlayer != null)
        {
            if (nearestPlayer.Distance < 70)
            {
                Explode(chicken);
            }
            else if (nearestPlayer.Distance < 170)
            {
                JumpAtPlayer(chicken, nearestPlayer.Player);
            }
            else if (nearestPlayer.Distance < 500)
            {
                ChangeChickenLeader(chicken, nearestPlayer.Player.PlayerPawn.Raw);
            }
        }
    }

    private void ChangeChickenLeader(CChicken chicken, uint raw)
    {
        chicken.Leader.Raw = raw;
        Utilities.SetStateChanged(chicken, "CChicken", "m_leader");
    }

    private void JumpAtPlayer(CChicken chicken, CCSPlayerController player)
    {
        if (_chickenLastJumpTime.TryGetValue(chicken, out var time) &&
            DateTime.UtcNow - time < TimeSpan.FromSeconds(2))
            return;

        _chickenLastJumpTime[chicken] = DateTime.UtcNow;

        var direction =
            Vector3.Normalize(player.PlayerPawn.Value!.AbsOrigin!.ToVector3() - chicken.AbsOrigin!.ToVector3());

        const float jumpSpeed = 150.0f;

        var jumpVelocity = new Vector(direction.X * jumpSpeed, direction.Y * jumpSpeed, 300.0f);

        jumpVelocity.X += Random.Shared.NextSingle() * 20 - 10;
        jumpVelocity.Y += Random.Shared.NextSingle() * 20 - 10;

        chicken.Teleport(new Vector(chicken.AbsOrigin.X, chicken.AbsOrigin.Y, chicken.AbsOrigin.Z + 20),
            velocity: jumpVelocity);
    }

    private void Explode(CBaseEntity entity)
    {
        var explosion = Utilities.CreateEntityByName<CEnvExplosion>("env_explosion");
        if (explosion is null || !explosion.IsValid)
            return;

        explosion.RadiusOverride = 150;
        explosion.Magnitude = 50;
        explosion.PlayerDamage = 25;
        explosion.DamageForce = 25;
        explosion.DispatchSpawn();

        explosion.Teleport(entity.AbsOrigin);
        Server.NextFrame(() => { explosion.AcceptInput("Explode"); });

        CreateParticle(entity);
        entity.Remove();
    }

    private void Reset()
    {
        _mathStart.Reset();
        _currentChicken.Reset();
        _spawnInterval.Reset();
        _spawnRate.Reset();
        _countdown.Reset();
        _wave.Reset();
        _remainingTimeInTicks.Reset();

        _countdownTimer?.Kill();
        _countdownTimer = null;

        _spawnTimer?.Kill();
        _spawnTimer = null;

        foreach (var timer in _gayTimer)
        {
            timer?.Kill();
        }

        if (_targetEntity?.IsValid == true)
        {
            _targetEntity?.Remove();
        }
        // foreach (var cDynamicProp in _targetEntities.Where(e => e.IsValid))
        // {
        //     cDynamicProp.Remove();
        // }

        foreach (var chicken in _chickens.Where(cChicken => cChicken.IsValid))
        {
            chicken.Remove();
        }

        foreach (var particleSystem in _particles.Where(p => p.IsValid))
        {
            particleSystem.Remove();
        }
    }

    public void End()
    {
        Reset();
        plugin.RemoveListener<Listeners.OnTick>(OnTick);
        plugin.DeregisterEventHandler<EventItemPickup>(EventItemPickup);
        VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Unhook(OnTakeDamage, HookMode.Pre);

        //PrintResult();
    }

    // private void PrintResult()
    // {
    //     foreach (var (key, value) in _teams)
    //     {
    //         Server.PrintToChatAll($"{ChatColors.ForTeam(key)}Информация команды {key}");
    //         Server.PrintToChatAll($"Убийств: {ChatColors.Red}{value.Kills}, Время: {ChatColors.Green}{value.Time}");
    //         
    //         _teams[key] = new Data();
    //     }
    // }
}

public static class VectorUtils
{
    public static Vector ToVector(this Vector3 v)
    {
        return new Vector(v.X, v.Y, 0);
    }

    public static Vector3 ToVector3(this Vector v)
    {
        return new Vector3(v.X, v.Y, 0);
    }
}