public void AddSensors(List <IMyTerminalBlock> blocks) { if (sensors == null) { sensors = new Sensors(ReferenceBlock, blocks); } sensors.UpdateSensors(blocks); }
private void SetupSensors() { if (sensors == null) { throw new Exception("No sensors available (sensors == null)."); } VRageMath.BoundingBox bb = GetBounds(); VRageMath.Matrix fromReference = new VRageMath.Matrix(); ReferenceBlock.Orientation.GetMatrix(out fromReference); //VRageMath.Vector3 v = m.Forward.Min() < 0 ? -m.Forward * bb.Min + (XUtils.One + m.Forward) * bb.Max : (XUtils.One - m.Forward) * bb.Min + m.Forward * bb.Max; _sensorIds.Clear(); // Asteroid search laser int id = sensors.GetClosestSensor(bb.Center, _sensorIds); if (id == sensors.CountSensors) { throw new Exception("Not enough sensors."); } _sensorIds.Add(id); var sensor = sensors[id]; sensors.ExtendFront(id, sensors.Max); sensors.ExtendBack(id, sensors.Min); sensors.ExtendBottom(id, sensors.Min); sensors.ExtendLeft(id, sensors.Min); sensors.ExtendRight(id, sensors.Min); sensors.ExtendTop(id, sensors.Min); Sensors.SetFlags(sensor, Sensors.Action.DetectAsteroids.Value); sensor.GetActionWithName("OnOff_On").Apply(sensor); sensor.RequestShowOnHUD(true); sensor.SetCustomName(sensor.DefinitionDisplayNameText + " X Laser"); // Asteroid collision detector id = sensors.GetClosestSensor(bb.Center, _sensorIds); if (id == sensors.CountSensors) { throw new Exception("Not enough sensors."); } _sensorIds.Add(id); sensor = sensors[id]; SetupDrillSensor(fromReference, id, bb); Sensors.SetFlags(sensor, Sensors.Action.DetectAsteroids.Value); sensor.GetActionWithName("OnOff_On").Apply(sensors[id]); sensor.RequestShowOnHUD(true); sensor.SetCustomName(sensor.DefinitionDisplayNameText + " X Drill"); }