static private void ConvertTo(MultiSpline inSpline, GenType inType)
        {
            switch (inType)
            {
            case GenType.Simple:
                ConvertToSimple(inSpline);
                break;

            case GenType.Linear:
                ConvertToLinear(inSpline);
                break;

            case GenType.CSpline:
                ConvertToCSpline(inSpline);
                break;

            case GenType.Cardinal:
                ConvertToCardinal(inSpline);
                break;

            default:
                Debug.LogError("[MultiSpline] Type " + inType.ToString() + " not yet supported in editor.");
                return;
            }

            inSpline.m_Type  = inType;
            inSpline.m_Dirty = true;
        }
 public JavaFieldContext(string[] docStringLines, string idlName, string codeName, string getterName,
                         string setterName, bool required, GenType genType)
     : base(docStringLines, idlName, codeName, required, genType)
 {
     GetterName = getterName;
     SetterName = setterName;
 }
Exemple #3
0
    internal static ExtMoveArrayWrapper make_promotions(
        GenType Type,
        SquareT Delta,
        ExtMoveArrayWrapper moveList,
        SquareT to,
        CheckInfo ci)
    {
        if (Type == GenType.CAPTURES || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
        {
            (moveList).Add(Move.make(MoveType.PROMOTION, to - Delta, to, PieceType.QUEEN));
        }

        if (Type == GenType.QUIETS || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
        {
            (moveList).Add(Move.make(MoveType.PROMOTION, to - Delta, to, PieceType.ROOK));

            (moveList).Add(Move.make(MoveType.PROMOTION, to - Delta, to, PieceType.BISHOP));

            (moveList).Add(Move.make(MoveType.PROMOTION, to - Delta, to, PieceType.KNIGHT));
        }

        // Knight promotion is the only promotion that can give a direct check
        // that's not already included in the queen promotion.
        if (Type == GenType.QUIET_CHECKS && Bitboard.AndWithSquare(Utils.StepAttacksBB[Piece.W_KNIGHT, to], ci.ksq)!=0)
        {
            (moveList).Add(Move.make(MoveType.PROMOTION, to - Delta, to, PieceType.KNIGHT));
        }

        return moveList;
    }
 /// <summary>
 /// Checking of alowing field type for selected GenType.
 /// </summary>
 /// <param name="type">The type of field.</param>
 /// <param name="gtype">The type of generator.</param>
 /// <returns></returns>
 public bool isAllow(Fields.Type type, GenType gtype)
 {
     if (gtype == GenType.CppDefinitions && type == Fields.Type.Number)
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
        public GenType ConvertToGenType(BaijiType type, bool nullable)
        {
            var ocTypeName = ConvertToString(type, nullable);
            var baseType   = ((BaseType)type).BType;
            var gType      = GTYPE_BASETYPE_MAP[baseType];
            var genType    = new GenType(gType, ocTypeName);

            return(genType);
        }
Exemple #6
0
        /// <summary> Adds a new map generator to the list of generators. </summary>
        public static void Register(string theme, GenType type, MapGenFunc func, string desc)
        {
            MapGen gen = new MapGen()
            {
                Theme = theme, GenFunc = func, Desc = desc, Type = type
            };

            Generators.Add(gen);
        }
Exemple #7
0
        public static bool AreInputsSane()
        {
            if (Action == ActionType.Gen)
            {
                if (WhichGen == GenType.None)
                {
                    WhichGen = GenType.Division;
                }
                if (End == 0)
                {
                    End = Start + 100;
                }
                if (Start >= End)
                {
                    Log.Error("start must be smaller than end");
                    return(false);
                }
            }
            else if (Action == ActionType.Bits)
            {
                if (TargetSize != 0 && End != 0)
                {
                    Log.Warning("-l will not be used since -e is set");
                }
                if (TargetSize == 0 && End == 0)
                {
                    TargetSize = 1024;
                }
                if (String.IsNullOrWhiteSpace(OutputFile))
                {
                    Log.Error("an output file must be provided");
                    return(false);
                }
            }
            else if (Action == ActionType.BitsImg)
            {
                if (Dimensions.Width < 1 || Dimensions.Height < 1)
                {
                    Log.Error("invalid dimensions '" + Dimensions.Width + "," + Dimensions.Height + "'");
                    return(false);
                }
                //TODO figure out color depth for image based on BitsPerColor
            }
            else if (Enum.IsDefined(typeof(ActionType), Action))
            {
                //Nothing to do
            }
            else
            {
                Log.Error("invalid action specified");
                return(false);
            }

            return(true);
        }
Exemple #8
0
        public GenType ConvertToGenType(BaijiType type, bool nullable)
        {
            var javaTypeName = ConvertToString(type, nullable);

            var listType = type as ListType;
            var genType  = new GenType(GenType.Type.List, javaTypeName);

            genType.ElementType     = typeToOCConverter.ConvertToGenType(listType.Type, false);
            genType.ElementTypeName = typeToOCConverter.ConvertToString(listType.Type, false);
            return(genType);
        }
Exemple #9
0
    public ProceduralWorld(float minHeight, float maxHeight, int size, float detail, int seed, GenType type)
    {
        Debug.Log("Constructor of the World called.");

        this.minHeight = minHeight;
        this.maxHeight = maxHeight;
        this.size      = size;
        this.detail    = detail;
        this.seed      = seed;
        this.type      = type;
    }
Exemple #10
0
        private void genDataSel_Click(object sender, RoutedEventArgs e)
        {
            if ((codeType == CodeType.CLIENT && !checkPath(Properties.Settings.Default.cdataPath, "客户端数据目录")) ||
                (codeType == CodeType.SERVER && !checkPath(Properties.Settings.Default.sdataPath, "服务器数据目录")))
            {
                return;
            }

            selType = SelType.SEL;
            genType = GenType.DATA;
            start();
        }
Exemple #11
0
 public FieldContext(string[] docStringLines,
                     string idlName,
                     string codeName,
                     bool required,
                     GenType genType)
 {
     DocStringLines = docStringLines;
     IdlName        = idlName;
     CodeName       = codeName;
     Required       = required;
     GenType        = genType;
 }
Exemple #12
0
        // Only used for debug, so we can explicitly place test arguments into the set
#if DEBUG || PROFILING
        private static string GetArg(GenType genType)
        {
            foreach (var item in _argToTaskMap)
            {
                if (item.Value == genType)
                {
                    return(item.Key);
                }
            }

            throw new ArgumentException(nameof(GetArg) + ": No matching arg string found for genType");
        }
Exemple #13
0
        public GenType ConvertToGenType(BaijiType type, bool nullable)
        {
            var javaTypeName = ConvertToString(type, nullable);

            var mapType = type as MapType;
            var genType = new GenType(GenType.Type.Map, javaTypeName);

            genType.KeyType       = typeToOCConverter.ConvertToGenType(mapType.KeyType, false);
            genType.KeyTypeName   = typeToOCConverter.ConvertToString(mapType.KeyType, false);
            genType.ValueType     = typeToOCConverter.ConvertToGenType(mapType.ValueType, false);
            genType.ValueTypeName = typeToOCConverter.ConvertToString(mapType.ValueType, false);
            return(genType);
        }
Exemple #14
0
        private void genCodeAll_Click(object sender, RoutedEventArgs e)
        {
            if ((codeType == CodeType.CLIENT && (!checkPath(Properties.Settings.Default.ccodePath, "客户端代码目录") ||
                                                 !checkPath(Properties.Settings.Default.cscriptPath, "客户端脚本目录"))) ||
                (codeType == CodeType.SERVER && !checkPath(Properties.Settings.Default.scodePath, "服务器代码目录")))
            {
                return;
            }

            selType = SelType.ALL;
            genType = GenType.CODE;
            start();
        }
Exemple #15
0
        public static void RegisterGenerators()
        {
            const GenType type = GenType.Advanced;

            MapGen.Register("Billow", type, GenBillow2D, defHelp);
            MapGen.Register("RidgedMultifractal", type, GenRidged2D, defHelp);
            MapGen.Register("Perlin", type, GenPerlin2D, defHelp);
            MapGen.Register("Checkerboard", type, GenCheckerboard, "&HSeed does nothing");
            MapGen.Register("Voronoi", type, GenVoronoi, defHelp);
            MapGen.Register("Perlin3D", type, GenPerlin3D, defHelp);
            MapGen.Register("Perlin3Dyadjust", type, GenPerlin3DYAdjust, defHelp);
            MapGen.Register("Billow3D", type, GenBillow3D, defHelp);
        }
Exemple #16
0
        private void Btn_Generate_Coords(object sender, RoutedEventArgs e)
        {
            PositionElement ElemObject    = new PositionElement(GetDigit(object_entry_width), GetDigit(object_entry_height), GetDigit(object_entry_left), GetDigit(object_entry_top));
            PositionElement ElemEnclosing = new PositionElement(GetDigit(avail_entry_width), GetDigit(avail_entry_height), GetDigit(avail_entry_left), GetDigit(avail_entry_top));

            GenType typeSwitch = GetGenTypeRadioBtn(CoordButtonContainer);

            switch (typeSwitch)
            {
            case GenType.center:
            {
                Coordinate newCoords = ElemEnclosing - ElemObject;
                OutputBox.Text = "New Top Coord: " + newCoords.Y + Environment.NewLine + "New Left Coord: " + newCoords.X + Environment.NewLine;
                break;
            }

            case GenType.offset:
            {
                long     offset   = 0;
                Position position = GetPositionRadioBtn(SideButtonContainer);
                switch (position)
                {
                case Position.bottom:
                {
                    offset = Math.Abs((ElemEnclosing.Coords.Y + ElemEnclosing.Height) - (ElemObject.Coords.Y + ElemObject.Height));
                    break;
                }

                case Position.top:
                {
                    offset = Math.Abs(ElemEnclosing.Coords.Y - ElemObject.Coords.Y);
                    break;
                }

                case Position.left:
                {
                    offset = Math.Abs(ElemEnclosing.Coords.X - ElemObject.Coords.X);
                    break;
                }

                case Position.right:
                {
                    offset = Math.Abs((ElemEnclosing.Coords.X + ElemEnclosing.Width) - (ElemObject.Coords.X + ElemObject.Width));
                    break;
                }
                }
                OutputBox.Text = position.ToString() + " offset: " + offset.ToString();
                break;
            }
            }
        }
Exemple #17
0
    public static int Main(String [] args)
    {
#if ADD_STRUCT_CONSTRAINT
        GenType <S> g = new GenType <S>();
        Console.WriteLine(Type.GetType("System.IComparable`1[GenType`1[S]]"));
#else
        GenType <C> g = new GenType <C>();
        Console.WriteLine(Type.GetType("System.IComparable`1[GenType`1[C]]"));
#endif
        g.foo();

        Console.WriteLine("PASS");

        return(100);
    }
 public FieldContext(string name,
     short id,
     string csharpName,
     string csharpPropertyName,
     bool required,
     GenType genType)
 {
     Name = name;
     Id = id;
     //CSharpType = csharpType;
     CSharpName = csharpName;
     CSharpPropertyName = csharpPropertyName;
     Required = required;
     GenType = genType;
 }
 public FieldContext(string name,
     short id,
     string javaName,
     string javaSetterName,
     string javaGetterName,
     bool required,
     GenType genType)
 {
     Name = name;
     Id = id;
     JavaName = javaName;
     JavaSetterName = javaSetterName;
     JavaGetterName = javaGetterName;
     Required = required;
     GenType = genType;
 }
Exemple #20
0
 public static int TestEntryPoint()
 {
     try
     {
         GenType <string> o = new GenType <string>();
         o.foo();
         Console.WriteLine("Test SUCCESS");
         return(100);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         Console.WriteLine("Test FAILED");
         return(666);
     }
 }
Exemple #21
0
        public static void RegisterGenerators()
        {
            const GenType type = GenType.Simple;

            MapGen.Register("Island", type, GenIsland, defHelp);
            MapGen.Register("Mountains", type, GenMountains, defHelp);
            MapGen.Register("Forest", type, GenForest, defHelp);
            MapGen.Register("Ocean", type, GenOcean, defHelp);
            MapGen.Register("Flat", type, GenFlat, "&HSeed specifies grass height (default half of level height)");
            MapGen.Register("Pixel", type, GenPixel, "&HSeed does nothing");
            MapGen.Register("Empty", type, GenEmpty, "&HSeed does nothing");
            MapGen.Register("Desert", type, GenDesert, defHelp);
            MapGen.Register("Space", type, GenSpace, defHelp);
            MapGen.Register("Rainbow", type, GenRainbow, defHelp);
            MapGen.Register("Hell", type, GenHell, defHelp);
        }
Exemple #22
0
 public FieldContext(string[] docStringLines,
                     string name,
                     short id,
                     string csharpName,
                     string csharpPropertyName,
                     bool required,
                     GenType genType)
 {
     DocStringLines = docStringLines;
     Name           = name;
     Id             = id;
     //CSharpType = csharpType;
     CSharpName         = csharpName;
     CSharpPropertyName = csharpPropertyName;
     Required           = required;
     GenType            = genType;
 }
Exemple #23
0
        public static async Task HandleGenerateAsync(int year, int day, string path, GenType genType)
        {
            switch (genType)
            {
            case GenType.Readme:
                await GenerateReadmeAsync(year, day, path);

                break;

            case GenType.Input:
                await GenerateInputAsync(year, day, path);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(genType), genType, null);
            }
        }
Exemple #24
0
 public FieldContext(string[] docStringLines,
                     string name,
                     short id,
                     string javaName,
                     string javaSetterName,
                     string javaGetterName,
                     bool required,
                     GenType genType)
 {
     DocStringLines = docStringLines;
     Name           = name;
     Id             = id;
     JavaName       = javaName;
     JavaSetterName = javaSetterName;
     JavaGetterName = javaGetterName;
     Required       = required;
     GenType        = genType;
 }
Exemple #25
0
        private void genCodeSel_Click(object sender, RoutedEventArgs e)
        {
            if ((codeType == CodeType.CLIENT && !checkPath(Properties.Settings.Default.ccodePath, "客户端代码目录")) ||
                (codeType == CodeType.SERVER && !checkPath(Properties.Settings.Default.scodePath, "服务器代码目录")))
            {
                return;
            }

            if (codeType == CodeType.CLIENT &&
                getSheetOutType(selectedArg.sheetName) == COutType.BOLO &&
                !checkPath(Properties.Settings.Default.cscriptPath, "客户端脚本目录"))
            {
                return;
            }

            selType = SelType.SEL;
            genType = GenType.CODE;
            start();
        }
Exemple #26
0
        public void Replen(CommandArgs args)
        {
            GenType type    = GenType.ore;
            int     amount  = -1;
            ushort  oretype = 0;
            int     counter = 0;

            if (args.Parameters.Count >= 2 && Enum.TryParse <GenType>(args.Parameters[0], true, out type) && int.TryParse(args.Parameters[1], out amount))
            {
                if (type == GenType.ore)
                {
                    if (args.Parameters.Count < 3)
                    {
                        args.Player.SendErrorMessage("Please enter a valid ore type.");
                        return;
                    }
                    var obj = new Terraria.ID.TileID();
                    try { oretype = (ushort)obj.GetType().GetField(args.Parameters[2].FirstCharToUpper()).GetValue(obj); }
                    catch (ArgumentException) { args.Player.SendErrorMessage("Please enter a valid ore type."); }
                }
                else if (type == GenType.trees)
                {
                    if (args.Parameters.Count >= 3)
                    {
                        args.Player.SendInfoMessage("CAUTION: The number entered is not the number of trees total. It refers to the number of batches of trees to generate.");
                    }
                }
                if (PrivateReplenisher(type, amount, out counter, oretype, args))
                {
                    args.Player.SendInfoMessage(type.ToString().FirstCharToUpper() + " generated successfully.");
                    return;
                }
                args.Player.SendErrorMessage("Failed to generate all the " + type.ToString() + ". Generated " + counter + " " + type.ToString() + ".");
            }
            else
            {
                args.Player.SendErrorMessage("Incorrect usage. Correct usage: /replen <ore|chests|pots|lifecrystals|altars|trees|floatingisland> <amount> (oretype)\r\nNote: when generating trees, the amount is in batches not specific trees.");
            }
        }
Exemple #27
0
 public CSharpFieldContext(string idlName, GenType genType) : base(idlName, genType)
 {
 }
Exemple #28
0
 public CSharpFieldContext(string[] docStringLines, string idlName, string codeName,
                           string propertyName, bool required, GenType genType)
     : base(docStringLines, idlName, codeName, required, genType)
 {
     PropertyName = propertyName;
 }
 public JavaFieldContext(string idlName, GenType genType) : base(idlName, genType)
 {
 }
Exemple #30
0
    internal void score(GenType Type)
    {
        switch (Type)
        {
            case GenType.CAPTURES:
                score_CAPTURES();
                return;
            case GenType.EVASIONS:
                score_EVASIONS();
                return;
            case GenType.QUIETS:
                score_QUIETS();
                return;
        }

        Debug.Assert(false);
    }
 private void BuildSerializeMapElement(StringBuilder sb, GenType genType, string iter, string map)
 {
     var kField = new FieldContext(iter, genType.KeyType);
     BuildSerializeField(sb, kField, "", true);
     var vField = new FieldContext(map + "[" + iter + "]", genType.ValueType);
     BuildSerializeField(sb, vField, "", true);
 }
Exemple #32
0
    internal static ExtMoveArrayWrapper generate_all(
        ColorT Us,
        GenType Type,
        Position pos,
        ExtMoveArrayWrapper moveList,
        BitboardT target,
        CheckInfo ci = null)
    {
        var Checks = Type == GenType.QUIET_CHECKS;

        moveList = generate_pawn_moves(Us, Type, pos, moveList, target, ci);
        moveList = generate_moves(PieceType.KNIGHT, Checks, pos, moveList, Us, target, ci);
        moveList = generate_moves(PieceType.BISHOP, Checks, pos, moveList, Us, target, ci);
        moveList = generate_moves(PieceType.ROOK, Checks, pos, moveList, Us, target, ci);
        moveList = generate_moves(PieceType.QUEEN, Checks, pos, moveList, Us, target, ci);

        if (Type != GenType.QUIET_CHECKS && Type != GenType.EVASIONS)
        {
            var ksq = pos.square(PieceType.KING, Us);
            var b = pos.attacks_from_PtS(PieceType.KING, ksq) & target;
            while (b != 0)
            {
                (moveList).Add(Move.make_move(ksq, Utils.pop_lsb(ref b)));
            }
        }

        if (Type != GenType.CAPTURES && Type != GenType.EVASIONS && pos.can_castle(Us) != 0)
        {
            if (pos.is_chess960())
            {
                moveList = generate_castling(
                    MakeCastling(Us, CastlingSide.KING_SIDE),
                    Checks,
                    true,
                    pos,
                    moveList,
                    Us,
                    ci);
                moveList = generate_castling(
                    MakeCastling(Us, CastlingSide.QUEEN_SIDE),
                    Checks,
                    true,
                    pos,
                    moveList,
                    Us,
                    ci);
            }
            else
            {
                moveList = generate_castling(
                    MakeCastling(Us, CastlingSide.KING_SIDE),
                    Checks,
                    false,
                    pos,
                    moveList,
                    Us,
                    ci);
                moveList = generate_castling(
                    MakeCastling(Us, CastlingSide.QUEEN_SIDE),
                    Checks,
                    false,
                    pos,
                    moveList,
                    Us,
                    ci);
            }
        }

        return moveList;
    }
Exemple #33
0
    internal static ExtMoveArrayWrapper generate_pawn_moves(
        ColorT Us,
        GenType Type,
        Position pos,
        ExtMoveArrayWrapper moveList,
        BitboardT target,
        CheckInfo ci)
    {
        // Compute our parametrized parameters at compile time, named according to
        // the point of view of white side.
        var Them = (Us == Color.WHITE ? Color.BLACK : Color.WHITE);
        var TRank8BB = (Us == Color.WHITE ? Bitboard.Rank8BB : Bitboard.Rank1BB);
        var TRank7BB = (Us == Color.WHITE ? Bitboard.Rank7BB : Bitboard.Rank2BB);
        var TRank3BB = (Us == Color.WHITE ? Bitboard.Rank3BB : Bitboard.Rank6BB);
        var Up = (Us == Color.WHITE ? Square.DELTA_N : Square.DELTA_S);
        var Right = (Us == Color.WHITE ? Square.DELTA_NE : Square.DELTA_SW);
        var Left = (Us == Color.WHITE ? Square.DELTA_NW : Square.DELTA_SE);

        var emptySquares = Bitboard.Create(0);

        var pawnsOn7 = pos.pieces_CtPt(Us, PieceType.PAWN) & TRank7BB;
        var pawnsNotOn7 = pos.pieces_CtPt(Us, PieceType.PAWN) & ~TRank7BB;

        var enemies = (Type == GenType.EVASIONS
            ? pos.pieces_Ct(Them) & target
            : Type == GenType.CAPTURES ? target : pos.pieces_Ct(Them));

        // Single and double pawn pushes, no promotions
        if (Type != GenType.CAPTURES)
        {
            emptySquares = (Type == GenType.QUIETS || Type == GenType.QUIET_CHECKS ? target : ~pos.pieces());

            var b1 = Bitboard.shift_bb(Up, pawnsNotOn7) & emptySquares;
            var b2 = Bitboard.shift_bb(Up, b1 & TRank3BB) & emptySquares;

            if (Type == GenType.EVASIONS) // Consider only blocking squares
            {
                b1 &= target;
                b2 &= target;
            }

            if (Type == GenType.QUIET_CHECKS)
            {
                b1 &= pos.attacks_from_PS(PieceType.PAWN, ci.ksq, Them);
                b2 &= pos.attacks_from_PS(PieceType.PAWN, ci.ksq, Them);

                // Add pawn pushes which give discovered check. This is possible only
                // if the pawn is not on the same file as the enemy king, because we
                // don't generate captures. Note that a possible discovery check
                // promotion has been already generated amongst the captures.
                if ((pawnsNotOn7 & ci.dcCandidates) != 0)
                {
                    var dc1 = Bitboard.shift_bb(Up, pawnsNotOn7 & ci.dcCandidates) & emptySquares
                              & ~Utils.file_bb_St(ci.ksq);
                    var dc2 = Bitboard.shift_bb(Up, dc1 & TRank3BB) & emptySquares;

                    b1 |= dc1;
                    b2 |= dc2;
                }
            }

            while (b1 != 0)
            {
                var to = Utils.pop_lsb(ref b1);
                (moveList).Add(Move.make_move(to - Up, to));
            }

            while (b2 != 0)
            {
                var to = Utils.pop_lsb(ref b2);
                (moveList).Add(Move.make_move(to - Up - Up, to));
            }
        }

        // Promotions and underpromotions
        if (pawnsOn7 != 0 && (Type != GenType.EVASIONS || ((target & TRank8BB) != 0)))
        {
            if (Type == GenType.CAPTURES)
            {
                emptySquares = ~pos.pieces();
            }

            if (Type == GenType.EVASIONS)
            {
                emptySquares &= target;
            }

            var b1 = Bitboard.shift_bb(Right, pawnsOn7) & enemies;
            var b2 = Bitboard.shift_bb(Left, pawnsOn7) & enemies;
            var b3 = Bitboard.shift_bb(Up, pawnsOn7) & emptySquares;

            while (b1 != 0)
            {
                moveList = make_promotions(Type, Right, moveList, Utils.pop_lsb(ref b1), ci);
            }

            while (b2 != 0)
            {
                moveList = make_promotions(Type, Left, moveList, Utils.pop_lsb(ref b2), ci);
            }

            while (b3 != 0)
            {
                moveList = make_promotions(Type, Up, moveList, Utils.pop_lsb(ref b3), ci);
            }
        }

        // Standard and en-passant captures
        if (Type == GenType.CAPTURES || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
        {
            var b1 = Bitboard.shift_bb(Right, pawnsNotOn7) & enemies;
            var b2 = Bitboard.shift_bb(Left, pawnsNotOn7) & enemies;

            while (b1 != 0)
            {
                var to = Utils.pop_lsb(ref b1);
                (moveList).Add(Move.make_move(to - Right, to));
            }

            while (b2 != 0)
            {
                var to = Utils.pop_lsb(ref b2);
                (moveList).Add(Move.make_move(to - Left, to));
            }

            if (pos.ep_square() != Square.SQ_NONE)
            {
                Debug.Assert(Square.rank_of(pos.ep_square()) == Rank.relative_rank_CtRt(Us, Rank.RANK_6));

                // An en passant capture can be an evasion only if the checking piece
                // is the double pushed pawn and so is in the target. Otherwise this
                // is a discovery check and we are forced to do otherwise.
                if (Type == GenType.EVASIONS && Bitboard.AndWithSquare(target, (pos.ep_square() - Up))==0)
                {
                    return moveList;
                }

                b1 = pawnsNotOn7 & pos.attacks_from_PS(PieceType.PAWN, pos.ep_square(), Them);

                Debug.Assert(b1 != 0);

                while (b1 != 0)
                {
                    (moveList).Add(Move.make(MoveType.ENPASSANT, Utils.pop_lsb(ref b1), pos.ep_square()));
                }
            }
        }

        return moveList;
    }
Exemple #34
0
 static string FilterThemes(GenType type)
 {
     return(Generators.Join(g => g.Type == type ? g.Theme : null));
 }
Exemple #35
0
 public FieldContext(string name, GenType genType)
 {
     Name    = name;
     GenType = genType;
 }
        private void BuildDeserializeContainer(StringBuilder sb, GenType genType, string prefix = "")
        {
            ScopeUp(sb);

            string obj;

            if (genType.IsMap)
            {
                obj = Tmp("_map");
            }
            else if (genType.IsSet)
            {
                obj = Tmp("_set");
            }
            else
            {
                obj = Tmp("_list");
            }

            sb.Indent(level).Append(prefix).Append(" = new ").Append(genType.CSharpTypeName).Append("();").AppendLine();
            if (genType.IsMap)
            {
                sb.Indent(level).Append("TMap ").Append(obj).Append(" = iprot.ReadMapBegin();").AppendLine();
            }
            else if (genType.IsSet)
            {
                sb.Indent(level).Append("TSet ").Append(obj).Append(" = iprot.ReadSetBegin();").AppendLine();
            }
            else
            {
                sb.Indent(level).Append("TList ").Append(obj).Append(" = iprot.ReadListBegin();").AppendLine();
            }

            string i = Tmp("_i");
            sb.Indent(level).Append("for(int ").Append(i).Append(" = 0; ").Append(i).Append(" < ").Append(obj).Append(".Count").Append("; ").Append("++").Append(i).Append(")").AppendLine();
            ScopeUp(sb);

            if (genType.IsMap)
            {
                BuildDeserializeMapElement(sb, genType, prefix);
            }
            else if (genType.IsSet)
            {
                BuildDeserializeSetElement(sb, genType, prefix);
            }
            else if (genType.IsList)
            {
                BuildDeserializeListElement(sb, genType, prefix);
            }

            ScopeDown(sb);

            if (genType.IsMap)
            {
                sb.Indent(level).Append("iprot.ReadMapEnd();").AppendLine();
            }
            else if (genType.IsSet)
            {
                sb.Indent(level).Append("iprot.ReadSetEnd();").AppendLine();
            }
            else if (genType.IsList)
            {
                sb.Indent(level).Append("iprot.ReadListEnd();").AppendLine();
            }

            ScopeDown(sb);
        }
Exemple #37
0
        private static void generate_pawn_moves(
            int Us,
            GenType Type,
            Position pos,
            MoveStack[] ms,
            ref int mpos,
            ulong target,
            CheckInfo ci)
        {
            // Compute our parametrized parameters at compile time, named according to
            // the point of view of white side.
            var Them = (Us == ColorC.WHITE ? ColorC.BLACK : ColorC.WHITE);
            var TRank8BB = (Us == ColorC.WHITE ? Constants.Rank8BB : Constants.Rank1BB);
            var TRank7BB = (Us == ColorC.WHITE ? Constants.Rank7BB : Constants.Rank2BB);
            var TRank3BB = (Us == ColorC.WHITE ? Constants.Rank3BB : Constants.Rank6BB);
            var UP = (Us == ColorC.WHITE ? SquareC.DELTA_N : SquareC.DELTA_S);
            var RIGHT = (Us == ColorC.WHITE ? SquareC.DELTA_NE : SquareC.DELTA_SW);
            var LEFT = (Us == ColorC.WHITE ? SquareC.DELTA_NW : SquareC.DELTA_SE);

            ulong b1, b2, dc1, dc2, emptySquares = 0;
            int to;

            var pawnsOn7 = (pos.byTypeBB[PieceTypeC.PAWN] & pos.byColorBB[Us]) & TRank7BB;
            var pawnsNotOn7 = (pos.byTypeBB[PieceTypeC.PAWN] & pos.byColorBB[Us]) & ~TRank7BB;

            var enemies = (Type == GenType.EVASIONS
                               ? pos.byColorBB[Them] & target
                               : Type == GenType.CAPTURES ? target : pos.byColorBB[Them]);

            // Single and double pawn pushes, no promotions
            if (Type != GenType.CAPTURES)
            {
                emptySquares = (Type == GenType.QUIETS ? target : ~pos.occupied_squares);

                b1 = move_pawns(UP, pawnsNotOn7) & emptySquares;
                b2 = move_pawns(UP, b1 & TRank3BB) & emptySquares;

                if (Type == GenType.EVASIONS) // Consider only blocking squares
                {
                    b1 &= target;
                    b2 &= target;
                }

                if (Type == GenType.QUIET_CHECKS)
                {
                    b1 &= Utils.StepAttacksBB[((Them << 3) | PieceTypeC.PAWN)][ci.ksq];
                    b2 &= Utils.StepAttacksBB[((Them << 3) | PieceTypeC.PAWN)][ci.ksq];

                    // Add pawn pushes which give discovered check. This is possible only
                    // if the pawn is not on the same file as the enemy king, because we
                    // don't generate captures. Note that a possible discovery check
                    // promotion has been already generated among captures.
                    if ((pawnsNotOn7 & ci.dcCandidates) != 0) // Target is dc bitboard
                    {
                        dc1 = move_pawns(UP, pawnsNotOn7 & ci.dcCandidates) & emptySquares & ~(Utils.FileBB[ci.ksq & 7]);
                        dc2 = move_pawns(UP, dc1 & TRank3BB) & emptySquares;

                        b1 |= dc1;
                        b2 |= dc2;
                    }
                }

                while (b1 != 0)
                {
                    to = Utils.pop_lsb(ref b1);
                    ms[mpos++].move = (to | ((to - UP) << 6));
                }
                while (b2 != 0)
                {
                    to = Utils.pop_lsb(ref b2);
                    ms[mpos++].move = (to | ((to - UP - UP) << 6));
                }
            }

            // Promotions and underpromotions
            if ((pawnsOn7 != 0) && (Type != GenType.EVASIONS || ((target & TRank8BB) != 0)))
            {
                if (Type == GenType.CAPTURES)
                {
                    emptySquares = ~pos.occupied_squares;
                }

                if (Type == GenType.EVASIONS)
                {
                    emptySquares &= target;
                }

                generate_promotions(Type, RIGHT, ms, ref mpos, pawnsOn7, enemies, ci);
                generate_promotions(Type, LEFT, ms, ref mpos, pawnsOn7, enemies, ci);
                generate_promotions(Type, UP, ms, ref mpos, pawnsOn7, emptySquares, ci);
            }

            // Standard and en-passant captures
            if (Type == GenType.CAPTURES || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
            {
                b1 = move_pawns(RIGHT, pawnsNotOn7) & enemies;
                b2 = move_pawns(LEFT, pawnsNotOn7) & enemies;

                while (b1 != 0)
                {
                    to = Utils.pop_lsb(ref b1);
                    ms[mpos++].move = (to | ((to - RIGHT) << 6));
                }
                while (b2 != 0)
                {
                    to = Utils.pop_lsb(ref b2);
                    ms[mpos++].move = (to | ((to - LEFT) << 6));
                }

                if (pos.st.epSquare != SquareC.SQ_NONE)
                {
                    Debug.Assert(Utils.rank_of(pos.st.epSquare) == Utils.relative_rank_CR(Us, RankC.RANK_6));

                    // An en passant capture can be an evasion only if the checking piece
                    // is the double pushed pawn and so is in the target. Otherwise this
                    // is a discovery check and we are forced to do otherwise.
                    if (Type == GenType.EVASIONS && (((target & Utils.SquareBB[pos.st.epSquare - UP]) == 0)))
                    {
                        return;
                    }

                    b1 = pawnsNotOn7 & Utils.StepAttacksBB[((Them << 3) | PieceTypeC.PAWN)][pos.st.epSquare];

                    Debug.Assert(b1 != 0);

                    while (b1 != 0)
                    {
                        ms[mpos++].move = Utils.make(Utils.pop_lsb(ref b1), pos.st.epSquare, MoveTypeC.ENPASSANT);
                    }
                }
            }
        }
Exemple #38
0
        private static void generate_all(
            GenType type,
            Position pos,
            MoveStack[] mlist,
            ref int mpos,
            int us,
            ulong target,
            CheckInfo ci)
        {
            var Checks = type == GenType.QUIET_CHECKS;

            generate_pawn_moves(us, type, pos, mlist, ref mpos, target, ci);

            generate_moves(PieceTypeC.KNIGHT, Checks, pos, mlist, ref mpos, us, target, ci);
            generate_moves(PieceTypeC.BISHOP, Checks, pos, mlist, ref mpos, us, target, ci);
            generate_moves(PieceTypeC.ROOK, Checks, pos, mlist, ref mpos, us, target, ci);
            generate_moves(PieceTypeC.QUEEN, Checks, pos, mlist, ref mpos, us, target, ci);

            if (!Checks && type != GenType.EVASIONS)
            {
                Square from = pos.king_square(us);
                Bitboard b = Position.attacks_from_KING(from) & target;
                // SERIALIZE(b);
                while (b != 0)
                {
#if X64
                    Bitboard bb = b;
                    b &= (b - 1);
                 mlist[mpos++].move = ((Utils.BSFTable[((bb & (0xffffffffffffffff - bb + 1)) * DeBruijn_64) >> 58]) | (from << 6));
#else
                    mlist[mpos++].move = Utils.make_move(from, Utils.pop_lsb(ref b));
#endif
                }
            }
            
            if (type != GenType.CAPTURES && type != GenType.EVASIONS && pos.can_castle_C(us) != 0)
            {
                generate_castle(CastlingSideC.KING_SIDE, Checks, pos, mlist, ref mpos, us);
                generate_castle(CastlingSideC.QUEEN_SIDE, Checks, pos, mlist, ref mpos, us);
            }
        }
Exemple #39
0
        private bool PrivateReplenisher(GenType type, int amount, ushort oretype = 0, CommandArgs args = null)
        {
            int counter = 0;
            bool success;
            for (int i = 0; i < TIMEOUT; i++)
            {
                success = false;
                int xRandBase = WorldGen.genRand.Next(1, Main.maxTilesX);
                int y = 0;
                switch (type)
                {
                    case GenType.ore:
                        y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        if (oretype != Terraria.ID.TileID.Hellstone)
                            WorldGen.OreRunner(xRandBase, y, 2.0, amount, oretype);
                        else
                            WorldGen.OreRunner(xRandBase, WorldGen.genRand.Next((int)(Main.maxTilesY) - 200, Main.maxTilesY), 2.0, amount, oretype);
                        success = true;
                        break;
                    case GenType.chests:
                        if (amount == 0)
                        {
                            int tmpEmpty = 0, empty = 0;
                            for (int x = 0; x < 1000; x++)
                            {
                                if (Main.chest[x] != null)
                                {
                                    tmpEmpty++;
                                    bool found = false;
                                    foreach (Item itm in Main.chest[x].item)
                                        if (itm.netID != 0)
                                            found = true;
                                    if (found == false)
                                    {
                                        empty++;
                                        WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false);
                                        Main.chest[x] = null;

                                    }

                                }

                            }
                            args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty);
                            return true;
                        }
                        y = WorldGen.genRand.Next((int)(Main.worldSurface) - 200, Main.maxTilesY);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        success = WorldGen.AddBuriedChest(xRandBase, y);
                        break;
                    case GenType.pots:
                        y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        success = WorldGen.PlacePot(xRandBase, y);
                        break;
                    case GenType.lifecrystals:
                        y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        success = WorldGen.AddLifeCrystal(xRandBase, y);
                        break;
                    case GenType.altars:
                        y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        WorldGen.Place3x2(xRandBase, y, 26);
                        success = Main.tile[xRandBase, y].type == 26;
                        break;
                    case GenType.trees:
                        WorldGen.AddTrees();
                        success = true;
                        break;
                    case GenType.floatingisland:
                        y = WorldGen.genRand.Next((int)Main.worldSurface + 175, (int)Main.worldSurface + 300);
                        if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                        {
                            success = false;
                            break;
                        }
                        WorldGen.FloatingIsland(xRandBase, y);
                        success = true;
                        break;
                    case GenType.pyramids:
                        //TODO
                        break;
                }
                if (success)
                {
                    counter++;
                    if (counter >= amount)
                        return true;
                }
            }
            return false;
        }
Exemple #40
0
 public FieldContext(string idlName, GenType genType)
 {
     IdlName = idlName;
     GenType = genType;
 }
 public FieldContext(string name, GenType genType)
 {
     Name = name;
     GenType = genType;
 }
Exemple #42
0
    internal static ExtMoveArrayWrapper generate(GenType Type, Position pos, ExtMoveArrayWrapper moveList)
    {
        switch (Type)
        {
            case GenType.EVASIONS:
                return generate_EVASIONS(pos, moveList);
            case GenType.LEGAL:
                return generate_LEGAL(pos, moveList);
            case GenType.QUIET_CHECKS:
                return generate_QUIET_CHECKS(pos, moveList);
        }

        Debug.Assert(Type == GenType.CAPTURES || Type == GenType.QUIETS || Type == GenType.NON_EVASIONS);
        Debug.Assert(pos.checkers() == 0);

        var us = pos.side_to_move();

        var target = Type == GenType.CAPTURES
            ? pos.pieces_Ct(Color.opposite(us))
            : Type == GenType.QUIETS
                ? ~pos.pieces()
                : Type == GenType.NON_EVASIONS ? ~pos.pieces_Ct(us) : Bitboard.Create(0);

        return us == Color.WHITE
            ? generate_all(Color.WHITE, Type, pos, moveList, target)
            : generate_all(Color.BLACK, Type, pos, moveList, target);
    }
        private void BuildDeserializeMapElement(StringBuilder sb, GenType mapType, string prefix = "")
        {
            string key = Tmp("_key");
            string val = Tmp("_val");

            var fkey = new FieldContext(key, mapType.KeyType);
            var fval = new FieldContext(val, mapType.ValueType);

            sb.Indent(level).Append(DeclareField(fkey)).AppendLine();
            sb.Indent(level).Append(DeclareField(fval)).AppendLine();

            BuildDeserializeField(sb, fkey);
            BuildDeserializeField(sb, fval);

            sb.Indent(level).Append(prefix).Append("[").Append(key).Append("] = ").Append(val).Append(";").AppendLine();
        }
        private void BuildSerializeContainer(StringBuilder sb, string prefix, GenType genType)
        {
            ScopeUp(sb);

            if (genType.IsMap)
            {
                sb.Indent(level).Append("oprot.WriteMapBegin(new TMap(").Append(genType.KeyType.TTypeName).Append(", ");
                sb.Append(genType.ValueType.TTypeName).Append(", ").Append(prefix).Append(".Count));").AppendLine();
            }
            else if (genType.IsSet)
            {
                sb.Indent(level).Append("oprot.WriteSetBegin(new TSet(").Append(genType.ElementType.TTypeName).Append(", ");
                sb.Append(prefix).Append(".Count));").AppendLine();
            }
            else if (genType.IsList)
            {
                sb.Indent(level).Append("oprot.WriteListBegin(new TList(").Append(genType.ElementType.TTypeName).Append(", ");
                sb.Append(prefix).Append(".Count));").AppendLine();
            }

            string iter = Tmp("_iter");
            if (genType.IsMap)
            {
                sb.Indent(level).Append("foreach (").Append(genType.KeyType.CSharpTypeName).Append(" ").Append(iter).Append(" in ").Append(prefix).Append(".Keys)").AppendLine();
            }
            else if (genType.IsSet || genType.IsList)
            {
                sb.Indent(level).Append("foreach (").Append(genType.ElementType.CSharpTypeName).Append(" ").Append(iter).Append(" in ").Append(prefix).Append(")").AppendLine();
            }

            ScopeUp(sb);

            if (genType.IsMap)
            {
                BuildSerializeMapElement(sb, genType, iter, prefix);
            }
            else if (genType.IsSet)
            {
                BuildSerializeSetElement(sb, genType, iter);
            }
            else if (genType.IsList)
            {
                BuildSerializeListElement(sb, genType, iter);
            }

            ScopeDown(sb);

            if (genType.IsMap)
            {
                sb.Indent(level).AppendLine("oprot.WriteMapEnd();");
            }
            else if (genType.IsSet)
            {
                sb.Indent(level).AppendLine("oprot.WriteSetEnd();");
            }
            else if (genType.IsList)
            {
                sb.Indent(level).AppendLine("oprot.WriteListEnd();");
            }

            ScopeDown(sb);
        }
Exemple #45
0
 /// <summary>
 /// Checking of alowing field type for selected GenType.
 /// </summary>
 /// <param name="type">The type of field.</param>
 /// <param name="gtype">The type of generator.</param>
 /// <returns></returns>
 public bool isAllow(Fields.Type type, GenType gtype)
 {
     if(gtype == GenType.CppDefinitions && type == Fields.Type.Number) {
         return false;
     }
     return true;
 }
Exemple #46
0
        private static void generate_promotions(
            GenType Type,
            int Delta,
            MoveStack[] ms,
            ref int mpos,
            ulong pawnsOn7,
            ulong target,
            CheckInfo ci)
        {
            var b = move_pawns(Delta, pawnsOn7) & target;
            while (b != 0)
            {
                var to = Utils.pop_lsb(ref b);

                if (Type == GenType.CAPTURES || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
                {
                    ms[mpos++].move = Utils.make(to - Delta, to, MoveTypeC.PROMOTION, PieceTypeC.QUEEN);
                }

                if (Type == GenType.QUIETS || Type == GenType.EVASIONS || Type == GenType.NON_EVASIONS)
                {
                    ms[mpos++].move = Utils.make(to - Delta, to, MoveTypeC.PROMOTION, PieceTypeC.ROOK);
                    ms[mpos++].move = Utils.make(to - Delta, to, MoveTypeC.PROMOTION, PieceTypeC.BISHOP);
                    ms[mpos++].move = Utils.make(to - Delta, to, MoveTypeC.PROMOTION, PieceTypeC.KNIGHT);
                }

                // Knight-promotion is the only one that can give a direct check not
                // already included in the queen-promotion.
                if (Type == GenType.QUIET_CHECKS
                    && (Utils.bit_is_set(Utils.StepAttacksBB[PieceC.W_KNIGHT][to], ci.ksq) != 0))
                {
                    ms[mpos++].move = Utils.make(to - Delta, to, MoveTypeC.PROMOTION, PieceTypeC.KNIGHT);
                }
            }
        }
 private void BuildSerializeListElement(StringBuilder sb, GenType genType, string iter)
 {
     var eField = new FieldContext(iter, genType.ElementType);
     BuildSerializeField(sb, eField, "", true);
 }
Exemple #48
0
        private bool PrivateReplenisher(GenType type, int amount, ushort oretype = 0, CommandArgs args = null)
        {
            int  counter = 0;
            bool success;

            for (int i = 0; i < TIMEOUT; i++)
            {
                success = false;
                int xRandBase = WorldGen.genRand.Next(1, Main.maxTilesX);
                int y         = 0;
                switch (type)
                {
                case GenType.ore:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    if (oretype != Terraria.ID.TileID.Hellstone)
                    {
                        WorldGen.OreRunner(xRandBase, y, 2.0, amount, oretype);
                    }
                    else
                    {
                        WorldGen.OreRunner(xRandBase, WorldGen.genRand.Next((int)(Main.maxTilesY) - 200, Main.maxTilesY), 2.0, amount, oretype);
                    }
                    success = true;
                    break;

                case GenType.chests:
                    if (amount == 0)
                    {
                        int tmpEmpty = 0, empty = 0;
                        for (int x = 0; x < 1000; x++)
                        {
                            if (Main.chest[x] != null)
                            {
                                tmpEmpty++;
                                bool found = false;
                                foreach (Item itm in Main.chest[x].item)
                                {
                                    if (itm.netID != 0)
                                    {
                                        found = true;
                                    }
                                }
                                if (found == false)
                                {
                                    empty++;
                                    WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false);
                                    Main.chest[x] = null;
                                }
                            }
                        }
                        args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty);
                        return(true);
                    }
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 200, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.AddBuriedChest(xRandBase, y);
                    break;

                case GenType.pots:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.PlacePot(xRandBase, y);
                    break;

                case GenType.lifecrystals:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.AddLifeCrystal(xRandBase, y);
                    break;

                case GenType.altars:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    WorldGen.Place3x2(xRandBase, y, 26);
                    success = Main.tile[xRandBase, y].type == 26;
                    break;

                case GenType.trees:
                    WorldGen.AddTrees();
                    success = true;
                    break;

                case GenType.floatingisland:
                    y = WorldGen.genRand.Next((int)Main.worldSurface + 175, (int)Main.worldSurface + 300);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    WorldGen.FloatingIsland(xRandBase, y);
                    success = true;
                    break;

                case GenType.pyramids:
                    //TODO
                    break;
                }
                if (success)
                {
                    counter++;
                    if (counter >= amount)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        private void BuildDeserializeListElement(StringBuilder sb, GenType listType, string prefix = "")
        {
            string elem = Tmp("_elem");

            var felem = new FieldContext(elem, listType.ElementType);

            sb.Indent(level).Append(DeclareField(felem, true)).AppendLine();

            BuildDeserializeField(sb, felem);

            sb.Indent(level).Append(prefix).Append(".Add(").Append(elem).Append(");").AppendLine();
        }