You could do something like this (note that I won't write the whole code, just some things to give you an idea):```cs
// component on your Tilemap object
public class TileDataHolder : MonoBehaviour
{
[SerializeField] private Tilemap map;
[SerializeField] private TileData[] data;
private TileState[,,] tileStates;
private void Start ()
{
InitializeTileStates();
}
private void InitializeTileStates()
{
// iterate over all tiles in your grid
var size = map.size;
var initData = GetInitialData();
// init states
tileStates = new TileState[size.x, size.y, size.z];
for(x < size.x)
{
for(y < size.y)
{
for(z < size.z)
{
// get tile in looked-at cell
var cell = map.GetTile(new Vector3Int(x, y, z));
// get initial data linked to cell type. should probably be done via "TryGetValue()"
var initial = initData[cell.sprite];
// set initial state for [x, y, z] and **copy** over initial values
tileStates[x, y, z] = new TileState() { HP = initial.InitialHP };
}
}
}
}
}
private Dictionary<Sprite, TileData> GetInitialData()
{
// convert "data" to a dictionary (using "data[n].Sprite" as key and "data[n]" as value)
}
// TileData class
[Serializable]
public class TileData
{
public Sprite Tile;
public int InitialHP;
// ...
}
// TileState struct
public struct TileState
{
public int HP;
}Note that since `TileState` is a `struct`, you have to get, manipulate and set it again to change a tile's value: cs
// get copy of tile state
var state = tileStates[x, y, z];
// modify HP of state
state.HP--;
// re-assign state to tile
tileStates[x, y, z] = state;```