Force grids to be collidable (#3480)

This commit is contained in:
metalgearsloth
2022-11-14 21:38:53 +11:00
committed by GitHub
parent 54db524e53
commit 1068458beb
4 changed files with 17 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
namespace Robust.Shared.GameObjects;

View File

@@ -870,6 +870,7 @@ namespace Robust.Shared.Map
return;
// TODO: Move this to the component when we combine.
_entityManager.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>().WakeBody(GridEntityId);
_mapManager.OnGridBoundsChange(GridEntityId, this);
system?.RegenerateCollision(GridEntityId, chunkRectangles, removedChunks);
}

View File

@@ -355,7 +355,7 @@ public partial class SharedPhysicsSystem
{
if (body._awake == value)
return;
if (value && (body.BodyType == BodyType.Static || !body.CanCollide))
return;
@@ -541,6 +541,15 @@ public partial class SharedPhysicsSystem
body._sleepTime = value;
}
public bool WakeBody(EntityUid uid, PhysicsComponent? body = null, FixturesComponent? manager = null, bool force = false)
{
if (!Resolve(uid, ref body, ref manager))
return false;
WakeBody(body, manager, force);
return body._awake;
}
/// <summary>
/// Tries to enable the body and also set it awake.
/// </summary>

View File

@@ -31,8 +31,7 @@ namespace Robust.UnitTesting.Shared.Map
EntityUid? gridEnt1;
EntityUid? gridEnt2;
await server.WaitPost(() =>
{
await server.WaitPost(() => {
mapId = mapManager.CreateMap();
gridId1 = mapManager.CreateGrid(mapId);
gridId2 = mapManager.CreateGrid(mapId);
@@ -85,6 +84,9 @@ namespace Robust.UnitTesting.Shared.Map
var contact = node.Value;
node = node.Next;
if (!contact.IsTouching)
continue;
var bodyA = contact.FixtureA!.Body;
var bodyB = contact.FixtureB!.Body;