ExplosionResistanceComponent.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Content.Shared.Explosion.EntitySystems;
  2. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
  3. using Robust.Shared.GameStates;
  4. namespace Content.Shared.Explosion.Components;
  5. /// <summary>
  6. /// Component that provides entities with explosion resistance.
  7. /// By default this is applied when worn, but to solely protect the entity itself and
  8. /// not the wearer use <c>worn: false</c>.
  9. /// </summary>
  10. /// <remarks>
  11. /// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
  12. /// significantly reduce the damage, but shouldn't be silly overpowered in regular combat.
  13. /// </remarks>
  14. [NetworkedComponent, RegisterComponent]
  15. [Access(typeof(SharedExplosionSystem))]
  16. public sealed partial class ExplosionResistanceComponent : Component
  17. {
  18. /// <summary>
  19. /// The explosive resistance coefficient, This fraction is multiplied into the total resistance.
  20. /// </summary>
  21. [DataField("damageCoefficient")]
  22. public float DamageCoefficient = 1;
  23. /// <summary>
  24. /// When true, resistances will be applied to the entity wearing this item.
  25. /// When false, only this entity will get th resistance.
  26. /// </summary>
  27. [DataField, ViewVariables(VVAccess.ReadWrite)]
  28. public bool Worn = true;
  29. /// <summary>
  30. /// Examine string for explosion resistance.
  31. /// Passed <c>value</c> from 0 to 100.
  32. /// </summary>
  33. [DataField, ViewVariables(VVAccess.ReadWrite)]
  34. public LocId Examine = "explosion-resistance-coefficient-value";
  35. /// <summary>
  36. /// Modifiers specific to each explosion type for more customizability.
  37. /// </summary>
  38. [ViewVariables(VVAccess.ReadWrite)]
  39. [DataField("modifiers", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, ExplosionPrototype>))]
  40. public Dictionary<string, float> Modifiers = new();
  41. }