mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Use Entity<T> for TileChangedEvent (#5698)
Content is manually resolving this in a few spots so we can avoid that overhead.
This commit is contained in:
@@ -309,6 +309,7 @@ public abstract partial class SharedMapSystem
|
||||
ChunkDatum data)
|
||||
{
|
||||
var counter = 0;
|
||||
var gridEnt = new Entity<MapGridComponent>(uid, component);
|
||||
|
||||
if (data.IsDeleted())
|
||||
{
|
||||
@@ -326,10 +327,12 @@ public abstract partial class SharedMapSystem
|
||||
|
||||
var gridIndices = deletedChunk.ChunkTileToGridTile((x, y));
|
||||
var newTileRef = new TileRef(uid, gridIndices, Tile.Empty);
|
||||
_mapInternal.RaiseOnTileChanged(newTileRef, oldTile, index);
|
||||
_mapInternal.RaiseOnTileChanged(gridEnt, newTileRef, oldTile, index);
|
||||
}
|
||||
}
|
||||
|
||||
deletedChunk.CachedBounds = Box2i.Empty;
|
||||
deletedChunk.SuppressCollisionRegeneration = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -350,10 +353,12 @@ public abstract partial class SharedMapSystem
|
||||
|
||||
var gridIndices = chunk.ChunkTileToGridTile((x, y));
|
||||
var newTileRef = new TileRef(uid, gridIndices, tile);
|
||||
_mapInternal.RaiseOnTileChanged(newTileRef, oldTile, index);
|
||||
_mapInternal.RaiseOnTileChanged(gridEnt, newTileRef, oldTile, index);
|
||||
}
|
||||
}
|
||||
|
||||
DebugTools.Assert(chunk.Fixtures.SetEquals(data.Fixtures));
|
||||
|
||||
// These should never refer to the same object
|
||||
DebugTools.AssertNotEqual(chunk.Fixtures, data.Fixtures);
|
||||
|
||||
@@ -1614,7 +1619,7 @@ public abstract partial class SharedMapSystem
|
||||
if (!MapManager.SuppressOnTileChanged)
|
||||
{
|
||||
var newTileRef = new TileRef(uid, gridTile, newTile);
|
||||
_mapInternal.RaiseOnTileChanged(newTileRef, oldTile, mapChunk.Indices);
|
||||
_mapInternal.RaiseOnTileChanged((uid, grid), newTileRef, oldTile, mapChunk.Indices);
|
||||
}
|
||||
|
||||
if (shapeChanged && !mapChunk.SuppressCollisionRegeneration)
|
||||
|
||||
@@ -158,9 +158,9 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Creates a new instance of this class.
|
||||
/// </summary>
|
||||
public TileChangedEvent(EntityUid uid, TileRef newTile, Tile oldTile, Vector2i chunkIndex)
|
||||
public TileChangedEvent(Entity<MapGridComponent> entity, TileRef newTile, Tile oldTile, Vector2i chunkIndex)
|
||||
{
|
||||
Entity = uid;
|
||||
Entity = entity;
|
||||
NewTile = newTile;
|
||||
OldTile = oldTile;
|
||||
ChunkIndex = chunkIndex;
|
||||
@@ -172,9 +172,9 @@ namespace Robust.Shared.GameObjects
|
||||
public bool EmptyChanged => OldTile.IsEmpty != NewTile.Tile.IsEmpty;
|
||||
|
||||
/// <summary>
|
||||
/// EntityUid of the grid with the tile-change. TileRef stores the GridId.
|
||||
/// Entity of the grid with the tile-change. TileRef stores the GridId.
|
||||
/// </summary>
|
||||
public readonly EntityUid Entity;
|
||||
public readonly Entity<MapGridComponent> Entity;
|
||||
|
||||
/// <summary>
|
||||
/// New tile that replaced the old one.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
@@ -10,6 +12,6 @@ namespace Robust.Shared.Map
|
||||
/// </summary>
|
||||
/// <param name="tileRef">A reference to the new tile.</param>
|
||||
/// <param name="oldTile">The old tile that got replaced.</param>
|
||||
void RaiseOnTileChanged(TileRef tileRef, Tile oldTile, Vector2i chunk);
|
||||
void RaiseOnTileChanged(Entity<MapGridComponent> entity, TileRef tileRef, Tile oldTile, Vector2i chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,14 +96,13 @@ internal partial class MapManager
|
||||
/// </summary>
|
||||
/// <param name="tileRef">A reference to the new tile.</param>
|
||||
/// <param name="oldTile">The old tile that got replaced.</param>
|
||||
public void RaiseOnTileChanged(TileRef tileRef, Tile oldTile, Vector2i chunk)
|
||||
void IMapManagerInternal.RaiseOnTileChanged(Entity<MapGridComponent> entity, TileRef tileRef, Tile oldTile, Vector2i chunk)
|
||||
{
|
||||
if (SuppressOnTileChanged)
|
||||
return;
|
||||
|
||||
var euid = tileRef.GridUid;
|
||||
var ev = new TileChangedEvent(euid, tileRef, oldTile, chunk);
|
||||
EntityManager.EventBus.RaiseLocalEvent(euid, ref ev, true);
|
||||
var ev = new TileChangedEvent(entity, tileRef, oldTile, chunk);
|
||||
EntityManager.EventBus.RaiseLocalEvent(entity.Owner, ref ev, true);
|
||||
}
|
||||
|
||||
protected Entity<MapGridComponent> CreateGrid(EntityUid map, ushort chunkSize, EntityUid forcedGridEuid)
|
||||
|
||||
Reference in New Issue
Block a user