@@ -23,17 +23,11 @@ internal class NetworkBehaviourHelper : CodegenBase
23
23
internal string FullName ;
24
24
//Prediction.
25
25
public string ClearReplicateCache_MethodName = nameof ( NetworkBehaviour . ClearReplicateCache_Virtual ) ;
26
- #if PREDICTION_V2
27
- public string Reconcile_Client_Start_MethodName = nameof ( NetworkBehaviour . Reconcile_Client_Start ) ;
28
- public string Replicate_Replay_Start_MethodName = nameof ( NetworkBehaviour . Replicate_Replay_Start ) ;
29
- #endif
30
26
public MethodReference Replicate_NonOwner_MethodRef ;
31
27
public MethodReference Replicate_Owner_MethodRef ;
32
28
public MethodReference Replicate_Reader_MethodRef ;
33
- #if ! PREDICTION_V2
34
29
public MethodReference Replicate_ExitEarly_A_MethodRef ;
35
30
public MethodReference Reconcile_ExitEarly_A_MethodRef ;
36
- #endif
37
31
public MethodReference Reconcile_Server_MethodRef ;
38
32
public FieldReference UsesPrediction_FieldRef ;
39
33
public MethodReference Replicate_Replay_Start_MethodRef ;
@@ -56,9 +50,9 @@ internal class NetworkBehaviourHelper : CodegenBase
56
50
public MethodReference ServerRpcDelegate_Ctor_MethodRef ;
57
51
public MethodReference ClientRpcDelegate_Ctor_MethodRef ;
58
52
//Is checks.
59
- public MethodReference IsClient_MethodRef ;
53
+ public MethodReference IsClientInitialized_MethodRef ;
60
54
public MethodReference IsOwner_MethodRef ;
61
- public MethodReference IsServer_MethodRef ;
55
+ public MethodReference IsServerInitialized_MethodRef ;
62
56
public MethodReference IsHost_MethodRef ;
63
57
public MethodReference IsNetworked_MethodRef ;
64
58
//Misc.
@@ -116,37 +110,22 @@ public override bool ImportReferences()
116
110
else if ( mi . Name == nameof ( NetworkBehaviour . SendTargetRpc ) )
117
111
SendTargetRpc_MethodRef = base . ImportReference ( mi ) ;
118
112
//Prediction.
119
- #if ! PREDICTION_V2
120
113
else if ( mi . Name == nameof ( NetworkBehaviour . Replicate_ExitEarly_A ) )
121
114
Replicate_ExitEarly_A_MethodRef = base . ImportReference ( mi ) ;
122
- #endif
123
115
else if ( mi . Name == nameof ( NetworkBehaviour . Replicate_NonOwner ) )
124
116
Replicate_NonOwner_MethodRef = base . ImportReference ( mi ) ;
125
117
else if ( mi . Name == nameof ( NetworkBehaviour . Replicate_Reader ) )
126
118
Replicate_Reader_MethodRef = base . ImportReference ( mi ) ;
127
119
else if ( mi . Name == nameof ( NetworkBehaviour . Reconcile_Reader ) )
128
120
Reconcile_Reader_MethodRef = base . ImportReference ( mi ) ;
129
- #if PREDICTION_V2
130
- else if ( mi . Name = = Replicate_Replay_Start_MethodName )
131
- Replicate_Replay_Start_MethodRef = base . ImportReference ( mi ) ;
132
- else if ( mi . Name = = nameof ( NetworkBehaviour . Replicate_Replay ) )
133
- Replicate_Replay_MethodRef = base . ImportReference ( mi ) ;
134
- #endif
135
- #if ! PREDICTION_V2
136
121
else if ( mi . Name == nameof ( NetworkBehaviour . Reconcile_ExitEarly_A ) )
137
122
Reconcile_ExitEarly_A_MethodRef = base . ImportReference ( mi ) ;
138
- #endif
139
123
else if ( mi . Name == nameof ( NetworkBehaviour . Reconcile_Server ) )
140
124
Reconcile_Server_MethodRef = base . ImportReference ( mi ) ;
141
125
else if ( mi . Name == nameof ( NetworkBehaviour . Replicate_Owner ) )
142
126
Replicate_Owner_MethodRef = base . ImportReference ( mi ) ;
143
127
else if ( mi . Name == nameof ( NetworkBehaviour . Reconcile_Client ) )
144
128
Reconcile_Client_MethodRef = base . ImportReference ( mi ) ;
145
- //#if PREDICTION_V2
146
- // else if (mi.Name == nameof(NetworkBehaviour.Replicate_Server_SendToSpectators_Internal))
147
- // Replicate_Server_SendToSpectators_MethodRef = base.ImportReference(mi);
148
- //#endif
149
- //Misc.
150
129
else if ( mi . Name == nameof ( NetworkBehaviour . OwnerMatches ) )
151
130
OwnerMatches_MethodRef = base . ImportReference ( mi ) ;
152
131
else if ( mi . Name == nameof ( NetworkBehaviour . RegisterSyncVarRead ) )
@@ -160,10 +139,10 @@ public override bool ImportReferences()
160
139
foreach ( PropertyInfo pi in networkBehaviourType . GetProperties ( ( BindingFlags . Static | BindingFlags . Public | BindingFlags . Instance | BindingFlags . NonPublic ) ) )
161
140
{
162
141
//Server/Client states.
163
- if ( pi . Name == nameof ( NetworkBehaviour . IsClient ) )
164
- IsClient_MethodRef = base . ImportReference ( pi . GetMethod ) ;
165
- else if ( pi . Name == nameof ( NetworkBehaviour . IsServer ) )
166
- IsServer_MethodRef = base . ImportReference ( pi . GetMethod ) ;
142
+ if ( pi . Name == nameof ( NetworkBehaviour . IsClientInitialized ) )
143
+ IsClientInitialized_MethodRef = base . ImportReference ( pi . GetMethod ) ;
144
+ else if ( pi . Name == nameof ( NetworkBehaviour . IsServerInitialized ) )
145
+ IsServerInitialized_MethodRef = base . ImportReference ( pi . GetMethod ) ;
167
146
else if ( pi . Name == nameof ( NetworkBehaviour . IsHost ) )
168
147
IsHost_MethodRef = base . ImportReference ( pi . GetMethod ) ;
169
148
else if ( pi . Name == nameof ( NetworkBehaviour . IsOwner ) )
@@ -180,17 +159,6 @@ public override bool ImportReferences()
180
159
TimeManager_MethodRef = base . ImportReference ( pi . GetMethod ) ;
181
160
}
182
161
183
- #if PREDICTION_V2
184
- foreach ( FieldInfo fi in networkBehaviourType . GetFields ( ( BindingFlags . Static | BindingFlags . Public | BindingFlags . Instance | BindingFlags . NonPublic ) ) )
185
- {
186
- if ( fi . Name == nameof ( NetworkBehaviour . UsesPrediction ) )
187
- {
188
- UsesPrediction_FieldRef = base . ImportReference ( fi ) ;
189
- break ;
190
- }
191
- }
192
- #endif
193
-
194
162
return true ;
195
163
}
196
164
@@ -358,9 +326,7 @@ internal Instruction CreateRemoteClientIsOwnerCheck(ILProcessor processor, Param
358
326
/// <summary>
359
327
/// Creates exit method condition if not client.
360
328
/// </summary>
361
- /// <param name="processor"></param>
362
- /// <param name="retInstruction"></param>
363
- /// <param name="warn"></param>
329
+ /// <param name="useStatic">When true InstanceFinder.IsClient is used, when false base.IsClientInitialized is used.</param>
364
330
internal void CreateIsClientCheck ( MethodDefinition methodDef , LoggingType loggingType , bool useStatic , bool insertFirst , bool checkIsNetworked )
365
331
{
366
332
/* This is placed after the if check.
@@ -379,18 +345,18 @@ internal void CreateIsClientCheck(MethodDefinition methodDef, LoggingType loggin
379
345
{
380
346
instructions . Add ( processor . Create ( OpCodes . Ldarg_0 ) ) ; //argument: this
381
347
//If (!base.IsClient)
382
- instructions . Add ( processor . Create ( OpCodes . Call , IsClient_MethodRef ) ) ;
348
+ instructions . Add ( processor . Create ( OpCodes . Call , IsClientInitialized_MethodRef ) ) ;
383
349
}
384
350
//Checking instanceFinder.
385
351
else
386
- {
352
+ {
387
353
instructions . Add ( processor . Create ( OpCodes . Call , base . GetClass < ObjectHelper > ( ) . InstanceFinder_IsClient_MethodRef ) ) ;
388
354
}
389
355
instructions . Add ( processor . Create ( OpCodes . Brtrue , endIf ) ) ;
390
356
//If warning then also append warning text.
391
357
if ( loggingType != LoggingType . Off )
392
358
{
393
- string msg = $ "Cannot complete action because client is not active. This may also occur if the object is not yet initialized or if it does not contain a NetworkObject component. { DISABLE_LOGGING_TEXT } .";
359
+ string msg = $ "Cannot complete action because client is not active. This may also occur if the object is not yet initialized, has deinitialized, or if it does not contain a NetworkObject component.";
394
360
instructions . AddRange ( base . GetClass < GeneralHelper > ( ) . LogMessage ( methodDef , msg , loggingType ) ) ;
395
361
}
396
362
//Add return.
@@ -412,8 +378,7 @@ internal void CreateIsClientCheck(MethodDefinition methodDef, LoggingType loggin
412
378
/// <summary>
413
379
/// Creates exit method condition if not server.
414
380
/// </summary>
415
- /// <param name="processor"></param>
416
- /// <param name="warn"></param>
381
+ /// <param name="useStatic">When true InstanceFinder.IsServer is used, when false base.IsServerInitialized is used.</param>
417
382
internal void CreateIsServerCheck ( MethodDefinition methodDef , LoggingType loggingType , bool useStatic , bool insertFirst , bool checkIsNetworked )
418
383
{
419
384
/* This is placed after the if check.
@@ -431,7 +396,7 @@ internal void CreateIsServerCheck(MethodDefinition methodDef, LoggingType loggin
431
396
{
432
397
instructions . Add ( processor . Create ( OpCodes . Ldarg_0 ) ) ; //argument: this
433
398
//If (!base.IsServer)
434
- instructions . Add ( processor . Create ( OpCodes . Call , IsServer_MethodRef ) ) ;
399
+ instructions . Add ( processor . Create ( OpCodes . Call , IsServerInitialized_MethodRef ) ) ;
435
400
}
436
401
//Checking instanceFinder.
437
402
else
@@ -442,7 +407,7 @@ internal void CreateIsServerCheck(MethodDefinition methodDef, LoggingType loggin
442
407
//If warning then also append warning text.
443
408
if ( loggingType != LoggingType . Off )
444
409
{
445
- string msg = $ "Cannot complete action because server is not active. This may also occur if the object is not yet initialized or if it does not contain a NetworkObject component. { DISABLE_LOGGING_TEXT } ";
410
+ string msg = $ "Cannot complete action because server is not active. This may also occur if the object is not yet initialized, has deinitialized, or if it does not contain a NetworkObject component.";
446
411
instructions . AddRange ( base . GetClass < GeneralHelper > ( ) . LogMessage ( methodDef , msg , loggingType ) ) ;
447
412
}
448
413
//Add return.
0 commit comments