diff --git a/mod/TTT.Roles/Helper/ColorManager.cs b/mod/TTT.Roles/Helper/ColorManager.cs new file mode 100644 index 0000000..ae4ece0 --- /dev/null +++ b/mod/TTT.Roles/Helper/ColorManager.cs @@ -0,0 +1,6 @@ +namespace TTT.Roles; + +public class ColorManager +{ + +} \ No newline at end of file diff --git a/mod/TTT.Roles/RoleManager.cs b/mod/TTT.Roles/RoleManager.cs index 4d88498..0f97c55 100644 --- a/mod/TTT.Roles/RoleManager.cs +++ b/mod/TTT.Roles/RoleManager.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System.Collections; +using System.Drawing; using System.Runtime.InteropServices; using System.Text.Json.Serialization; using CounterStrikeSharp.API; @@ -29,6 +30,8 @@ public class RoleManager : PlayerHandler, IRoleService, IPluginBehavior private int _traitorsLeft; private InfoManager _infoManager; private MuteManager _muteManager; + + private List _glowingEntities = []; public void Start(BasePlugin parent) { @@ -46,6 +49,8 @@ public void Start(BasePlugin parent) parent.RegisterEventHandler(OnPlayerDeath, HookMode.Pre); parent.RegisterEventHandler(OnMapStart); parent.RegisterEventHandler(Event_PlayerSpawn, HookMode.Post); + + parent.RegisterListener(RegisterSetColor); VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(hook => { @@ -171,6 +176,7 @@ private HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) Server.NextFrame(Clear); _muteManager.UnMuteAll(); + RemoveGlow(); return HookResult.Continue; } @@ -240,6 +246,32 @@ public Role GetRole(CCSPlayerController player) return GetPlayer(player).PlayerRole(); } + private void RemoveGlow() + { + foreach (var glowEnt in _glowingEntities) + { + glowEnt.Remove(); + } + _glowingEntities.Clear(); + } + + private void RegisterSetColor(CCheckTransmitInfoList infoList) + { + foreach (var (info, player) in infoList) + { + if (player == null) + continue; + + if (IsTraitor(player)) + continue; + + foreach (var model in _glowingEntities) + { + info.TransmitEntities.Remove(model); + } + } + } + public void AddTraitor(CCSPlayerController player) { GetPlayer(player).SetPlayerRole(Role.Traitor); @@ -465,6 +497,39 @@ private void PlayerSpawnNextFrame(CCSPlayerController player, CHandle("prop_dynamic"); + CBaseModelEntity? modelRelay = Utilities.CreateEntityByName("prop_dynamic"); + if (modelGlow == null || modelRelay == null) + { + return; + } + + string modelName = pawn.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName; + + modelRelay.SetModel(modelName); + modelRelay.Spawnflags = 256u; + modelRelay.RenderMode = RenderMode_t.kRenderNone; + modelRelay.DispatchSpawn(); + + modelGlow.SetModel(modelName); + modelGlow.Spawnflags = 256u; + modelGlow.DispatchSpawn(); + + modelGlow.Glow.GlowColorOverride = Color.Red; + modelGlow.Glow.GlowRange = 5000; + modelGlow.Glow.GlowTeam = -1; + modelGlow.Glow.GlowType = 3; + modelGlow.Glow.GlowRangeMin = 100; + + modelRelay.AcceptInput("FollowEntity", pawn, modelRelay, "!activator"); + modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator"); + + _glowingEntities.Add(modelGlow); + _glowingEntities.Add(modelRelay); + } } diff --git a/public/TTT.Public/TTT.Public.csproj b/public/TTT.Public/TTT.Public.csproj index 7d965c2..6f87a68 100644 --- a/public/TTT.Public/TTT.Public.csproj +++ b/public/TTT.Public/TTT.Public.csproj @@ -5,7 +5,7 @@ enable - +