mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
splitting code into multiple functions (#1903)
This commit is contained in:
parent
f989b0fb11
commit
866808438a
@ -424,7 +424,37 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefi
|
||||
// check for Hook function
|
||||
MethodDefinition hookMethod = SyncVarProcessor.GetHookMethod(netBehaviourSubclass, syncVar);
|
||||
|
||||
// [SyncVar] GameObject/NetworkIdentity?
|
||||
if (IsNetworkIdentityField(syncVar))
|
||||
{
|
||||
DeserializeNetworkIdentityField(syncVar, serWorker, deserialize, hookMethod);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeserializeNormalField(syncVar, serWorker, deserialize, hookMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the field a NetworkIdentity or GameObject
|
||||
/// </summary>
|
||||
/// <param name="syncVar"></param>
|
||||
/// <returns></returns>
|
||||
static bool IsNetworkIdentityField(FieldDefinition syncVar)
|
||||
{
|
||||
return syncVar.FieldType.FullName == Weaver.gameObjectType.FullName ||
|
||||
syncVar.FieldType.FullName == Weaver.NetworkIdentityType.FullName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [SyncVar] GameObject/NetworkIdentity?
|
||||
/// </summary>
|
||||
/// <param name="syncVar"></param>
|
||||
/// <param name="serWorker"></param>
|
||||
/// <param name="deserialize"></param>
|
||||
/// <param name="initialState"></param>
|
||||
/// <param name="hookResult"></param>
|
||||
void DeserializeNetworkIdentityField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefinition deserialize, MethodDefinition hookMethod)
|
||||
{
|
||||
/*
|
||||
Generates code like:
|
||||
uint oldNetId = ___qNetId;
|
||||
@ -437,9 +467,7 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefi
|
||||
OnSetQ(oldSyncVar, syncvar.getter);
|
||||
}
|
||||
*/
|
||||
if (syncVar.FieldType.FullName == Weaver.gameObjectType.FullName ||
|
||||
syncVar.FieldType.FullName == Weaver.NetworkIdentityType.FullName)
|
||||
{
|
||||
|
||||
// GameObject/NetworkIdentity SyncVar:
|
||||
// OnSerialize sends writer.Write(go);
|
||||
// OnDeserialize reads to __netId manually so we can use
|
||||
@ -530,7 +558,17 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefi
|
||||
serWorker.Append(syncVarEqualLabel);
|
||||
}
|
||||
}
|
||||
// [SyncVar] int/float/struct/etc.?
|
||||
|
||||
/// <summary>
|
||||
/// [SyncVar] int/float/struct/etc.?
|
||||
/// </summary>
|
||||
/// <param name="syncVar"></param>
|
||||
/// <param name="serWorker"></param>
|
||||
/// <param name="deserialize"></param>
|
||||
/// <param name="initialState"></param>
|
||||
/// <param name="hookResult"></param>
|
||||
void DeserializeNormalField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefinition deserialize, MethodDefinition hookMethod)
|
||||
{
|
||||
/*
|
||||
Generates code like:
|
||||
// for hook
|
||||
@ -541,8 +579,7 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefi
|
||||
OnSetA(oldValue, Networka);
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
|
||||
MethodReference readFunc = Readers.GetReadFunc(syncVar.FieldType);
|
||||
if (readFunc == null)
|
||||
{
|
||||
@ -614,7 +651,6 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker, MethodDefi
|
||||
serWorker.Append(syncVarEqualLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateDeSerialization()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user