Predict StorageComponent (#19682)

This commit is contained in:
metalgearsloth
2023-09-11 21:20:46 +10:00
committed by GitHub
parent 99b77bc2d3
commit d5bd1c6f86
68 changed files with 1124 additions and 1121 deletions

View File

@@ -1,11 +1,17 @@
using Content.Client.Animations;
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Timing;
namespace Content.Client.Storage.Systems;
// TODO kill this is all horrid.
public sealed class StorageSystem : EntitySystem
public sealed class StorageSystem : SharedStorageSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
public event Action<EntityUid, StorageComponent>? StorageUpdated;
public override void Initialize()
{
base.Initialize();
@@ -13,22 +19,24 @@ public sealed class StorageSystem : EntitySystem
SubscribeNetworkEvent<AnimateInsertingEntitiesEvent>(HandleAnimatingInsertingEntities);
}
public override void UpdateUI(EntityUid uid, StorageComponent component)
{
// Should we wrap this in some prediction call maybe?
StorageUpdated?.Invoke(uid, component);
}
/// <summary>
/// Animate the newly stored entities in <paramref name="msg"/> flying towards this storage's position
/// </summary>
/// <param name="msg"></param>
public void HandleAnimatingInsertingEntities(AnimateInsertingEntitiesEvent msg)
{
var store = GetEntity(msg.Storage);
if (!HasComp<ClientStorageComponent>(store))
return;
TryComp(store, out TransformComponent? transformComp);
TryComp(GetEntity(msg.Storage), out TransformComponent? transformComp);
for (var i = 0; msg.StoredEntities.Count > i; i++)
{
var entity = GetEntity(msg.StoredEntities[i]);
var initialPosition = msg.EntityPositions[i];
if (EntityManager.EntityExists(entity) && transformComp != null)
{