Pullability partial ECS refactor, monkey-gibbing error fix (#4695)
* Migrate lots of pulling logic out of the components and clean it up * It's buggy, but move more code out of the pullable component * Pulling system now throws less errors than it did before the refactor * Finally finish the big parts of refactoring pullability * Pulling: Handle disconnect properly if the pull joint has been removed by physics shutdown * Port2b68449328to this branch * Changes as per PR reviews * Porte801ffac45(SharedJointSystem) and fix issues encountered during testing SharedJointSystem. Also, MinLength and Stiffness appear to have suddenly gained enough meaning that pulling is broken unless they're set.
This commit is contained in:
@@ -1,49 +1,40 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Pulling;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Log;
|
||||
using Component = Robust.Shared.GameObjects.Component;
|
||||
|
||||
namespace Content.Shared.Pulling.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(SharedPullingStateManagementSystem))]
|
||||
public class SharedPullerComponent : Component, IMoveSpeedModifier
|
||||
{
|
||||
public override string Name => "Puller";
|
||||
|
||||
private IEntity? _pulling;
|
||||
// Before changing how this is updated, please see SharedPullerSystem.RefreshMovementSpeed
|
||||
public float WalkSpeedModifier => Pulling == null ? 1.0f : 0.75f;
|
||||
|
||||
public float WalkSpeedModifier => _pulling == null ? 1.0f : 0.75f;
|
||||
|
||||
public float SprintSpeedModifier => _pulling == null ? 1.0f : 0.75f;
|
||||
public float SprintSpeedModifier => Pulling == null ? 1.0f : 0.75f;
|
||||
|
||||
[ViewVariables]
|
||||
public IEntity? Pulling
|
||||
public IEntity? Pulling { get; set; }
|
||||
|
||||
protected override void Shutdown()
|
||||
{
|
||||
get => _pulling;
|
||||
set
|
||||
{
|
||||
if (_pulling == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_pulling = value;
|
||||
|
||||
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? speed))
|
||||
{
|
||||
speed.RefreshMovementSpeedModifiers();
|
||||
}
|
||||
}
|
||||
EntitySystem.Get<SharedPullingStateManagementSystem>().ForceDisconnectPuller(this);
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
protected override void OnRemove()
|
||||
{
|
||||
if (Pulling != null &&
|
||||
Pulling.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
if (Pulling != null)
|
||||
{
|
||||
pullable.TryStopPull();
|
||||
// This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc
|
||||
Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLER {0} - OnRemove called when Pulling is set!", Owner);
|
||||
}
|
||||
|
||||
base.OnRemove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user