* 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:
metalgearsloth
2021-03-01 03:11:29 +11:00
committed by GitHub
parent 9deee05279
commit 3e64fd56a1
211 changed files with 2602 additions and 2562 deletions

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics.Shapes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -38,7 +39,6 @@ namespace Content.Server.GameObjects.Components.Singularity
_energy = value;
if (_energy <= 0)
{
if(_singularityController != null) _singularityController.LinearVelocity = Vector2.Zero;
_spriteComponent?.LayerSetVisible(0, false);
Owner.Delete();
@@ -75,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Singularity
_spriteComponent?.LayerSetRSI(0, "Effects/Singularity/singularity_" + _level + ".rsi");
_spriteComponent?.LayerSetState(0, "singularity_" + _level);
if(_collidableComponent != null && _collidableComponent.PhysicsShapes.Any() && _collidableComponent.PhysicsShapes[0] is PhysShapeCircle circle)
if(_collidableComponent != null && _collidableComponent.Fixtures.Any() && _collidableComponent.Fixtures[0].Shape is PhysShapeCircle circle)
{
circle.Radius = _level - 0.5f;
}
@@ -95,7 +95,6 @@ namespace Content.Server.GameObjects.Components.Singularity
_ => 0
};
private SingularityController? _singularityController;
private PhysicsComponent? _collidableComponent;
private SpriteComponent? _spriteComponent;
private RadiationPulseComponent? _radiationPulseComponent;
@@ -129,9 +128,6 @@ namespace Content.Server.GameObjects.Components.Singularity
Logger.Error("SingularityComponent was spawned without SpriteComponent");
}
_singularityController = _collidableComponent?.EnsureController<SingularityController>();
if(_singularityController!=null)_singularityController.ControlledComponent = _collidableComponent;
if (!Owner.TryGetComponent(out _radiationPulseComponent))
{
Logger.Error("SingularityComponent was spawned without RadiationPulseComponent");
@@ -140,60 +136,18 @@ namespace Content.Server.GameObjects.Components.Singularity
Level = 1;
}
public void Update()
public void Update(int seconds)
{
Energy -= EnergyDrain;
if(Level == 1) return;
//pushing
var pushVector = new Vector2((_random.Next(-10, 10)), _random.Next(-10, 10));
while (pushVector.X == 0 && pushVector.Y == 0)
{
pushVector = new Vector2((_random.Next(-10, 10)), _random.Next(-10, 10));
}
_singularityController?.Push(pushVector.Normalized, 2);
Energy -= EnergyDrain * seconds;
}
private readonly List<IEntity> _previousPulledEntities = new();
public void CleanupPulledEntities()
void ICollideBehavior.CollideWith(IPhysBody ourBody, IPhysBody otherBody)
{
foreach (var previousPulledEntity in _previousPulledEntities)
var otherEntity = otherBody.Entity;
if (otherEntity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
{
if(previousPulledEntity.Deleted) continue;
if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>();
controller.StopPull();
}
_previousPulledEntities.Clear();
}
public void PullUpdate()
{
CleanupPulledEntities();
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
foreach (var entity in entitiesToPull)
{
if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
if (entity.HasComponent<GhostComponent>()) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>();
if(Owner.Transform.Coordinates.EntityId != entity.Transform.Coordinates.EntityId) continue;
var vec = (Owner.Transform.Coordinates - entity.Transform.Coordinates).Position;
if (vec == Vector2.Zero) continue;
var speed = 10 / vec.Length * Level;
controller.Pull(vec.Normalized, speed);
_previousPulledEntities.Add(entity);
}
}
void ICollideBehavior.CollideWith(IEntity entity)
{
if (_collidableComponent == null) return; //how did it even collide then? :D
if (entity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
{
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(((IPhysBody) _collidableComponent).WorldAABB))
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourBody.GetWorldAABB()))
{
mapGridComponent.Grid.SetTile(tile.GridIndices, Tile.Empty);
Energy++;
@@ -201,14 +155,14 @@ namespace Content.Server.GameObjects.Components.Singularity
return;
}
if (entity.HasComponent<ContainmentFieldComponent>() || (entity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var component) && component.CanRepell(Owner)))
if (otherEntity.HasComponent<ContainmentFieldComponent>() || (otherEntity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var component) && component.CanRepell(Owner)))
{
return;
}
if (entity.IsInContainer()) return;
if (otherEntity.IsInContainer()) return;
entity.Delete();
otherEntity.Delete();
Energy++;
}
@@ -216,7 +170,6 @@ namespace Content.Server.GameObjects.Components.Singularity
{
_playingSound?.Stop();
_audioSystem.PlayAtCoords("/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates);
CleanupPulledEntities();
base.OnRemove();
}
}