Exemplo n.º 1
0
        public LevelBlueprint Parse(string fileName = "__root__")
        {
            _result = new LevelBlueprint();

            _scaleFactor  = 1f;
            _nextCannonID = 1;

            StartParse(fileName, content);

            _result.ValidOrThrow();

            return(_result);
        }
Exemplo n.º 2
0
        public LevelBlueprint CompileToBlueprint(GameHUD hud)
        {
            var bp = new LevelBlueprint();

            bp.UniqueID    = Guid.Parse($"b16b00b5-0001-4001-0000-{OnlineID:000000000000}");
            bp.WrapMode    = (byte)Geometry;
            bp.LevelWidth  = Width * 64;
            bp.LevelHeight = Height * 64;
            bp.LevelViewX  = CalculateViewCenter().X;
            bp.LevelViewY  = CalculateViewCenter().Y;
            bp.Name        = "0-" + OnlineID;
            bp.FullName    = Name;
            bp.KIType      = GetKIType();
            bp.CustomMusic = Music;

            byte cannonID = 0;

            foreach (var e in Elements)
            {
                e.InsertIntoBlueprint(bp, ref cannonID);
            }

            try
            {
                bp.ValidOrThrow();

                BlueprintPreprocessor.ProcessLevel(bp);

                return(bp);
            }
            catch (Exception e)
            {
                MonoSAMGame.CurrentInst.DispatchBeginInvoke(() =>
                {
                    hud.ShowToast("SCCMLD::CTB_1", L10N.T(L10NImpl.STR_LVLED_ERR_COMPILERERR), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f);
                    SAMLog.Error("SCMMLD_CTBERR", "LevelBlueprint compiled to invalid", $"Exception: {e}\n\n\nData: {SerializeToString()}");
                });
                return(null);
            }
        }