Revert "Physics (#3452)"

This reverts commit 3e64fd56a1.
This commit is contained in:
Pieter-Jan Briers
2021-02-28 18:49:48 +01:00
parent eddec5fcce
commit 1eb0fbd8d0
211 changed files with 2560 additions and 2600 deletions

View File

@@ -18,7 +18,7 @@ namespace Content.Shared.GameObjects.Components.Buckle
public sealed override uint? NetID => ContentNetIDs.BUCKLE;
[ComponentDependency] protected readonly IPhysBody? Physics;
[ComponentDependency] protected readonly IPhysicsComponent? Physics;
/// <summary>
/// The range from which this entity can buckle to a <see cref="SharedStrapComponent"/>.

View File

@@ -20,8 +20,8 @@ namespace Content.Shared.GameObjects.Components.Disposal
[ViewVariables]
public bool Anchored =>
!Owner.TryGetComponent(out IPhysBody? physics) ||
physics.BodyType == BodyType.Static;
!Owner.TryGetComponent(out IPhysicsComponent? physics) ||
physics.Anchored;
[Serializable, NetSerializable]
public enum Visuals
@@ -166,7 +166,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
if (!Anchored)
return false;
if (!entity.TryGetComponent(out IPhysBody? physics) ||
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
!physics.CanCollide)
{
if (!(entity.TryGetComponent(out IMobStateComponent? damageState) && damageState.IsDead())) {

View File

@@ -19,7 +19,7 @@ namespace Content.Shared.GameObjects.Components.Doors
protected readonly SharedAppearanceComponent? AppearanceComponent = null;
[ComponentDependency]
protected readonly IPhysBody? PhysicsComponent = null;
protected readonly IPhysicsComponent? PhysicsComponent = null;
[ViewVariables]
private DoorState _state = DoorState.Closed;

View File

@@ -21,22 +21,8 @@ namespace Content.Shared.GameObjects.Components.Mobs
get => _isInCombatMode;
set
{
if (_isInCombatMode == value) return;
_isInCombatMode = value;
Dirty();
// Regenerate physics contacts -> Can probably just selectively check
/* Still a bit jank so left disabled for now.
if (Owner.TryGetComponent(out PhysicsComponent? physicsComponent))
{
if (value)
{
physicsComponent.WakeBody();
}
physicsComponent.RegenerateContacts();
}
*/
}
}
@@ -46,7 +32,6 @@ namespace Content.Shared.GameObjects.Components.Mobs
get => _activeZone;
set
{
if (_activeZone == value) return;
_activeZone = value;
Dirty();
}

View File

@@ -1,15 +0,0 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Shared.GameObjects.Components.Movement
{
public interface IMobMoverComponent : IComponent
{
EntityCoordinates LastPosition { get; set; }
public float StepSoundDistance { get; set; }
float GrabRange { get; set; }
}
}

View File

@@ -19,6 +19,17 @@ namespace Content.Shared.GameObjects.Components.Movement
/// </summary>
float CurrentSprintSpeed { get; }
/// <summary>
/// The movement speed (m/s) of the entity when it pushes off of a solid object in zero gravity.
/// </summary>
float CurrentPushSpeed { get; }
/// <summary>
/// How far an entity can reach (in meters) to grab hold of a solid object in zero gravity.
/// </summary>
float GrabRange { get; }
/// <summary>
/// Is the entity Sprinting (running)?
/// </summary>
@@ -29,6 +40,10 @@ namespace Content.Shared.GameObjects.Components.Movement
/// </summary>
(Vector2 walking, Vector2 sprinting) VelocityDir { get; }
EntityCoordinates LastPosition { get; set; }
float StepSoundDistance { get; set; }
/// <summary>
/// Toggles one of the four cardinal directions. Each of the four directions are
/// composed into a single direction vector, <see cref="SharedPlayerInputMoverComponent.VelocityDir"/>. Enabling
@@ -40,5 +55,6 @@ namespace Content.Shared.GameObjects.Components.Movement
void SetVelocityDirection(Direction direction, ushort subTick, bool enabled);
void SetSprinting(ushort subTick, bool walking);
}
}

View File

@@ -3,89 +3,64 @@ using System;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Movement
{
public abstract class SharedClimbingComponent : Component, IActionBlocker
public abstract class SharedClimbingComponent : Component, IActionBlocker, ICollideSpecial
{
public sealed override string Name => "Climbing";
public sealed override uint? NetID => ContentNetIDs.CLIMBING;
protected bool IsOnClimbableThisFrame
protected IPhysicsComponent? Body;
protected bool IsOnClimbableThisFrame;
protected bool OwnerIsTransitioning
{
get
{
if (Body == null) return false;
foreach (var entity in Body.GetBodiesIntersecting())
if (Body != null && Body.TryGetController<ClimbController>(out var controller))
{
if ((entity.CollisionLayer & (int) CollisionGroup.VaultImpassable) != 0) return true;
return controller.IsActive;
}
return false;
}
}
public abstract bool IsClimbing { get; set; }
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
bool IActionBlocker.CanChangeDirection() => !OwnerIsTransitioning;
[ViewVariables]
protected virtual bool OwnerIsTransitioning { get; set; }
[ComponentDependency] protected PhysicsComponent? Body;
protected TimeSpan StartClimbTime = TimeSpan.Zero;
/// <summary>
/// We'll launch the mob onto the table and give them at least this amount of time to be on it.
/// </summary>
protected const float BufferTime = 0.3f;
public virtual bool IsClimbing
bool ICollideSpecial.PreventCollide(IPhysBody collided)
{
get => _isClimbing;
set
if (((CollisionGroup)collided.CollisionLayer).HasFlag(CollisionGroup.VaultImpassable) && collided.Entity.HasComponent<IClimbable>())
{
if (_isClimbing == value) return;
_isClimbing = value;
ToggleVaultPassable(value);
IsOnClimbableThisFrame = true;
return IsClimbing;
}
return false;
}
protected bool _isClimbing;
// TODO: Layers need a re-work
private void ToggleVaultPassable(bool value)
public override void Initialize()
{
// Hope the mob has one fixture
if (Body == null || Body.Deleted) return;
base.Initialize();
foreach (var fixture in Body.Fixtures)
{
if (value)
{
fixture.CollisionMask &= ~(int) CollisionGroup.VaultImpassable;
}
else
{
fixture.CollisionMask |= (int) CollisionGroup.VaultImpassable;
}
}
Owner.TryGetComponent(out Body);
}
[Serializable, NetSerializable]
protected sealed class ClimbModeComponentState : ComponentState
{
public ClimbModeComponentState(bool climbing, bool isTransitioning) : base(ContentNetIDs.CLIMBING)
public ClimbModeComponentState(bool climbing) : base(ContentNetIDs.CLIMBING)
{
Climbing = climbing;
IsTransitioning = isTransitioning;
}
public bool Climbing { get; }
public bool IsTransitioning { get; }
}
}
}

View File

@@ -10,12 +10,14 @@ namespace Content.Shared.GameObjects.Components.Movement
public class SharedDummyInputMoverComponent : Component, IMoverComponent
{
public override string Name => "DummyInputMover";
public bool IgnorePaused => false;
public float CurrentWalkSpeed => 0f;
public float CurrentSprintSpeed => 0f;
public float CurrentPushSpeed => 0f;
public float GrabRange => 0f;
public bool Sprinting => false;
public (Vector2 walking, Vector2 sprinting) VelocityDir => (Vector2.Zero, Vector2.Zero);
public EntityCoordinates LastPosition { get; set; }
public float StepSoundDistance { get; set; }
public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled)
{

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
@@ -14,9 +15,7 @@ using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Movement
{
[RegisterComponent]
[ComponentReference(typeof(IMoverComponent))]
public class SharedPlayerInputMoverComponent : Component, IMoverComponent
public abstract class SharedPlayerInputMoverComponent : Component, IMoverComponent, ICollideSpecial
{
// This class has to be able to handle server TPS being lower than client FPS.
// While still having perfectly responsive movement client side.
@@ -40,10 +39,8 @@ namespace Content.Shared.GameObjects.Components.Movement
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[ComponentDependency] private readonly MovementSpeedModifierComponent? _movementSpeed = default!;
public override string Name => "PlayerInputMover";
public override uint? NetID => ContentNetIDs.PLAYER_INPUT_MOVER;
public sealed override string Name => "PlayerInputMover";
public sealed override uint? NetID => ContentNetIDs.PLAYER_INPUT_MOVER;
private GameTick _lastInputTick;
private ushort _lastInputSubTick;
@@ -52,19 +49,36 @@ namespace Content.Shared.GameObjects.Components.Movement
private MoveButtons _heldMoveButtons = MoveButtons.None;
// Don't serialize because it probably shouldn't change and it's a waste.
public bool IgnorePaused
public float CurrentWalkSpeed
{
get => _ignorePaused;
set => _ignorePaused = value;
get
{
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component))
{
return component.CurrentWalkSpeed;
}
return MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
}
}
private bool _ignorePaused;
public float CurrentSprintSpeed
{
get
{
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component))
{
return component.CurrentSprintSpeed;
}
public float CurrentWalkSpeed => _movementSpeed?.CurrentWalkSpeed ?? MovementSpeedModifierComponent.DefaultBaseWalkSpeed;
public float CurrentSprintSpeed => _movementSpeed?.CurrentSprintSpeed ?? MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
return MovementSpeedModifierComponent.DefaultBaseSprintSpeed;
}
}
[ViewVariables(VVAccess.ReadWrite)]
public float CurrentPushSpeed => 5;
[ViewVariables(VVAccess.ReadWrite)]
public float GrabRange => 0.2f;
public bool Sprinting => !HasFlag(_heldMoveButtons, MoveButtons.Walk);
/// <summary>
@@ -117,24 +131,27 @@ namespace Content.Shared.GameObjects.Components.Movement
}
}
public abstract EntityCoordinates LastPosition { get; set; }
public abstract float StepSoundDistance { get; set; }
/// <summary>
/// Whether or not the player can move diagonally.
/// </summary>
[ViewVariables]
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
public override void ExposeData(ObjectSerializer serializer)
/// <inheritdoc />
public override void OnAdd()
{
base.ExposeData(serializer);
serializer.DataField(ref _ignorePaused, "ignorePaused", false);
// This component requires that the entity has a IPhysicsComponent.
if (!Owner.HasComponent<IPhysicsComponent>())
Logger.Error(
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
$" {nameof(IPhysicsComponent)}. ");
base.OnAdd();
}
/// <inheritdoc />
public override void Initialize()
{
base.Initialize();
Owner.EnsureComponentWarn<PhysicsComponent>();
}
/// <summary>
/// Toggles one of the four cardinal directions. Each of the four directions are
@@ -249,6 +266,12 @@ namespace Content.Shared.GameObjects.Components.Movement
return vec;
}
bool ICollideSpecial.PreventCollide(IPhysBody collidedWith)
{
// Don't collide with other mobs
return collidedWith.Entity.HasComponent<IBody>();
}
[Serializable, NetSerializable]
private sealed class MoverComponentState : ComponentState
{

View File

@@ -1,100 +0,0 @@
#nullable enable
using System;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Movement
{
/// <summary>
/// The basic player mover with footsteps and grabbing
/// </summary>
[RegisterComponent]
[ComponentReference(typeof(IMobMoverComponent))]
public class SharedPlayerMobMoverComponent : Component, IMobMoverComponent, ICollideSpecial
{
public override string Name => "PlayerMobMover";
public override uint? NetID => ContentNetIDs.PLAYER_MOB_MOVER;
private float _stepSoundDistance;
private float _grabRange;
[ViewVariables(VVAccess.ReadWrite)]
public EntityCoordinates LastPosition { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public float StepSoundDistance
{
get => _stepSoundDistance;
set
{
if (MathHelper.CloseTo(_stepSoundDistance, value)) return;
_stepSoundDistance = value;
Dirty();
}
}
[ViewVariables(VVAccess.ReadWrite)]
public float GrabRange
{
get => _grabRange;
set
{
if (MathHelper.CloseTo(_grabRange, value)) return;
_grabRange = value;
Dirty();
}
}
public override void Initialize()
{
base.Initialize();
if (!Owner.HasComponent<IMoverComponent>())
{
Owner.EnsureComponentWarn<SharedPlayerInputMoverComponent>();
}
}
public override ComponentState GetComponentState(ICommonSession session)
{
return new PlayerMobMoverComponentState(StepSoundDistance, GrabRange);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not PlayerMobMoverComponentState playerMoverState) return;
StepSoundDistance = playerMoverState.StepSoundDistance;
GrabRange = playerMoverState.GrabRange;
}
bool ICollideSpecial.PreventCollide(IPhysBody collidedWith)
{
// Don't collide with other mobs
// unless they have combat mode on
return collidedWith.Entity.HasComponent<IBody>(); /* &&
(!Owner.TryGetComponent(out SharedCombatModeComponent? ownerCombat) || !ownerCombat.IsInCombatMode) &&
(!collidedWith.Entity.TryGetComponent(out SharedCombatModeComponent? otherCombat) || !otherCombat.IsInCombatMode);
*/
}
[Serializable, NetSerializable]
private sealed class PlayerMobMoverComponentState : ComponentState
{
public float StepSoundDistance;
public float GrabRange;
public PlayerMobMoverComponentState(float stepSoundDistance, float grabRange) : base(ContentNetIDs.PLAYER_MOB_MOVER)
{
StepSoundDistance = stepSoundDistance;
GrabRange = grabRange;
}
}
}
}

View File

@@ -3,12 +3,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
using Content.Shared.Physics;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -55,12 +53,14 @@ namespace Content.Shared.GameObjects.Components.Movement
[ViewVariables(VVAccess.ReadWrite)]
public virtual bool Slippery { get; set; }
private bool TrySlip(IPhysBody ourBody, IPhysBody otherBody)
private bool TrySlip(IEntity entity)
{
if (!Slippery
|| Owner.IsInContainer()
|| _slipped.Contains(otherBody.Entity.Uid)
|| !otherBody.Entity.TryGetComponent(out SharedStunnableComponent? stun))
|| _slipped.Contains(entity.Uid)
|| !entity.TryGetComponent(out SharedStunnableComponent? stun)
|| !entity.TryGetComponent(out IPhysicsComponent? otherBody)
|| !Owner.TryGetComponent(out IPhysicsComponent? body))
{
return false;
}
@@ -70,22 +70,26 @@ namespace Content.Shared.GameObjects.Components.Movement
return false;
}
var percentage = otherBody.GetWorldAABB().IntersectPercentage(ourBody.GetWorldAABB());
var percentage = otherBody.WorldAABB.IntersectPercentage(body.WorldAABB);
if (percentage < IntersectPercentage)
{
return false;
}
if (!EffectBlockerSystem.CanSlip(otherBody.Entity))
if (!EffectBlockerSystem.CanSlip(entity))
{
return false;
}
otherBody.LinearVelocity *= LaunchForwardsMultiplier;
if (entity.TryGetComponent(out IPhysicsComponent? physics))
{
var controller = physics.EnsureController<SlipController>();
controller.LinearVelocity = physics.LinearVelocity * LaunchForwardsMultiplier;
}
stun.Paralyze(5);
_slipped.Add(otherBody.Entity.Uid);
_slipped.Add(entity.Uid);
OnSlip();
@@ -94,9 +98,9 @@ namespace Content.Shared.GameObjects.Components.Movement
protected virtual void OnSlip() { }
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
public void CollideWith(IEntity collidedWith)
{
TrySlip(ourBody, otherBody);
TrySlip(collidedWith);
}
public void Update()
@@ -110,10 +114,10 @@ namespace Content.Shared.GameObjects.Components.Movement
}
var entity = Owner.EntityManager.GetEntity(uid);
var physics = Owner.GetComponent<IPhysBody>();
var otherPhysics = entity.GetComponent<IPhysBody>();
var physics = Owner.GetComponent<IPhysicsComponent>();
var otherPhysics = entity.GetComponent<IPhysicsComponent>();
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
if (!physics.WorldAABB.Intersects(otherPhysics.WorldAABB))
{
_slipped.Remove(uid);
}
@@ -128,12 +132,12 @@ namespace Content.Shared.GameObjects.Components.Movement
physics.Hard = false;
var fixtures = physics.Fixtures.FirstOrDefault();
var shape = physics.PhysicsShapes.FirstOrDefault();
if (fixtures != null)
if (shape != null)
{
fixtures.CollisionLayer |= (int) CollisionGroup.SmallImpassable;
fixtures.CollisionMask = (int) CollisionGroup.None;
shape.CollisionLayer |= (int) CollisionGroup.SmallImpassable;
shape.CollisionMask = (int) CollisionGroup.None;
}
}

View File

@@ -1,62 +0,0 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Movement
{
[RegisterComponent]
public class SharedTileFrictionModifier : Component
{
public override string Name => "TileFrictionModifier";
/// <summary>
/// Multiply the tilefriction cvar by this to get the body's actual tilefriction.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float Modifier
{
get => _modifier;
set
{
if (MathHelper.CloseTo(_modifier, value)) return;
_modifier = value;
}
}
private float _modifier;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.Modifier, "modifier", 1.0f);
}
public override ComponentState GetComponentState(ICommonSession session)
{
return new TileFrictionComponentState(_modifier);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not TileFrictionComponentState tileState) return;
_modifier = tileState.Modifier;
}
[NetSerializable, Serializable]
protected class TileFrictionComponentState : ComponentState
{
public float Modifier;
public TileFrictionComponentState(float modifier) : base(ContentNetIDs.TILE_FRICTION)
{
Modifier = modifier;
}
}
}
}

View File

@@ -1,7 +1,6 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Portal
@@ -14,7 +13,7 @@ namespace Content.Shared.GameObjects.Components.Portal
{
base.OnAdd();
if (Owner.TryGetComponent<IPhysBody>(out var physics))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
physics.Hard = false;
}

View File

@@ -19,8 +19,6 @@ namespace Content.Shared.GameObjects.Components.Projectiles
get => _ignoreShooter;
set
{
if (_ignoreShooter == value) return;
_ignoreShooter = value;
Dirty();
}

View File

@@ -11,7 +11,6 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Physics.Dynamics.Joints;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Pulling
@@ -21,16 +20,14 @@ namespace Content.Shared.GameObjects.Components.Pulling
public override string Name => "Pullable";
public override uint? NetID => ContentNetIDs.PULLABLE;
[ComponentDependency] private readonly PhysicsComponent? _physics = default!;
[ComponentDependency] private readonly IPhysicsComponent? _physics = default!;
/// <summary>
/// Only set in Puller->set! Only set in unison with _pullerPhysics!
/// </summary>
private IEntity? _puller;
private IPhysBody? _pullerPhysics;
public IPhysBody? PullerPhysics => _pullerPhysics;
private DistanceJoint? _pullJoint = null;
private IPhysicsComponent? _pullerPhysics;
public IPhysicsComponent? PullerPhysics => _pullerPhysics;
/// <summary>
/// The current entity pulling this component.
@@ -65,6 +62,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
oldPuller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
_physics.WakeBody();
_physics.TryRemoveController<PullController>();
}
// else-branch warning is handled below
}
@@ -72,7 +70,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
// Now that is settled, prepare to be pulled by a new object.
if (_physics == null)
{
Logger.WarningS("c.go.c.pulling", "Well now you've done it, haven't you? SharedPullableComponent on {0} didn't have an IPhysBody.", Owner);
Logger.WarningS("c.go.c.pulling", "Well now you've done it, haven't you? SharedPullableComponent on {0} didn't have an IPhysicsComponent.", Owner);
return;
}
@@ -85,7 +83,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
return;
}
if (!value.TryGetComponent<PhysicsComponent>(out var pullerPhysics))
if (!value.TryGetComponent<IPhysicsComponent>(out var valuePhysics))
{
return;
}
@@ -115,7 +113,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
// Continue with pulling process.
var pullAttempt = new PullAttemptMessage(pullerPhysics, _physics);
var pullAttempt = new PullAttemptMessage(valuePhysics, _physics);
value.SendMessage(null, pullAttempt);
@@ -135,8 +133,9 @@ namespace Content.Shared.GameObjects.Components.Pulling
_puller = value;
Dirty();
_pullerPhysics = pullerPhysics;
_pullerPhysics = valuePhysics;
_physics.EnsureController<PullController>().Manager = this;
var message = new PullStartedMessage(_pullerPhysics, _physics);
_puller.SendMessage(null, message);
@@ -144,13 +143,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
_puller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
_physics.WakeBody();
_pullJoint = pullerPhysics.CreateDistanceJoint(_physics);
// _physics.BodyType = BodyType.Kinematic; // TODO: Need to consider their original bodytype
_pullJoint.CollideConnected = true;
_pullJoint.Length = 1.4f;
_pullJoint.MaxLength = 2.0f; // TODO hacky, we should consider ours and their bb
}
// Code here will not run if pulling a new object was attempted and failed because of the returns from the refactor.
}
@@ -219,12 +212,6 @@ namespace Content.Shared.GameObjects.Components.Pulling
return false;
}
if (_physics != null && _pullJoint != null)
{
_physics.RemoveJoint(_pullJoint);
}
_pullJoint = null;
Puller = null;
return true;
}
@@ -259,16 +246,12 @@ namespace Content.Shared.GameObjects.Components.Pulling
return false;
}
/*
if (!_physics.TryGetController(out PullController controller))
{
return false;
}
*/
return true;
//return controller.TryMoveTo(Puller.Transform.Coordinates, to);
return controller.TryMoveTo(Puller.Transform.Coordinates, to);
}
public override ComponentState GetComponentState(ICommonSession player)