InteractionPopupComponent.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Robust.Shared.Audio;
  2. using Robust.Shared.Prototypes;
  3. namespace Content.Shared.Interaction.Components;
  4. [RegisterComponent, Access(typeof(InteractionPopupSystem))]
  5. public sealed partial class InteractionPopupComponent : Component
  6. {
  7. /// <summary>
  8. /// Time delay between interactions to avoid spam.
  9. /// </summary>
  10. [DataField("interactDelay")]
  11. [ViewVariables(VVAccess.ReadWrite)]
  12. public TimeSpan InteractDelay = TimeSpan.FromSeconds(1.0);
  13. /// <summary>
  14. /// String will be used to fetch the localized message to be played if the interaction succeeds.
  15. /// Nullable in case none is specified on the yaml prototype.
  16. /// </summary>
  17. [DataField("interactSuccessString")]
  18. public string? InteractSuccessString;
  19. /// <summary>
  20. /// String will be used to fetch the localized message to be played if the interaction fails.
  21. /// Nullable in case no message is specified on the yaml prototype.
  22. /// </summary>
  23. [DataField("interactFailureString")]
  24. public string? InteractFailureString;
  25. /// <summary>
  26. /// Sound effect to be played when the interaction succeeds.
  27. /// Nullable in case no path is specified on the yaml prototype.
  28. /// </summary>
  29. [DataField("interactSuccessSound")]
  30. public SoundSpecifier? InteractSuccessSound;
  31. /// <summary>
  32. /// Sound effect to be played when the interaction fails.
  33. /// Nullable in case no path is specified on the yaml prototype.
  34. /// </summary>
  35. [DataField("interactFailureSound")]
  36. public SoundSpecifier? InteractFailureSound;
  37. /// <summary>
  38. /// a prototype that will spawn upon successful interaction (as planned only for special effects)
  39. /// </summary>
  40. [DataField, ViewVariables(VVAccess.ReadWrite)]
  41. public EntProtoId? InteractSuccessSpawn;
  42. /// <summary>
  43. /// a prototype that will spawn upon failure interaction (as planned only for special effects)
  44. /// </summary>
  45. [DataField, ViewVariables(VVAccess.ReadWrite)]
  46. public EntProtoId? InteractFailureSpawn;
  47. /// <summary>
  48. /// Chance that an interaction attempt will succeed.
  49. /// 1 = always play "success" popup and sound.
  50. /// 0.5 = 50% chance to play either success or failure popup and sound.
  51. /// 0 = always play "failure" popup and sound.
  52. /// </summary>
  53. [DataField("successChance")]
  54. public float SuccessChance = 1.0f; // Always succeed, unless specified otherwise on the yaml prototype.
  55. /// <summary>
  56. /// If set, shows a message to all surrounding players but NOT the current player.
  57. /// </summary>
  58. [DataField("messagePerceivedByOthers")]
  59. public string? MessagePerceivedByOthers;
  60. /// <summary>
  61. /// Will the sound effect be perceived by entities not involved in the interaction?
  62. /// </summary>
  63. [DataField("soundPerceivedByOthers")]
  64. public bool SoundPerceivedByOthers = true;
  65. [ViewVariables(VVAccess.ReadWrite)]
  66. public TimeSpan LastInteractTime;
  67. /// <summary>
  68. /// If set to true, activate interactions will also trigger the component.
  69. /// </summary>
  70. [DataField]
  71. public bool OnActivate;
  72. }