From 981fed8b27ae8043ae3be23c7b4cecc62d331dd0 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Mon, 2 Nov 2020 11:58:47 +0100 Subject: [PATCH] Fix being able to start pulls on anchored entities (#2457) * Fix being able to start pulls on anchored entities * Replace tryget with component dependency --- .../Pulling/SharedPullableComponent.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs index 5683665358..1a76e085e3 100644 --- a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs +++ b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs @@ -19,7 +19,7 @@ namespace Content.Shared.GameObjects.Components.Pulling public override string Name => "Pullable"; public override uint? NetID => ContentNetIDs.PULLABLE; - [ComponentDependency] private IPhysicsComponent? _physics = default!; + [ComponentDependency] private readonly IPhysicsComponent? _physics = default!; private IEntity? _puller; @@ -36,7 +36,7 @@ namespace Content.Shared.GameObjects.Components.Pulling _puller = value; Dirty(); - if (!Owner.TryGetComponent(out IPhysicsComponent? physics)) + if (_physics == null) { return; } @@ -45,7 +45,7 @@ namespace Content.Shared.GameObjects.Components.Pulling if (value == null) { - if (physics.TryGetController(out controller)) + if (_physics.TryGetController(out controller)) { controller.StopPull(); } @@ -53,7 +53,7 @@ namespace Content.Shared.GameObjects.Components.Pulling return; } - controller = physics.EnsureController(); + controller = _physics.EnsureController(); controller.StartPull(value); } } @@ -67,12 +67,12 @@ namespace Content.Shared.GameObjects.Components.Pulling return false; } - if (!puller.TryGetComponent(out IPhysicsComponent? physics)) + if (_physics == null) { return false; } - if (physics.Anchored) + if (_physics.Anchored) { return false; } @@ -145,12 +145,12 @@ namespace Content.Shared.GameObjects.Components.Pulling return false; } - if (!Owner.TryGetComponent(out IPhysicsComponent? physics)) + if (_physics == null) { return false; } - if (!physics.TryGetController(out PullController controller)) + if (!_physics.TryGetController(out PullController controller)) { return false; }