protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var waterPointType = GetArchetypeChunkComponentType <WaterPoint>();

        var job = new WaterPointJob {
            WaterPointType = waterPointType
        };

        return(job.Schedule(_waterPointsQuery, inputDependencies));
    }
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var waterPointType = GetArchetypeChunkComponentType <WaterPoint>();

        var partsQuery = GetEntityQuery(typeof(Initialized), typeof(WaterMeshComponent));

        int partsCount = partsQuery.CalculateEntityCount();

        var steps           = new NativeArray <float>(partsCount, Allocator.TempJob);
        var partPointsCount = new NativeArray <int>(partsCount, Allocator.TempJob);

        var topColors    = new NativeArray <Color32>(partsCount, Allocator.TempJob);
        var bottomColors = new NativeArray <Color32>(partsCount, Allocator.TempJob);

        var parts = partsQuery.ToComponentDataArray <WaterMeshComponent>(Allocator.TempJob);

        for (int i = 0; i < partsCount; i++)
        {
            var part = parts[i];

            steps[i] = part.Step;

            partPointsCount[i] = part.PointsRange.y - part.PointsRange.x + 1;

            topColors[i]    = part.TopColor;
            bottomColors[i] = part.BottomColor;
        }

        parts.Dispose();

        Vertices.Clear();

        var job = new WaterPointJob
        {
            Vertices         = Vertices,
            WaterPointType   = waterPointType,
            Height           = 1f,
            WaterSteps       = steps,
            WaterPointsCount = partPointsCount,
            TopColors        = topColors,
            BottomColors     = bottomColors
        };

        return(job.Schedule(_pointsQuery, inputDependencies));
    }
Example #3
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var job = new WaterPointJob();

        return(job.Schedule(this, inputDependencies));
    }