Esempio n. 1
0
        public Block ToObject()
        {
            var block = BlockLoader.CreateBlock(_type, _position);

            block.Health    = _health;
            block.Stability = _stability;

            return(block);
        }
Esempio n. 2
0
        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);
                }
            }
        }