Beispiel #1
0
        public void Main(string argument, UpdateType updateSource)
        {
            GridTerminalSystem.GetBlocksOfType <IMyGyro>(gyros);
            GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(controllers);
            GridTerminalSystem.GetBlocksOfType <IMySensorBlock>(sensors);

            if (controllers.Count < 1 || gyros.Count < 1)
            {
                Echo("ERROR: either no controller or gyro");
                return;
            }
            IMyRemoteControl controller = controllers[0];//

            //Vector2 yawAndRoll = controller.RotationIndicator;
            //Vector3 inputRotationVector = new Vector3(-yawAndRoll.X, yawAndRoll.Y, controller.RollIndicator);//pitch, yaw, roll. What?? ok.

            IMySensorBlock sensor = sensors[0];
            //Echo($"{sensor.LastDetectedEntity.Position}\n{sensor.LastDetectedEntity.Orientation}\n{sensor.LastDetectedEntity.Velocity}");
            //direction to the target
            Vector3D p1 = controller.GetPosition();
            Vector3D p2 = sensor.LastDetectedEntity.Position;
            Vector3D p3 = p2 - p1;

            //rotation to the target
            p3.Normalize();
            Vector3D heading = controller.WorldMatrix.Forward;

            heading.Normalize();
            double angle = Math.Acos(heading.Dot(p3));//this doesn't account for up vector for now

            Echo($"ANGLE:{angle}");
            Echo($"p3:{p3}");
            antenna.HudText = angle.ToString();
            //axis of rotation
            Vector3D cross = heading.Cross(p3);
            //var relativeRotation = Vector3D.Transform(cross, controller.WorldMatrix);

            double yaw; double pitch;

            GetRotationAngles(p3, controller.WorldMatrix.Forward, controller.WorldMatrix.Left, controller.WorldMatrix.Up, out yaw, out pitch);



            applyRotation(VECTOR@, gyros, controller);
            //turn axis into ship coordinates

            //calc the new matrix after that rotation

            //IF there is a gravity
            //calc angle to rotate by and axis of rotation, add that rotation to the rotation already underway
            //align the grav and up vector into the same plane...?
            //calc what my desired forward vector is(p3?), then

            //need to rotate and project up vector in line with art/nat gravity
            //Vector3D projection = a.Dot(b) / b.LengthSquared() * b;
            //applyRotation(inputRotationVector, gyros, controller);

            //keep this at the end
            previousShipVelicities = controllers[0].GetShipVelocities();
        }
            private void SetHangarStatus(HangarStatus status)
            {
                source.Echo(string.Format("Setting Hangar Status to: {0}", status.ToString()));
                this.status = status;
                string data_string  = status.ToString();
                string screenString = "Status:\n {0}\nShip Name:\n {1}\nShip ID:\n {2}";
                string ship_name    = "";
                string ship_id      = "";
                string data         = source.Me.CustomData;

                if (status == HangarStatus.docked)
                {
                    string[] saved_info = source.Me.CustomData.Split(',');
                    if (saved_info.Count() != 3)
                    {
                        IMySensorBlock sensor = (IMySensorBlock)blocks["landing_sensor"];
                        ship_name = sensor.LastDetectedEntity.Name;
                        ship_id   = sensor.LastDetectedEntity.EntityId.ToString("X");
                    }
                    else
                    {
                        ship_name = saved_info[1].Trim();
                        ship_id   = saved_info[2].Trim();
                    }

                    ship_id     = ship_id.Substring(Math.Max(0, ship_id.Length - 8));
                    data_string = string.Format("{0},\n{1},\n{2}", data_string, ship_name, ship_id);
                }
                source.Me.CustomData = data_string;

                screen.WriteText(string.Format(screenString, status.ToString(), ship_name, ship_id));
            }
        public Program()
        {
            sensor = GridTerminalSystem.GetBlockWithName(NAME_SENSOR) as IMySensorBlock;
            IMyProgrammableBlock pb = GridTerminalSystem.GetBlockWithName(NAME_PB) as IMyProgrammableBlock;

            if (pb != null)
            {
                Echo("LCD count: " + pb.SurfaceCount);
                pbLCD             = pb.GetSurface(0); // or 1
                pbLCD.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
                pbLCD.WriteText("init OK");
            }
            else
            {
                Echo("init ERROR PB");
            }

            if (sensor != null)
            {
                Echo("init SENSOR OK");
            }
            else
            {
                Echo("init SENSOR ERROR");
            }

            if (sensor != null && pbLCD != null)
            {
                Runtime.UpdateFrequency = UpdateFrequency.Update10;
            }
        }
        public void calibration()
        {
            FinishedCycle = false;

            //Find which direction the user is entering by checking
            //which sensor is detecting the user
            ActivatedSensor = SensorList.Find(match =>
            {
                return(match.IsActive);
            });
            //Find which door the user entered by checking which door is open
            ActivatedDoor = DoorList.Find(match =>
            {
                return(match.Status == DoorStatus.Open);
            });
            //Determine which sensor is the one not active
            OppositeSensor = SensorList.Find(match =>
            {
                return(!match.IsActive);
            });

            //Close all doors to prepare for airlock cycle
            foreach (var door in DoorList)
            {
                if (door.Status != DoorStatus.Closed)
                {
                    door.CloseDoor();
                    Echo($"{door.CustomName} closed");
                }
            }

            //TODO: LCD screen setup
        }
Beispiel #5
0
        bool SensorActive(IMySensorBlock s1, ref bool bAsteroidFound, ref bool bLargeFound, ref bool bSmallFound)
        {
            //           bool bAnyFound = false;
            bAsteroidFound = false;
            bLargeFound    = false;
            bSmallFound    = false;

            if (s1 != null && s1.IsActive && s1.Enabled && !s1.LastDetectedEntity.IsEmpty())
            {
                List <MyDetectedEntityInfo> lmyDEI = new List <MyDetectedEntityInfo>();
                s1.DetectedEntities(lmyDEI);
                for (int j1 = 0; j1 < lmyDEI.Count; j1++)
                {
                    if (lmyDEI[j1].Type == MyDetectedEntityType.Asteroid)
                    {
                        bAsteroidFound = true;
                    }
                    else if (lmyDEI[j1].Type == MyDetectedEntityType.LargeGrid)
                    {
                        bLargeFound = true;
                    }
                    else if (lmyDEI[j1].Type == MyDetectedEntityType.SmallGrid)
                    {
                        bSmallFound = true;
                    }
                }
            }
            return(bAsteroidFound || bLargeFound || bSmallFound);// bAnyFound;
        }
        public void Extend(VRageMath.Vector3 dir, int id, float value)
        {
            if (!XUtils.Directions.Contains(dir))
            {
                throw new Exception("Invalid direction vector used: " + dir);
            }

            if (id < 0 || id >= CountSensors)
            {
                throw new Exception("Parameter id (= " + id + ") out of range [" + 0 + ", " + CountSensors + ").");
            }

            if (value < Min || value > Max)
            {
                throw new Exception("Parameter value (= " + value + ") out of range [" + Min + ", " + Max + "].");
            }

            IMySensorBlock sensor = sensorBlocks[id];

            VRageMath.Matrix toSensor;
            sensor.Orientation.GetMatrix(out toSensor);
            VRageMath.Matrix.Transpose(ref toSensor, out toSensor);
            VRageMath.Matrix toGrid;
            referenceBlock.Orientation.GetMatrix(out toGrid);
            VRageMath.Vector3.Transform(ref dir, ref toGrid, out dir);
            VRageMath.Vector3.Transform(ref dir, ref toSensor, out dir);

            string propteryId = extendDirections[dir];

            sensor.SetValue(propteryId, value);
        }
Beispiel #7
0
            public bool SensorIsActive(IMySensorBlock s1, ref bool bAsteroidFound, ref bool bLargeFound, ref bool bSmallFound)
            {
                //           bool bAnyFound = false;
                bAsteroidFound = false;
                bLargeFound    = false;
                bSmallFound    = false;
                if (s1 == null)
                {
                    _program.ErrorLog("SensorIsActive: Null sensor");
                }

                if (s1 != null && s1.IsActive && s1.Enabled && !s1.LastDetectedEntity.IsEmpty())
                {
                    List <MyDetectedEntityInfo> lmyDEI = new List <MyDetectedEntityInfo>();
                    s1.DetectedEntities(lmyDEI);
                    for (int j1 = 0; j1 < lmyDEI.Count; j1++)
                    {
                        if (lmyDEI[j1].Type == MyDetectedEntityType.Asteroid)
                        {
                            //                        Echo(s1.CustomName + "SIA: Asteroid");
                            bAsteroidFound = true;
                        }
                        else if (lmyDEI[j1].Type == MyDetectedEntityType.LargeGrid)
                        {
                            bLargeFound = true;
                        }
                        else if (lmyDEI[j1].Type == MyDetectedEntityType.SmallGrid)
                        {
                            bSmallFound = true;
                        }
                    }
                }
                //            else Echo(s1.CustomName + " SIA() Inactive");
                return(bAsteroidFound || bLargeFound || bSmallFound);// bAnyFound;
            }
Beispiel #8
0
        void setSensorShip(IMyTerminalBlock tb, float fLeft, float fRight, float fUp, float fDown, float fFront, float fBack)
        {
            // need to use world matrix to get orientation correctly
            IMySensorBlock sb1 = tb as IMySensorBlock;

            if (sb1 == null)
            {
                return;
            }
            //		Echo(sb.CustomName);
            //	Echo(sb.Position.ToString());
            //x=width, y=height, z=back/forth. (fw=+z) (right=-y)
            float fXOffset = sb1.Position.X * 0.5f; // small grid only?
            float fYOffset = sb1.Position.Y * 0.5f;
            float fZOffset = sb1.Position.Z * 0.5f;

            // need to use grid orientation to main orientation block
            float fSet;

            fSet            = (float)(shipDim.WidthInMeters() / 2 - fXOffset + fLeft);
            sb1.LeftExtend  = Math.Max(fSet, 1.0f);
            fSet            = (float)(shipDim.WidthInMeters() / 2 + fXOffset + fRight);
            sb1.RightExtend = Math.Max(fSet, 1.0f);

            fSet             = (float)(shipDim.HeightInMeters() / 2 - fYOffset + fUp);
            sb1.TopExtend    = Math.Max(fSet, 1.0f);
            fSet             = (float)(shipDim.HeightInMeters() / 2 + fYOffset + fDown);
            sb1.BottomExtend = Math.Max(fSet, 1.0f);
            fSet             = (float)(shipDim.LengthInMeters() + fZOffset + fFront);
            sb1.FrontExtend  = Math.Max(fSet, 1.0f);
            fSet             = (float)(shipDim.LengthInMeters() - fZOffset + fBack);
            sb1.BackExtend   = Math.Max(fSet, 1.0f);

            sb1.Enabled = true;
        }
        // Compare current weather against list of 'bad' weathers.
        // If weather is bad, and sensor not triggered, then trigger it
        // If weather is good, and sensor is triggered, then un-trigger it
        private void CheckBadWeather(IMySensorBlock sensor_block)
        {
            // Get current weather
            MyAPIGateway.Session.WeatherEffects.GetWeather(sensor_block.GetPosition(), out MyObjectBuilder_WeatherEffect weatherEffect);

            // Create List of 'bad' weathers
            string[]      bad_weathers      = { "badweather1", "badweather2", "etc", };
            List <string> bad_weathers_list = new List <string>(bad_weathers);

            // Compare current weather against bad weather
            if ((bad_weathers_list.Contains(weatherEffect.ToString()) == true) && (bad_weather_active == false))
            {
                bad_weather_active = true;
                TriggerSensor(sensor_block, true);
            }
            else if ((bad_weathers_list.Contains(weatherEffect.ToString()) == false) && (bad_weather_active == true))
            {
                bad_weather_active = false;
                TriggerSensor(sensor_block, false);
            }
            else
            {
                return;
            }
        }
Beispiel #10
0
        bool FuncTest(IMySensorBlock block)
        {
            //Sensor
            //Interface name: IMySensorBlock
            //Parent: IMyFunctionalBlock
            //Fields:
            float LeftExtend   = block.LeftExtend;
            float RightExtend  = block.RightExtend;
            float TopExtend    = block.TopExtend;
            float BottomExtend = block.BottomExtend;
            float FrontExtend  = block.FrontExtend;
            float BackExtend   = block.BackExtend;

            bool DetectPlayers         = block.DetectPlayers;
            bool DetectFloatingObjects = block.DetectFloatingObjects;
            bool DetectSmallShips      = block.DetectSmallShips;
            bool DetectLargeShips      = block.DetectLargeShips;
            bool DetectStations        = block.DetectStations;
            bool DetectAsteroids       = block.DetectAsteroids;
            bool DetectOwner           = block.DetectOwner;
            bool DetectFriendly        = block.DetectFriendly;
            bool DetectNeutral         = block.DetectNeutral;
            bool DetectEnemy           = block.DetectEnemy;

            //IMyEntity LastDetectedEntity = block.LastDetectedEntity;
            return(true);
        }
        public override void UpdateBeforeSimulation100()
        {
            Init();

            IMySensorBlock sensorBlock = Entity as IMySensorBlock;

            if (Target != null && sensorBlock.IsActive && TeleporterNetwork.ContainsKey(Target))
            {
                PrintDebugMessage($"'{sensorBlock.DisplayNameText}' is an active teleporter to '{Target}'.");
                List <MyDetectedEntityInfo> detectedEntityInfos = new List <MyDetectedEntityInfo>();
                sensorBlock.DetectedEntities(detectedEntityInfos);
                List <IMyPlayer> players = new List <IMyPlayer>();

                foreach (MyDetectedEntityInfo entityInfo in detectedEntityInfos)
                {
                    if (entityInfo.Type == MyDetectedEntityType.CharacterHuman)
                    {
                        MyAPIGateway.Players.GetPlayers(players, p => p.Character.EntityId == entityInfo.EntityId);
                        IMyPlayer player = players[0];

                        PrintDebugMessage($"'{sensorBlock.DisplayNameText}' detected '{player.DisplayName}' and will teleport it to '{TeleporterNetwork[Target].Name}'.");
                        Teleport(player.Character, TeleporterNetwork[Target]);
                    }
                }
            }
        }
        private void Init(bool firstTime = false)
        {
            IMySensorBlock sensorBlock = Entity as IMySensorBlock;

            if (sensorBlock.CustomData.Contains($"{PROPERTY_KEY_NAME}="))
            {
                Dictionary <string, string> props = ReadProperties(sensorBlock.CustomData);

                if (!props.ContainsKey(PROPERTY_KEY_NAME))
                {
                    PrintDebugMessage($"'{sensorBlock.DisplayNameText}' has '{PROPERTY_KEY_NAME}=' in Custom Data, but it can not be used/read.");
                    return;
                }

                // Idea: Check for changed name and update the teleporter-network automatically ?!
                Name = props[PROPERTY_KEY_NAME];

                if (props.ContainsKey(PROPERTY_KEY_OFFSET))
                {
                    string[] coordStrs = props[PROPERTY_KEY_OFFSET].Split(',');
                    try
                    {
                        Offset = ParseVector3D(coordStrs);
                    }
                    catch (Exception e)
                    {
                        PrintErrorMessage($"While reading '{PROPERTY_KEY_OFFSET}' from '{sensorBlock.DisplayNameText}': {e.Message}");
                    }
                }
                else
                {
                    Offset = DEFAULT_OFFSET;
                }

                try
                {
                    Register(this);
                }
                catch (Exception e)
                {
                    PrintErrorMessage(e.Message);
                    return;
                }

                if (!props.ContainsKey(PROPERTY_KEY_TARGET))
                {
                    // One-Way teleporter. This might be a target only.
                    //PrintWarningMessage($"'{PROPERTY_KEY_TARGET}' not set in Custom Data at '{sensorBlock.DisplayNameText}'. It might be a target only.");
                    return;
                }

                Target = props[PROPERTY_KEY_TARGET];

                if (!TeleporterNetwork.ContainsKey(Target) && !firstTime && sensorBlock.IsActive)
                {
                    PrintErrorMessage($"No teleporter found with the name '{Target}'!");
                }
            }
        }
Beispiel #13
0
 public Program()
 {
     _logger   = new Logger(Me.GetSurface(0));
     _displays = new List <Display>();
     // _displays.Add(new Game(Me.GetSurface(0), this));
     _floor  = EnumerateFloor();
     _sensor = (IMySensorBlock)GridTerminalSystem.GetBlockWithName("F_SENSOR");
     Runtime.UpdateFrequency = UpdateFrequency.Once | UpdateFrequency.Update1;
     Log("Initialized");
 }
Beispiel #14
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            if (OreNames == null)
            {
                MyDefinitionManager.Static.GetOreTypeNames(out OreNames);
            }

            Sensor = Entity as IMySensorBlock;
            Sensor.StateChanged += sensor_StateChanged;
        }
            public IMySensorBlock GetForwardSensor()
            {
                IMySensorBlock sb = null;

                if (sensorsList.Count > 0)
                {
                    sb = sensorsList[0];
                }

                return(sb);
            }
        // 0000


        public Program()
        {
            // 0000
            Runtime.UpdateFrequency = UpdateFrequency.Update10;
            tribalSensor            = GridTerminalSystem.GetBlockWithName("sensor1") as IMySensorBlock;
            List <IMyGravityGenerator> gravity = new List <IMyGravityGenerator>();

            GridTerminalSystem.GetBlocksOfType <IMyGravityGenerator>(gravity);
            gravGen = gravity[0];
            // 0000
        }
Beispiel #17
0
    public void updateNearbyCollisionData(IMySensorBlock sensor)
    {
        if (!sensor.LastDetectedEntity.IsEmpty())
        {
            MyDetectedEntityInfo entity = sensor.LastDetectedEntity;
            if (!this.nearbyEntities.Any(val => val.id == entity.EntityId))
            {
                DetectedEntity tmp = new DetectedEntity();
                tmp.id       = entity.EntityId;
                tmp.name     = entity.Name;
                tmp.position = entity.Position;
                tmp.lastSeen = Communication.getTimestamp();
                tmp.distance = this.getDistanceFrom(entity.Position, sensor.GetPosition());
                tmp.type     = entity.Type;
                this.nearbyEntities.Add(tmp);
            }
            else
            {
                for (int i = 0; i < this.nearbyEntities.Count; i++)
                {
                    DetectedEntity nearEntity = this.nearbyEntities[i];
                    if (nearEntity.id == entity.EntityId)
                    {
                        DetectedEntity tmp = new DetectedEntity();
                        tmp.id                 = entity.EntityId;
                        tmp.name               = entity.Name;
                        tmp.position           = entity.Position;
                        tmp.entityInfo         = entity;
                        tmp.lastSeen           = Communication.getTimestamp();
                        tmp.distance           = this.getDistanceFrom(entity.Position, sensor.GetPosition());
                        tmp.type               = entity.Type;
                        this.nearbyEntities[i] = tmp;
                        break;
                    }
                }
            }
        }
        else
        {
            List <DetectedEntity> tmp = new List <DetectedEntity>();

            for (int i = 0; i < this.nearbyEntities.Count; i++)
            {
                DetectedEntity nearEntity = this.nearbyEntities[i];
                if (Communication.getTimestamp() - nearEntity.lastSeen < 7 * 24 * 60 * 60)   // Last seen in 7 days?
                {
                    tmp.Add(nearEntity);
                }
            }

            this.nearbyEntities = tmp;
        }
    }
Beispiel #18
0
            public IMySensorBlock GetForwardSensor(int iOffset = 0)
            {
                // Todo: chose the sensor closest to 'forward' on the ship
                IMySensorBlock sb = null;

                if (sensorsList.Count > iOffset)
                {
                    sb = sensorsList[iOffset];
                }

                return(sb);
            }
Beispiel #19
0
        public Program()
        {
            test_panel             = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("LCD");
            test_panel.ContentType = ContentType.TEXT_AND_IMAGE;

            turret = (IMyLargeTurretBase)GridTerminalSystem.GetBlockWithName("test_turret");
            Runtime.UpdateFrequency = UpdateFrequency.Update10;

            sensor            = (IMySensorBlock)GridTerminalSystem.GetBlockWithName("turret_sensor");
            detected_entities = new List <MyDetectedEntityInfo>();

            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Beispiel #20
0
 void sleepAllSensors()
 {
     for (int i1 = 0; i1 < sensorsList.Count; i1++)
     {
         IMySensorBlock sb1 = sensorsList[i1] as IMySensorBlock;
         if (sb1 == null)
         {
             continue;
         }
         sb1.LeftExtend = sb1.RightExtend = sb1.TopExtend = sb1.BottomExtend = sb1.FrontExtend = sb1.BackExtend = 1;
         sb1.Enabled    = false;
     }
 }
Beispiel #21
0
        public Program()
        {
            greet_panel             = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("greetings_LCD");
            greet_panel.ContentType = ContentType.TEXT_AND_IMAGE;
            debug_panel             = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("debug_panel");
            debug_panel.ContentType = ContentType.TEXT_AND_IMAGE;

            sensor            = (IMySensorBlock)GridTerminalSystem.GetBlockWithName("greetings_sensor");
            detected_entities = new List <MyDetectedEntityInfo>();

            jukebox = GridTerminalSystem.GetBlockWithName("greetings_jukebox");
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Beispiel #22
0
 void sleepAllSensors()
 {
     for (int i = 0; i < sensorsList.Count; i++)
     {
         IMySensorBlock sb = sensorsList[i] as IMySensorBlock;
         if (sb == null)
         {
             continue;
         }
         sb.LeftExtend = sb.RightExtend = sb.TopExtend = sb.BottomExtend = sb.FrontExtend = sb.BackExtend = 1;
         sb.Enabled    = false;
     }
 }
        public Sensors(IMyTerminalBlock reference, List <IMyTerminalBlock> blocks)
            : base(reference)
        {
            UpdateSensors(blocks);

            if (sensorBlocks.Count > 0)
            {
                IMySensorBlock sensor = sensorBlocks[0];
                Min     = sensor.GetMininum <float>("Back");
                Max     = sensor.GetMaximum <float>("Back");
                Default = sensor.GetDefaultValue <float>("Back");
            }
        }
Beispiel #24
0
            public void SensorProp(int propId, int propVal)
            {
                if (0 == propId)
                {
                    sensor = NextBlockInGrid(Pgm, Me, sensor, propVal);
                    return;
                }
                if (null == sensor)
                {
                    return;
                }

                Func <float, int, float> ext = (v, d) => { return(0 == d ? 1 : MathHelper.Clamp(v + d, 1, 50)); };

                switch (propId)
                {
                case 1: sensor.FrontExtend = ext(sensor.FrontExtend, propVal);       break;

                case 2: sensor.BackExtend = ext(sensor.BackExtend, propVal);        break;

                case 3: sensor.LeftExtend = ext(sensor.LeftExtend, propVal);        break;

                case 4: sensor.RightExtend = ext(sensor.RightExtend, propVal);       break;

                case 5: sensor.TopExtend = ext(sensor.TopExtend, propVal);         break;

                case 6: sensor.BottomExtend = ext(sensor.BottomExtend, propVal);      break;

                case 11: sensor.DetectLargeShips = !sensor.DetectLargeShips;              break;

                case 12: sensor.DetectSmallShips = !sensor.DetectSmallShips;              break;

                case 13: sensor.DetectStations = !sensor.DetectStations;                break;

                case 14: sensor.DetectSubgrids = !sensor.DetectSubgrids;                break;

                case 15: sensor.DetectPlayers = !sensor.DetectPlayers;                 break;

                case 16: sensor.DetectAsteroids = !sensor.DetectAsteroids;               break;

                case 17: sensor.DetectFloatingObjects = !sensor.DetectFloatingObjects; break;

                case 21: sensor.DetectOwner = !sensor.DetectOwner;           break;

                case 22: sensor.DetectFriendly = !sensor.DetectFriendly;        break;

                case 23: sensor.DetectNeutral = !sensor.DetectNeutral;         break;

                case 24: sensor.DetectEnemy = !sensor.DetectEnemy;           break;
                }
            }
Beispiel #25
0
        private void InitilizeServerClient()
        {
            WriteDebug("Initilize", "Start");
            _isInitialized   = true; // Set this first to block any other calls from UpdateAfterSimulation().
            _sunSensorEntity = (IMySensorBlock)Entity;
            _isIsValid       = (_sunSensorEntity.BlockDefinition.SubtypeName.Equals("SmallSunSensor", StringComparison.InvariantCultureIgnoreCase) ||
                                _sunSensorEntity.BlockDefinition.SubtypeName.Equals("LargeSunSensor", StringComparison.InvariantCultureIgnoreCase));

            if (_isIsValid)
            {
                ((IMyTerminalBlock)_sunSensorEntity).CustomNameChanged += _iMyTerminalBlock_CustomNameChanged;
            }
            WriteDebug("Initilize", "End = {0}", _isIsValid);
        }
Beispiel #26
0
            internal MULE()
            {
                _evasive = 0;
                ProgramInstance.Me.CustomName = "PB CDS Drone";
                ProgramInstance.Me.CustomData = "IGC ID: " + ProgramInstance.IGC.Me;
                _connector  = GetFirstWithName <IMyShipConnector>(_connectorName);
                _sensor     = GetFirstWithName <IMySensorBlock>(_sensorName);
                _controller = GetFirstWithName <IMyRemoteControl>(_controllerName);

                InitializeAndSubscribeSuspensions();

                ReadRouteData();
                try { ReadData(); } catch { WriteData(); }
            }
            public void openForSensor(IMySensorBlock sensor, string groupName)
            {
                if (!_desiredStates.ContainsKey(groupName))
                {
                    return;
                }
                DoorDesiredState desired = _desiredStates[groupName];
                bool             old     = desired.IsDesiredOpen;

                desired.openForSensors.Add(sensor);
                if (!old)
                {
                    (State as AutoDoorState).onOpenRequested(this);
                }
            }
            public Payload(GridTerminalSystemUtils GTS, double backupDetonateEngageDist)
            {
                this.backupDetonateEngageDistSq = backupDetonateEngageDist * backupDetonateEngageDist;

                GTS.GetBlocksOfTypeOnGrid(warheads);

                var templist = new List <IMySensorBlock>();

                GTS.GetBlocksOfTypeOnGrid(templist);

                if (templist.Count > 0)
                {
                    sensor = templist.First();
                }
            }
        public static int CreateActionBitMask(IMySensorBlock sensor)
        {
            int actionBitMask = 0;

            actionBitMask |= sensor.DetectAsteroids ? Action.DetectAsteroids.Value : 0;
            actionBitMask |= sensor.DetectEnemy ? Action.DetectEnemy.Value : 0;
            actionBitMask |= sensor.DetectFloatingObjects ? Action.DetectFloatingObjects.Value : 0;
            actionBitMask |= sensor.DetectFriendly ? Action.DetectFriendly.Value : 0;
            actionBitMask |= sensor.DetectLargeShips ? Action.DetectLargeShips.Value : 0;
            actionBitMask |= sensor.DetectNeutral ? Action.DetectNeutral.Value : 0;
            actionBitMask |= sensor.DetectOwner ? Action.DetectOwner.Value : 0;
            actionBitMask |= sensor.DetectPlayers ? Action.DetectPlayers.Value : 0;
            actionBitMask |= sensor.DetectSmallShips ? Action.DetectSmallShips.Value : 0;
            actionBitMask |= sensor.DetectStations ? Action.DetectStations.Value : 0;
            return(actionBitMask);
        }
Beispiel #30
0
            public Hangar(
                Action <string> echo,
                IMyGridTerminalSystem system,
                IMyProgrammableBlock controller)
            {
                Echo               = echo;
                this.controller    = controller;
                GridTerminalSystem = system;

                name = controller.CustomName.Split('-')[0].Trim();

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

                GridTerminalSystem.SearchBlocksOfName(name, sensors, sensor => sensor is IMySensorBlock && !sensor.CustomName.Contains("exit"));
                sensor = sensors[0] as IMySensorBlock;
            }
 public override void Init(MyObjectBuilder_EntityBase objectBuilder)
 {
     Sensor = Entity as IMySensorBlock;
     Sensor.StateChanged += sensor_StateChanged;
 }