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:
@@ -2,6 +2,11 @@ using System;
|
||||
using Content.Shared.Doors;
|
||||
using JetBrains.Annotations;
|
||||
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
|
||||
{
|
||||
@@ -13,6 +18,12 @@ namespace Content.Client.Doors
|
||||
[ComponentReference(typeof(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 TimeSpan _timeOffset;
|
||||
|
||||
@@ -27,7 +38,7 @@ namespace Content.Client.Doors
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Doors;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using static Content.Shared.Doors.SharedDoorComponent;
|
||||
|
||||
namespace Content.Client.Doors
|
||||
{
|
||||
@@ -18,28 +21,32 @@ namespace Content.Client.Doors
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DoorStateMessage>(HandleDoorState);
|
||||
SubscribeLocalEvent<ClientDoorComponent, DoorStateChangedEvent>(OnDoorStateChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
private void OnDoorStateChanged(EntityUid uid, ClientDoorComponent door, DoorStateChangedEvent args)
|
||||
{
|
||||
switch (message.State)
|
||||
switch (args.State)
|
||||
{
|
||||
case SharedDoorComponent.DoorState.Closed:
|
||||
case SharedDoorComponent.DoorState.Open:
|
||||
_activeDoors.Remove(message.Component);
|
||||
case DoorState.Closed:
|
||||
case DoorState.Open:
|
||||
_activeDoors.Remove(door);
|
||||
break;
|
||||
case SharedDoorComponent.DoorState.Closing:
|
||||
case SharedDoorComponent.DoorState.Opening:
|
||||
_activeDoors.Add(message.Component);
|
||||
case DoorState.Closing:
|
||||
case DoorState.Opening:
|
||||
_activeDoors.Add(door);
|
||||
break;
|
||||
default:
|
||||
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 />
|
||||
|
||||
@@ -69,10 +69,10 @@ namespace Content.Client.MobState
|
||||
}
|
||||
|
||||
// So they don't draw over mobs anymore
|
||||
if (_data == DamageState.Dead)
|
||||
if (_data == DamageState.Dead && sprite.DrawDepth > (int) DrawDepth.Items)
|
||||
{
|
||||
_originalDrawDepth = sprite.DrawDepth;
|
||||
sprite.DrawDepth = (int) DrawDepth.FloorObjects;
|
||||
sprite.DrawDepth = (int) DrawDepth.Items;
|
||||
}
|
||||
else if (_originalDrawDepth != null)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Doors
|
||||
namespace Content.Shared.Doors
|
||||
{
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// Raised when the door is determining whether it is able to close.
|
||||
/// 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>
|
||||
/// Called when the door is determining whether it is 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>
|
||||
/// Raised to determine whether the door's safety is on.
|
||||
/// Modify Safety to set the door's safety.
|
||||
@@ -6,25 +6,73 @@ namespace Content.Shared.DrawDepth
|
||||
[ConstantsFor(typeof(DrawDepthTag))]
|
||||
public enum DrawDepth
|
||||
{
|
||||
LowFloors = DrawDepthTag.Default - 7,
|
||||
/// <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>
|
||||
BelowFloor = DrawDepthTag.Default - 6,
|
||||
FloorTiles = DrawDepthTag.Default - 5,
|
||||
|
||||
/// <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>
|
||||
FloorObjects = DrawDepthTag.Default - 4,
|
||||
|
||||
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,
|
||||
|
||||
/// <summary>
|
||||
/// Posters, APCs, air alarms, etc.
|
||||
/// </summary>
|
||||
WallMountedItems = DrawDepthTag.Default - 1,
|
||||
|
||||
/// <summary>
|
||||
/// Furniture, crates, etc.
|
||||
/// </summary>
|
||||
Objects = DrawDepthTag.Default,
|
||||
Items = DrawDepthTag.Default + 1,
|
||||
Mobs = DrawDepthTag.Default + 2,
|
||||
HighlightedItems = DrawDepthTag.Default + 3,
|
||||
Effects = DrawDepthTag.Default + 4,
|
||||
Ghosts = DrawDepthTag.Default + 5,
|
||||
Overlays = DrawDepthTag.Default + 6,
|
||||
|
||||
/// <summary>
|
||||
/// In-between an furniture and an item. Useful for entities that need to appear on top of tables, but are
|
||||
/// not items. E.g., power cell chargers. Also useful for pizza boxes, which appear above crates, but not
|
||||
/// above the pizza itself.
|
||||
/// </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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
sprite: Effects/arcs.rsi
|
||||
noRot: false
|
||||
offset: 0, -0.85
|
||||
drawdepth: Overlays
|
||||
drawdepth: Effects
|
||||
- type: MeleeWeaponArcAnimation
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Food/Baked/pizza.rsi
|
||||
drawdepth: FloorObjects
|
||||
drawdepth: SmallObjects
|
||||
layers:
|
||||
- state: box
|
||||
- state: box-open
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
|
||||
- type: entity
|
||||
id: CartridgeCap
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
netsync: false
|
||||
sprite: Objects/Weapons/Guns/Ammunition/Explosives/rpg.rsi
|
||||
state: frag
|
||||
drawdepth: FloorObjects
|
||||
|
||||
- type: entity
|
||||
id: GrenadeBaton
|
||||
@@ -28,7 +27,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
@@ -47,7 +45,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
@@ -66,7 +63,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
@@ -85,7 +81,6 @@
|
||||
layers:
|
||||
- state: base
|
||||
map: ["enum.AmmoVisualLayers.Base"]
|
||||
drawdepth: FloorObjects
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpentAmmoVisualizer
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs
|
||||
sprite: Structures/Doors/Airlocks/Standard/basic.rsi
|
||||
state: "assembly"
|
||||
- type: Physics
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Airlocks/Standard/basic.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
acts: ["Destruction"]
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Airlocks/Standard/firelock.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
@@ -48,6 +47,7 @@
|
||||
- VaultImpassable
|
||||
- SmallImpassable
|
||||
- type: Door
|
||||
openDrawDepth: WallTops
|
||||
closeTimeOne: 0.1
|
||||
closeTimeTwo: 0.6
|
||||
openTimeOne: 0.1
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Shutters/blastdoor.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Shutters/shutters.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
@@ -98,7 +97,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Shutters/shutters_radiation.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
@@ -121,7 +119,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs # They're on the same layer as mobs, perspective.
|
||||
sprite: Structures/Doors/Shutters/shutters_window.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: FloorObjects
|
||||
sprite: Structures/Doors/Windoors/windoor.rsi
|
||||
layers:
|
||||
- state: assembly
|
||||
@@ -53,7 +52,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: Mobs
|
||||
sprite: Structures/Doors/Windoors/windoor.rsi
|
||||
layers:
|
||||
- state: secure_underlay
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
- VaultImpassable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: FloorObjects
|
||||
sprite: Structures/Doors/Windoors/windoor.rsi
|
||||
layers:
|
||||
- state: closed
|
||||
@@ -104,7 +103,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: FloorObjects
|
||||
sprite: Structures/Doors/Windoors/windoor.rsi
|
||||
layers:
|
||||
- state: secure_underlay
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
- type: PlaceableSurface
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: FloorTiles
|
||||
- type: Icon
|
||||
state: full
|
||||
- type: IconSmooth
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
abstract: true
|
||||
components:
|
||||
- type: Sprite
|
||||
drawdepth: BelowFloor
|
||||
drawdepth: FloorTiles
|
||||
- type: Icon
|
||||
state: full
|
||||
- type: IconSmooth
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Machines/microwave.rsi
|
||||
drawdepth: WallMountedItems
|
||||
drawdepth: SmallObjects
|
||||
layers:
|
||||
- state: mw0
|
||||
map: ["enum.MicrowaveVisualizerLayers.Base"]
|
||||
|
||||
@@ -28,4 +28,4 @@
|
||||
netsync: false
|
||||
sprite: Structures/Machines/juicer.rsi
|
||||
state: juicer0
|
||||
drawdepth: Items
|
||||
drawdepth: SmallObjects
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Power/cell_recharger.rsi
|
||||
drawdepth: Items
|
||||
drawdepth: SmallObjects
|
||||
- type: Icon
|
||||
sprite: Structures/Power/cell_recharger.rsi
|
||||
state: empty
|
||||
@@ -27,7 +27,7 @@
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Power/recharger.rsi
|
||||
drawdepth: Items
|
||||
drawdepth: SmallObjects
|
||||
- type: Icon
|
||||
sprite: Structures/Power/recharger.rsi
|
||||
state: empty
|
||||
@@ -49,7 +49,7 @@
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Power/wall_recharger.rsi
|
||||
drawdepth: Items
|
||||
drawdepth: SmallObjects
|
||||
- type: Icon
|
||||
sprite: Structures/Power/wall_recharger.rsi
|
||||
state: empty
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
- type: Sprite
|
||||
sprite: Structures/Furniture/furniture.rsi
|
||||
state: rack
|
||||
drawdepth: FloorObjects
|
||||
- type: Physics
|
||||
bodyType: Static
|
||||
fixtures:
|
||||
|
||||
@@ -65,4 +65,4 @@
|
||||
sprite: Effects/fire.rsi
|
||||
normalState: 1
|
||||
Sprite:
|
||||
drawdepth: Overlays
|
||||
drawdepth: Effects
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
- type: Sprite
|
||||
sprite: Structures/Hydroponics/containers.rsi
|
||||
state: hydrotray3
|
||||
drawdepth: FloorObjects
|
||||
- type: PlantHolder
|
||||
drawWarnings: true
|
||||
- type: Construction
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
- type: Sprite
|
||||
sprite: Structures/Hydroponics/misc.rsi
|
||||
state: soil
|
||||
drawdepth: FloorObjects
|
||||
- type: PlantHolder
|
||||
drawWarnings: false
|
||||
- type: SolutionContainerManager
|
||||
|
||||
Reference in New Issue
Block a user