2024-02-17 17:38:21 +01:00
|
|
|
using Content.Server.Mind;
|
2024-02-16 18:54:44 -08:00
|
|
|
using Content.Shared.Species.Components;
|
|
|
|
|
using Content.Shared.Body.Events;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
using Robust.Shared.Timing;
|
|
|
|
|
|
2024-02-17 17:38:21 +01:00
|
|
|
namespace Content.Server.Species.Systems;
|
2024-02-16 18:54:44 -08:00
|
|
|
|
|
|
|
|
public sealed partial class NymphSystem : EntitySystem
|
|
|
|
|
{
|
2024-02-17 17:38:21 +01:00
|
|
|
[Dependency] private readonly IPrototypeManager _protoManager= default!;
|
|
|
|
|
[Dependency] private readonly MindSystem _mindSystem = default!;
|
2024-02-16 18:54:44 -08:00
|
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<NymphComponent, RemovedFromPartInBodyEvent>(OnRemovedFromPart);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRemovedFromPart(EntityUid uid, NymphComponent comp, RemovedFromPartInBodyEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!_timing.IsFirstTimePredicted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.OldBody))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!_protoManager.TryIndex<EntityPrototype>(comp.EntityPrototype, out var entityProto))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var coords = Transform(uid).Coordinates;
|
2024-02-17 17:38:21 +01:00
|
|
|
var nymph = EntityManager.SpawnAtPosition(entityProto.ID, coords);
|
2024-02-16 18:54:44 -08:00
|
|
|
|
|
|
|
|
if (comp.TransferMind == true && _mindSystem.TryGetMind(args.OldBody, out var mindId, out var mind))
|
|
|
|
|
_mindSystem.TransferTo(mindId, nymph, mind: mind);
|
|
|
|
|
|
2024-02-17 17:38:21 +01:00
|
|
|
QueueDel(uid);
|
2024-02-16 18:54:44 -08:00
|
|
|
}
|
|
|
|
|
}
|