Interface IPlayerVoteManager
Handles player-wide votes for certain events. Currently used by seeding gamemode.
public interface IPlayerVoteManager
Properties
IsVoting
If there's a vote currently active.
bool IsVoting { get; }
Property Value
VoteEnd
The time at which the vote will end (UTC).
DateTime VoteEnd { get; }
Property Value
Exceptions
- InvalidOperationException
Not voting.
VoteStart
The time at which the vote started (UTC).
DateTime VoteStart { get; }
Property Value
Exceptions
- InvalidOperationException
Not voting.
Methods
EndVoteAsync(CancellationToken, bool)
Ends the current vote
UniTask EndVoteAsync(CancellationToken token = default, bool cancelled = false)
Parameters
tokenCancellationTokenCancellation token used to cancel ending the vote.
cancelledboolIf the vote should be cancelled instead of ended.
Returns
- UniTask
Exceptions
- InvalidOperationException
Not voting.
GetVoteCount(PlayerVoteState)
Gets the number of votes in a certain state.
int GetVoteCount(PlayerVoteState vote)
Parameters
votePlayerVoteState
Returns
Exceptions
- InvalidOperationException
Not voting.
GetVoteState(CSteamID)
Gets a player's current vote state (unanswered/yes/no).
PlayerVoteState GetVoteState(CSteamID player)
Parameters
playerCSteamID
Returns
Exceptions
- InvalidOperationException
Not voting.
RegisterVote(CSteamID, PlayerVoteState)
Registers a player's vote with the system, overriding their current vote if they've already voted.
PlayerVoteState RegisterVote(CSteamID player, PlayerVoteState vote)
Parameters
playerCSteamIDThe player that's voting.
votePlayerVoteStateTheir vote, or Unanswered to remove thier vote.
Returns
- PlayerVoteState
Their previous vote, or Unanswered if they hadn't voted.
Exceptions
- InvalidOperationException
Not voting.
- ArgumentOutOfRangeException
Invalid vote.
StartVoteAsync(VoteSettings, Action<IVoteResult>?, CancellationToken)
Starts a new vote.
UniTask StartVoteAsync(VoteSettings settings, Action<IVoteResult>? callback, CancellationToken startCancellationToken = default)
Parameters
settingsVoteSettingsGeneral settings for the vote.
callbackAction<IVoteResult>Invoked when the vote is completed or cancelled.
startCancellationTokenCancellationTokenCancellation token used to cancel starting the vote, not the same as the token used to cancel the vote.
Returns
- UniTask
Exceptions
- InvalidOperationException
Already voting.