Ejemplo n.º 1
0
 public static void SerializeComponent(global::Improbable.Interest.Component component, global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
 {
     foreach (var keyValuePair in component.ComponentInterest)
     {
         var mapObj = obj.AddObject(1);
         mapObj.AddUint32(1, keyValuePair.Key);
         global::Improbable.ComponentInterest.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2));
     }
 }
Ejemplo n.º 2
0
            public static void SerializeUpdate(global::Improbable.Interest.Component component, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
            {
                var obj = updateObj.GetFields();

                if (component.IsDataDirty(0))
                {
                    foreach (var keyValuePair in component.ComponentInterest)
                    {
                        var mapObj = obj.AddObject(1);
                        mapObj.AddUint32(1, keyValuePair.Key);
                        global::Improbable.ComponentInterest.Serialization.Serialize(keyValuePair.Value, mapObj.AddObject(2));
                    }

                    if (component.ComponentInterest.Count == 0)
                    {
                        updateObj.AddClearedField(1);
                    }
                }
            }
Ejemplo n.º 3
0
            public static global::Improbable.Interest.Component Deserialize(global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
            {
                var component = new global::Improbable.Interest.Component();

                component.componentInterestHandle = global::Improbable.Gdk.Core.ReferenceProvider <global::System.Collections.Generic.Dictionary <uint, global::Improbable.ComponentInterest> > .Create();

                {
                    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);
            }
Ejemplo n.º 4
0
            public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref global::Improbable.Interest.Component component)
            {
                var obj = updateObj.GetFields();

                {
                    var mapSize = obj.GetObjectCount(1);

                    var isCleared = updateObj.IsFieldCleared(1);

                    if (mapSize > 0 || isCleared)
                    {
                        component.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));
                        component.ComponentInterest.Add(key, value);
                    }
                }
            }