mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
WeaverLists.replacedFields and replacementProperties merged into replacementSetterProperties dict for easier code and more obvious naming.
This commit is contained in:
parent
4fa584e72a
commit
266f262665
@ -159,7 +159,6 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, List<Fi
|
|||||||
{
|
{
|
||||||
string originalName = fd.Name;
|
string originalName = fd.Name;
|
||||||
|
|
||||||
Weaver.lists.replacedFields.Add(fd);
|
|
||||||
Weaver.DLog(td, "Sync Var " + fd.Name + " " + fd.FieldType + " " + Weaver.gameObjectType);
|
Weaver.DLog(td, "Sync Var " + fd.Name + " " + fd.FieldType + " " + Weaver.gameObjectType);
|
||||||
|
|
||||||
// GameObject SyncVars have a new field for netId
|
// GameObject SyncVars have a new field for netId
|
||||||
@ -188,7 +187,7 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, List<Fi
|
|||||||
td.Methods.Add(get);
|
td.Methods.Add(get);
|
||||||
td.Methods.Add(set);
|
td.Methods.Add(set);
|
||||||
td.Properties.Add(propertyDefinition);
|
td.Properties.Add(propertyDefinition);
|
||||||
Weaver.lists.replacementProperties.Add(set);
|
Weaver.lists.replacementSetterProperties[fd] = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> syncVars, List<FieldDefinition> syncObjects, List<FieldDefinition> syncVarNetIds)
|
public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> syncVars, List<FieldDefinition> syncObjects, List<FieldDefinition> syncVarNetIds)
|
||||||
|
@ -13,10 +13,8 @@ namespace Mirror.Weaver
|
|||||||
// This data is flushed each time - if we are run multiple times in the same process/domain
|
// This data is flushed each time - if we are run multiple times in the same process/domain
|
||||||
class WeaverLists
|
class WeaverLists
|
||||||
{
|
{
|
||||||
// [SyncVar] member variables that should be replaced
|
// setter functions that replace [SyncVar] member variable references. dict<field, replacement>
|
||||||
public List<FieldDefinition> replacedFields = new List<FieldDefinition>();
|
public Dictionary<FieldDefinition, MethodDefinition> replacementSetterProperties = new Dictionary<FieldDefinition, MethodDefinition>();
|
||||||
// setter functions that replace [SyncVar] member variable references
|
|
||||||
public List<MethodDefinition> replacementProperties = new List<MethodDefinition>();
|
|
||||||
// GameObject SyncVar generated netId fields
|
// GameObject SyncVar generated netId fields
|
||||||
public List<FieldDefinition> netIdFields = new List<FieldDefinition>();
|
public List<FieldDefinition> netIdFields = new List<FieldDefinition>();
|
||||||
|
|
||||||
@ -751,18 +749,14 @@ static void ProcessInstructionSetterField(TypeDefinition td, MethodDefinition md
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// does it set a field that we replaced?
|
// does it set a field that we replaced?
|
||||||
for (int n = 0; n < lists.replacedFields.Count; n++)
|
MethodDefinition replacement;
|
||||||
{
|
if (lists.replacementSetterProperties.TryGetValue(opField, out replacement))
|
||||||
FieldDefinition fd = lists.replacedFields[n];
|
|
||||||
if (opField == fd)
|
|
||||||
{
|
{
|
||||||
//replace with property
|
//replace with property
|
||||||
//DLog(td, " replacing " + md.Name + ":" + i);
|
//DLog(td, " replacing " + md.Name + ":" + i);
|
||||||
i.OpCode = OpCodes.Call;
|
i.OpCode = OpCodes.Call;
|
||||||
i.Operand = lists.replacementProperties[n];
|
i.Operand = replacement;
|
||||||
//DLog(td, " replaced " + md.Name + ":" + i);
|
//DLog(td, " replaced " + md.Name + ":" + i);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user