Physics (#3485)
* 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 * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
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;
|
||||
|
||||
/// <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;
|
||||
}
|
||||
@@ -102,7 +104,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
{
|
||||
if (oldPulling.TryGetComponent(out SharedPullableComponent? pullable))
|
||||
{
|
||||
pullable.Puller = null;
|
||||
pullable.TryStopPull();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -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,15 @@ namespace Content.Shared.GameObjects.Components.Pulling
|
||||
|
||||
_puller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
|
||||
|
||||
var union = _pullerPhysics.GetWorldAABB().Union(_physics.GetWorldAABB());
|
||||
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
||||
|
||||
_physics.WakeBody();
|
||||
_pullJoint = pullerPhysics.CreateDistanceJoint(_physics);
|
||||
// _physics.BodyType = BodyType.Kinematic; // TODO: Need to consider their original bodytype
|
||||
_pullJoint.CollideConnected = true;
|
||||
_pullJoint.Length = length * 0.75f;
|
||||
_pullJoint.MaxLength = length;
|
||||
}
|
||||
// Code here will not run if pulling a new object was attempted and failed because of the returns from the refactor.
|
||||
}
|
||||
@@ -212,6 +221,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 +261,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