Skip to content

Commit

Permalink
Rename SmokeDissipateSpawnComponent to SpawnOnDespawnComponent (#20782)
Browse files Browse the repository at this point in the history
  • Loading branch information
deltanedas authored Oct 11, 2023
1 parent d466747 commit e911c9e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.

This file was deleted.

11 changes: 0 additions & 11 deletions Content.Server/Fluids/EntitySystems/SmokeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ public override void Initialize()
SubscribeLocalEvent<SmokeComponent, EntityUnpausedEvent>(OnSmokeUnpaused);
SubscribeLocalEvent<SmokeComponent, ReactionAttemptEvent>(OnReactionAttempt);
SubscribeLocalEvent<SmokeComponent, SpreadNeighborsEvent>(OnSmokeSpread);
SubscribeLocalEvent<SmokeDissipateSpawnComponent, TimedDespawnEvent>(OnSmokeDissipate);
}

private void OnSmokeDissipate(EntityUid uid, SmokeDissipateSpawnComponent component, ref TimedDespawnEvent args)
{
if (!TryComp<TransformComponent>(uid, out var xform))
{
return;
}

Spawn(component.Prototype, xform.Coordinates);
}

private void OnSmokeSpread(EntityUid uid, SmokeComponent component, ref SpreadNeighborsEvent args)
Expand Down
18 changes: 18 additions & 0 deletions Content.Server/Spawners/Components/SpawnOnDespawnComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
22 changes: 22 additions & 0 deletions Content.Server/Spawners/EntitySystems/SpawnOnDespawnSystem.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Effects/chemistry_effects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
animationTime: 0.6
animationState: mfoam-dissolve
- type: Smoke
- type: SmokeDissipateSpawn
- type: SpawnOnDespawn
prototype: FoamedIronMetal

- type: entity
Expand All @@ -109,7 +109,7 @@
animationTime: 0.6
animationState: mfoam-dissolve
- type: Smoke
- type: SmokeDissipateSpawn
- type: SpawnOnDespawn
prototype: FoamedAluminiumMetal

- type: entity
Expand Down

0 comments on commit e911c9e

Please sign in to comment.