Migrate pulling logic into SharedPullableComponent from PullController (#2627)

* Pulling: Migrate critical pull state from PullController to SharedPullableComponent, fixing two bugs in the process

Bug 1: PullController can be just summoned for no reason when the verb is queried
Bug 2: PullController keeps it's own independent pull state which can (and will) go out of sync (See https://github.com/space-wizards/space-station-14/issues/2619 )

* Pulling: Fix issues with previous commit (or possibly in general?) causing transferring a pull to cause alerts to go wrong

The primary problem is that there is one "pulling slot" for a puller, so SharedPullableComponent needs to stop the existing pull.

* Pulling: Remove debug logs (whoops)
This commit is contained in:
20kdc
2020-11-26 13:48:10 +00:00
committed by GitHub
parent 06b1939a60
commit 380d76f4cd
5 changed files with 163 additions and 146 deletions

View File

@@ -41,26 +41,17 @@ namespace Content.Server.GameObjects.Components.Pulling
return;
}
var controller = targetPhysics.EnsureController<PullController>();
data.Visibility = VerbVisibility.Visible;
data.Text = controller.Puller == userPhysics
data.Text = component.Puller == userPhysics
? Loc.GetString("Stop pulling")
: Loc.GetString("Pull");
}
protected override void Activate(IEntity user, PullableComponent component)
{
if (!user.TryGetComponent(out IPhysicsComponent? userCollidable) ||
!component.Owner.TryGetComponent(out IPhysicsComponent? targetCollidable) ||
targetCollidable.Anchored)
{
return;
}
var controller = targetCollidable.EnsureController<PullController>();
if (controller.Puller == userCollidable)
// There used to be sanity checks here for no reason.
// Why no reason? Because they're supposed to be performed in TryStartPull.
if (component.Puller == user)
{
component.TryStopPull();
}