Files
wwdpublic/Content.Server/Spawners/EntitySystems/SpawnOnDespawnSystem.cs
Spatison bee3125947 [Tweak] Blood Cult (#859)
* commit

* commit

* commit

* commit

* fuck

* cockmit

* fix

* fix Yaml

* test fix
2025-10-12 00:53:06 +03:00

48 lines
1.3 KiB
C#

using Content.Server.Mind;
using Content.Server.Spawners.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Spawners;
namespace Content.Server.Spawners.EntitySystems;
public sealed class SpawnOnDespawnSystem : EntitySystem
{
[Dependency] private readonly MindSystem _mind = default!; // WD EDIT
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpawnOnDespawnComponent, TimedDespawnEvent>(OnDespawn);
}
private void OnDespawn(EntityUid uid, SpawnOnDespawnComponent comp, ref TimedDespawnEvent args)
{
if (!TryComp(uid, out TransformComponent? xform))
return;
// Lavaland Change start
if (comp.Prototype != null)
{
// WD EDIT START
var spawned = Spawn(comp.Prototype, xform.Coordinates);
if (_mind.TryGetMind(uid, out var mindId, out _))
_mind.TransferTo(mindId, spawned);
// WD EDIT END
}
// Lavaland Change end
// Lavaland Change start
// make it spawn more (without intrusion)
foreach (var prot in comp.Prototypes)
Spawn(prot, xform.Coordinates);
// Lavaland Change end
}
public void SetPrototype(Entity<SpawnOnDespawnComponent> entity, EntProtoId prototype)
{
entity.Comp.Prototype = prototype;
}
}