コード例 #1
0
ファイル: Interest.cs プロジェクト: DB823/unity
 public static void SerializeSnapshot(global::Improbable.Interest.Snapshot snapshot, global::Improbable.Worker.CInterop.SchemaObject obj)
 {
     foreach (var keyValuePair in snapshot.ComponentInterest)
     {
         var mapObj = obj.AddObject(1);
         mapObj.AddUint32(1, keyValuePair.Key);
         global::Improbable.ComponentInterest.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2));
     }
 }
コード例 #2
0
ファイル: Interest.cs プロジェクト: DB823/unity
            public static global::Improbable.Interest.Snapshot DeserializeSnapshot(global::Improbable.Worker.CInterop.SchemaObject obj)
            {
                var component = new global::Improbable.Interest.Snapshot();

                {
                    var map     = new global::System.Collections.Generic.Dictionary <uint, global::Improbable.ComponentInterest>();
                    var mapSize = obj.GetObjectCount(1);
                    component.ComponentInterest = map;

                    for (var i = 0; i < mapSize; i++)
                    {
                        var mapObj = obj.IndexObject(1, (uint)i);
                        var key    = mapObj.GetUint32(1);
                        var value  = global::Improbable.ComponentInterest.Serialization.Deserialize(mapObj.GetObject(2));
                        map.Add(key, value);
                    }
                }

                return(component);
            }
コード例 #3
0
ファイル: Interest.cs プロジェクト: DB823/unity
            public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref global::Improbable.Interest.Snapshot snapshot)
            {
                var obj = updateObj.GetFields();

                {
                    var mapSize = obj.GetObjectCount(1);

                    var isCleared = updateObj.IsFieldCleared(1);

                    if (mapSize > 0 || isCleared)
                    {
                        snapshot.ComponentInterest.Clear();
                    }

                    for (var i = 0; i < mapSize; i++)
                    {
                        var mapObj = obj.IndexObject(1, (uint)i);
                        var key    = mapObj.GetUint32(1);
                        var value  = global::Improbable.ComponentInterest.Serialization.Deserialize(mapObj.GetObject(2));
                        snapshot.ComponentInterest.Add(key, value);
                    }
                }
            }