Various questions - Constructors and TArray

Hi guys, apology if I’ll put a blueprint image as well, but I’m using both c++ and blueprint, so my question fall into both areas and opening two topics for trivial stuff seems bad.

So, I have this code here:

struct TArrayBool {
    TArray<bool> BoolRow;

//Code Inside GameMode..
TArray<TArrayBool> GridSlotsOccupiedMap;

//Code Inside the .cpp...
    //Setup GridSlotsOccupiedMap
    TArrayBool Temp;
    Temp.BoolRow.Init(false, GridWidth / GridBlockSize);
    GridSlotsOccupiedMap.Init(Temp, GridHeight / GridBlockSize);

void AWormGameMode::ToggleOccupiedBlock_Implementation(int Row, int Columns)
    GridSlotsOccupiedMap[Row].BoolRow[Columns] = GridSlotsOccupiedMap[Row].BoolRow[Columns] == true ? false : true;


Basically as you see I’m making a worm game (I’m begginner) and I want to store a 2dArray of bools to know which block is occupied (by a pickup or the worm’s body) so when spawning new pickups, I know on which block I can spawn.

the line “GridSlotsOccupiedMap[Row].BoolRow[Columns]” is extremely weird though, can I do any sorcery trough overloading operators inside the struct so that I can end up with a line that looks like “GridSlotsOccupiedMap[Row][Columns]” ?

Ok, on some more important question, image below.

As you see when I spawn a pickup I toggle the corresponding bool inside the “GridSlotsOccupiedMap” 2dArray inside the class and then use InitPickupID to store that same ID inside the pickup itself, so when the Worm collide with it and the pickup get destroyed I know which ID on the 2dArray should be toggled again (as allowed starting position for spawned stuff).
So my concern here is, is it possible that the SpawnActor by random chance spawns the pickup just in front of my Worm which steps on it before the InitPickupID is executed?
If that could happen I wouldn’t be able to toggle the corresponding ID on the map thus that slot won’t be able to spawn any more pickups.
So there is a way for me to pass those informations directly to the Pickup.h constructor so that the ID is recorded before the spawning? :confused:

Ok, I think I’ve figured out the first answer on my own in the code below, though the second question is still open :slight_smile:

struct TArrayBool {
    TArray<bool> BoolRow;
    inline bool& operator](int Column) { return BoolRow[Column]; }
void AWormGameMode::ToggleOccupiedBlock_Implementation(int Row, int Column)
    GridSlotsOccupiedMap[Row][Column] = GridSlotsOccupiedMap[Row][Column] == true ? false : true;