MicrowaveMealRecipePrototype.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Content.Shared.Chemistry.Reagent;
  2. using Content.Shared.FixedPoint;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
  6. namespace Content.Shared.Kitchen
  7. {
  8. /// <summary>
  9. /// A recipe for space microwaves.
  10. /// </summary>
  11. [Prototype("microwaveMealRecipe")]
  12. public sealed partial class FoodRecipePrototype : IPrototype
  13. {
  14. [ViewVariables]
  15. [IdDataField]
  16. public string ID { get; private set; } = default!;
  17. [DataField("name")]
  18. private string _name = string.Empty;
  19. [DataField]
  20. public string Group = "Other";
  21. [DataField("reagents", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
  22. private Dictionary<string, FixedPoint2> _ingsReagents = new();
  23. [DataField("solids", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<FixedPoint2, EntityPrototype>))]
  24. private Dictionary<string, FixedPoint2> _ingsSolids = new ();
  25. [DataField("result", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
  26. public string Result { get; private set; } = string.Empty;
  27. [DataField("time")]
  28. public uint CookTime { get; private set; } = 5;
  29. public string Name => Loc.GetString(_name);
  30. // TODO Turn this into a ReagentQuantity[]
  31. public IReadOnlyDictionary<string, FixedPoint2> IngredientsReagents => _ingsReagents;
  32. public IReadOnlyDictionary<string, FixedPoint2> IngredientsSolids => _ingsSolids;
  33. /// <summary>
  34. /// Is this recipe unavailable in normal circumstances?
  35. /// </summary>
  36. [DataField]
  37. public bool SecretRecipe = false;
  38. /// <summary>
  39. /// Count the number of ingredients in a recipe for sorting the recipe list.
  40. /// This makes sure that where ingredient lists overlap, the more complex
  41. /// recipe is picked first.
  42. /// </summary>
  43. public FixedPoint2 IngredientCount()
  44. {
  45. FixedPoint2 n = 0;
  46. n += _ingsReagents.Count; // number of distinct reagents
  47. foreach (FixedPoint2 i in _ingsSolids.Values) // sum the number of solid ingredients
  48. {
  49. n += i;
  50. }
  51. return n;
  52. }
  53. }
  54. }