Removes all dependencies on engine component events. (#4199)

This commit is contained in:
Acruid
2021-06-18 01:49:18 -07:00
committed by GitHub
parent 9fea68707c
commit e1e54e9cb1
27 changed files with 235 additions and 184 deletions

View File

@@ -10,6 +10,7 @@ using Content.Shared.Acts;
using Content.Shared.Body.Components;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Movement;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Physics;

View File

@@ -47,24 +47,17 @@ namespace Content.Server.Storage.Components
}
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
public void ContainerUpdateAppearance(IContainer container)
{
base.HandleMessage(message, component);
if(_appearanceComponent is null)
return;
if (_appearanceComponent != null)
var actual = Count(container.ContainedEntities);
_appearanceComponent.SetData(StackVisuals.Actual, actual);
if (_maxAmount != null)
{
switch (message)
{
case ContainerContentsModifiedMessage msg:
var actual = Count(msg.Container.ContainedEntities);
_appearanceComponent.SetData(StackVisuals.Actual, actual);
if (_maxAmount != null)
{
_appearanceComponent.SetData(StackVisuals.MaxCount, _maxAmount);
}
break;
}
_appearanceComponent.SetData(StackVisuals.MaxCount, _maxAmount);
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Content.Server.Interaction;
using Content.Server.Storage.Components;
using JetBrains.Annotations;
@@ -39,6 +39,11 @@ namespace Content.Server.Storage
{
storageComp.HandleEntityMaybeRemoved(message);
}
if (oldParentEntity.TryGetComponent<StorageCounterComponent>(out var newStorageComp))
{
newStorageComp.ContainerUpdateAppearance(message.Container);
}
}
private static void HandleEntityInsertedIntoContainer(EntInsertedIntoContainerMessage message)
@@ -49,6 +54,11 @@ namespace Content.Server.Storage
{
storageComp.HandleEntityMaybeInserted(message);
}
if (oldParentEntity.TryGetComponent<StorageCounterComponent>(out var newStorageComp))
{
newStorageComp.ContainerUpdateAppearance(message.Container);
}
}
private void CheckSubscribedEntities(ServerStorageComponent storageComp)