--- /dev/null
+using Content.Shared.Chemistry.Components;
+using Robust.Client.GameObjects;
+
+namespace Content.Client.Chemistry.EntitySystems;
+
+public sealed class PillSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ base.Initialize();
+ SubscribeLocalEvent<PillComponent, AfterAutoHandleStateEvent>(OnHandleState);
+ }
+
+ private void OnHandleState(EntityUid uid, PillComponent component, ref AfterAutoHandleStateEvent args)
+ {
+ if (!TryComp(uid, out SpriteComponent? sprite))
+ return;
+
+ if (!sprite.TryGetLayer(0, out var layer))
+ return;
+
+ layer.SetState($"pill{component.PillType + 1}");
+ }
+}
[Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly LabelSystem _labelSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly AppearanceSystem _appearance = default!;
private const string PillPrototypeId = "Pill";
_solutionContainerSystem.TryAddSolution(
item, itemSolution, withdrawal.SplitSolution(message.Dosage));
- if (TryComp<SpriteComponent>(item, out var spriteComp))
- spriteComp.LayerSetState(0, "pill" + (chemMaster.PillType + 1));
+ var pill = EnsureComp<PillComponent>(item);
+ pill.PillType = chemMaster.PillType;
+ Dirty(pill);
if (user.HasValue)
{
--- /dev/null
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Chemistry.Components;
+
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
+public sealed partial class PillComponent : Component
+{
+ /// <summary>
+ /// The pill id. Used for networking & serializing pill visuals.
+ /// </summary>
+ [AutoNetworkedField]
+ [DataField("pillType")]
+ [ViewVariables(VVAccess.ReadWrite)]
+ public uint PillType;
+}
- type: Item
size: 1
sprite: Objects/Specific/Chemistry/pills.rsi
+ - type: Pill
+ # TODO remove pill tag?
- type: Tag
tags:
- Pill