Files
wwdpublic/Content.Shared/_Shitmed/Autodoc/Systems/HandsFillSystem.cs
gluesniffler 2a33691a1c Ports Shitmed Updates From Goob (#1387)
Lots of stuff. Also moved everything I could to the _Shitmed namespace
as I do in Goob. Will make future ports way faster

# Changelog
🆑 Mocho
- add: Added some fun organs and other thingies, check out the Goob PRs
if you want more details.
- fix: Fixed tons of issues with shitmed. Too many for the changelog in
fact.

(cherry picked from commit 3c9db94102cb25b28a83d51ac8d659fa31fe7d12)
2025-01-13 23:01:51 +03:00

40 lines
1.2 KiB
C#

using Content.Shared._Shitmed.Autodoc.Components;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
namespace Content.Shared._Shitmed.Autodoc.Systems;
public sealed class HandsFillSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _hands = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HandsFillComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(Entity<HandsFillComponent> ent, ref MapInitEvent args)
{
if (!TryComp<HandsComponent>(ent, out var hands))
return;
var coords = Transform(ent).Coordinates;
foreach (var (name, fill) in ent.Comp.Hands)
{
_hands.AddHand(ent, name, HandLocation.Middle, hands);
if (fill is not {} id)
continue;
var uid = Spawn(id, coords);
if (!_hands.TryPickup(ent, uid, name, animate: false, handsComp: hands))
{
Log.Error($"Entity {ToPrettyString(ent)} couldn't pick up item {id} into its '{name}' hand!");
Del(uid);
}
}
}
}