protected override JobHandle OnUpdate(JobHandle inputDeps) { currentCooldown -= Time.deltaTime; var job = new PositionJob { CDPercentage = currentCooldown / totalCooldown }; if (currentCooldown <= 0) { currentCooldown = totalCooldown; //NativeArray<Entity> allEntities = EntityManager.GetAllEntities(Allocator.TempJob); int step = (int)MicrobeSpawner.total / 500; for (int i = 0; i < MicrobeSpawner.total; i += step) { //Entity e = EntityManager.CreateEntity(EnemySpawner._cellArchetype); Debug.LogError("there is " + MicrobeSpawner.total + " and index is " + i); MicrobeSpawner.SpawnEntity( EntityManager.GetComponentData <Position>(MicrobeSpawner.entityArray[i]).Value + MicrobeSpawner.ReturnRandomPositionOffset(1f), MicrobeSpawner.EntityType.Antibody); //if (EntityManager.HasComponent<MitosisData>(e)) //{ // EntityManager.SetComponentData(e, new Position() {Value = EntityManager.GetComponentData<Position>(allEntities[i]).Value}); //} } } return(job.Schedule(this, inputDeps)); }
void Update() { /* * Vector3 mouseDiff = lastmouse - Input.mousePosition; * transform.position -= new Vector3(-mouseDiff.x/2 + mouseDiff.x, 0, -mouseDiff.y / 2 + mouseDiff.y) * 0.1f; * lastmouse = Input.mousePosition; */ transform.position += new Vector3(Input.GetAxis("RHorizontal"), 0, Input.GetAxis("RVertical")) * Time.deltaTime * speedMult; if (Input.GetButton("Fire2")) { for (int i = 0; i < 7; i++) { MicrobeSpawner.SpawnEntity(transform.position, MicrobeSpawner.EntityType.Antibody); } } }