Advertisement
Guest User

Untitled

a guest
Mar 29th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public partial struct RegisterGunfireSystem : ISystem
  2. {
  3. EntityQuery query_Enemies;
  4. ComponentLookup<GunfireEvent> luGunFire;
  5. public void OnCreate(ref SystemState state)
  6. {
  7. query_Enemies = new EntityQueryBuilder(Allocator.Temp)
  8. .WithAll<EnemyTag>()
  9. .Build(ref state);
  10.  
  11. luGunFire = state.GetComponentLookup<GunfireEvent>(true);
  12. }
  13.  
  14.  
  15. public void OnUpdate(ref SystemState state)
  16. {
  17. luGunFire.Update(ref state);
  18. new RegisterGunfire
  19. {
  20. GunFire = luGunFire,
  21. }.ScheduleParallel(query_Enemies);
  22. }
  23.  
  24. //[BurstCompile]
  25. public partial struct RegisterGunfire : IJobEntity
  26. {
  27.  
  28. [ReadOnly] public ComponentLookup<GunfireEvent> GunFire;
  29. public void Execute(in LocalToWorld transform, ref Stimuli stimuli)
  30. {
  31. float3 gunfire = GunFire[???].location;
  32. if (math.distance(gunfire, transform.Position) < 15) {
  33. stimuli.HeardGunfire = 1;
  34. }
  35. }
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement