using Content.Server.Body.Components; using Content.Server.Chemistry.EntitySystems; using Content.Server.Nutrition.EntitySystems; using Content.Shared.FixedPoint; using Robust.Shared.Audio; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Nutrition.Components { [RegisterComponent, Access(typeof(FoodSystem))] public sealed partial class FoodComponent : Component { [DataField("solution")] public string SolutionName { get; set; } = "food"; [DataField("useSound")] public SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/Items/eatfood.ogg"); [DataField("trash", customTypeSerializer: typeof(PrototypeIdSerializer))] public string? TrashPrototype { get; set; } [DataField("transferAmount")] public FixedPoint2? TransferAmount { get; set; } = FixedPoint2.New(5); /// /// Acceptable utensil to use /// [DataField("utensil")] public UtensilType Utensil = UtensilType.Fork; //There are more "solid" than "liquid" food /// /// Is utensil required to eat this food /// [DataField("utensilRequired")] public bool UtensilRequired = false; /// /// If this is set to true, food can only be eaten if you have a stomach with a /// that includes this entity in its whitelist, /// rather than just being digestible by anything that can eat food. /// Whitelist the food component to allow eating of normal food. /// [DataField("requiresSpecialDigestion")] public bool RequiresSpecialDigestion = false; /// /// Stomachs required to digest this entity. /// Used to simulate 'ruminant' digestive systems (which can digest grass) /// [DataField("requiredStomachs")] public int RequiredStomachs = 1; /// /// The localization identifier for the eat message. Needs a "food" entity argument passed to it. /// [DataField("eatMessage")] public string EatMessage = "food-nom"; /// /// How long it takes to eat the food personally. /// [DataField("delay")] public float Delay = 1; /// /// This is how many seconds it takes to force feed someone this food. /// Should probably be smaller for small items like pills. /// [DataField("forceFeedDelay")] public float ForceFeedDelay = 3; [ViewVariables] public int UsesRemaining { get { if (!EntitySystem.Get().TryGetSolution(Owner, SolutionName, out var solution)) { return 0; } if (TransferAmount == null) return solution.Volume == 0 ? 0 : 1; return solution.Volume == 0 ? 0 : Math.Max(1, (int) Math.Ceiling((solution.Volume / (FixedPoint2)TransferAmount).Float())); } } } }