Welcome to your next quest.
Now, if you're up to this quest, you're going to implement net serialize for our custom effect context.
Now for this one, make a UN 32 so we can accommodate for all of our variables, call it rep bits and
flip bits on it for each variable when loading.
Now make sure to call, serialize bits on rep bits and then check each bit and archive or unarchive
for each variable based on whether that bit has been flipped.
Now make sure you're looking at how net serialize is implemented in gameplay effect types and see if
you can handle this and make any adjustments that you think should be made so that we can serialize
our two new boolean variables.
Now, that's okay.
If you're a little intimidated by this one, I understand if you want to skip it and just do it along
with me, but if you'd like and if you're up to the challenge, give it a try.
So pause the video and conquer this quest now.
Welcome back.
Now here's net serialized for gameplay effect types.
It uses an uint8, but we're going to use a UNT 32 because we plan on accommodating for more than just
eight variables.
So I'm going to go into my aura ability type scope and we're going to start handling things here.
Now first I'll make my you int 32 called rep bits and initialize it to zero and then I need to check
if my archive is saving.
So we're going to say if R dot is saving then we have some bits to flip.
Right now I'm going to go ahead and just take some code from gameplay effect types.
I do want to flip bits for the instigator for the effect causer, the source object, our actors array
our hit results and has world origin.
I'm going to go ahead and just copy all of these if statements and come back over to aura ability types
right in my if statement here and paste them in.
The only difference is I'd like to use the next two bits on my integer rep bits for my two booleans.
And really what we can check is the boolean value of them.
We can see if B is blocked, hit is true or false and b is critical hit.
If they're false, no need to serialize them.
Right.
So let's check first.
I'll check if B is blocked hit.
If it is, we'll flip the bit on rep bits.
Now we're going to use bitwise or equals.
And the last bit we flipped was the sixth one.
So now we're going to flip the seventh, we're going to say one left shift seven just like that.
And we'll do this for the next boolean.
If bee is critical hit.
If so, we'll flip the eighth bit so we'll say rep bits.
Bitwise or equals one left shift eight.
So that's the first step.
Now let's take a look at gameplay effect types after flipping bits.
We call the archive Serialized bits function passing in rep bits.
It's actually passing in the address of rep bits.
Notice serialized bits takes a void pointer.
That means it can take in a pointer to anything we're passing in the pointer to rep bits and the length
of the bits.
Now we're going to be using two more bits, so we need to call this with nine here instead of seven.
So we're going to copy it, come back into Ora ability types and just after the is saving if statement,
we're going to call serialized bits passing in rep bits, the address of it and the length in bits is
going to be two more because we added two more bits that we've flipped on that integer.
So length bits is nine and that's okay if you miss that part.
But that's a very subtle nuance that you need to know about for this to work properly.
Now back in gameplay effect types, we have the checking of the bits for instigator effect causer ability
source object, the actor's array, the hit result the world origin.
Notice that the world origin has an else case.
If that bit has been flipped the sixth one, then it's going to archive world origin.
It's also going to set be has world origin to true, but in the false case it's not going to serialize,
but it is going to set be has world origin to false.
Right.
Interesting.
Well we're going to go ahead and take everything down to here.
Right?
So starting all the way up here, just after serialized bits, all the way down here to the world origin,
We're going to go ahead and copy that.
Come back over here into our function and paste it in.
So that takes care of everything except for our two variables, right?
So we have to check against one left shift seven and one left shift eight as those are the places here
that we care about.
So let's check.
So first we're going to say if and we're going to check rep bits bitwise and and we'll put this in parentheses.
We're going to say one left shift seven.
If that is true, then we know that we serialized.
What did we serialize?
One of our booleans, right?
We serialized B is blocked hit.
So we want to use the archive with the left shift operator and our B is blocked hit.
So we're going to say our left shift B is blocked hit and then we'll do the same thing for B is critical,
hit only.
We're checking against one left shift eight and we're going to use the operator with B is critical hit
like that.
Okay.
So that takes care of almost everything.
Let's check our gameplay effect types.
We'll see that there's just a couple things left.
One is if the archive is loading, we can call add instigator.
We can do that as well and we can also set be out success to true.
So let's just copy those and we'll go back into our net serialize and we'll paste those in.
And now we have successfully implemented net serialize.
We're one step closer to having our own custom gameplay effect context class.
We're almost ready to start learning how to use it.
But there's one more important detail that we haven't quite looked at yet and we'll look at that next.
Excellent job.
And if you did this challenge, I'm very proud of you.
It was a little bit more intimidating with all of this cryptic looking code.
We're messing with bits, so we're getting a little bit lower level, but this is a little more advanced.
So I'm proud of you for sticking through it.
So great job and I'll see you soon.