| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using Content.Shared.Armor;
- using Content.Shared.Explosion.Components;
- namespace Content.Shared.Explosion.EntitySystems;
- /// <summary>
- /// Lets code in shared trigger explosions and handles explosion resistance examining.
- /// All processing is still done clientside.
- /// </summary>
- public abstract class SharedExplosionSystem : EntitySystem
- {
- public override void Initialize()
- {
- base.Initialize();
- SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
- }
- private void OnArmorExamine(Entity<ExplosionResistanceComponent> ent, ref ArmorExamineEvent args)
- {
- var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
- if (value == 0)
- return;
- args.Msg.PushNewline();
- args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
- }
- /// <summary>
- /// Given an entity with an explosive component, spawn the appropriate explosion.
- /// </summary>
- /// <remarks>
- /// Also accepts radius or intensity arguments. This is useful for explosives where the intensity is not
- /// specified in the yaml / by the component, but determined dynamically (e.g., by the quantity of a
- /// solution in a reaction).
- /// </remarks>
- public virtual void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
- {
- }
- }
|