The SubFloorHideComponent can now be properly started/stopped. Previously this did nothing.
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple component that automatically hides the sibling <see cref="ISpriteComponent"/> when the tile it's on
|
||||
/// is not a sub floor (plating).
|
||||
/// Simple component that automatically hides the sibling
|
||||
/// <see cref="ISpriteComponent" /> when the tile it's on is not a sub floor
|
||||
/// (plating).
|
||||
/// </summary>
|
||||
/// <seealso cref="ContentTileDefinition.IsSubFloor"/>
|
||||
/// <seealso cref="P:Content.Shared.Maps.ContentTileDefinition.IsSubFloor" />
|
||||
[RegisterComponent]
|
||||
public sealed class SubFloorHideComponent : Component
|
||||
{
|
||||
private SnapGridComponent _snapGridComponent;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => "SubFloorHide";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -39,6 +41,7 @@ namespace Content.Client.GameObjects.Components
|
||||
base.Shutdown();
|
||||
|
||||
_snapGridComponent.OnPositionChanged -= SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.RaiseEvent(Owner, new SubFloorHideDirtyEvent());
|
||||
}
|
||||
|
||||
private void SnapGridOnPositionChanged()
|
||||
@@ -47,7 +50,5 @@ namespace Content.Client.GameObjects.Components
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage
|
||||
{
|
||||
}
|
||||
internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage { }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
@@ -39,12 +39,9 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
return;
|
||||
}
|
||||
|
||||
var sprite = senderEnt.GetComponent<ISpriteComponent>();
|
||||
var grid = _mapManager.GetGrid(senderEnt.Transform.GridID);
|
||||
var position = senderEnt.Transform.GridPosition;
|
||||
var tileRef = grid.GetTileRef(position);
|
||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tileRef.Tile.TypeId];
|
||||
sprite.Visible = tileDef.IsSubFloor;
|
||||
var indices = grid.WorldToTile(senderEnt.Transform.WorldPosition);
|
||||
UpdateTile(grid, indices);
|
||||
}
|
||||
|
||||
private void MapManagerOnTileChanged(object sender, TileChangedEventArgs e)
|
||||
@@ -67,13 +64,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
||||
{
|
||||
var entity = snapGridComponent.Owner;
|
||||
if (!entity.HasComponent<SubFloorHideComponent>() ||
|
||||
if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent) ||
|
||||
!entity.TryGetComponent(out ISpriteComponent spriteComponent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
spriteComponent.Visible = tileDef.IsSubFloor;
|
||||
spriteComponent.Visible = !subFloorComponent.Running || tileDef.IsSubFloor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user