Content changes for SetTiles change (#37229)
* Content changes for SetTiles change * Retest with new engine changes * Derp * Update for new engine PR changes
This commit is contained in:
@@ -160,38 +160,41 @@ namespace Content.Server.Decals
|
||||
|
||||
private void OnTileChanged(ref TileChangedEvent args)
|
||||
{
|
||||
if (!args.NewTile.IsSpace(_tileDefMan))
|
||||
return;
|
||||
|
||||
if (!TryComp(args.Entity, out DecalGridComponent? grid))
|
||||
return;
|
||||
|
||||
var indices = GetChunkIndices(args.NewTile.GridIndices);
|
||||
var toDelete = new HashSet<uint>();
|
||||
if (!grid.ChunkCollection.ChunkCollection.TryGetValue(indices, out var chunk))
|
||||
return;
|
||||
|
||||
foreach (var (uid, decal) in chunk.Decals)
|
||||
foreach (var change in args.Changes)
|
||||
{
|
||||
if (new Vector2((int) Math.Floor(decal.Coordinates.X), (int) Math.Floor(decal.Coordinates.Y)) ==
|
||||
args.NewTile.GridIndices)
|
||||
if (!change.NewTile.IsSpace(_tileDefMan))
|
||||
return;
|
||||
|
||||
if (!TryComp(args.Entity, out DecalGridComponent? grid))
|
||||
return;
|
||||
|
||||
var indices = GetChunkIndices(change.GridIndices);
|
||||
var toDelete = new HashSet<uint>();
|
||||
if (!grid.ChunkCollection.ChunkCollection.TryGetValue(indices, out var chunk))
|
||||
return;
|
||||
|
||||
foreach (var (uid, decal) in chunk.Decals)
|
||||
{
|
||||
toDelete.Add(uid);
|
||||
if (new Vector2((int)Math.Floor(decal.Coordinates.X), (int)Math.Floor(decal.Coordinates.Y)) ==
|
||||
change.GridIndices)
|
||||
{
|
||||
toDelete.Add(uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (toDelete.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var decalId in toDelete)
|
||||
{
|
||||
grid.DecalIndex.Remove(decalId);
|
||||
chunk.Decals.Remove(decalId);
|
||||
}
|
||||
|
||||
DirtyChunk(args.Entity, indices, chunk);
|
||||
if (chunk.Decals.Count == 0)
|
||||
grid.ChunkCollection.ChunkCollection.Remove(indices);
|
||||
}
|
||||
|
||||
if (toDelete.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var decalId in toDelete)
|
||||
{
|
||||
grid.DecalIndex.Remove(decalId);
|
||||
chunk.Decals.Remove(decalId);
|
||||
}
|
||||
|
||||
DirtyChunk(args.Entity, indices, chunk);
|
||||
if (chunk.Decals.Count == 0)
|
||||
grid.ChunkCollection.ChunkCollection.Remove(indices);
|
||||
}
|
||||
|
||||
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user