public void ProjectileSpawned_When_WeaponFired() { BeginInitializationEntityCommandBufferSystem projectileEntityCommandBuffer = _world.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>(); SpawnProjectileSystem spawnSystem = _world.CreateSystem <SpawnProjectileSystem>(); JobHandle handle = spawnSystem.ProcessSpawnProjectileJob(m_weaponFiredQuery, projectileEntityCommandBuffer); projectileEntityCommandBuffer.Update(); _manager.DestroyEntity(m_projectileEntity); // Destroy prefab entity so that it doesn't count towards the final result EntityQuery projectileQuery = _manager.CreateEntityQuery(typeof(Projectile)); int expectation = 1; int result = projectileQuery.CalculateLength(); Assert.AreEqual(expectation, result); }
public void SpawnedProjectile_SpawnedAtPositionOfWeapon() { _manager.SetComponentData(m_weaponEntity, new Translation { Value = new float3(1, 0, 0) }); BeginInitializationEntityCommandBufferSystem projectileEntityCommandBuffer = _world.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>(); SpawnProjectileSystem spawnSystem = _world.CreateSystem <SpawnProjectileSystem>(); JobHandle handle = spawnSystem.ProcessSpawnProjectileJob(m_weaponFiredQuery, projectileEntityCommandBuffer); projectileEntityCommandBuffer.Update(); _manager.DestroyEntity(m_projectileEntity); // Destroy prefab entity so that it doesn't count towards the final result EntityQuery projectileQuery = _manager.CreateEntityQuery(typeof(Projectile), typeof(Translation)); float3 expectation = new float3(1, 0, 0); Entity spawnedProjectile = projectileQuery.GetSingletonEntity(); float3 result = _manager.GetComponentData <Translation>(spawnedProjectile).Value; Assert.AreEqual(expectation, result); }