Exemplo n.º 1
0
        internal static void AddWorldCommandRequesters(World world, EntityManager manager, Unity.Entities.Entity entity)
        {
            var createEntitySender = new CreateEntity.CommandSender
            {
                Handle = CreateEntity.RequestsProvider.Allocate(world)
            };

            createEntitySender.RequestsToSend = new List <CreateEntity.Request>();
            manager.AddComponentData(entity, createEntitySender);

            var deleteEntitySender = new DeleteEntity.CommandSender
            {
                Handle = DeleteEntity.RequestsProvider.Allocate(world)
            };

            deleteEntitySender.RequestsToSend = new List <DeleteEntity.Request>();
            manager.AddComponentData(entity, deleteEntitySender);

            var reserveEntityIdsSender = new ReserveEntityIds.CommandSender
            {
                Handle = ReserveEntityIds.RequestsProvider.Allocate(world)
            };

            reserveEntityIdsSender.RequestsToSend = new List <ReserveEntityIds.Request>();
            manager.AddComponentData(entity, reserveEntityIdsSender);

            var entityQuerySender = new EntityQuery.CommandSender
            {
                Handle = EntityQuery.RequestsProvider.Allocate(world)
            };

            entityQuerySender.RequestsToSend = new List <EntityQuery.Request>();
            manager.AddComponentData(entity, entityQuerySender);
        }
Exemplo n.º 2
0
            public void AddComponents(Entity entity, EntityManager entityManager, World world)
            {
                // todo error message if not the worker entity or spatial entity
                EntityId entityId = entityManager.HasComponent <SpatialEntityId>(entity)
                    ? entityManager.GetComponentData <SpatialEntityId>(entity).EntityId
                    : new EntityId(0);

                var handles = new Handles();

                var createEntitySender = new CreateEntity.CommandSender
                {
                    Handle = CreateEntity.RequestsProvider.Allocate(world)
                };

                createEntitySender.RequestsToSend = new List <CreateEntity.Request>();
                entityManager.AddComponentData(entity, createEntitySender);

                var deleteEntitySender = new DeleteEntity.CommandSender
                {
                    Handle = DeleteEntity.RequestsProvider.Allocate(world)
                };

                deleteEntitySender.RequestsToSend = new List <DeleteEntity.Request>();
                entityManager.AddComponentData(entity, deleteEntitySender);

                var reserveEntityIdsSender = new ReserveEntityIds.CommandSender
                {
                    Handle = ReserveEntityIds.RequestsProvider.Allocate(world)
                };

                reserveEntityIdsSender.RequestsToSend = new List <ReserveEntityIds.Request>();
                entityManager.AddComponentData(entity, reserveEntityIdsSender);

                var entityQuerySender = new EntityQuery.CommandSender
                {
                    Handle = EntityQuery.RequestsProvider.Allocate(world)
                };

                entityQuerySender.RequestsToSend = new List <EntityQuery.Request>();
                entityManager.AddComponentData(entity, entityQuerySender);

                handles.CreateEntity    = createEntitySender.Handle;
                handles.DeleteEntity    = deleteEntitySender.Handle;
                handles.ReserveEntityId = reserveEntityIdsSender.Handle;
                handles.EntityQuery     = entityQuerySender.Handle;

                entityIdToAllocatedHandles.Add(entityId, handles);
            }