Rename SmokeDissipateSpawnComponent to SpawnOnDespawnComponent (#20782)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using Content.Server.Spawners.EntitySystems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Spawners.Components;
|
||||
|
||||
/// <summary>
|
||||
/// When a <c>TimedDespawnComponent"</c> despawns, another one will be spawned in its place.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(SpawnOnDespawnSystem))]
|
||||
public sealed partial class SpawnOnDespawnComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Entity prototype to spawn.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public EntProtoId Prototype = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Content.Server.Spawners.Components;
|
||||
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<TransformComponent>(uid, out var xform))
|
||||
return;
|
||||
|
||||
Spawn(comp.Prototype, xform.Coordinates);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user