mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Remove client/server split on sharedphysicsmap (#3618)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Robust.Client.Physics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Client.GameObjects
|
||||
{
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Client.Physics
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedPhysicsMapComponent))]
|
||||
public sealed class PhysicsMapComponent : SharedPhysicsMapComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Robust.Client.Physics
|
||||
SimulateWorld(frameTime, _gameTiming.InPrediction);
|
||||
}
|
||||
|
||||
protected override void Cleanup(SharedPhysicsMapComponent component, float frameTime)
|
||||
protected override void Cleanup(PhysicsMapComponent component, float frameTime)
|
||||
{
|
||||
var toRemove = new List<PhysicsComponent>();
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Robust.Client.Physics
|
||||
base.Cleanup(component, frameTime);
|
||||
}
|
||||
|
||||
protected override void UpdateLerpData(SharedPhysicsMapComponent component, List<PhysicsComponent> bodies, EntityQuery<TransformComponent> xformQuery)
|
||||
protected override void UpdateLerpData(PhysicsMapComponent component, List<PhysicsComponent> bodies, EntityQuery<TransformComponent> xformQuery)
|
||||
{
|
||||
foreach (var body in bodies)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace Robust.Client.Physics
|
||||
/// <summary>
|
||||
/// Flush all of our lerping data.
|
||||
/// </summary>
|
||||
protected override void FinalStep(SharedPhysicsMapComponent component)
|
||||
protected override void FinalStep(PhysicsMapComponent component)
|
||||
{
|
||||
base.FinalStep(component);
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Robust.Server.Console.Commands
|
||||
|
||||
_map.SetMapPaused(mapId, false);
|
||||
var mapUid = _map.GetMapEntityIdOrThrow(mapId);
|
||||
_ent.GetComponent<SharedPhysicsMapComponent>(mapUid).Gravity = new Vector2(0, -9.8f);
|
||||
_ent.GetComponent<PhysicsMapComponent>(mapUid).Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
shell.ExecuteCommand("aghost");
|
||||
shell.ExecuteCommand($"tp 0 0 {mapId}");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Server.Physics;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Map.Events;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Server.GameObjects
|
||||
{
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Robust.Server.Physics
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedPhysicsMapComponent))]
|
||||
public sealed class PhysicsMapComponent : SharedPhysicsMapComponent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var fixtureQuery = GetEntityQuery<FixturesComponent>();
|
||||
var physicsMapQuery = GetEntityQuery<SharedPhysicsMapComponent>();
|
||||
var physicsMapQuery = GetEntityQuery<PhysicsMapComponent>();
|
||||
var xform = xformQuery.GetComponent(uid);
|
||||
var map = xform.MapUid;
|
||||
physicsMapQuery.TryGetComponent(map, out var physMap);
|
||||
@@ -105,10 +105,10 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void RemoveChildrenFromTerminatingBroadphase(TransformComponent xform,
|
||||
BroadphaseComponent component,
|
||||
SharedPhysicsMapComponent? map,
|
||||
PhysicsMapComponent? map,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<FixturesComponent> fixtureQuery,
|
||||
EntityQuery<SharedPhysicsMapComponent> physicsMapQuery)
|
||||
EntityQuery<PhysicsMapComponent> physicsMapQuery)
|
||||
{
|
||||
var childEnum = xform.ChildEnumerator;
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (!TryGetCurrentBroadphase(xform, out var broadphase))
|
||||
return;
|
||||
|
||||
if (!TryComp(xform.MapUid, out SharedPhysicsMapComponent? physMap))
|
||||
if (!TryComp(xform.MapUid, out PhysicsMapComponent? physMap))
|
||||
throw new InvalidOperationException();
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
@@ -210,7 +210,7 @@ namespace Robust.Shared.GameObjects
|
||||
AddOrMoveProxies(fixture, tree, broadphaseTransform, mapTransform, physMap.MoveBuffer);
|
||||
}
|
||||
|
||||
internal void DestroyProxies(Fixture fixture, TransformComponent xform, BroadphaseComponent broadphase, SharedPhysicsMapComponent? physicsMap)
|
||||
internal void DestroyProxies(Fixture fixture, TransformComponent xform, BroadphaseComponent broadphase, PhysicsMapComponent? physicsMap)
|
||||
{
|
||||
DebugTools.AssertNotNull(xform.Broadphase);
|
||||
DebugTools.Assert(xform.Broadphase!.Value.Uid == broadphase.Owner);
|
||||
@@ -272,7 +272,7 @@ namespace Robust.Shared.GameObjects
|
||||
var fixtures = Comp<FixturesComponent>(uid);
|
||||
if (old.CanCollide)
|
||||
{
|
||||
TryComp(old.MapUid, out SharedPhysicsMapComponent? physicsMap);
|
||||
TryComp(old.MapUid, out PhysicsMapComponent? physicsMap);
|
||||
RemoveBroadTree(broadphase, fixtures, old.Static, physicsMap);
|
||||
}
|
||||
else
|
||||
@@ -285,7 +285,7 @@ namespace Robust.Shared.GameObjects
|
||||
AddOrUpdateSundriesTree(old.Uid, broadphase, uid, xform, body.BodyType == BodyType.Static);
|
||||
}
|
||||
|
||||
private void RemoveBroadTree(BroadphaseComponent lookup, FixturesComponent manager, bool staticBody, SharedPhysicsMapComponent? map)
|
||||
private void RemoveBroadTree(BroadphaseComponent lookup, FixturesComponent manager, bool staticBody, PhysicsMapComponent? map)
|
||||
{
|
||||
var tree = staticBody ? lookup.StaticTree : lookup.DynamicTree;
|
||||
foreach (var fixture in manager.Fixtures.Values)
|
||||
@@ -294,7 +294,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
internal void DestroyProxies(Fixture fixture, IBroadPhase tree, SharedPhysicsMapComponent? map)
|
||||
internal void DestroyProxies(Fixture fixture, IBroadPhase tree, PhysicsMapComponent? map)
|
||||
{
|
||||
var buffer = map?.MoveBuffer;
|
||||
for (var i = 0; i < fixture.ProxyCount; i++)
|
||||
@@ -316,7 +316,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (broadphaseXform.MapID == MapId.Nullspace)
|
||||
return;
|
||||
|
||||
if (!TryComp(broadphaseXform.MapUid, out SharedPhysicsMapComponent? physMap))
|
||||
if (!TryComp(broadphaseXform.MapUid, out PhysicsMapComponent? physMap))
|
||||
throw new InvalidOperationException($"Physics Broadphase is missing physics map. {ToPrettyString(broadUid)}");
|
||||
|
||||
AddOrUpdatePhysicsTree(broadUid, broadphase, broadphaseXform, physMap, xform, body, fixtures, xformQuery);
|
||||
@@ -326,7 +326,7 @@ namespace Robust.Shared.GameObjects
|
||||
EntityUid broadUid,
|
||||
BroadphaseComponent broadphase,
|
||||
TransformComponent broadphaseXform,
|
||||
SharedPhysicsMapComponent physicsMap,
|
||||
PhysicsMapComponent physicsMap,
|
||||
TransformComponent xform,
|
||||
PhysicsComponent body,
|
||||
FixturesComponent manager,
|
||||
@@ -447,8 +447,8 @@ namespace Robust.Shared.GameObjects
|
||||
DebugTools.Assert(!newMap.IsValid() || HasComp<MapComponent>(newMap));
|
||||
DebugTools.Assert(!oldMap.IsValid() || HasComp<MapComponent>(oldMap));
|
||||
|
||||
var oldBuffer = CompOrNull<SharedPhysicsMapComponent>(oldMap)?.MoveBuffer;
|
||||
var newBuffer = CompOrNull<SharedPhysicsMapComponent>(newMap)?.MoveBuffer;
|
||||
var oldBuffer = CompOrNull<PhysicsMapComponent>(oldMap)?.MoveBuffer;
|
||||
var newBuffer = CompOrNull<PhysicsMapComponent>(newMap)?.MoveBuffer;
|
||||
|
||||
var enumerator = args.Component.ChildEnumerator;
|
||||
while (enumerator.MoveNext(out var child))
|
||||
@@ -516,7 +516,7 @@ namespace Robust.Shared.GameObjects
|
||||
var fixturesQuery = GetEntityQuery<FixturesComponent>();
|
||||
|
||||
BroadphaseComponent? oldBroadphase = null;
|
||||
SharedPhysicsMapComponent? oldPhysMap = null;
|
||||
PhysicsMapComponent? oldPhysMap = null;
|
||||
if (xform.Broadphase != null)
|
||||
{
|
||||
if (!xform.Broadphase.Value.IsValid())
|
||||
@@ -570,7 +570,7 @@ namespace Robust.Shared.GameObjects
|
||||
var contQuery = GetEntityQuery<ContainerManagerComponent>();
|
||||
|
||||
var newBroadphaseXform = xformQuery.GetComponent(newBroadphase.Owner);
|
||||
if (!TryComp(newBroadphaseXform.MapUid, out SharedPhysicsMapComponent? physMap))
|
||||
if (!TryComp(newBroadphaseXform.MapUid, out PhysicsMapComponent? physMap))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Broadphase's map is missing a physics map comp. Broadphase: {ToPrettyString(newBroadphase.Owner)}");
|
||||
@@ -656,7 +656,7 @@ namespace Robust.Shared.GameObjects
|
||||
bool recursive)
|
||||
{
|
||||
var broadphaseXform = xformQuery.GetComponent(broadphase.Owner);
|
||||
if (!TryComp(broadphaseXform.MapUid, out SharedPhysicsMapComponent? physMap))
|
||||
if (!TryComp(broadphaseXform.MapUid, out PhysicsMapComponent? physMap))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Broadphase's map is missing a physics map comp. Broadphase: {ToPrettyString(broadphase.Owner)}");
|
||||
@@ -681,7 +681,7 @@ namespace Robust.Shared.GameObjects
|
||||
EntityUid broadUid,
|
||||
BroadphaseComponent broadphase,
|
||||
TransformComponent broadphaseXform,
|
||||
SharedPhysicsMapComponent physicsMap,
|
||||
PhysicsMapComponent physicsMap,
|
||||
EntityUid uid,
|
||||
TransformComponent xform,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
@@ -742,7 +742,7 @@ namespace Robust.Shared.GameObjects
|
||||
var physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||
var fixturesQuery = GetEntityQuery<FixturesComponent>();
|
||||
|
||||
SharedPhysicsMapComponent? physMap = null;
|
||||
PhysicsMapComponent? physMap = null;
|
||||
if (xform.Broadphase!.Value.MapUid is { Valid: true } map && !TryComp(map, out physMap))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
@@ -758,7 +758,7 @@ namespace Robust.Shared.GameObjects
|
||||
private void RemoveFromEntityTree(
|
||||
EntityUid broadUid,
|
||||
BroadphaseComponent broadphase,
|
||||
ref SharedPhysicsMapComponent? physicsMap,
|
||||
ref PhysicsMapComponent? physicsMap,
|
||||
EntityUid uid,
|
||||
TransformComponent xform,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Robust.Shared.Physics.Controllers
|
||||
/// <param name="prediction"></param>
|
||||
/// <param name="mapComponent"></param>
|
||||
/// <param name="frameTime"></param>
|
||||
public virtual void UpdateBeforeMapSolve(bool prediction, SharedPhysicsMapComponent mapComponent, float frameTime) {}
|
||||
public virtual void UpdateBeforeMapSolve(bool prediction, PhysicsMapComponent mapComponent, float frameTime) {}
|
||||
|
||||
/// <summary>
|
||||
/// Run after a particular map finishes.
|
||||
@@ -101,6 +101,6 @@ namespace Robust.Shared.Physics.Controllers
|
||||
/// <param name="prediction"></param>
|
||||
/// <param name="mapComponent"></param>
|
||||
/// <param name="frameTime"></param>
|
||||
public virtual void UpdateAfterMapSolve(bool prediction, SharedPhysicsMapComponent mapComponent, float frameTime) {}
|
||||
public virtual void UpdateAfterMapSolve(bool prediction, PhysicsMapComponent mapComponent, float frameTime) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
@@ -34,7 +34,8 @@ using PhysicsComponent = Robust.Shared.Physics.Components.PhysicsComponent;
|
||||
|
||||
namespace Robust.Shared.Physics.Dynamics
|
||||
{
|
||||
public abstract class SharedPhysicsMapComponent : Component
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class PhysicsMapComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
@@ -141,10 +142,10 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
public readonly struct PhysicsUpdateBeforeMapSolveEvent
|
||||
{
|
||||
public readonly bool Prediction;
|
||||
public readonly SharedPhysicsMapComponent MapComponent;
|
||||
public readonly PhysicsMapComponent MapComponent;
|
||||
public readonly float DeltaTime;
|
||||
|
||||
public PhysicsUpdateBeforeMapSolveEvent(bool prediction, SharedPhysicsMapComponent mapComponent, float deltaTime)
|
||||
public PhysicsUpdateBeforeMapSolveEvent(bool prediction, PhysicsMapComponent mapComponent, float deltaTime)
|
||||
{
|
||||
Prediction = prediction;
|
||||
MapComponent = mapComponent;
|
||||
@@ -156,10 +157,10 @@ namespace Robust.Shared.Physics.Dynamics
|
||||
public readonly struct PhysicsUpdateAfterMapSolveEvent
|
||||
{
|
||||
public readonly bool Prediction;
|
||||
public readonly SharedPhysicsMapComponent MapComponent;
|
||||
public readonly PhysicsMapComponent MapComponent;
|
||||
public readonly float DeltaTime;
|
||||
|
||||
public PhysicsUpdateAfterMapSolveEvent(bool prediction, SharedPhysicsMapComponent mapComponent, float deltaTime)
|
||||
public PhysicsUpdateAfterMapSolveEvent(bool prediction, PhysicsMapComponent mapComponent, float deltaTime)
|
||||
{
|
||||
Prediction = prediction;
|
||||
MapComponent = mapComponent;
|
||||
@@ -200,7 +200,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
if (_lookup.TryGetCurrentBroadphase(xform, out var broadphase))
|
||||
{
|
||||
var map = Transform(broadphase.Owner).MapUid;
|
||||
if (TryComp<SharedPhysicsMapComponent>(map, out var physicsMap))
|
||||
if (TryComp<PhysicsMapComponent>(map, out var physicsMap))
|
||||
{
|
||||
foreach (var contact in fixture.Contacts.Values.ToArray())
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
/// Check the AABB for each moved broadphase fixture and add any colliding entities to the movebuffer in case.
|
||||
/// </summary>
|
||||
private void FindGridContacts(
|
||||
SharedPhysicsMapComponent component,
|
||||
PhysicsMapComponent component,
|
||||
MapId mapId,
|
||||
HashSet<MapGridComponent> movedGrids,
|
||||
Dictionary<FixtureProxy, Box2> gridMoveBuffer,
|
||||
@@ -135,7 +135,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
[Obsolete("Use the overload with SharedPhysicsMapComponent")]
|
||||
internal void FindNewContacts(MapId mapId)
|
||||
{
|
||||
if (!TryComp<SharedPhysicsMapComponent>(_mapManager.GetMapEntityId(mapId), out var physicsMap))
|
||||
if (!TryComp<PhysicsMapComponent>(_mapManager.GetMapEntityId(mapId), out var physicsMap))
|
||||
return;
|
||||
|
||||
FindNewContacts(physicsMap, mapId);
|
||||
@@ -144,7 +144,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
/// <summary>
|
||||
/// Go through every single created, moved, or touched proxy on the map and try to find any new contacts that should be created.
|
||||
/// </summary>
|
||||
internal void FindNewContacts(SharedPhysicsMapComponent component, MapId mapId)
|
||||
internal void FindNewContacts(PhysicsMapComponent component, MapId mapId)
|
||||
{
|
||||
var moveBuffer = component.MoveBuffer;
|
||||
var movedGrids = _mapManager.GetMovedGrids(mapId);
|
||||
@@ -438,7 +438,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
|
||||
private void AddToMoveBuffer(MapId mapId, FixtureProxy proxy, Box2 aabb)
|
||||
{
|
||||
if (!TryComp<SharedPhysicsMapComponent>(_mapManager.GetMapEntityId(mapId), out var physicsMap))
|
||||
if (!TryComp<PhysicsMapComponent>(_mapManager.GetMapEntityId(mapId), out var physicsMap))
|
||||
return;
|
||||
|
||||
DebugTools.Assert(proxy.Fixture.Body.CanCollide);
|
||||
|
||||
@@ -171,7 +171,7 @@ public partial class SharedPhysicsSystem
|
||||
xform ??= Transform(body.Owner);
|
||||
mapId ??= xform.MapID;
|
||||
|
||||
if (!TryComp<SharedPhysicsMapComponent>(MapManager.GetMapEntityId(mapId.Value), out var map))
|
||||
if (!TryComp<PhysicsMapComponent>(MapManager.GetMapEntityId(mapId.Value), out var map))
|
||||
{
|
||||
DebugTools.Assert("Attempted to destroy contacts, but entity has no physics map!");
|
||||
return;
|
||||
@@ -180,7 +180,7 @@ public partial class SharedPhysicsSystem
|
||||
DestroyContacts(body, map);
|
||||
}
|
||||
|
||||
public void DestroyContacts(PhysicsComponent body, SharedPhysicsMapComponent physMap)
|
||||
public void DestroyContacts(PhysicsComponent body, PhysicsMapComponent physMap)
|
||||
{
|
||||
if (body.Contacts.Count == 0) return;
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
/// <summary>
|
||||
/// Where the magic happens.
|
||||
/// </summary>
|
||||
public void Step(SharedPhysicsMapComponent component, float frameTime, bool prediction)
|
||||
public void Step(PhysicsMapComponent component, float frameTime, bool prediction)
|
||||
{
|
||||
// Box2D does this at the end of a step and also here when there's a fixture update.
|
||||
// Given external stuff can move bodies we'll just do this here.
|
||||
@@ -308,7 +308,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
component._invDt0 = invDt;
|
||||
}
|
||||
|
||||
private void ClearForces(SharedPhysicsMapComponent component)
|
||||
private void ClearForces(PhysicsMapComponent component)
|
||||
{
|
||||
foreach (var body in component.AwakeBodies)
|
||||
{
|
||||
@@ -318,7 +318,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void Solve(SharedPhysicsMapComponent component, float frameTime, float dtRatio, float invDt, bool prediction)
|
||||
private void Solve(PhysicsMapComponent component, float frameTime, float dtRatio, float invDt, bool prediction)
|
||||
{
|
||||
var contactNode = component.ContactManager._activeContacts.First;
|
||||
|
||||
@@ -512,7 +512,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
island.BrokenJoints.Clear();
|
||||
}
|
||||
|
||||
protected virtual void Cleanup(SharedPhysicsMapComponent component, float frameTime)
|
||||
protected virtual void Cleanup(PhysicsMapComponent component, float frameTime)
|
||||
{
|
||||
foreach (var body in _islandSet)
|
||||
{
|
||||
@@ -531,7 +531,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
_awakeBodyList.Clear();
|
||||
}
|
||||
|
||||
private void SolveIslands(SharedPhysicsMapComponent component, List<IslandData> islands, float frameTime, float dtRatio, float invDt, bool prediction)
|
||||
private void SolveIslands(PhysicsMapComponent component, List<IslandData> islands, float frameTime, float dtRatio, float invDt, bool prediction)
|
||||
{
|
||||
var iBegin = 0;
|
||||
var gravity = component.Gravity;
|
||||
@@ -634,7 +634,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
/// If this is the first time a body has been updated this tick update its position for lerping.
|
||||
/// Due to substepping we have to check it every time.
|
||||
/// </summary>
|
||||
protected virtual void UpdateLerpData(SharedPhysicsMapComponent component, List<PhysicsComponent> bodies, EntityQuery<TransformComponent> xformQuery)
|
||||
protected virtual void UpdateLerpData(PhysicsMapComponent component, List<PhysicsComponent> bodies, EntityQuery<TransformComponent> xformQuery)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ namespace Robust.Shared.Physics.Systems
|
||||
SubscribeLocalEvent<CollisionChangeEvent>(OnCollisionChange);
|
||||
SubscribeLocalEvent<PhysicsComponent, EntGotRemovedFromContainerMessage>(HandleContainerRemoved);
|
||||
SubscribeLocalEvent<EntParentChangedMessage>(OnParentChange);
|
||||
SubscribeLocalEvent<SharedPhysicsMapComponent, ComponentInit>(HandlePhysicsMapInit);
|
||||
SubscribeLocalEvent<SharedPhysicsMapComponent, ComponentRemove>(HandlePhysicsMapRemove);
|
||||
SubscribeLocalEvent<PhysicsMapComponent, ComponentInit>(HandlePhysicsMapInit);
|
||||
SubscribeLocalEvent<PhysicsMapComponent, ComponentRemove>(HandlePhysicsMapRemove);
|
||||
SubscribeLocalEvent<PhysicsComponent, ComponentInit>(OnPhysicsInit);
|
||||
SubscribeLocalEvent<PhysicsComponent, ComponentRemove>(OnPhysicsRemove);
|
||||
SubscribeLocalEvent<PhysicsComponent, ComponentGetState>(OnPhysicsGetState);
|
||||
@@ -112,7 +112,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePhysicsMapInit(EntityUid uid, SharedPhysicsMapComponent component, ComponentInit args)
|
||||
private void HandlePhysicsMapInit(EntityUid uid, PhysicsMapComponent component, ComponentInit args)
|
||||
{
|
||||
_deps.InjectDependencies(component);
|
||||
component.Physics = this;
|
||||
@@ -126,7 +126,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
|
||||
private void OnAutoClearChange(bool value)
|
||||
{
|
||||
var enumerator = AllEntityQuery<SharedPhysicsMapComponent>();
|
||||
var enumerator = AllEntityQuery<PhysicsMapComponent>();
|
||||
|
||||
while (enumerator.MoveNext(out var comp))
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
_substeps = (int)Math.Ceiling(targetMinTickrate / serverTickrate);
|
||||
}
|
||||
|
||||
private void HandlePhysicsMapRemove(EntityUid uid, SharedPhysicsMapComponent component, ComponentRemove args)
|
||||
private void HandlePhysicsMapRemove(EntityUid uid, PhysicsMapComponent component, ComponentRemove args)
|
||||
{
|
||||
// THis entity might be getting deleted before ever having been initialized.
|
||||
if (component.ContactManager == null)
|
||||
@@ -194,8 +194,8 @@ namespace Robust.Shared.Physics.Systems
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var jointQuery = GetEntityQuery<JointComponent>();
|
||||
|
||||
TryComp(MapManager.GetMapEntityId(oldMapId), out SharedPhysicsMapComponent? oldMap);
|
||||
TryComp(MapManager.GetMapEntityId(newMapId), out SharedPhysicsMapComponent? newMap);
|
||||
TryComp(MapManager.GetMapEntityId(oldMapId), out PhysicsMapComponent? oldMap);
|
||||
TryComp(MapManager.GetMapEntityId(newMapId), out PhysicsMapComponent? newMap);
|
||||
|
||||
RecursiveMapUpdate(xform, body, newMap, oldMap, bodyQuery, xformQuery, jointQuery);
|
||||
}
|
||||
@@ -206,8 +206,8 @@ namespace Robust.Shared.Physics.Systems
|
||||
private void RecursiveMapUpdate(
|
||||
TransformComponent xform,
|
||||
PhysicsComponent? body,
|
||||
SharedPhysicsMapComponent? newMap,
|
||||
SharedPhysicsMapComponent? oldMap,
|
||||
PhysicsMapComponent? newMap,
|
||||
PhysicsMapComponent? oldMap,
|
||||
EntityQuery<PhysicsComponent> bodyQuery,
|
||||
EntityQuery<TransformComponent> xformQuery,
|
||||
EntityQuery<JointComponent> jointQuery)
|
||||
@@ -276,7 +276,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
return;
|
||||
|
||||
EntityUid tempQualifier = MapManager.GetMapEntityId(mapId);
|
||||
EntityManager.GetComponent<SharedPhysicsMapComponent>(tempQualifier).AddAwakeBody(@event.Body);
|
||||
EntityManager.GetComponent<PhysicsMapComponent>(tempQualifier).AddAwakeBody(@event.Body);
|
||||
}
|
||||
|
||||
private void OnSleep(ref PhysicsSleepEvent @event)
|
||||
@@ -287,7 +287,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
return;
|
||||
|
||||
EntityUid tempQualifier = MapManager.GetMapEntityId(mapId);
|
||||
EntityManager.GetComponent<SharedPhysicsMapComponent>(tempQualifier).RemoveSleepBody(@event.Body);
|
||||
EntityManager.GetComponent<PhysicsMapComponent>(tempQualifier).RemoveSleepBody(@event.Body);
|
||||
}
|
||||
|
||||
private void HandleContainerRemoved(EntityUid uid, PhysicsComponent physics, EntGotRemovedFromContainerMessage message)
|
||||
@@ -316,7 +316,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
var updateBeforeSolve = new PhysicsUpdateBeforeSolveEvent(prediction, frameTime);
|
||||
RaiseLocalEvent(ref updateBeforeSolve);
|
||||
|
||||
var enumerator = AllEntityQuery<SharedPhysicsMapComponent>();
|
||||
var enumerator = AllEntityQuery<PhysicsMapComponent>();
|
||||
|
||||
while (enumerator.MoveNext(out var comp))
|
||||
{
|
||||
@@ -329,7 +329,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
// On last substep (or main step where no substeps occured) we'll update all of the lerp data.
|
||||
if (i == _substeps - 1)
|
||||
{
|
||||
enumerator = AllEntityQuery<SharedPhysicsMapComponent>();
|
||||
enumerator = AllEntityQuery<PhysicsMapComponent>();
|
||||
|
||||
while (enumerator.MoveNext(out var comp))
|
||||
{
|
||||
@@ -342,7 +342,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void FinalStep(SharedPhysicsMapComponent component)
|
||||
protected virtual void FinalStep(PhysicsMapComponent component)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Robust.UnitTesting
|
||||
compFactory.RegisterClass<MetaDataComponent>();
|
||||
}
|
||||
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(SharedPhysicsMapComponent)))
|
||||
if (!compFactory.AllRegisteredTypes.Contains(typeof(PhysicsMapComponent)))
|
||||
{
|
||||
compFactory.RegisterClass<PhysicsMapComponent>();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Server.Physics;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -39,6 +39,7 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Threading;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Server.Replays;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Replays;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ public sealed class Broadphase_Test
|
||||
var AssertMap = (EntityUid map, EntityUid otherMap) =>
|
||||
{
|
||||
var broadphase = entManager.GetComponent<BroadphaseComponent>(map);
|
||||
var physMap = entManager.GetComponent<SharedPhysicsMapComponent>(map);
|
||||
var physMap = entManager.GetComponent<PhysicsMapComponent>(map);
|
||||
Assert.That(parentXform.ParentUid == map);
|
||||
Assert.That(parentXform.MapUid == map);
|
||||
Assert.That(childXform.MapUid == map);
|
||||
@@ -240,7 +240,7 @@ public sealed class Broadphase_Test
|
||||
Assert.That(parentXform.Broadphase == new BroadphaseData(map, default, false, false));
|
||||
Assert.That(childXform.Broadphase == new BroadphaseData(map, map, true, true));
|
||||
Assert.That(physMap.MoveBuffer.ContainsKey(childFixtures.Fixtures.First().Value.Proxies.First()));
|
||||
var otherPhysMap = entManager.GetComponent<SharedPhysicsMapComponent>(otherMap);
|
||||
var otherPhysMap = entManager.GetComponent<PhysicsMapComponent>(otherMap);
|
||||
Assert.That(otherPhysMap.MoveBuffer.Count == 0);
|
||||
};
|
||||
AssertMap(mapA, mapB);
|
||||
@@ -263,7 +263,7 @@ public sealed class Broadphase_Test
|
||||
var AssertGrid = (EntityUid grid, EntityUid map, EntityUid otherMap) =>
|
||||
{
|
||||
var broadphase = entManager.GetComponent<BroadphaseComponent>(grid);
|
||||
var physMap = entManager.GetComponent<SharedPhysicsMapComponent>(map);
|
||||
var physMap = entManager.GetComponent<PhysicsMapComponent>(map);
|
||||
var gridXform = entManager.GetComponent<TransformComponent>(grid);
|
||||
Assert.That(gridXform.ParentUid == map);
|
||||
Assert.That(gridXform.MapUid == map);
|
||||
@@ -275,7 +275,7 @@ public sealed class Broadphase_Test
|
||||
Assert.That(parentXform.Broadphase == new BroadphaseData(grid, default, false, false));
|
||||
Assert.That(childXform.Broadphase == new BroadphaseData(grid, map, true, true));
|
||||
Assert.That(physMap.MoveBuffer.ContainsKey(childFixtures.Fixtures.First().Value.Proxies.First()));
|
||||
var otherPhysMap = entManager.GetComponent<SharedPhysicsMapComponent>(otherMap);
|
||||
var otherPhysMap = entManager.GetComponent<PhysicsMapComponent>(otherMap);
|
||||
Assert.That(otherPhysMap.MoveBuffer.Count == 0);
|
||||
};
|
||||
AssertGrid(gridA, mapA, mapB);
|
||||
|
||||
@@ -62,7 +62,7 @@ public sealed class GridMovement_Test : RobustIntegrationTest
|
||||
|
||||
// Alright just a quick validation then we start the actual damn test.
|
||||
|
||||
var physicsMap = entManager.GetComponent<SharedPhysicsMapComponent>(mapManager.GetMapEntityId(mapId));
|
||||
var physicsMap = entManager.GetComponent<PhysicsMapComponent>(mapManager.GetMapEntityId(mapId));
|
||||
physSystem.Step(physicsMap, 0.001f, false);
|
||||
|
||||
Assert.That(onGridBody.ContactCount, Is.EqualTo(0));
|
||||
|
||||
@@ -12,7 +12,7 @@ using Robust.UnitTesting.Server;
|
||||
|
||||
namespace Robust.UnitTesting.Shared.Physics;
|
||||
|
||||
[TestFixture, TestOf(typeof(SharedPhysicsMapComponent))]
|
||||
[TestFixture, TestOf(typeof(PhysicsMapComponent))]
|
||||
public sealed class PhysicsMap_Test
|
||||
{
|
||||
/// <summary>
|
||||
@@ -32,8 +32,8 @@ public sealed class PhysicsMap_Test
|
||||
var mapUid = mapManager.GetMapEntityId(mapId);
|
||||
var mapUid2 = mapManager.GetMapEntityId(mapId2);
|
||||
|
||||
var physicsMap = entManager.GetComponent<SharedPhysicsMapComponent>(mapUid);
|
||||
var physicsMap2 = entManager.GetComponent<SharedPhysicsMapComponent>(mapUid2);
|
||||
var physicsMap = entManager.GetComponent<PhysicsMapComponent>(mapUid);
|
||||
var physicsMap2 = entManager.GetComponent<PhysicsMapComponent>(mapUid2);
|
||||
|
||||
var parent = entManager.SpawnEntity(null, new MapCoordinates(Vector2.Zero, mapId));
|
||||
var parentXform = entManager.GetComponent<TransformComponent>(parent);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Robust.UnitTesting.Shared.Physics
|
||||
mapId = mapManager.CreateMap();
|
||||
|
||||
EntityUid tempQualifier2 = mapManager.GetMapEntityId(mapId);
|
||||
entityManager.GetComponent<SharedPhysicsMapComponent>(tempQualifier2).Gravity = new Vector2(0, -9.8f);
|
||||
entityManager.GetComponent<PhysicsMapComponent>(tempQualifier2).Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
EntityUid tempQualifier = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
|
||||
var ground = entityManager.AddComponent<PhysicsComponent>(tempQualifier);
|
||||
@@ -183,7 +183,7 @@ namespace Robust.UnitTesting.Shared.Physics
|
||||
{
|
||||
mapId = mapManager.CreateMap();
|
||||
EntityUid tempQualifier2 = mapManager.GetMapEntityId(mapId);
|
||||
entityManager.GetComponent<SharedPhysicsMapComponent>(tempQualifier2).Gravity = new Vector2(0, -9.8f);
|
||||
entityManager.GetComponent<PhysicsMapComponent>(tempQualifier2).Gravity = new Vector2(0, -9.8f);
|
||||
|
||||
EntityUid tempQualifier = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
|
||||
var ground = entityManager.AddComponent<PhysicsComponent>(tempQualifier);
|
||||
|
||||
Reference in New Issue
Block a user