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