Пример #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var input = new float3
            {
                x = Input.GetAxis("Horizontal"),
                y = Input.GetAxis("Length"),
                z = Input.GetAxis("Vertical"),
            };
            var job = new PlayerMoveJob
            {
                player_move = playerMove,
                dt          = Time.deltaTime,
                input       = input
            };

            inputDeps = job.Schedule(playerMove.Length, 64, inputDeps);
            var rot_job = new PlayerRotJob
            {
                player_move = playerMove,
                dt          = Time.deltaTime,
                input       = new float2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")),
            };

            inputDeps = rot_job.Schedule(playerMove.Length, 64, inputDeps);
            return(inputDeps);
        }
Пример #2
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new PlayerMoveJob
            {
                dt = Time.deltaTime,
            };

            return(job.Schedule(this, inputDeps));
        }
Пример #3
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new PlayerMoveJob
        {
            target    = m_LocalPlayer.ToComponentDataArray <Translation>(Allocator.TempJob),
            deltaTime = Time.deltaTime,
            speed     = 6
        };

        return(job.Schedule(this, inputDeps));
    }
Пример #4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            ArchetypeChunkComponentType <PlayerInputData>       playerInputDataRO = GetArchetypeChunkComponentType <PlayerInputData>(true);
            ArchetypeChunkComponentType <PlayerMoveData>        playerMoveDataRO  = GetArchetypeChunkComponentType <PlayerMoveData>(true);
            ArchetypeChunkComponentType <Position>              positionRW        = GetArchetypeChunkComponentType <Position>(false);
            ArchetypeChunkComponentType <Rotation>              rotationRW        = GetArchetypeChunkComponentType <Rotation>(false);
            ArchetypeChunkComponentType <EntityBoundCenterData> boundCenterDataRW = GetArchetypeChunkComponentType <EntityBoundCenterData>(false);
            ArchetypeChunkComponentType <EntityBoundMinMaxData> boundMinMaxDataRW = GetArchetypeChunkComponentType <EntityBoundMinMaxData>(false);
            ArchetypeChunkComponentType <EntityBoundOffsetData> boundOffsetDataRO = GetArchetypeChunkComponentType <EntityBoundOffsetData>(true);
            ArchetypeChunkComponentType <EntityBoundExtendData> boundExtendDataRO = GetArchetypeChunkComponentType <EntityBoundExtendData>(true);

            //CreateArchetypeChunkArray runs inside a job, we can use a job handle to make dependency on that job
            //A NativeArray<ArchetypeChunk> is allocated with the correct size on the main thread and that's what is returned, we are responsible for de-allocating it (In this case using [DeallocateOnJobCompletion] in the move job)
            //The job scheduled by CreateArchetypeChunkArray fill that array with correct chunk information
            JobHandle createChunckArrayJobHandle;
            NativeArray <ArchetypeChunk> playerMoveDataChunk = playerMoveDataGroup.CreateArchetypeChunkArray(Allocator.TempJob, out createChunckArrayJobHandle);

            //Special case when our query return no chunk at all
            if (playerMoveDataChunk.Length == 0)
            {
                createChunckArrayJobHandle.Complete();
                playerMoveDataChunk.Dispose();
                return(inputDeps);
            }

            //Make sure our movejob is dependent on the job filling the array has completed
            JobHandle moveJobDependency = JobHandle.CombineDependencies(inputDeps, createChunckArrayJobHandle);

            PlayerMoveJob playerMoveJob = new PlayerMoveJob
            {
                chunks            = playerMoveDataChunk,
                playerInputDataRO = playerInputDataRO,
                playerMoveDataRO  = playerMoveDataRO,
                positionRW        = positionRW,
                rotationRW        = rotationRW,
                boundCenterDataRW = boundCenterDataRW,
                boundMinMaxDataRW = boundMinMaxDataRW,
                boundOffsetDataRO = boundOffsetDataRO,
                boundExtendDataRO = boundExtendDataRO,
                deltaTime         = Time.deltaTime,
            };

            return(playerMoveJob.Schedule(playerMoveDataChunk.Length,
                                          MonoBehaviourECSBridge.Instance.GetJobBatchCount(playerMoveDataChunk.Length),
                                          moveJobDependency));
        }
Пример #5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            PlayerMoveJob playerMoveJob = new PlayerMoveJob
            {
                playerInputDataArray          = playerMoveDataGroup.playerInputDataArray,
                playerMoveDataArray           = playerMoveDataGroup.playerMoveDataArray,
                entityInstanceRenderDataArray = playerMoveDataGroup.entityInstanceRenderDataArray,
                entityBoundCenterDataArray    = playerMoveDataGroup.entityBoundCenterDataArray,
                entityBoundMinMaxDataArray    = playerMoveDataGroup.entityBoundMinMaxDataArray,
                entityBoundOffsetDataArray    = playerMoveDataGroup.entityBoundOffsetDataArray,
                entityBoundExtendDataArray    = playerMoveDataGroup.entityBoundExtendDataArray,
                deltaTime = Time.deltaTime,
            };


            return(playerMoveJob.Schedule(playerMoveDataGroup.Length,
                                          MonoBehaviourECSBridge.Instance.GetJobBatchCount(playerMoveDataGroup.Length),
                                          inputDeps));
        }