ItemMapper ECS (#9867)

This commit is contained in:
metalgearsloth
2022-08-08 12:35:57 +10:00
committed by GitHub
parent b55b806c6b
commit 189d49a51f
13 changed files with 112 additions and 156 deletions

View File

@@ -0,0 +1,37 @@
using Content.Client.Animations;
using Content.Shared.Storage;
namespace Content.Client.Storage.Systems;
// TODO kill this is all horrid.
public sealed class StorageSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<AnimateInsertingEntitiesEvent>(HandleAnimatingInsertingEntities);
}
/// <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)
{
if (!TryComp(msg.Storage, out ClientStorageComponent? storage))
return;
TryComp(msg.Storage, out TransformComponent? transformComp);
for (var i = 0; msg.StoredEntities.Count > i; i++)
{
var entity = msg.StoredEntities[i];
var initialPosition = msg.EntityPositions[i];
if (EntityManager.EntityExists(entity) && transformComp != null)
{
ReusableAnimations.AnimateEntityPickup(entity, initialPosition, transformComp.LocalPosition, EntityManager);
}
}
}
}