Exemple #1
0
 public void UpdateDeposits(ref BoundingSphereD worldDetectionSphere, long detectorId, MyOreDetectorComponent detectorComponent)
 {
     if (this.m_tasksRunning == 0)
     {
         MySession @static = MySession.Static;
         if ((@static != null) && @static.Ready)
         {
             Vector3I vectori;
             Vector3I vectori2;
             Vector3D worldPosition = worldDetectionSphere.Center - worldDetectionSphere.Radius;
             Vector3D vectord2      = worldDetectionSphere.Center + worldDetectionSphere.Radius;
             MyVoxelCoordSystems.WorldPositionToVoxelCoord(this.m_voxelMap.PositionLeftBottomCorner, ref worldPosition, out vectori);
             MyVoxelCoordSystems.WorldPositionToVoxelCoord(this.m_voxelMap.PositionLeftBottomCorner, ref vectord2, out vectori2);
             vectori  = (Vector3I)(vectori + this.m_voxelMap.StorageMin);
             vectori2 = (Vector3I)(vectori2 + this.m_voxelMap.StorageMin);
             this.m_voxelMap.Storage.ClampVoxelCoord(ref vectori, 1);
             this.m_voxelMap.Storage.ClampVoxelCoord(ref vectori2, 1);
             vectori  = vectori >> 5;
             vectori2 = vectori2 >> 5;
             if ((vectori != this.m_lastDetectionMin) || (vectori2 != this.m_lastDetectionMax))
             {
                 Vector3I vectori3;
                 Vector3I vectori4;
                 this.m_lastDetectionMin = vectori;
                 this.m_lastDetectionMax = vectori2;
                 int num  = Math.Max((vectori2.X - vectori.X) / 2, 1);
                 int num2 = Math.Max((vectori2.Y - vectori.Y) / 2, 1);
                 vectori3.Z = vectori.Z;
                 vectori4.Z = vectori2.Z;
                 int num3 = 0;
                 while (num3 < 2)
                 {
                     int num4 = 0;
                     while (true)
                     {
                         if (num4 >= 2)
                         {
                             num3++;
                             break;
                         }
                         vectori3.X = vectori.X + (num3 * num);
                         vectori3.Y = vectori.Y + (num4 * num2);
                         vectori4.X = vectori3.X + num;
                         vectori4.Y = vectori3.Y + num2;
                         MyDepositQuery.Start(vectori3, vectori4, detectorId, this.m_voxelMap, this.m_onDepositQueryComplete, detectorComponent);
                         this.m_tasksRunning++;
                         num4++;
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public static void Start(Vector3I min, Vector3I max, long detectorId, MyVoxelBase voxelMap, Action <List <MyEntityOreDeposit>, List <Vector3I>, MyOreDetectorComponent> completionCallback, MyOreDetectorComponent detectorComp)
        {
            MyDepositQuery item = null;

            m_instancePool.AllocateOrCreate(out item);
            if (item != null)
            {
                item.Min                   = min;
                item.Max                   = max;
                item.DetectorId            = detectorId;
                item.VoxelMap              = voxelMap;
                item.CompletionCallback    = completionCallback;
                item.OreDetectionComponent = detectorComp;
                Parallel.Start(item, item.m_onComplete);
            }
        }
        private void IssueQueries()
        {
            while (m_issuedQueries.Count < 100 && m_queriesToIssue.Count > 0)
            { // discard queries which have gone out of range
                var e = m_queriesToIssue.GetEnumerator();
                e.MoveNext();
                var coord = e.Current;
                if (!coord.IsInsideInclusive(ref m_lastDetectionMin, ref m_lastDetectionMax))
                {
                    m_queriesToIssue.Remove(coord);
                    continue;
                }

                MyDepositQuery.Start(new MyDepositQuery.Args()
                {
                    VoxelMap           = m_voxelMap,
                    CompletionCallback = m_onDepositQueryComplete,
                    Cell = coord,
                });
                m_issuedQueries.Add(coord);
                m_queriesToIssue.Remove(coord);
            }
            Stats.Generic.Write("Ore detector queries", m_queriesToIssue.Count + m_issuedQueries.Count, VRage.Stats.MyStatTypeEnum.CurrentValue, 100, 0);
        }