public static void SerializeUpdate(Improbable.EntityAcl.Component component, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj) { var obj = updateObj.GetFields(); { if (component.IsDataDirty(0)) { global::Improbable.WorkerRequirementSet.Serialization.Serialize(component.ReadAcl, obj.AddObject(1)); } } { if (component.IsDataDirty(1)) { foreach (var keyValuePair in component.ComponentWriteAcl) { var mapObj = obj.AddObject(2); mapObj.AddUint32(1, keyValuePair.Key); global::Improbable.WorkerRequirementSet.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2)); } } if (component.ComponentWriteAcl.Count == 0) { updateObj.AddClearedField(2); } } }
public static void SerializeComponent(Improbable.EntityAcl.Component component, global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world) { { global::Improbable.WorkerRequirementSet.Serialization.Serialize(component.ReadAcl, obj.AddObject(1)); } { foreach (var keyValuePair in component.ComponentWriteAcl) { var mapObj = obj.AddObject(2); mapObj.AddUint32(1, keyValuePair.Key); global::Improbable.WorkerRequirementSet.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2)); } } }
public static Improbable.EntityAcl.Component Deserialize(global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world) { var component = new Improbable.EntityAcl.Component(); component.readAclHandle = Improbable.EntityAcl.ReferenceTypeProviders.ReadAclProvider.Allocate(world); { component.ReadAcl = global::Improbable.WorkerRequirementSet.Serialization.Deserialize(obj.GetObject(1)); } component.componentWriteAclHandle = Improbable.EntityAcl.ReferenceTypeProviders.ComponentWriteAclProvider.Allocate(world); { component.ComponentWriteAcl = new global::System.Collections.Generic.Dictionary <uint, global::Improbable.WorkerRequirementSet>(); var map = component.ComponentWriteAcl; var mapSize = obj.GetObjectCount(2); for (var i = 0; i < mapSize; i++) { var mapObj = obj.IndexObject(2, (uint)i); var key = mapObj.GetUint32(1); var value = global::Improbable.WorkerRequirementSet.Serialization.Deserialize(mapObj.GetObject(2)); map.Add(key, value); } } return(component); }
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref Improbable.EntityAcl.Component component) { var obj = updateObj.GetFields(); var clearedFields = updateObj.GetClearedFields(); { if (obj.GetObjectCount(1) == 1) { var value = global::Improbable.WorkerRequirementSet.Serialization.Deserialize(obj.GetObject(1)); component.ReadAcl = value; } } { var mapSize = obj.GetObjectCount(2); bool isCleared = false; foreach (var fieldIndex in clearedFields) { isCleared = fieldIndex == 2; if (isCleared) { break; } } if (mapSize > 0 || isCleared) { component.ComponentWriteAcl.Clear(); } for (var i = 0; i < mapSize; i++) { var mapObj = obj.IndexObject(2, (uint)i); var key = mapObj.GetUint32(1); var value = global::Improbable.WorkerRequirementSet.Serialization.Deserialize(mapObj.GetObject(2)); component.ComponentWriteAcl.Add(key, value); } } }