Exemplo n.º 1
0
        public void PlayAreaInitialiseNoStructures()
        {
            Vector3Int chunkDimensions = new Vector3Int(16, 16, 16);
            Vector3Int collidableRadii = new Vector3Int(1, 1, 1);
            Vector3Int renderedRadii   = new Vector3Int(4, 4, 4);

            //Set up the mocks
            SetupMocks(chunkDimensions, generateStructures: false);

            PlayAreaManager playArea = new PlayAreaManager(collidableRadii, renderedRadii);

            //Initialise play area
            playArea.Initialise(mockManager, mockPipeline, player);

            Vector3Int MaxActiveRadii = renderedRadii + new Vector3Int(1, 1, 1);

            //Ensure we've got the max active radii correct
            Assert.AreEqual(MaxActiveRadii, playArea.MaximumActiveRadii);

            Vector3Int PlayerChunkId = playArea.playerChunkID;

            //Ensure player chunk id correct
            Assert.AreEqual(Vector3Int.zero, PlayerChunkId);

            //After initialise, check all positions have the expected target.

            //printStageMap2DSlice(MaxActiveRadii,0,PlayerChunkId);

            AssertStatusMapCorrect(MaxActiveRadii, PlayerChunkId, playArea);
        }
Exemplo n.º 2
0
        public void PlayAreaIncrementalUpdateInterrupted(Vector3Int[] displacements)
        {
            Debug.Log($"Displacement sequence {displacements.ArrayToString()}");

            Vector3Int chunkDimensions = new Vector3Int(16, 16, 16);

            Vector3Int collidableRadii = new Vector3Int(1, 1, 1);
            Vector3Int renderedRadii   = new Vector3Int(2, 2, 2);

            //Set up the mocks
            SetupMocks(chunkDimensions);

            PlayAreaManager playArea = new PlayAreaManager(collidableRadii, renderedRadii);

            playArea.UpdateRate = 5;//Limited update rate

            //Initialise play area
            playArea.Initialise(mockManager, mockPipeline, player);
            Vector3Int MaxActiveRadii        = playArea.MaximumActiveRadii;
            Vector3Int originalPlayerChunkId = playArea.playerChunkID;

            //printStageMap2DSlice(MaxActiveRadii, 0, originalPlayerChunkId);

            printStageMap2DSlice(MaxActiveRadii, 0, playArea.playerChunkID);
            for (int i = 0; i < displacements.Length; i++)
            {
                player.Position += displacements[i] * chunkDimensions;//move player interrupting progress

                playArea.Update();
            }

            //remove update limit
            playArea.UpdateRate = ushort.MaxValue;
            playArea.Update();//Final update

            Vector3Int playerChunkIdAfterUpdate = playArea.playerChunkID;

            Debug.Log("PostUpdate");

            //printStageMap2DSlice(MaxActiveRadii, 0, playArea.playerChunkID);

            //Check play area is correct
            AssertStatusMapCorrect(MaxActiveRadii, playerChunkIdAfterUpdate, playArea);
        }
Exemplo n.º 3
0
        public void PlayAreaUpdateWithLargeDisplacement(int xDisp, int yDisp, int zDisp)
        {
            Vector3Int displacement = new Vector3Int(xDisp, yDisp, zDisp) * 10;

            Debug.Log(displacement);

            Vector3Int chunkDimensions = new Vector3Int(16, 16, 16);

            Vector3Int collidableRadii = new Vector3Int(1, 1, 1);
            Vector3Int renderedRadii   = new Vector3Int(2, 2, 2);

            //Set up the mocks
            SetupMocks(chunkDimensions);

            PlayAreaManager playArea = new PlayAreaManager(collidableRadii, renderedRadii);

            playArea.UpdateRate = ushort.MaxValue;//Unlimited update rate for testing

            //Initialise play area
            playArea.Initialise(mockManager, mockPipeline, player);
            Vector3Int MaxActiveRadii        = playArea.MaximumActiveRadii;
            Vector3Int originalPlayerChunkId = playArea.playerChunkID;

            player.Position += displacement * chunkDimensions;
            //Debug.Log("PreUpdate");
            //printStageMap2DSlice(MaxActiveRadii, 0, originalPlayerChunkId);

            playArea.Update();

            Vector3Int playerChunkIdAfterUpdate = playArea.playerChunkID;

            //Ensure player chunk updated correctly
            Assert.AreEqual(originalPlayerChunkId + displacement, playerChunkIdAfterUpdate,
                            $"Player chunk id was incorrect");

            //Debug.Log("PostUpdate");
            //printStageMap2DSlice(MaxActiveRadii, 0, playerChunkIdAfterUpdate);

            //Check play area is correct
            AssertStatusMapCorrect(MaxActiveRadii, playerChunkIdAfterUpdate, playArea);
        }