/// <summary>
        /// Schedule job to construct a new NativeStream using the specified type of memory allocation.
        /// </summary>
        /// <param name="allocator">A member of the
        /// [Unity.Collections.Allocator](https://docs.unity3d.com/ScriptReference/Unity.Collections.Allocator.html) enumeration.</param>
        public static JobHandle ScheduleConstruct(out NativeStream stream, NativeArray <int> lengthFromIndex0, JobHandle dependency, Allocator allocator)
        {
            AllocateBlock(out stream, allocator);
            var jobData = new ConstructJob {
                Length = lengthFromIndex0, Container = stream
            };

            return(jobData.Schedule(dependency));
        }
Ejemplo n.º 2
0
        public static JobHandle ScheduleConstruct(out BlockStream blockStream, NativeArray <int> lengthFromIndex0, uint uniqueBlockStreamId, JobHandle dependency, Allocator allocator = Allocator.TempJob)
        {
            AllocateBlock(out blockStream, uniqueBlockStreamId, allocator);
            var jobData = new ConstructJob {
                Length = lengthFromIndex0, BlockStream = blockStream
            };

            return(jobData.Schedule(dependency));
        }
Ejemplo n.º 3
0
    //Runs on the MainThread
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var job = new ConstructJob()
        {
            DeltaTime = Time.deltaTime
        };

        return(job.Schedule(this, inputDependencies));
    }
Ejemplo n.º 4
0
        public IAssignment FindAssignment(ILivingObject living)
        {
            if (m_jobDataList.Count == 0)
            {
                return(null);
            }

            int tick = m_environment.World.TickNumber;

            foreach (var data in m_jobDataList)
            {
                if (data.Job == null)
                {
                    if (data.NextTick > tick)
                    {
                        continue;
                    }

                    var item = m_environment.ItemTracker.GetReachableItemByDistance(living.Location, data.ItemFilter,
                                                                                    m_unreachables);

                    if (item == null)
                    {
                        Trace.TraceInformation("Failed to find materials");
                        data.NextTick = m_environment.World.TickNumber + 50;
                        continue;
                    }

                    item.ReservedBy = this;
                    data.Item       = item;

                    var job = new ConstructJob(this, data.Mode, new IItemObject[] { data.Item }, m_environment, data.Location);

                    data.Job = job;
                    m_environment.World.Jobs.Add(job);
                }

                var assignment = data.Job.FindAssignment(living);

                if (assignment != null)
                {
                    return(assignment);
                }
            }

            return(null);
        }