Stacks now use ComponentHandleState.

This commit is contained in:
Vera Aguilera Puerto
2021-07-11 11:07:27 +02:00
parent d8bfb7c054
commit 14c2f65b17
2 changed files with 28 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.Examine;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Localization;
namespace Content.Shared.Stacks
@@ -12,6 +13,7 @@ namespace Content.Shared.Stacks
{
base.Initialize();
SubscribeLocalEvent<SharedStackComponent, ComponentHandleState>(OnStackHandleState);
SubscribeLocalEvent<SharedStackComponent, ComponentStartup>(OnStackStarted);
SubscribeLocalEvent<SharedStackComponent, ExaminedEvent>(OnStackExamined);
}
@@ -60,6 +62,16 @@ namespace Content.Shared.Stacks
RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count));
}
private void OnStackHandleState(EntityUid uid, SharedStackComponent component, ComponentHandleState args)
{
if (args.Current is not StackComponentState cast)
return;
// This will change the count and call events.
SetCount(uid, component, cast.Count);
component.MaxCount = cast.MaxCount;
}
private void OnStackExamined(EntityUid uid, SharedStackComponent component, ExaminedEvent args)
{
if (!args.IsInDetailsRange)