예제 #1
0
        private bool ConvertBlock(GBXFile file, Block block, Challenge03043040 itemChunk)
        {
            bool isSecondaryTerrain;

            if (SecondaryTerrainFlag != null)
            {
                isSecondaryTerrain = file.TestFlag(SecondaryTerrainFlag.Name, block.Coords.X, block.Coords.Z);
            }
            else
            {
                isSecondaryTerrain = false;
            }

            var blockName = block.BlockName.Content;

            if (_blockNameDict.ContainsKey(blockName))
            {
                var blockData = _blockNameDict[blockName];
                var itemInfo  = blockData.GetItemInfo(new Identifier(block, isSecondaryTerrain));

                if (itemInfo != null)
                {
                    //Getting item data
                    itemInfo.PlaceRelToBlock(file, block, itemChunk, Collection, DefaultAuthor.Content);
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public override void Convert(GBXFile file)
        {
            int itemCount = 0;

            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);
            var itemChunk  = (Challenge03043040)file.GetChunk(Chunk.challenge03043040Key);

            if (itemChunk == null)
            {
                itemChunk = new Challenge03043040(false);
                file.AddBodyChunk(Chunk.challenge03043040Key, itemChunk);
            }

            foreach (var block in blockChunk.Blocks)
            {
                if (BlockIgnoreFlags != null)
                {
                    foreach (var blockIgnoreFlag in BlockIgnoreFlags)
                    {
                        if (file.TestFlag(blockIgnoreFlag.Name, block.Coords.X, block.Coords.Z))
                        {
                            goto nextBlock; // D: Goto?!? What a maniac.
                        }
                    }
                }

                //Block cannot not be ignored
                var success = ConvertBlock(file, block, itemChunk);
                if (success)
                {
                    itemCount++;
                }

                nextBlock :;
            }

            if (ItemCountStatistic != null)
            {
                file.AddStatistic(ItemCountStatistic.Name, itemCount);
            }
        }