public void UpdateBeforeSimulation()
        {
            ProfilerShort.Begin("Thrusters");
            MyEntityThrustComponent thrustComp;

            if (CubeGrid.Components.TryGet(out thrustComp))
            {
                thrustComp.UpdateBeforeSimulation(false, Sync.IsServer || CubeGrid.GridSystems.ControlSystem.IsLocallyControlled);
            }
            ProfilerShort.End();

            // Only update gyros if there are gyros in the system
            if (GyroSystem.GyroCount > 0)
            {
                ProfilerShort.Begin("Gyros");
                GyroSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                ProfilerShort.Begin("Wheels");
                WheelSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            /*ProfilerShort.Begin("Conveyors");
             * ConveyorSystem.UpdateBeforeSimulation();
             * ProfilerShort.End();*/

            ProfilerShort.Begin("Control");
            ControlSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            ProfilerShort.Begin("Cameras");
            CameraSystem.UpdateBeforeSimulation();
            ProfilerShort.End();

            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization)
            {
                ProfilerShort.Begin("Oxygen");
                GasSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                ProfilerShort.Begin("Jump");
                JumpSystem.UpdateBeforeSimulation();
                ProfilerShort.End();
            }

            ProfilerShort.Begin("Ship sounds");
            if (ShipSoundComponent != null)
            {
                ShipSoundComponent.Update();
            }
            ProfilerShort.End();
        }
        public virtual void UpdateBeforeSimulation100()
        {
            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization)
            {
                GasSystem.UpdateBeforeSimulation100();
            }

            if (ShipSoundComponent != null)
            {
                ShipSoundComponent.Update100();
            }
        }
        public virtual void BeforeGridClose()
        {
            ConveyorSystem.IsClosing       = true;
            ReflectorLightSystem.IsClosing = true;

            if (ShipSoundComponent != null)
            {
                ShipSoundComponent.DestroyComponent();
                ShipSoundComponent = null;
            }

            // Inform gas system we are going down
            if (GasSystem != null)
            {
                GasSystem.OnGridClosing();
            }
        }
        public virtual void Init(MyObjectBuilder_CubeGrid builder)
        {
            var thrustComp = CubeGrid.Components.Get <MyEntityThrustComponent>();

            if (thrustComp != null)
            {
                thrustComp.DampenersEnabled = builder.DampenersEnabled;
            }

            if (WheelSystem != null)
            {
                m_cubeGrid.SetHandbrakeRequest(builder.Handbrake);
            }

            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization)
            {
                GasSystem.Init(builder.OxygenAmount);
            }
            if (ShipSoundComponent != null)
            {
                if (ShipSoundComponent.InitComponent(m_cubeGrid) == false)
                {
                    ShipSoundComponent.DestroyComponent();
                    ShipSoundComponent = null;
                }
            }

            if (MyPerGameSettings.EnableJumpDrive)
            {
                JumpSystem.Init(builder.JumpDriveDirection, builder.JumpRemainingTime);
            }

            var thrustComponent = CubeGrid.Components.Get <MyEntityThrustComponent>();

            if (thrustComponent != null)
            {
                thrustComponent.MergeAllGroupsDirty();
            }
        }