/// <summary> /// Sends a message to all dead, informing them about a new ghost role that has become available. /// </summary> public static NetMessage SendToDead(uint key) { if (GhostRoleManager.Instance != null) { GhostRoleServer role = GhostRoleManager.Instance.serverAvailableRoles[key]; foreach (ConnectedPlayer player in PlayerList.Instance.InGamePlayers) { if (player?.Script == null) { Logger.LogError("SendToDead, player?.Script == null", Category.Ghosts); continue; } if (player.Script.IsDeadOrGhost == false) { continue; } SendTo(player, key, role); } return(GetMessage(key, role)); } else { Logger.LogError("SendToDead, GhostRoleManager.Instance == null", Category.Ghosts); } return(new NetMessage()); }
/// <summary> /// Sends a message to the specific player, informing them about a new ghost role that has become available. /// </summary> public static NetMessage SendTo(ConnectedPlayer player, uint key, GhostRoleServer role) { NetMessage msg = GetMessage(key, role); SendTo(player, msg); return(msg); }
private static GhostRoleUpdateMessage GetMessage(uint key, GhostRoleServer role) { return(new GhostRoleUpdateMessage { roleID = key, roleType = role.RoleListIndex, minPlayers = role.MinPlayers, maxPlayers = role.MaxPlayers, playerCount = role.WaitingPlayers.Count, timeRemaining = role.TimeRemaining, }); }
/// <summary> /// Sends a message to the specific player, informing them about a new ghost role that has become available. /// </summary> public static NetMessage SendTo(ConnectedPlayer player, uint key, GhostRoleServer role) { NetMessage msg = GetMessage(key, role); if (PlayerList.Instance.loggedOff.Contains(player)) { return(msg); } SendTo(player, msg); return(msg); }
/// <summary> /// Sends a message to all dead, informing them about a new ghost role that has become available. /// </summary> public static GhostRoleUpdateMessage SendToDead(uint key) { GhostRoleServer role = GhostRoleManager.Instance.serverAvailableRoles[key]; foreach (ConnectedPlayer player in PlayerList.Instance.InGamePlayers) { if (player.Script.IsDeadOrGhost == false) { continue; } SendTo(player, key, role); } return(GetMessage(key, role)); }
public void CreateGhostRole(HandActivate interaction) { if (createdRoleKey != null && GhostRoleManager.Instance.serverAvailableRoles.ContainsKey(createdRoleKey)) { return; } else if (WasUsed) { return; } createdRoleKey = GhostRoleManager.Instance.ServerCreateRole(ghostRole); GhostRoleServer role = GhostRoleManager.Instance.serverAvailableRoles[createdRoleKey]; role.OnPlayerAdded += SpawnReinforcement; role.OnTimerExpired += ClearGhostRole; userPlayer = interaction.Performer; Chat.AddExamineMsgFromServer(userPlayer, $"The {gameObject.ExpensiveName()} sends out a reinforcement request!"); }
public void CreateGhostRole() { if (GhostRoleManager.Instance.serverAvailableRoles.ContainsKey(createdRoleKey)) { Logger.LogWarning("A wizard apprentice ghost role already exists.", Category.Spells); return; } else if (WasUsed) { Logger.LogWarning("This contract has already been used. Cannot spawn another apprentice.", Category.Spells); return; } BoundTo = netTab.LastInteractedPlayer().Player(); createdRoleKey = GhostRoleManager.Instance.ServerCreateRole(ghostRole); GhostRoleServer role = GhostRoleManager.Instance.serverAvailableRoles[createdRoleKey]; role.OnPlayerAdded += SpawnApprentice; role.OnTimerExpired += OnGhostRoleTimeout; }
private static NetMessage GetMessage(uint key, GhostRoleServer role) { var MSG = new NetMessage { roleID = key, roleType = role.RoleListIndex, minPlayers = role.MinPlayers, maxPlayers = role.MaxPlayers, playerCount = role.PlayersSpawned, timeRemaining = role.TimeRemaining, }; if (MSG.minPlayers > 0 && role.PlayersSpawned == 0) { MSG.playerCount = role.WaitingPlayers.Count; } else { MSG.playerCount = role.PlayersSpawned; } return(MSG); }
/// <summary> /// Sends a message to the specific player, informing them about a new ghost role that has become available. /// </summary> public static GhostRoleUpdateMessage SendTo(ConnectedPlayer player, uint key, GhostRoleServer role) { GhostRoleUpdateMessage msg = GetMessage(key, role); msg.SendTo(player); return(msg); }