private static void SpawnLemming()
        {
            m_spawnCount--;

            if (m_spawnCount <= 0)
            {
                m_timeToNextSpawn = -1;
                return;
            }

            Vector3D spawnPosition = m_spawnMedical.PositionComp.GetPosition() + (MyMedicalRoom.GetSafePlaceRelative() * (Matrix)m_spawnMedical.WorldMatrix).Translation;
            MatrixD  matrix        = m_spawnMedical.WorldMatrix;

            matrix.Translation = spawnPosition;

            var character = MyCharacter.CreateCharacter((Matrix)matrix, Vector3.Zero, "Lemming" + m_lemmings.Count, null, null, false, true);

            character.EnableJetpack(false, false, true, true);
            character.AIMode = true;
            MatrixD m = character.WorldMatrix;

            m             = m * Matrix.CreateRotationY(-MathHelper.PiOver2);
            m.Translation = character.PositionComp.GetPosition();
            character.PositionComp.SetWorldMatrix(m);
            character.Save = false;
            MyLemmingCharacter lemming = new MyLemmingCharacter()
            {
                Character = character,
            };

            m_lemmings.Add(lemming);
        }
예제 #2
0
        public static MyCharacter SpawnAgent(
            ulong steamId, string name, Color color, MatrixD startPosition, long identityId
            )
        {
            var identityBuilder = new MyObjectBuilder_Identity
            {
                DisplayName = name,
                ColorMask   = color.ToVector3(),
                IdentityId  = identityId,
            };

            var identity = MySession.Static.Players.CreateNewIdentity(identityBuilder);

            var character = MyCharacter.CreateCharacter(
                startPosition, Vector3.Zero, name, "", color, null, identityId: identityId);


            var client = new MyNetworkClient(steamId, name);
            //client.SetInstanceProperty("IsLocal", true);

            var player = MySession.Static.Players.CreateNewPlayer(
                identity: identity, steamClient: client, playerName: name,
                realPlayer: true
                );

            var characterController = new MyEntityController(player);

            characterController.TakeControl(character);

            return(player.Character);
        }
예제 #3
0
        public static MyCharacter SpawnAgent(ulong steamId, string name, Color color, MatrixD startPosition,
                                             long identityId = 1000)
        {
            var character = MyCharacter.CreateCharacter(
                startPosition, Vector3.Zero, name, "", color, null, identityId: identityId);

            character.SwitchJetpack();

            var playerId = new MyPlayer.PlayerId(steamId);

            var identityBuilder = new MyObjectBuilder_Identity
            {
                DisplayName       = name,
                CharacterEntityId = character.EntityId,
                ColorMask         = color.ToVector3()
            };
            var identity = new MyAgentIdentity().CreateNewIdentity(identityBuilder);

            var myPlayer = new MyPlayer(Sync.Clients.LocalClient, playerId)
            {
                Identity = identity
            };
            var characterController = new MyEntityController(myPlayer);

            characterController.TakeControl(character);

            return(character);
        }
예제 #4
0
        public void SpawnAt(MatrixD worldMatrix, Vector3 velocity, MyEntity spawnedBy, MyBotDefinition botDefinition, bool findFreePlace = true)
        {
            Debug.Assert(Sync.IsServer, "Spawning can be called only on the server!");
            Debug.Assert(Identity != null, "Spawning with empty identity!");
            if (!Sync.IsServer || Identity == null)
            {
                return;
            }

            var character = MyCharacter.CreateCharacter(worldMatrix, velocity, Identity.DisplayName, Identity.Model,
                                                        Identity.ColorMask, findNearPos: false, useInventory: Id.SerialId == 0, playerSteamId: this.Id.SteamId,
                                                        botDefinition: botDefinition);

            if (findFreePlace)
            {
                float   radius;
                MyModel model = character.Render.GetModel();
                radius = model.BoundingBox.Size.Length() / 2;
                const float SPHERE_REDUCTION_RATE = 0.9f;
                radius *= SPHERE_REDUCTION_RATE;

                // Offset from bottom position to center.
                Vector3 up = worldMatrix.Up;
                up.Normalize();
                const float RISE_STEP = 0.01f; // 1cm
                Vector3     offset    = up * (radius + RISE_STEP);
                MatrixD     matrix    = worldMatrix;
                matrix.Translation = worldMatrix.Translation + offset;

                // Attempt first to rotate around the given spawn location (matrix.Up axis rotation)
                // NOTE: A proper orbital search would be better here
                Vector3D?correctedPos = MyEntities.FindFreePlace(ref matrix, matrix.GetDirectionVector(Base6Directions.Direction.Up), radius, 200, 15, 0.2f);
                if (!correctedPos.HasValue)
                {
                    // Attempt secondly to rotate around matrix.Right axis
                    correctedPos = MyEntities.FindFreePlace(ref matrix, matrix.GetDirectionVector(Base6Directions.Direction.Right), radius, 200, 15, 0.2f);
                    if (!correctedPos.HasValue)
                    {
                        // If everything fails attempt the old FindFreePlace
                        correctedPos = MyEntities.FindFreePlace(worldMatrix.Translation + offset, radius, 200, 15, 0.2f);
                    }
                }

                if (correctedPos.HasValue)
                {
                    worldMatrix.Translation = correctedPos.Value - offset;
                    character.PositionComp.SetWorldMatrix(worldMatrix);
                }
            }

            Sync.Players.SetPlayerCharacter(this, character, spawnedBy);
            Sync.Players.RevivePlayer(this);
        }
예제 #5
0
        private void SpawnInSuit(MyPlayer player)
        {
            Vector3 direction, position;

            GetSpawnPosition(10, out direction, out position);

            //Create character
            Matrix      matrix    = Matrix.CreateWorld(position, direction, Vector3.Up);
            MyCharacter character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null);

            Sync.Players.SetPlayerCharacter(player, character);
            Sync.Players.RevivePlayer(player);
        }
        private void SpawnInSuit(MyPlayer player, MyEntity spawnedBy, MyBotDefinition botDefinition)
        {
            Vector3  direction;
            Vector3D position;

            GetSpawnPosition(10, out direction, out position);

            //Create character
            Matrix      matrix    = Matrix.CreateWorld(position, direction, Vector3.Up);
            MyCharacter character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null, botDefinition, playerSteamId: player.Id.SteamId);

            Sync.Players.SetPlayerCharacter(player, character, spawnedBy);
            Sync.Players.RevivePlayer(player);
        }
예제 #7
0
        private void SpawnInSuit(MyPlayer player, MyEntity spawnedBy, MyBotDefinition botDefinition)
        {
            Vector3D position = Vector3D.Zero;
            Vector3D forward  = Vector3D.Forward;
            Vector3D up       = Vector3D.Up;

            GetSpawnPosition(10, ref position, out forward, out up);

            //Create character
            Matrix      matrix    = Matrix.CreateWorld(position, forward, up);
            MyCharacter character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null, botDefinition, playerSteamId: player.Id.SteamId);

            Sync.Players.SetPlayerCharacter(player, character, spawnedBy);
            Sync.Players.RevivePlayer(player);
        }
예제 #8
0
        private void SpawnInSuit()
        {
            Vector3 direction, position;

            GetSpawnPosition(10, out direction, out position);

            //Create character
            Matrix      matrix    = Matrix.CreateWorld(position, direction, Vector3.Up);
            MyCharacter character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, Identity.DisplayName, Identity.Model, null);

            System.Diagnostics.Debug.Assert(character.Health > 0);

            Sync.Players.SetPlayerCharacter(this, character);
            Sync.Players.RevivePlayer(this);
        }
        public static MyCharacter SpawnCharacter(string model = null)
        {
            var     charObject = MySession.Static.LocalHumanPlayer == null ? null : MySession.Static.LocalHumanPlayer.Identity.Character;
            Vector3?colorMask  = null;

            string name         = MySession.Static.LocalHumanPlayer == null ? "" : MySession.Static.LocalHumanPlayer.Identity.DisplayName;
            string currentModel = MySession.Static.LocalHumanPlayer == null ? MyCharacter.DefaultModel : MySession.Static.LocalHumanPlayer.Identity.Model;

            if (charObject != null)
            {
                colorMask = charObject.ColorMask;
            }

            var character = MyCharacter.CreateCharacter(MatrixD.CreateTranslation(MySector.MainCamera.Position), Vector3.Zero, name, model ?? currentModel, colorMask, null, false);

            return(character);
        }
예제 #10
0
        public void SpawnAt(MatrixD worldMatrix, Vector3 velocity, bool findFreePlace = true)
        {
            Debug.Assert(Sync.IsServer, "Spawning can be called only on the server!");
            Debug.Assert(Identity != null, "Spawning with empty identity!");
            if (!Sync.IsServer || Identity == null)
            {
                return;
            }

            if (findFreePlace)
            {
                Vector3D?correctedPos = MyEntities.FindFreePlace(worldMatrix.Translation, 0.5f, 200);
                if (correctedPos.HasValue)
                {
                    worldMatrix.Translation = correctedPos.Value;
                }
            }

            var character = MyCharacter.CreateCharacter(worldMatrix, velocity, Identity.DisplayName, Identity.Model, Identity.ColorMask, findNearPos: false, useInventory: Id.SerialId == 0);

            Sync.Players.SetPlayerCharacter(this, character);
            Sync.Players.RevivePlayer(this);
        }
        public void SpawnAtShip(MyPlayer player, string respawnShipId)
        {
            Debug.Assert(Sync.IsServer, "Spawning can only be called on the server!");
            if (!Sync.IsServer)
            {
                return;
            }

            ResetRespawnCooldown(player.Id);
            if (Sync.MultiplayerActive)
            {
                SyncCooldownToPlayer(player.Id.SteamId);
            }

            MyCharacter       character    = null;
            MyCockpit         cockpit      = null;
            List <MyCubeGrid> respawnGrids = new List <MyCubeGrid>();

            var respawnShipDef = MyDefinitionManager.Static.GetRespawnShipDefinition(respawnShipId);


            Debug.Assert(respawnShipDef != null);
            if (respawnShipDef == null)
            {
                return;
            }

            var prefabDef = respawnShipDef.Prefab;

            Debug.Assert(prefabDef != null);
            if (prefabDef == null)
            {
                return;
            }

            if (prefabDef.CubeGrids == null)
            {
                MyDefinitionManager.Static.ReloadPrefabsFromFile(prefabDef.PrefabPath);
                prefabDef = MyDefinitionManager.Static.GetPrefabDefinition(prefabDef.Id.SubtypeName);
            }
            // Deploy ship
            Vector3 direction, position;

            GetSpawnPosition(prefabDef.BoundingSphere.Radius, out direction, out position);
            MyPrefabManager.Static.SpawnPrefab(
                respawnGrids,
                prefabDef.Id.SubtypeName,
                position,
                -direction,
                Vector3.CalculatePerpendicularVector(-direction),
                spawningOptions: Sandbox.ModAPI.SpawningOptions.RotateFirstCockpitTowardsDirection,
                updateSync: true);

            // Find cockpit
            foreach (var grid in respawnGrids)
            {
                foreach (var block in grid.GetBlocks())
                {
                    if (block.FatBlock is MyCockpit)
                    {
                        cockpit = (MyCockpit)block.FatBlock;
                        break;
                    }
                }
                if (cockpit != null)
                {
                    break;
                }
            }
            System.Diagnostics.Debug.Assert(cockpit != null, "character is spawning in ship without cockpit !");

            // Create character
            Matrix matrix = Matrix.Identity;

            if (cockpit != null)
            {
                matrix             = cockpit.WorldMatrix;
                matrix.Translation = cockpit.WorldMatrix.Translation - Vector3.Up - Vector3.Forward;
            }
            else if (respawnGrids.Count > 0)
            {
                matrix.Translation = respawnGrids[0].PositionComp.WorldAABB.Center + respawnGrids[0].PositionComp.WorldAABB.HalfExtents;
            }

            character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null, cockpit: cockpit);

            if (cockpit != null)
            {
                cockpit.AttachPilot(character, false);
            }

            CloseRespawnShip(player);
            foreach (var respawnGrid in respawnGrids)
            {
                respawnGrid.ChangeGridOwnership(player.Identity.IdentityId, MyOwnershipShareModeEnum.None);
                player.RespawnShip.Add(respawnGrid.EntityId);
            }

            Sync.Players.SetPlayerCharacter(player, character, cockpit);
            Sync.Players.RevivePlayer(player);
        }
예제 #12
0
        public void SpawnAtShip(MyPlayer player, string respawnShipId, MyBotDefinition botDefinition)
        {
            Debug.Assert(Sync.IsServer, "Spawning can only be called on the server!");
            if (!Sync.IsServer)
            {
                return;
            }

            ResetRespawnCooldown(player.Id);
            if (Sync.MultiplayerActive)
            {
                SyncCooldownToPlayer(player.Id.SteamId, player.Id.SteamId == Sync.MyId);
            }

            MyCharacter       character    = null;
            MyCockpit         cockpit      = null;
            List <MyCubeGrid> respawnGrids = new List <MyCubeGrid>();

            var respawnShipDef           = MyDefinitionManager.Static.GetRespawnShipDefinition(respawnShipId);
            MyPrefabDefinition prefabDef = respawnShipDef.Prefab;

            // Deploy ship
            Vector3D position = Vector3D.Zero;
            float    planetSpawnHeightRatio = 0.3f;
            float    spawnRangeMin          = 500f;
            float    spawnRangeMax          = 650f;

            if (prefabDef.CubeGrids != null && prefabDef.CubeGrids.Length > 0)
            {
                MyObjectBuilder_CubeGrid firstGrid = prefabDef.CubeGrids[0];
                if (firstGrid.UsePositionForSpawn)
                {
                    position = new Vector3D(
                        firstGrid.PositionAndOrientation.Value.Position.x,
                        firstGrid.PositionAndOrientation.Value.Position.y,
                        firstGrid.PositionAndOrientation.Value.Position.z);
                }

                planetSpawnHeightRatio = MyMath.Clamp(firstGrid.PlanetSpawnHeightRatio, 0.05f, 0.95f); // Clamped to prevent crazy data
                spawnRangeMin          = firstGrid.SpawnRangeMin;
                spawnRangeMax          = firstGrid.SpawnRangeMax;
            }
            Vector3D forward = Vector3.Forward;
            Vector3D up      = Vector3D.Up;

            GetSpawnPosition(prefabDef.BoundingSphere.Radius, ref position, out forward, out up, planetSpawnHeightRatio, spawnRangeMin, spawnRangeMax);

            MyPrefabManager.Static.SpawnPrefab(
                respawnGrids,
                prefabDef.Id.SubtypeName,
                position,
                forward,
                up,
                spawningOptions: VRage.Game.ModAPI.SpawningOptions.RotateFirstCockpitTowardsDirection,
                updateSync: true);

            // Find cockpits
            List <MyCockpit> shipCockpits = new List <MyCockpit>();

            foreach (MyCubeGrid grid in respawnGrids)
            {
                foreach (MyCockpit gridCockpit in grid.GetFatBlocks <MyCockpit>())
                {
                    // Ignore non-functional cockpits
                    if (!gridCockpit.IsFunctional)
                    {
                        continue;
                    }
                    shipCockpits.Add(gridCockpit);
                }
            }

            // First sort cockpits by order: Ship controlling cockpits set to main, then ship controlling cockpits not set to main, lastly whatever remains, e.g. CryoChambers and Passenger Seats
            if (shipCockpits.Count > 1)
            {
                shipCockpits.Sort(delegate(MyCockpit cockpitA, MyCockpit cockpitB)
                {
                    int controlCompare = cockpitB.EnableShipControl.CompareTo(cockpitA.EnableShipControl);
                    if (controlCompare != 0)
                    {
                        return(controlCompare);
                    }

                    int mainCompare = cockpitB.IsMainCockpit.CompareTo(cockpitA.IsMainCockpit);
                    if (mainCompare != 0)
                    {
                        return(mainCompare);
                    }

                    return(0);
                });
            }

            // Finally, select the most important cockpit
            if (shipCockpits.Count > 0)
            {
                cockpit = shipCockpits[0];
            }

            System.Diagnostics.Debug.Assert(cockpit != null, "character is spawning in ship without cockpit !");

            // Create character
            MatrixD matrix = MatrixD.Identity;

            if (cockpit != null)
            {
                matrix             = cockpit.WorldMatrix;
                matrix.Translation = cockpit.WorldMatrix.Translation - Vector3.Up - Vector3.Forward;
            }
            else if (respawnGrids.Count > 0)
            {
                matrix.Translation = respawnGrids[0].PositionComp.WorldAABB.Center + respawnGrids[0].PositionComp.WorldAABB.HalfExtents;
            }

            character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null, botDefinition, cockpit: cockpit, playerSteamId: player.Id.SteamId);

            CloseRespawnShip(player);
            foreach (var respawnGrid in respawnGrids)
            {
                respawnGrid.ChangeGridOwnership(player.Identity.IdentityId, MyOwnershipShareModeEnum.None);
                respawnGrid.IsRespawnGrid = true;
                player.RespawnShip.Add(respawnGrid.EntityId);
            }

            if (cockpit != null)
            {
                cockpit.AttachPilot(character, false);
                MyMultiplayer.ReplicateImmediatelly(MyExternalReplicable.FindByObject(cockpit.CubeGrid), new EndpointId(player.Id.SteamId));
            }

            if (cockpit == null)
            {
                Sync.Players.SetPlayerCharacter(player, character, null);
            }
            else
            {
                character.SetPlayer(player);
                Sync.Players.SetPlayerToCockpit(player, cockpit);
            }
            Sync.Players.RevivePlayer(player);
        }
        public MyAsteroidsDebugInputComponent()
        {
            AddShortcut(MyKeys.NumPad1, true, false, false, false,
                        () => "Debug draw procedural asteroid seeds: " + m_drawSeeds,
                        delegate
            {
                m_drawSeeds = !m_drawSeeds;
                return(true);
            });

            AddShortcut(MyKeys.NumPad2, true, false, false, false,
                        () => "Debug draw procedural tracked entities: " + m_drawTrackedEntities,
                        delegate
            {
                m_drawTrackedEntities = !m_drawTrackedEntities;
                return(true);
            });

            AddShortcut(MyKeys.NumPad3, true, false, false, false,
                        () => "Debug draw around camera: " + m_drawAroundCamera,
                        delegate
            {
                m_drawAroundCamera = !m_drawAroundCamera;
                return(true);
            });

            AddShortcut(MyKeys.NumPad4, true, false, false, false,
                        () => "Toggle farplane distance: " + (MySector.MainCamera == null ? -1f : MySector.MainCamera.FarPlaneDistance),
                        delegate
            {
                m_fakeFarPlaneDistance = !m_fakeFarPlaneDistance;
                if (m_originalFarPlaneDisatance == -1)
                {
                    m_originalFarPlaneDisatance = MySector.MainCamera.FarPlaneDistance;
                }
                if (m_fakeFarPlaneDistance)
                {
                    MySector.MainCamera.FarPlaneDistance = m_debugFarPlaneDistance;
                }
                else
                {
                    MySector.MainCamera.FarPlaneDistance = m_originalFarPlaneDisatance;
                }
                return(true);
            });

            AddShortcut(MyKeys.NumPad5, true, false, false, false,
                        () => "Debug draw procedural seed radius: " + m_drawRadius,
                        delegate
            {
                m_drawRadius = !m_drawRadius;
                return(true);
            });

            AddShortcut(MyKeys.NumPad6, true, false, false, false,
                        () => "Debug draw procedural seed distance: " + m_drawDistance,
                        delegate
            {
                m_drawDistance = !m_drawDistance;
                return(true);
            });

            AddShortcut(MyKeys.NumPad7, true, false, false, false,
                        () => "Toggle fog: " + MySector.FogProperties.EnableFog,
                        delegate
            {
                MySector.FogProperties.EnableFog = !MySector.FogProperties.EnableFog;
                return(true);
            });

            AddShortcut(MyKeys.NumPad8, true, false, false, false,
                        () => "Debug draw procedural cells: " + m_drawCells,
                        delegate
            {
                m_drawCells = !m_drawCells;
                return(true);
            });

            AddShortcut(MyKeys.NumPad9, true, false, false, false,
                        () => "Spawn new moving player somewhere: " + m_plys.Count,
                        delegate
            {
                var pos = new Vector3D(MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f) * 150000;
                var vel = new Vector3(MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f);
                vel.Normalize();
                var ply = MyCharacter.CreateCharacter(MatrixD.CreateTranslation(pos), vel * 100 * (MyRandom.Instance.NextFloat() * 0.5f + 0.5f), "ALIEN SPACE NINJA", MyCharacter.DefaultModel, null, null, false);
                m_plys.Add(ply);
                return(true);
            });

            AddShortcut(MyKeys.NumPad0, true, false, false, false,
                        () => "Remove one spawned player: " + m_plys.Count,
                        delegate
            {
                if (m_plys.Count == 0)
                {
                    return(false);
                }
                var ply = m_plys[0];
                m_plys.Remove(ply);
                ply.Close();
                return(true);
            });
        }
예제 #14
0
        private void PutPlayerInRespawnGrid(MyPlayer player, List <MyCubeGrid> respawnGrids, MyBotDefinition botDefinition)
        {
            MyCharacter character = null;
            MyCockpit   cockpit   = null;

            // Find cockpits
            List <MyCockpit> shipCockpits = new List <MyCockpit>();

            foreach (MyCubeGrid grid in respawnGrids)
            {
                foreach (MyCockpit gridCockpit in grid.GetFatBlocks <MyCockpit>())
                {
                    // Ignore non-functional cockpits
                    if (!gridCockpit.IsFunctional)
                    {
                        continue;
                    }
                    shipCockpits.Add(gridCockpit);
                }
            }

            // First sort cockpits by order: Ship controlling cockpits set to main, then ship controlling cockpits not set to main, lastly whatever remains, e.g. CryoChambers and Passenger Seats
            if (shipCockpits.Count > 1)
            {
                shipCockpits.Sort(delegate(MyCockpit cockpitA, MyCockpit cockpitB)
                {
                    int controlCompare = cockpitB.EnableShipControl.CompareTo(cockpitA.EnableShipControl);
                    if (controlCompare != 0)
                    {
                        return(controlCompare);
                    }

                    int mainCompare = cockpitB.IsMainCockpit.CompareTo(cockpitA.IsMainCockpit);
                    if (mainCompare != 0)
                    {
                        return(mainCompare);
                    }

                    return(0);
                });
            }

            // Finally, select the most important cockpit
            if (shipCockpits.Count > 0)
            {
                cockpit = shipCockpits[0];
            }

            System.Diagnostics.Debug.Assert(cockpit != null, "character is spawning in ship without cockpit !");

            // Create character
            MatrixD matrix = MatrixD.Identity;

            if (cockpit != null)
            {
                matrix             = cockpit.WorldMatrix;
                matrix.Translation = cockpit.WorldMatrix.Translation - Vector3.Up - Vector3.Forward;
            }
            else if (respawnGrids.Count > 0)
            {
                matrix.Translation = respawnGrids[0].PositionComp.WorldAABB.Center + respawnGrids[0].PositionComp.WorldAABB.HalfExtents;
            }

            character = MyCharacter.CreateCharacter(matrix, Vector3.Zero, player.Identity.DisplayName, player.Identity.Model, null, botDefinition, cockpit: cockpit, playerSteamId: player.Id.SteamId);

            CloseRespawnShip(player);
            foreach (var respawnGrid in respawnGrids)
            {
                respawnGrid.ChangeGridOwnership(player.Identity.IdentityId, MyOwnershipShareModeEnum.None);
                respawnGrid.IsRespawnGrid = true;
                respawnGrid.m_playedTime  = 0;
                player.RespawnShip.Add(respawnGrid.EntityId);
            }
            //SaveRespawnShip(player);

            if (cockpit != null)
            {
                cockpit.AttachPilot(character, false);
                MyMultiplayer.ReplicateImmediatelly(MyExternalReplicable.FindByObject(cockpit.CubeGrid), new EndpointId(player.Id.SteamId));
            }

            if (cockpit == null)
            {
                Sync.Players.SetPlayerCharacter(player, character, null);
            }
            else
            {
                character.SetPlayer(player);
                Sync.Players.SetPlayerToCockpit(player, cockpit);
            }
            Sync.Players.RevivePlayer(player);
        }