IVoteManager.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Diagnostics.CodeAnalysis;
  2. using Content.Shared.Voting;
  3. using Robust.Shared.Player;
  4. namespace Content.Server.Voting.Managers
  5. {
  6. /// <summary>
  7. /// Manages in-game votes that players can vote on.
  8. /// </summary>
  9. public interface IVoteManager
  10. {
  11. /// <summary>
  12. /// All votes that are currently active and can be voted on by players.
  13. /// </summary>
  14. IEnumerable<IVoteHandle> ActiveVotes { get; }
  15. /// <summary>
  16. /// Try to get a vote handle by integer ID.
  17. /// </summary>
  18. /// <remarks>
  19. /// Only votes that are currently active can be retrieved.
  20. /// </remarks>
  21. /// <param name="voteId">The integer ID of the vote, corresponding to <see cref="IVoteHandle.Id"/>.</param>
  22. /// <param name="vote">The vote handle, if found.</param>
  23. /// <returns>True if the vote was found and it was returned, false otherwise.</returns>
  24. bool TryGetVote(int voteId, [NotNullWhen(true)] out IVoteHandle? vote);
  25. /// <summary>
  26. /// Check if a player can initiate a vote right now. Optionally of a specified standard type.
  27. /// </summary>
  28. /// <remarks>
  29. /// Players cannot start votes if they have made another vote recently,
  30. /// or if the specified vote type has been made recently.
  31. /// </remarks>
  32. /// <param name="initiator">The player to check.</param>
  33. /// <param name="voteType">
  34. /// The standard vote type to check cooldown for.
  35. /// Null to only check timeout for all vote types for the specified player.
  36. /// </param>
  37. /// <returns>
  38. /// True if <paramref name="initiator"/> can start votes right now,
  39. /// and if provided if they can start votes of type <paramref name="voteType"/>.
  40. /// </returns>
  41. bool CanCallVote(ICommonSession initiator, StandardVoteType? voteType = null);
  42. /// <summary>
  43. /// Initiate a standard vote such as restart round, that can be initiated by players.
  44. /// </summary>
  45. /// <param name="initiator">
  46. /// The player that called the vote.
  47. /// If null it is assumed to be an automatic vote by the server.
  48. /// </param>
  49. /// <param name="voteType">The type of standard vote to make.</param>
  50. void CreateStandardVote(ICommonSession? initiator, StandardVoteType voteType, string[]? args = null);
  51. /// <summary>
  52. /// Create a non-standard vote with special parameters.
  53. /// </summary>
  54. /// <param name="options">The options specifying the vote's behavior.</param>
  55. /// <returns>A handle to the created vote.</returns>
  56. IVoteHandle CreateVote(VoteOptions options);
  57. void Initialize();
  58. void Update();
  59. }
  60. }