Example #1
0
        /**
         *      This creates a shape described by a shape of the base point shape op.
         *      Typicaly usage:
         *      \code
         *      [ShapeMethod]
         *      public FlatRhombShapeInfo<TCell> SomeShape(...)
         *      {
         *              return ShapeFromBase(FlatHexGrid<TCell>.BeginShape().SomeShape(...));
         *      }
         *      \endcode
         */
        public FlatRhombShapeInfo <TCell> ShapeFromBase(FlatHexShapeInfo <TCell> baseShapeInfo)
        {
            ShapeStorageInfo <FlatHexPoint> storageInfo = baseShapeInfo.ShapeStorageStorageInfo;
            var storageRect = storageInfo.storageRect;
            Func <FlatRhombPoint, bool> isInside = x => storageInfo.contains(x.BasePoint);
            var shapeInfo = MakeShapeStorageInfo <FlatRhombPoint>(storageRect, isInside);

            return(new FlatRhombShapeInfo <TCell>(shapeInfo));
        }
Example #2
0
        public static bool __CompilerHint2__FlatHex__MeshTileCell()
        {
            //Ensures abstract super classes for base grids gets created
            var grid = new FlatHexGrid <MeshTileCell>(1, 1, p => p == FlatHexPoint.Zero, x => x, x => x, new List <FlatHexPoint>());

            //Ensures shape infpo classes get created
            var shapeStorageInfo = new ShapeStorageInfo <FlatHexPoint>(new IntRect(), p => true);
            var shapeInfo        = new FlatHexShapeInfo <MeshTileCell>(shapeStorageInfo);

            return(grid[grid.First()] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null);
        }
Example #3
0
        public static bool __CompilerHint__FlatHex__MeshTileCell()
        {
            var grid = new FlatHexGrid <MeshTileCell[]>(1, 1);

            foreach (var point in grid)
            {
                grid[point] = new MeshTileCell[1];
            }

            var shapeStorageInfo = new ShapeStorageInfo <FlatHexPoint>(new IntRect(), p => true);
            var shapeInfo        = new FlatHexShapeInfo <MeshTileCell>(shapeStorageInfo);

            return(grid[grid.First()][0] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null);
        }
Example #4
0
        /**
         *      Call this method if you use a FlatHexGrid.
         *      Replace	the type __CellType to whatever type you have in your grid.
         *
         *      You can call the method anywhere in your code.
         *
         *              if(!__CompilerHint__FlatHex()) return;
         *
         *      This methods always returns true.
         *
         *      @since 1.6
         */
        public static bool __CompilerHint__FlatHex()
        {
            //Ensures abstract super classes for base grids gets created
            var grid = new FlatHexGrid <__CellType[]>(1, 1);

            foreach (var point in grid)
            {
                grid[point] = new __CellType[1];
            }

            //Ensures shape infpo classes get created
            var shapeStorageInfo = new ShapeStorageInfo <FlatHexPoint>(new IntRect(), p => true);
            var shapeInfo        = new FlatHexShapeInfo <__CellType>(shapeStorageInfo);

            return(grid[grid.First()][0] == null || shapeInfo.Translate(FlatHexPoint.Zero) != null);
        }