Esempio n. 1
0
        public void SpawnAsNewPlayer(Vector3 currentPosition, string respawnShipId, bool resetIdentity)
        {
            Debug.Assert(Sync.IsServer, "Calling SpawnAsNewPlayer on client!");
            Debug.Assert(Identity != null, "Spawning with empty identity!");
            if (!Sync.IsServer || Identity == null)
            {
                return;
            }

            if (Identity != null && resetIdentity)
            {
                if (!Identity.IsDead)
                {
                    Sync.Players.KillPlayer(this);
                }

                if (MySession.Static.Settings.PermanentDeath.Value)
                {
                    var faction = MySession.Static.Factions.TryGetPlayerFaction(Identity.IdentityId);
                    if (faction != null)
                    {
                        MySession.Static.Factions.KickMember(faction.FactionId, Identity.IdentityId);
                    }

                    //Clear chat history
                    if (MySession.Static.ChatSystem != null)
                    {
                        MySession.Static.ChatSystem.ClearChatHistoryForPlayer(Identity);
                    }

                    var identity = Sync.Players.CreateNewIdentity(DisplayName);
                    ChangeIdentity(identity);
                }
            }

            if (MySession.Static.Settings.EnableOxygen)
            {
                Identity.ChangeToOxygenSafeSuit();
            }

            if (respawnShipId != null)
            {
                SpawnAtShip(respawnShipId);
            }
            else
            {
                SpawnInSuit();
            }
        }