Exemple #1
0
    public void Execute(int index)
    {
        float distance = ((Vector3)(displacement[index] * deltaTime)).magnitude;

        raycasts[index] = new CapsulecastCommand(position[index] + new float3(0, 0, 5), position[index] - new float3(0, 0, 5), radius, displacement[index], distance);

        Debug.DrawRay(position[index], displacement[index]);

        position[index] += displacement[index] * deltaTime;

        if (position[index].x > boundsMax.x)
        {
            position[index] = new float3(position[index].x - boundsSize.x, position[index].y, position[index].z);
        }

        if (position[index].y > boundsMax.y)
        {
            position[index] = new float3(position[index].x, position[index].y - boundsSize.y, position[index].z);
        }

        if (position[index].x < boundsMin.x)
        {
            position[index] = new float3(position[index].x + boundsSize.x, position[index].y, position[index].z);
        }

        if (position[index].y < boundsMin.y)
        {
            position[index] = new float3(position[index].x, position[index].y + boundsSize.y, position[index].z);
        }

        rotation[index] = new float3(0f, 0f, rotation[index].z + (angularVelocity[index] * deltaTime));
    }
Exemple #2
0
            public void Execute(Int32 index)
            {
                var link = _links[index];

                if (!link.valid)
                {
                    return;
                }
                var node1 = _nodes[link.node1ID];

                if (node1.forbiddenHulls.HasFlag(hull.hullMask))
                {
                    link.hullMask     |= hull.hullMask;
                    link.jumpHullMask |= hull.hullMask;
                    _links[index]      = link;
                    return;
                }
                var node2 = _nodes[link.node2ID];

                if (node2.forbiddenHulls.HasFlag(hull.hullMask))
                {
                    link.hullMask     |= hull.hullMask;
                    link.jumpHullMask |= hull.hullMask;
                    _links[index]      = link;
                    return;
                }
                var offset = index * 2;

                Vector3 bottomEdgeVec  = Vector3.up * (hull.height * 0.5f - hull.radius);
                Vector3 bottomPointVec = Vector3.up * (hull.height * 0.5f);
                Single  radiusMod      = hull.radius * 0.5f + 0.005f;


                Vector3 point = node1.position + fudge + Vector3.up * radiusMod;

                _caps[offset] = new CapsulecastCommand
                {
                    point1    = (point + bottomEdgeVec),
                    point2    = (point - bottomEdgeVec),
                    radius    = hull.radius,
                    direction = Vector3.down,
                    distance  = (radiusMod * 2f + 0.005f),
                    layerMask = LayerIndex.world.mask
                };

                point = node2.position + fudge + Vector3.up * radiusMod;

                _caps[offset + 1] = new CapsulecastCommand
                {
                    point1    = (point + bottomEdgeVec),
                    point2    = (point - bottomEdgeVec),
                    radius    = hull.radius,
                    direction = Vector3.down,
                    distance  = (radiusMod * 2f + 0.005f),
                    layerMask = LayerIndex.world.mask
                };
            }
Exemple #3
0
                public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
                {
                    NativeArray <CapsuleColliderComponentData> capsuleColliders = chunk.GetNativeArray(CapsuleColliderType);
                    NativeArray <Position> positions = chunk.GetNativeArray(PositionType);
                    NativeArray <Rotation> rotations = chunk.GetNativeArray(RotationType);
                    NativeArray <Scale>    scales    = chunk.GetNativeArray(ScaleType);

                    NativeArray <Entity> entities = chunk.GetNativeArray(EntityType);

                    float3 zero = float3.zero;

                    for (int i = 0, length = capsuleColliders.Length; i < length; ++i)
                    {
                        CapsuleColliderComponentData capsule = capsuleColliders[i];
                        Position position = positions[i];
                        Rotation rotation = rotations[i];
                        Scale    scale    = scales[i];

                        float3 dir    = new float3();
                        float  radius = 0.0f;

                        switch (capsule.Direction)
                        {
                        case 0:
                            dir.x  = 1;
                            radius = capsule.Radius * math.max(scale.Value[1], scale.Value[2]);
                            break;

                        case 1:
                            dir.y  = 1;
                            radius = capsule.Radius * math.max(scale.Value[0], scale.Value[2]);
                            break;

                        case 2:
                            dir.z  = 1;
                            radius = capsule.Radius * math.max(scale.Value[0], scale.Value[1]);
                            break;
                        }

                        float height = capsule.Height * scale.Value[capsule.Direction];
                        dir = math.rotate(rotation.Value, dir);

                        float3 offset = (dir * (height * 0.5f) - (dir * radius));

                        float3 point1 = position.Value + capsule.Center + offset;
                        float3 point2 = position.Value + capsule.Center - offset;

                        CapsulecastCommand capsuleCast = new CapsulecastCommand(point1, point2,
                                                                                radius, zero, 0, 0);
                        CapsuleCasts.TryAdd(entities[i], capsuleCast);
                    }
                }
Exemple #4
0
    private void Update()
    {
        for (int i = 0; i < asteroids.Count; i++)
        {
            Asteroid.displacements[i]     = asteroids[i].displacement;
            Asteroid.positions[i]         = asteroids[i].transform.position;
            Asteroid.rotations[i]         = asteroids[i].transform.rotation.eulerAngles;
            Asteroid.angularVelocities[i] = asteroids[i].angularVelocity;
            Asteroid.quaternions[i]       = asteroids[i].transform.rotation;
        }

        MoveJob moveJob = new MoveJob
        {
            deltaTime       = Time.deltaTime,
            displacement    = Asteroid.displacements,
            position        = Asteroid.positions,
            angularVelocity = Asteroid.angularVelocities,
            rotation        = Asteroid.rotations,
            boundsMax       = bounds.max,
            boundsMin       = bounds.min,
            boundsSize      = bounds.size,
            raycasts        = Asteroid.raycastCommands,
            radius          = asteroids[0].GetComponent <CapsuleCollider>().radius
        };

        JobHandle moveJobHande     = moveJob.Schedule(asteroids.Count, 32);
        JobHandle raycastJobHandle = CapsulecastCommand.ScheduleBatch(Asteroid.raycastCommands, Asteroid.raycastHits, 32, moveJobHande);

        raycastJobHandle.Complete();

        for (int i = 0; i < asteroids.Count; i++)
        {
            asteroids[i].transform.position = Asteroid.positions[i];
            asteroids[i].transform.rotation = Quaternion.Euler(Asteroid.rotations[i].x, Asteroid.rotations[i].y, Asteroid.rotations[i].z);
            if (Asteroid.raycastHits[i].normal != Vector3.zero)
            {
                asteroids[i].GetComponent <SpriteRenderer>().color = Color.red;
            }
        }
    }
Exemple #5
0
        public static void VisualiseCapsuleGizmos(CapsulecastCommand cast, Color color = default)
        {
            var offset = cast.direction * cast.distance;

            _gizmosQueue.Enqueue(() => GizmosExtensions.DrawWireCapsule(cast.point1 + offset, cast.point2 + offset, cast.radius, color));
        }
Exemple #6
0
 public static void VisualiseCapsuleCast(CapsulecastCommand cast, Color color = default, Color castColor = default)
 {
     _gizmosQueue.Enqueue(() => GizmosExtensions.DrawCapsuleCast(cast.point1, cast.point2, cast.radius, cast.direction, cast.distance, color, castColor));
 }
Exemple #7
0
            protected override JobHandle OnUpdate(JobHandle inputDeps)
            {
                PreCollisionSystem preCollisionSystem = World.Active.GetExistingManager <PreCollisionSystem>();

                if (preCollisionSystem != null)
                {
                    var entities     = preCollisionSystem.Entities;
                    var boxcasts     = preCollisionSystem.Boxcasts;
                    var spherecasts  = preCollisionSystem.Spherecasts;
                    var capsulecasts = preCollisionSystem.Capsulecasts;

                    EntityManager.CompleteAllJobs();

                    if (boxcasts.IsCreated && boxcasts.Length != 0)
                    {
                        var hitBoxCollider = new NativeArray <RaycastHit>(boxcasts.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

                        var transaction = EntityManager.BeginExclusiveEntityTransaction();

                        var job = new UpdateBoxDistDir {
                            Boxcasts          = boxcasts,
                            Entities          = entities,
                            entityTransaction = transaction
                        };


                        var handle = job.Schedule(boxcasts.Length / 3, 32, inputDeps);

                        EntityManager.ExclusiveEntityTransactionDependency = handle;

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        EntityManager.EndExclusiveEntityTransaction();

                        handle = BoxcastCommand.ScheduleBatch(boxcasts, hitBoxCollider, 1, default);

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        InvokeCollisionResponse(entities, hitBoxCollider, 0, boxcasts.Length);

                        hitBoxCollider.Dispose();
                    }

                    if (spherecasts.IsCreated && spherecasts.Length != 0)
                    {
                        var hitSphereCollider = new NativeArray <RaycastHit>(spherecasts.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

                        var transaction = EntityManager.BeginExclusiveEntityTransaction();

                        var job = new UpdateSphereDistDir {
                            Spherecasts       = spherecasts,
                            Entities          = entities,
                            entityTransaction = transaction,
                            StartIndex        = boxcasts.Length / 3
                        };

                        var handle = job.Schedule(spherecasts.Length / 3, 32, inputDeps);

                        EntityManager.ExclusiveEntityTransactionDependency = handle;

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        EntityManager.EndExclusiveEntityTransaction();

                        handle = SpherecastCommand.ScheduleBatch(spherecasts, hitSphereCollider, 1, default);

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        InvokeCollisionResponse(entities, hitSphereCollider, boxcasts.Length, spherecasts.Length);

                        hitSphereCollider.Dispose();
                    }

                    if (capsulecasts.IsCreated && capsulecasts.Length != 0)
                    {
                        var hitCapsuleCollider = new NativeArray <RaycastHit>(capsulecasts.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

                        var transaction = EntityManager.BeginExclusiveEntityTransaction();

                        var job = new UpdateCapsuleDistDir {
                            Capsulecasts      = capsulecasts,
                            Entities          = entities,
                            entityTransaction = transaction,
                            StartIndex        = (boxcasts.Length + spherecasts.Length) / 3
                        };

                        var handle = job.Schedule(capsulecasts.Length / 3, 32, inputDeps);

                        EntityManager.ExclusiveEntityTransactionDependency = handle;

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        EntityManager.EndExclusiveEntityTransaction();

                        handle = CapsulecastCommand.ScheduleBatch(capsulecasts, hitCapsuleCollider, 1, default);

                        Utils.Utils.ScheduleBatchedJobAndComplete(handle);

                        InvokeCollisionResponse(entities, hitCapsuleCollider, spherecasts.Length, capsulecasts.Length);

                        hitCapsuleCollider.Dispose();
                    }
                }
                return(inputDeps);
            }
Exemple #8
0
        private void BakeNodes(Stopwatch stopwatch, NativeArray <Node> _nodes, NativeArray <Link> _links, String logPrefix = "")
        {
            Int32 loopSize = 10;

            Int64 timer = stopwatch.ElapsedMilliseconds;

            LogWatch(stopwatch, ref timer, logPrefix + "Start: ");

            var linkGen = new GenerateLinks
            {
                count  = _nodes.Length,
                _links = _links
            };
            var linkGenHandle = linkGen.Schedule(_links.Length, loopSize);

            linkGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Node link gen: ");


            NativeArray <RaycastCommand> _losRays = new NativeArray <RaycastCommand>(_links.Length, Allocator.TempJob);
            var losRayGen = new LOSRayGen
            {
                count  = _nodes.Length,
                _links = _links,
                _nodes = _nodes,
                _rays  = _losRays,
                mask   = LayerIndex.world.mask
            };
            var losGenHandle = losRayGen.Schedule(_links.Length, loopSize, linkGenHandle);

            losGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "LOS rays gen: ");


            NativeArray <RaycastHit> _losCast = new NativeArray <RaycastHit>(_links.Length, Allocator.TempJob);
            var losCastHandle = RaycastCommand.ScheduleBatch(_losRays, _losCast, loopSize, losGenHandle);

            losCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "LOS rays cast: ");


            var losRead = new LOSRayRead
            {
                _hitRes = _losCast,
                _links  = _links,
            };
            var losReadHandle = losRead.Schedule(_links.Length, loopSize, losCastHandle);

            losReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "LOS rays read: ");


            NativeArray <RaycastCommand> _skyRays = new NativeArray <RaycastCommand>(_nodes.Length, Allocator.TempJob);
            var skyRayGen = new SkyRayGen
            {
                _nodes = _nodes,
                _rays  = _skyRays
            };
            var skyGenHandle = skyRayGen.Schedule(_nodes.Length, loopSize);

            skyGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Sky rays gen: ");


            NativeArray <RaycastHit> _skyHits = new NativeArray <RaycastHit>(_nodes.Length, Allocator.TempJob);
            var skyCastHandle = RaycastCommand.ScheduleBatch(_skyRays, _skyHits, loopSize, skyGenHandle);

            skyCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Sky rays cast: ");


            var skyRead = new SkyRayRead
            {
                _hits  = _skyHits,
                _nodes = _nodes
            };
            var skyReadHandle = skyRead.Schedule(_nodes.Length, loopSize, skyCastHandle);

            skyReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Sky rays read: ");


            NativeArray <RaycastCommand> _tpRays = new NativeArray <RaycastCommand>(_nodes.Length * tpCheckOffsets.Length, Allocator.TempJob);
            var toRayGen = new TPRayGen
            {
                _offsets = tpCheckOffsets,
                range    = 10f,
                _nodes   = _nodes,
                _rays    = _tpRays
            };
            var tpGenHandle = toRayGen.Schedule(_nodes.Length, loopSize);

            tpGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "TP rays gen: ");


            NativeArray <RaycastHit> _tpHits = new NativeArray <RaycastHit>(_nodes.Length * tpCheckOffsets.Length, Allocator.TempJob);
            var tpCastHandle = RaycastCommand.ScheduleBatch(_tpRays, _tpHits, loopSize, tpGenHandle);

            tpCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "TP rays cast: ");


            var tpRead = new TPRayRead
            {
                offCount = tpCheckOffsets.Length,
                _hits    = _tpHits,
                _nodes   = _nodes
            };
            var tpReadHandle = tpRead.Schedule(_nodes.Length, loopSize, tpCastHandle);

            tpReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "TP rays read: ");


            var distChecks = new LinkDistScore
            {
                rangeFactor = (15f * 2f) * (15f * 2f),
                _links      = _links,
                _nodes      = _nodes
            };
            var distCheckHandle = distChecks.Schedule(_links.Length, loopSize, linkGenHandle);

            distCheckHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Link distance scoring: ");


            NativeArray <CapsulecastCommand> _groundCapsules = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            var groundHumanCastGen = new GroundCastsGen
            {
                _links = _links,
                _nodes = _nodes,
                _caps  = _groundCapsules,
                fudge  = Vector3.up * 0.01f,
                hull   = humanData
            };
            var groundHumanGenHandle = groundHumanCastGen.Schedule(_links.Length, 100, linkGenHandle);

            groundHumanGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Human ground position gen: ");


            NativeArray <RaycastHit> _groundCapsuleHits = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundHumanCastHandle = CapsulecastCommand.ScheduleBatch(_groundCapsules, _groundCapsuleHits, loopSize, groundHumanGenHandle);

            groundHumanCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Human ground position cast: ");


            NativeArray <CapsulecastCommand> _groundCapsules2 = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            NativeArray <Vector3>            _groundVecs1     = new NativeArray <Vector3>(2 * _links.Length, Allocator.TempJob);
            var groundHumanCastRead = new GroundCastsReadGen
            {
                _links     = _links,
                _nodes     = _nodes,
                _hitRes    = _groundCapsuleHits,
                _caps      = _groundCapsules2,
                _groundPos = _groundVecs1,
                hull       = humanData,
                fudge      = Vector3.up * 0.01f
            };
            var groundHumanCastReadHandle = groundHumanCastRead.Schedule(_links.Length, loopSize, groundHumanCastHandle);

            groundHumanCastReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Human ground position read: ");


            NativeArray <RaycastHit> _groundCapsuleHits2 = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundHumanCastHandle2 = CapsulecastCommand.ScheduleBatch(_groundCapsules2, _groundCapsuleHits2, loopSize, groundHumanCastReadHandle);

            groundHumanCastHandle2.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Human ground position casts2: ");


            var groundHumanCastRead2 = new GroundCastsReadGen2
            {
                _links  = _links,
                _nodes  = _nodes,
                _hitRes = _groundCapsuleHits2,
                hull    = humanData,
            };
            var groundHumanCastRead2Handle = groundHumanCastRead2.Schedule(_links.Length, loopSize, groundHumanCastHandle2);

            groundHumanCastRead2Handle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Human ground position read2: ");



            NativeArray <CapsulecastCommand> _groundGolemCapsules = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            var groundGolemCastGen = new GroundCastsGen
            {
                _links = _links,
                _nodes = _nodes,
                _caps  = _groundGolemCapsules,
                fudge  = Vector3.up * 0.01f,
                hull   = golemData
            };
            var groundGolemGenHandle = groundGolemCastGen.Schedule(_links.Length, loopSize, groundHumanCastHandle2);

            groundGolemGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Golem ground position gen: ");


            NativeArray <RaycastHit> _groundGolemCapsuleHits = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundGolemCastHandle = CapsulecastCommand.ScheduleBatch(_groundGolemCapsules, _groundGolemCapsuleHits, loopSize, groundGolemGenHandle);

            groundGolemCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Golem ground position cast: ");


            NativeArray <CapsulecastCommand> _groundGolemCapsules2 = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            NativeArray <Vector3>            _groundGolemVecs1     = new NativeArray <Vector3>(2 * _links.Length, Allocator.TempJob);
            var groundGolemCastRead = new GroundCastsReadGen
            {
                _links     = _links,
                _nodes     = _nodes,
                _hitRes    = _groundGolemCapsuleHits,
                _caps      = _groundGolemCapsules2,
                _groundPos = _groundGolemVecs1,
                hull       = golemData,
                fudge      = Vector3.up * 0.01f
            };
            var groundGolemCastReadHandle = groundGolemCastRead.Schedule(_links.Length, loopSize, groundGolemCastHandle);

            groundGolemCastReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Golem ground position read: ");


            NativeArray <RaycastHit> _groundGolemCapsuleHits2 = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundGolemCastHandle2 = CapsulecastCommand.ScheduleBatch(_groundGolemCapsules2, _groundGolemCapsuleHits2, loopSize, groundGolemCastReadHandle);

            groundGolemCastHandle2.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Golem ground position casts2: ");


            var groundGolemCastRead2 = new GroundCastsReadGen2
            {
                _links  = _links,
                _nodes  = _nodes,
                _hitRes = _groundGolemCapsuleHits2,
                hull    = golemData,
            };
            var groundGolemCastRead2Handle = groundGolemCastRead2.Schedule(_links.Length, loopSize, groundGolemCastHandle2);

            groundGolemCastRead2Handle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Golem ground position read2: ");



            NativeArray <CapsulecastCommand> _groundQueenCapsules = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            var groundQueenCastGen = new GroundCastsGen
            {
                _links = _links,
                _nodes = _nodes,
                _caps  = _groundQueenCapsules,
                fudge  = Vector3.up * 0.01f,
                hull   = queenData
            };
            var groundQueenGenHandle = groundQueenCastGen.Schedule(_links.Length, loopSize, groundHumanCastHandle2);

            groundQueenGenHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Queen ground position gen: ");


            NativeArray <RaycastHit> _groundQueenCapsuleHits = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundQueenCastHandle = CapsulecastCommand.ScheduleBatch(_groundQueenCapsules, _groundQueenCapsuleHits, loopSize, groundQueenGenHandle);

            groundQueenCastHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Queen ground position cast: ");


            NativeArray <CapsulecastCommand> _groundQueenCapsules2 = new NativeArray <CapsulecastCommand>(2 * _links.Length, Allocator.TempJob);
            NativeArray <Vector3>            _groundQueenVecs1     = new NativeArray <Vector3>(2 * _links.Length, Allocator.TempJob);
            var groundQueenCastRead = new GroundCastsReadGen
            {
                _links     = _links,
                _nodes     = _nodes,
                _hitRes    = _groundQueenCapsuleHits,
                _caps      = _groundQueenCapsules2,
                _groundPos = _groundQueenVecs1,
                hull       = queenData,
                fudge      = Vector3.up * 0.01f
            };
            var groundQueenCastReadHandle = groundQueenCastRead.Schedule(_links.Length, loopSize, groundQueenCastHandle);

            groundQueenCastReadHandle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Queen ground position read: ");


            NativeArray <RaycastHit> _groundQueenCapsuleHits2 = new NativeArray <RaycastHit>(2 * _links.Length, Allocator.TempJob);
            var groundQueenCastHandle2 = CapsulecastCommand.ScheduleBatch(_groundQueenCapsules2, _groundQueenCapsuleHits2, loopSize, groundQueenCastReadHandle);

            groundQueenCastHandle2.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Queen ground position casts2: ");


            var groundQueenCastRead2 = new GroundCastsReadGen2
            {
                _links  = _links,
                _nodes  = _nodes,
                _hitRes = _groundQueenCapsuleHits2,
                hull    = queenData,
            };
            var groundQueenCastRead2Handle = groundQueenCastRead2.Schedule(_links.Length, loopSize, groundQueenCastHandle2);

            groundQueenCastRead2Handle.Complete();
            LogWatch(stopwatch, ref timer, logPrefix + "Queen ground position read2: ");



            // TODO: Slope
            // TODO: Hull

            _losRays.Dispose();
            _losCast.Dispose();
            _skyRays.Dispose();
            _skyHits.Dispose();
            _tpRays.Dispose();
            _tpHits.Dispose();
            _groundCapsules.Dispose();
            _groundCapsuleHits.Dispose();
            _groundCapsules2.Dispose();
            _groundCapsuleHits2.Dispose();
            _groundVecs1.Dispose();
            _groundGolemCapsules.Dispose();
            _groundGolemCapsuleHits.Dispose();
            _groundGolemCapsules2.Dispose();
            _groundGolemCapsuleHits2.Dispose();
            _groundGolemVecs1.Dispose();
            _groundQueenCapsules.Dispose();
            _groundQueenCapsuleHits.Dispose();
            _groundQueenCapsules2.Dispose();
            _groundQueenCapsuleHits2.Dispose();
            _groundQueenVecs1.Dispose();
        }
Exemple #9
0
            public void Execute(Int32 index)
            {
                var link = _links[index];

                if (!link.valid)
                {
                    return;
                }
                var node1 = _nodes[link.node1ID];

                if (node1.forbiddenHulls.HasFlag(hull.hullMask))
                {
                    return;
                }
                var node2 = _nodes[link.node2ID];

                if (node2.forbiddenHulls.HasFlag(hull.hullMask))
                {
                    return;
                }

                var offset = index * 2;
                var hit1   = _hitRes[offset];
                var hit2   = _hitRes[offset + 1];

                Single  radiusMod      = hull.radius * 0.5f + 0.005f;
                Vector3 bottomEdgeVec  = Vector3.up * (hull.height * 0.5f - hull.radius);
                Vector3 bottomPointVec = Vector3.up * (hull.height * 0.5f);


                Vector3 foot1 = node1.position + fudge + fudge + bottomPointVec;
                Vector3 foot2 = node2.position + fudge + fudge + bottomPointVec;

                if (hit1.collider != null)
                {
                    foot1 += Vector3.up * radiusMod + Vector3.down * hit1.distance;
                }

                if (hit2.collider != null)
                {
                    foot2 += Vector3.up * radiusMod + Vector3.down * hit2.distance;
                }

                _groundPos[offset]     = foot1;
                _groundPos[offset + 1] = foot2;

                _caps[offset] = new CapsulecastCommand
                {
                    point1    = foot1 + bottomEdgeVec,
                    point2    = foot1 - bottomEdgeVec,
                    direction = Vector3.zero,
                    distance  = 0f,
                    layerMask = LayerIndex.world.mask | LayerIndex.defaultLayer.mask,
                    radius    = hull.radius
                };

                _caps[offset + 1] = new CapsulecastCommand
                {
                    point1    = foot2 + bottomEdgeVec,
                    point2    = foot2 - bottomEdgeVec,
                    direction = Vector3.zero,
                    distance  = 0f,
                    layerMask = LayerIndex.world.mask | LayerIndex.defaultLayer.mask,
                    radius    = hull.radius
                };
            }