using System.Collections.Generic;
using System.Numerics;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.ViewVariables;
namespace Robust.Shared.Physics.Systems;
public partial class SharedPhysicsSystem
{
[ViewVariables]
public Vector2 Gravity { get; private set; }
public void SetGravity(Vector2 value)
{
if (Gravity.Equals(value))
return;
Gravity = value;
// TODO: Network + datafield
}
// Box2D has a bunch of methods that work on worlds but in our case separate EntityManager instances are
// separate worlds so we can just treat the physics system as the world.
private bool _autoClearForces;
///
/// When substepping the client needs to know about the first position to use for lerping.
///
protected readonly Dictionary
LerpData = new();
// TODO:
// - Add test that movebuffer removes entities moved to nullspace.
// Previously we stored the WorldAABB of the proxy being moved and tracked state.
// The issue is that if something moves multiple times in a tick it can add up, plus it's also done on hotpaths such as physics.
// As such we defer it until we actually try and get contacts, then we can run them in parallel.
///
/// Keep a buffer of everything that moved in a tick. This will be used to check for physics contacts.
///
[ViewVariables]
internal readonly HashSet MoveBuffer = new();
///
/// Track moved grids to know if we need to run checks for them driving over entities.
///
[ViewVariables]
internal readonly HashSet MovedGrids = new();
///
/// All awake bodies in the game.
///
[ViewVariables]
public readonly HashSet> AwakeBodies = new();
///
/// Store last tick's invDT
///
private float _invDt0;
}