From 63a16f2f25698c5870b80275541ebbe7521b1eb0 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 1 Mar 2022 11:45:44 +1100 Subject: [PATCH] Update dragdrop pos every frame (#6933) No more 30fps here. --- Content.Client/DragDrop/DragDropSystem.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index e400f0504d..7afe513b64 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; using Content.Client.Outline; using Content.Client.Viewport; using Content.Shared.ActionBlocker; using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; -using Content.Shared.Interaction.Helpers; using Content.Shared.Popups; using JetBrains.Annotations; using Robust.Client.GameObjects; @@ -14,13 +11,8 @@ using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Player; using Robust.Client.State; -using Robust.Shared.GameObjects; using Robust.Shared.Input; using Robust.Shared.Input.Binding; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Log; -using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Utility; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; @@ -237,8 +229,6 @@ namespace Content.Client.DragDrop if (_dragShadow == default) return false; - EntityManager.GetComponent(_dragShadow).WorldPosition = mousePos.Position; - _targetRecheckTime += frameTime; if (_targetRecheckTime > TargetRecheckInterval) { @@ -464,7 +454,20 @@ namespace Content.Client.DragDrop public override void Update(float frameTime) { base.Update(frameTime); + _dragDropHelper.Update(frameTime); } + + public override void FrameUpdate(float frameTime) + { + base.FrameUpdate(frameTime); + + // Update position every frame to make it smooth. + if (_dragDropHelper.IsDragging) + { + var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition); + Transform(_dragShadow).WorldPosition = mousePos.Position; + } + } } }