Fix being able to start pulls on anchored entities (#2457)
* Fix being able to start pulls on anchored entities * Replace tryget with component dependency
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
public override string Name => "Pullable";
|
public override string Name => "Pullable";
|
||||||
public override uint? NetID => ContentNetIDs.PULLABLE;
|
public override uint? NetID => ContentNetIDs.PULLABLE;
|
||||||
|
|
||||||
[ComponentDependency] private IPhysicsComponent? _physics = default!;
|
[ComponentDependency] private readonly IPhysicsComponent? _physics = default!;
|
||||||
|
|
||||||
private IEntity? _puller;
|
private IEntity? _puller;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
_puller = value;
|
_puller = value;
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
if (!Owner.TryGetComponent(out IPhysicsComponent? physics))
|
if (_physics == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
if (physics.TryGetController(out controller))
|
if (_physics.TryGetController(out controller))
|
||||||
{
|
{
|
||||||
controller.StopPull();
|
controller.StopPull();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller = physics.EnsureController<PullController>();
|
controller = _physics.EnsureController<PullController>();
|
||||||
controller.StartPull(value);
|
controller.StartPull(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,12 +67,12 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!puller.TryGetComponent(out IPhysicsComponent? physics))
|
if (_physics == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (physics.Anchored)
|
if (_physics.Anchored)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -145,12 +145,12 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Owner.TryGetComponent(out IPhysicsComponent? physics))
|
if (_physics == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!physics.TryGetController(out PullController controller))
|
if (!_physics.TryGetController(out PullController controller))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user