WEBVTT

00:00.350 --> 00:02.690
Welcome to your next quest.

00:02.720 --> 00:09.500
Now, if you're up to this quest, you're going to implement net serialize for our custom effect context.

00:09.530 --> 00:16.670
Now for this one, make a UN 32 so we can accommodate for all of our variables, call it rep bits and

00:16.670 --> 00:20.290
flip bits on it for each variable when loading.

00:20.300 --> 00:29.720
Now make sure to call, serialize bits on rep bits and then check each bit and archive or unarchive

00:29.720 --> 00:35.300
for each variable based on whether that bit has been flipped.

00:35.420 --> 00:43.100
Now make sure you're looking at how net serialize is implemented in gameplay effect types and see if

00:43.100 --> 00:49.220
you can handle this and make any adjustments that you think should be made so that we can serialize

00:49.220 --> 00:51.710
our two new boolean variables.

00:51.800 --> 00:52.970
Now, that's okay.

00:52.970 --> 00:58.370
If you're a little intimidated by this one, I understand if you want to skip it and just do it along

00:58.370 --> 01:02.900
with me, but if you'd like and if you're up to the challenge, give it a try.

01:02.910 --> 01:06.450
So pause the video and conquer this quest now.

01:09.610 --> 01:10.720
Welcome back.

01:11.380 --> 01:14.440
Now here's net serialized for gameplay effect types.

01:14.470 --> 01:22.210
It uses an uint8, but we're going to use a UNT 32 because we plan on accommodating for more than just

01:22.210 --> 01:23.500
eight variables.

01:24.220 --> 01:31.180
So I'm going to go into my aura ability type scope and we're going to start handling things here.

01:31.180 --> 01:40.600
Now first I'll make my you int 32 called rep bits and initialize it to zero and then I need to check

01:40.600 --> 01:42.670
if my archive is saving.

01:42.670 --> 01:49.960
So we're going to say if R dot is saving then we have some bits to flip.

01:49.960 --> 01:57.240
Right now I'm going to go ahead and just take some code from gameplay effect types.

01:57.250 --> 02:05.410
I do want to flip bits for the instigator for the effect causer, the source object, our actors array

02:05.440 --> 02:08.230
our hit results and has world origin.

02:08.470 --> 02:15.880
I'm going to go ahead and just copy all of these if statements and come back over to aura ability types

02:15.880 --> 02:18.490
right in my if statement here and paste them in.

02:18.640 --> 02:26.240
The only difference is I'd like to use the next two bits on my integer rep bits for my two booleans.

02:26.240 --> 02:30.650
And really what we can check is the boolean value of them.

02:30.650 --> 02:36.560
We can see if B is blocked, hit is true or false and b is critical hit.

02:36.590 --> 02:39.350
If they're false, no need to serialize them.

02:39.350 --> 02:40.040
Right.

02:40.040 --> 02:43.340
So let's check first.

02:43.340 --> 02:46.820
I'll check if B is blocked hit.

02:47.700 --> 02:51.180
If it is, we'll flip the bit on rep bits.

02:51.480 --> 02:55.350
Now we're going to use bitwise or equals.

02:55.350 --> 02:58.710
And the last bit we flipped was the sixth one.

02:58.710 --> 03:04.890
So now we're going to flip the seventh, we're going to say one left shift seven just like that.

03:05.040 --> 03:07.080
And we'll do this for the next boolean.

03:07.110 --> 03:10.950
If bee is critical hit.

03:12.690 --> 03:16.170
If so, we'll flip the eighth bit so we'll say rep bits.

03:17.070 --> 03:21.720
Bitwise or equals one left shift eight.

03:22.050 --> 03:24.000
So that's the first step.

03:24.030 --> 03:28.750
Now let's take a look at gameplay effect types after flipping bits.

03:28.770 --> 03:33.510
We call the archive Serialized bits function passing in rep bits.

03:33.510 --> 03:36.300
It's actually passing in the address of rep bits.

03:36.330 --> 03:39.240
Notice serialized bits takes a void pointer.

03:39.270 --> 03:47.820
That means it can take in a pointer to anything we're passing in the pointer to rep bits and the length

03:47.820 --> 03:48.360
of the bits.

03:48.390 --> 03:55.620
Now we're going to be using two more bits, so we need to call this with nine here instead of seven.

03:55.740 --> 04:04.050
So we're going to copy it, come back into Ora ability types and just after the is saving if statement,

04:04.080 --> 04:10.080
we're going to call serialized bits passing in rep bits, the address of it and the length in bits is

04:10.080 --> 04:16.420
going to be two more because we added two more bits that we've flipped on that integer.

04:16.420 --> 04:20.200
So length bits is nine and that's okay if you miss that part.

04:20.200 --> 04:24.940
But that's a very subtle nuance that you need to know about for this to work properly.

04:24.970 --> 04:32.950
Now back in gameplay effect types, we have the checking of the bits for instigator effect causer ability

04:33.550 --> 04:39.610
source object, the actor's array, the hit result the world origin.

04:39.670 --> 04:42.490
Notice that the world origin has an else case.

04:42.520 --> 04:48.730
If that bit has been flipped the sixth one, then it's going to archive world origin.

04:48.730 --> 04:54.550
It's also going to set be has world origin to true, but in the false case it's not going to serialize,

04:54.550 --> 04:57.880
but it is going to set be has world origin to false.

04:57.880 --> 04:58.270
Right.

04:58.270 --> 04:59.170
Interesting.

04:59.170 --> 05:02.440
Well we're going to go ahead and take everything down to here.

05:02.440 --> 05:02.950
Right?

05:02.950 --> 05:10.090
So starting all the way up here, just after serialized bits, all the way down here to the world origin,

05:10.090 --> 05:11.980
We're going to go ahead and copy that.

05:12.010 --> 05:16.000
Come back over here into our function and paste it in.

05:16.000 --> 05:21.220
So that takes care of everything except for our two variables, right?

05:21.220 --> 05:28.780
So we have to check against one left shift seven and one left shift eight as those are the places here

05:28.780 --> 05:30.340
that we care about.

05:30.340 --> 05:31.510
So let's check.

05:31.510 --> 05:39.460
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.

05:39.460 --> 05:42.910
We're going to say one left shift seven.

05:43.920 --> 05:48.690
If that is true, then we know that we serialized.

05:48.720 --> 05:50.100
What did we serialize?

05:50.100 --> 05:51.240
One of our booleans, right?

05:51.240 --> 05:53.700
We serialized B is blocked hit.

05:53.820 --> 06:01.080
So we want to use the archive with the left shift operator and our B is blocked hit.

06:01.080 --> 06:09.780
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,

06:09.780 --> 06:10.320
hit only.

06:10.320 --> 06:17.880
We're checking against one left shift eight and we're going to use the operator with B is critical hit

06:17.910 --> 06:19.020
like that.

06:19.230 --> 06:19.770
Okay.

06:19.770 --> 06:22.320
So that takes care of almost everything.

06:22.320 --> 06:24.540
Let's check our gameplay effect types.

06:24.540 --> 06:27.150
We'll see that there's just a couple things left.

06:27.180 --> 06:31.710
One is if the archive is loading, we can call add instigator.

06:31.710 --> 06:36.150
We can do that as well and we can also set be out success to true.

06:36.150 --> 06:43.930
So let's just copy those and we'll go back into our net serialize and we'll paste those in.

06:43.930 --> 06:48.430
And now we have successfully implemented net serialize.

06:48.460 --> 06:54.640
We're one step closer to having our own custom gameplay effect context class.

06:54.670 --> 06:57.280
We're almost ready to start learning how to use it.

06:57.280 --> 07:04.180
But there's one more important detail that we haven't quite looked at yet and we'll look at that next.

07:04.300 --> 07:05.350
Excellent job.

07:05.350 --> 07:08.080
And if you did this challenge, I'm very proud of you.

07:08.080 --> 07:13.090
It was a little bit more intimidating with all of this cryptic looking code.

07:13.120 --> 07:18.730
We're messing with bits, so we're getting a little bit lower level, but this is a little more advanced.

07:18.730 --> 07:21.010
So I'm proud of you for sticking through it.

07:21.010 --> 07:23.650
So great job and I'll see you soon.
