This commit is contained in:
Juzlus 2025-09-23 04:53:25 +02:00
parent a36fdbf92d
commit 04a4fdce0d
143 changed files with 3565 additions and 2344 deletions

View file

@ -4,18 +4,18 @@ using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
using System.Collections.Concurrent;
namespace jRandomSkills
{
public class Magnifier : ISkill
{
private const Skills skillName = Skills.Magnifier;
private static readonly uint customFOV = Config.GetValue<uint>(skillName, "customFOV");
private static readonly Dictionary<CCSPlayerController, uint> playersFOV = [];
private static readonly ConcurrentDictionary<CCSPlayerController, uint> playersFOV = [];
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
}
public static void NewRound()
@ -45,7 +45,7 @@ namespace jRandomSkills
if (playerInfo == null || playerInfo.Skill != skillName) continue;
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
HashSet<(string, string)> menuItems = enemies.Select(e => (e.PlayerName, e.Index.ToString())).ToHashSet();
ConcurrentBag<(string, string)> menuItems = new(enemies.Select(e => (e.PlayerName, e.Index.ToString())));
SkillUtils.UpdateMenu(player, menuItems);
}
}
@ -72,8 +72,8 @@ namespace jRandomSkills
}
if (!playersFOV.ContainsKey(enemy))
playersFOV.Add(enemy, enemy.DesiredFOV);
enemy.DesiredFOV = customFOV;
playersFOV.TryAdd(enemy, enemy.DesiredFOV);
enemy.DesiredFOV = SkillsInfo.GetValue<uint>(skillName, "customFOV");
Utilities.SetStateChanged(enemy, "CBasePlayerController", "m_iDesiredFOV");
playerInfo.SkillChance = 1;
@ -90,7 +90,7 @@ namespace jRandomSkills
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
if (enemies.Length > 0)
{
HashSet<(string, string)> menuItems = enemies.Select(e => (e.PlayerName, e.Index.ToString())).ToHashSet();
ConcurrentBag<(string, string)> menuItems = new(enemies.Select(e => (e.PlayerName, e.Index.ToString())));
SkillUtils.CreateMenu(player, menuItems);
}
else
@ -104,11 +104,11 @@ namespace jRandomSkills
player.DesiredFOV = fov;
Utilities.SetStateChanged(player, "CBasePlayerController", "m_iDesiredFOV");
}
playersFOV.Remove(player);
playersFOV.TryRemove(player, out _);
SkillUtils.CloseMenu(player);
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#9ba882", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, uint customFOV = 50) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#9ba882", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, uint customFOV = 50) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates)
{
public uint CustomFOV { get; set; } = customFOV;
}