From 19a634c1954669c31c65dc3402bad24970c4f5fb Mon Sep 17 00:00:00 2001 From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Date: Sat, 3 Aug 2024 20:34:33 -0700 Subject: [PATCH] Make pointing cooldown a cvar (#30623) * Make pointing cooldown a cvar * Remove empty line --- Content.Server/Pointing/EntitySystems/PointingSystem.cs | 9 +++++++-- Content.Shared/CCVar/CCVars.cs | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index f2f60f3063ec..d5ad1fb123e4 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using Content.Server.Administration.Logs; using Content.Server.Pointing.Components; +using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.Examine; using Content.Shared.Eye; @@ -14,6 +15,7 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Server.Player; +using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.GameStates; using Robust.Shared.Input.Binding; @@ -27,6 +29,7 @@ namespace Content.Server.Pointing.EntitySystems [UsedImplicitly] internal sealed class PointingSystem : SharedPointingSystem { + [Dependency] private readonly IConfigurationManager _config = default!; [Dependency] private readonly IReplayRecordingManager _replay = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; @@ -40,7 +43,7 @@ internal sealed class PointingSystem : SharedPointingSystem [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly ExamineSystemShared _examine = default!; - private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f); + private TimeSpan _pointDelay = TimeSpan.FromSeconds(0.5f); /// /// A dictionary of players to the last time that they @@ -124,7 +127,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coordsPointed, E } if (_pointers.TryGetValue(session, out var lastTime) && - _gameTiming.CurTime < lastTime + PointDelay) + _gameTiming.CurTime < lastTime + _pointDelay) { return false; } @@ -257,6 +260,8 @@ public override void Initialize() CommandBinds.Builder .Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint)) .Register(); + + Subs.CVar(_config, CCVars.PointingCooldownSeconds, v => _pointDelay = TimeSpan.FromSeconds(v), true); } private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args) diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 9f8a02cbb731..6c145d69da33 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -2212,6 +2212,12 @@ public static readonly CVarDef public static readonly CVarDef TippyEntity = CVarDef.Create("tippy.entity", "Tippy", CVar.SERVER | CVar.REPLICATED); + /// + /// The number of seconds that must pass for a single entity to be able to point at something again. + /// + public static readonly CVarDef PointingCooldownSeconds = + CVarDef.Create("pointing.cooldown_seconds", 0.5f, CVar.SERVERONLY); + /* * DEBUG */