SubFloorHide requires entities to be anchored by default.
This commit is contained in:
@@ -68,8 +68,7 @@ namespace Content.Shared.SubFloor
|
||||
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
|
||||
|
||||
// We do this directly instead of calling UpdateEntity.
|
||||
if(_mapManager.TryGetGrid(transform.GridID, out var grid))
|
||||
UpdateTile(grid, grid.TileIndicesFor(transform.Coordinates));
|
||||
UpdateEntity(uid);
|
||||
}
|
||||
|
||||
private void MapManagerOnTileChanged(object? sender, TileChangedEventArgs e)
|
||||
@@ -113,6 +112,7 @@ namespace Content.Shared.SubFloor
|
||||
private void UpdateEntity(EntityUid uid)
|
||||
{
|
||||
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
|
||||
|
||||
if (!_mapManager.TryGetGrid(transform.GridID, out var grid))
|
||||
{
|
||||
// Not being on a grid counts as no subfloor, unhide this.
|
||||
@@ -134,6 +134,18 @@ namespace Content.Shared.SubFloor
|
||||
if (subFloorHideEvent.Handled)
|
||||
return;
|
||||
|
||||
// This might look weird, but basically we only need to query the SubFloorHide and Transform components
|
||||
// if we are gonna hide the entity and we require it to be anchored to be hidden. Because getting components
|
||||
// is "expensive", we have a slow path where we query them, and a fast path where we don't.
|
||||
if (!subFloor
|
||||
&& ComponentManager.TryGetComponent(uid, out SubFloorHideComponent? subFloorHideComponent) &&
|
||||
subFloorHideComponent.RequireAnchored
|
||||
&& ComponentManager.TryGetComponent(uid, out ITransformComponent? transformComponent))
|
||||
{
|
||||
// If we require the entity to be anchored but it's not, this will set subfloor to true, unhiding it.
|
||||
subFloor = !transformComponent.Anchored;
|
||||
}
|
||||
|
||||
// Show sprite
|
||||
if (ComponentManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user