Add subfloor appearance data, pipes correctly render subfloor. (#4393)
This commit is contained in:
committed by
GitHub
parent
eee3c940fb
commit
f2a3987343
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Piping;
|
using Content.Shared.Atmos.Piping;
|
||||||
|
using Content.Shared.SubFloor;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
@@ -69,13 +70,16 @@ namespace Content.Client.Atmos.Visualizers
|
|||||||
if (!component.TryGetData(PipeVisuals.VisualState, out PipeVisualState state))
|
if (!component.TryGetData(PipeVisuals.VisualState, out PipeVisualState state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(!component.TryGetData(SubFloorVisuals.SubFloor, out bool subfloor))
|
||||||
|
subfloor = true;
|
||||||
|
|
||||||
foreach (Layer layerKey in Enum.GetValues(typeof(Layer)))
|
foreach (Layer layerKey in Enum.GetValues(typeof(Layer)))
|
||||||
{
|
{
|
||||||
var dir = (PipeDirection) layerKey;
|
var dir = (PipeDirection) layerKey;
|
||||||
var layerVisible = state.ConnectedDirections.HasDirection(dir);
|
var layerVisible = state.ConnectedDirections.HasDirection(dir);
|
||||||
|
|
||||||
var layer = sprite.LayerMapGet(layerKey);
|
var layer = sprite.LayerMapGet(layerKey);
|
||||||
sprite.LayerSetVisible(layer, layerVisible);
|
sprite.LayerSetVisible(layer, layerVisible && subfloor);
|
||||||
sprite.LayerSetColor(layer, color);
|
sprite.LayerSetColor(layer, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
Content.Client/SubFloor/SubFloorShowLayerVisualizer.cs
Normal file
40
Content.Client/SubFloor/SubFloorShowLayerVisualizer.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using Content.Shared.SubFloor;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.SubFloor
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class SubFloorShowLayerVisualizer : AppearanceVisualizer
|
||||||
|
{
|
||||||
|
public override void OnChangeData(AppearanceComponent component)
|
||||||
|
{
|
||||||
|
base.OnChangeData(component);
|
||||||
|
|
||||||
|
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (component.TryGetData(SubFloorVisuals.SubFloor, out bool subfloor))
|
||||||
|
{
|
||||||
|
sprite.Visible = true;
|
||||||
|
|
||||||
|
// Due to the way this visualizer works, you might want to specify it before any other
|
||||||
|
// visualizer that hides/shows layers depending on certain conditions, such as PipeConnectorVisualizer.
|
||||||
|
foreach (var layer in sprite.AllLayers)
|
||||||
|
{
|
||||||
|
layer.Visible = subfloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sprite.LayerMapTryGet(Layers.FirstLayer, out var firstLayer))
|
||||||
|
{
|
||||||
|
sprite.LayerSetVisible(firstLayer, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Layers : byte
|
||||||
|
{
|
||||||
|
FirstLayer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
using System;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.SubFloor
|
namespace Content.Shared.SubFloor
|
||||||
@@ -146,10 +148,19 @@ namespace Content.Shared.SubFloor
|
|||||||
subFloor = !transformComponent.Anchored;
|
subFloor = !transformComponent.Anchored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Whether to show this entity as visible, visually.
|
||||||
|
var subFloorVisible = ShowAll || subFloor;
|
||||||
|
|
||||||
// Show sprite
|
// Show sprite
|
||||||
if (ComponentManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
|
if (ComponentManager.TryGetComponent(uid, out SharedSpriteComponent? spriteComponent))
|
||||||
{
|
{
|
||||||
spriteComponent.Visible = ShowAll || subFloor;
|
spriteComponent.Visible = subFloorVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set an appearance data value so visualizers can use this as needed.
|
||||||
|
if (ComponentManager.TryGetComponent(uid, out SharedAppearanceComponent? appearanceComponent))
|
||||||
|
{
|
||||||
|
appearanceComponent.SetData(SubFloorVisuals.SubFloor, subFloorVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// So for collision all we care about is that the component is running.
|
// So for collision all we care about is that the component is running.
|
||||||
@@ -169,4 +180,10 @@ namespace Content.Shared.SubFloor
|
|||||||
SubFloor = subFloor;
|
SubFloor = subFloor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum SubFloorVisuals : byte
|
||||||
|
{
|
||||||
|
SubFloor,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,10 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpPressure
|
- state: pumpPressure
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
- type: PressurePumpVisualizer
|
- type: PressurePumpVisualizer
|
||||||
@@ -57,6 +59,12 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpVolume
|
- state: pumpVolume
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasVolumePump
|
- type: GasVolumePump
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -75,6 +83,12 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpPassiveGate
|
- state: pumpPassiveGate
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasPassiveGate
|
- type: GasPassiveGate
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -94,6 +108,12 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpPassiveGate
|
- state: pumpPassiveGate
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasValve
|
- type: GasValve
|
||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
nodes:
|
nodes:
|
||||||
@@ -118,6 +138,12 @@
|
|||||||
state: pipeHalf
|
state: pipeHalf
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: gasCanisterPort
|
- state: gasCanisterPort
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasPort
|
- type: GasPort
|
||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
nodes:
|
nodes:
|
||||||
@@ -142,9 +168,10 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: vent_off
|
- state: vent_off
|
||||||
map: ["enum.VentVisualLayers.Vent"]
|
map: [ "enum.VentVisualLayers.Vent", "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
- type: VentPumpVisualizer
|
- type: VentPumpVisualizer
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
- type: AtmosUnsafeUnanchor
|
- type: AtmosUnsafeUnanchor
|
||||||
- type: AtmosPipeColor
|
- type: AtmosPipeColor
|
||||||
|
- type: SubFloorHide
|
||||||
|
|
||||||
#Note: The PipeDirection of the PipeNode should be the south-facing version, because the entity starts at an angle of 0 (south)
|
#Note: The PipeDirection of the PipeNode should be the south-facing version, because the entity starts at an angle of 0 (south)
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,12 @@
|
|||||||
state: pipeTJunction
|
state: pipeTJunction
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: gasFilter
|
- state: gasFilter
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasFilter
|
- type: GasFilter
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
@@ -57,6 +63,12 @@
|
|||||||
state: pipeTJunction
|
state: pipeTJunction
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: gasFilter
|
- state: gasFilter
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasMixer
|
- type: GasMixer
|
||||||
inletOne: inlet
|
inletOne: inlet
|
||||||
inletTwo: filter
|
inletTwo: filter
|
||||||
|
|||||||
@@ -29,9 +29,10 @@
|
|||||||
state: pipeHalf
|
state: pipeHalf
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: vent_off
|
- state: vent_off
|
||||||
map: ["enum.VentVisualLayers.Vent"]
|
map: [ "enum.VentVisualLayers.Vent", "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
- type: VentPumpVisualizer
|
- type: VentPumpVisualizer
|
||||||
@@ -54,8 +55,10 @@
|
|||||||
state: pipeHalf
|
state: pipeHalf
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: vent_off
|
- state: vent_off
|
||||||
|
map: [ "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
- type: GasPassiveVent
|
- type: GasPassiveVent
|
||||||
@@ -76,9 +79,10 @@
|
|||||||
state: pipeHalf
|
state: pipeHalf
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: scrub_off
|
- state: scrub_off
|
||||||
map: ["enum.ScrubberVisualLayers.Scrubber"]
|
map: [ "enum.ScrubberVisualLayers.Scrubber", "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
- type: ScrubberVisualizer
|
- type: ScrubberVisualizer
|
||||||
@@ -93,18 +97,24 @@
|
|||||||
placement:
|
placement:
|
||||||
mode: SnapgridCenter
|
mode: SnapgridCenter
|
||||||
components:
|
components:
|
||||||
- type: GasOutletInjector
|
|
||||||
# TODO ATMOS: Actual sprite for this.
|
# TODO ATMOS: Actual sprite for this.
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
netsync: false
|
||||||
layers:
|
layers:
|
||||||
- state: pipeHalf
|
- state: pipeHalf
|
||||||
sprite: Structures/Piping/Atmospherics/pipe.rsi
|
sprite: Structures/Piping/Atmospherics/pipe.rsi
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe", "enum.SubFloorShowLayerVisualizer+Layers.FirstLayer" ]
|
||||||
|
- type: Appearance
|
||||||
|
visuals:
|
||||||
|
- type: SubFloorShowLayerVisualizer
|
||||||
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
|
- type: GasOutletInjector
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: GasUnaryBase
|
parent: BaseMachinePowered
|
||||||
id: GasThermoMachineBase
|
id: BaseGasThermoMachine
|
||||||
name: thermomachine
|
name: thermomachine
|
||||||
description: Heats or cools gas in connected pipes.
|
description: Heats or cools gas in connected pipes.
|
||||||
abstract: true
|
abstract: true
|
||||||
@@ -117,10 +127,19 @@
|
|||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: GasThermoMachine
|
- type: GasThermoMachine
|
||||||
|
- type: AtmosPipeColor
|
||||||
|
- type: AtmosDevice
|
||||||
|
- type: NodeContainer
|
||||||
|
nodes:
|
||||||
|
pipe:
|
||||||
|
!type:PipeNode
|
||||||
|
nodeGroupID: Pipe
|
||||||
|
pipeDirection: South
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: GasThermoMachineBase
|
parent: BaseGasThermoMachine
|
||||||
id: GasThermoMachineFreezer
|
id: GasThermoMachineFreezer
|
||||||
name: freezer
|
name: freezer
|
||||||
placement:
|
placement:
|
||||||
@@ -130,9 +149,11 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: freezer_off
|
- state: freezer_off
|
||||||
- state: pipe
|
- state: pipe
|
||||||
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: ThermoMachineVisualizer
|
- type: ThermoMachineVisualizer
|
||||||
enabledState: freezer_on
|
enabledState: freezer_on
|
||||||
- type: GasThermoMachine
|
- type: GasThermoMachine
|
||||||
@@ -140,7 +161,7 @@
|
|||||||
minTemperature: 73.15
|
minTemperature: 73.15
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: GasThermoMachineBase
|
parent: BaseGasThermoMachine
|
||||||
id: GasThermoMachineHeater
|
id: GasThermoMachineHeater
|
||||||
name: heater
|
name: heater
|
||||||
placement:
|
placement:
|
||||||
@@ -150,9 +171,11 @@
|
|||||||
layers:
|
layers:
|
||||||
- state: heater_off
|
- state: heater_off
|
||||||
- state: pipe
|
- state: pipe
|
||||||
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PipeConnectorVisualizer
|
- type: PipeConnectorVisualizer
|
||||||
|
- type: PipeColorVisualizer
|
||||||
- type: ThermoMachineVisualizer
|
- type: ThermoMachineVisualizer
|
||||||
enabledState: heater_on
|
enabledState: heater_on
|
||||||
- type: GasThermoMachine
|
- type: GasThermoMachine
|
||||||
|
|||||||
Reference in New Issue
Block a user