Table of Contents

Interface IPlayerVoteManager

Namespace
Uncreated.Warfare.Players
Assembly
Uncreated.Warfare.dll

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

bool

VoteEnd

The time at which the vote will end (UTC).

DateTime VoteEnd { get; }

Property Value

DateTime

Exceptions

InvalidOperationException

Not voting.

VoteStart

The time at which the vote started (UTC).

DateTime VoteStart { get; }

Property Value

DateTime

Exceptions

InvalidOperationException

Not voting.

Methods

EndVoteAsync(CancellationToken, bool)

Ends the current vote

UniTask EndVoteAsync(CancellationToken token = default, bool cancelled = false)

Parameters

token CancellationToken

Cancellation token used to cancel ending the vote.

cancelled bool

If 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

vote PlayerVoteState

Returns

int

Exceptions

InvalidOperationException

Not voting.

GetVoteState(CSteamID)

Gets a player's current vote state (unanswered/yes/no).

PlayerVoteState GetVoteState(CSteamID player)

Parameters

player CSteamID

Returns

PlayerVoteState

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

player CSteamID

The player that's voting.

vote PlayerVoteState

Their 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

settings VoteSettings

General settings for the vote.

callback Action<IVoteResult>

Invoked when the vote is completed or cancelled.

startCancellationToken CancellationToken

Cancellation token used to cancel starting the vote, not the same as the token used to cancel the vote.

Returns

UniTask

Exceptions

InvalidOperationException

Already voting.