public virtual void Update(double time) { //Update the controllers foreach (var r in ControlInterpreters) { r.Update(time, this); } foreach (var r in Interactables) { r.Update(time, this); } LightManager.Update(); Physics.Update(time); }
public void OnChunksGeneratedSunlight(bool topToBottom) { int first = 0; int second = 1; if (!topToBottom) { Utils.Helpers.Swap(ref first, ref second); } Vector3Int[] ids = new Vector3Int[] { Vector3Int.zero, Vector3Int.down }; var upChunkData = GetMockChunkData(ids[0]); var lowChunkData = GetMockChunkData(ids[1]); var expectedLv = new LightValue() { Sun = 0, Dynamic = 0 }; //Ground level is at 0, so the lower chunk will at first think it has no sunlight heightMapYValue = 0; //Generate first chunk RunLightingGeneration(ids[first]); lightManager.Update(); //Second chunk should not have sunlight yet var secondChunkData = GetMockChunkData(ids[second]); for (int z = 0; z < chunkDimensions.z; z++) { for (int y = 0; y < chunkDimensions.y; y++) { for (int x = 0; x < chunkDimensions.x; x++) { Assert.AreEqual(expectedLv, secondChunkData.GetLight(x, y, z), $"Light value not as expected for position {x},{y},{z} in second chunk"); } } } //Generate second chunk RunLightingGeneration(ids[second]); lightManager.Update(); var bottomNeigh = new ChunkNeighbourhood(lowChunkData, GetMockChunkData); //Debug.Log("TopSlice"); //PrintSlice(bottomNeigh, 15,false); //Debug.Log("BottomSlice"); //PrintSlice(bottomNeigh, 0, false); expectedLv = new LightValue() { Sun = maxIntensity, Dynamic = 0 }; for (int z = 0; z < chunkDimensions.z; z++) { for (int y = 0; y < chunkDimensions.y; y++) { for (int x = 0; x < chunkDimensions.x; x++) { Assert.AreEqual(expectedLv, upChunkData.GetLight(x, y, z), $"Light value not as expected for position {x},{y},{z} in upper chunk"); Assert.AreEqual(expectedLv, lowChunkData.GetLight(x, y, z), $"Light value not as expected for position {x},{y},{z} in lower chunk"); } } } }