IEnumerator SpawningDoofuses() { //not really needed, can be useful to avoid run time allocations _factory.PreallocateEntitySpace <DoofusEntityDescriptor>(GameGroups.DOOFUSES, MaxNumberOfDoofuses); while (_numberOfDoofuses < MaxNumberOfDoofuses) { var init = _factory.BuildEntity <DoofusEntityDescriptor>(_numberOfDoofuses, GameGroups.DOOFUSES); var positionEntityStruct = new PositionEntityStruct { position = new float3(Random.value * 40, 0, Random.value * 40) }; init.Init(positionEntityStruct); init.Init(new UnityEcsEntityStructStruct { uecsEntity = _capsule, spawnPosition = positionEntityStruct.position, unityComponent = ComponentType.ReadOnly <UnityECSDoofusesGroup>() }); init.Init(new SpeedEntityStruct { speed = Random.Range(1, 10) / 10.0f }); _numberOfDoofuses++; // yield return Yield.It; } yield break; }
IEnumerator SpawningDoofuses() { //not really needed, can be useful to avoid run time allocations _factory.PreallocateEntitySpace <DoofusEntityDescriptor>(GroupCompound <GameGroups.DOOFUSES, GameGroups.RED> .Group, MaxNumberOfDoofuses); _factory.PreallocateEntitySpace <DoofusEntityDescriptor>(GroupCompound <GameGroups.DOOFUSES, GameGroups.BLUE> .Group, MaxNumberOfDoofuses); yield return(Yield.It); while (_numberOfDoofuses < MaxNumberOfDoofuses) { var init = _factory.BuildEntity <DoofusEntityDescriptor>(_numberOfDoofuses, GroupCompound <GameGroups.DOOFUSES, GameGroups.RED> .Group); //var init = _factory.BuildEntity<DoofusEntityDescriptor>(_numberOfDoofuses, GameGroups.DOOFUSES); var positionEntityStruct = new PositionEntityStruct { position = new float3(Random.value * 40, 0, Random.value * 40) }; init.Init(positionEntityStruct); init.Init(new UnityEcsEntityStructStruct { uecsEntity = _capsule, spawnPosition = positionEntityStruct.position, }); init.Init(new SpeedEntityStruct { speed = Random.Range(1, 10) / 10.0f }); _numberOfDoofuses++; } yield break; }