OpenableComponent.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Content.Shared.Nutrition.EntitySystems;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.GameStates;
  4. namespace Content.Shared.Nutrition.Components;
  5. /// <summary>
  6. /// A drink or food that can be opened.
  7. /// Starts closed, open it with Z or E.
  8. /// </summary>
  9. [NetworkedComponent, AutoGenerateComponentState]
  10. [RegisterComponent, Access(typeof(OpenableSystem))]
  11. public sealed partial class OpenableComponent : Component
  12. {
  13. /// <summary>
  14. /// Whether this drink or food is opened or not.
  15. /// Drinks can only be drunk or poured from/into when open, and food can only be eaten when open.
  16. /// </summary>
  17. [DataField, AutoNetworkedField]
  18. public bool Opened;
  19. /// <summary>
  20. /// If this is false you cant press Z to open it.
  21. /// Requires an OpenBehavior damage threshold or other logic to open.
  22. /// </summary>
  23. [DataField, AutoNetworkedField]
  24. public bool OpenableByHand = true;
  25. /// <summary>
  26. /// If true, tries to open when activated in world.
  27. /// </summary>
  28. [DataField, AutoNetworkedField]
  29. public bool OpenOnActivate;
  30. /// <summary>
  31. /// Text shown when examining and its open.
  32. /// </summary>
  33. [DataField]
  34. public LocId ExamineText = "drink-component-on-examine-is-opened";
  35. /// <summary>
  36. /// The locale id for the popup shown when IsClosed is called and closed. Needs a "owner" entity argument passed to it.
  37. /// Defaults to the popup drink uses since its "correct".
  38. /// It's still generic enough that you should change it if you make openable non-drinks, i.e. unwrap it first, peel it first.
  39. /// </summary>
  40. [DataField]
  41. public LocId ClosedPopup = "drink-component-try-use-drink-not-open";
  42. /// <summary>
  43. /// Text to show in the verb menu for the "Open" action.
  44. /// You may want to change this for non-drinks, i.e. "Peel", "Unwrap"
  45. /// </summary>
  46. [DataField]
  47. public LocId OpenVerbText = "openable-component-verb-open";
  48. /// <summary>
  49. /// Text to show in the verb menu for the "Close" action.
  50. /// You may want to change this for non-drinks, i.e. "Wrap"
  51. /// </summary>
  52. [DataField]
  53. public LocId CloseVerbText = "openable-component-verb-close";
  54. /// <summary>
  55. /// Sound played when opening.
  56. /// </summary>
  57. [DataField]
  58. public SoundSpecifier? Sound = new SoundCollectionSpecifier("canOpenSounds");
  59. /// <summary>
  60. /// Can this item be closed again after opening?
  61. /// </summary>
  62. [DataField, AutoNetworkedField]
  63. public bool Closeable;
  64. /// <summary>
  65. /// Sound played when closing.
  66. /// </summary>
  67. [DataField]
  68. public SoundSpecifier? CloseSound;
  69. }