using Content.Shared.Chemistry.Components; using Content.Shared.Construction.Prototypes; using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Materials; /// /// This is a machine that handles converting entities /// into the raw materials and chemicals that make them up. /// [RegisterComponent, NetworkedComponent, Access(typeof(SharedMaterialReclaimerSystem))] public sealed partial class MaterialReclaimerComponent : Component { /// /// Whether or not the machine has power. We put it here /// so we can network and predict it. /// [DataField("powered"), ViewVariables(VVAccess.ReadWrite)] public bool Powered; /// /// An "enable" toggle for things like interfacing with machine linking /// [DataField("enabled"), ViewVariables(VVAccess.ReadWrite)] public bool Enabled = true; /// /// How efficiently the materials are reclaimed. /// In practice, a multiplier per material when calculating the output of the reclaimer. /// [DataField("efficiency"), ViewVariables(VVAccess.ReadWrite)] public float Efficiency = 1f; /// /// Whether or not the process /// speed scales with the amount of materials being processed /// or if it's just /// [DataField("scaleProcessSpeed")] public bool ScaleProcessSpeed = true; /// /// How quickly it takes to consume X amount of materials per second. /// For example, with a rate of 50, an entity with 100 total material takes 2 seconds to process. /// [DataField("baseMaterialProcessRate"), ViewVariables(VVAccess.ReadWrite)] public float BaseMaterialProcessRate = 100f; /// /// How quickly it takes to consume X amount of materials per second. /// For example, with a rate of 50, an entity with 100 total material takes 2 seconds to process. /// [DataField("materialProcessRate"), ViewVariables(VVAccess.ReadWrite)] public float MaterialProcessRate = 100f; /// /// Machine part whose rating modifies /// [DataField("machinePartProcessRate", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] public string MachinePartProcessRate = "Manipulator"; /// /// How much the machine part quality affects the /// [DataField("partRatingProcessRateMultiplier"), ViewVariables(VVAccess.ReadWrite)] public float PartRatingProcessRateMultiplier = 1.5f; /// /// The minimum amount fo time it can take to process an entity. /// this value supercedes the calculated one using /// [DataField("minimumProcessDuration"), ViewVariables(VVAccess.ReadWrite)] public TimeSpan MinimumProcessDuration = TimeSpan.FromSeconds(0.5f); /// /// The id of our output solution /// [DataField("solutionContainerId"), ViewVariables(VVAccess.ReadWrite)] public string SolutionContainerId = "output"; /// /// The solution itself. /// [ViewVariables(VVAccess.ReadWrite)] public Solution OutputSolution = default!; /// /// a whitelist for what entities can be inserted into this reclaimer /// [DataField("whitelist")] public EntityWhitelist? Whitelist; /// /// a blacklist for what entities cannot be inserted into this reclaimer /// [DataField("blacklist")] public EntityWhitelist? Blacklist; /// /// The sound played when something is being processed. /// [DataField("sound")] public SoundSpecifier? Sound; /// /// whether or not we cut off the sound early when the reclaiming ends. /// [DataField("cutOffSound")] public bool CutOffSound = true; /// /// When the next sound will be allowed to be played. Used to prevent spam. /// [DataField("nextSound", customTypeSerializer: typeof(TimeOffsetSerializer))] public TimeSpan NextSound; /// /// Minimum time inbetween each /// [DataField("soundCooldown")] public TimeSpan SoundCooldown = TimeSpan.FromSeconds(0.8f); public IPlayingAudioStream? Stream; /// /// A counter of how many items have been processed /// /// /// I saw this on the recycler and i'm porting it because it's cute af /// [DataField("itemsProcessed")] public int ItemsProcessed; } [Serializable, NetSerializable] public sealed class MaterialReclaimerComponentState : ComponentState { public bool Powered; public bool Enabled; public float MaterialProcessRate; public int ItemsProcessed; public MaterialReclaimerComponentState(bool powered, bool enabled, float materialProcessRate, int itemsProcessed) { Powered = powered; Enabled = enabled; MaterialProcessRate = materialProcessRate; ItemsProcessed = itemsProcessed; } } [NetSerializable, Serializable] public enum RecyclerVisuals { Bloody } public enum RecyclerVisualLayers : byte { Main, Bloody }