Files
tbd-station-14/Content.Server/Spawners/EntitySystems/SpawnOnDespawnSystem.cs
Plykiya 1d2b7131ab Meteors now leave behind a bit of ore (#30419)
* Meteors that leave behind asteroid ore

* bigger offset

* Bit more generic

* Better defaults

* hrm?

* I HATE CUSTOM SERIALIZERS

* More comments

* renamed a variable

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
2024-07-31 19:55:02 -07:00

29 lines
766 B
C#

using Content.Server.Spawners.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Spawners;
namespace Content.Server.Spawners.EntitySystems;
public sealed class SpawnOnDespawnSystem : EntitySystem
{
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;
Spawn(comp.Prototype, xform.Coordinates);
}
public void SetPrototype(Entity<SpawnOnDespawnComponent> entity, EntProtoId prototype)
{
entity.Comp.Prototype = prototype;
}
}