protected override void PlacePilotInSeat(MyCharacter pilot) { pilot.EnableLights(false, false); pilot.EnableJetpack(false, false, false, false); pilot.Sit(true, MySession.LocalCharacter == pilot, false, BlockDefinition.CharacterAnimation); pilot.SuitBattery.Enabled = true; pilot.PositionComp.SetWorldMatrix(m_characterDummy * WorldMatrix); UpdateEmissivity(true); }
public bool RemovePilot() { if (m_pilot == null) { return(true); } System.Diagnostics.Debug.Assert(m_pilot.Physics != null); if (m_pilot.Physics == null) { //probably already closed pilot left in cockpit m_pilot = null; return(true); } //m_soundEmitter.OwnedBy = null; if (MyFakes.ENABLE_NEW_SOUNDS) { StopLoopSound(); } m_pilot.OnMarkForClose -= m_pilotClosedHandler; if (m_pilot.IsDead) { if (this.ControllerInfo.Controller != null) { this.SwitchControl(m_pilot); } Hierarchy.RemoveChild(m_pilot); MyEntities.Add(m_pilot); m_pilot.WorldMatrix = WorldMatrix; m_pilotGunDefinition = null; m_rechargeSocket.Unplug(); m_pilot = null; return(true); } bool usePilotOriginalWorld = false; MatrixD placementMatrix = MatrixD.Identity; if (m_pilotRelativeWorld.HasValue) { placementMatrix = MatrixD.Multiply((MatrixD)m_pilotRelativeWorld.Value, this.WorldMatrix); if (m_pilot.CanPlaceCharacter(ref placementMatrix)) { usePilotOriginalWorld = true; } } Vector3D?allowedPosition = null; if (!usePilotOriginalWorld) { allowedPosition = FindFreeNeighbourPosition(); if (!allowedPosition.HasValue) { allowedPosition = PositionComp.GetPosition(); } } RemovePilotFromSeat(m_pilot); EndShootAll(); if (usePilotOriginalWorld || allowedPosition.HasValue) { Hierarchy.RemoveChild(m_pilot); MyEntities.Add(m_pilot); m_pilot.Physics.Enabled = true; m_rechargeSocket.Unplug(); m_pilot.Stand(); // allowedPosition is in center of character MatrixD placeMatrix = (usePilotOriginalWorld) ? placementMatrix : MatrixD.CreateWorld(allowedPosition.Value - WorldMatrix.Up, WorldMatrix.Forward, WorldMatrix.Up); if (m_pilot.Physics.CharacterProxy != null) { m_pilot.Physics.CharacterProxy.ImmediateSetWorldTransform = true; } if (!MyEntities.CloseAllowed) { m_pilot.PositionComp.SetWorldMatrix(placeMatrix); } if (m_pilot.Physics.CharacterProxy != null) { m_pilot.Physics.CharacterProxy.ImmediateSetWorldTransform = false; } if (Parent != null) // Cockpit could be removing the pilot after it no longer belongs to any grid (e.g. during a split) { m_pilot.Physics.LinearVelocity = Parent.Physics.LinearVelocity; if (Parent.Physics.LinearVelocity.LengthSquared() > 100) { m_pilot.EnableDampeners(false); m_pilot.EnableJetpack(true); } } if (this.ControllerInfo.Controller != null) { this.SwitchControl(m_pilot); } if (m_pilotGunDefinition != null) { m_pilot.SwitchToWeapon(m_pilotGunDefinition); } else { m_pilot.SwitchToWeapon(null); } var pilot = m_pilot; m_pilot = null; if (MySession.Static.CameraController == this) { MySession.SetCameraController(MyCameraControllerEnum.Entity, pilot); } return(true); } else { //System.Diagnostics.Debug.Assert(false, "There is no place where to put astronaut. Kill him!"); } return(false); }