Airlock / firelock code refactor, pseudo-prediction implementation (#3037)
* splits off airlocks, firelocks * adds airlock prediction. anims broken though * fixes animation weirdness * removes opacity prediction because it looked odd * Now firelocks don't visually start open. Argh. * Fixes firelock weirdness, saneifies _state var. * Documentation changes, code shuffle. * Lets firelocks crush people. * Stops open-hand opening/closing firelocks. * updates serializable, netserializable attributes * Addresses reviews... hopefully. * updates submodule? * nullability * fuck fuck fuck fuck * fucking finally
This commit is contained in:
62
Content.Client/GameObjects/EntitySystems/ClientDoorSystem.cs
Normal file
62
Content.Client/GameObjects/EntitySystems/ClientDoorSystem.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components.Doors;
|
||||
using Content.Shared.GameObjects.Components.Doors;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the client to "predict" when doors will change how collideable they are as part of their opening / closing.
|
||||
/// </summary>
|
||||
public class ClientDoorSystem : EntitySystem
|
||||
{
|
||||
/// <summary>
|
||||
/// List of doors that need to be periodically checked.
|
||||
/// </summary>
|
||||
private readonly List<ClientDoorComponent> _activeDoors = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DoorStateMessage>(HandleDoorState);
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
switch (message.State)
|
||||
{
|
||||
case SharedDoorComponent.DoorState.Closed:
|
||||
case SharedDoorComponent.DoorState.Open:
|
||||
_activeDoors.Remove(message.Component);
|
||||
break;
|
||||
case SharedDoorComponent.DoorState.Closing:
|
||||
case SharedDoorComponent.DoorState.Opening:
|
||||
_activeDoors.Add(message.Component);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
for (var i = _activeDoors.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var comp = _activeDoors[i];
|
||||
if (comp.Deleted)
|
||||
{
|
||||
_activeDoors.RemoveAt(i);
|
||||
}
|
||||
comp.OnUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user