示例#1
0
        private void PressurizeInitialize()
        {
            m_tempPrevCubeRoom = m_isPressurizing ? m_prevCubeRoom : m_cubeRoom;
            m_tempPrevRooms    = m_isPressurizing? m_prevRooms : m_rooms;

            Vector3I size = GridMax() - GridMin();

            m_cubeRoom = new MyOxygenBlock[size.X + 1, size.Y + 1, size.Z + 1];
            m_queue.Clear();
            m_queue.Add(new RoomSquare(GridMin(), 0));
            m_tempRooms         = new List <MyOxygenRoom>();
            m_cubeRoom[0, 0, 0] = new MyOxygenBlock(new MyOxygenRoomLink(new MyOxygenRoom(0)));
            m_tempRooms.Add(m_cubeRoom[0, 0, 0].Room);

            m_deletedBlocks.Clear();

            m_queueIndex     = 0;
            m_isPressurizing = true;
        }
示例#2
0
        private bool PressurizeProcessQueue(int count)
        {
            int index = 0;

            while (m_queueIndex < m_queue.Count)
            {
                for (int i = 0; i < 6; i++)
                {
                    var currentRoom = m_queue[m_queueIndex];

                    Vector3I current = currentRoom.Pos + m_neighbours[i];

                    if (!IsInBounds(current))
                    {
                        continue;
                    }

                    Vector3I posInGrid = current - GridMin();

                    int x = posInGrid.X;
                    int y = posInGrid.Y;
                    int z = posInGrid.Z;

                    int prevRoomIndex = currentRoom.Index;
                    int currRoomIndex = RoomIndex(x, y, z);

                    if (currRoomIndex <= prevRoomIndex)
                    {
                        continue;
                    }

                    bool isPressurized = IsPressurized(currentRoom.Pos, current);

                    if (isPressurized)
                    {
                        if (prevRoomIndex < currRoomIndex)
                        {
                            if (m_tempRooms.Count >= currRoomIndex)
                            {
                                continue;
                            }

                            prevRoomIndex       = m_tempRooms.Count;
                            m_cubeRoom[x, y, z] = new MyOxygenBlock(new MyOxygenRoomLink(new MyOxygenRoom(prevRoomIndex)));
                            m_tempRooms.Add(m_cubeRoom[x, y, z].Room);
                            if (current == GridMin())
                            {
                            }
                            m_queue.Add(new RoomSquare(current, prevRoomIndex, !currentRoom.WasWall));
                            if (m_cubeRoom[x, y, z].Room == null)
                            {
                                m_cubeRoom[x, y, z].RoomLink = new MyOxygenRoomLink(new MyOxygenRoom(prevRoomIndex));
                            }
                            else
                            {
                                m_cubeRoom[x, y, z].RoomLink = m_tempRooms[prevRoomIndex].Link;
                            }
                        }
                    }
                    else
                    {
                        m_queue.Add(new RoomSquare(current, prevRoomIndex, currentRoom.WasWall));
                        if (m_cubeRoom[x, y, z].Room == null)
                        {
                            m_cubeRoom[x, y, z].RoomLink = new MyOxygenRoomLink(new MyOxygenRoom(prevRoomIndex));
                        }
                        else
                        {
                            if (prevRoomIndex < m_tempRooms.Count)
                            {
                                m_cubeRoom[x, y, z].RoomLink = m_tempRooms[prevRoomIndex].Link;
                            }
                        }

                        if (IsOnBounds(current))
                        {
                            m_cubeRoom[x, y, z].Room.IsPressurized        = false;
                            m_cubeRoom[x, y, z].Room.EnvironmentOxygen    = Math.Max(m_cubeRoom[x, y, z].Room.EnvironmentOxygen, MyOxygenProviderSystem.GetOxygenInPoint(m_cubeGrid.GridIntegerToWorld(posInGrid)));
                            m_cubeRoom[x, y, z].Room.DepressurizationTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                        }
                    }
                }
                m_queueIndex++;
                index++;

                if ((index > count))
                {
                    return(false);
                }
            }
            m_queue.Clear();
            return(true);
        }
        private void PressurizeInitialize()
        {
            m_tempPrevCubeRoom = isPressurizing ? m_prevCubeRoom : m_cubeRoom;
            m_tempPrevRooms = isPressurizing? m_prevRooms : m_rooms;

            Vector3I size = GridMax() - GridMin();

            m_cubeRoom = new MyOxygenBlock[size.X + 1, size.Y + 1, size.Z + 1];
            m_queue.Clear();
            m_queue.Add(new RoomSquare(GridMin(), 0));
            m_tempRooms = new List<MyOxygenRoom>();
            m_cubeRoom[0, 0, 0] = new MyOxygenBlock(new MyOxygenRoom(0));
            m_tempRooms.Add(m_cubeRoom[0, 0, 0].Room);

            m_queueIndex = 0;
            isPressurizing = true;
        }
        private bool PressurizeProcessQueue(int count)
        {
            int index = 0;
            while (m_queueIndex < m_queue.Count)
            {
                for (int i = 0; i < 6; i++)
                {
                    var currentRoom = m_queue[m_queueIndex];

                    Vector3I current = currentRoom.Pos + m_neighbours[i];

                    if (!IsInBounds(current))
                    {
                        continue;
                    }

                    Vector3I posInGrid = current - GridMin();

                    int x = posInGrid.X;
                    int y = posInGrid.Y;
                    int z = posInGrid.Z;

                    int prevRoomIndex = currentRoom.Index;
                    int currRoomIndex = RoomIndex(x, y, z);

                    if (currRoomIndex <= prevRoomIndex)
                        continue;

                    bool isPressurized = IsPressurized(currentRoom.Pos, current);

                    if (isPressurized)
                    {
                        if (prevRoomIndex < currRoomIndex)
                        {
                            if (m_tempRooms.Count >= currRoomIndex)
                            {
                                continue;
                            }

                            prevRoomIndex = m_tempRooms.Count;
                            m_cubeRoom[x, y, z] = new MyOxygenBlock(new MyOxygenRoom(prevRoomIndex));
                            m_tempRooms.Add(m_cubeRoom[x, y, z].Room);
                            if (current == GridMin())
                            {

                            }
                            m_queue.Add(new RoomSquare(current, prevRoomIndex, !currentRoom.WasWall));
                            if (m_cubeRoom[x, y, z].Room == null)
                            {
                                m_cubeRoom[x, y, z].Room = new MyOxygenRoom(prevRoomIndex);
                            }
                            else
                            {
                                m_cubeRoom[x, y, z].Room = m_tempRooms[prevRoomIndex];
                            }
                        }
                    }
                    else
                    {
                        m_queue.Add(new RoomSquare(current, prevRoomIndex, currentRoom.WasWall));
                        if (m_cubeRoom[x, y, z].Room == null)
                        {
                            m_cubeRoom[x, y, z].Room = new MyOxygenRoom(prevRoomIndex);
                        }
                        else
                        {
                            if (prevRoomIndex < m_tempRooms.Count)
                            {
                                m_cubeRoom[x, y, z].Room = m_tempRooms[prevRoomIndex];
                            }
                        }

                        if (IsOnBounds(current))
                        {
                            m_cubeRoom[x, y, z].Room.IsPressurized = false;
                            m_cubeRoom[x, y, z].Room.EnvironmentOxygen = Math.Max(m_cubeRoom[x, y, z].Room.EnvironmentOxygen, MyOxygenProviderSystem.GetOxygenInPoint(m_cubeGrid.GridIntegerToWorld(posInGrid)));
                            m_cubeRoom[x, y, z].Room.DepressurizationTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                        }
                    }
                }
                m_queueIndex++;
                index++;

                if ((index > count))
                {
                    return false;
                }
            }
            m_queue.Clear();
            return true;
        }
        private bool IsInGridBounds(Vector3I pos, MyOxygenBlock[, ,] grid)
        {
            if (pos.X < 0 || pos.X >= grid.GetLength(0))
                return false;
            if (pos.Y < 0 || pos.Y >= grid.GetLength(1))
                return false;
            if (pos.Z < 0 || pos.Z >= grid.GetLength(2))
                return false;

            return true;
        }