This commit is contained in:
DrSmugleaf 2020-07-22 09:50:39 +02:00 committed by GitHub
parent f34b454923
commit 80fbb44ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components.Movement;
#nullable enable
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC;
@ -10,7 +11,7 @@ namespace Content.Shared.Physics
public class MoverController : VirtualController
{
private Vector2 _velocity;
private ICollidableComponent _component = null;
private ICollidableComponent? _component;
public Vector2 Velocity
{
@ -30,8 +31,8 @@ namespace Content.Shared.Physics
public void Move(Vector2 velocityDirection, float speed)
{
if (!_component.Owner.HasComponent<MovementIgnoreGravityComponent>() && IoCManager
.Resolve<IPhysicsManager>().IsWeightless(_component.Owner.Transform.GridPosition)) return;
if (_component?.Owner.HasComponent<MovementIgnoreGravityComponent>() == false
&& IoCManager.Resolve<IPhysicsManager>().IsWeightless(_component.Owner.Transform.GridPosition)) return;
Push(velocityDirection, speed);
}
@ -49,6 +50,11 @@ namespace Content.Shared.Physics
{
base.UpdateBeforeProcessing();
if (_component == null)
{
return;
}
if (Velocity == Vector2.Zero)
{
// Try to stop movement