示例#1
0
        public SerializeClientData(Allocator allocator)
        {
            if (allocator != Allocator.Persistent)
            {
                throw new InvalidOperationException("Only persistent allocators are accepted");
            }

            Created = true;

            // Those variables are assigned automatically by a system
            AllChunks  = default;
            GhostType  = default;
            EntityType = default;
            // >

            GhostSnapshots          = new NativeHashMap <uint, IntPtr>(128, Allocator.Persistent);
            NetworkCompressionModel = new NetworkCompressionModel(Allocator.Persistent);
            ProgressiveGhostIds     = new NativeList <uint>(Allocator.Persistent);
            BlockedGhostIds         = new NativeList <uint>(Allocator.Persistent);
            KnownArchetypes         = new NativeList <uint>(Allocator.Persistent);

            Client = default;
            Tick   = 0;

            m_GhostSnapshots = default;
        }
示例#2
0
        protected override void OnUpdate()
        {
            if (_initialStatePersistRequests.Count + _applyRequests.Count == 0)
            {
                return;
            }

            EntityTypeHandle entityTypeHandle = GetEntityTypeHandle();
            ComponentTypeHandle <PersistenceState> indexTypeHandle = GetComponentTypeHandle <PersistenceState>(true);
            ComponentTypeHandle <PersistencyArchetypeIndexInContainer> archetypeIndexTypeHandle = GetComponentTypeHandle <PersistencyArchetypeIndexInContainer>(true);

            JobHandle inputDependencies        = Dependency;
            NativeArray <JobHandle> jobHandles = new NativeArray <JobHandle>(_initialStatePersistRequests.Count + _applyRequests.Count, Allocator.Temp);

            for (var i = 0; i < _initialStatePersistRequests.Count; i++)
            {
                jobHandles[i] = SchedulePersist(inputDependencies, _initialStatePersistRequests[i], indexTypeHandle, archetypeIndexTypeHandle);
            }

            int applyStartIndex = _initialStatePersistRequests.Count;

            for (var i = 0; i < _applyRequests.Count; i++)
            {
                int index = applyStartIndex + i;
                jobHandles[index] = ScheduleApply(inputDependencies, _applyRequests[i], _ecbSystem, entityTypeHandle, indexTypeHandle, archetypeIndexTypeHandle);
            }
            _ecbSystem.AddJobHandleForProducer(JobHandle.CombineDependencies(jobHandles.Slice(applyStartIndex)));

            Dependency = JobHandle.CombineDependencies(jobHandles);

            jobHandles.Dispose();
            _initialStatePersistRequests.Clear();
            _applyRequests.Clear();
        }
示例#3
0
 public ComponentDataEnumerator
     (NativeArray <ArchetypeChunk> chunks, ComponentTypeHandle <T> ctype)
 {
     this.ctype           = ctype;
     this.chunks          = chunks;
     this.chunkEnumerator = this.chunks.GetEnumerator();
     this.currentArray    = new NativeArray <T>();
     this.arrayIndex      = 0;
 }
        protected internal void SlowSynchronousPersist(PersistentDataContainer dataContainer)
        {
            ComponentTypeHandle <PersistenceState> persistenceStateTypeHandle = GetComponentTypeHandle <PersistenceState>();
            ComponentTypeHandle <PersistencyArchetypeIndexInContainer> archetypeIndexInContainerTypeHandle = GetComponentTypeHandle <PersistencyArchetypeIndexInContainer>();

            JobHandle jobHandle = default;

            jobHandle = SchedulePersist(jobHandle, dataContainer, persistenceStateTypeHandle, archetypeIndexInContainerTypeHandle);
            jobHandle.Complete();
        }
示例#5
0
        // OnUpdate runs on the main thread.
        protected override void OnUpdate()
        {
            ComponentTypeHandle <ShootDelayData> shootDelayDataType = GetComponentTypeHandle <ShootDelayData>();
            ShootJob shootJob = new ShootJob()
            {
                deltaTime = Time.DeltaTime,
                ShootDelayDataTypeHandle = shootDelayDataType
            };

            shootJob.Run(group);
        }
 protected JobHandle SchedulePersist(JobHandle inputDeps, PersistentDataContainer dataContainer, ComponentTypeHandle <PersistenceState> persistenceStateTypeHandle,
                                     ComponentTypeHandle <PersistencyArchetypeIndexInContainer> persistencyArchetypeIndexInContainerTypeHandle)
 {
     if (PersistencySettings.UseGroupedJobs())
     {
         return(SchedulePersistGroupedJob(inputDeps, dataContainer, persistenceStateTypeHandle, persistencyArchetypeIndexInContainerTypeHandle));
     }
     else
     {
         return(SchedulePersistJobs(inputDeps, dataContainer, persistenceStateTypeHandle));
     }
 }
 protected JobHandle ScheduleApply(JobHandle inputDeps, PersistentDataContainer dataContainer, EntityCommandBufferSystem ecbSystem,
                                   EntityTypeHandle entityTypeHandle, ComponentTypeHandle <PersistenceState> persistenceStateTypeHandle, ComponentTypeHandle <PersistencyArchetypeIndexInContainer> indexInContainerTypeHandle)
 {
     if (PersistencySettings.UseGroupedJobs())
     {
         return(ScheduleApplyGroupedJob(inputDeps, dataContainer, ecbSystem, entityTypeHandle, persistenceStateTypeHandle, indexInContainerTypeHandle));
     }
     else
     {
         return(ScheduleApplyJobs(inputDeps, dataContainer, ecbSystem, entityTypeHandle, persistenceStateTypeHandle));
     }
 }
        public static void Replace <T>(ref ComponentTypeHandle <T> bfe, AtomicSafetyHandle safetyHandle)
            where T : struct, IComponentData
        {
            if (s_ArchetypeComponentSafetyVarPos < 0)
            {
                Init();
            }

            // remove safety... (the array goes only writeonly for some weird reasons)
            UnsafeUtility.MemCpy((byte *)UnsafeUtility.AddressOf(ref bfe) + s_ArchetypeComponentSafetyVarPos,
                                 UnsafeUtility.AddressOf(ref safetyHandle),
                                 sizeof(AtomicSafetyHandle));
        }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        ComponentTypeHandle <Velocity>     velocityType     = GetComponentTypeHandle <Velocity>();
        ComponentTypeHandle <Acceleration> accelerationType = GetComponentTypeHandle <Acceleration>();

        VelocityUpdateJob job = new VelocityUpdateJob
        {
            VelocityType     = velocityType,
            AccelerationType = accelerationType,
            dt = Time.DeltaTime
        };

        return(job.Schedule(m_Group, inputDeps));
    }
示例#10
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        ComponentTypeHandle <Translation> translationType = GetComponentTypeHandle <Translation>();
        ComponentTypeHandle <Velocity>    velocityType    = GetComponentTypeHandle <Velocity>();

        MovementJob job = new MovementJob
        {
            TranslationType = translationType,
            VelocityType    = velocityType,
            dt = Time.DeltaTime
        };

        return(job.Schedule(m_Group, inputDeps));
    }
示例#11
0
 public void BeginSerialize(ComponentSystemBase system)
 {
     componentTypeActiveComponent      = ComponentType.ReadWrite <ActiveComponent>();
     componentTypeOwnerComponent       = ComponentType.ReadWrite <OwnerComponent>();
     componentTypeProjectileTag        = ComponentType.ReadWrite <ProjectileTag>();
     componentTypePhysicsCollider      = ComponentType.ReadWrite <PhysicsCollider>();
     componentTypePhysicsGravityFactor = ComponentType.ReadWrite <PhysicsGravityFactor>();
     componentTypePhysicsMass          = ComponentType.ReadWrite <PhysicsMass>();
     componentTypePhysicsVelocity      = ComponentType.ReadWrite <PhysicsVelocity>();
     componentTypeCompositeScale       = ComponentType.ReadWrite <CompositeScale>();
     componentTypeLocalToWorld         = ComponentType.ReadWrite <LocalToWorld>();
     componentTypeRotation             = ComponentType.ReadWrite <Rotation>();
     componentTypeTranslation          = ComponentType.ReadWrite <Translation>();
     ghostActiveComponentType          = system.GetComponentTypeHandle <ActiveComponent>(true);
     ghostRotationType    = system.GetComponentTypeHandle <Rotation>(true);
     ghostTranslationType = system.GetComponentTypeHandle <Translation>(true);
 }
示例#12
0
        //protected override JobHandle OnUpdate(JobHandle inputDeps)
        //{
        //    MovementJob moveJob = new MovementJob
        //    {
        //        topBound = GameManager.gameManager.topBound,
        //        bottomBound = GameManager.gameManager.bottomBound,
        //        deltaTime = Time.DeltaTime
        //    };
        //    JobHandle moveHandle = moveJob.Schedule(this, inputDeps);
        //    return moveHandle;
        //}


        // OnUpdate runs on the main thread.
        protected override void OnUpdate()
        {
            ComponentTypeHandle <Translation> translationType = GetComponentTypeHandle <Translation>();
            ComponentTypeHandle <Rotation>    rotationType    = GetComponentTypeHandle <Rotation>();
            ComponentTypeHandle <MoveSpeed>   moveSpeedType   = GetComponentTypeHandle <MoveSpeed>(true);

            MovementJob moveJob = new MovementJob()
            {
                TranslationTypeHandle = translationType,
                RotationTypeHandle    = rotationType,
                MoveSpeedTypeHandle   = moveSpeedType,
                deltaTime             = Time.DeltaTime,
                topBound    = GameManager.gameManager.topBound,
                bottomBound = GameManager.gameManager.bottomBound,
            };

            Dependency = moveJob.Schedule(group, Dependency);
        }
        protected override void OnUpdate()
        {
            JobHandle inputDependencies = Dependency;

            // Add auto persisting scenes to the _persistRequests
            if (!_autoPersistRequests.IsEmpty)
            {
                var sceneSectionsToUnload = _autoPersistRequests.ToComponentDataArray <SceneSectionData>(Allocator.TempJob);
                var tempHashSet           = new NativeHashSet <Hash128>(sceneSectionsToUnload.Length, Allocator.Temp);
                foreach (SceneSectionData sceneSectionData in sceneSectionsToUnload)
                {
                    var containerIdentifier = sceneSectionData.SceneGUID;
                    if (!tempHashSet.Contains(containerIdentifier) && _containerSystem.PersistentDataStorage.IsInitialized(containerIdentifier))
                    {
                        var writeContainer = _containerSystem.PersistentDataStorage.GetWriteContainerForCurrentIndex(containerIdentifier);
                        _persistRequests.Add(writeContainer);
                        tempHashSet.Add(containerIdentifier);
                    }
                }
                sceneSectionsToUnload.Dispose();
                tempHashSet.Dispose();

                // this will trigger the actual unload
                EntityCommandBuffer ecb = _ecbSystem.CreateCommandBuffer();
                ecb.RemoveComponent(_unloadRequests, new ComponentTypes(typeof(RequestSceneLoaded), typeof(PersistentSceneSection), typeof(PersistentSceneSectionLoadComplete)));
            }

            // Schedule the actual persist jobs
            if (_persistRequests.Count > 0)
            {
                ComponentTypeHandle <PersistenceState> indexTypeHandle = GetComponentTypeHandle <PersistenceState>(true);
                ComponentTypeHandle <PersistencyArchetypeIndexInContainer> archetypeIndexTypeHandle = GetComponentTypeHandle <PersistencyArchetypeIndexInContainer>(true);
                var jobHandles = new NativeList <JobHandle>(_persistRequests.Count, Allocator.Temp);
                foreach (PersistentDataContainer container in _persistRequests)
                {
                    JobHandle persistDep = SchedulePersist(inputDependencies, container, indexTypeHandle, archetypeIndexTypeHandle);
                    jobHandles.Add(persistDep);
                }
                Dependency = JobHandle.CombineDependencies(jobHandles);
                jobHandles.Dispose();
                _persistRequests.Clear();
            }
        }
示例#14
0
 public void BeginSerialize(ComponentSystemBase system)
 {
     componentTypeBoostComponent           = ComponentType.ReadWrite <BoostComponent>();
     componentTypeCarComponent             = ComponentType.ReadWrite <CarComponent>();
     componentTypeCarTag                   = ComponentType.ReadWrite <CarTag>();
     componentTypeHealthComponent          = ComponentType.ReadWrite <HealthComponent>();
     componentTypeMissileScopeComponent    = ComponentType.ReadWrite <MissileScopeComponent>();
     componentTypeProgressionComponent     = ComponentType.ReadWrite <ProgressionComponent>();
     componentTypeShieldComponent          = ComponentType.ReadWrite <ShieldComponent>();
     componentTypeSynchronizedCarComponent = ComponentType.ReadWrite <SynchronizedCarComponent>();
     componentTypePhysicsCollider          = ComponentType.ReadWrite <PhysicsCollider>();
     componentTypePhysicsDamping           = ComponentType.ReadWrite <PhysicsDamping>();
     componentTypePhysicsMass              = ComponentType.ReadWrite <PhysicsMass>();
     componentTypePhysicsVelocity          = ComponentType.ReadWrite <PhysicsVelocity>();
     componentTypeCompositeScale           = ComponentType.ReadWrite <CompositeScale>();
     componentTypeLocalToWorld             = ComponentType.ReadWrite <LocalToWorld>();
     componentTypeRotation                 = ComponentType.ReadWrite <Rotation>();
     componentTypeTranslation              = ComponentType.ReadWrite <Translation>();
     ghostHealthComponentType              = system.GetComponentTypeHandle <HealthComponent>(true);
     ghostProgressionComponentType         = system.GetComponentTypeHandle <ProgressionComponent>(true);
     ghostSynchronizedCarComponentType     = system.GetComponentTypeHandle <SynchronizedCarComponent>(true);
     ghostRotationType    = system.GetComponentTypeHandle <Rotation>(true);
     ghostTranslationType = system.GetComponentTypeHandle <Translation>(true);
 }
示例#15
0
 public void BeginSerialize(ComponentSystemBase system, NativeArray <ArchetypeChunk> chunks)
 {
     AllChunks  = chunks;
     GhostType  = system.GetComponentTypeHandle <GhostIdentifier>();
     EntityType = system.GetEntityTypeHandle();
 }
示例#16
0
        protected override void OnUpdate()
        {
            physicsWorld = World.GetExistingSystem <Unity.Physics.Systems.BuildPhysicsWorld>();

            BoidBootstrap bootstrap = this.bootstrap;

            ComponentTypeHandle <Wander>            wTHandle   = GetComponentTypeHandle <Wander>();
            ComponentTypeHandle <Boid>              bTHandle   = GetComponentTypeHandle <Boid>();
            ComponentTypeHandle <Translation>       ttTHandle  = GetComponentTypeHandle <Translation>();
            ComponentTypeHandle <Rotation>          rTHandle   = GetComponentTypeHandle <Rotation>();
            ComponentTypeHandle <Seperation>        sTHandle   = GetComponentTypeHandle <Seperation>();
            ComponentTypeHandle <Cohesion>          cTHandle   = GetComponentTypeHandle <Cohesion>();
            ComponentTypeHandle <Alignment>         aTHandle   = GetComponentTypeHandle <Alignment>();
            ComponentTypeHandle <Constrain>         conTHandle = GetComponentTypeHandle <Constrain>();
            ComponentTypeHandle <LocalToWorld>      ltwTHandle = GetComponentTypeHandle <LocalToWorld>();
            ComponentTypeHandle <ObstacleAvoidance> oaTHandle  = GetComponentTypeHandle <ObstacleAvoidance>();

            float deltaTime = Time.DeltaTime * bootstrap.speed;

            Unity.Mathematics.Random random = new Unity.Mathematics.Random((uint)UnityEngine.Random.Range(1, 100000));

            CamPosition = positions[0];
            CamRotation = rotations[0];

            //DrawGizmos();

            // Copy entities to the native arrays
            var copyToNativeJob = new CopyTransformsToNativeJob()
            {
                positions             = this.positions,
                rotations             = this.rotations,
                boidTypeHandle        = bTHandle,
                translationTypeHandle = ttTHandle,
                rotationTypeHandle    = rTHandle
            };

            var copyToNativeHandle = copyToNativeJob.ScheduleParallel(translationsRotationsQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, copyToNativeHandle);

            var oaJob = new ObstacleAvoidanceJob()
            {
                boidTypeHandle              = bTHandle,
                translationTypeHandle       = ttTHandle,
                ltwTypeHandle               = ltwTHandle,
                obstacleAvoidanceTypeHandle = oaTHandle,
                rotationTypeHandle          = rTHandle,
                collisionWorld              = physicsWorld.PhysicsWorld.CollisionWorld
            };

            var oaJobHandle = oaJob.ScheduleParallel(obstacleQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, oaJobHandle);

            if (bootstrap.usePartitioning)
            {
                cells.Clear();
                var partitionJob = new PartitionSpaceJob()
                {
                    positions   = this.positions,
                    cells       = this.cells.AsParallelWriter(),
                    threedcells = bootstrap.threedcells,
                    cellSize    = bootstrap.cellSize,
                    gridSize    = bootstrap.gridSize
                };

                var partitionHandle = partitionJob.Schedule(bootstrap.numBoids, 50, Dependency);
                Dependency = JobHandle.CombineDependencies(Dependency, partitionHandle);
            }
            var countNeighbourJob = new CountNeighboursJob()
            {
                positions             = this.positions,
                rotations             = this.rotations,
                neighbours            = this.neighbours,
                maxNeighbours         = bootstrap.totalNeighbours,
                cells                 = this.cells,
                cellSize              = bootstrap.cellSize,
                gridSize              = bootstrap.gridSize,
                usePartitioning       = bootstrap.usePartitioning,
                neighbourDistance     = bootstrap.neighbourDistance,
                boidTypeHandle        = bTHandle,
                translationTypeHandle = ttTHandle,
                rotationTypeHandle    = rTHandle
            };
            var cnjHandle = countNeighbourJob.ScheduleParallel(translationsRotationsQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, cnjHandle);

            var constrainJob = new ConstrainJob()
            {
                positions           = this.positions,
                boidTypeHandle      = bTHandle,
                constrainTypeHandle = conTHandle,
                weight = bootstrap.constrainWeight,
                centre = bootstrap.transform.position,
                radius = bootstrap.radius
            };

            var conjHandle = constrainJob.ScheduleParallel(constrainQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, conjHandle);


            var seperationJob = new SeperationJob()
            {
                positions             = this.positions,
                maxNeighbours         = this.maxNeighbours,
                random                = random,
                neighbours            = this.neighbours,
                weight                = bootstrap.seperationWeight,
                seperationTypeHandle  = sTHandle,
                translationTypeHandle = ttTHandle,
                boidTypeHandle        = bTHandle,
            };

            var sjHandle = seperationJob.ScheduleParallel(seperationQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, sjHandle);

            var cohesionJob = new CohesionJob()
            {
                positions          = this.positions,
                maxNeighbours      = this.maxNeighbours,
                neighbours         = this.neighbours,
                weight             = bootstrap.cohesionWeight,
                cohesionTypeHandle = cTHandle,
                boidTypeHandle     = bTHandle,
            };

            var cjHandle = cohesionJob.ScheduleParallel(cohesionQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, cjHandle);

            var alignmentJob = new AlignmentJob()
            {
                rotations           = this.rotations,
                maxNeighbours       = this.maxNeighbours,
                neighbours          = this.neighbours,
                weight              = bootstrap.alignmentWeight,
                alignmentTypeHandle = aTHandle,
                boidTypeHandle      = bTHandle,
            };

            var ajHandle = alignmentJob.ScheduleParallel(alignmentQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, ajHandle);

            var wanderJob = new WanderJob()
            {
                wanderTypeHandle      = wTHandle,
                translationTypeHandle = ttTHandle,
                rotationTypeHandle    = rTHandle,
                boidTypeHandle        = bTHandle,
                dT     = deltaTime,
                ran    = random,
                weight = bootstrap.wanderWeight
            };

            var wanderJobHandle = wanderJob.ScheduleParallel(wanderQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, wanderJobHandle);

            var boidJob = new BoidJob()
            {
                positions             = this.positions,
                rotations             = this.rotations,
                speeds                = this.speeds,
                dT                    = deltaTime,
                limitUpAndDown        = bootstrap.limitUpAndDown,
                banking               = 0.01f,
                damping               = 0.01f,
                wanderTypeHandle      = wTHandle,
                boidTypeHandle        = bTHandle,
                translationTypeHandle = ttTHandle,
                seperationTypeHandle  = sTHandle,
                rotationTypeHandle    = rTHandle,
                cohesionTypeHandle    = cTHandle,
                alignmentTypeHandle   = aTHandle,
                constrainTypeHandle   = conTHandle,
                obstacleTypeHandle    = oaTHandle
            };

            var boidJobHandle = boidJob.ScheduleParallel(boidQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, boidJobHandle);

            var copyFromNativeJob = new CopyTransformsFromNativeJob()
            {
                positions             = this.positions,
                rotations             = this.rotations,
                boidTypeHandle        = bTHandle,
                translationTypeHandle = ttTHandle,
                rotationTypeHandle    = rTHandle
            };

            var copyFromNativeHandle = copyFromNativeJob.ScheduleParallel(translationsRotationsQuery, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(Dependency, copyFromNativeHandle);

            return;
        }
 public void BeginCollect(World world)
 {
     _cachedColliders.Clear();
     _simAssetIdsHandle     = world.EntityManager.GetComponentTypeHandle <SimAssetId>(isReadOnly: true);
     _tileColliderTagHandle = world.EntityManager.GetComponentTypeHandle <TileColliderTag>(isReadOnly: true);
 }
 public void BeginDistribute(World world)
 {
     _cachedColliders.Clear();
     _simAssetIdsHandle = world.EntityManager.GetComponentTypeHandle <SimAssetId>(isReadOnly: true);
 }
        private JobHandle SchedulePersistJobs(JobHandle inputDeps, PersistentDataContainer dataContainer, ComponentTypeHandle <PersistenceState> persistenceStateTypeHandle)
        {
            var returnJobHandle = inputDeps;

            for (int persistenceArchetypeIndex = 0; persistenceArchetypeIndex < dataContainer.DataLayoutCount; persistenceArchetypeIndex++)
            {
                PersistencyArchetypeDataLayout dataLayout = dataContainer.GetDataLayoutAtIndex(persistenceArchetypeIndex);
                ref BlobArray <PersistencyArchetypeDataLayout.TypeInfo> typeInfoArray = ref dataLayout.PersistedTypeInfoArrayRef.Value;

                PersistencyContainerTag containerTag = new PersistencyContainerTag {
                    DataIdentifier = dataContainer.DataIdentifier
                };
                PersistableTypeCombinationHash persistableTypeCombinationHash = new PersistableTypeCombinationHash {
                    Value = dataLayout.PersistableTypeHandleCombinationHash
                };

                for (int typeInfoIndex = 0; typeInfoIndex < typeInfoArray.Length; typeInfoIndex++)
                {
                    // type info
                    PersistencyArchetypeDataLayout.TypeInfo typeInfo = typeInfoArray[typeInfoIndex];
                    ComponentType runtimeType = ComponentType.ReadOnly(PersistencySettings.GetTypeIndex(typeInfo.PersistableTypeHandle));
                    int           stride      = typeInfo.ElementSize * typeInfo.MaxElements + PersistenceMetaData.SizeOfStruct;
                    int           byteSize    = dataLayout.Amount * stride;

                    // query
                    var query = PersistableEntitiesQuery;
                    query.SetSharedComponentFilter(containerTag, persistableTypeCombinationHash);

                    JobHandle jobHandle;
                    if (typeInfo.IsBuffer)
                    {
                        jobHandle = new CopyBufferElementsToByteArray
                        {
                            BufferTypeHandle     = GetDynamicComponentTypeHandle(runtimeType),
                            MaxElements          = typeInfo.MaxElements,
                            PersistenceStateType = persistenceStateTypeHandle,
                            RawContainerData     = dataContainer.GetRawData(),
                            SubArrayOffset       = dataLayout.Offset + typeInfo.Offset,
                            SubArrayByteSize     = byteSize,
                            ElementSize          = typeInfo.ElementSize
                        }.Schedule(query, inputDeps);
                    }
                    else
                    {
                        jobHandle = new CopyComponentDataToByteArray()
                        {
                            ComponentTypeHandle  = GetDynamicComponentTypeHandle(runtimeType),
                            TypeSize             = typeInfo.ElementSize,
                            PersistenceStateType = persistenceStateTypeHandle,
                            RawContainerData     = dataContainer.GetRawData(),
                            SubArrayOffset       = dataLayout.Offset + typeInfo.Offset,
                            SubArrayByteSize     = byteSize
                        }.Schedule(query, inputDeps);
                    }

                    query.ResetFilter();
                    returnJobHandle = JobHandle.CombineDependencies(returnJobHandle, jobHandle);
                }
            }
示例#20
0
        public void SetEmptySafetyHandle <TComponent>(ref ComponentTypeHandle <TComponent> comp) where TComponent : struct, IComponentData
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            SafetyUtility.Replace(ref comp, SafetyHandle);
#endif
        }
示例#21
0
 public void ScheduleTimeInitialize(ComponentSystemBase jobComponentSystem, bool isReadOnly)
 {
     _typeHandle = jobComponentSystem.GetComponentTypeHandle <T>(isReadOnly);
 }
示例#22
0
 public static NativeArray <T> GetNativeArray <T>(this ArchetypeChunk chunk, ComponentTypeHandle <T> chunkComponentType) where T : struct, IComponentData => chunk.GetNativeArray(chunkComponentType.Value);
示例#23
0
 public EnumerableComponentData(JobComponentSystem sys, EntityQuery query, bool isReadOnly)
 {
     this.ctype  = sys.GetComponentTypeHandle <T>(isReadOnly);
     this.chunks = query.CreateArchetypeChunkArray(Allocator.TempJob);// Allocator.Temp );
 }