Remove server-side sprite references from chem master (#15888)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Leon Friedrich
2023-04-29 21:27:14 +12:00
committed by GitHub
parent 83c9e2bb50
commit a372daadb2
4 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
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}");
}
}

View File

@@ -34,6 +34,7 @@ namespace Content.Server.Chemistry.EntitySystems
[Dependency] private readonly StorageSystem _storageSystem = default!; [Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly LabelSystem _labelSystem = default!; [Dependency] private readonly LabelSystem _labelSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
private const string PillPrototypeId = "Pill"; private const string PillPrototypeId = "Pill";
@@ -206,8 +207,9 @@ namespace Content.Server.Chemistry.EntitySystems
_solutionContainerSystem.TryAddSolution( _solutionContainerSystem.TryAddSolution(
item, itemSolution, withdrawal.SplitSolution(message.Dosage)); item, itemSolution, withdrawal.SplitSolution(message.Dosage));
if (TryComp<SpriteComponent>(item, out var spriteComp)) var pill = EnsureComp<PillComponent>(item);
spriteComp.LayerSetState(0, "pill" + (chemMaster.PillType + 1)); pill.PillType = chemMaster.PillType;
Dirty(pill);
if (user.HasValue) if (user.HasValue)
{ {

View File

@@ -0,0 +1,15 @@
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;
}

View File

@@ -283,6 +283,8 @@
- type: Item - type: Item
size: 1 size: 1
sprite: Objects/Specific/Chemistry/pills.rsi sprite: Objects/Specific/Chemistry/pills.rsi
- type: Pill
# TODO remove pill tag?
- type: Tag - type: Tag
tags: tags:
- Pill - Pill