Exemple #1
0
        public IntVector3 Truncate(IntGrid3 box)
        {
            int x = Math.Min(Math.Max(this.X, box.X1), box.X2);
            int y = Math.Min(Math.Max(this.Y, box.Y1), box.Y2);
            int z = Math.Min(Math.Max(this.Z, box.Z1), box.Z2);

            return(new IntVector3(x, y, z));
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw base.GetConvertFromException(value);
            }

            string source = value as string;

            if (source == null)
            {
                return(base.ConvertFrom(context, culture, value));
            }

            return(IntGrid3.Parse(source));
        }
Exemple #3
0
        public static void Calculate3(IntVector3 viewerLocation, int visionRange, VisionMap visibilityMap, IntSize3 mapSize,
                                      Func <IntVector3, bool> blockerDelegate)
        {
            visibilityMap.Clear();

            if (blockerDelegate(viewerLocation) == true)
            {
                return;
            }

            var g = new IntGrid3(new IntVector3(), mapSize);

            g = g.Offset(-viewerLocation.X, -viewerLocation.Y, -viewerLocation.Z);
            var vr = new IntVector3(visionRange, visionRange, visionRange);

            g = g.Intersect(new IntGrid3(vr, -vr));

            int visionRangeSquared = (visionRange + 1) * (visionRange + 1);             // +1 to get a bit bigger view area

            foreach (var dst in g.Range())
            {
                if (dst.LengthSquared > visionRangeSquared)
                {
                    continue;
                }

                bool vis = FindLos3(viewerLocation, dst, blockerDelegate);
                visibilityMap[dst] = vis;

                // XXX Cheat a bit so that the floor will be visible
                if (vis && dst.Z == 0 && viewerLocation.Z > 1)
                {
                    visibilityMap[dst.SetZ(dst.Z - 1)] = true;
                }
            }
        }
        /// <summary>
        /// Find route from src to destination area
        /// </summary>
        public static AStarResult FindArea(IEnvironmentObject env, IntVector3 src, DirectionSet srcPositioning, IntGrid3 dstArea,
                                           int maxNodeCount = 200000, CancellationToken?cancellationToken = null)
        {
            var initLocs = env.GetPositioningLocations(src, srcPositioning);
            var target   = new AStarAreaTarget(env, dstArea);

            return(Find(initLocs, target, maxNodeCount, cancellationToken));
        }
Exemple #5
0
 public void Remove(IntGrid3 box)
 {
     m_boxs.Remove(box);
 }
Exemple #6
0
 public void Add(IntGrid3 box)
 {
     m_boxs.Add(box);
 }
Exemple #7
0
 public AStarAreaTarget(IEnvironmentObject env, IntGrid3 destination)
     : base(env)
 {
     m_destination = destination;
 }