fish-station/Content.Shared/_Sunrise/Explosion/SharedSunriseExplosionSystem.cs
ThereDrD 6c8050eb1e
Новые эффекты взрывов (#1410)
Co-authored-by: Vero <73014819+vero5123@users.noreply.github.com>
Co-authored-by: Whisper <121047731+QuietlyWhisper@users.noreply.github.com>
Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
2025-02-20 17:29:41 +03:00

35 lines
1 KiB
C#

using Content.Shared._RMC14.Explosion;
using Content.Shared.Explosion;
using Content.Shared.Explosion.Components;
using Robust.Shared.Prototypes;
namespace Content.Shared._Sunrise.Explosion;
public sealed class SharedSunriseExplosionSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ExplosiveComponent, ComponentInit>(OnInit);
}
private void OnInit(Entity<ExplosiveComponent> ent, ref ComponentInit args)
{
TryAddExplosionEffect(ent, ent.Comp.ExplosionType);
}
public bool TryAddExplosionEffect(EntityUid uid, string explosionType)
{
if (!_prototype.TryIndex<ExplosionPrototype>(explosionType, out var explosionPrototype))
return false;
if (explosionPrototype.EffectType != ExplosionEffectType.Fancy)
return false;
EnsureComp<CMExplosionEffectComponent>(uid);
return true;
}
}