private IEnumerator BuildBlocks(Chunk chunk, IncrementalTimer timer) { foreach (var builder in _blockBuilders) { var position = builder.Position; var blockType = BlockTypes.None; var featureToBuild = FeatureTypes.None; if (builder.IsFill) { builder.SetType(FillBlock); } blockType = builder.GetBlock(); featureToBuild = builder.GetFeature();; Block block = null; if (blockType != BlockTypes.None) { block = BlockLoader.CreateBlock(blockType, position); chunk.Register(block); } if (featureToBuild != FeatureTypes.None) { var feature = FeatureLoader.CreateFeature(featureToBuild, position); chunk.Register(feature); if (block != null) { feature.Assign(block); } feature.Assign(builder.Space); feature.Initialize(); } if (timer.CheckIncrement(Time.realtimeSinceStartup)) { yield return(null); timer.AdvanceIncrement(Time.realtimeSinceStartup); } } }
public Feature ToObject() => FeatureLoader.CreateFeature(_type, _position);