Esempio n. 1
0
        void Launch()
        {
            if (Context.WCAPI == null)
            {
                return;
            }
            var target = Context.WCAPI.GetAiFocus(Context.Reference.CubeGrid.EntityId);

            if (target == null)
            {
                return;
            }

            Landpedo landpedo = null;

            foreach (var tube in LandpedoTubes)
            {
                if (tube.Landpedo != null)
                {
                    landpedo = tube.Launch();
                    break;
                }
            }

            if (landpedo == null)
            {
                return;
            }
            Landpedos.Add(landpedo);
            landpedo.TargetID = target.Value.EntityId;
        }
Esempio n. 2
0
        public Landpedo Launch()
        {
            foreach (var thruster in Landpedo.Thrusters)
            {
                thruster.Enabled = true;
            }
            foreach (var gyro in Landpedo.Gyros)
            {
                gyro.Enabled = true;
            }
            foreach (var bat in Landpedo.Batteries)
            {
                bat.ChargeMode = ChargeMode.Auto;
            }

            Landpedo.Drive = new HeliDrive();
            Landpedo.Drive.Setup(Landpedo.Controller);

            Landpedo.Drive.gyroController.Update(Landpedo.Controller, Landpedo.Gyros);
            Landpedo.Drive.thrustController.Update(Landpedo.Controller, Landpedo.Thrusters);

            Landpedo.Drive.maxFlightPitch = 60;
            Landpedo.Drive.maxFlightRoll  = 60;

            Landpedo.Drive.SwitchToMode("flight");

            var torp = Landpedo;

            torp.Connector.Enabled = false;
            Landpedo = null;
            return(torp);
        }
Esempio n. 3
0
        public static Landpedo GetLandpedo(List <IMyTerminalBlock> blocks)
        {
            Landpedo landpedo = new Landpedo();

            foreach (var block in blocks)
            {
                if (block is IMyGyro)
                {
                    landpedo.Gyros.Add(block as IMyGyro);
                }
                else if (block is IMyThrust)
                {
                    landpedo.Thrusters.Add(block as IMyThrust);
                }
                else if (block is IMyBatteryBlock)
                {
                    landpedo.Batteries.Add(block as IMyBatteryBlock);
                }
                else if (block is IMyLightingBlock)
                {
                    landpedo.Lights.Add(block as IMyLightingBlock);
                }
                else if (block is IMyShipConnector)
                {
                    landpedo.Connector = block as IMyShipConnector;
                }
                else if (block is IMyShipController)
                {
                    landpedo.Controller = block as IMyShipController;
                }
                else if (block.CustomName.Contains("launcher"))
                {
                    landpedo.Launchers.Add(block as IMyFunctionalBlock);
                }
            }

            if (landpedo.Gyros.Count == 0 ||
                landpedo.Thrusters.Count == 0 ||
                landpedo.Connector == null ||
                landpedo.Controller == null)
            {
                return(null);
            }

            foreach (var light in landpedo.Lights)
            {
                light.Color = Color.Green;
            }

            return(landpedo);
        }
Esempio n. 4
0
        public void CheckLandpedo()
        {
            statusBuilder.Clear();
            if (Landpedo != null)
            {
                return;
            }

            if (Connector != null)
            {
                if (!Connector.IsWorking)
                {
                    return;
                }
                if (Connector.Status == MyShipConnectorStatus.Unconnected)
                {
                    return;
                }
                if (Connector.Status == MyShipConnectorStatus.Connectable)
                {
                    Connector.Connect();
                }

                if (Connector.Status != MyShipConnectorStatus.Connected)
                {
                    return;
                }

                var other = Connector.OtherConnector;
                var lines = other.CustomData.Split('\n');
                // Parts
                // Projector
                // Merge

                IMyProjector      projector = null;
                IMyShipMergeBlock merge     = null;


                if (GridTerminalHelper.Base64BytePosToBlockList(lines[1], other, ref PartScratchpad))
                {
                    projector = PartScratchpad[0] as IMyProjector;
                }

                PartScratchpad.Clear();
                if (GridTerminalHelper.Base64BytePosToBlockList(lines[2], other, ref PartScratchpad))
                {
                    merge = PartScratchpad[0] as IMyShipMergeBlock;
                }

                if (projector != null && merge != null)
                {
                    projector.Enabled = true;
                    merge.Enabled     = false;
                }

                PartScratchpad.Clear();
                if (!GridTerminalHelper.Base64BytePosToBlockList(lines[0], other, ref PartScratchpad))
                {
                    return;
                }

                Landpedo          = Landpedo.GetLandpedo(PartScratchpad);
                projector.Enabled = false;
            }
            else
            {
            }
        }