public PrioritizedBufferStage(string name, int order, IChunkPipeline pipeline, Func <Vector3Int, float> priorityFunc ) : base(name, order, pipeline) { getPriority = priorityFunc; pipeline.OnChunkRemovedFromPipeline += WhenChunkRemovedFromPipeline; }
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; }
public GenerateTerrainStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline, maxInStage) { }
public WaitForJobStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline) { MaxInStage = maxInStage; }
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) { }
public GenerateStructuresStage(string name, int order, IChunkPipeline pipeline, int maxInStage) : base(name, order, pipeline, maxInStage) { }
public PassThroughApplyFunctionStage(string name, int stageId, IChunkPipeline pipeline, Action <Vector3Int> func) : base(name, stageId, pipeline) { this.func = func; }
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; }