From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Sat, 3 May 2025 15:17:30 +0000 (+1000)
Subject: Fix throwing prediction (#37086)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=60e3d8e5071708e0db5f212fb5393b3525429524;p=space-station-14.git
Fix throwing prediction (#37086)
* Fix throwing prediction
- Disposals is still janky but I think that's disposals in general not being predicted and the disposals throw not being predicted and short-lived.
- Would need to check RMC.
- Couldn't repro the underlying issues however thrown items don't slip anymore so (and we also don't predict their land / stopping anymore so).
* primary constructor
---------
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
---
diff --git a/Content.Shared/Throwing/LandEvent.cs b/Content.Shared/Throwing/LandEvent.cs
index f1326bb9ac..aee995b609 100644
--- a/Content.Shared/Throwing/LandEvent.cs
+++ b/Content.Shared/Throwing/LandEvent.cs
@@ -9,8 +9,6 @@ namespace Content.Shared.Throwing
///
/// Raised when a thrown entity is no longer moving.
///
- public sealed class StopThrowEvent : EntityEventArgs
- {
- public EntityUid? User;
- }
+ [ByRefEvent]
+ public record struct StopThrowEvent(EntityUid? User);
}
diff --git a/Content.Shared/Throwing/ThrowingSystem.cs b/Content.Shared/Throwing/ThrowingSystem.cs
index 567c969b0f..2d01810d8b 100644
--- a/Content.Shared/Throwing/ThrowingSystem.cs
+++ b/Content.Shared/Throwing/ThrowingSystem.cs
@@ -20,11 +20,6 @@ public sealed class ThrowingSystem : EntitySystem
{
public const float ThrowAngularImpulse = 5f;
- ///
- /// Speed cap on rotation in case of click-spam.
- ///
- public const float ThrowAngularCap = 3f * MathF.PI;
-
public const float PushbackDefault = 2f;
public const float FlyTimePercentage = 0.8f;
diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs
index 236e91aec6..3e1a4f18de 100644
--- a/Content.Shared/Throwing/ThrownItemSystem.cs
+++ b/Content.Shared/Throwing/ThrownItemSystem.cs
@@ -4,6 +4,7 @@ using Content.Shared.Database;
using Content.Shared.Gravity;
using Content.Shared.Physics;
using Content.Shared.Movement.Pulling.Events;
+using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
@@ -17,10 +18,11 @@ namespace Content.Shared.Throwing
///
public sealed class ThrownItemSystem : EntitySystem
{
- [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
- [Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
+ [Dependency] private readonly INetManager _netMan = default!;
+ [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly FixtureSystem _fixtures = default!;
+ [Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
@@ -108,8 +110,9 @@ namespace Content.Shared.Throwing
}
}
- EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent { User = thrownItemComponent.Thrower }, true);
- EntityManager.RemoveComponent(uid);
+ var ev = new StopThrowEvent(thrownItemComponent.Thrower);
+ RaiseLocalEvent(uid, ref ev);
+ RemComp(uid);
}
public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics, bool playSound)
@@ -145,15 +148,13 @@ namespace Content.Shared.Throwing
{
base.Update(frameTime);
- // TODO predicted throwing - remove this check
- // We don't want to predict landing or stopping, since throwing isn't actually predicted.
- // If we do, the landing/stop will occur prematurely on the client.
- if (_gameTiming.InPrediction)
- return;
-
var query = EntityQueryEnumerator();
while (query.MoveNext(out var uid, out var thrown, out var physics))
{
+ // If you remove this check verify slipping for other entities is networked properly.
+ if (_netMan.IsClient && !physics.Predict)
+ continue;
+
if (thrown.LandTime <= _gameTiming.CurTime)
{
LandComponent(uid, thrown, physics, thrown.PlayLandSound);