Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pointing cooldown a cvar #30623

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Content.Server/Pointing/EntitySystems/PointingSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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!;
Expand All @@ -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);

/// <summary>
/// A dictionary of players to the last time that they
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -257,6 +260,8 @@ public override void Initialize()
CommandBinds.Builder
.Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint))
.Register<PointingSystem>();

Subs.CVar(_config, CCVars.PointingCooldownSeconds, v => _pointDelay = TimeSpan.FromSeconds(v), true);
}

private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args)
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,12 @@ public static readonly CVarDef<float>
public static readonly CVarDef<string> TippyEntity =
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
*/
Expand Down
Loading