From 770d4e72e7a19d7ce3f390b9f07a9467b7cf48a4 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Wed, 8 Jul 2020 13:22:14 +0200 Subject: [PATCH] Add 0.25 second delay to unbuckling after recently buckling and more summaries --- .../Components/Mobs/BuckleComponent.cs | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs index c2e08e975a..7a8bb272e9 100644 --- a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using Content.Server.GameObjects.Components.Strap; using Content.Server.Interfaces; using Content.Server.Interfaces.GameObjects.Components.Interaction; @@ -13,6 +14,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; @@ -27,11 +29,30 @@ namespace Content.Server.GameObjects.Components.Mobs #pragma warning disable 649 [Dependency] private readonly IEntitySystemManager _entitySystem = default!; [Dependency] private readonly IServerNotifyManager _notifyManager = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; #pragma warning restore 649 + /// + /// The amount of space that this entity occupies in a . + /// private int _size; + + /// + /// The range from which this entity can buckle to a . + /// private float _range; + /// + /// The amount of time that must pass for this entity to + /// be able to unbuckle after recently buckling. + /// + private TimeSpan _unbuckleDelay; + + /// + /// The time that this entity buckled at. + /// + private TimeSpan _buckleTime; + private StrapComponent? _buckledTo; [ViewVariables] @@ -41,6 +62,7 @@ namespace Content.Server.GameObjects.Components.Mobs private set { _buckledTo = value; + _buckleTime = _gameTiming.CurTime; Dirty(); } } @@ -188,6 +210,11 @@ namespace Content.Server.GameObjects.Components.Mobs if (!force) { + if (_gameTiming.CurTime < _buckleTime + _unbuckleDelay) + { + return false; + } + if (!ActionBlockerSystem.CanInteract(user)) { _notifyManager.PopupMessage(user, user, @@ -199,7 +226,7 @@ namespace Content.Server.GameObjects.Components.Mobs if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range)) { - _notifyManager.PopupMessage(user, user, + _notifyManager.PopupMessage(Owner, user, Loc.GetString("You can't reach there!")); return false; } @@ -260,6 +287,11 @@ namespace Content.Server.GameObjects.Components.Mobs serializer.DataField(ref _size, "size", 100); serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 2); + + var seconds = 0.25f; + serializer.DataField(ref seconds, "cooldown", 0.25f); + + _unbuckleDelay = TimeSpan.FromSeconds(seconds); } protected override void Startup() @@ -267,6 +299,7 @@ namespace Content.Server.GameObjects.Components.Mobs base.Startup(); BuckleStatus(); } + public override void OnRemove() { base.OnRemove(); @@ -278,6 +311,7 @@ namespace Content.Server.GameObjects.Components.Mobs } BuckledTo = null; + _buckleTime = default; BuckleStatus(); }