public MyCubeGridSystems(MyCubeGrid grid)
        {
            m_cubeGrid = grid;

            m_terminalSystem_GroupAdded   = TerminalSystem_GroupAdded;
            m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved;

            ThrustSystem         = new MyGridThrustSystem(m_cubeGrid);
            GyroSystem           = new MyGridGyroSystem(m_cubeGrid);
            WeaponSystem         = new MyGridWeaponSystem();
            ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid);
            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                WheelSystem = new MyGridWheelSystem(m_cubeGrid);
            }
            ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid);
            LandingSystem  = new MyGridLandingSystem();
            ControlSystem  = new MyGroupControlSystem();
            CameraSystem   = new MyGridCameraSystem(m_cubeGrid);

            if (MySession.Static.Settings.EnableOxygen)
            {
                OxygenSystem = new MyGridOxygenSystem(m_cubeGrid);
            }
            if (MyPerGameSettings.EnableJumpDrive)
            {
                JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid);
            }

            m_cubeGrid.SyncObject.PowerProducerStateChanged += SyncObject_PowerProducerStateChanged;

            m_blocksRegistered = true;
        }
        public MyCubeGridSystems(MyCubeGrid grid)
        {
            m_cubeGrid = grid;

            m_terminalSystem_GroupAdded   = TerminalSystem_GroupAdded;
            m_terminalSystem_GroupRemoved = TerminalSystem_GroupRemoved;

            GyroSystem           = new MyGridGyroSystem(m_cubeGrid);
            WeaponSystem         = new MyGridWeaponSystem();
            ReflectorLightSystem = new MyGridReflectorLightSystem(m_cubeGrid);
            if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT)
            {
                WheelSystem = new MyGridWheelSystem(m_cubeGrid);
            }
            ConveyorSystem = new MyGridConveyorSystem(m_cubeGrid);
            LandingSystem  = new MyGridLandingSystem();
            ControlSystem  = new MyGroupControlSystem();
            CameraSystem   = new MyGridCameraSystem(m_cubeGrid);

            if (MySession.Static.Settings.EnableOxygen && MySession.Static.Settings.EnableOxygenPressurization)
            {
                GasSystem = new MyGridGasSystem(m_cubeGrid);
            }
            if (MyPerGameSettings.EnableJumpDrive)
            {
                JumpSystem = new MyGridJumpDriveSystem(m_cubeGrid);
            }
            if (MyPerGameSettings.EnableShipSoundSystem && (MyFakes.ENABLE_NEW_SMALL_SHIP_SOUNDS || MyFakes.ENABLE_NEW_LARGE_SHIP_SOUNDS) && MySandboxGame.IsDedicated == false)
            {
                ShipSoundComponent = new MyShipSoundComponent();
            }

            m_blocksRegistered = true;
        }
示例#3
0
        private static void MainCockpitChanged(MyShipController controller)
        {
            MyGroupControlSystem system = controller.CubeGrid.GridSystems.ControlSystem;

            MethodInfo OnControlReleased = typeof(MyGridSelectionSystem).GetMethod("OnControlReleased", BindingFlags.Instance | BindingFlags.NonPublic);

            if (OnControlReleased == null)
            {
                throw new NullReferenceException("MyGridSelectionSystem.OnControlReleased does not exist or has unexpected binding");
            }

            MethodInfo OnControlAcquired = typeof(MyGridSelectionSystem).GetMethod("OnControlAcquired", BindingFlags.Instance | BindingFlags.NonPublic);

            if (OnControlAcquired == null)
            {
                throw new NullReferenceException("MyGridSelectionSystem.OnControlAcquired does not exist or has unexpected binding");
            }

            bool enabled = controller.IsMainCockpit;

            foreach (MySlimBlock block in controller.CubeGrid.GetBlocks())
            {
                MyShipController otherController = block.FatBlock as MyShipController;
                if (otherController != null && otherController.EnableShipControl && otherController != controller && otherController.ControllerInfo.Controller != null)
                {
                    MyGridSelectionSystem selectSystem = otherController.GridSelectionSystem;

                    if (enabled)
                    {
                        if (system != null)
                        {
                            system.RemoveControllerBlock(otherController);
                        }
                        if (selectSystem != null)
                        {
                            OnControlReleased.Invoke(selectSystem, null);
                        }
                    }
                    else
                    {
                        if (system != null)
                        {
                            system.AddControllerBlock(otherController);
                        }
                        if (selectSystem != null)
                        {
                            OnControlAcquired.Invoke(selectSystem, null);
                        }
                    }
                }
            }
        }