1
0

MaterialReclaimerComponent.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using Content.Shared.Whitelist;
  2. using JetBrains.Annotations;
  3. using Robust.Shared.Audio;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Serialization;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  7. namespace Content.Shared.Materials;
  8. /// <summary>
  9. /// This is a machine that handles converting entities
  10. /// into the raw materials and chemicals that make them up.
  11. /// </summary>
  12. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
  13. [Access(typeof(SharedMaterialReclaimerSystem))]
  14. public sealed partial class MaterialReclaimerComponent : Component
  15. {
  16. /// <summary>
  17. /// Whether or not the machine has power. We put it here
  18. /// so we can network and predict it.
  19. /// </summary>
  20. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  21. public bool Powered;
  22. /// <summary>
  23. /// An "enable" toggle for things like interfacing with machine linking
  24. /// </summary>
  25. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  26. public bool Enabled = true;
  27. /// <summary>
  28. /// A master control for whether or not the recycler is broken and can function.
  29. /// </summary>
  30. [DataField, AutoNetworkedField]
  31. public bool Broken;
  32. /// <summary>
  33. /// How efficiently the materials are reclaimed.
  34. /// In practice, a multiplier per material when calculating the output of the reclaimer.
  35. /// </summary>
  36. [DataField, ViewVariables(VVAccess.ReadWrite)]
  37. public float Efficiency = 1f;
  38. /// <summary>
  39. /// Whether or not the process
  40. /// speed scales with the amount of materials being processed
  41. /// or if it's just <see cref="MinimumProcessDuration"/>
  42. /// </summary>
  43. [DataField]
  44. public bool ScaleProcessSpeed = true;
  45. /// <summary>
  46. /// How quickly it takes to consume X amount of materials per second.
  47. /// For example, with a rate of 50, an entity with 100 total material takes 2 seconds to process.
  48. /// </summary>
  49. [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
  50. public float MaterialProcessRate = 100f;
  51. /// <summary>
  52. /// The minimum amount fo time it can take to process an entity.
  53. /// this value supercedes the calculated one using <see cref="MaterialProcessRate"/>
  54. /// </summary>
  55. [DataField, ViewVariables(VVAccess.ReadWrite)]
  56. public TimeSpan MinimumProcessDuration = TimeSpan.FromSeconds(0.5f);
  57. /// <summary>
  58. /// The id of our output solution
  59. /// </summary>
  60. [DataField]
  61. public string? SolutionContainerId;
  62. /// <summary>
  63. /// If the reclaimer should attempt to reclaim all solutions or just drainable ones
  64. /// Difference between Recycler and Industrial Reagent Grinder
  65. /// </summary>
  66. [DataField]
  67. public bool OnlyReclaimDrainable = true;
  68. /// <summary>
  69. /// a whitelist for what entities can be inserted into this reclaimer
  70. /// </summary>
  71. [DataField]
  72. public EntityWhitelist? Whitelist;
  73. /// <summary>
  74. /// a blacklist for what entities cannot be inserted into this reclaimer
  75. /// </summary>
  76. [DataField]
  77. public EntityWhitelist? Blacklist;
  78. /// <summary>
  79. /// The sound played when something is being processed.
  80. /// </summary>
  81. [DataField]
  82. public SoundSpecifier? Sound;
  83. /// <summary>
  84. /// whether or not we cut off the sound early when the reclaiming ends.
  85. /// </summary>
  86. [DataField]
  87. public bool CutOffSound = true;
  88. /// <summary>
  89. /// When the next sound will be allowed to be played. Used to prevent spam.
  90. /// </summary>
  91. [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
  92. [AutoPausedField]
  93. public TimeSpan NextSound;
  94. /// <summary>
  95. /// Minimum time inbetween each <see cref="Sound"/>
  96. /// </summary>
  97. [DataField]
  98. public TimeSpan SoundCooldown = TimeSpan.FromSeconds(0.8f);
  99. public EntityUid? Stream;
  100. /// <summary>
  101. /// A counter of how many items have been processed
  102. /// </summary>
  103. /// <remarks>
  104. /// I saw this on the recycler and i'm porting it because it's cute af
  105. /// </remarks>
  106. [DataField, AutoNetworkedField]
  107. public int ItemsProcessed;
  108. }
  109. [NetSerializable, Serializable]
  110. public enum RecyclerVisuals
  111. {
  112. Bloody,
  113. Broken
  114. }
  115. [UsedImplicitly]
  116. public enum RecyclerVisualLayers : byte
  117. {
  118. Main
  119. }