ArtifactCrusherComponent.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Content.Shared.Damage;
  2. using Content.Shared.Stacks;
  3. using Content.Shared.Whitelist;
  4. using Robust.Shared.Audio;
  5. using Robust.Shared.Audio.Components;
  6. using Robust.Shared.Containers;
  7. using Robust.Shared.GameStates;
  8. using Robust.Shared.Prototypes;
  9. using Robust.Shared.Serialization;
  10. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  11. namespace Content.Shared.Xenoarchaeology.Equipment;
  12. /// <summary>
  13. /// This is an entity storage that, when activated, crushes the artifact inside of it and gives artifact fragments.
  14. /// </summary>
  15. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  16. [Access(typeof(SharedArtifactCrusherSystem))]
  17. public sealed partial class ArtifactCrusherComponent : Component
  18. {
  19. /// <summary>
  20. /// Whether or not the crusher is currently in the process of crushing something.
  21. /// </summary>
  22. [DataField, AutoNetworkedField]
  23. public bool Crushing;
  24. /// <summary>
  25. /// When the current crushing will end.
  26. /// </summary>
  27. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  28. public TimeSpan CrushEndTime;
  29. /// <summary>
  30. /// The next second. Used to apply damage over time.
  31. /// </summary>
  32. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  33. public TimeSpan NextSecond;
  34. /// <summary>
  35. /// The total duration of the crushing.
  36. /// </summary>
  37. [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  38. public TimeSpan CrushDuration = TimeSpan.FromSeconds(10);
  39. /// <summary>
  40. /// A whitelist specifying what items, when crushed, will give fragments.
  41. /// </summary>
  42. [DataField]
  43. public EntityWhitelist CrushingWhitelist = new();
  44. /// <summary>
  45. /// The minimum amount of fragments spawned.
  46. /// </summary>
  47. [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  48. public int MinFragments = 2;
  49. /// <summary>
  50. /// The maximum amount of fragments spawned, non-inclusive.
  51. /// </summary>
  52. [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
  53. public int MaxFragments = 5;
  54. /// <summary>
  55. /// The material for the fragments.
  56. /// </summary>
  57. [DataField, ViewVariables(VVAccess.ReadWrite)]
  58. public ProtoId<StackPrototype> FragmentStackProtoId = "ArtifactFragment";
  59. /// <summary>
  60. /// A container used to hold fragments and gibs from crushing.
  61. /// </summary>
  62. [ViewVariables]
  63. public Container OutputContainer;
  64. /// <summary>
  65. /// The ID for <see cref="OutputContainer"/>
  66. /// </summary>
  67. [DataField]
  68. public string OutputContainerName = "output_container";
  69. /// <summary>
  70. /// Damage dealt each second to entities inside while crushing.
  71. /// </summary>
  72. [DataField]
  73. public DamageSpecifier CrushingDamage = new();
  74. /// <summary>
  75. /// Sound played at the end of a successful crush.
  76. /// </summary>
  77. [DataField, AutoNetworkedField]
  78. public SoundSpecifier? CrushingCompleteSound = new SoundCollectionSpecifier("MetalCrunch");
  79. /// <summary>
  80. /// Sound played throughout the entire crushing. Cut off if ended early.
  81. /// </summary>
  82. [DataField, AutoNetworkedField]
  83. public SoundSpecifier? CrushingSound = new SoundPathSpecifier("/Audio/Effects/hydraulic_press.ogg");
  84. /// <summary>
  85. /// Stores entity of <see cref="CrushingSound"/> to allow ending it early.
  86. /// </summary>
  87. [DataField]
  88. public (EntityUid, AudioComponent)? CrushingSoundEntity;
  89. /// <summary>
  90. /// When enabled, stops the artifact crusher from being opened when it is being crushed.
  91. /// </summary>
  92. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  93. public bool AutoLock = false;
  94. }
  95. [Serializable, NetSerializable]
  96. public enum ArtifactCrusherVisuals : byte
  97. {
  98. Crushing
  99. }