/// <summary> /// Use this when a player rejoins the game and already has a logged-out body in the game. /// Transfers their control back to the body. /// </summary> /// <param name="viewer"></param> /// <param name="body">to transfer into</param> public static void ServerRejoinPlayer(JoinedViewer viewer, GameObject body) { var ps = body.GetComponent <PlayerScript>(); var mind = ps.mind; var occupation = mind.occupation; var settings = ps.characterSettings; ServerTransferPlayer(viewer.connectionToClient, body, viewer.gameObject, EVENT.PlayerRejoined, settings); body.GetComponent <PlayerScript>().playerNetworkActions.ReenterBodyUpdates(); }
/// <summary> /// Spawns as a ghost for spectating the Round /// </summary> public static void ServerSpawnGhost(JoinedViewer joinedViewer, CharacterSettings characterSettings) { //Hard coding to assistant Vector3Int spawnPosition = GetSpawnForJob(JobType.ASSISTANT).transform.position.CutToInt(); //Get spawn location var matrixInfo = MatrixManager.AtPoint(spawnPosition, true); var parentNetId = matrixInfo.NetID; var parentTransform = matrixInfo.Objects; var newPlayer = UnityEngine.Object.Instantiate(CustomNetworkManager.Instance.ghostPrefab, spawnPosition, parentTransform.rotation, parentTransform); newPlayer.GetComponent <PlayerScript>().registerTile.ServerSetNetworkedMatrixNetID(parentNetId); //Create the mind without a job refactor this to make it as a ghost mind Mind.Create(newPlayer); ServerTransferPlayer(joinedViewer.connectionToClient, newPlayer, null, EVENT.GhostSpawned, characterSettings); }
/// <summary> /// Server-side only. For use when a player has only joined (as a JoinedViewer) and /// is not in control of any mobs. Spawns the joined viewer as the indicated occupation and transfers control to it. /// Note that this doesn't take into account game mode or antags, it just spawns whatever is requested. /// </summary> /// <param name="joinedViewer">viewer who should control the player</param> /// <param name="occupation">occupation to spawn as</param> /// <param name="characterSettings">settings to use for the character</param> /// <returns>the game object of the spawned player</returns> public static GameObject ServerSpawnPlayer(JoinedViewer joinedViewer, Occupation occupation, CharacterSettings characterSettings) { NetworkConnection conn = joinedViewer.connectionToClient; var newPlayer = ServerSpawnInternal(conn, occupation, characterSettings, null); if (newPlayer) { if (occupation.JobType != JobType.SYNDICATE && occupation.JobType != JobType.AI) { SecurityRecordsManager.Instance.AddRecord(newPlayer.GetComponent <PlayerScript>(), occupation.JobType); } } return(newPlayer); }
/// <summary> /// Spawns as a ghost for spectating the Round /// </summary> public static void ServerSpawnGhost(JoinedViewer joinedViewer, CharacterSettings characterSettings) { //Hard coding to assistant Vector3Int spawnPosition = SpawnPoint.GetRandomPointForJob(JobType.ASSISTANT).transform.position.CutToInt(); //Get spawn location var matrixInfo = MatrixManager.AtPoint(spawnPosition, true); var parentTransform = matrixInfo.Objects; var newPlayer = UnityEngine.Object.Instantiate(CustomNetworkManager.Instance.ghostPrefab, spawnPosition, parentTransform.rotation, parentTransform); //Create the mind without a job refactor this to make it as a ghost mind Mind.Create(newPlayer); ServerTransferPlayer(joinedViewer.connectionToClient, newPlayer, null, Event.GhostSpawned, characterSettings); var isAdmin = PlayerList.Instance.IsAdmin(PlayerList.Instance.Get(joinedViewer.connectionToClient)); newPlayer.GetComponent <GhostSprites>().SetGhostSprite(isAdmin); }
/// <summary> /// Server-side only. For use when a player has only joined (as a JoinedViewer) and /// is not in control of any mobs. Spawns the joined viewer as the indicated occupation and transfers control to it. /// Note that this doesn't take into account game mode or antags, it just spawns whatever is requested. /// </summary> /// <param name="joinedViewer">viewer who should control the player</param> /// <param name="occupation">occupation to spawn as</param> /// <param name="characterSettings">settings to use for the character</param> /// <returns>the game object of the spawned player</returns> public static GameObject ServerSpawnPlayer(JoinedViewer joinedViewer, Occupation occupation, CharacterSettings characterSettings) { NetworkConnection conn = joinedViewer.connectionToClient; // TODO: add a nice cutscene/animation for the respawn transition var newPlayer = ServerSpawnInternal(conn, occupation, characterSettings, null); if (newPlayer != null && occupation.IsCrewmember) { CrewManifestManager.Instance.AddMember(newPlayer.GetComponent <PlayerScript>(), occupation.JobType); } if (SpawnEvent != null) { SpawnEventArgs args = new SpawnEventArgs() { player = newPlayer }; SpawnEvent.Invoke(null, args); } return(newPlayer); }
public static void SetViewerForControl(JoinedViewer viewer) { LocalViewerScript = viewer; }
/// <summary> /// Create a new player spawn info indicating a request to spawn with the /// selected occupation and settings. /// </summary> /// <returns></returns> public static PlayerSpawnRequest RequestOccupation(JoinedViewer requestedBy, Occupation requestedOccupation, CharacterSettings characterSettings) { return(new PlayerSpawnRequest(requestedOccupation, requestedBy, characterSettings)); }
private PlayerSpawnRequest(Occupation requestedOccupation, JoinedViewer joinedViewer, CharacterSettings characterSettings) { RequestedOccupation = requestedOccupation; JoinedViewer = joinedViewer; CharacterSettings = characterSettings; }