v1.2.3.b7
## Shared Systems * **DecoyTracker** - owner-aware decoy tracking shared by FrozenDecoy, GravityDecoy and MagneticDecoy, replacing the per-skill position dictionaries. * **DebugCategory** - new flag enum backing the numeric `DebugMode`, with automatic migration from the old boolean value. * **SkillsInfo.GetSkillConfig** - indexed skill config lookup replacing the linear scan used by draws and HUD rendering. * **SkillNames** - cached enum name table, removing repeated `ToString()` calls from the draw path. * **SkillUtils.HideCarriedEntities** - shared carried-weapon resolution for C4Camouflage, Ghost and Ninja. ## Performance * **Skill draw** - replaced the O(n²) config lookup; rounds exceeding the perf threshold dropped from 89% to 0.3%. * **CheckTransmit** - the weapon chain is now resolved once per hidden pawn instead of once per receiver; Ghost cost down 61%. * **Pilot** - the exhaust trail is paused and resumed instead of being destroyed and recreated on every jump release. * **MagneticDecoy** - config reads and the pawn list are hoisted out of the per-decoy loop. * **FrozenDecoy** - config reads are hoisted out of the per-tick loop. * **Debug** - the damage hook is only installed when damage logging is enabled. ## Fixes * **PsychicDefusing** - can no longer finish a defuse and award an extra round after the round has already ended. * **Spectator** - now picks a different enemy on each activation and no longer creates an unused camera prop every time the skill is switched off. * **Random** - replaced the shared `Random` instance with `Random.Shared`, preventing degenerate results from concurrent use. * **Baseball** - decoys are removed when their owner dies or loses the skill. * **FrozenDecoy, GravityDecoy, MagneticDecoy** - decoys and their ground rings are removed when the skill is taken away. * **ThirdEye** - fixed the camera check dereferencing a missing `CameraServices`, and the door toggle now verifies the entity class before casting. * **Round start** - fixed `[gamerules unavailable]` appearing on the first freeze-time end after every map change. * **Config** - added migration for keys missing from existing configuration files. ## Menu * **WASDMenuAPI** - fixed a malformed `<font>` tag that wrapped every non-hovered menu row in an unclosed attribute. * **WSAD menu** - the controls line is no longer dropped when the header line is hidden. * **HtmlHudCustomisation** - line size options left empty now hide their line instead of emitting an invalid font class. ## Debug * **DebugMode** - changed from a boolean to a number with concatenated category digits: `1` Skill, `2` Round, `3` Entity, `4` Damage. `123` enables Skill, Round and Entity. `0` disables logging. Existing `true` values migrate automatically. * **EntityManager** - entity creation, destruction and failures are now logged under the Entity category instead of the server console. * Startup now reports which debug categories are active.
This commit is contained in:
parent
5c65f4ac71
commit
0033d1e13d
29 changed files with 634 additions and 251 deletions
|
|
@ -10,7 +10,6 @@ namespace src.player.skills
|
|||
public class MagneticDecoy : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.MagneticDecoy;
|
||||
private static readonly ConcurrentDictionary<Vector, byte> decoys = [];
|
||||
private readonly static ConcurrentDictionary<uint, int> playersWithSkill = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
|
|
@ -21,14 +20,12 @@ namespace src.player.skills
|
|||
|
||||
public static void NewRound()
|
||||
{
|
||||
decoys.Clear();
|
||||
DecoyRing.ClearAll(skillName);
|
||||
DecoyTracker.Clear(skillName);
|
||||
}
|
||||
|
||||
public static void RoundEnd()
|
||||
{
|
||||
decoys.Clear();
|
||||
DecoyRing.ClearAll(skillName);
|
||||
DecoyTracker.Clear(skillName);
|
||||
}
|
||||
|
||||
public static void DecoyStarted(EventDecoyStarted @event)
|
||||
|
|
@ -40,50 +37,58 @@ namespace src.player.skills
|
|||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
Vector pos = new(@event.X, @event.Y, @event.Z);
|
||||
decoys.TryAdd(pos, 0);
|
||||
DecoyTracker.Add(skillName, (uint)@event.Entityid, pos, player.Index);
|
||||
DecoyRing.Show(skillName, (uint)@event.Entityid, pos, SkillsInfo.GetValue<float>(skillName, "triggerRadius"));
|
||||
}
|
||||
|
||||
public static void DecoyDetonate(EventDecoyDetonate @event)
|
||||
{
|
||||
var player = PlayerManager.GetPlayerEvent(@event.Userid);
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
|
||||
foreach (var decoy in decoys.Keys.Where(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z))
|
||||
decoys.TryRemove(decoy, out _);
|
||||
|
||||
DecoyRing.Hide(skillName, (uint)@event.Entityid);
|
||||
DecoyTracker.Remove(skillName, (uint)@event.Entityid);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
foreach (Vector decoyPos in decoys.Keys)
|
||||
foreach (var player in PlayerManager.GetTickPlayers().Where(p => p.IsValid && p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist))
|
||||
var decoyPositions = DecoyTracker.Positions(skillName);
|
||||
if (decoyPositions.Length == 0) return;
|
||||
|
||||
float decoyRadius = SkillsInfo.GetValue<float>(skillName, "triggerRadius");
|
||||
float baseStrenght = SkillsInfo.GetValue<float>(skillName, "strenght");
|
||||
|
||||
List<CCSPlayerPawn> pawns = [];
|
||||
foreach (var player in PlayerManager.GetTickPlayers())
|
||||
{
|
||||
if (player == null || !player.IsValid) continue;
|
||||
if (player.Team is not (CsTeam.CounterTerrorist or CsTeam.Terrorist)) continue;
|
||||
|
||||
var eventPlayer = PlayerManager.GetPlayerEvent(player);
|
||||
if (eventPlayer == null || !eventPlayer.IsValid) continue;
|
||||
|
||||
var pawn = eventPlayer.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) continue;
|
||||
|
||||
pawns.Add(pawn);
|
||||
}
|
||||
|
||||
if (pawns.Count == 0) return;
|
||||
|
||||
foreach (Vector decoyPos in decoyPositions)
|
||||
foreach (var pawn in pawns)
|
||||
{
|
||||
var eventPlayer = PlayerManager.GetPlayerEvent(player);
|
||||
if (eventPlayer == null || !eventPlayer.IsValid) continue;
|
||||
var origin = pawn.AbsOrigin;
|
||||
if (origin == null) continue;
|
||||
|
||||
var decoyRadius = SkillsInfo.GetValue<float>(skillName, "triggerRadius");
|
||||
double distance = SkillUtils.GetDistance(decoyPos, origin);
|
||||
if (distance > decoyRadius || distance <= 10) continue;
|
||||
|
||||
var pawn = eventPlayer.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) continue;
|
||||
Vector direction = new(decoyPos.X - origin.X, decoyPos.Y - origin.Y, 0);
|
||||
float length = direction.Length();
|
||||
if (length <= 0) continue;
|
||||
|
||||
double distance = SkillUtils.GetDistance(decoyPos, pawn.AbsOrigin);
|
||||
if (distance <= decoyRadius && distance > 10)
|
||||
{
|
||||
Vector direction = new(decoyPos.X - pawn.AbsOrigin.X, decoyPos.Y - pawn.AbsOrigin.Y, 0);
|
||||
float length = direction.Length();
|
||||
Vector normalized = direction / length;
|
||||
float strenght = baseStrenght * (1 - (float)(distance / decoyRadius));
|
||||
|
||||
Vector normalized = direction / length;
|
||||
float ratio = 1 - (float)(distance / decoyRadius);
|
||||
float strenght = SkillsInfo.GetValue<float>(skillName, "strenght") * ratio;
|
||||
|
||||
pawn.AbsVelocity.X += normalized.X * strenght;
|
||||
pawn.AbsVelocity.Y += normalized.Y * strenght;
|
||||
}
|
||||
pawn.AbsVelocity.X += normalized.X * strenght;
|
||||
pawn.AbsVelocity.Y += normalized.Y * strenght;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +149,12 @@ namespace src.player.skills
|
|||
if (player == null || !player.IsValid) return;
|
||||
|
||||
playersWithSkill.TryRemove(player.Index, out _);
|
||||
DecoyTracker.RemoveOwner(skillName, player.Index);
|
||||
|
||||
var eventPlayer = PlayerManager.GetPlayerEvent(player);
|
||||
if (eventPlayer != null && eventPlayer.IsValid && eventPlayer.Index != player.Index)
|
||||
DecoyTracker.RemoveOwner(skillName, eventPlayer.Index);
|
||||
|
||||
SkillUtils.UpdateGrenadeCount(player, CsItem.DecoyGrenade, 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue