コード例 #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)
        {
            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);
            var itemChunk  = (Challenge03043040)file.GetChunk(Chunk.challenge03043040Key);

            var mapXSize = blockChunk.MapSize.X;
            var mapZSize = blockChunk.MapSize.Z;

            var ignoredTiles = new bool[GBXFile.MaxMapXSize, GBXFile.MaxMapZSize];

            //Initializing ignoredTiles
            foreach (var blockIgnoreFlag in BlockIgnoreFlags)
            {
                for (int x = 0; x < GBXFile.MaxMapXSize; x++)
                {
                    for (int z = 0; z < GBXFile.MaxMapZSize; z++)
                    {
                        if (file.TestFlag(blockIgnoreFlag.Name, x, z))
                        {
                            ignoredTiles[x, z] = true;
                        }
                    }
                }
            }

            //Placing the ground on all other tiles
            for (byte x = 0; x < mapXSize; x++)
            {
                for (byte z = 0; z < mapZSize; z++)
                {
                    if (ignoredTiles[x, z])
                    {
                        continue;
                    }

                    //Tile not ignored
                    //ground item needs to be placed
                    byte height = 0;
                    if (HeightFlag != null)
                    {
                        height = file.GetFlag(HeightFlag.Name, x, z);
                    }

                    //Creating the item chunk
                    var itemInfo = GroundItem.GetItemInfo(new Identifier(null, 0, false, null));
                    itemInfo.PlaceAt(file, (x, (byte)(Height.Value + height), z), 0, itemChunk, Collection, DefaultAuthor.Content);
                }
            }
        }
コード例 #3
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);
            }
        }