Draw depth adjustments (#5130)

* door drawdepth toggle

* git mv

* dooooors

* drawdepth adjustments

* fix door and missed projectiles

* firelock depth tweak

* Get sprite only when needed

* single letter typo

* forgot to include closing in _activeDoors.
This commit is contained in:
Leon Friedrich
2021-11-04 02:43:10 +13:00
committed by GitHub
parent 40f866f35c
commit 673301825b
32 changed files with 103 additions and 100 deletions

View File

@@ -2,6 +2,11 @@ using System;
using Content.Shared.Doors; using Content.Shared.Doors;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.Doors namespace Content.Client.Doors
{ {
@@ -13,6 +18,12 @@ namespace Content.Client.Doors
[ComponentReference(typeof(SharedDoorComponent))] [ComponentReference(typeof(SharedDoorComponent))]
public class ClientDoorComponent : SharedDoorComponent public class ClientDoorComponent : SharedDoorComponent
{ {
[DataField("openDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
public int OpenDrawDepth = (int) DrawDepth.Doors;
[DataField("closedDrawDepth", customTypeSerializer: typeof(ConstantSerializer<DrawDepthTag>))]
public int ClosedDrawDepth = (int) DrawDepth.Doors;
private bool _stateChangeHasProgressed = false; private bool _stateChangeHasProgressed = false;
private TimeSpan _timeOffset; private TimeSpan _timeOffset;
@@ -27,7 +38,7 @@ namespace Content.Client.Doors
base.State = value; base.State = value;
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new DoorStateMessage(this, State)); Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
} }
} }
@@ -85,16 +96,4 @@ namespace Content.Client.Doors
} }
} }
} }
public sealed class DoorStateMessage : EntityEventArgs
{
public ClientDoorComponent Component { get; }
public SharedDoorComponent.DoorState State { get; }
public DoorStateMessage(ClientDoorComponent component, SharedDoorComponent.DoorState state)
{
Component = component;
State = state;
}
}
} }

View File

@@ -1,6 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Doors; using Content.Shared.Doors;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Doors.SharedDoorComponent;
namespace Content.Client.Doors namespace Content.Client.Doors
{ {
@@ -18,28 +21,32 @@ namespace Content.Client.Doors
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<DoorStateMessage>(HandleDoorState); SubscribeLocalEvent<ClientDoorComponent, DoorStateChangedEvent>(OnDoorStateChanged);
} }
/// <summary> private void OnDoorStateChanged(EntityUid uid, ClientDoorComponent door, DoorStateChangedEvent args)
/// Registers doors to be periodically checked.
/// </summary>
/// <param name="message">A message corresponding to the component under consideration, raised when its state changes.</param>
private void HandleDoorState(DoorStateMessage message)
{ {
switch (message.State) switch (args.State)
{ {
case SharedDoorComponent.DoorState.Closed: case DoorState.Closed:
case SharedDoorComponent.DoorState.Open: case DoorState.Open:
_activeDoors.Remove(message.Component); _activeDoors.Remove(door);
break; break;
case SharedDoorComponent.DoorState.Closing: case DoorState.Closing:
case SharedDoorComponent.DoorState.Opening: case DoorState.Opening:
_activeDoors.Add(message.Component); _activeDoors.Add(door);
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
if (!EntityManager.TryGetComponent(uid, out SpriteComponent sprite))
return;
// Update sprite draw depth. If the door is opening or closing, we will use the closed-draw depth.
sprite.DrawDepth = (args.State == DoorState.Open)
? door.OpenDrawDepth
: door.ClosedDrawDepth;
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@@ -69,10 +69,10 @@ namespace Content.Client.MobState
} }
// So they don't draw over mobs anymore // So they don't draw over mobs anymore
if (_data == DamageState.Dead) if (_data == DamageState.Dead && sprite.DrawDepth > (int) DrawDepth.Items)
{ {
_originalDrawDepth = sprite.DrawDepth; _originalDrawDepth = sprite.DrawDepth;
sprite.DrawDepth = (int) DrawDepth.FloorObjects; sprite.DrawDepth = (int) DrawDepth.Items;
} }
else if (_originalDrawDepth != null) else if (_originalDrawDepth != null)
{ {

View File

@@ -1,10 +1,7 @@
#nullable enable
using System;
using Content.Shared.Doors;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Server.Doors namespace Content.Shared.Doors
{ {
/// <summary> /// <summary>
/// Raised when the door's State variable is changed to a new variable that it was not equal to before. /// Raised when the door's State variable is changed to a new variable that it was not equal to before.
@@ -27,13 +24,6 @@ namespace Content.Server.Doors
{ {
} }
/// <summary>
/// Raised when the door is successfully opened.
/// </summary>
public class OnDoorOpenedEvent : HandledEntityEventArgs
{
}
/// <summary> /// <summary>
/// Raised when the door is determining whether it is able to close. /// Raised when the door is determining whether it is able to close.
/// Cancel to stop the door from being closed. /// Cancel to stop the door from being closed.
@@ -42,13 +32,6 @@ namespace Content.Server.Doors
{ {
} }
/// <summary>
/// Raised when the door is successfully closed.
/// </summary>
public class OnDoorClosedEvent : HandledEntityEventArgs
{
}
/// <summary> /// <summary>
/// Called when the door is determining whether it is able to deny. /// Called when the door is determining whether it is able to deny.
/// Cancel to stop the door from being able to deny. /// Cancel to stop the door from being able to deny.
@@ -57,13 +40,6 @@ namespace Content.Server.Doors
{ {
} }
/// <summary>
/// Raised when access to the door is denied.
/// </summary>
public class OnDoorDeniedEvent : HandledEntityEventArgs
{
}
/// <summary> /// <summary>
/// Raised to determine whether the door's safety is on. /// Raised to determine whether the door's safety is on.
/// Modify Safety to set the door's safety. /// Modify Safety to set the door's safety.

View File

@@ -6,25 +6,73 @@ namespace Content.Shared.DrawDepth
[ConstantsFor(typeof(DrawDepthTag))] [ConstantsFor(typeof(DrawDepthTag))]
public enum DrawDepth public enum DrawDepth
{ {
LowFloors = DrawDepthTag.Default - 7,
/// <summary> /// <summary>
/// Things that are beneath regular floors, such as wires. /// This is for sub-floors, the floors you see after prying off a tile.
/// </summary>
LowFloors = DrawDepthTag.Default - 7,
/// <summary>
/// Things that are beneath regular floors, such as wires or pipes. vents/scrubbers also use this to ensure
/// that they appear below carpets.
/// </summary> /// </summary>
BelowFloor = DrawDepthTag.Default - 6, BelowFloor = DrawDepthTag.Default - 6,
FloorTiles = DrawDepthTag.Default - 5,
/// <summary> /// <summary>
/// Things that are actually right on the floor, like vents. /// Used for entities like carpets.
/// </summary>
FloorTiles = DrawDepthTag.Default - 5,
/// <summary>
/// Things that are actually right on the floor, like puddles. This does not mean objects like
/// tables, even though they are technically "on the floor".
/// </summary> /// </summary>
FloorObjects = DrawDepthTag.Default - 4, FloorObjects = DrawDepthTag.Default - 4,
Walls = DrawDepthTag.Default - 3, Walls = DrawDepthTag.Default - 3,
/// <summary>
/// Used for windows (grilles use walls) and misc signage. Useful if you want to have an APC in the middle
/// of some wall-art or something.
/// </summary>
WallTops = DrawDepthTag.Default - 2, WallTops = DrawDepthTag.Default - 2,
/// <summary>
/// Posters, APCs, air alarms, etc.
/// </summary>
WallMountedItems = DrawDepthTag.Default - 1, WallMountedItems = DrawDepthTag.Default - 1,
/// <summary>
/// Furniture, crates, etc.
/// </summary>
Objects = DrawDepthTag.Default, Objects = DrawDepthTag.Default,
Items = DrawDepthTag.Default + 1,
Mobs = DrawDepthTag.Default + 2, /// <summary>
HighlightedItems = DrawDepthTag.Default + 3, /// In-between an furniture and an item. Useful for entities that need to appear on top of tables, but are
Effects = DrawDepthTag.Default + 4, /// not items. E.g., power cell chargers. Also useful for pizza boxes, which appear above crates, but not
Ghosts = DrawDepthTag.Default + 5, /// above the pizza itself.
Overlays = DrawDepthTag.Default + 6, /// </summary>
SmallObjects = DrawDepthTag.Default + 1,
/// <summary>
/// Generic items. Things that should be above crates & tables, but underneath mobs.
/// </summary>
Items = DrawDepthTag.Default + 2,
Mobs = DrawDepthTag.Default + 3,
Doors = DrawDepthTag.Default + 4,
/// <summary>
/// Explosions, fire, melee swings. Whatever.
/// </summary>
Effects = DrawDepthTag.Default + 5,
Ghosts = DrawDepthTag.Default + 6,
/// <summary>
/// Use this selectively if it absolutely needs to be drawn above (almost) everything else. Examples include
/// the pointing arrow, the drag & drop ghost-entity, and some debug tools.
/// </summary>
Overlays = DrawDepthTag.Default + 7,
} }
} }

View File

@@ -7,5 +7,5 @@
sprite: Effects/arcs.rsi sprite: Effects/arcs.rsi
noRot: false noRot: false
offset: 0, -0.85 offset: 0, -0.85
drawdepth: Overlays drawdepth: Effects
- type: MeleeWeaponArcAnimation - type: MeleeWeaponArcAnimation

View File

@@ -144,7 +144,7 @@
components: components:
- type: Sprite - type: Sprite
sprite: Objects/Consumable/Food/Baked/pizza.rsi sprite: Objects/Consumable/Food/Baked/pizza.rsi
drawdepth: FloorObjects drawdepth: SmallObjects
layers: layers:
- state: box - state: box
- state: box-open - state: box-open

View File

@@ -14,7 +14,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -20,7 +20,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -13,7 +13,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: entity - type: entity
id: CartridgeCap id: CartridgeCap

View File

@@ -12,7 +12,6 @@
netsync: false netsync: false
sprite: Objects/Weapons/Guns/Ammunition/Explosives/rpg.rsi sprite: Objects/Weapons/Guns/Ammunition/Explosives/rpg.rsi
state: frag state: frag
drawdepth: FloorObjects
- type: entity - type: entity
id: GrenadeBaton id: GrenadeBaton
@@ -28,7 +27,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer
@@ -47,7 +45,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer
@@ -66,7 +63,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer
@@ -85,7 +81,6 @@
layers: layers:
- state: base - state: base
map: ["enum.AmmoVisualLayers.Base"] map: ["enum.AmmoVisualLayers.Base"]
drawdepth: FloorObjects
- type: Appearance - type: Appearance
visuals: visuals:
- type: SpentAmmoVisualizer - type: SpentAmmoVisualizer

View File

@@ -7,7 +7,6 @@
- type: InteractionOutline - type: InteractionOutline
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs
sprite: Structures/Doors/Airlocks/Standard/basic.rsi sprite: Structures/Doors/Airlocks/Standard/basic.rsi
state: "assembly" state: "assembly"
- type: Physics - type: Physics

View File

@@ -7,7 +7,6 @@
- type: InteractionOutline - type: InteractionOutline
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Airlocks/Standard/basic.rsi sprite: Structures/Doors/Airlocks/Standard/basic.rsi
layers: layers:
- state: closed - state: closed

View File

@@ -18,7 +18,6 @@
acts: ["Destruction"] acts: ["Destruction"]
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Airlocks/Standard/firelock.rsi sprite: Structures/Doors/Airlocks/Standard/firelock.rsi
layers: layers:
- state: closed - state: closed
@@ -48,6 +47,7 @@
- VaultImpassable - VaultImpassable
- SmallImpassable - SmallImpassable
- type: Door - type: Door
openDrawDepth: WallTops
closeTimeOne: 0.1 closeTimeOne: 0.1
closeTimeTwo: 0.6 closeTimeTwo: 0.6
openTimeOne: 0.1 openTimeOne: 0.1

View File

@@ -6,7 +6,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Shutters/blastdoor.rsi sprite: Structures/Doors/Shutters/blastdoor.rsi
layers: layers:
- state: closed - state: closed

View File

@@ -7,7 +7,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Shutters/shutters.rsi sprite: Structures/Doors/Shutters/shutters.rsi
layers: layers:
- state: closed - state: closed
@@ -98,7 +97,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Shutters/shutters_radiation.rsi sprite: Structures/Doors/Shutters/shutters_radiation.rsi
layers: layers:
- state: closed - state: closed
@@ -121,7 +119,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs # They're on the same layer as mobs, perspective.
sprite: Structures/Doors/Shutters/shutters_window.rsi sprite: Structures/Doors/Shutters/shutters_window.rsi
layers: layers:
- state: closed - state: closed

View File

@@ -7,7 +7,6 @@
- type: InteractionOutline - type: InteractionOutline
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: FloorObjects
sprite: Structures/Doors/Windoors/windoor.rsi sprite: Structures/Doors/Windoors/windoor.rsi
layers: layers:
- state: assembly - state: assembly
@@ -53,7 +52,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: Mobs
sprite: Structures/Doors/Windoors/windoor.rsi sprite: Structures/Doors/Windoors/windoor.rsi
layers: layers:
- state: secure_underlay - state: secure_underlay

View File

@@ -21,7 +21,6 @@
- VaultImpassable - VaultImpassable
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: FloorObjects
sprite: Structures/Doors/Windoors/windoor.rsi sprite: Structures/Doors/Windoors/windoor.rsi
layers: layers:
- state: closed - state: closed
@@ -104,7 +103,6 @@
components: components:
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: FloorObjects
sprite: Structures/Doors/Windoors/windoor.rsi sprite: Structures/Doors/Windoors/windoor.rsi
layers: layers:
- state: secure_underlay - state: secure_underlay

View File

@@ -11,7 +11,6 @@
- type: PlaceableSurface - type: PlaceableSurface
- type: Sprite - type: Sprite
netsync: false netsync: false
drawdepth: FloorTiles
- type: Icon - type: Icon
state: full state: full
- type: IconSmooth - type: IconSmooth

View File

@@ -5,7 +5,7 @@
abstract: true abstract: true
components: components:
- type: Sprite - type: Sprite
drawdepth: BelowFloor drawdepth: FloorTiles
- type: Icon - type: Icon
state: full state: full
- type: IconSmooth - type: IconSmooth

View File

@@ -32,7 +32,7 @@
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Structures/Machines/microwave.rsi sprite: Structures/Machines/microwave.rsi
drawdepth: WallMountedItems drawdepth: SmallObjects
layers: layers:
- state: mw0 - state: mw0
map: ["enum.MicrowaveVisualizerLayers.Base"] map: ["enum.MicrowaveVisualizerLayers.Base"]

View File

@@ -28,4 +28,4 @@
netsync: false netsync: false
sprite: Structures/Machines/juicer.rsi sprite: Structures/Machines/juicer.rsi
state: juicer0 state: juicer0
drawdepth: Items drawdepth: SmallObjects

View File

@@ -5,7 +5,7 @@
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Structures/Power/cell_recharger.rsi sprite: Structures/Power/cell_recharger.rsi
drawdepth: Items drawdepth: SmallObjects
- type: Icon - type: Icon
sprite: Structures/Power/cell_recharger.rsi sprite: Structures/Power/cell_recharger.rsi
state: empty state: empty
@@ -27,7 +27,7 @@
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Structures/Power/recharger.rsi sprite: Structures/Power/recharger.rsi
drawdepth: Items drawdepth: SmallObjects
- type: Icon - type: Icon
sprite: Structures/Power/recharger.rsi sprite: Structures/Power/recharger.rsi
state: empty state: empty
@@ -49,7 +49,7 @@
- type: Sprite - type: Sprite
netsync: false netsync: false
sprite: Structures/Power/wall_recharger.rsi sprite: Structures/Power/wall_recharger.rsi
drawdepth: Items drawdepth: SmallObjects
- type: Icon - type: Icon
sprite: Structures/Power/wall_recharger.rsi sprite: Structures/Power/wall_recharger.rsi
state: empty state: empty

View File

@@ -13,7 +13,6 @@
- type: Sprite - type: Sprite
sprite: Structures/Furniture/furniture.rsi sprite: Structures/Furniture/furniture.rsi
state: rack state: rack
drawdepth: FloorObjects
- type: Physics - type: Physics
bodyType: Static bodyType: Static
fixtures: fixtures:

View File

@@ -65,4 +65,4 @@
sprite: Effects/fire.rsi sprite: Effects/fire.rsi
normalState: 1 normalState: 1
Sprite: Sprite:
drawdepth: Overlays drawdepth: Effects

View File

@@ -17,7 +17,6 @@
- type: Sprite - type: Sprite
sprite: Structures/Hydroponics/containers.rsi sprite: Structures/Hydroponics/containers.rsi
state: hydrotray3 state: hydrotray3
drawdepth: FloorObjects
- type: PlantHolder - type: PlantHolder
drawWarnings: true drawWarnings: true
- type: Construction - type: Construction

View File

@@ -38,7 +38,6 @@
- type: Sprite - type: Sprite
sprite: Structures/Hydroponics/misc.rsi sprite: Structures/Hydroponics/misc.rsi
state: soil state: soil
drawdepth: FloorObjects
- type: PlantHolder - type: PlantHolder
drawWarnings: false drawWarnings: false
- type: SolutionContainerManager - type: SolutionContainerManager