SubFloorHide requires entities to be anchored by default.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.SubFloor
|
||||
{
|
||||
@@ -13,5 +15,12 @@ namespace Content.Shared.SubFloor
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Name => "SubFloorHide";
|
||||
|
||||
/// <summary>
|
||||
/// This entity needs to be anchored to be hid in the subfloor.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("requireAnchored")]
|
||||
public bool RequireAnchored { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Spirate/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Strippable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=stunnable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=subfloor/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Superconduct/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=superconduction/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean>
|
||||
@@ -284,6 +285,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unequip/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unexcite/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unequip/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unhiding/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unlockable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unobtanium/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unoccluded/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
Reference in New Issue
Block a user