Ejemplo n.º 1
0
        /// <summary> Registers the given <paramref name="tilemap"/> keyed by the given <typeparamref name="T"/>. </summary>
        /// <typeparam name="T"> The <see cref="Type"/> of the <see cref="BaseTilemap{T}"/>. </typeparam>
        public void RegisterTilemap <T>(BaseTilemap <T> tilemap) where T : struct, ITileData
        {
            // If the given tilemap is null, do nothing.
            if (tilemap == null)
            {
                return;
            }

            // Add the tilemap keyed by the given type.
            mapsByType.Add(typeof(T), tilemap);
        }
Ejemplo n.º 2
0
        /// <summary> Finds the <see cref="BaseTilemap{T}"/> with the given <typeparamref name="T"/> from the <see cref="GameObject"/>'s children of this behaviour, and registers it. </summary>
        /// <typeparam name="T"> The <see cref="Type"/> of the <see cref="BaseTilemap{T}"/>. </typeparam>
        /// <returns> The <see cref="BaseTilemap{T}"/> with the matching <see cref="Type"/>, or null if none was found. </returns>
        private BaseTilemap <T> findAndRegisterTilemap <T>() where T : struct, ITileData
        {
            // Get the tilemap within the children of this GameObject.
            BaseTilemap <T> tilemap = GetComponentInChildren <BaseTilemap <T> >();

            // If a tilemap was found, register it.
            if (tilemap != null)
            {
                RegisterTilemap(tilemap);
            }

            // Return the tilemap, which could be null if none was found.
            return(tilemap);
        }
Ejemplo n.º 3
0
 /// <summary> Queries the given <paramref name="tile"/> against the given <paramref name="tilemap"/> using the given position, and checks that the tile can be placed. </summary>
 /// <param name="tilemap"> The <see cref="BaseTilemap{T}"/> against which the <paramref name="tile"/> is being queried. </param>
 /// <param name="x"> The x co-ordinate of the position. </param>
 /// <param name="y"> The y co-ordinate of the position. </param>
 /// <returns> True if the tile can be placed; otherwise, false. </returns>
 public virtual bool CanPlace(BaseTilemap <T> tilemap, int x, int y) => true;
Ejemplo n.º 4
0
 /// <summary> Is fired every tick of the given <paramref name="tilemap"/>. </summary>
 /// <param name="tilemap"> The <see cref="BaseTilemap{T}"/> on which this tile resides. </param>
 /// <param name="x"> The x co-ordinate of the position. </param>
 /// <param name="y"> The y co-ordinate of the position. </param>
 public virtual void OnTick(BaseTilemap <T> tilemap, int x, int y)
 {
 }
Ejemplo n.º 5
0
 /// <summary> Is fired immediately after a tile is destroyed. </summary>
 /// <param name="tilemap"> The <see cref="BaseTilemap{T}"/> on which this tile resided. </param>
 /// <param name="x"> The x co-ordinate of the position. </param>
 /// <param name="y"> The y co-ordinate of the position. </param>
 public virtual void OnTileDestroyed(BaseTilemap <T> tilemap, int x, int y)
 {
 }
Ejemplo n.º 6
0
 /// <summary> Is fired immediately after a tile is placed. </summary>
 /// <param name="tilemap"> The <see cref="BaseTilemap{T}"/> on which this tile now resides. </param>
 /// <param name="x"> The x co-ordinate of the position. </param>
 /// <param name="y"> The y co-ordinate of the position. </param>
 public virtual void OnTilePlaced(BaseTilemap <T> tilemap, int x, int y)
 {
 }