Beispiel #1
0
        public void Init(BlockCollection blocks, World world)
        {
            // Add all the block definitions defined in the config files
            ProcessConfigs(world, blocks.Blocks);

            // Build block type lookup table
            BlockTypes = new Block[configs.Length];
            for (int i = 0; i < configs.Length; i++)
            {
                BlockConfig config = configs[i];

                Block block = (Block)Activator.CreateInstance(config.BlockClass);
                block.Init((ushort)i, config);
                BlockTypes[i] = block;
            }

            // Once all blocks are set up, call OnInit on them. It is necessary to do it in a separate loop
            // in order to ensure there will be no dependency issues.
            for (int i = 0; i < BlockTypes.Length; i++)
            {
                Block block = BlockTypes[i];
                block.OnInit(this);
            }

            // Add block types from config
            foreach (BlockConfig configFile in configs)
            {
                configFile.OnPostSetUp(world);
            }
        }