FireProtectionSystem.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Content.Shared.Armor;
  2. using Content.Shared.Atmos;
  3. using Content.Shared.Clothing.Components;
  4. using Content.Shared.Inventory;
  5. namespace Content.Shared.Clothing.EntitySystems;
  6. /// <summary>
  7. /// Handles reducing fire damage when wearing clothing with <see cref="FireProtectionComponent"/>.
  8. /// </summary>
  9. public sealed class FireProtectionSystem : EntitySystem
  10. {
  11. public override void Initialize()
  12. {
  13. base.Initialize();
  14. SubscribeLocalEvent<FireProtectionComponent, InventoryRelayedEvent<GetFireProtectionEvent>>(OnGetProtection);
  15. SubscribeLocalEvent<FireProtectionComponent, ArmorExamineEvent>(OnArmorExamine);
  16. }
  17. private void OnGetProtection(Entity<FireProtectionComponent> ent, ref InventoryRelayedEvent<GetFireProtectionEvent> args)
  18. {
  19. args.Args.Reduce(ent.Comp.Reduction);
  20. }
  21. private void OnArmorExamine(Entity<FireProtectionComponent> ent, ref ArmorExamineEvent args)
  22. {
  23. var value = MathF.Round((1f - ent.Comp.Reduction) * 100, 1);
  24. if (value == 0)
  25. return;
  26. args.Msg.PushNewline();
  27. args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.ExamineMessage, ("value", value)));
  28. }
  29. }