Пример #1
0
            public Lights(IMyGridTerminalSystem gts)
            {
                lightGroups = new LightGroup[lightGroupCount];

                for (int i = 0; i < lightGroupCount; i++)
                {
                    List <IMyInteriorLight> lightGroup = new List <IMyInteriorLight>();

                    for (int j = 0; j < lightGroupSize; j++)
                    {
                        IMyInteriorLight light = gts.GetBlockWithName("Licht" + i + "." + j) as IMyInteriorLight;

                        if (light == null)
                        {
                            string error = "Licht " + i + "." + j + " nicht gefunden.";
                        }
                        else
                        {
                            lightGroup.Add(light);
                            light.Enabled = lightState;
                        }
                    }

                    lightGroups[i] = new LightGroup(lightGroup.ToArray());
                }
            }
 public Program()
 {
     // Retrieve the blocks we're going to use.
     blocks      = new ExpectedBlocks(GridTerminalSystem);
     _panelLight = blocks.GetBlock <IMyInteriorLight>("Interior Light");
     _textPanel  = blocks.GetBlock <IMyTextPanel>("LCD Panel");
 }
 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;
         }
     }
 }
Пример #4
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;
     }
 }
Пример #5
0
        public Program()
        {
            #region Constructor Help

            /* The constructor, called only once every session and
             * // always before any other method is called. Use it to
             * // initialize your script.
             * //
             * // The constructor is optional and can be removed if not
             * // needed.
             * //
             * // It's recommended to set RuntimeInfo.UpdateFrequency
             * // here, which will allow your script to run itself without a
             * timer block.*/
            #endregion

            _timer      = GridTerminalSystem.GetBlockWithName("MRF_Timer") as IMyTimerBlock;
            _lOn        = GridTerminalSystem.GetBlockWithName("MRF_lOn") as IMyInteriorLight;
            _lOff       = GridTerminalSystem.GetBlockWithName("MRF_lOff") as IMyInteriorLight;
            _rotor      = GridTerminalSystem.GetBlockWithName("MRF_Rotor") as IMyMotorStator;
            _debugPanel = GridTerminalSystem.GetBlockWithName("MRF_Debug") as IMyTextPanel;

            SetDrills();
            _debugPanel.WriteText(string.Join(",", _drills.Select(d => d.Name)));
        }
Пример #6
0
 public static void setColor(List <IMyInteriorLight> lights, Color color)
 {
     for (int i = 0; i < lights.Count; i++)
     {
         IMyInteriorLight light = lights[i];
         light.SetValue <Color>("Color", color);
     }
 }
Пример #7
0
 void GetParts()
 {
     IndicatorLight = null;
     Context.Terminal.GetBlocksOfType <IMyTerminalBlock>(null, CollectParts);
     if (IndicatorLight != null)
     {
         IndicatorLight.Radius = 10;
     }
 }
 public void Clear()
 {
     Connector          = null;
     DirectionIndicator = null;
     gates.Clear();
     lights.Clear();
     display      = null;
     OwnerID      = 0;
     hangarStatus = HangarStatus.None;
 }
        bool CollectParts(IMyTerminalBlock block)
        {
            if (!Context.Reference.IsSameConstructAs(block))
            {
                return(false);
            }

            if (block is IMyShipController)
            {
                controller = (IMyShipController)block;
                return(false);
            }

            var tagindex = block.CustomName.IndexOf(TagPrefix);

            if (tagindex == -1)
            {
                return(false);
            }

            var indexTagEnd = block.CustomName.IndexOf(']', tagindex);

            if (indexTagEnd == -1)
            {
                return(false);
            }

            var numString = block.CustomName.Substring(tagindex + TagPrefix.Length, indexTagEnd - tagindex - TagPrefix.Length);

            if (numString == string.Empty)
            {
                // No number - master systems
                if (block is IMyInteriorLight && block.CustomName.Contains("<DI>"))
                {
                    DirectionIndicator = (IMyInteriorLight)block;
                }
                return(false);
            }

            int hangarIndex;

            if (!int.TryParse(numString, out hangarIndex))
            {
                return(false);
            }
            if (Hangars[hangarIndex] == null)
            {
                Hangars[hangarIndex] = new Hangar(hangarIndex, this);
            }
            Hangars[hangarIndex].AddPart(block);

            return(false);
        }
Пример #10
0
        public void Main(string argument, UpdateType updateSource)
        {
            IMyTerminalBlock block = GridTerminalSystem.GetBlockWithName(nameLight);

            if (block is IMyInteriorLight)
            {
                blockLight = (IMyInteriorLight)block;
            }

            blockLight.Enabled = !blockLight.Enabled;
            Echo(updateSource.ToString());
        }
            public LowHydrogenWarningSystem(List <IMyGasTank> h2TankBlocks, IMyInteriorLight warningLightBlock, IMyTextPanel warningLCDBlock, IMySoundBlock warningSoundBlock)
            {
                gasTanksManager = new GasTanksManager(h2TankBlocks);

                AlertLight warningLight = new AlertLight(warningLightBlock);
                AlertLight warningLCD   = new AlertText(warningLCDBlock, "Low H2!");
                AlertLight warningSound = new AlertSound(warningSoundBlock);

                listAlertObjects = new List <AlertLight> {
                    warningLight, warningLCD, warningSound
                };
            }
Пример #12
0
        private void SetIndicator(IMyInteriorLight light, OnOff setting)
        {
            switch (setting)
            {
            case OnOff.On:
                light.Enabled = true;
                break;

            case OnOff.Off:
                light.Enabled = false;
                break;
            }
        }
 public void ChangeSetColor(IMyInteriorLight light, Color color, float radius, float intensity, int numLights, string mode)
 {
     light.Color      = color;
     light.CustomData = color.ToString() + ";" + mode;
     if (radius != 0)
     {
         light.Radius = radius;
     }
     if (intensity != 0)
     {
         light.Intensity = intensity;
     }
 }
Пример #14
0
        bool CollectParts(IMyTerminalBlock block)
        {
            if (Context.Reference.CubeGrid.EntityId != block.CubeGrid.EntityId)
            {
                return(false);
            }

            if (block is IMyInteriorLight)
            {
                IndicatorLight = (IMyInteriorLight)block;
            }

            return(false);
        }
        public void ChangeRandomColor(IMyInteriorLight light, Random rand, int[,] colors, float radius, float intensity, int numLights, string mode)
        {
            int colorIndex = rand.Next(colors.GetLength(0));

            light.Color      = new Color(colors[colorIndex, 0], colors[colorIndex, 1], colors[colorIndex, 2]);
            light.CustomData = light.Color.ToString() + ";" + mode + ";" + colorIndex;
            if (radius != 0)
            {
                light.Radius = radius;
            }
            if (intensity != 0)
            {
                light.Intensity = intensity;
            }
        }
Пример #16
0
        bool FuncTest(IMyInteriorLight block)
        {
            //Interior Light
            //Interface name: IMyInteriorLight
            //Parent: IMyLightingBlock
            //Parent: IMyFunctionalBlock
            //Fields:
            float Radius               = block.Radius;
            float Intensity            = block.Intensity;
            float BlinkIntervalSeconds = block.BlinkIntervalSeconds;
            float BlinkLenght          = block.BlinkLenght;
            float BlinkOffset          = block.BlinkOffset;

            return(true);
        }
Пример #17
0
        public Program()
        {
            List <IMyGasTank> listH2Tanks = new List <IMyGasTank> {
                (IMyGasTank)GridTerminalSystem.GetBlockWithName(nameHydrogenTank)
            };
            IMyInteriorLight warningLight = (IMyInteriorLight)GridTerminalSystem.GetBlockWithName(nameWarningLight);
            IMyTextPanel     warningPanel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(nameLCDPanel);

            lowH2WarningSystem = new LowHydrogenWarningSystem(listH2Tanks, warningLight, warningPanel, null)
            {
                warningLevel = h2WarningLevel
            };
            antenna = (IMyRadioAntenna)GridTerminalSystem.GetBlockWithName(nameAntenna);

            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Пример #18
0
        /// <summary>
        /// Demo: sets up a simple light chase sequence.
        /// </summary>
        private void Setup()
        {
            _light1 = GridTerminalSystem.GetBlockWithName("Interior Light") as IMyInteriorLight;
            _light2 = GridTerminalSystem.GetBlockWithName("Interior Light 2") as IMyInteriorLight;
            _light3 = GridTerminalSystem.GetBlockWithName("Interior Light 3") as IMyInteriorLight;

            _fsm.AddState("CHASER1", () => SetLightColor(_light1, Color.Red), () => SetLightColor(_light1, Color.White));
            _fsm.AddState("CHASER2", () => SetLightColor(_light2, Color.Red), () => SetLightColor(_light2, Color.White));
            _fsm.AddState("CHASER3", () => SetLightColor(_light3, Color.Red), () => SetLightColor(_light3, Color.White));

            _fsm.AddStateTransition("CHASER1", "CHASER2", () => true);
            _fsm.AddStateTransition("CHASER2", "CHASER3", () => true);
            _fsm.AddStateTransition("CHASER3", "CHASER1", () => true);

            _fsm.SetCurrentStateName("CHASER1");
        }
Пример #19
0
 public Program()
 {
     // The constructor, called only once every session and
     // always before any other method is called. Use it to
     // initialize your script.
     //
     // The constructor is optional and can be removed if not
     // needed.
     //
     // It's recommended to set RuntimeInfo.UpdateFrequency
     // here, which will allow your script to run itself without a
     // timer block.
     _mtsGyro  = GridTerminalSystem.GetBlockWithName("mtsGyro") as IMyGyro;
     _mtsError = GridTerminalSystem.GetBlockWithName("mtsError") as IMyInteriorLight;
     _mtsGo    = GridTerminalSystem.GetBlockWithName("mtsGo") as IMyInteriorLight;
 }
Пример #20
0
    public Program()
    {
        Runtime.UpdateFrequency = UpdateFrequency.Update10;
        // Retrieve the blocks we're going to use.
        _timer      = GridTerminalSystem.GetBlockWithName("Timer Block") as IMyTimerBlock;
        _panelLight = GridTerminalSystem.GetBlockWithName("Interior Light") as IMyInteriorLight;
        _textPanel  = GridTerminalSystem.GetBlockWithName("LCD Panel") as IMyTextPanel;

        // Initialize our state machine
        _stateMachine = RunStuffOverTime().GetEnumerator();

        // Start the timer to run the first instruction set. Depending on your script, you may want to use
        // TriggerNow rather than Start. Just be very careful with that, you can easily bog down your
        // game that way.
        _timer.ApplyAction("Start");
    }
Пример #21
0
        public List <IMyInteriorLight> searchLights(string[] values)
        {
            List <IMyInteriorLight> lights = new List <IMyInteriorLight>();

            for (int i = 0; i < values.Length; i++)
            {
                IMyTerminalBlock block = this.gridTerminal.GetBlockWithName(values[i].Trim());
                if (block != null && block as IMyInteriorLight != null)
                {
                    IMyInteriorLight light = block as IMyInteriorLight;
                    if (!lights.Contains(light))
                    {
                        lights.Add(light);
                    }
                }
            }
            return(lights);
        }
Пример #22
0
        public Program()
        {
            // Retrieve the blocks we're going to use.
            thrusterForward  = GridTerminalSystem.GetBlockWithName("Ion Thrusters") as IMyThrust;
            thrusterBackward = GridTerminalSystem.GetBlockWithName("Ion Thrusters 2") as IMyThrust;
            light            = GridTerminalSystem.GetBlockWithName("Interior Light") as IMyInteriorLight;
            controller       = GridTerminalSystem.GetBlockWithName("Remote Control") as IMyShipController;

            // Initialize our state machine
            _stateMachine = RunStuffOverTime();

            // Signal the programmable block to run again in the next tick. Be careful on how much you
            // do within a single tick, you can easily bog down your game. The more ticks you do your
            // operation over, the better.
            //
            // What is actually happening here is that we are _adding_ the Once flag to the frequencies.
            // By doing this we can have multiple frequencies going at any time.
            Runtime.UpdateFrequency |= UpdateFrequency.Once;
        }
Пример #23
0
        public Program()
        {
            List <IMyGasTank> listH2Tanks = new List <IMyGasTank>();

            foreach (string nameH2Tank in nameHydrogenTanks)
            {
                listH2Tanks.Add((IMyGasTank)GridTerminalSystem.GetBlockWithName(nameH2Tank));
            }
            IMyInteriorLight warningLight      = (IMyInteriorLight)GridTerminalSystem.GetBlockWithName(nameWarningLight);
            IMyTextPanel     warningPanel      = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(nameLCDPanel);
            IMySoundBlock    warningSoundBlock = (IMySoundBlock)GridTerminalSystem.GetBlockWithName(nameSoundBlock);

            lowH2WarningSystem = new LowHydrogenWarningSystem(listH2Tanks, warningLight, warningPanel, warningSoundBlock)
            {
                warningLevel = warningLevel
            };

            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Пример #24
0
    void InitIndicator()
    {
        string pattern = IndicatorPrefix + id;
        List <IMyTerminalBlock> lights = new List <IMyTerminalBlock>();

        manager.grid.SearchBlocksOfName(IndicatorPrefix, lights,
                                        delegate(IMyTerminalBlock block) {
            return(block is IMyInteriorLight && Util.NameRegex(block, pattern).Success);
        }
                                        );
        if (lights.Count == 1)
        {
            indicator = lights[0];
        }
        else
        {
            Echo("No indicator light for Prison #" + id);
        }
    }
        bool CollectParts(IMyTerminalBlock block)
        {
            if (!Context.Reference.IsSameConstructAs(block))
            {
                return(false);
            }

            // Exclude types
            if (block is IMyInteriorLight && block.CustomName.Contains("Alarm"))
            {
                IMyInteriorLight light = (IMyInteriorLight)block;
                AlarmLights.Add(light);
            }

            if (block is IMyShipController && ((IMyShipController)block).CanControlShip && (Controller == null || block.CustomName.Contains("[I]")))
            {
                Controller = (IMyShipController)block;
            }

            return(false);
        }
        void GetParts()
        {
            controller         = null;
            DirectionIndicator = null;
            foreach (var hangar in Hangars)
            {
                hangar?.Clear();
            }
            HangarsDict.Clear();
            lastConnectorStatuses.Clear();
            SortedHangarsList.Clear();

            Context.Terminal.GetBlocksOfType <IMyTerminalBlock>(null, CollectParts);
            foreach (var hangar in Hangars)
            {
                if (IsHangarOk(hangar))
                {
                    SortedHangarsList.Add(hangar);
                    HangarsDict[hangar.Connector.EntityId] = hangar;
                }
            }
        }
Пример #27
0
 public Program()
 {
     light = GridTerminalSystem.GetBlockWithName("DebugLight") as IMyInteriorLight;
     Runtime.UpdateFrequency = UpdateFrequency.Update100;
 }
Пример #28
0
        public void setUp()
        {
            IMyMotorStator
                hipp = GridTerminalSystem.GetBlockWithName("Left Hip Rotor") as IMyMotorStator,
                knee = GridTerminalSystem.GetBlockWithName("Left Knee Rotor") as IMyMotorStator,
                ankl = GridTerminalSystem.GetBlockWithName("Left Ankle Rotor") as IMyMotorStator,
                anrt = GridTerminalSystem.GetBlockWithName("Left Rotat Ankle Rotor") as IMyMotorStator;

            ///LHip Light

            IMyInteriorLight
                hipL = GridTerminalSystem.GetBlockWithName("LHip Light") as IMyInteriorLight,
                kneL = GridTerminalSystem.GetBlockWithName("LKne Light") as IMyInteriorLight,
                ankL = GridTerminalSystem.GetBlockWithName("LAnk Light") as IMyInteriorLight,
                legL = GridTerminalSystem.GetBlockWithName("LLeg Light") as IMyInteriorLight;

            if (hipp == null || knee == null || ankl == null || anrt == null)
            {
                left = null;
            }
            else
            {
                left = new Leg(hipp, knee, ankl, anrt, true, 90f, 180f);
            }
            left.setLights(hipL, kneL, ankL, legL);

            hipp = GridTerminalSystem.GetBlockWithName("Right Hip Rotor") as IMyMotorStator;
            knee = GridTerminalSystem.GetBlockWithName("Right Knee Rotor") as IMyMotorStator;
            ankl = GridTerminalSystem.GetBlockWithName("Right Ankle Rotor") as IMyMotorStator;
            anrt = GridTerminalSystem.GetBlockWithName("Right Rotat Ankle Rotor") as IMyMotorStator;


            hipL = GridTerminalSystem.GetBlockWithName("RHip Light") as IMyInteriorLight;
            kneL = GridTerminalSystem.GetBlockWithName("RKne Light") as IMyInteriorLight;
            ankL = GridTerminalSystem.GetBlockWithName("RAnk Light") as IMyInteriorLight;
            legL = GridTerminalSystem.GetBlockWithName("RLeg Light") as IMyInteriorLight;

            if (hipp == null || knee == null || ankl == null || anrt == null)
            {
                right = null;
            }
            else
            {
                right = new Leg(hipp, knee, ankl, anrt, false, 270f, 360f);
            }
            right.setLights(hipL, kneL, ankL, legL);

            if (left != null)
            {
                left.set(init.X, init.Y);
            }
            if (right != null)
            {
                right.set(init.X, init.Y);
            }

            List <IMyLandingGear> temp   = new List <IMyLandingGear>();
            List <IMyLandingGear> Lgears = new List <IMyLandingGear>();
            List <IMyLandingGear> Rgears = new List <IMyLandingGear>();

            GridTerminalSystem.GetBlocksOfType(temp);

            foreach (IMyLandingGear gear in temp)
            {
                if (gear.CustomName.Equals("Left Gear"))
                {
                    Lgears.Add(gear);
                }
                else
                if (gear.CustomName.Equals("Right Gear"))
                {
                    Rgears.Add(gear);
                }
            }

            if (left != null)
            {
                left.setGears(Lgears);
            }
            if (right != null)
            {
                right.setGears(Rgears);
            }
        }
Пример #29
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
        }
Пример #30
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
        }
Пример #31
0
 public AlertLight(IMyInteriorLight lightBlock, Color color, bool blink)
 {
     this.lightBlock = lightBlock;
     this.color      = color;
     this.blink      = blink;
 }