private void Update() { if (Camera.main == null || _playfield == null) { return; } // find nearest ball if (Mouse.current.middleButton.wasPressedThisFrame) { if (GetCursorPositionOnPlayfield(out var mousePosition)) { var ballEntities = _ballEntityQuery.ToEntityArray(Allocator.Temp); var nearestDistance = float.PositiveInfinity; BallData nearestBall = default; var ballFound = false; foreach (var ballEntity in ballEntities) { var ballData = _entityManager.GetComponentData <BallData>(ballEntity); if (ballData.IsFrozen) { continue; } var distance = math.distance(mousePosition, ballData.Position.xy); if (distance < nearestDistance) { nearestDistance = distance; nearestBall = ballData; ballFound = true; _ballEntity = ballEntity; } } if (ballFound) { UpdateBall(ref nearestBall, mousePosition); } } } else if (Mouse.current.middleButton.isPressed && _ballEntity != Entity.Null) { if (GetCursorPositionOnPlayfield(out var mousePosition)) { var ballData = _entityManager.GetComponentData <BallData>(_ballEntity); UpdateBall(ref ballData, mousePosition); } } if (Mouse.current.middleButton.wasReleasedThisFrame && _ballEntity != Entity.Null) { var ballData = _entityManager.GetComponentData <BallData>(_ballEntity); ballData.ManualControl = false; _entityManager.SetComponentData(_ballEntity, ballData); _ballEntity = Entity.Null; } }
public static void Collide(ref BallData ball, ref NativeQueue <EventData> .ParallelWriter events, ref DynamicBuffer <BallInsideOfBufferElement> insideOfs, ref KickerCollisionData collData, in KickerStaticData staticData, in ColliderMeshData meshData, in CollisionEventData collEvent,
public static void Collide3DWall(ref BallData ball, in PhysicsMaterialData material, in CollisionEventData collEvent, in float3 hitNormal, ref Random random)
public static void Collide(ref BallData ball, ref NativeQueue <EventData> .ParallelWriter hitEvents, ref HitTargetAnimationData animationData, in float3 normal, in CollisionEventData collEvent,
public static void Collide(ref BallData ball, ref NativeQueue <EventData> .ParallelWriter events, ref CollisionEventData collEvent, ref BumperRingAnimationData ringData, ref BumperSkirtAnimationData skirtData, in Entity ballEntity, in Collider collider, in BumperStaticData data, ref Random random)
/// <summary> /// Collides without triggering the animation, which is what the /// <see cref="Poly3DCollider"/> does. /// </summary> public static void Collide(ref BallData ball, ref NativeQueue <EventData> .ParallelWriter events, ref CollisionEventData collEvent, ref DynamicBuffer <BallInsideOfBufferElement> insideOfs, in Collider coll)
public static void OnBallLeaveFlipper(ref BallData ballData, ref FlipperCorrectionBlob flipperCorrectionBlob, in FlipperMovementData flipperMovementData, in FlipperStaticData flipperStaticData, uint timeMs)
private void UpdateBall(ref BallData ballData, float2 position) { ballData.ManualControl = true; ballData.ManualPosition = position; _entityManager.SetComponentData(_ballEntity, ballData); }