Beispiel #1
0
 /// <summary>
 /// Initializes a new <see cref="WaitForTrigger"/>.
 /// </summary>
 /// <param name="usersToWaitFor">Function returning users to wait for, null indicates to use all currently registered users upon first caller. Called ONCE when first user hits waiting state.</param>
 /// <param name="waitingPromptGenerator">The waiting state to use while waiting for the trigger. The outlet of this state will be overwritten</param>
 public WaitForUsers_StateExit(
     Lobby lobby,
     WaitForUsersType usersToWaitFor = WaitForUsersType.Active,
     Func <User, UserPrompt> waitingPromptGenerator = null)
     : base(waitingPromptGenerator)
 {
     this.Lobby = lobby;
     this.UsersToWaitForType = usersToWaitFor;
 }
Beispiel #2
0
        // TODO: move this to lobby and optimize.
        private HashSet <User> GetUsers(WaitForUsersType type)
        {
            switch (type)
            {
            // TODO: no need to call this multiple times if not looking at active users.
            case WaitForUsersType.All:
                return(new HashSet <User>(this.Lobby.GetAllUsers()));

            case WaitForUsersType.Active:
                return(new HashSet <User>(this.Lobby.GetUsers(UserActivity.Active)));

            default:
                throw new Exception(Invariant($"Something went wrong. Unknown WaitForUsersType '{type}'"));
            }
        }