using Content.Server.Animals.Systems; using Content.Shared.Nutrition.EntitySystems; using Content.Shared.Nutrition.Prototypes; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Server.Animals.Components; /// /// Periodically attempts to produce something, consuming satiation on success. /// The actual product is supplied by a handler for . /// [RegisterComponent, AutoGenerateComponentPause] [Access(typeof(SatiationProductionSystem))] public sealed partial class SatiationProductionComponent : Component { /// /// Selects the entity whose mob state and satiation are used for production checks and consumption. /// [DataField] public SatiationProductionOwner Producer = SatiationProductionOwner.Self; /// /// Minimum delay between automatic production attempts. /// [DataField] public TimeSpan Delay = TimeSpan.FromMinutes(1); /// /// Optional maximum delay. When set, each automatic delay is randomized. /// [DataField] public TimeSpan? DelayMax; /// /// Amount of the configured satiation removed after successful production. /// [DataField] public float SatiationUsage = 10f; /// /// Satiation type checked and consumed by production. Defaults to hunger. /// [DataField] public ProtoId SatiationType = SatiationSystem.Hunger; /// /// Optional threshold that the configured satiation must still exceed after applying the production cost. /// [DataField] public SatiationValue? MinimumSatiationThreshold; /// /// Optional minimum numeric value of the configured satiation required before production. /// [DataField] public float? MinimumSatiation; /// /// Whether production is attempted automatically. /// [DataField] public bool Automatic = true; /// /// Whether automatic production is allowed for player-controlled producer entities. /// [DataField] public bool AutomaticForPlayers = true; /// /// Next scheduled automatic production attempt. Adjusted while the component is paused. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan NextProductionTime; } /// /// Selects the entity against which production conditions are evaluated. /// public enum SatiationProductionOwner : byte { Self, Parent } /// /// Reason a production attempt failed. /// public enum SatiationProductionFailure : byte { None, Dead, /// /// The selected producer does not meet the configured satiation requirement. /// InsufficientSatiation, /// /// The production attempt completed without producing a product. /// ProductUnavailable } /// /// Raised when production is attempted. /// Handlers set when something was successfully produced. /// /// Entity selected as the producer for this attempt. [ByRefEvent] public record struct ProductionAttemptEvent(EntityUid Owner) { /// /// Set by handlers when production succeeds. /// public bool Produced; }