public ColliderAllocationJob(IEnumerable <ICollider> colliderList, PlaneCollider playfieldCollider, PlaneCollider glassCollider) : this()
        {
            var perfMarker = new ProfilerMarker("ColliderAllocationJob.ctr");

            perfMarker.Begin();

            _circleColliders        = new NativeList <CircleCollider>(Allocator.TempJob);
            _flipperColliders       = new NativeList <FlipperCollider>(Allocator.TempJob);
            _gateColliders          = new NativeList <GateCollider>(Allocator.TempJob);
            _line3DColliders        = new NativeList <Line3DCollider>(Allocator.TempJob);
            _lineSlingshotColliders = new NativeList <LineSlingshotCollider>(Allocator.TempJob);
            _lineColliders          = new NativeList <LineCollider>(Allocator.TempJob);
            _lineZColliders         = new NativeList <LineZCollider>(Allocator.TempJob);
            _plungerColliders       = new NativeList <PlungerCollider>(Allocator.TempJob);
            _pointColliders         = new NativeList <PointCollider>(Allocator.TempJob);
            _spinnerColliders       = new NativeList <SpinnerCollider>(Allocator.TempJob);
            _triangleColliders      = new NativeList <TriangleCollider>(Allocator.TempJob);
            _planeColliders         = new NativeArray <PlaneCollider>(2, Allocator.TempJob)
            {
                [0] = playfieldCollider,
                [1] = glassCollider
            };

            BlobAsset = new NativeArray <BlobAssetReference <ColliderBlob> >(1, Allocator.TempJob);

            // separate created colliders per type
            foreach (var collider in colliderList)
            {
                switch (collider)
                {
                case CircleCollider circleCollider: _circleColliders.Add(circleCollider); break;

                case FlipperCollider flipperCollider: _flipperColliders.Add(flipperCollider); break;

                case GateCollider gateCollider: _gateColliders.Add(gateCollider); break;

                case LineCollider lineCollider: _lineColliders.Add(lineCollider); break;

                case Line3DCollider line3DCollider: _line3DColliders.Add(line3DCollider); break;

                case LineSlingshotCollider lineSlingshotCollider: _lineSlingshotColliders.Add(lineSlingshotCollider); break;

                case LineZCollider lineZCollider: _lineZColliders.Add(lineZCollider); break;

                case PlungerCollider plungerCollider: _plungerColliders.Add(plungerCollider); break;

                case PointCollider pointCollider: _pointColliders.Add(pointCollider); break;

                case SpinnerCollider spinnerCollider: _spinnerColliders.Add(spinnerCollider); break;

                case TriangleCollider triangleCollider: _triangleColliders.Add(triangleCollider); break;
                }
            }

            perfMarker.End();
        }
        public static BlobAssetReference <QuadTreeBlob> CreateBlobAssetReference(HitQuadTree hitQuadTree, HitPlane playfield, HitPlane glass)
        {
            using (var builder = new BlobBuilder(Allocator.Temp)) {
                ref var rootQuadTree = ref builder.ConstructRoot <QuadTreeBlob>();
                QuadTree.Create(hitQuadTree, ref rootQuadTree.QuadTree, builder);

                if (playfield != null)
                {
                    PlaneCollider.Create(builder, playfield, ref rootQuadTree.PlayfieldCollider);
                }
                else
                {
                    ref var playfieldCollider = ref builder.Allocate(ref rootQuadTree.PlayfieldCollider);
                    playfieldCollider.Header = new ColliderHeader {
                        Type = ColliderType.None
                    };
                }
Exemple #3
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;
            }
        }