//Просто спавнить непрерывно энтити по префабу /*protected override JobHandle OnUpdate(JobHandle inputDeps) * { * var SpawnerJob = new SpawnerJob( * endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(), * new unityMath.Random((uint)UnityEngine.Random.Range(0,int.MaxValue)) * ); * * JobHandle jobHandle = SpawnerJob.Schedule(this, inputDeps); * * endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle); * * return jobHandle; * }*/ //Спавнить энтити по префабу, когда список объектов с DeleteTag не пустой (всратый, но рабочий пока что костыль, нужно переписывать!) protected override JobHandle OnUpdate(JobHandle inputDeps) { bool trigger = false; var jobHandle = new JobHandle(); Entities .WithAll <DeleteTag>() .WithoutBurst() .ForEach((Entity entity) => { var SpawnerJob = new SpawnerJob( endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(), new unityMath.Random((uint)UnityEngine.Random.Range(0, int.MaxValue))); jobHandle = SpawnerJob.Schedule(this, inputDeps); endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle); trigger = true; }).Run(); if (trigger) { return(jobHandle); } else { return(default);
//Run the SpawnerJob protected override JobHandle OnUpdate(JobHandle inputDeps) { var spawner_job = new SpawnerJob(endSimulationEntityCommand.CreateCommandBuffer().ToConcurrent(), new Random((uint)UnityEngine.Random.Range(0, int.MaxValue)), Time.DeltaTime); JobHandle job_handle = spawner_job.Schedule(this, inputDeps); endSimulationEntityCommand.AddJobHandleForProducer(job_handle); return job_handle; }
protected override JobHandle OnUpdate(JobHandle inputDeps) { sinceLastUpdate += Time.DeltaTime; if (sinceLastUpdate < updateEvery) { return(inputDeps); } sinceLastUpdate = 0; SpawnerJob job = new SpawnerJob { CommandBuffer = commandBufferSystem.CreateCommandBuffer().ToConcurrent(), random = new Random((uint)UnityEngine.Random.Range(1, 100000)), prefabs = GetSingleton <PrefabContainer>(), blinks = GetComponentDataFromEntity <BlinkMovement>(true) }; JobHandle handle = job.Schedule(this, inputDeps); commandBufferSystem.AddJobHandleForProducer(handle); return(handle); }