Beispiel #1
0
        public static float CheckIntersections(Creature creature, short heading, Point3D moveVector, float distance)
        {
            if (distance <= 0f)
            {
                return(0f);
            }

            WorldPosition targetPosition = moveVector.Clone().Add(creature.Position).ToWorldPosition();

            double minDistance = distance;

            List <Creature> around = Global.VisibleService.FindTargets(creature, creature.Position, distance + 40, TargetingAreaType.All);

            for (int x = 0; x < around.Count; x++)
            {
                if (around[x] == creature)
                {
                    continue;
                }

                short diff = Geom.GetAngleDiff(heading, Geom.GetHeading(creature.Position, around[x].Position));
                if (diff > 90)
                {
                    continue;
                }

                double d = Geom.DistanceToLine(around[x].Position, creature.Position, targetPosition);

                if (d > 40)
                {
                    continue;
                }

                d = creature.Position.DistanceTo(around[x].Position) - 40;

                if (d <= 0)
                {
                    return(0f);
                }

                if (d < minDistance)
                {
                    minDistance = d;
                }
            }

            return((float)(minDistance / distance));
        }