SyncVarAccessLists.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. // tracks SyncVar read/write access when processing NetworkBehaviour,
  2. // to later be replaced by SyncVarAccessReplacer.
  3. using System.Collections.Generic;
  4. using Mono.CecilX;
  5. namespace Mirror.Weaver
  6. {
  7. // This data is flushed each time - if we are run multiple times in the same process/domain
  8. public class SyncVarAccessLists
  9. {
  10. // setter functions that replace [SyncVar] member variable references. dict<field, replacement>
  11. public Dictionary<FieldDefinition, MethodDefinition> replacementSetterProperties =
  12. new Dictionary<FieldDefinition, MethodDefinition>();
  13. // getter functions that replace [SyncVar] member variable references. dict<field, replacement>
  14. public Dictionary<FieldDefinition, MethodDefinition> replacementGetterProperties =
  15. new Dictionary<FieldDefinition, MethodDefinition>();
  16. // amount of SyncVars per class. dict<className, amount>
  17. // necessary for SyncVar dirty bits, where inheriting classes start
  18. // their dirty bits at base class SyncVar amount.
  19. public Dictionary<string, int> numSyncVars = new Dictionary<string, int>();
  20. public int GetSyncVarStart(string className) =>
  21. numSyncVars.TryGetValue(className, out int value) ? value : 0;
  22. public void SetNumSyncVars(string className, int num)
  23. {
  24. numSyncVars[className] = num;
  25. }
  26. }
  27. }