Esempio n. 1
0
        public FlipperCollider(CircleCollider hitCircleBase, float flipperRadius, float startRadius, float endRadius, float startAngle, float endAngle, ColliderInfo info) : this()
        {
            var bounds = hitCircleBase.Bounds;

            _header.Init(info, ColliderType.Flipper);
            _hitCircleBase = hitCircleBase;
            _zLow          = bounds.Aabb.ZLow;
            _zHigh         = bounds.Aabb.ZHigh;

            // compute bounds. we look at the flipper angles to compute the smallest possible bounds.
            var c  = _hitCircleBase.Center;
            var r2 = endRadius + 0.1f;
            var r3 = startRadius + 0.1f;

            var a0 = ClampDegrees(startAngle);
            var a1 = ClampDegrees(endAngle);

            // start with no bounds
            var aabb = new Aabb(c.x, c.x, c.y, c.y, _zLow, _zHigh);

            // extend with start and end position
            aabb = ExtendBoundsAtPosition(aabb, c, flipperRadius, r2, a0);
            aabb = ExtendBoundsAtPosition(aabb, c, flipperRadius, r2, a1);

            // extend with extremes (-90°, 0°, 90° and 180°)
            aabb = ExtendBoundsAtExtreme(aabb, c, flipperRadius, r2, r3, a0, a1, -90f);
            aabb = ExtendBoundsAtExtreme(aabb, c, flipperRadius, r2, r3, a0, a1, 0f);
            aabb = ExtendBoundsAtExtreme(aabb, c, flipperRadius, r2, r3, a0, a1, 90f);
            aabb = ExtendBoundsAtExtreme(aabb, c, flipperRadius, r2, r3, a0, a1, 180f);

            Bounds = new ColliderBounds(_header.Entity, _header.Id, aabb);
        }
Esempio n. 2
0
        public static void Create(BlobBuilder builder, HitObject src, ref BlobPtr <Collider> dest)
        {
            switch (src)
            {
            case KickerHit kickerHit:
                CircleCollider.Create(builder, kickerHit, ref dest, ColliderType.KickerCircle);
                break;

            case TriggerHitCircle triggerHitCircle:
                CircleCollider.Create(builder, triggerHitCircle, ref dest, ColliderType.TriggerCircle);
                break;

            case TriggerHitLineSeg triggerHitLine:
                LineCollider.Create(builder, triggerHitLine, ref dest, ColliderType.TriggerLine);
                break;

            case BumperHit bumperHit:
                CircleCollider.Create(builder, bumperHit, ref dest, ColliderType.Bumper);
                break;

            case HitCircle hitCircle:
                CircleCollider.Create(builder, hitCircle, ref dest);
                break;

            case LineSegSlingshot lineSegSlingshot:
                LineSlingshotCollider.Create(builder, lineSegSlingshot, ref dest);
                break;

            case FlipperHit flipperHit:
                FlipperCollider.Create(builder, flipperHit, ref dest);
                break;

            case GateHit gateHit:
                GateCollider.Create(builder, gateHit, ref dest);
                break;

            case LineSeg lineSeg:
                LineCollider.Create(builder, lineSeg, ref dest);
                break;

            case HitLine3D hitLine3D:
                Line3DCollider.Create(builder, hitLine3D, ref dest);
                break;

            case HitLineZ hitLineZ:
                LineZCollider.Create(builder, hitLineZ, ref dest);
                break;

            case HitPoint hitPoint:
                PointCollider.Create(builder, hitPoint, ref dest);
                break;

            case HitPlane hitPlane:
                PlaneCollider.Create(builder, hitPlane, ref dest);
                break;

            case PlungerHit plungerCollider:
                PlungerCollider.Create(builder, plungerCollider, ref dest);
                break;

            case SpinnerHit spinnerHit:
                SpinnerCollider.Create(builder, spinnerHit, ref dest);
                break;

            case HitTriangle hitTriangle:
                TriangleCollider.Create(builder, hitTriangle, ref dest);
                break;

            default:
                Logger.Warn("Unsupported collider {0}, skipping.", src.GetType().Name);
                break;
            }
        }