Content changes for grid splitting (#7645) (#7746)

Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
This commit is contained in:
metalgearsloth
2022-04-24 13:54:25 +10:00
committed by GitHub
parent a2da1580d0
commit 72da2db62d
35 changed files with 291 additions and 151 deletions

View File

@@ -52,8 +52,11 @@ namespace Content.Shared.Decals
}
}
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) => EntityManager
.GetComponent<DecalGridComponent>(MapManager.GetGrid(gridId).GridEntityId).ChunkCollection;
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(EntityUid gridEuid) =>
Comp<DecalGridComponent>(gridEuid).ChunkCollection;
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) =>
Comp<DecalGridComponent>(MapManager.GetGridEuid(gridId)).ChunkCollection;
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(EntityUid gridEuid) => DecalGridChunkCollection(gridEuid).ChunkCollection;
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(GridId gridId) => DecalGridChunkCollection(gridId).ChunkCollection;
protected virtual void DirtyChunk(GridId id, Vector2i chunkIndices) {}

View File

@@ -164,7 +164,7 @@ namespace Content.Shared.Maps
if (!GetWorldTileBox(turf, out var worldBox))
return Enumerable.Empty<EntityUid>();
return lookupSystem.GetEntitiesIntersecting(turf.MapIndex, worldBox, flags);
return lookupSystem.GetEntitiesIntersecting(turf.GridIndex, worldBox, flags);
}
/// <summary>
@@ -191,22 +191,24 @@ namespace Content.Shared.Maps
/// <summary>
/// Checks if a turf has something dense on it.
/// </summary>
public static bool IsBlockedTurf(this TileRef turf, bool filterMobs, SharedPhysicsSystem? physics = null, IEntitySystemManager? entSysMan = null)
public static bool IsBlockedTurf(this TileRef turf, bool filterMobs, EntityLookupSystem? physics = null, IEntitySystemManager? entSysMan = null)
{
// TODO: Deprecate this with entitylookup.
if (physics == null)
{
// Slow path, resolve dependencies.
IoCManager.Resolve(ref entSysMan);
entSysMan.Resolve(ref physics);
physics = entSysMan.GetEntitySystem<EntityLookupSystem>();
}
if (!GetWorldTileBox(turf, out var worldBox))
return false;
var query = physics.GetCollidingEntities(turf.MapIndex, in worldBox);
var entManager = IoCManager.Resolve<IEntityManager>();
var query = physics.GetEntitiesIntersecting(turf.GridIndex, worldBox);
foreach (var body in query)
foreach (var ent in query)
{
var body = entManager.GetComponent<PhysicsComponent>(ent);
if (body.CanCollide && body.Hard && (body.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
return true;

View File

@@ -26,6 +26,7 @@ namespace Content.Shared.SubFloor
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
SubscribeLocalEvent<SubFloorHideComponent, ComponentStartup>(OnSubFloorStarted);
SubscribeLocalEvent<SubFloorHideComponent, ComponentShutdown>(OnSubFloorTerminating);
// Like 80% sure this doesn't need to handle re-anchoring.
SubscribeLocalEvent<SubFloorHideComponent, AnchorStateChangedEvent>(HandleAnchorChanged);
SubscribeLocalEvent<SubFloorHideComponent, GettingInteractedWithAttemptEvent>(OnInteractionAttempt);
}

View File

@@ -40,7 +40,7 @@ public sealed class TrayScannerSystem : EntitySystem
return;
scanner.Enabled = enabled;
scanner.Dirty();
Dirty(scanner);
if (scanner.Enabled)
_activeScanners.Add(uid);

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.Throwing
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ThrownItemComponent, PhysicsSleepMessage>(HandleSleep);
SubscribeLocalEvent<ThrownItemComponent, PhysicsSleepEvent>(OnSleep);
SubscribeLocalEvent<ThrownItemComponent, StartCollideEvent>(HandleCollision);
SubscribeLocalEvent<ThrownItemComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<ThrownItemComponent, ThrownEvent>(ThrowItem);
@@ -87,7 +87,7 @@ namespace Content.Shared.Throwing
}
}
private void HandleSleep(EntityUid uid, ThrownItemComponent thrownItem, PhysicsSleepMessage message)
private void OnSleep(EntityUid uid, ThrownItemComponent thrownItem, ref PhysicsSleepEvent @event)
{
StopThrow(uid, thrownItem);
}