Esempio n. 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);
        }
        public static void PropagateClips(GBXFile file)
        {
            lock (ClipLock)
            {
                string defaultXmlFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\complex.xml";

                ComplexConversion complexConversion;
                var xmls = new XmlSerializer(typeof(ComplexConversion));

                using (var fs = new FileStream(defaultXmlFilePath, FileMode.Open))
                    complexConversion = (ComplexConversion)xmls.Deserialize(fs);

                //The Values in this loop can be adjusted
                foreach (var conversion in complexConversion.Conversions)
                {
                    if (conversion is BlockToItemConversion blockToItemConversion)
                    {
                        blockToItemConversion.PropagateClips(file, "AlpineRoadChaletSlopePillar", "AlpineChaletPillarClip");
                    }
                }

                using (var fs = new FileStream(defaultXmlFilePath + "l", FileMode.Create))
                    xmls.Serialize(fs, complexConversion);
            }
        }
 public override void Convert(GBXFile file)
 {
     foreach (var conversion in Conversions)
     {
         conversion.Convert(file);
     }
 }
        public static void CreateLog(GBXFile file, string filePath)
        {
            string logFilePath = filePath.Replace(".Challenge.Gbx", ".txt").Replace(".Gbx", ".txt");

            using var fs = new FileStream(logFilePath, FileMode.Create);
            using var sw = new StreamWriter(fs);
            file.DumpToFile(sw);
        }
Esempio n. 5
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);

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

            foreach (var block in ExtraBlocks)
            {
                blockChunk.Blocks.Add((Block)block.DeepClone());
            }
        }
        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);

            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;
                }
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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;
        }
Esempio n. 11
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();
        }
Esempio n. 12
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)
                        {
 private Converter(string inputFileName)
 {
     using var fs = new FileStream(inputFileName, FileMode.Open);
     file         = new GBXFile(fs);
 }
        public override void Convert(GBXFile file)
        {
            var blockChunk = (Challenge0304301F)file.GetChunk(Chunk.challenge0304301FKey);

            blockChunk.Blocks.Clear();
        }
 public abstract void Convert(GBXFile file);
        public override void Convert(GBXFile file)
        {
            var itemChunk = (Challenge03043040)file.GetChunk(Chunk.challenge03043040Key);

            itemChunk.Items.AddAll(ExtraItems);
        }
 public override void Convert(GBXFile file)
 {
     file.GridSize   = (GBXVec3)this.GridSize.DeepClone();
     file.GridOffset = (GBXVec3)this.GridOffset.DeepClone();
 }
        public override void Convert(GBXFile file)
        {
            var chunk0304300D = (Challenge0304300D)file.GetChunk(Chunk.challenge0304300DKey);

            chunk0304300D.Meta = (Meta)CarMeta.DeepClone();
        }