Fix some buckling bugs (#10759)
This commit is contained in:
@@ -85,6 +85,9 @@ namespace Content.Server.Buckle.Systems
|
|||||||
|
|
||||||
private void ContainerModifiedStrap(EntityUid uid, StrapComponent strap, ContainerModifiedMessage message)
|
private void ContainerModifiedStrap(EntityUid uid, StrapComponent strap, ContainerModifiedMessage message)
|
||||||
{
|
{
|
||||||
|
if (GameTiming.ApplyingState)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var buckledEntity in strap.BuckledEntities)
|
foreach (var buckledEntity in strap.BuckledEntities)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled))
|
if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled))
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ using Content.Shared.Movement.Events;
|
|||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Shared.Buckle
|
namespace Content.Shared.Buckle
|
||||||
{
|
{
|
||||||
public abstract class SharedBuckleSystem : EntitySystem
|
public abstract class SharedBuckleSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -28,6 +31,20 @@ namespace Content.Shared.Buckle
|
|||||||
// TODO: This looks dirty af.
|
// TODO: This looks dirty af.
|
||||||
// On rotation of a strap, reattach all buckled entities.
|
// On rotation of a strap, reattach all buckled entities.
|
||||||
// This fixes buckle offsets and draw depths.
|
// This fixes buckle offsets and draw depths.
|
||||||
|
// This is mega cursed. Please somebody save me from Mr Buckle's wild ride.
|
||||||
|
|
||||||
|
// Consider a chair that has a player strapped to it. Then the client receives a new server state, showing
|
||||||
|
// that the player entity has moved elsewhere, and the chair has rotated. If the client applies the player
|
||||||
|
// state, then the chairs transform comp state, and then the buckle state. The transform state will
|
||||||
|
// forcefully teleport the player back to the chair (client-side only). This causes even more issues if the
|
||||||
|
// chair was teleporting in from nullspace after having left PVS.
|
||||||
|
//
|
||||||
|
// One option is to just never trigger re-buckles during state application.
|
||||||
|
// another is to.. just not do this? Like wtf is this code. But I CBF with buckle atm.
|
||||||
|
|
||||||
|
if (GameTiming.ApplyingState)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var buckledEntity in component.BuckledEntities)
|
foreach (var buckledEntity in component.BuckledEntities)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent(buckledEntity, out SharedBuckleComponent? buckled))
|
if (!EntityManager.TryGetComponent(buckledEntity, out SharedBuckleComponent? buckled))
|
||||||
@@ -35,6 +52,12 @@ namespace Content.Shared.Buckle
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!buckled.Buckled || buckled.LastEntityBuckledTo != uid)
|
||||||
|
{
|
||||||
|
Logger.Error($"A moving strap entity {ToPrettyString(uid)} attempted to re-parent an entity that does not 'belong' to it {ToPrettyString(buckledEntity)}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
buckled.ReAttach(component);
|
buckled.ReAttach(component);
|
||||||
Dirty(buckled);
|
Dirty(buckled);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user