コード例 #1
0
            /// <summary>
            /// Gets actions for blocks implementing IMyShipConnector.
            /// </summary>
            public static void GetConnectorActions(IMyTerminalBlock tBlock, List <IScrollableAction> actions)
            {
                IMyShipConnector connector = (IMyShipConnector)tBlock;

                actions.Add(new BlockAction(
                                () =>
                {
                    string status = "";

                    if (connector.Status == ConnectorStatus.Connected)
                    {
                        status = "Locked";
                    }
                    else if (connector.Status == ConnectorStatus.Connectable)
                    {
                        status = "Ready";
                    }
                    else if (connector.Status == ConnectorStatus.Unconnected)
                    {
                        status = "Unlocked";
                    }

                    return($"Lock/Unlock ({status})");
                },
                                () => connector.ToggleConnect()));
            }
コード例 #2
0
ファイル: FlyToGrid.cs プロジェクト: zrisher/ARMS
        /// <summary>
        /// Determines if the connector, landing gear, or merge block is locked. False if m_navBlock is none of those.
        /// </summary>
        private bool IsLocked()
        {
            if (m_landingState == LandingState.None)
            {
                return(false);
            }

            if (m_beforeMerge)
            {
                return(true);
            }

            IMyLandingGear asGear = m_navBlock.Block as IMyLandingGear;

            if (asGear != null)
            {
                return(asGear.IsLocked);
            }

            IMyShipConnector asConn = m_navBlock.Block as IMyShipConnector;

            if (asConn != null)
            {
                //Log.DebugLog("locked: " + asConn.IsLocked + ", connected: " + asConn.IsConnected + ", other: " + asConn.OtherConnector, "IsLocked()");
                return(asConn.Status == Ingame.MyShipConnectorStatus.Connected);
            }

            return(false);
        }
コード例 #3
0
        public void UpdateCallPanels()
        {
            if (craneConnector == null || cranePiston == null || craneRotor == null)
            {
                return;
            }

            for (int key = 0; key < callPanels.Count; key++)
            {
                string                 areaPrefix    = callPanels[key].CustomName.Substring(0, callPanels[key].CustomName.Length - callPanelName.Length);
                IMyShipConnector       areaConnector = GridTerminalSystem.GetBlockWithName(areaPrefix + "Connector") as IMyShipConnector;
                IMyTextSurfaceProvider panelScreens  = (IMyTextSurfaceProvider)callPanels[key];
                IMyTextSurface         callScreen    = panelScreens.GetSurface(0);

                if (areaConnector != null)
                {
                    if (callOverride == null && areaConnector.Status == MyShipConnectorStatus.Connected && areaConnector.OtherConnector == craneConnector)
                    {
                        callScreen.FontColor = Color.Green;
                    }
                    else
                    {
                        callScreen.FontColor = callOverride != null ? Color.Yellow : Color.White;
                    }
                }
                else
                {
                    callScreen.FontColor = Color.Red;
                }
            }

            UpdateStatusPanels();
        }
コード例 #4
0
        private bool CollectParts(IMyTerminalBlock block)
        {
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }

            if (block.CustomName == null)
            {
                block.CustomName = block.Name;
            }
            if (!block.CustomName.StartsWith($"({tag})"))
            {
                block.CustomName = $"({tag}) {block.CustomName}";
            }

            if (block is IMyShipConnector)
            {
                connector = (IMyShipConnector)block;
            }
            if (block is IMyRadioAntenna)
            {
                antenna = (IMyRadioAntenna)block;
            }
            if (block is IMyProgrammableBlock && block.CustomName == $"({tag}) {dockingManagerName}")
            {
                dockingManager = (IMyProgrammableBlock)block;
            }
            if (block is IMyProgrammableBlock && block.CustomName == $"({tag}) {autopilotName}")
            {
                autopilotManager = (IMyProgrammableBlock)block;
            }

            return(false);
        }
コード例 #5
0
            /// <summary>
            /// Calculates position and approach vector to dock on specific ship connector.
            /// </summary>
            /// <param name="connector">Connector to use.</param>
            /// <param name="pos">Connector position.</param>
            /// <param name="approach">Approach direction.</param>
            public static void CalculateApproach(IMyShipConnector connector, out Vector3D pos, out Vector3D approach)
            {
                MatrixD wm = connector.WorldMatrix;

                pos      = wm.Translation;
                approach = -wm.GetDirectionVector(Base6Directions.Direction.Forward);
            }
コード例 #6
0
            public void ProcessDockingRequest()
            {
                Drone.LogToLcd($"\nLogging: {DateTime.Now}");

                MyIGCMessage message = this.Drone.NetworkService.GetBroadcastListenerForChannel(DockingRequestChannel).AcceptMessage();

                if (message.Data == null)
                {
                    Drone.LogToLcd($"\nNo Message");
                }

                IMyShipConnector dockingPort = Drone.Grid().GetBlockWithName("Docking Port 1") as IMyShipConnector;

                if (dockingPort == null)
                {
                    Drone.LogToLcd("\nDocking Port 1 not found.");
                }
                else
                {
                    Vector3D        approachPoint = Vector3D.Add(dockingPort.GetPosition(), Vector3D.Multiply(dockingPort.WorldMatrix.Forward, 50));
                    List <Vector3D> dockingPath   = new List <Vector3D> {
                        approachPoint, dockingPort.GetPosition()
                    };
                    Drone.LogToLcd($"Sending message: {dockingPort.WorldMatrix.Forward},{dockingPath[0].ToString()},{dockingPath[1].ToString()}");
                    this.Drone.NetworkService.BroadcastMessage(
                        DockingRequestChannel,
                        $"{dockingPort.WorldMatrix.Forward},{dockingPath[0].ToString()},{dockingPath[1].ToString()}"
                        );
                }
            }
コード例 #7
0
        public Program()
        {
            base_prgblk  = GridTerminalSystem.GetBlockWithName(base_prgblk_name) as IMyProgrammableBlock;
            drill_drills = GridTerminalSystem.GetBlockGroupWithName(drill_drills_name);
            drill_rotor  = GridTerminalSystem.GetBlockGroupWithName(drill_rotor_name);
            drill_landing_gears_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_pistons_name);
            drill_landing_gears         = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_name);
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            text_panel_status = GridTerminalSystem.GetBlockWithName(text_panel_status_name) as IMyTextPanel;
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            drill_connector   = GridTerminalSystem.GetBlockWithName(drill_connector_name) as IMyShipConnector;

            //read stored config
            if (Storage.Length != 0)
            {
                string[] stored_config = Storage.Split('\n');
                {
                    read_stored_settings(stored_config);
                }
            }

            if (drill_status == "")
            {
                drill_status = "stopped";
                write_settings();
            }

            drill_connector_status  = drill_connector.Status.ToString();
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            verify_availability();
            write_settings();
        }
コード例 #8
0
 public void AddPart(IMyTerminalBlock part)
 {
     if (part is IMyShipConnector)
     {
         connector = (IMyShipConnector)part;
     }
     if (part is IMyPistonBase)
     {
         extender = (IMyPistonBase)part;
     }
     if (part is IMyMotorAdvancedStator)
     {
         rotor = (IMyMotorAdvancedStator)part;
     }
     if (part is IMyAirtightHangarDoor)
     {
         gates.Add((IMyAirtightHangarDoor)part);
     }
     if (part is IMyTextPanel)
     {
         display = (IMyTextPanel)part;
     }
     if (part is IMyInteriorLight)
     {
         IMyInteriorLight light = (IMyInteriorLight)part;
         lights.Add(light);
         light.Intensity = 2f;
         light.Radius    = 12f;
     }
 }
コード例 #9
0
        void ExternalExport(IMyShipConnector connector, List <IMyTerminalBlock> exportFrom)
        {
            if (connector.Status != MyShipConnectorStatus.Connected)
            {
                return;
            }

            var otherInv = connector.OtherConnector.GetInventory(0);

            if (otherInv == null)
            {
                return;
            }

            foreach (var block in exportFrom)
            {
                var inv = block.GetInventory(0);
                if (inv == null)
                {
                    continue;
                }
                for (int i = inv.ItemCount - 1; i >= 0; i--)
                {
                    if (!otherInv.TransferItemFrom(inv, i))
                    {
                        break;
                    }
                }
            }
        }
コード例 #10
0
        bool CollectAllPartsLandpedo(IMyTerminalBlock block)
        {
            if (block == Me)
            {
                return(false);
            }
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }
            if (block is IMyProgrammableBlock)
            {
                return(false);
            }
            if (block is IMyShipMergeBlock)
            {
                Base = (IMyShipMergeBlock)block;
            }
            if (block is IMyProjector)
            {
                Projector = (IMyProjector)block;
            }
            if (block is IMyShipConnector)
            {
                Connector = (IMyShipConnector)block;
            }

            PartsOfInterest.Add(block);

            return(false);
        }
コード例 #11
0
        private void ManageDock(IMyShipConnector dock)
        {
            if (dock == null)
            {
                return;
            }

            Echo($"Docking {dock.CustomName}");

            IMyShipConnector otherConnector = dock.OtherConnector;

            if (otherConnector == null || dock.Status == MyShipConnectorStatus.Unconnected)
            {
                Echo("not connected");
                return;
            }
            else if (dock.Status == MyShipConnectorStatus.Connectable)
            {
                Echo($"to connector {otherConnector.CustomName}");
                UnDock(otherConnector);
            }
            else if (dock.Status == MyShipConnectorStatus.Connected)
            {
                Echo($"to connector {otherConnector.CustomName}");
                Dock(otherConnector);
            }
        }
コード例 #12
0
        public static bool CheckHummingbirdComponents(IMyShipMergeBlock baseplate, ref IMyShipConnector connector, ref IMyMotorStator turretRotor, ref List <IMyTerminalBlock> PartsScratchpad, ref string status)
        {
            var releaseOther = GridTerminalHelper.OtherMergeBlock(baseplate);

            if (releaseOther == null || !releaseOther.IsFunctional || !releaseOther.Enabled)
            {
                return(false);
            }

            PartsScratchpad.Clear();

            var gotParts = GridTerminalHelper.Base64BytePosToBlockList(releaseOther.CustomData, releaseOther, ref PartsScratchpad);

            if (!gotParts)
            {
                return(false);
            }

            foreach (var block in PartsScratchpad)
            {
                if (!block.IsFunctional)
                {
                    return(false);
                }
                if (block is IMyMotorStator)
                {
                    turretRotor = (IMyMotorStator)block;
                }
                if (block is IMyShipConnector)
                {
                    connector = (IMyShipConnector)block;
                }
            }
            return(true);
        }
コード例 #13
0
            // int CowntDown=5;
            // bool StartCountDown =false;

            public Torpedo(string GroupName)
            {
                Name = GroupName;
                List <IMyTerminalBlock> templist = new List <IMyTerminalBlock>();

                templist.Clear();

                gts.GetBlocksOfType <IMyShipConnector>(templist, (b) => b.CustomName.Contains(GroupName));
                merge = templist[0] as IMyShipConnector;
                if (merge.Status == MyShipConnectorStatus.Connectable)
                {
                    merge.ToggleConnect();
                }
                templist.Clear();

                gts.GetBlocksOfType <IMyCockpit>(templist, (b) => b.CustomName.Contains(GroupName));
                remcon    = templist[0] as IMyCockpit;
                batteries = new List <IMyBatteryBlock>();
                gts.GetBlocksOfType <IMyBatteryBlock>(batteries, (b) => b.CustomName.Contains(GroupName));
                foreach (IMyBatteryBlock battery in batteries)
                {
                    battery.Enabled = true;
                }
                thrusters = new List <IMyThrust>();
                gts.GetBlocksOfType <IMyThrust>(thrusters, (b) => b.CustomName.Contains(GroupName));
                gyros = new List <IMyGyro>();
                gts.GetBlocksOfType <IMyGyro>(gyros, (b) => b.CustomName.Contains(GroupName));
                warheads = new List <IMyWarhead>();
                gts.GetBlocksOfType <IMyWarhead>(warheads, (b) => b.CustomName.Contains(GroupName));
                decoys = new List <IMyDecoy>();
                gts.GetBlocksOfType <IMyDecoy>(decoys, (b) => b.CustomName.Contains(GroupName));
                status = 1;
            }
コード例 #14
0
    public void Init()
    {
        top_connector    = (IMyShipConnector)GridTerminalSystem.GetBlockWithName(TOP_CONNECTOR_NAME);
        middle_connector = (IMyShipConnector)GridTerminalSystem.GetBlockWithName(MIDDLE_CONNECTOR_NAME);
        bottom_connector = (IMyShipConnector)GridTerminalSystem.GetBlockWithName(BOTTOM_CONNECTOR_NAME);

        connectors = new Dictionary <string, IMyShipConnector> {
            { TOP_CONNECTOR_NAME, top_connector },
            { MIDDLE_CONNECTOR_NAME, middle_connector },
            { BOTTOM_CONNECTOR_NAME, bottom_connector }
        };

        top_piston    = (IMyPistonBase)GridTerminalSystem.GetBlockWithName(TOP_PISTON);
        bottom_piston = (IMyPistonBase)GridTerminalSystem.GetBlockWithName(BOTTOM_PISTON);

        programmable_block = (IMyProgrammableBlock)GridTerminalSystem.GetBlockWithName(PROGRAMMABLE_BLOCK_NAME);

        top_piston.MaxLimit    = PISTON_MAX_DISTANCE;
        top_piston.MinLimit    = PISTON_MIN_DISTANCE;
        bottom_piston.MaxLimit = PISTON_MAX_DISTANCE;
        bottom_piston.MinLimit = PISTON_MIN_DISTANCE;

        SetupDisplay();
        GetStatus();
        PrintStatus();
    }
コード例 #15
0
        void AddConnector(string nameOfConnector, string nameOfGroup) //adds a connector to the given list, and adds a new list if it doesn't exist.
        {
            if (!connectorGroupDict.ContainsKey(nameOfGroup))
            {
                connectorGroupDict.Add(nameOfGroup, new List <Connector>());
                Echo("New connector group '" + nameOfGroup + "' added.");
            }
            IMyShipConnector newShipConnector = GridTerminalSystem.GetBlockWithName(nameOfConnector) as IMyShipConnector;
            Connector        newConnector     = new Connector(newShipConnector);

            if (newConnector != null && newShipConnector != null)
            {
                Boolean duplicate = false;
                foreach (Connector connector in connectorGroupDict[nameOfGroup])
                {
                    if (connector.instance.CustomName == newConnector.instance.CustomName)
                    {
                        duplicate = true;
                        Echo(nameOfConnector + " is a duplicate");
                        break;
                    }
                }
                if (!duplicate)
                {
                    newConnector.instance.PullStrength = float.PositiveInfinity;
                    connectorGroupDict[nameOfGroup].Add(newConnector);
                    Echo(nameOfConnector + " was added to: " + nameOfGroup);
                }
            }
            else
            {
                Echo("No connector named '" + nameOfConnector + "' found.");
            }
        }
コード例 #16
0
        void AddConnector(string nameOfConnector)
        { //adds a connector to the default group
            IMyShipConnector newShipConnector = GridTerminalSystem.GetBlockWithName(nameOfConnector) as IMyShipConnector;
            Connector        newConnector     = new Connector(newShipConnector);

            if (newConnector != null && newShipConnector != null)
            {
                Boolean duplicate = false;
                foreach (Connector connector in connectorGroupDict["default"])
                {
                    if (connector.instance.CustomName == newConnector.instance.CustomName)
                    {
                        duplicate = true;
                        Echo(nameOfConnector + " is a duplicate");
                        break;
                    }
                }

                if (!duplicate)
                {
                    newConnector.instance.PullStrength = float.PositiveInfinity;
                    connectorGroupDict["default"].Add(newConnector);
                    Echo(nameOfConnector + " was added");
                }
            }
            else
            {
                Echo("No connector named '" + nameOfConnector + "' found.");
            }
        }
コード例 #17
0
        public Program()
        {
            Load();

            // Grinder Arm Blocks
            _grindArmRotor            = GetBlockOrThrow <IMyMotorStator>("Grinder Rotor");
            _grindArmHinge            = GetBlockOrThrow <IMyMotorStator>("Grinder Hinge");
            _grindArmPistonVert       = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Vert");
            _grindArmPistonHoriz      = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Horiz");
            _grindArmPistonPark       = GetBlockOrThrow <IMyPistonBase>("Grinder Park Piston");
            _grindArmLandingGearGroup = GetGroupOrThrow("Grinder Landing Gear");

            // Drill Blocks
            _drillPistonGroup       = GetGroupOrThrow("Drill Pistons");
            _drillGroup             = GetGroupOrThrow("Drills");
            _drillWelderGroup       = GetGroupOrThrow("Welders");
            _drillMergeBlock        = GetBlockOrThrow <IMyShipMergeBlock>("Drill Merge Block");
            _drillConnector         = GetBlockOrThrow <IMyShipConnector>("Drill Connector");
            _drillSupportMergeBlock = GetBlockOrThrow <IMyShipMergeBlock>("Support Merge Block");
            _drillProjector         = GetBlockOrThrow <IMyProjector>("Drill Projector");

            // LCD setup
            _lcd = GetBlockOrThrow <IMyTextPanel>("Drill Rig LCD");
            if (_lcd != null)
            {
                Echo("Found LCD");
                _lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                _lcd.FontSize    = 0.5f;
                _lcd.FontColor   = new Color(200, 200, 200); // less bright white is also less blurry
                _lcd.Alignment   = TextAlignment.LEFT;
                _lcd.WriteText("Drill Rig Debug Logs");      // Clear all text
            }
        }
コード例 #18
0
        private void Dock(IMyShipConnector otherConnector)
        {
            // Tanks
            List <IMyGasTank> listGasTanks = new List <IMyGasTank>();

            GridTerminalSystem.GetBlocksOfType(listGasTanks, t => t.IsSameConstructAs(otherConnector));
            listGasTanks.ForEach(t => t.SetValue("Stockpile", true));

            // Batteries
            List <IMyBatteryBlock> listBatteries = new List <IMyBatteryBlock>();

            GridTerminalSystem.GetBlocksOfType(listBatteries, b => b.IsSameConstructAs(otherConnector));
            listBatteries.ForEach(b => b.SetValue("ChargeMode", (long)ChargeMode.Recharge));

            //
            List <IMyTerminalBlock> powerUsers = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyThrust>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMyAirVent>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMyBeacon>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMySensorBlock>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMyOreDetector>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMyLaserAntenna>(powerUsers, p => p.IsSameConstructAs(otherConnector));
            GridTerminalSystem.GetBlocksOfType <IMySensorBlock>(powerUsers, p => p.IsSameConstructAs(otherConnector));

            foreach (IMyTerminalBlock tb in powerUsers)
            {
                tb.SetValue("OnOff", false);
                Echo($"Turn {tb.CustomName} Off");
            }
        }
コード例 #19
0
        public void Main(string argument, UpdateType updateSource)
        {
            List <IMyShipConnector> connectors = new List <IMyShipConnector>();

            GridTerminalSystem.GetBlocksOfType <IMyShipConnector>(connectors, b => b.IsSameConstructAs(Me));
            if (connectors.Count == 0 || connectors[0].Status != MyShipConnectorStatus.Connected)
            {
                throw new Exception("Ship needs a connector that is connected");
            }

            IMyShipConnector targetConnector = connectors[0].OtherConnector;

            List <IMyTerminalBlock> blocks       = new List <IMyTerminalBlock>();
            List <IMyTerminalBlock> sourceBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(blocks, b => b.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(sourceBlocks, b => !b.IsSameConstructAs(Me));

            MyInventories     = InventoryUtils.GetInventoriesFromBlocks(blocks);
            SourceInventories = InventoryUtils.GetInventoriesFromBlocks(sourceBlocks);

            if (argument.Equals("flush"))
            {
                FlushInventories();
            }
            else if (argument.Equals("import"))
            {
                ImportItemsIntoInventory();
            }
        }
コード例 #20
0
            public void PerformSelfDiagnostic()
            {
                IMyGridTerminalSystem GridTerminalSystem = MyInstance.GridTerminalSystem;

                if (CTRL != null && GridTerminalSystem.GetBlockWithId(this.CTRL.EntityId) == null)
                {
                    CTRL = null;
                }
                if (XROT != null && GridTerminalSystem.GetBlockWithId(this.XROT.EntityId) == null)
                {
                    XROT = null;
                }
                if (YROT != null && GridTerminalSystem.GetBlockWithId(this.YROT.EntityId) == null)
                {
                    YROT = null;
                }
                if (YROTA != null && GridTerminalSystem.GetBlockWithId(this.YROTA.EntityId) == null)
                {
                    YROTA = null;
                }
                if (RLDCon != null && GridTerminalSystem.GetBlockWithId(this.RLDCon.EntityId) == null)
                {
                    RLDCon = null;
                }
                if (BSDCon != null && GridTerminalSystem.GetBlockWithId(this.BSDCon.EntityId) == null)
                {
                    BSDCon = null;
                }
                if (Camera != null && GridTerminalSystem.GetBlockWithId(this.Camera.EntityId) == null)
                {
                    Camera = null;
                }
            }
コード例 #21
0
        public Program()
        {
            m_Cockpit = GridTerminalSystem.GetBlockWithName(CockpitName) as IMyCockpit;

            m_CockpitBatteryDamagePanel           = m_Cockpit.GetSurface(IntegrityBatteryDisplayIndex);
            m_CockpitBatteryDamagePanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
            GridTerminalSystem.GetBlocksOfType(m_Batteries, a => a is IMyBatteryBlock && a.IsSameConstructAs(m_Cockpit));

            m_CockpitCargoPanel           = m_Cockpit.GetSurface(CargoCheckDisplayIndex);
            m_CockpitCargoPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            m_Gyros = new List <IMyGyro>();
            GridTerminalSystem.GetBlocksOfType(m_Gyros, a => a.IsSameConstructAs(m_Cockpit));

            var allBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(allBlocks, a => a.IsSameConstructAs(m_Cockpit));
            foreach (var block in allBlocks)
            {
                m_AllBlocks.Add(new KeyValuePair <IMyTerminalBlock, IMySlimBlock>(block, block.CubeGrid.GetCubeBlock(block.Position)));
            }

            m_Connector = GridTerminalSystem.GetBlockWithName(ConnectorName) as IMyShipConnector;

            Runtime.UpdateFrequency = UpdateFrequency.Update10;
        }
コード例 #22
0
ファイル: ToolieProG.cs プロジェクト: Reitarou/SpaceEngineers
        public Program()
        {
            m_Cockpit = GridTerminalSystem.GetBlockWithName(CockpitName) as IMyCockpit;

            m_CockpitBatteryDamagePanel             = m_Cockpit.GetSurface(IntegrityBatteryDisplayIndex);
            m_CockpitBatteryDamagePanel.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            m_CockpitBatteryDamagePanel.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            GridTerminalSystem.GetBlocksOfType(m_Batteries, a => a is IMyBatteryBlock && a.IsSameConstructAs(m_Cockpit) && a.CustomName != BIOSBatteryName);
            m_BIOSBattery = GridTerminalSystem.GetBlockWithName(BIOSBatteryName) as IMyBatteryBlock;

            GridTerminalSystem.GetBlocksOfType(m_Cargos, a => a is IMyCargoContainer && a.IsSameConstructAs(m_Cockpit));

            m_CockpitCargoPanel             = m_Cockpit.GetSurface(CargoCheckDisplayIndex);
            m_CockpitCargoPanel.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            m_CockpitCargoPanel.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
            m_CockpitCargoPanel.FontSize    = 2.5f;

            m_Gyros = new List <IMyGyro>();
            GridTerminalSystem.GetBlocksOfType(m_Gyros, a => a.IsSameConstructAs(m_Cockpit));

            var allBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(allBlocks, a => a.IsSameConstructAs(m_Cockpit));
            foreach (var block in allBlocks)
            {
                m_AllBlocks.Add(new KeyValuePair <IMyTerminalBlock, IMySlimBlock>(block, block.CubeGrid.GetCubeBlock(block.Position)));
            }

            m_Connector = GridTerminalSystem.GetBlockWithName(ConnectorName) as IMyShipConnector;

            m_Hinge = GridTerminalSystem.GetBlockWithName(ToolieHingeName) as IMyMotorStator;

            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
コード例 #23
0
ファイル: Docking.cs プロジェクト: dumbdiscord/FlightControl
            public void Initialize(IMyShipConnector connector)
            {
                if (CanInitialize)
                {
                    ship.Communications.RegisterCustomMessageHandler("DOCKINGINFOREQUEST", (x, c) => {
                        using (var buf = new BinarySerializer(new byte[0]))
                        {
                            buf.WriteMatrixD(connector.WorldMatrix);
                            ship.Communications.SendCustomMessage("DOCKINGINFORESPONSE", buf.buffer, c);
                        }
                    });
                    ship.Communications.RegisterCustomMessageHandler("DOCKINGINFORESPONSE", (x, c) =>
                    {
                        using (var buf = new BinarySerializer(x))
                        {
                            if (TargetClient != null)
                            {
                                if (c == TargetClient)
                                {
                                    TargetMatrix = buf.ReadMatrixD();
                                }
                            }
                        }
                    });

                    Initialized = true;
                }
            }
コード例 #24
0
        IMyTerminalBlock getConnectedConnector(bool bMe = false)
        {
            getLocalConnectors();

            for (int i = 0; i < localDockConnectors.Count; i++)
            {
                IMyShipConnector sc = localDockConnectors[i] as IMyShipConnector;
                if (sc.Status == MyShipConnectorStatus.Connected)
                {
                    IMyShipConnector sco = sc.OtherConnector;
                    if (sco.CubeGrid == sc.CubeGrid)
                    {
                        continue;
                    }
                    else
                    {
                        if (!bMe)
                        {
                            return(sc.OtherConnector);
                        }
                        else
                        {
                            return(localDockConnectors[i]);
                        }
                    }
                }
            }
            return(null);
        }
コード例 #25
0
 public void AddPart(IMyTerminalBlock part)
 {
     if (part is IMyShipConnector)
     {
         Connector = (IMyShipConnector)part;
         ParseConfigs();
     }
     if (part is IMyDoor)
     {
         gates.Add((IMyDoor)part);
     }
     if (part is IMyTextPanel)
     {
         display = (IMyTextPanel)part;
     }
     if (part is IMyInteriorLight)
     {
         IMyInteriorLight light = (IMyInteriorLight)part;
         if (light.CustomName.Contains("<DI>"))
         {
             DirectionIndicator         = light;
             light.Color                = Color.Red;
             light.Intensity            = 0.5f;
             light.BlinkIntervalSeconds = 1;
             light.BlinkLength          = 0.1f;
         }
         else
         {
             lights.Add(light);
             light.Intensity = 2f;
             light.Radius    = 12f;
         }
     }
 }
コード例 #26
0
 public DockingAttempt(Drone drone, IMyShipConnector dockingPort, long dockWithGrid, string dockingRequestChannel)
 {
     Drone                 = drone;
     DockingPort           = dockingPort;
     DockWithGrid          = dockWithGrid;
     DockingRequestChannel = dockingRequestChannel;
     State                 = "Initial";
 }
コード例 #27
0
 void PrepareConnector(IMyShipConnector connector)
 {
     // bug fix connector too strong
     if (connector != null)
     {
         connector.PullStrength = 0;
     }
 }
コード例 #28
0
ファイル: Drone.cs プロジェクト: GeorgeLautenschlager/Drones
            private void InitializeBlocks()
            {
                Grid().GetBlocksOfType <IMyGyro>(Gyros, block => block.IsSameConstructAs(Program.Me));
                if (Gyros == null || Gyros.Count == 0)
                {
                    throw new Exception("Drone has no Gyros!");
                }

                Grid().GetBlocksOfType <IMyThrust>(Thrusters, block => block.IsSameConstructAs(Program.Me));
                if (Thrusters == null || Thrusters.Count == 0)
                {
                    throw new Exception("Drone has no Thrusters!");
                }

                Grid().GetBlocksOfType <IMyBatteryBlock>(Batteries, block => block.IsSameConstructAs(Program.Me));
                if (Batteries == null || Batteries.Count == 0)
                {
                    throw new Exception("Drone has no Batteries!");
                }

                Grid().GetBlocksOfType <IMyGasTank>(FuelTanks, block => block.IsSameConstructAs(Program.Me));
                if (FuelTanks == null || FuelTanks.Count == 0)
                {
                    throw new Exception("Drone has no Fuel Tanks!");
                }

                List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

                //TODO: make sure you don't grab a connector on the other grid
                Grid().GetBlocksOfType <IMyShipConnector>(blocks, block => block.IsSameConstructAs(Program.Me));
                if (blocks == null || blocks.Count == 0)
                {
                    throw new Exception("No docking connector found!");
                }
                DockingConnector = blocks.First() as IMyShipConnector;

                //TODO: make sure you don't grab a connector on the other grid
                Grid().GetBlocksOfType <IMyCameraBlock>(blocks, block => block.IsSameConstructAs(Program.Me));
                if (blocks == null || blocks.Count == 0)
                {
                    throw new Exception("No camera found!");
                }
                Eye = blocks.First() as IMyCameraBlock;

                InventoryBlocks = new List <IMyTerminalBlock>();
                Grid().GetBlocksOfType <IMyTerminalBlock>(InventoryBlocks, block => block.InventoryCount > 0 && block.IsSameConstructAs(Program.Me));

                if (InventoryBlocks != null && InventoryBlocks.Count > 1)
                {
                    foreach (IMyTerminalBlock block in InventoryBlocks)
                    {
                        for (int i = 0; i < block.InventoryCount; i++)
                        {
                            MaxCargo += block.GetInventory(i).MaxVolume;
                        }
                    }
                }
            }
コード例 #29
0
 public ShipDockingStation(IMyShipConnector shipConnector)
 {
     if (shipConnector == null)
     {
         throw new ArgumentNullException(nameof(shipConnector));
     }
     this.shipConnector      = shipConnector;
     lastShipConnectorStatus = ShipConnectionStatus;
 }
コード例 #30
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            _debug = new Debug(this);

            //_ship_dock = GridTerminalSystem.GetBlockWithName("DRN-M: Connector") as IMyShipConnector;
            _ground_dock = GridTerminalSystem.GetBlockWithName("STN: Connector") as IMyShipConnector;
            //_remote_control = GridTerminalSystem.GetBlockWithName("DRN-M: Remote Control") as IMyRemoteControl;
        }
コード例 #31
0
        private void init()
        {
            #region initialization

            oldPBName = Me.CustomName;

            unique_id = (new Random()).Next();

            all_blocks_found = true;

            autopilot_en = true;

            location_name = "UNKNOWN";

            // For spinner
            counter = 0;

            string parse = Me.CustomName.Replace(BLOCK_PREFIX, "");
            int id1 = Me.CustomName.IndexOf('[');
            int id2 = Me.CustomName.IndexOf(']');
            if (id1 >= 0 && id2 >= 0)
            {
                parse = parse.Substring(id1 + 1, id2 - id1 - 1);
            }
            else
            {
                parse = "";
            }

            BaconArgs Args = BaconArgs.parse(parse);

            IS_BASE = (Args.getFlag('b') > 0);

            DOCK_LEFT = (Args.getFlag('l') > 0);

            IS_PLANET = (Args.getFlag('p') > 0);

            if (IS_PLANET) IS_BASE = true;

            List<string> nameArg = Args.getOption("name");

            if (nameArg.Count > 0 && nameArg[0] != null)
            {
                location_name = nameArg[0];
            }

            // Set all known blocks to null or clear lists
            lcdPanel = null;
            messageReceiver = null;
            WANProgram = null;
            connector = null;
            remoteControl = null;
            door = null;
            timer = null;
            landLight = null;
            mainGear = 0;

            gyros.Clear();
            destinations.Clear();
            gears.Clear();

            // Get all blocks
            List<IMyTerminalBlock> blks = new List<IMyTerminalBlock>();
            GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix);
            num_blocks_found = blks.Count;

            // Assign blocks to variables as appropriate
            foreach (var blk in blks)
            {
                // LCD panel for printing
                if (blk is IMyTextPanel)
                {
                    lcdPanel = blk as IMyTextPanel;
                    lcdPanel.ShowPublicTextOnScreen();
                    lcdPanel.SetValueFloat("FontSize", 1.2f);
                }
                // Wico Area Network programmable block
                else if (blk is IMyProgrammableBlock && !blk.Equals(Me))
                {
                    WANProgram = blk as IMyProgrammableBlock;
                }
                // Autopilot
                else if (!IS_BASE && blk is IMyRemoteControl)
                {
                    remoteControl = blk as IMyRemoteControl;
                }
                /* Ship or station connector for docking
                 * Used to connect to station and for orientation info
                 */
                else if (!IS_PLANET && blk is IMyShipConnector)
                {
                    connector = blk as IMyShipConnector;
                }
                /* Door used for docking; used for orientation information
                 * since it's more obvious which way a door faces than a connector
                 */
                else if (!IS_PLANET && blk is IMyDoor)
                {
                    door = blk as IMyDoor;
                }
                // Gyros for ship orientation
                else if (!IS_BASE && blk is IMyGyro)
                {
                    IMyGyro g = blk as IMyGyro;
                    gyros.Add(g);

                }
                // Timer block so that we can orient ship properly - requires multiple calls/sec
                else if (!IS_BASE && blk is IMyTimerBlock)
                {
                    timer = blk as IMyTimerBlock;
                    timer.SetValueFloat("TriggerDelay", 1.0f);
                }
                // Light (interior or spotlight) determines where we will land
                else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight)
                {
                    landLight = blk as IMyInteriorLight;
                }
                // Landing gear....
                else if (!IS_BASE && blk is IMyLandingGear)
                {
                    IMyLandingGear gear = blk as IMyLandingGear;
                    gears.Add(gear);
                    if (gear.CustomName.ToLower().Contains("main"))
                    {
                        mainGear = gears.Count - 1;
                    }
                }
            }

            // Make sure all gyros reset
            resetGyros();

            // Clear block list
            blks.Clear();

            // Get text panel blocks used by Wico Area Network for communication
            GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(blks, hasWANRPrefix);

            if (blks.Count == 0)
            {
                Echo("Error: Can't find message received text panel for Wico Area Network");
                all_blocks_found = false;
            }
            else
            {
                messageReceiver = blks[0] as IMyTextPanel;
                messageReceiver.WritePublicTitle("");
                messageReceiver.WritePrivateTitle("NAV");
            }

            if (WANProgram == null)
            {
                Echo("Error: Can't find programming block for Wico Area Network");
                all_blocks_found = false;
            }

            if (lcdPanel == null)
            {
                Echo("Error: Expect 1 LCD");
                all_blocks_found = false;
            }

            if (!IS_PLANET && connector == null)
            {
                Echo("Error: Can't find any connectors to use for docking");
                all_blocks_found = false;
            }

            if (!IS_BASE && remoteControl == null)
            {
                Echo("Error: Can't find any remote control blocks");
                all_blocks_found = false;
            }

            if (!IS_PLANET && door == null)
            {
                Echo("Error: Can't find door");
                all_blocks_found = false;
            }

            if (!IS_BASE && gyros.Count == 0)
            {
                Echo("Error: No gyros detected");
                all_blocks_found = false;
            }

            if (!IS_BASE && timer == null)
            {
                Echo("Error: No timer found");
                all_blocks_found = false;
            }
            if (IS_PLANET && landLight == null)
            {
                Echo("Error: No light for landing ship destination found");
                all_blocks_found = false;
            }
            if (!IS_BASE && gears.Count == 0)
            {
                Echo("Warning: no landing gear found.  You will not be able to land on planets");
            }

            // Init communicator state machine
            comm = communicate().GetEnumerator();

            // Clear autopilot state machine
            fly = null;
            #endregion
        }