Welcome back.
So we've created a singleton or a gameplay tags and we have a function.
It's static called initialize native gameplay tags.
Now so far we're just adding a native gameplay tag for attributes secondary armor.
Now we need to call this function at some point and that's why we're going to create our very own asset
manager.
Now, what's an asset manager?
It's another singleton and it has to do with loading primary assets, and it's where we can initialize
this singleton where we can call this function.
Now the asset manager is a singleton in that there is only a single one in the whole project and we
set that at the project level.
So we're going to learn how to do that.
But first we have to create the class for it.
So we're going to do that.
We're going to go ahead and press run now.
We need to run in debug mode.
At this point in time.
We're just going to make a new class.
Our new asset manager.
So to make our asset manager, we'll go into our C plus plus classes or public folder.
We'll go ahead and put it here.
New C plus plus class.
We're going to choose all classes and search for asset manager and we're going to choose asset manager.
We'll click next.
We'll go ahead and let it go into Aura Public and we'll call this Aura asset manager.
Let's create the class and close the editor.
And now we can start to define this.
Singleton Which is going to be quite simple.
As with our other singleton, we're going to have a static get function.
So let's make a public section and we'll have a function that's static that returns an aura.
Asset manager reference a reference to the one and only asset manager.
We'll call this get and we'll go ahead and generate this definition.
And what does the get function return?
Well, it's going to return the engines.
Asset manager, but we're going to cast it to this type.
So we're going to set the asset manager.
We're going to do that in one of our config files and we'll see that very shortly.
But once our project has this class set to be its asset manager, then we can define the static get
function to return that asset manager cast to this class.
Now we get the engines asset manager from engine Asset Manager.
So that's what we're going to cast now.
First we're going to assert that engine is valid.
It should be.
If it's not, we're going to crash intentionally because then we have larger problems.
Now we're going to take its asset manager and cast so cast, what are we going to cast to?
We're going to cast to your aura asset manager.
Now, this is going to return a pointer for us so we can have a pointer to our asset manager called
our asset manager, but this function doesn't return a pointer.
It returns a reference.
So we're going to return the Dereferenced pointer or an asset manager.
And of course we could just dereference this and return it like this if we wanted to do it that way.
But I'm going to just do it this way.
Okay.
So that's the first thing we have to do is we need to define the get function which will return this
actual type.
Now, once we've done that, our asset manager needs to override a function that exists on the asset
manager class.
That's a protected function.
So we'll make a protected section and it's a virtual void function called Start initial loading.
This is called very early on and this is when we start the initial loading for our assets for the game.
And this is the perfect place for us to call that initialize native tags function that we have here
in our gameplay tags.
It's a static function.
We can call that here.
That's what we're going to do.
So here in start initial loading after calling super, we're going to load the native tags.
So that means we need our aura gameplay tags header file included here.
So let's go ahead and include aura gameplay tags, dot h and we'll use F or a gameplay tags, double
colon, initialize native gameplay tags.
This will call that function.
And what's that going to do?
Well, it's going to initialize native gameplay tags.
It's going to get the gameplay tag manager and call add native gameplay tag and that's going to create
our attributes.
Secondary armor gameplay tag.
So now the last thing to do is set this Aura asset Manager to be our project's asset manager.
Right?
So how do we do that?
Well, first of all, I'm going to go ahead and compile just to make sure we have no compiler errors
and to set the asset manager for our project, we go to our config files.
So let's go into our projects config folder and the config file we're interested in is default engine
dot Ini.
So here we have a number of settings and the one we're interested in setting is our asset manager.
We can specify that here.
Now first control F to search for asset manager and make sure that you don't have it set already so
we don't have asset manager set.
So here's how we set it.
Find the section script, engine dot engine.
Here's how we actually set it.
Just under whatever lines you have under this script slash engine engine, we're going to specify the
asset manager by typing asset manager class name equals script, and that's forward slash script.
Forward slash.
And then we use our project name, that's Aura Dot, and then our asset manager class name, Aura Asset
Manager.
Now we don't put the U for Aura asset manager.
We leave that off.
So this is how we specify Aura Asset Manager.
To be our project's asset manager, we go to scripts slash engine engine here in default engine Ini
and we say asset manager class name equals slash script slash aura or your project name, dot aura asset
manager or your asset manager name.
Let's go ahead and save and close that.
And now we can go ahead and compile and launch the engine.
Let's go ahead and do that.
I just hit the debug button.
So now that we've compiled and launched the engine, let's just go to edit project settings, gameplay
tags, and let's take a look at our gameplay tags attributes and here we have secondary.
And if we expand that, here's armor.
If we hover over it, it says attributes dot secondary armor and in parentheses native.
Now if we go to our other ones like Vital Health for example, the parentheses doesn't say native,
it says the dot ini file where this is defined.
So we don't have this defined in C plus plus.
That's what our native gameplay tags are.
And that's fine.
We may not care about accessing the health tag from within C plus plus if we just want to access it
within blueprint and there's no need for it to be a native tag, then fine.
But what about tags that we already have like our primary attributes that are not native, they're defined
in our primary attributes.
Data Table What about those?
What if we want those to be native?
Well, we can make those native.
We can just remove the table from the gameplay tag table list by hitting the trash can icon.
Now we don't have those primary attributes.
Careful doing this if you're using those attributes in assets and blueprints, well now those will be
gone and they'll have to be set all over again.
But the cool thing is we can now add gameplay tags to our project natively in our aura gameplay tags.
Singleton And we now have our own Aura asset manager that starts the initial loading.
That's what calls initialized native gameplay tags.
That's great.
The last piece of the puzzle is, well, how do we use these gameplay tags in our code?
Right?
Well, let's just see how we can do that.
Where's a good place to test out accessing our gameplay tags in code?
Well, I think perhaps in our ability system components dot cpp we have ability actor info set.
Let's just test it out here.
I'd like to access our native gameplay tag armor and then just prove to myself that I've accessed it
by, say, printing a message to the screen.
That way we'll see how we can access those tags.
Now for our gameplay tags.
Has that static get function?
It's F or a gameplay tags double colon get.
Now as soon as I did that of course writer includes or a gameplay tags for me so you'll have to make
sure that you do that.
And what does this return.
Well it returns our gameplay tags, the one and only singleton.
Right.
We can store that and we'll store it in a const reference.
We don't want to make a copy of it.
We'll call this const for gameplay tags, reference gameplay tags, and now that we have that singleton,
we can access the tags, we can say gameplay tags, dot and well, too bad we don't have a variable
on that singleton for our armor, right?
That's what we need and that's what we're going to add to it now.
So we go back to our gameplay tags and we need a public armor gameplay tag variable.
So let's add that variable.
It's going to be an F gameplay tag called Here's the convention we'll use.
We'll say attributes underscore secondary underscore armor.
So we'll just use underscores in place of the dot for the gameplay tag.
Now we need to set this right and we know that we're creating the gameplay tag in the CPP file here
with add native gameplay tag.
How do we associate that tag with our actual gameplay tag variable?
We'll add native gameplay tag returns that tag.
So what we can do is just store it in our new variable attributes secondary armor.
So we'll say attribute secondary armor equals.
Now we get the red squiggles because this is a static function, so we have to have some object of this
type.
Well, we know there's only one object of this type and we need to set the gameplay tag on that object.
So we say gameplay tags, dot attributes, secondary armor.
See, we have access to the one and only instance of it here.
So that's how we do it.
So now that this is happening, we're storing attributes, secondary armor.
Then in our aura ability system component, we can take our gameplay tags.
And we can access attribute secondary armor.
And because this is a gameplay tag and gameplay tags have the ability to be converted to strings we
can call to string, we can print a message.
With this, I'm going to go ahead and comment it out while I'm working and just add a debug message
engine add on screen debug message.
I'll use a key of negative one time to display can be 10s ten point f color can be f color orange and
the message can be f string print f will have text that says tag percent s followed by an asterisk and
we'll use this expression here.
Gameplay tags dot attributes secondary armor dot two string.
We'll put that right there and we get a semicolon at the end.
So just an on screen debug message that's going to prove to us that we're actually accessing a gameplay
tag that was created natively.
I'm going to go ahead and remove this comment here and to make things easier to read, let's put things
on their own lines here.
Like.
So we'll go ahead and do that.
So all that's left to do is play, test the game, start the game and see if we get this orange debug
message proving that we've accessed gameplay tags natively in code and we've accessed gameplay tags,
dot attributes, secondary armor.
Let's go ahead, we'll run in debug mode and we'll test this out.
Okay, Moment of truth.
Let's press play and check it out.
Tag attributes Secondary armor.
Now we've got it printed four different times, but that's just because we're printing this from within
the ability system component.
And each of these enemies has one.
If we just take one of these enemies, such as this one and hit delete and remove it, now there are
only three ability system components and if we press play, we only see the message three times.
So don't let that trip you up.
It's only being created once.
But we're printing the message here in ability actor info set, which happens three times at least in
a standalone game.
So this is great.
We now have our asset manager.
It's now set in our project and we have a singleton or a gameplay tags where we can define our native
gameplay tags.
Now Ryder's only letting me put a single space here, so what I'd like to do is add three more spaces
so there's at least four here, just so this looks nice and indented.
Okay, great job.
So now that we can add native gameplay tags, I'd like to add all of our attribute tags here to aura
gameplay tags, and then we can access those tags and use them in C plus plus.
So we'll be doing that next.
Great job and I'll see you soon.