SharedLightningComponent.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Content.Shared.Physics;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  4. namespace Content.Shared.Lightning.Components;
  5. /// <summary>
  6. /// Handles how lightning acts and is spawned. Use the ShootLightning method to fire lightning from one user to a target.
  7. /// </summary>
  8. public abstract partial class SharedLightningComponent : Component
  9. {
  10. /// <summary>
  11. /// Can this lightning arc?
  12. /// </summary>
  13. [ViewVariables(VVAccess.ReadWrite)]
  14. [DataField("canArc")]
  15. public bool CanArc;
  16. /// <summary>
  17. /// How much should lightning arc in total?
  18. /// Controls the amount of bolts that will spawn.
  19. /// </summary>
  20. [ViewVariables(VVAccess.ReadWrite)]
  21. [DataField("maxTotalArc")]
  22. public int MaxTotalArcs = 50;
  23. /// <summary>
  24. /// The prototype ID used for arcing bolts. Usually will be the same name as the main proto but it could be flexible.
  25. /// </summary>
  26. [ViewVariables(VVAccess.ReadWrite)]
  27. [DataField("lightningPrototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
  28. public string LightningPrototype = "Lightning";
  29. /// <summary>
  30. /// The target that the lightning will Arc to.
  31. /// </summary>
  32. [DataField("arcTarget")]
  33. public EntityUid? ArcTarget;
  34. /// <summary>
  35. /// How far should this lightning go?
  36. /// </summary>
  37. [ViewVariables(VVAccess.ReadWrite)]
  38. [DataField("maxLength")]
  39. public float MaxLength = 5f;
  40. /// <summary>
  41. /// List of targets that this collided with already
  42. /// </summary>
  43. [DataField("arcTargets")]
  44. public HashSet<EntityUid> ArcTargets = new();
  45. /// <summary>
  46. /// What should this arc to?
  47. /// </summary>
  48. [DataField("collisionMask")]
  49. public int CollisionMask = (int) (CollisionGroup.MobMask | CollisionGroup.MachineMask);
  50. }