SpawnEntityEffectSystem.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
  2. // SPDX-FileCopyrightText: 2025 Piras314 <p1r4s@proton.me>
  3. // SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
  4. //
  5. // SPDX-License-Identifier: AGPL-3.0-or-later
  6. using Content.Shared.NPC.Components;
  7. using Content.Shared.NPC.Systems;
  8. using Content.Shared._Shitmed.StatusEffects;
  9. namespace Content.Server._Shitmed.StatusEffects;
  10. public sealed class SpawnEntityEffectSystem : EntitySystem
  11. {
  12. [Dependency] private readonly SharedTransformSystem _xformSys = default!;
  13. [Dependency] private readonly NpcFactionSystem _factionException = default!;
  14. public override void Initialize()
  15. {
  16. SubscribeLocalEvent<SpawnSpiderEggsComponent, ComponentInit>(OnInit);
  17. SubscribeLocalEvent<SpawnSlimesComponent, ComponentInit>(OnInit);
  18. SubscribeLocalEvent<SpawnEmpComponent, ComponentInit>(OnInit);
  19. SubscribeLocalEvent<SpawnGravityWellComponent, ComponentInit>(OnInit);
  20. SubscribeLocalEvent<SpawnFlashComponent, ComponentInit>(OnInit);
  21. SubscribeLocalEvent<SpawnSmokeComponent, ComponentInit>(OnInit);
  22. }
  23. private void OnInit(EntityUid uid, SpawnEntityEffectComponent component, ComponentInit args)
  24. {
  25. EntityUid entity;
  26. if (component.AttachToParent)
  27. {
  28. entity = SpawnAttachedTo(component.EntityPrototype, Transform(uid).Coordinates);
  29. _xformSys.SetParent(entity, uid);
  30. }
  31. else
  32. {
  33. entity = Spawn(component.EntityPrototype, Transform(uid).Coordinates);
  34. }
  35. if (component.IsFriendly)
  36. {
  37. if (EnsureComp<FactionExceptionComponent>(entity, out var comp))
  38. return;
  39. _factionException.IgnoreEntities(entity, new[] { uid });
  40. }
  41. }
  42. }