Exemple #1
0
        public void Main(string argument)
        {
            IMyLaserAntenna antenna  = null;
            IMyLaserAntenna antenna2 = null;

            antenna.SetTargetCoords(antenna2.GetPosition().ToString());
        }
Exemple #2
0
            public ACPWrapper(Program p, IMyLaserAntenna lAntenna)
            {
                CommonInit(p);
                this.lAntenna = lAntenna;
                isLaser       = true;

                Ping();
            }
Exemple #3
0
                public Antenna(IMyLaserAntenna laserAntenna) : this()
                {
                    if (laserAntenna == null)
                    {
                        throw new Exception("laserAntenna cannot be null!");
                    }

                    this.laserAntenna = laserAntenna;
                    type = antennaType.laserAntenna;
                }
            public ACPWrapper(Program p, string antennaName)
            {
                CommonInit(p);

                IMyTerminalBlock temp = P.GridTerminalSystem.GetBlockWithName(antennaName);

                if (temp.GetType() == typeof(IMyRadioAntenna))
                {
                    this.antenna = (IMyRadioAntenna)temp;
                }
                else if (temp.GetType() == typeof(IMyLaserAntenna))
                {
                    this.lAntenna = (IMyLaserAntenna)temp;
                    isLaser       = true;
                }
            }
Exemple #5
0
        /// <param name="pathfinder">The mover to use</param>
        ///
        /// <param name="rotBlock">The block to rotate</param>
        public Facer(Pathfinder pathfinder, PseudoBlock rotBlock)
            : base(pathfinder)
        {
            this.m_pseudoBlock = rotBlock;
            this.m_laser       = rotBlock.Block as IMyLaserAntenna;
            if (this.m_laser == null)
            {
                if (!(rotBlock.Block is Ingame.IMySolarPanel) && !(rotBlock.Block is Ingame.IMyOxygenFarm))
                {
                    Log.AlwaysLog("Block is of wrong type: " + rotBlock.Block.DisplayNameText, Logger.severity.FATAL);
                    throw new Exception("Block is of wrong type: " + rotBlock.Block.DisplayNameText);
                }
            }

            m_navSet.Settings_Task_NavRot.NavigatorRotator = this;
        }
Exemple #6
0
        /// <summary>
        /// Creates a NetworkNode for a block, checking block attachments, laser, and radio communication.
        /// </summary>
        /// <param name="block">The block to create the NetworkNode for.</param>
        public RelayNode(IMyCubeBlock block)
        {
            this.m_debugName        = () => block.DisplayNameText;
            this.m_ownerId          = () => block.OwnerId;
            this.m_entity           = block;
            this.m_comp_blockAttach = block;
            this.m_comp_radio       = ComponentRadio.TryCreateRadio(block);

            IMyLaserAntenna lAnt = block as IMyLaserAntenna;

            if (lAnt != null)
            {
                this.m_comp_laser = lAnt;
            }

            Registrar.Add(block, this);
        }
Exemple #7
0
		/// <param name="mover">The mover to use</param>
		/// <param name="navSet">The settings to use</param>
		/// <param name="rotBlock">The block to rotate</param>
		public Facer(Mover mover, AllNavigationSettings navSet, PseudoBlock rotBlock)
			: base(mover, navSet)
		{
			this.m_logger = new Logger("Facer", m_controlBlock.CubeBlock);

			this.m_pseudoBlock = rotBlock;
			this.m_laser = rotBlock.Block as IMyLaserAntenna;
			if (this.m_laser == null)
			{
				if (!(rotBlock.Block is Ingame.IMySolarPanel) && !(rotBlock.Block is Ingame.IMyOxygenFarm))
				{
					m_logger.alwaysLog("Block is of wrong type: " + rotBlock.Block.DisplayNameText, "Facer()", Logger.severity.FATAL);
					throw new Exception("Block is of wrong type: " + rotBlock.Block.DisplayNameText);
				}
			}

			m_navSet.Settings_Task_NavRot.NavigatorRotator = this;
		}
Exemple #8
0
        public void Main(string argument, UpdateType updateSource)
        {
            // The main entry point of the script, invoked every time
            // one of the programmable block's Run actions are invoked,
            // or the script updates itself. The updateSource argument
            // describes where the update came from. Be aware that the
            // updateSource is a  bitfield  and might contain more than
            // one update type.
            //
            // The method itself is required, but the arguments above
            // can be removed if not needed.

            IMyLaserAntenna  antenna       = (IMyLaserAntenna)GridTerminalSystem.GetBlockWithName("Main Laser Antenna");
            IMyRemoteControl remoteControl = (IMyRemoteControl)GridTerminalSystem.GetBlockWithName("Main Remote Control");

            if (antenna != null && remoteControl != null)
            {
                if (antenna.Status != MyLaserAntennaStatus.Connected)
                {
                    if (antenna.Status != MyLaserAntennaStatus.RotatingToTarget)
                    {
                        if (antenna.Status != MyLaserAntennaStatus.SearchingTargetForAntenna)
                        {
                            if (antenna.Status != MyLaserAntennaStatus.Connecting)
                            {
                                antenna.Connect();
                            }
                        }
                    }

                    remoteControl.ClearWaypoints();
                    remoteControl.AddWaypoint(antenna.TargetCoords, "Antenna Target");
                    remoteControl.SpeedLimit = 10;
                    remoteControl.Direction  = Base6Directions.Direction.Forward;
                    remoteControl.SetAutoPilotEnabled(true);
                    regainedConnection = false;
                }
                else if (!regainedConnection)
                {
                    remoteControl.SetAutoPilotEnabled(false);
                    regainedConnection = true;
                }
            }
        }
Exemple #9
0
        public Program()
        {
            _laser1LCDs = new List <IMyTerminalBlock>();
            _laser2LCDs = new List <IMyTerminalBlock>();
            _laser3LCDs = new List <IMyTerminalBlock>();
            _laser4LCDs = new List <IMyTerminalBlock>();
            _laser5LCDs = new List <IMyTerminalBlock>();
            _laser6LCDs = new List <IMyTerminalBlock>();
            _laser7LCDs = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName("LCD Panel 1-", _laser1LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 2-", _laser2LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 3-", _laser3LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 4-", _laser4LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 5-", _laser5LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 6-", _laser6LCDs, lcd => lcd is IMyTextPanel);
            GridTerminalSystem.SearchBlocksOfName("LCD Panel 7-", _laser7LCDs, lcd => lcd is IMyTextPanel);

            _laserAntenna1 = GridTerminalSystem.GetBlockWithName("Moon to Space Port Relay") as IMyLaserAntenna;
            _laserAntenna2 = GridTerminalSystem.GetBlockWithName("Moon to Earth Relay") as IMyLaserAntenna;
            _laserAntenna3 = GridTerminalSystem.GetBlockWithName("Moon to Chrono Relay") as IMyLaserAntenna;
            _laserAntenna4 = GridTerminalSystem.GetBlockWithName("Moon to Mars Relay") as IMyLaserAntenna;
            _laserAntenna5 = GridTerminalSystem.GetBlockWithName("Moon to Titan Relay") as IMyLaserAntenna;
            _laserAntenna6 = GridTerminalSystem.GetBlockWithName("Moon to Alien Relay") as IMyLaserAntenna;
            _laserAntenna7 = GridTerminalSystem.GetBlockWithName("Moon to Alien Moon Relay") as IMyLaserAntenna;

            Runtime.UpdateFrequency = UpdateFrequency.Update100;

            _oldStatus1 = _laserAntenna1.Status == MyLaserAntennaStatus.Connected;
            _oldStatus2 = _laserAntenna2.Status == MyLaserAntennaStatus.Connected;
            _oldStatus3 = _laserAntenna3.Status == MyLaserAntennaStatus.Connected;
            _oldStatus4 = _laserAntenna4.Status == MyLaserAntennaStatus.Connected;
            _oldStatus5 = _laserAntenna5.Status == MyLaserAntennaStatus.Connected;
            _oldStatus6 = _laserAntenna6.Status == MyLaserAntennaStatus.Connected;
            _oldStatus7 = _laserAntenna7.Status == MyLaserAntennaStatus.Connected;
        }
    public bool FilterLasserAntena(IMyTerminalBlock block)
    {
        IMyLaserAntenna la = block as IMyLaserAntenna;

        return(la != null);
    }
Exemple #11
0
    bool Filter_Method_Laser_Antenna(IMyTerminalBlock block)
    {
        IMyLaserAntenna la = block as IMyLaserAntenna;

        return(la != null);
    }
        public void Main(string arg)
        {
            DateTime currentDateTime = DateTime.Now;

            Antenna = GridTerminalSystem.GetBlockWithName(LA) as IMyLaserAntenna;
            if (Antenna == null)
            {
                Echo(LAFailedMSG);
                return;
            }
            LCD = GridTerminalSystem.GetBlockWithName(LCDs) as IMyTextPanel;
            if (counter == 0)
            {
                graphics = new Graphics(150, 150, (IMyTextPanel)LCD);
            }
            counter++;
            if (LCD == null)
            {
                Echo(LCDFailedMSG);
                return;
            }
            if (Setup && Antenna.Status != MyLaserAntennaStatus.Connected)
            {
                LCD.WritePublicText(CenterText("Connection Lost to " + Ship), false);
                LCD.WritePublicText(CenterText("Last known details.."), true);
                LCD.WritePublicText(ShipOutput + StatusOutput + ElevationOutput, true);
            }
            if (!Setup && Antenna.Status != MyLaserAntennaStatus.Connected)
            {
                LCD.WritePublicText(CenterText("Mission not setup!"), false);
                LCD.WritePublicText(CenterText("No connection has been made!"), true);
            }
            if (Antenna.Status == MyLaserAntennaStatus.Connected)
            {
                var keyValuePairs = arg.Split(',').Select(x => x.Split(':')).Where(x => x.Length == 2).ToDictionary(x => x.First(), x => x.Last());
                foreach (KeyValuePair <String, String> i in keyValuePairs)
                {
                    Echo("Key: " + i.Key);
                    Echo("Value: " + i.Value);
                }
                if (!Setup && arg.Contains("Ship:"))
                {
                    ConnectedShip = keyValuePairs["Ship"];
                    Setup         = true;
                }
                Echo(arg);
                if (Setup)
                {
                    if (arg.Contains("Ship:"))
                    {
                        if (keyValuePairs["Ship"] == ConnectedShip)
                        {
                            Ship       = keyValuePairs["Ship"];
                            ShipOutput = CenterText(("Ship: " + Ship));
                        }
                        else
                        {
                            ShipOutput = CenterText("Ship: Connection changed!");
                        }
                    }
                    graphics.setFG(255, 0, 0);
                    graphics.rect("line", 0, 0, 12, 150);
                    if (arg.Contains("Status:"))
                    {
                        Status       = keyValuePairs["Status"];
                        StatusOutput = CenterText("Status: " + Status);
                    }
                    if (arg.Contains("Elevation:"))
                    {
                        Elevation = keyValuePairs["Elevation"];
                        int Elevation1 = Convert.ToInt32(Elevation);
                        ElevationOutput = CenterText("Elevation: " + Elevation);
                        ElevProgress    = (Elevation1 / 15000) * 100;
                        int ElevPro = (148 * (ElevProgress / 100));
                        graphics.mask(1, 1, 10, 148);
                        graphics.setFG(0, 255, 0);
                        graphics.rect("fill", 1, 1, 10, 148);
                        graphics.print(12, 0, string.Format("{0,5:P0}", ElevProgress));
                        graphics.mask(1, 1, 10, ElevPro);
                        graphics.setFG(0, 0, 0);
                        graphics.rect("fill", 1, 1, 10, ElevPro);
                        graphics.mask();
                        graphics.paint();
                    }
                    if (arg.Contains("Speed:"))
                    {
                        Speed       = keyValuePairs["Speed"];
                        SpeedOutput = CenterText("Speed: " + Speed);
                    }
                    string AntennaStatus = BottomLeftText("Antenna Connected");
                    //LCD.WritePublicText(ShipOutput + StatusOutput + ElevationOutput + SpeedOutput + AntennaStatus, false);
                }
                else
                {
                    LCD.WritePublicText(CenterText("Connected ship has changed!"), false);
                }
            }
        }
Exemple #13
0
 /// <summary>
 /// Creates the laser component from a laser antenna block.
 /// </summary>
 /// <param name="laser">The block to create the laser component for.</param>
 public ComponentLaser(IMyLaserAntenna laser)
 {
     this.m_laser = laser;
 }
Exemple #14
0
        public void Main(string arg)
        {
            RController = GridTerminalSystem.GetBlockWithName(RC) as IMyShipController;
            if (RController == null)
            {
                Echo(RCFailedMSG);
                RCFailed = true;
                Status   = "Failed";
                return;
            }

            RControllers = GridTerminalSystem.GetBlockWithName(RC) as IMyRemoteControl;
            if (RControllers == null)
            {
                Echo(RCFailedMSG);
                RCFailed = true;
                Status   = "Failed";
                return;
            }

            var CCruise = GridTerminalSystem.GetBlockWithName(CC) as IMyProgrammableBlock;

            if (CCruise == null)
            {
                Echo(CCFailedMSG);
                CCFailed = true;
                Status   = "Failed";
                return;
            }

            RGyro = GridTerminalSystem.GetBlockWithName(Gyro) as IMyGyro;
            if (RGyro == null)
            {
                Echo(GyroFailedMSG);
                GyroFailed = true;
                Status     = "Failed";
                return;
            }

            RGyros = GridTerminalSystem.GetBlockWithName(Gyro) as IMyFunctionalBlock;
            if (RGyros == null)
            {
                Echo(GyroFailedMSG);
                GyroFailed = true;
                Status     = "Failed";
                return;
            }

            RCon = GridTerminalSystem.GetBlockWithName(Cargo) as IMyCargoContainer;
            if (RCon == null)
            {
                Echo(RConFailedMSG);
                RConFailed = true;
                Status     = "Failed";
                return;
            }

            LAntenna = GridTerminalSystem.GetBlockWithName(LA) as IMyLaserAntenna;
            if (LAntenna == null)
            {
                Echo(LAFailedMSG);
                LAFailed = true;
                Status   = "Failed";
                return;
            }

            LGear = GridTerminalSystem.GetBlockWithName(LG) as IMyTimerBlock;
            if (LGear == null)
            {
                Echo(LGFailedMSG);
                LGFailed = true;
                Status   = "Failed";
                return;
            }

            CCUp = GridTerminalSystem.GetBlockWithName(CCU) as IMyTimerBlock;
            if (CCUp == null)
            {
                Echo(CCTsFailedMSG);
                CCTsFailed = true;
                Status     = "Failed";
                return;
            }
            CCOff = GridTerminalSystem.GetBlockWithName(CCO) as IMyTimerBlock;
            if (CCOff == null)
            {
                Echo(CCTsFailedMSG);
                CCTsFailed = true;
                Status     = "Failed";
                return;
            }
            CCDown = GridTerminalSystem.GetBlockWithName(CCD) as IMyTimerBlock;
            if (CCDown == null)
            {
                Echo(CCTsFailedMSG);
                CCTsFailed = true;
                Status     = "Failed";
                return;
            }
            GridTerminalSystem.GetBlocksOfType(thrustersUP, x => x.WorldMatrix.Forward == RControllers.WorldMatrix.Up);
            if (thrustersUP.Count == 0)
            {
                Echo($"Error: No lift-off thrusters were found!");
            }
            GridTerminalSystem.GetBlocksOfType(thrustersDOWN, x => x.WorldMatrix.Forward == RControllers.WorldMatrix.Down);
            if (thrustersDOWN.Count == 0)
            {
                Echo($"Error: No lift-off thrusters were found!");
            }
            var shipMass = RController.CalculateShipMass();

            TotalMass  = shipMass.TotalMass;
            AutoEnable = RControllers.IsAutoPilotEnabled;
            RController.TryGetPlanetElevation(MyPlanetElevation.Sealevel, out Elev);
            velo          = RController.GetShipSpeed();
            Position      = RController.GetPosition();
            Gravity       = (RController.GetNaturalGravity().Length());
            GravityG      = (RController.GetNaturalGravity().Length() / 9.81);
            thrustSumUP   = 0;
            thrustSumDOWN = 0;
            foreach (var block in thrustersUP)
            {
                thrustSumUP += block.MaxEffectiveThrust;
            }
            foreach (var block in thrustersDOWN)
            {
                thrustSumDOWN += block.MaxEffectiveThrust;
            }
            if (Status == "Launched")
            {
                TargetGravity = (PlanetGravity * (Math.Pow((MaxR / (TargetAltitude + MinR)), 7)));
                Accel         = ((thrustSumUP / TotalMass) + TargetGravity); //Stopping force
                AccelTime     = ((0 - velo) / -Accel);                       //Seconds to stop
                stopDistance  = ((velo * AccelTime) + ((-Accel * (AccelTime * AccelTime)) / 2));
            }
            if (Status == "Return")
            {
                Accel        = ((thrustSumDOWN / TotalMass) - PlanetGravity); //Stopping force
                AccelTime    = ((0 - velo) / -Accel);                         //Seconds to stop
                stopDistance = ((velo * AccelTime) + ((-Accel * (AccelTime * AccelTime)) / 2));
            }
            Echo(Ship + " Control Pro");
            Echo("Status: " + Status);
            Echo("Altitude: " + Math.Round(Elev, 2) + "/" + TargetAltitude);
            Echo("Speed: " + Math.Round(velo, 2));
            Echo("Total Weight: " + TotalMass);
            Echo("Gravity: " + Math.Round(GravityG, 2) + "G");
            string msg = ("Ship" + ":" + Ship + "," + "Status" + ":" + Status + "," + "Elevation" + ":" + Elev + "," + "Position" + ":" + Position + "," + "Speed" + ":" + velo + "," + "Target" + ":" + TargetAltitude + ",");

            LAntenna.TransmitMessage(msg);
            var keyValuePairs = arg.Split(',').Select(x => x.Split(':')).Where(x => x.Length == 2).ToDictionary(x => x.First(), x => x.Last());

            //Echo(thrustSumDOWN.ToString());
            //Echo(thrustersDOWN.Count.ToString());
            //Echo(thrustSumUP.ToString());
            //Echo(thrustersUP.Count.ToString());

            if (Status == "Failed")
            {
                if (RCFailed == true)
                {
                    Echo(RCFailedMSG); return;
                }
                if (CCFailed == true)
                {
                    Echo(CCFailedMSG); return;
                }
                if (GyroFailed == true)
                {
                    Echo(GyroFailedMSG); return;
                }
                if (LAFailed == true)
                {
                    Echo(LAFailedMSG); return;
                }
                if (LGFailed == true)
                {
                    Echo(LGFailedMSG); return;
                }
                if (RConFailed == true)
                {
                    Echo(RConFailedMSG); return;
                }
                if (CCTsFailed == true)
                {
                    Echo(CCTsFailedMSG); return;
                }
                Status = "Failed";
                return;
            }

            if (arg.Contains("Target"))
            {
                TargetAltitudeSetter = keyValuePairs["Target"];
                TargetAltitude       = int.Parse(TargetAltitudeSetter);
                NotReady();
            }
            if (!Init)
            {
                Status = "Initalizing..."; NotReady();
            }
            if (arg == "Reset")
            {
                Status = "Not Ready"; NotReady();
            }
            if (arg == "Ready")
            {
                Status = "Ready"; Ready();
            }
            if (arg == "Launch")
            {
                Status = "Launching"; Launch();
            }
            if (arg == "Launched")
            {
                Status = "Launched"; Climb();
            }
            if (arg == "Seperate")
            {
                Status = "Seperation"; Seperation();
            }
            if (arg == "Return")
            {
                Status = "Return"; Return();
            }
            if (arg == "Approach")
            {
                Status = "Approaching"; Approach();
            }
            if (arg == "Land")
            {
                Status = "Landing"; Land();
            }
            if (arg == "Landed")
            {
                Status = "Landed";
            }

            if (Status == "Launching")
            {
                Launch();
            }
            if (Status == "Launched")
            {
                Climb();
            }
            if (Status == "Seperation")
            {
                Seperation();
            }
            if (Status == "Return")
            {
                Return();
            }
            if (Status == "Approaching")
            {
                Approach();
            }
            if (Status == "Landing")
            {
                Land();
            }
            if (Status == "Landed")
            {
                Status = "Landed";
            }
        }