Ejemplo n.º 1
0
        /// <summary>
        /// Converts the given set of entities to be part of the same scene.
        /// </summary>
        /// <param name="entityManager">The entity manager to operate on.</param>
        /// <param name="entities">The set of entities to convert.</param>
        /// <param name="guid">The unique identifier of the scene.</param>
        /// <returns>A scene view of entities.</returns>
        public static Scene Create(EntityManager entityManager, NativeArray <Entity> entities, Guid guid)
        {
            var sceneGuid = new SceneGuid {
                Guid = guid
            };
            var sceneInstanceId = new SceneInstanceId {
                InstanceId = s_NextSceneInstanceId++
            };

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

                if (!entityManager.HasComponent <SceneGuid>(entity))
                {
                    entityManager.AddSharedComponentData(entities[i], sceneGuid);
                }
                else
                {
                    entityManager.SetSharedComponentData(entities[i], sceneGuid);
                }

                if (!entityManager.HasComponent <SceneInstanceId>(entity))
                {
                    entityManager.AddSharedComponentData(entities[i], sceneInstanceId);
                }
                else
                {
                    entityManager.SetSharedComponentData(entities[i], sceneInstanceId);
                }
            }

            return(new Scene(sceneGuid, sceneInstanceId));
        }
Ejemplo n.º 2
0
 public Scene(Guid sceneGuid, uint sceneInstanceId)
 {
     SceneGuid = new SceneGuid {
         Guid = sceneGuid
     };
     SceneInstanceId = new SceneInstanceId {
         InstanceId = sceneInstanceId
     };
 }
Ejemplo n.º 3
0
        public static Scene Create(Guid guid)
        {
            var sceneGuid = new SceneGuid {
                Guid = guid
            };
            var sceneInstanceId = new SceneInstanceId {
                InstanceId = s_NextSceneInstanceId++
            };

            return(new Scene(sceneGuid, sceneInstanceId));
        }
Ejemplo n.º 4
0
 public Scene(SceneGuid sceneGuid, SceneInstanceId sceneInstanceId)
 {
     SceneGuid       = sceneGuid;
     SceneInstanceId = sceneInstanceId;
 }