Refactor to use the new multiple controller system (#1462)
* Transition code to new controller system * Fix shuttles not moving * Fix throwing * Fix guns * Change hands to use physics.Stop() and remove item fumble method
This commit is contained in:
@@ -10,60 +10,27 @@ namespace Content.Shared.Physics
|
||||
{
|
||||
public class MoverController : VirtualController
|
||||
{
|
||||
private Vector2 _velocity;
|
||||
private ICollidableComponent? _component;
|
||||
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get => _velocity;
|
||||
set => _velocity = value;
|
||||
}
|
||||
|
||||
public override ICollidableComponent? ControlledComponent
|
||||
{
|
||||
set => _component = value;
|
||||
}
|
||||
|
||||
public MoverController()
|
||||
{
|
||||
_velocity = Vector2.Zero;
|
||||
}
|
||||
public override ICollidableComponent? ControlledComponent { protected get; set; }
|
||||
|
||||
public void Move(Vector2 velocityDirection, float speed)
|
||||
{
|
||||
if (_component?.Owner.HasComponent<MovementIgnoreGravityComponent>() == false
|
||||
&& IoCManager.Resolve<IPhysicsManager>().IsWeightless(_component.Owner.Transform.GridPosition)) return;
|
||||
if (ControlledComponent?.Owner.HasComponent<MovementIgnoreGravityComponent>() == false
|
||||
&& IoCManager.Resolve<IPhysicsManager>().IsWeightless(ControlledComponent.Owner.Transform.GridPosition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Push(velocityDirection, speed);
|
||||
}
|
||||
|
||||
public void Push(Vector2 velocityDirection, float speed)
|
||||
{
|
||||
Velocity = velocityDirection * speed;
|
||||
LinearVelocity = velocityDirection * speed;
|
||||
}
|
||||
|
||||
public void StopMoving()
|
||||
{
|
||||
Velocity = Vector2.Zero;
|
||||
}
|
||||
|
||||
public override void UpdateBeforeProcessing()
|
||||
{
|
||||
base.UpdateBeforeProcessing();
|
||||
|
||||
if (_component == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Velocity == Vector2.Zero)
|
||||
{
|
||||
// Try to stop movement
|
||||
_component.LinearVelocity = Vector2.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
_component.LinearVelocity = Velocity;
|
||||
}
|
||||
LinearVelocity = Vector2.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user