Implanters and Subdermal Implants (#11840)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
39
Content.Server/Jobs/AddImplantSpecial.cs
Normal file
39
Content.Server/Jobs/AddImplantSpecial.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Content.Shared.Implants;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Shared.Roles;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Adds implants on spawn to the entity
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class AddImplantSpecial : JobSpecial
|
||||
{
|
||||
|
||||
[DataField("implants", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<EntityPrototype>))]
|
||||
public HashSet<String> Implants { get; } = new();
|
||||
|
||||
public override void AfterEquip(EntityUid mob)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var implantSystem = entMan.System<SharedSubdermalImplantSystem>();
|
||||
var xformQuery = entMan.GetEntityQuery<TransformComponent>();
|
||||
|
||||
if (!xformQuery.TryGetComponent(mob, out var xform))
|
||||
return;
|
||||
|
||||
foreach (var implantId in Implants)
|
||||
{
|
||||
var implant = entMan.SpawnEntity(implantId, xform.Coordinates);
|
||||
|
||||
if (!entMan.TryGetComponent<SubdermalImplantComponent>(implant, out var implantComp))
|
||||
return;
|
||||
|
||||
implantSystem.ForceImplant(mob, implant, implantComp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user