Devlin Willis

UE4 Gameplay Engineer
Independent Contractor for 3 years

ECT :: Expanded Container Types

Better, non-macro BP loops, and Algo:: esque container operations.

Containers in UE4 BP are supported, in that you can create them and do some operations on them. They’re not as fully featured as they would be in C++ though, and I wanted to see if I could make a plugin to address that. If you prefer a video format, here‘s a link to a video where I explain the exact same thing you’re about to read.

Arrays

Looping over an array is one of the most common tasks in programming, and its no different in Unreal Engine. Blueprints provide three macros which you can use for this – ForEachLoop, ForEachLoopWithBreak, and ReverseForEachLoop. There isn’t a ReverseForEachLoopWithBreak. These three macros are defined in StandardMacros… but they’re as messy to use as they are to look at.
 
Here’s a simple example – When I press 1 in game we’re going to loop through the Tags array in reverse order, and print any tag shorter than 4 characters to the screen.
 
A natural extension to the last example, now we’ll use a FlipFlop node to toggle the execution path between these macros. We want to change the order we’re looping over the array so that every other time we’re looping forward, and otherwise we’re looping backwards. Notice that I have to repeat the loop body, however. Even if I use a custom event, I’ll still have to use both loop macros.
 
With Expanded Container Types, using the ForEach node we can provide a direction input. This is easier to maintain as there isn’t a second loop control to remove or modify later.
 

Maps/Dictionaries

Maps, or dictionaries, are a useful tool in programming. Blueprint offers support for these, but it can be very messy.
 
Take this example. For some reason I want to loop over the map and do something for each pair in the map. I have to grab the pairs
as two different arrays. I’ll loop over one array, and use the array index to get the corresponding element from the other.

I don’t want to focus on the result of that sort of map handling, as it can quickly become a pain. Instead, lets imagine we want to have a sort of “threat” display in a game. As a player, you’d be notified of which people can harm you. We’re first going to remove any pairs from the map which meet our test condition. Then, we’re just going to print the map directly to the screen.

Alternatively, we could Filter the map to only entries that meet our condition. We’ll grab only the keys, and print that directly to the screen.
Our character has been replaced with one that is only able to take damage by DoTs.
 Either of these examples would be difficult to organize without Expanded Container Types.

Custom Type Support

Could you imagine a world without custom data types? Neither could the people behind Blueprint. A feature that never found its way into Blueprint however, is a true equality comparison for a custom data type. Equals is defined for quite a few engine types – AND ENUMS – but not for custom structures.
In addition to equality, all Expand Container Types functions support YOUR custom data types.
Here is a toy example that finds the key for a value.

A slightly more useful example toggles between sorting an array of custom actor instances by either ping or score.
You’ll also notice we then loop through the result and execute a custom print.