Refactor skill lookup logic and vote system, update language files
Refactored command handling to improve player and skill lookup logic, replaced some list operations with direct queries, and updated method signatures for clarity and null safety. The vote system was reworked to support more robust vote tracking, cooldowns, and localized chat messages. Language files were updated to add new vote-related translations. Various code style and nullability improvements were made throughout the plugin.
This commit is contained in:
parent
54b265d43d
commit
e33975fe8b
117 changed files with 1532 additions and 1674 deletions
|
|
@ -10,8 +10,8 @@ namespace jRandomSkills
|
|||
public class HolyHandGrenade : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.HolyHandGrenade;
|
||||
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static float damageRadiusMultiplier = Config.GetValue<float>(skillName, "damageRadiusMultiplier");
|
||||
private static readonly float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
|
||||
private static readonly float damageRadiusMultiplier = Config.GetValue<float>(skillName, "damageRadiusMultiplier");
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -24,7 +24,7 @@ namespace jRandomSkills
|
|||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!Instance.IsPlayerValid(player)) continue;
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName) continue;
|
||||
EnableSkill(player);
|
||||
}
|
||||
|
|
@ -42,13 +42,14 @@ namespace jRandomSkills
|
|||
Server.NextFrame(() =>
|
||||
{
|
||||
var hegrenade = @event.As<CHEGrenadeProjectile>();
|
||||
var playerPawn = hegrenade.Thrower.Value;
|
||||
if (hegrenade == null || !hegrenade.IsValid) return;
|
||||
|
||||
var playerPawn = hegrenade.Thrower.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid) return;
|
||||
|
||||
var player = Utilities.GetPlayers().FirstOrDefault(p => p.PlayerPawn.Index == playerPawn.Index);
|
||||
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo?.Skill != skillName)
|
||||
return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
hegrenade.Damage *= damageMultiplier;
|
||||
hegrenade.DmgRadius *= damageRadiusMultiplier;
|
||||
|
|
@ -61,15 +62,10 @@ namespace jRandomSkills
|
|||
SkillUtils.TryGiveWeapon(player, CsItem.HEGrenade);
|
||||
}
|
||||
|
||||
public class SkillConfig : Config.DefaultSkillInfo
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffdd00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float damageRadiusMultiplier = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
public float DamageMultiplier { get; set; }
|
||||
public float DamageRadiusMultiplier { get; set; }
|
||||
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffdd00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float damageRadiusMultiplier = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
|
||||
{
|
||||
DamageMultiplier = damageMultiplier;
|
||||
DamageRadiusMultiplier = damageRadiusMultiplier;
|
||||
}
|
||||
public float DamageMultiplier { get; set; } = damageMultiplier;
|
||||
public float DamageRadiusMultiplier { get; set; } = damageRadiusMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue