コード例 #1
0
        /// <summary>
        /// Where the hitbox is located when the vehicle is traveling on a given surface.
        /// e.g. Walking on a slightly slanted surface may push the hitbox up slightly from its surfaceposition
        /// to avoid its corner clipping into the surface.
        /// Maybe TODO future: Orientation instead of Position?
        /// </summary>
        public virtual Orientation HitboxOffset(ObstacleSurface surface)
        {
            //TODO: This should probably use more detail from the Hitbox (probably call a function on it).
            //For now just assuming it is a square hitbox.
            Vector normal = surface.GetNormal();

            if (normal.z > 1 / Math.Sqrt(2))
            {
                //Just going to prop the hitbox up enough to avoid clipping into the surface.
                //height = hitbox diagonal * (normal dot diagonal unit vector) / (normal dot vertical unit vector)
                double      heightAdjust = this.Hitbox.MaxXIncrease(default(Rotation)) * (Math.Abs(normal.x) + Math.Abs(normal.y)) / normal.z;
                Orientation adjustment;
                adjustment.x         = 0;
                adjustment.y         = 0;
                adjustment.z         = (int)heightAdjust;
                adjustment.Direction = 0;
                adjustment.Roll      = 0;
                adjustment.Tilt      = 0;
                return(adjustment);
            }
            else
            {
                throw new NotImplementedException("Offset for sides isn't supported yet.");
            }
        }
コード例 #2
0
 public ConsideredPosition(Point position, ObstacleSurface surface, int score, PoseMechanism pose)
 {
     Position  = position;
     Pose      = pose;
     RestingOn = surface;
     CostScore = score;
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="surface"></param>
        /// <returns></returns>
        public virtual bool CanUse(ObstacleSurface surface)
        {
            //By default can use surfaces as long as they're less than a 45 degree angle.

            if (surface.GetNormal().z > 1 / Math.Sqrt(2))
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        //public List<ConsideredPosition> EndPoints;

        public void AddStartPoint(ObstacleSurface mySurface, Point position, int score, ConsideredPosition previousPosition, PoseMechanism pose, TryGoEvent context)
        {
            if (StartPoints == null)
            {
                StartPoints = new List <ConsideredPosition>();
            }
            else
            {
                foreach (ConsideredPosition point in StartPoints)
                {
                    if (point.Position.Equals(position))
                    {
                        if (score < point.CostScore)
                        {
                            //TODO: I don't think this can actually be reached. It might be good to update scores of future points if it does though?
                            //There's not a good way to do that currently though, so not doing that right now.
                            point.PreviousPositions.Insert(0, previousPosition);
                            point.CostScore = score;
                        }
                        else
                        {
                            point.PreviousPositions.Add(previousPosition);
                        }
                        return;
                    }
                }
            }
            //Not found yet, need to create a new point.
            ConsideredPosition newPoint = new ConsideredPosition(position, mySurface, score, pose);

            StartPoints.Add(newPoint);
            //Since it's new, connect to all end points on this surface.
            if (EndPoints != null)
            {
                //foreach (ConsideredPosition endPoint in EndPoints)
                //{
                //    context.ConsiderSurfacePath(newPoint, endPoint);
                //}
            }
        }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="command">Action that is trying to be satisfied/accomplished.</param>
 /// <param name="surface">Surface this is on. If the obstacle is null, this is in air instead of on a surface.</param>
 /// <param name="targetData">Cached data for calculations from this mechanism for this command.</param>
 /// <returns>Null if there are no targets on the surface. Else a list of regions that might allow the acting MOB to
 /// satisfy the action - it doesn't have to be guaranteed that all spots in the region will satisfy the action, but
 /// all spots that satisfy the action must be in the region.</returns>
 public abstract List <TargetRegion> TargetsOnSurface(QueuedCommand command, ObstacleSurface surface, ref object targetData);
コード例 #6
0
 public bool EqualTo(ObstacleSurface other)
 {
     return(manager == other.manager && surfaceIndex == other.surfaceIndex);
 }
コード例 #7
0
        //public abstract Hitbox ExpandByHitbox(Hitbox hitbox, Rotation rotation);

        //TODO: This probably goes elsewhere. Finds all obstacles nearby this obstacle, has each of those call MarkIntersectWithSurface on own surface with specified vehicle.
        //public void MarkIntersectWithNearbyObstacles(int ownSurfaceIndex, Hitbox vehicle);
        //TODO: Hitbox needs a size and offset. Worst case scenario is basically another obstacle.
        //  Actually on second thought, offset can be applied AFTER this, and for different offsets. Doesn't need to be appllied to generate the total 3D overlap of an obstacle.
        public abstract void MarkIntersectWithSurface(ObstacleSurface otherSurface, MovementMechanism forMechanism);
コード例 #8
0
 public override List <TargetRegion> TargetsOnSurface(QueuedCommand command, ObstacleSurface surface, ref object targetData)
 {
     //TODO
     throw new NotImplementedException();
 }