Okay, so we're ready to actually add our ability system component and attribute set to our corresponding
classes that need them.
Now the first thing I'm going to do is open up my Aura character base class here, and I'd like a couple
of pointers here to store the ability system component and the attribute set.
That way, those pointers will be inherited by all characters.
Whether those characters are going to construct these in the character class or not.
Now, we've already decided that we'll be constructing and owning the ability, system component and
attribute set on the enemy class.
But for the player controlled character, those will be owned by the player state.
So in this video we're going to take care of both of those cases, but either way or a character base
is going to have pointers to the ability system component and the attribute set.
We'll keep those right here in the protected section.
And if we have to move them into public later for any reason we can.
Now these will be object pointers, so we'll make a T object pointer of type U ability system component,
not the aura version, just the engine class, and we'll call this ability system component and we'll
go ahead and make this a U property and we'll also have a pointer to the attribute set.
So we'll have a T object pointer for a U attribute set called attribute set, and this will also get
a U property.
Now we have two pointers and we want to construct these but not in or a character base because as we
just said, we want the player controlled character to construct them in the player state.
But for Aura Enemy, we can construct these in the enemy's constructor.
So let's go into the private character folder and open Aura Enemy.
And right here in the constructor we'll go ahead and construct these.
We'll say ability system component equals.
And this is a component.
So the way to create a component in the constructor is going to be create default Subobject.
And for the type, I'd like to make sure our enemy gets a U aura ability system component.
So I'm going to say you aura ability system component and for the native name we'll call it ability
system component so we can create an object of type aura, ability, system component and store it in
our member variable which has the type ability system component.
Now I see some red squiggles, which means I might have a typo somewhere because this should be legal.
So I'm going to go back to our character base and sure enough, I do have a typo.
I spelled component wrong, so that should fix it and that fixes the squiggles.
All right.
And before we can compile, these are, of course, incomplete types here, which we could forward declare
right up here at the top.
So we'll say class ability system component, and then we'll forward declare the attribute set as well.
And that gives us a successful compile.
Okay, so back in Ora Enemy, we've constructed our ability system component.
We want to make sure that that ability system component is replicated.
So I'm going to say ability system component set is replicated and we'll pass in True.
Now there's another thing we need to do related to replication, but we're not going to do it in this
video.
We're going to learn about what that thing is that we need to do shortly and then we'll do it.
But we're also going to construct our attribute set.
We're going to say attribute set.
Equals.
We'll use create default subobject.
This will be a you or a attribute set.
So we got that base class and the native name will be attribute set.
And we've now constructed our ability system component and our attribute set for the enemy.
And that of course sets these pointers.
So they're now populated by valid data.
So ability system component and attribute set in or a character base should be valid in the enemy class.
But for a character which is not an enemy, these two pointers are uninitialized.
Now we need to construct these, but we don't want to do it in or a character.
We want to do it in the player state.
So I'm going to go ahead and open or a player state that's going to be in the player folder or a player
state dot H.
And I'd like to have two pointers just like we have in our character base.
We want ability, system component and attribute set.
So I'm just going to copy these from character base and put them here in Aura Player State.
I'm going to give this a protected section and simply paste in these variables and I'd like to construct
them in the Aura Player State constructor, and we'll do so the same way we did in Aura Enemy, so we
can copy these lines where we're constructing these two and we can paste them in Aura Player State.
So I'll open the CPP file and just above setting our net update frequency, we'll go ahead and paste
these and writers telling me I need to include these header files.
I can use alt enter to automatically do that for both of them.
Alt enter will include those header files.
So now the player state has these pointers and is setting them but still on aura character.
These pointers will be null, right?
Because Aura player State has its own and the base character class has its own pointers for these.
So we're going to want to make sure that the aura, character, ability, system component and attribute
set pointers are set and we will make sure that we do that.
We'll keep in mind that that's something we still need to do.
Okay.
But we do know that the ability system component is constructed on both the enemy for aura enemy and
the player state for aura player State.
Now, there's still some setup that needs to be done and we're going to get to those things shortly.
But before we do, we're going to do one last thing before wrapping this up, and that is to implement
a specific interface that exists for the ability system.
We're going to first implement that interface on Aura character base right here, just after a character
we're going to inherit publicly, we're going to say public I ability system interface.
And Ryder says, What's that?
Well, Alt Enter takes me to the build file and tells me I should put gameplay abilities here and public
dependency module names as we're attempting to access this from within our aura character base.
Now, if we move this into the public array, we don't need this in the private, we don't need it in
both places.
So I'm going to go ahead and remove it from private dependency module names.
We'll just keep it in the public.
Now, here in our character base, writer automatically included ability system interface.
Now what is this interface?
Well, if I right click on it in Visual Studio, I could just peek definition.
But here in writer I'm going to select go to declaration or usages to go to its header file.
And we see here that it's just an interface that contains this pure virtual function get ability system
component.
This interface is really useful because it allows us to simply check any actor to see if it has this
interface and then we can easily get its ability system component from it.
Now because it's a pure virtual function, it's mandatory that we override this.
So I'm going to go ahead and highlight this line so that we can override it in aura character base as
we now have to.
So here in the public section, I'm going to override it.
We'll say const override and now we can generate a definition for it.
And all I want to do in here is return that pointer.
So we're going to say return ability system component and that's it.
Now something I like to do when I create a getter for the ability system component is I also like to
create a getter for the attribute set.
It's just convenient.
So along with this, I'm going to create a getter for the attribute set.
So I'm going to say you attribute, set, get, attribute set and this one can also be const and I can
just return attribute set here.
Nothing really fancy needs to be done.
I'm just going to keep it there.
So our ability system interface is now implemented in the character base class and all it does is return
those pointers.
Now remember, if we're on a character and we call this, we could get a null pointer because we haven't
ever set those pointers for a character.
We only constructed it for Aura Enemy right now.
I also like to implement this on the player state because I have the actual attribute set an ability
system component on the player state.
So we're going to implement that on the player state as well.
We'll go to Aura Player State and we'll inherit from I ability system interface that's going to pop
up that header there.
And we now have to override that function.
I'm just going to steal the declaration for both of these getters from Aura character base and I'll
paste them here in the public section in our player state and go ahead and implement get ability system
component here.
And just return the pointer return ability system component.
So at least from the player state for Aura, we can always get it.
So this is just one of those convenient things that we set up for characters or other classes that have
ability system components and attribute sets.
We generally implement the ability system interface.
That's just one of those boilerplate things that helps everything in the system, interact with each
other in a nice, convenient manner.
So now that we have the ability system component and attribute set pointers both on aura player State
and on the Aura character base, and we're actually constructing these objects.
We're doing it in Aura Enemy in the constructor and we're doing it in Aura Player State for the player
controlled character.
We're now ready to make that connection for the Aura character because the Aura character has these
pointers and they're null.
The Aura player state has non null pointers since we constructed them.
Now attempting to compile, I see that aura player State dot line 20 has an error because we're not
forward declaring here.
That is something we're going to want to do here as well.
I'm going to copy those lines where we're forward declaring in the base character class.
We're going to paste those in there and let's just make sure we can compile before we continue and we
have a successful compile.
Perfect.
Okay.
So in the next video, we're going to make sure that we tell the ability system component who its owner
is, and we're also going to make sure that our aura, character ability, system component and attribute
set pointers point to valid data and we'll do that next.
I'll see you soon.