Remove server-side sprite references from chem master (#15888)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
24
Content.Client/Chemistry/EntitySystems/PillSystem.cs
Normal file
24
Content.Client/Chemistry/EntitySystems/PillSystem.cs
Normal 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}");
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
[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";
|
||||
|
||||
@@ -206,8 +207,9 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
_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)
|
||||
{
|
||||
|
||||
15
Content.Shared/Chemistry/Components/PillComponent.cs
Normal file
15
Content.Shared/Chemistry/Components/PillComponent.cs
Normal 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;
|
||||
}
|
||||
@@ -283,6 +283,8 @@
|
||||
- type: Item
|
||||
size: 1
|
||||
sprite: Objects/Specific/Chemistry/pills.rsi
|
||||
- type: Pill
|
||||
# TODO remove pill tag?
|
||||
- type: Tag
|
||||
tags:
|
||||
- Pill
|
||||
|
||||
Reference in New Issue
Block a user