2024-01-26 16:08:08 +07:00
|
|
|
using Content.Server.Body.Systems;
|
|
|
|
|
using Content.Shared.Body.Organ;
|
|
|
|
|
using Content.Shared.Construction;
|
2024-01-28 18:37:24 +07:00
|
|
|
using Content.Shared._White.CheapSurgery;
|
2024-03-21 04:54:07 +09:00
|
|
|
using Content.Shared.Changeling;
|
2024-01-26 16:08:08 +07:00
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
namespace Content.Server._White.Construction.Completions;
|
2024-01-26 16:08:08 +07:00
|
|
|
|
|
|
|
|
public sealed partial class Surgery : IGraphAction
|
|
|
|
|
{
|
|
|
|
|
private ISawmill _sawmill = default!;
|
|
|
|
|
|
|
|
|
|
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
|
|
|
|
{
|
|
|
|
|
_sawmill = Logger.GetSawmill("Surgery");
|
|
|
|
|
var bodySystem = entityManager.EntitySysManager.GetEntitySystem<BodySystem>();
|
|
|
|
|
|
|
|
|
|
if (!entityManager.TryGetComponent<ActiveSurgeryComponent>(uid, out var surgeryComponent))
|
|
|
|
|
{
|
|
|
|
|
_sawmill.Warning($"Entity {uid} does not have a ActiveSurgery Component");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-21 04:54:07 +09:00
|
|
|
if (entityManager.TryGetComponent<OrganComponent>(surgeryComponent.OrganUid, out var organComponent) &&
|
|
|
|
|
!entityManager.HasComponent<ChangelingComponent>(uid))
|
2024-01-26 16:08:08 +07:00
|
|
|
bodySystem.RemoveOrgan(surgeryComponent.OrganUid, organComponent);
|
|
|
|
|
|
|
|
|
|
entityManager.RemoveComponent<ActiveSurgeryComponent>(uid);
|
|
|
|
|
}
|
|
|
|
|
}
|