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 />
|
||||
|
||||
Reference in New Issue
Block a user