Ejemplo n.º 1
0
        private void Transfer(NativeArray <Entity> entities, NativeArray <EntityGuid> guids)
        {
            TransferConfigurations.Clear();
            if (entities.Length > TransferConfigurations.Capacity)
            {
                TransferConfigurations.Capacity = entities.Length;
            }

            for (var i = 0; i < entities.Length; ++i)
            {
                var entity = entities[i];
                var guid   = guids[i];

                if (!EntityToBindingConfiguration.TryGetValue(guid, out var current))
                {
                }
                var configuration = current;

                if (default == configuration || DirtyConfigurations.Contains(guid))
                {
                    configuration = GenerateBindingConfiguration(entity);
                    DirtyConfigurations.Remove(guid);
                    EntityToBindingConfiguration[guid] = configuration;
                }

                TransferConfigurations.Add(configuration);
                if (default != current && !configuration.Equals(current))
                {
                    for (var inverted = current.Bindings.Length - 1; inverted >= 0; --inverted)
                    {
                        var profile = current.Bindings[inverted];
                        if (Array.IndexOf(configuration.Bindings, profile) < 0)
                        {
                            profile.UnloadBinding(entity, m_BindingsContext);
                        }
                    }
                }
            }

            for (var i = 0; i < entities.Length; ++i)
            {
                var entity        = entities[i];
                var configuration = TransferConfigurations[i];
                foreach (var profile in configuration.Bindings)
                {
                    profile.LoadBinding(entity, m_BindingsContext);
                }
            }

            for (var i = 0; i < entities.Length; ++i)
            {
                var entity        = entities[i];
                var configuration = TransferConfigurations[i];
                foreach (var profile in configuration.Bindings)
                {
                    profile.TransferToUnity(entity, m_BindingsContext);
                }
            }
        }
Ejemplo n.º 2
0
 public void TransferBack(NativeArray <Entity> entities, NativeArray <Guid> guids)
 {
     for (var i = 0; i < entities.Length; ++i)
     {
         var entity = entities[i];
         if (!m_WorldManager.EntityManager.Exists(entity))
         {
             continue;
         }
         var guid = guids[i].ToEntityGuid();
         if (!EntityToBindingConfiguration.TryGetValue(guid, out var configuration))
         {
             continue;
         }
         foreach (var profile in configuration.Bindings)
         {
             profile.TransferFromUnity(entity, m_BindingsContext);
         }
     }
 }