Skip to content

Commit

Permalink
Injector sprite fix (#9011)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored Jul 9, 2022
1 parent 029924e commit 65408f6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
18 changes: 8 additions & 10 deletions Content.Client/SubFloor/SubFloorHideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ private void OnAppearanceChanged(EntityUid uid, SubFloorHideComponent component,
}

// Is there some layer that is always visible?
if (args.Sprite.LayerMapTryGet(SubfloorLayers.FirstLayer, out var firstLayer))
var hasVisibleLayer = false;
foreach (var layerKey in component.VisibleLayers)
{
var layer = args.Sprite[firstLayer];
if (!args.Sprite.LayerMapTryGet(layerKey, out var layerIndex))
continue;

var layer = args.Sprite[layerIndex];
layer.Visible = true;
layer.Color = layer.Color.WithAlpha(1f);
args.Sprite.Visible = true;
return;
hasVisibleLayer = true;
}

args.Sprite.Visible = revealed;
args.Sprite.Visible = hasVisibleLayer || revealed;
}

private void UpdateAll()
Expand All @@ -73,8 +76,3 @@ private void UpdateAll()
}
}
}

public enum SubfloorLayers : byte
{
FirstLayer, // always visible. E.g. vent part of a vent..
}
5 changes: 5 additions & 0 deletions Content.Shared/SubFloor/SharedSubFloorHideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,9 @@ public enum SubFloorVisuals : byte
Covered, // is there a floor tile over this entity
ScannerRevealed, // is this entity revealed by a scanner or some other entity?
}

public enum SubfloorLayers : byte
{
FirstLayer
}
}
9 changes: 9 additions & 0 deletions Content.Shared/SubFloor/SubFloorHideComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;

namespace Content.Shared.SubFloor
{
Expand Down Expand Up @@ -43,6 +45,13 @@ public sealed class SubFloorHideComponent : Component
[DataField("scannerTransparency")]
public float ScannerTransparency = 0.8f;

/// <summary>
/// Sprite layer keys for the layers that are always visible, even if the entity is below a floor tile. E.g.,
/// the vent part of a vent is always visible, even though the piping is hidden.
/// </summary>
[DataField("visibleLayers", customTypeSerializer:typeof(CustomHashSetSerializer<object, AppearanceKeySerializer>))]
public HashSet<object> VisibleLayers = new() { SubfloorLayers.FirstLayer };

/// <summary>
/// The entities this subfloor is revealed by.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@
layers:
- state: pipeHalf
sprite: Structures/Piping/Atmospherics/pipe.rsi
map: [ "enum.PipeVisualLayers.Pipe", "enum.SubfloorLayers.FirstLayer" ]
map: [ "enum.PipeVisualLayers.Pipe" ]
- state: injector
map: [ "enum.SubfloorLayers.FirstLayer" ]
- state: injector-unshaded
shader: unshaded
map: [ "unshaded" ]
Expand All @@ -177,6 +178,10 @@
- type: Construction
graph: GasUnary
node: outletinjector
- type: SubFloorHide
visibleLayers:
- enum.SubfloorLayers.FirstLayer
- unshaded

- type: entity
parent: BaseMachinePowered
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65408f6

Please sign in to comment.