Example #1
0
        internal static GameBox <CGameCtnChallenge> LoadGBX(string fileName, out TimeSpan?time)
        {
            time = null;

            Log.Write("Validating the GBX...");

            Log.Write();

            bool isMap = false;

            using (var fs = File.OpenRead(fileName))
                isMap = GameBox.ReadNodeType(fs) == typeof(GameBox <CGameCtnChallenge>);

            Log.Write();

            if (!isMap)
            {
                Log.Write("Not a map GBX!", ConsoleColor.Red);
                return(null);
            }

            Log.Write("This GBX is a map!", ConsoleColor.Green);

            Log.Write();

            var startMapLoad = DateTime.Now;

            var gbx = GameBox.Parse <CGameCtnChallenge>(fileName);

            if (gbx == null)
            {
                Log.Write("GBX failed to load!", ConsoleColor.Red);
                return(null);
            }

            time = DateTime.Now - startMapLoad;

            if (gbx.MainNode.Collection != "Island")
            {
                Log.Write("Not an Island map!", ConsoleColor.Red);
                return(null);
            }

            return(gbx);
        }