Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Unity.Entities;
  5. using Unity.Physics.Systems;
  6. using Unity.Collections;
  7. using Unity.Jobs;
  8. using Unity.Burst;
  9. using Unity.Physics;
  10.  
  11. [UpdateAfter(typeof(StepPhysicsWorld)), UpdateBefore(typeof(EndFramePhysicsSystem))]
  12. public class AttackCollisionSystem : JobComponentSystem
  13. {
  14. private EndSimulationEntityCommandBufferSystem endSimBuffer;
  15. private BuildPhysicsWorld physicsWorld;
  16. private StepPhysicsWorld stepPhysicsWorld;
  17.  
  18. protected override void OnCreate()
  19. {
  20. physicsWorld = World.GetOrCreateSystem<BuildPhysicsWorld>();
  21. stepPhysicsWorld = World.GetOrCreateSystem<StepPhysicsWorld>();
  22. endSimBuffer = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
  23. base.OnCreate();
  24. }
  25.  
  26. protected override JobHandle OnUpdate(JobHandle inputDeps)
  27. {
  28. JobHandle jh = new ScanForImpact
  29. {
  30. ecb = endSimBuffer.CreateCommandBuffer().ToConcurrent(),
  31.  
  32. }.Schedule(stepPhysicsWorld.Simulation, ref physicsWorld.PhysicsWorld, inputDeps);
  33. endSimBuffer.AddJobHandleForProducer(jh);
  34. return jh;
  35. }
  36.  
  37. private struct ScanForImpact : ICollisionEventsJob
  38. {
  39. public EntityCommandBuffer.Concurrent ecb;
  40. public void Execute(CollisionEvent collisionEvent)
  41. {
  42.  
  43.  
  44.  
  45. Debug.Log("collision!");
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement