示例#1
0
        private static JoinAsResult SpawnNewPlayerWithBody(NetworkUser player, BodyIndex newBodyIndex)
        {
            player.CmdSetBodyPreference(newBodyIndex);

            Run.instance.SetFieldValue("allowNewParticipants", true);
            Run.instance.OnUserAdded(player);
            Run.instance.SetFieldValue("allowNewParticipants", false);


            Transform spawnTransform = GetSpawnTransformForPlayer(player);

            player.master.SpawnBody(spawnTransform.position, spawnTransform.rotation);

            HandleBodyItems(player, null, BodyCatalog.GetBodyPrefab(newBodyIndex));

            if (DropInConfig.GiveCatchUpItems.Value)
            {
                GiveCatchUpItems(player);
            }

            return(JoinAsResult.Success);
        }
示例#2
0
        private static JoinAsResult RespawnExistingPlayerWithBody(NetworkUser player, BodyIndex newBodyIndex)
        {
            GameObject oldBodyPrefab = player.master.bodyPrefab;

            player.CmdSetBodyPreference(newBodyIndex);

            JoinAsResult result = JoinAsResult.Success;

            if (player.GetCurrentBody() == null && player.master.lostBodyToDeath && !DropInConfig.AllowRespawn.Value)
            {
                Logger.LogMessage($"Unable immediately to spawn {player.userName} with bodyIndex = {newBodyIndex} due to being player being dead and AllowRespawn being set to false");
                result = JoinAsResult.DeadAndNotAllowRespawn;
            }
            else
            {
                Transform spawnTransform = GetSpawnTransformForPlayer(player);
                player.master.Respawn(spawnTransform.position, spawnTransform.rotation);
            }

            HandleBodyItems(player, oldBodyPrefab, BodyCatalog.GetBodyPrefab(newBodyIndex));

            return(result);
        }