mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 10:37:05 +02:00
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Dynamics;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Shared.Physics.Systems;
|
|
|
|
public partial class SharedPhysicsSystem
|
|
{
|
|
#region AddRemove
|
|
|
|
internal void AddAwakeBody(EntityUid uid, PhysicsComponent body, PhysicsMapComponent? map = null)
|
|
{
|
|
if (map == null)
|
|
return;
|
|
|
|
if (!body.CanCollide)
|
|
{
|
|
Log.Error($"Tried to add non-colliding {ToPrettyString(uid)} as an awake body to map!");
|
|
DebugTools.Assert(false);
|
|
return;
|
|
}
|
|
|
|
if (body.BodyType == BodyType.Static)
|
|
{
|
|
Log.Error($"Tried to add static body {ToPrettyString(uid)} as an awake body to map!");
|
|
DebugTools.Assert(false);
|
|
return;
|
|
}
|
|
|
|
DebugTools.Assert(body.Awake);
|
|
map.AwakeBodies.Add(body);
|
|
}
|
|
|
|
internal void AddAwakeBody(EntityUid uid, PhysicsComponent body, EntityUid mapUid, PhysicsMapComponent? map = null)
|
|
{
|
|
Resolve(mapUid, ref map, false);
|
|
AddAwakeBody(uid, body, map);
|
|
}
|
|
|
|
internal void RemoveSleepBody(EntityUid uid, PhysicsComponent body, PhysicsMapComponent? map = null)
|
|
{
|
|
map?.AwakeBodies.Remove(body);
|
|
}
|
|
|
|
internal void RemoveSleepBody(EntityUid uid, PhysicsComponent body, EntityUid mapUid, PhysicsMapComponent? map = null)
|
|
{
|
|
Resolve(mapUid, ref map, false);
|
|
RemoveSleepBody(uid, body, map);
|
|
}
|
|
|
|
#endregion
|
|
}
|