Make pointing cooldown a cvar (#30623)

* Make pointing cooldown a cvar

* Remove empty line
This commit is contained in:
DrSmugleaf
2024-08-03 20:34:33 -07:00
committed by GitHub
parent 2aa7226266
commit 8865d4a782
2 changed files with 13 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
using System.Linq; using System.Linq;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Pointing.Components; using Content.Server.Pointing.Components;
using Content.Shared.CCVar;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Eye; using Content.Shared.Eye;
@@ -14,6 +15,7 @@ using Content.Shared.Popups;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
@@ -27,6 +29,7 @@ namespace Content.Server.Pointing.EntitySystems
[UsedImplicitly] [UsedImplicitly]
internal sealed class PointingSystem : SharedPointingSystem internal sealed class PointingSystem : SharedPointingSystem
{ {
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IReplayRecordingManager _replay = default!; [Dependency] private readonly IReplayRecordingManager _replay = default!;
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -40,7 +43,7 @@ namespace Content.Server.Pointing.EntitySystems
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!; [Dependency] private readonly ExamineSystemShared _examine = default!;
private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f); private TimeSpan _pointDelay = TimeSpan.FromSeconds(0.5f);
/// <summary> /// <summary>
/// A dictionary of players to the last time that they /// A dictionary of players to the last time that they
@@ -124,7 +127,7 @@ namespace Content.Server.Pointing.EntitySystems
} }
if (_pointers.TryGetValue(session, out var lastTime) && if (_pointers.TryGetValue(session, out var lastTime) &&
_gameTiming.CurTime < lastTime + PointDelay) _gameTiming.CurTime < lastTime + _pointDelay)
{ {
return false; return false;
} }
@@ -257,6 +260,8 @@ namespace Content.Server.Pointing.EntitySystems
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint)) .Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint))
.Register<PointingSystem>(); .Register<PointingSystem>();
Subs.CVar(_config, CCVars.PointingCooldownSeconds, v => _pointDelay = TimeSpan.FromSeconds(v), true);
} }
private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args) private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args)

View File

@@ -2212,6 +2212,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<string> TippyEntity = public static readonly CVarDef<string> TippyEntity =
CVarDef.Create("tippy.entity", "Tippy", CVar.SERVER | CVar.REPLICATED); CVarDef.Create("tippy.entity", "Tippy", CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// The number of seconds that must pass for a single entity to be able to point at something again.
/// </summary>
public static readonly CVarDef<float> PointingCooldownSeconds =
CVarDef.Create("pointing.cooldown_seconds", 0.5f, CVar.SERVERONLY);
/* /*
* DEBUG * DEBUG
*/ */