Example #1
0
        /// <summary>
        /// Replace a cell at a given index to the grid and initialize it.
        /// Don't destroy the duplicate in the processus and must be handle by the user with the return value.
        /// </summary>
        /// <param name="index">The index of the cell to replace.</param>
        /// <param name="cell">The cell data to initialize and replace.</param>
        /// <returns>The previous cell registered, or null if there was any cell.</returns>
        public Cell ReplaceCell(Vector3Int index, Cell cell)
        {
            CheckIsInitialised();

            if (HaveCell(ref index))
            {
                cell.Initialize(index, this);
                Cell delete = _map[index];
                _map[index] = cell;
                return(delete);
            }
            return(null);
        }
Example #2
0
 /// <summary>
 /// Add a cell at a given index to the grid and initialize it.
 /// </summary>
 /// <param name="index">The index of the cell.</param>
 /// <param name="cell">The cell data to initialize and register.</param>
 public void AddCell(Vector3Int index, Cell cell)
 {
     CheckIsInitialised();
     cell.Initialize(index, this);
     _map.Add(index, cell);
 }