private void SpawnInRespawn(MyPlayer player, MyRespawnComponent respawn, MyBotDefinition botDefinition) { if (MySession.Static.Settings.EnableOxygen) { player.Identity.ChangeToOxygenSafeSuit(); } if (respawn.Entity == null) { Debug.Assert(false, "Respawn does not have entity!"); SpawnInSuit(player, null, botDefinition); return; } var parent = respawn.Entity.GetTopMostParent(); if (parent.Physics == null) { Debug.Assert(false, "Respawn entity parent does not have physics!"); SpawnInSuit(player, (MyEntity)parent, botDefinition); return; } MatrixD pos; var medRoom = respawn.Entity as MyMedicalRoom; if (medRoom != null) { pos = medRoom.GetSpawnPosition(); } else { pos = respawn.GetSpawnPosition(respawn.Entity.WorldMatrix); } Vector3 velocity = parent.Physics.GetVelocityAtPoint(pos.Translation); MyMultiplayer.ReplicateImmediatelly(MyExternalReplicable.FindByObject(parent), new EndpointId(player.Id.SteamId)); player.SpawnAt(pos, velocity, (MyEntity)parent, botDefinition, true); if (medRoom != null) { medRoom.TryTakeSpawneeOwnership(player); medRoom.TrySetFaction(player); if (medRoom.ForceSuitChangeOnRespawn) { player.Character.ChangeModelAndColor(medRoom.RespawnSuitName, player.Character.ColorMask); } } }
private void SpawnInRespawn(MyPlayer player, MyRespawnComponent respawn) { if (MySession.Static.Settings.EnableOxygen) { player.Identity.ChangeToOxygenSafeSuit(); } if (respawn.Entity == null) { Debug.Assert(false, "Respawn does not have entity!"); SpawnInSuit(player); return; } var parent = respawn.Entity.GetTopMostParent(); if (parent.Physics == null) { Debug.Assert(false, "Respawn entity parent does not have physics!"); SpawnInSuit(player); return; } MatrixD pos; var medRoom = respawn.Entity as MyMedicalRoom; if (medRoom != null) { pos = medRoom.GetSpawnPosition(); } else { pos = respawn.GetSpawnPosition(respawn.Entity.WorldMatrix); } Vector3 velocity = parent.Physics.GetVelocityAtPoint(pos.Translation); player.SpawnAt(pos, velocity, false); if (medRoom != null) { medRoom.TryTakeSpawneeOwnership(player); medRoom.TrySetFaction(player); } }