Пример #1
0
 public static GodotVector2 ToSceneVector(this HopperIntVector2 vector)
 => new GodotVector2(vector.x, vector.y) * TileSize;
Пример #2
0
        /// <summary>
        /// Gets the rotation of the cell, represented by a hopper vector.
        /// The default orientation is to the right: (1, 0).
        /// With this function, it is impossible to get a diagonal orientation,
        /// or any orientation other than the 4 orthogonal directions.
        /// </summary>
        public static HopperIntVector2 GetCellOrientation(this Godot.TileMap tileMap, HopperIntVector2 position)
        {
            bool isTransposed = tileMap.IsCellTransposed(position.x, position.y);
            bool isYFlipped   = tileMap.IsCellYFlipped(position.x, position.y);

            if (isTransposed)
            {
                return(new HopperIntVector2(0, isYFlipped ? -1 : 1));
            }

            bool isXFlipped = tileMap.IsCellXFlipped(position.x, position.y);

            return(new HopperIntVector2(isXFlipped ? -1 : 1, 0));
        }