Physics (#3452)
* Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ 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
|
||||
@@ -20,14 +21,16 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
public override string Name => "Pullable";
|
||||
public override uint? NetID => ContentNetIDs.PULLABLE;
|
||||
|
||||
[ComponentDependency] private readonly IPhysicsComponent? _physics = default!;
|
||||
[ComponentDependency] private readonly PhysicsComponent? _physics = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Only set in Puller->set! Only set in unison with _pullerPhysics!
|
||||
/// </summary>
|
||||
private IEntity? _puller;
|
||||
private IPhysicsComponent? _pullerPhysics;
|
||||
public IPhysicsComponent? PullerPhysics => _pullerPhysics;
|
||||
private IPhysBody? _pullerPhysics;
|
||||
public IPhysBody? PullerPhysics => _pullerPhysics;
|
||||
|
||||
private DistanceJoint? _pullJoint = null;
|
||||
|
||||
/// <summary>
|
||||
/// The current entity pulling this component.
|
||||
@@ -62,7 +65,6 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
|
||||
oldPuller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
|
||||
_physics.WakeBody();
|
||||
_physics.TryRemoveController<PullController>();
|
||||
}
|
||||
// else-branch warning is handled below
|
||||
}
|
||||
@@ -70,7 +72,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 IPhysicsComponent.", Owner);
|
||||
Logger.WarningS("c.go.c.pulling", "Well now you've done it, haven't you? SharedPullableComponent on {0} didn't have an IPhysBody.", Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +85,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
return;
|
||||
}
|
||||
|
||||
if (!value.TryGetComponent<IPhysicsComponent>(out var valuePhysics))
|
||||
if (!value.TryGetComponent<PhysicsComponent>(out var pullerPhysics))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -113,7 +115,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
|
||||
// Continue with pulling process.
|
||||
|
||||
var pullAttempt = new PullAttemptMessage(valuePhysics, _physics);
|
||||
var pullAttempt = new PullAttemptMessage(pullerPhysics, _physics);
|
||||
|
||||
value.SendMessage(null, pullAttempt);
|
||||
|
||||
@@ -133,9 +135,8 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
|
||||
_puller = value;
|
||||
Dirty();
|
||||
_pullerPhysics = valuePhysics;
|
||||
_pullerPhysics = pullerPhysics;
|
||||
|
||||
_physics.EnsureController<PullController>().Manager = this;
|
||||
var message = new PullStartedMessage(_pullerPhysics, _physics);
|
||||
|
||||
_puller.SendMessage(null, message);
|
||||
@@ -143,7 +144,13 @@ 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.
|
||||
}
|
||||
@@ -212,6 +219,12 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_physics != null && _pullJoint != null)
|
||||
{
|
||||
_physics.RemoveJoint(_pullJoint);
|
||||
}
|
||||
|
||||
_pullJoint = null;
|
||||
Puller = null;
|
||||
return true;
|
||||
}
|
||||
@@ -246,12 +259,16 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!_physics.TryGetController(out PullController controller))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return controller.TryMoveTo(Puller.Transform.Coordinates, to);
|
||||
return true;
|
||||
|
||||
//return controller.TryMoveTo(Puller.Transform.Coordinates, to);
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
|
||||
Reference in New Issue
Block a user