예제 #1
0
        public override void Convert(GBXFile file)
        {
            int itemCount = 0;

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

            var clipList = new List <(ClipData clipItemInfo, byte rot)> [GBXFile.MaxMapXSize, GBXFile.MaxMapYSize, GBXFile.MaxMapZSize];
        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);
                }
            }
        }
        public override void Convert(GBXFile file)
        {
            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);

            blockChunk.Version.Value = 6; //Adding Support for Custom Blocks

            foreach (var block in ExtraBlocks)
            {
                blockChunk.Blocks.Add((Block)block.DeepClone());
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
        public override void Convert(GBXFile file)
        {
            var commonChunk = (ChallengeCommon)file.GetChunk(Chunk.challengeCommonKey);

            commonChunk.UpdateToVersion11();
            commonChunk.TitleUID = (GBXLBS)TitleUID.DeepClone();

            var communityChunk = (ChallengeCommunity)file.GetChunk(Chunk.challengeCommunityKey);

            communityChunk.CommunityXml.Xml.Title = TitleUID.Content;

            var titlepackChunk = (Challenge03043051)file.GetChunk(Chunk.challenge03043051Key);

            if (titlepackChunk == null)
            {
                titlepackChunk = new Challenge03043051(false);
                file.AddBodyChunk(Chunk.challenge03043051Key, titlepackChunk);
            }

            titlepackChunk.TitlePack.Content = TitleUID.Content;
        }
예제 #6
0
        public override void Convert(GBXFile file)
        {
            var commonChunk   = (ChallengeCommon)file.GetChunk(Chunk.challengeCommonKey);
            var chunk0304301F = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);

            Decoration newDeco = null;
            var        oldDeco = chunk0304301F.DecorationMeta.ID.Content;

            foreach (var deco in Decos)
            {
                if (deco.Name == oldDeco)
                {
                    newDeco = deco;
                    break;
                }
            }
            if (newDeco == null)
            {
                throw new UnsupportedMapBaseException();
            }

            //Change data in common chunk
            commonChunk.TrackMeta.Collection = (GBXLBS)newDeco.Deco.Collection.DeepClone();
            commonChunk.DecorationMeta       = (Meta)newDeco.Deco.DeepClone();;

            //Change data in map chunk
            chunk0304301F.TrackMeta.Collection = (GBXLBS)newDeco.Deco.Collection.DeepClone();
            chunk0304301F.DecorationMeta       = (Meta)newDeco.Deco.DeepClone();

            //Adjust block Position
            if (newDeco.GridOffset != null)
            {
                file.Move(newDeco.GridOffset.X, newDeco.GridOffset.Y, newDeco.GridOffset.Z);
            }

            //Adjust map size
            chunk0304301F.MapSize = (GBXNat3)MapSize.DeepClone();
        }
        public override void Convert(GBXFile file)
        {
            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);

            foreach (var block in blockChunk.Blocks)
            {
                var blockName = block.BlockName.Content;

                if (_blockDict.ContainsKey(blockName))
                {
                    var blockToBlock = _blockDict[blockName];
                    block.BlockName = new GBXLBS(blockToBlock.NewName);
                    block.Coords.Y += blockToBlock.YOffset;
                }
            }
        }
예제 #8
0
        public override void Convert(GBXFile file)
        {
            int itemCount = 0;

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

            var pylonMap = new SortedSet <Pylon> [GBXFile.MaxMapXSize + 1, GBXFile.MaxMapZSize + 1, 2];

            foreach (var pylon in file.GetPylons(PylonType.Top))
            {
                var pylonField = pylonMap[pylon.X, pylon.Z, pylon.NormalizedRot] ??= new SortedSet <Pylon>(Pylon.GetComparer());
                pylonField.Add(pylon);
            }

            foreach (var pylon in file.GetPylons(PylonType.Bottom))
            {
                var pylonField = pylonMap[pylon.X, pylon.Z, pylon.NormalizedRot];
                pylonField?.Add(pylon);
            }

            foreach (var pylon in file.GetPylons(PylonType.Prevent))
            {
                var pylonField = pylonMap[pylon.X, pylon.Z, pylon.NormalizedRot];
                pylonField?.Add(pylon);
            }

            foreach (var pylonField in pylonMap)
            {
                if (pylonField != null)
                {
                    byte?topLeft = null, topRight = null;

                    foreach (var pylonInfo in pylonField)
                    {
                        switch (pylonInfo.Type, pylonInfo.Pos)
                        {
        public override void Convert(GBXFile file)
        {
            var chunk0304300D = (Challenge0304300D)file.GetChunk(Chunk.challenge0304300DKey);

            chunk0304300D.Meta = (Meta)CarMeta.DeepClone();
        }
        public override void Convert(GBXFile file)
        {
            var itemChunk = (Challenge03043040)file.GetChunk(Chunk.challenge03043040Key);

            itemChunk.Items.AddAll(ExtraItems);
        }
        public override void Convert(GBXFile file)
        {
            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);

            blockChunk.Blocks.Clear();
        }