예제 #1
0
 public PrioritizedBufferStage(string name, int order,
                               IChunkPipeline pipeline,
                               Func <Vector3Int, float> priorityFunc
                               ) : base(name, order, pipeline)
 {
     getPriority = priorityFunc;
     pipeline.OnChunkRemovedFromPipeline += WhenChunkRemovedFromPipeline;
 }
예제 #2
0
 public AbstractPipelineStage(string name, int stageId, IChunkPipeline pipeline)
 {
     Name                     = name;
     StageID                  = stageId;
     MovingOnThisUpdate       = new HashSet <Vector3Int>();
     GoingBackwardsThisUpdate = new HashSet <Vector3Int>();
     this.pipeline            = pipeline;
 }
        public WaitForNeighboursStage(string name, int stageId, IChunkPipeline pipeline, bool includeDiagonals) : base(name, stageId, pipeline)
        {
            this.includeDiagonals = includeDiagonals;

            prevStageId = stageId - 1;

            waitEndedSet = new HashSet <Vector3Int>();

            pipeline.OnChunkAddedToPipeline      += WhenChunkAddedToPipeline;
            pipeline.OnChunkRemovedFromPipeline  += WhenChunkRemovedFromPipeline;
            pipeline.OnChunkMinStageDecreased    += WhenChunkMinStageDecreased;
            pipeline.OnChunkTargetStageDecreased += WhenChunkTargetStageDecreased;
        }
예제 #4
0
 public GenerateTerrainStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline, maxInStage)
 {
 }
예제 #5
0
 public WaitForJobStage(string name, int order, IChunkPipeline pipeline,
                        int maxInStage) : base(name, order, pipeline)
 {
     MaxInStage = maxInStage;
 }
예제 #6
0
 public GenerateLightsStage(string name, int order, IChunkPipeline pipeline, int maxInStage, ILightManager lightManager) : base(name, order, pipeline, maxInStage)
 {
     this.lightManager = lightManager;
 }
 public ApplyCollisionMeshStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline, maxInStage)
 {
 }
예제 #8
0
 public GenerateStructuresStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline, maxInStage)
 {
 }
예제 #9
0
 public PassThroughApplyFunctionStage(string name, int stageId, IChunkPipeline pipeline, Action <Vector3Int> func) : base(name, stageId, pipeline)
 {
     this.func = func;
 }
예제 #10
0
        private void SetupMocks(Vector3Int chunkDimensions, WorldSizeLimits worldSizeLimits = null, bool generateStructures = true)
        {
            if (worldSizeLimits == null)
            {
                worldSizeLimits = new WorldSizeLimits(false, 0);
                worldSizeLimits.Initalise();
            }


            mockManager = Substitute.For <IChunkManager>();
            mockManager.GenerateStructures.Returns(generateStructures);
            mockManager.WorldToChunkPosition(Arg.Any <Vector3>()).Returns(args => WorldToChunkPos((Vector3)args[0], chunkDimensions));

            mockManager.WorldLimits.Returns(worldSizeLimits);
            mockManager.GetAllLoadedChunkIds().Returns((_) => statusMap.Keys.ToArray());

            mockPipeline = Substitute.For <IChunkPipeline>();
            mockPipeline.TerrainDataStage.Returns(0);
            mockPipeline.OwnStructuresStage.Returns(1);
            mockPipeline.FullyGeneratedStage.Returns(2);
            mockPipeline.RenderedStage.Returns(3);
            mockPipeline.CompleteStage.Returns(4);

            statusMap = new Dictionary <Vector3Int, int>();

            //Mock set target to write to the status map instead
            mockManager
            .When(_ => _.SetTargetStageOfChunk(Arg.Any <Vector3Int>(), Arg.Any <int>(), Arg.Any <TargetUpdateMode>()))
            .Do(args =>
            {
                Vector3Int pos = (Vector3Int)args[0];
                int newStatus  = (int)args[1];
                var mode       = (TargetUpdateMode)args[2];

                if (statusMap.TryGetValue(pos, out var currentStatus))
                {    //If the pos exists, ensure update modes are respected
                    if (newStatus > currentStatus && mode.allowsUpgrade())
                    {
                        statusMap[pos] = newStatus;
                    }
                    else if (newStatus < currentStatus && mode.allowsDowngrade())
                    {
                        statusMap[pos] = newStatus;
                    }
                }
                else
                {    //Otherwise, add the new pos and status
                    statusMap[pos] = newStatus;
                }
            });

            //Mock deactivate to remove from the status map
            mockManager
            .When(_ => _.TryDeactivateChunk(Arg.Any <Vector3Int>()))
            .Do(args =>
            {
                Vector3Int pos = (Vector3Int)args[0];
                statusMap.Remove(pos);
            });

            player          = Substitute.For <IVoxelPlayer>();
            player.Position = Vector3.zero;
        }