TMAP for Blueprints

So, here TMap's in Blueprint - Blueprint - Unreal Engine Forums we were asked to make a new thread if this is needed (2014). That thread is the first google hit, I don’t know if there is something more current.

Basically, asking for an implementation of dictionary/tmap for blueprints. there are many algorithms that rely on it and while it can be emulated with two arrays, the performance is terrible.
For a specific use case, here something from my Project, as it may well be among the worst there are. I have a Tilemap, where I want to remove/add tiles, and neighbour tiles have blended states (They change depending on their surrounding). So, when a change happens, the 4 surrounding tiles need to be checked and may need to be changed too.

Now I’ve done this in the past with a different project, in this case Python/Pygame. I had a Data Structure like this:
{(Bool, Bool, Bool, Bool) : SubSurfaceRef}

Where the Bools are the 4 neighbours existing and then the texture that should be set based on these.

I have found no way to do this well in UE4 Blueprints. C++ would be an option, if one doesn’t target HTML5/Mobile.

So, my current way, a Data Table:

Then iterate over the thing:

Check if it’s the right entry:

And then set the tile.
For 64 Tiles this took my computer ~5.5 seconds to run through in editor.
The old Python system took less than 1ms.

Implementation Idea:
A variation of Data Table, where one column can be set as key and we can retrieve a row by key in Blueprints.

Edit: I optimized into acceptable margin by using Find, which I appear to have overlooked. Still a dictionary would speed up the algorithm from O(n²) to O(n)

Until/unless TMap is implemented in BP, you could create methods in your BP’s base class to retrieve and set elements from the TMap that you need. It’s a cludgy workaround, but it’s doable.

//.h

UPROPERTY()
TMap<FName, ATile*> TileMap;


UFUNCTION(BlueprintCallable, Category = "Tilemap")
ATile* GetTileFromMapByName(const FName& TargetTileName);

UFUNCTION(BlueprintCallable, Category = "Tilemap")
void SetTileToMapWithName(const FName& TargetTileName, ATile* TargetTile);


//.cpp

ATile* GetTileFromMapByName(const FName& TargetTileName) {
    return TileMap.FindChecked(TargetTileName);

   //--OR--
   if (TileMap.Contains(TargetTileName) {
      return * TileMap.Find(TargetTileName);

    }
    return NULL;

}

void SetTileToMapWithName(const FName& TargetTileName, ATile* TargetTile) {
    TileMap.Emplace(TargetTileName, TargetTile);

}

“C++ would be an option, if one doesn’t target HTML5/Mobile.”

I don’t understand this; is there something about HTML5/Mobile that prevents you from accessing custom C++ classes? Blueprints are rooted in C++, how do they work in HTML5/Mobile at all if not via C++?

Regardless, I agree. I’d very much like to see TMap available in BP.
TSet as well.

Ah, should have googled some more before posting. Building for iOS gave me a this feature does not exist for code projects. After some digging I found out that you need a mac to build C++ projects for iOS. And as for HTML I kind of assumed that C++ is a no go, which to be fair, it is. It’s just cross compiled to JS ( Developing HTML5 Projects | Unreal Engine Documentation )

So yeah, disregard the C++ sentence, it very much is an option. I still stand by the point that this feature would do well in blueprints though.

“I still stand by the point that this feature would do well in blueprints though.”

Wholeheartedly agree.

After some digging, it seems like this feature might come in .15:

But the info in that ticket is very vague.
So @Epic, any chance of some more elaboration of how the implementation might look like?
In my case, I have one instance where I get a TileMap(Value) by a custom 2D int vector(Key). If this is possible in blueprints soonish, I could save a lot of time moving onto other things and finishing that once C++ is not necessary.