SharedExplosionSystem.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Content.Shared.Armor;
  2. using Content.Shared.Explosion.Components;
  3. namespace Content.Shared.Explosion.EntitySystems;
  4. /// <summary>
  5. /// Lets code in shared trigger explosions and handles explosion resistance examining.
  6. /// All processing is still done clientside.
  7. /// </summary>
  8. public abstract class SharedExplosionSystem : EntitySystem
  9. {
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
  14. }
  15. private void OnArmorExamine(Entity<ExplosionResistanceComponent> ent, ref ArmorExamineEvent args)
  16. {
  17. var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
  18. if (value == 0)
  19. return;
  20. args.Msg.PushNewline();
  21. args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
  22. }
  23. /// <summary>
  24. /// Given an entity with an explosive component, spawn the appropriate explosion.
  25. /// </summary>
  26. /// <remarks>
  27. /// Also accepts radius or intensity arguments. This is useful for explosives where the intensity is not
  28. /// specified in the yaml / by the component, but determined dynamically (e.g., by the quantity of a
  29. /// solution in a reaction).
  30. /// </remarks>
  31. public virtual void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
  32. {
  33. }
  34. }