protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var handle    = JobHandle.CombineDependencies(inputDeps, m_BuildPhysicsWorldSystem.GetOutputDependency());
            var gameState = m_gameState.ToComponentDataArray <GameState>(Allocator.TempJob);

            if (Input.GetMouseButtonDown(0) && (Camera.main != null) && (gameState[0].gameState == e_GameStates.state_Idle) && (!EventSystem.current.IsPointerOverGameObject()))
            {
                Vector2         mousePosition = Input.mousePosition;
                UnityEngine.Ray unityRay      = Camera.main.ScreenPointToRay(mousePosition);
                var             ray           = new UnityEngine.Ray(unityRay.origin, unityRay.direction * k_MaxDistance);

                var selectedEntities = new NativeArray <Entity>(1, Allocator.TempJob);

                handle = new Pick
                {
                    CollisionWorld  = m_BuildPhysicsWorldSystem.PhysicsWorld.CollisionWorld,
                    NumStaticBodies = m_BuildPhysicsWorldSystem.PhysicsWorld.NumStaticBodies,
                    RayInput        = new RaycastInput
                    {
                        Start  = unityRay.origin,
                        End    = unityRay.origin + unityRay.direction * k_MaxDistance,
                        Filter = CollisionFilter.Default,
                    },
                    selected = selectedEntities,
                }.Schedule(JobHandle.CombineDependencies(handle, m_BuildPhysicsWorldSystem.GetOutputDependency()));

                handle.Complete();

                // if we got a valid entity
                if (EntityManager.Exists(selectedEntities[0]))
                {
                    // if that entity doesnt already have the Selected type
                    if (!EntityManager.HasComponent(selectedEntities[0], typeof(Selected)))
                    {
                        // if the previously selected entity had Selected type, remove it
                        if (EntityManager.HasComponent(previouslySelected, typeof(Selected)))
                        {
                            EntityManager.RemoveComponent <Selected>(previouslySelected);
                        }
                        // give the entity the Selected type
                        EntityManager.AddComponent(selectedEntities[0], typeof(Selected));

                        // update previous selected entity
                        previouslySelected = selectedEntities[0];
                    }
                }
                else    // else we didnt hit anything valid, remove previous Selection
                {
                    EntityManager.RemoveComponent <Selected>(previouslySelected);
                }


                selectedEntities.Dispose();
            }

            gameState.Dispose();
            return(handle);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (m_MouseGroup.CalculateEntityCount() == 0)
            {
                return(inputDeps);
            }

            var handle = JobHandle.CombineDependencies(inputDeps, m_BuildPhysicsWorldSystem.FinalJobHandle);

            if (Input.GetMouseButtonDown(0) && (Camera.main != null))
            {
                Vector2         mousePosition = Input.mousePosition;
                UnityEngine.Ray unityRay      = Camera.main.ScreenPointToRay(mousePosition);

                var mice           = m_MouseGroup.ToComponentDataArray <MousePick>(Allocator.TempJob);
                var IgnoreTriggers = mice[0].IgnoreTriggers != 0;
                mice.Dispose();

                // Schedule picking job, after the collision world has been built
                handle = new Pick
                {
                    CollisionWorld   = m_BuildPhysicsWorldSystem.PhysicsWorld.CollisionWorld,
                    NumDynamicBodies = m_BuildPhysicsWorldSystem.PhysicsWorld.NumDynamicBodies,
                    SpringData       = SpringDatas,
                    RayInput         = new RaycastInput
                    {
                        Start  = unityRay.origin,
                        End    = unityRay.origin + unityRay.direction * k_MaxDistance,
                        Filter = CollisionFilter.Default,
                    },
                    Near           = Camera.main.nearClipPlane,
                    Forward        = Camera.main.transform.forward,
                    IgnoreTriggers = IgnoreTriggers,
                }.Schedule(JobHandle.CombineDependencies(handle, m_BuildPhysicsWorldSystem.FinalJobHandle));

                PickJobHandle = handle;

                handle.Complete(); // TODO.ma figure out how to do this properly...we need a way to make physics sync wait for
                // any user jobs that touch the component data, maybe a JobHandle LastUserJob or something that the user has to set
            }

            if (Input.GetMouseButtonUp(0))
            {
                SpringDatas[0] = new SpringData();
            }

            return(handle);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (m_MouseGroup.CalculateLength() == 0)
            {
                return(inputDeps);
            }

            var handle = JobHandle.CombineDependencies(inputDeps, m_BuildPhysicsWorldSystem.FinalJobHandle);

            if (Input.GetMouseButtonDown(0) && (Camera.main != null))
            {
                var mice           = m_MouseGroup.ToComponentDataArray <MousePick>(Allocator.TempJob);
                var IgnoreTriggers = mice[0].IgnoreTriggers != 0;
                mice.Dispose();

                // Schedule picking job, after the collision world has been built
                handle = new Pick
                {
                    CollisionWorld   = m_BuildPhysicsWorldSystem.PhysicsWorld.CollisionWorld,
                    NumDynamicBodies = m_BuildPhysicsWorldSystem.PhysicsWorld.NumDynamicBodies,
                    SpringData       = SpringDatas,
                    RayInput         = MousePickBehaviour.CreateRayCastFromMouse(),
                    Near             = Camera.main.nearClipPlane,
                    Forward          = Camera.main.transform.forward,
                    IgnoreTriggers   = IgnoreTriggers,
                }.Schedule(JobHandle.CombineDependencies(handle, m_BuildPhysicsWorldSystem.FinalJobHandle));

                PickJobHandle = handle;

                handle.Complete(); // TODO.ma figure out how to do this properly...we need a way to make physics sync wait for
                // any user jobs that touch the component data, maybe a JobHandle LastUserJob or something that the user has to set
            }

            if (Input.GetMouseButtonUp(0))
            {
                SpringDatas[0] = new SpringData();
            }

            return(handle);
        }