예제 #1
0
        private static void Update10()
        {
            foreach (TestRemoteTask task in m_tasks)
            {
                switch (task.CurrentStatus)
                {
                case Status.None:
                case Status.Started:
                    break;

                default:
                    Logger.DebugLog("Completed: " + task + ", Result: " + task.Result);
                    m_tasks.Remove(task);
                    break;
                }
            }

            m_tasks.ApplyRemovals();

            if (m_tasks.Count < 10)
            {
                TestRemoteTask task = new TestRemoteTask();
                task.Parameter = "Par";
                m_tasks.Add(task);
                StartTask(task);
            }

            m_tasks.ApplyAdditions();
        }
예제 #2
0
파일: WeldGrid.cs 프로젝트: zrisher/ARMS
        /// <summary>
        /// Move blocks in m_projectedBlocks to m_damagedBlocks if they are touching any real blocks
        /// </summary>
        private void ProjectedToDamaged()
        {
            foreach (IMySlimBlock block in m_projectedBlocks)
            {
                MyCubeGrid projected     = (MyCubeGrid)block.CubeGrid;
                MyCubeGrid projectorGrid = projected.Projector.CubeGrid;

                if (projected.Closed || projected.Projector.Closed || !projected.Projector.IsWorking || projectorGrid.Closed)
                {
                    Log.DebugLog("projection closed");
                    continue;
                }

                Vector3I min = projectorGrid.WorldToGridInteger(projected.GridIntegerToWorld(block.Min()));

                if (projectorGrid.GetCubeBlock(min) != null)
                {
                    Log.DebugLog("space is occupied: " + min);
                    m_projectedBlocks.Remove(block);
                    continue;
                }

                IMyCubeBlock cubeBlock = block.FatBlock;
                if (cubeBlock != null)
                {
                    Vector3I max = projectorGrid.WorldToGridInteger(projected.GridIntegerToWorld(block.Max()));

                    MatrixD invOrient = projectorGrid.PositionComp.WorldMatrixNormalizedInv.GetOrientation();
                    Vector3 forward   = Vector3D.Transform(cubeBlock.WorldMatrix.Forward, ref invOrient);
                    Vector3 up        = Vector3D.Transform(cubeBlock.WorldMatrix.Up, ref invOrient);

                    MyBlockOrientation orient = new MyBlockOrientation(Base6Directions.GetClosestDirection(ref forward), Base6Directions.GetClosestDirection(ref up));

                    if (projectorGrid.CanPlaceBlock(min, max, orient, ((MyCubeBlock)cubeBlock).BlockDefinition))
                    {
                        Log.DebugLog("can place fatblock: " + cubeBlock.DisplayNameText + ", position: " + min + ", world: " + projectorGrid.GridIntegerToWorld(min));
                        m_damagedBlocks.Add(block);
                        m_projectedBlocks.Remove(block);
                    }

                    continue;
                }

                // no fatblock, cannot get definition
                if (projectorGrid.IsTouchingAnyNeighbor(min, min))
                {
                    Log.DebugLog("can place slimblock: " + block.ToString() + ", position: " + min + ", world: " + projectorGrid.GridIntegerToWorld(min));
                    m_damagedBlocks.Add(block);
                    m_projectedBlocks.Remove(block);
                }
            }

            m_projectedBlocks.ApplyRemovals();
        }
        public void ProcessDirtyCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities)
        {
            m_dirtyCells.ApplyAdditions();

            if (m_dirtyCells.Count == 0)
            {
                return;
            }
            ProfilerShort.Begin("Find false possitive dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                foreach (var tracker in trackedEntities.Values)
                {
                    var scaledBoundingVolume = tracker.BoundingVolume;
                    scaledBoundingVolume.Radius *= SCALE;
                    if (scaledBoundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint)
                    {
                        m_dirtyCells.Remove(cell);
                        break;
                    }
                }
            }
            m_dirtyCells.ApplyRemovals();

            ProfilerShort.BeginNextBlock("Remove stuff");
            foreach (var cell in m_dirtyCells)
            {
                cell.GetAll(m_tempObjectSeedList);

                foreach (var objectSeed in m_tempObjectSeedList)
                {
                    if (objectSeed.Generated)
                    {
                        CloseObjectSeed(objectSeed);
                    }
                }
                m_tempObjectSeedList.Clear();
            }

            ProfilerShort.BeginNextBlock("Remove dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                m_cells.Remove(cell.CellId);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }
            m_dirtyCells.Clear();
            ProfilerShort.End();
        }
        /// <summary>
        /// Unloads all cells that have been marked to be unloaded. It will remove all objects inside the sphere from
        /// the world. It will not unload cells that are still in the tracking volume of a tracked entity.
        /// </summary>
        /// <param name="trackedEntities">List of tracked entities</param>
        public void UnloadCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities)
        {
            m_toUnloadCells.ApplyAdditions();
            if (m_toUnloadCells.Count == 0)
            {
                return;
            }

            List <MyObjectSeed> cellObjects = new List <MyObjectSeed>();

            foreach (MyProceduralCell cell in m_toUnloadCells)
            {
                foreach (MyEntityTracker tracker in trackedEntities.Values)
                {
                    BoundingSphereD boundingVolume = tracker.BoundingVolume;
                    if (boundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint)
                    {
                        m_toUnloadCells.Remove(cell);
                        break;
                    }
                }
            }
            m_toUnloadCells.ApplyRemovals();
            foreach (var cell in m_toUnloadCells)
            {
                cell.GetAll(cellObjects);

                foreach (MyObjectSeed obj in cellObjects)
                {
                    if (obj.Params.Generated)
                    {
                        CloseObject(obj);
                    }
                }
                cellObjects.Clear();
            }
            foreach (MyProceduralCell cell in m_toUnloadCells)
            {
                m_cells.Remove(cell.CellId);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }
            m_toUnloadCells.Clear();
        }