Ejemplo n.º 1
0
        public virtual void SetTarget(IPoint3D target)
        {
            if (IsDisposed || Target == target)
            {
                return;
            }

            if (target == null)
            {
                Target = null;
                return;
            }

            if (target is IEntity)
            {
                Target = (IEntity)target;
                return;
            }

            if (Target is Mobile)
            {
                ((Mobile)Target).Location = target.Clone3D();
                return;
            }

            if (Target is Item)
            {
                ((Item)Target).Location = target.Clone3D();
                return;
            }

            Target = new Entity(Serial.Zero, target.Clone3D(), Map);
        }
Ejemplo n.º 2
0
        public static Point3D GetWorldTop(this IPoint3D p, Map map)
        {
            if (map == null || map == Map.Internal)
            {
                return(p.ToPoint3D());
            }

            Point3D point;

            if (p is Item)
            {
                point = p.Clone3D(0, 0, ((Item)p).ItemData.Height);
            }
            else if (p is Mobile)
            {
                point = p.Clone3D(0, 0, 20);
            }
            else if (p is Entity)
            {
                point = p.Clone3D(0, 0, 5);
            }
            else
            {
                point = p.ToPoint3D();
            }

            int z, a, t;

            GetAverageZ(point, map, out z, out a, out t);

            point.Z = t;

            return(point);
        }
Ejemplo n.º 3
0
        public virtual void SetSource(IPoint3D source)
        {
            if (IsDisposed || Source == source)
            {
                return;
            }

            if (source == null)
            {
                Source = null;
                return;
            }

            if (source is IEntity)
            {
                Source = (IEntity)source;
                Map    = Source.Map;
                return;
            }

            if (Source is Mobile)
            {
                ((Mobile)Source).Location = source.Clone3D();
                return;
            }

            if (Source is Item)
            {
                ((Item)Source).Location = source.Clone3D();
                return;
            }

            Source = new Entity(Serial.Zero, source.Clone3D(), Source != null ? Source.Map : Map);
        }
Ejemplo n.º 4
0
        public static Point3D GetRandomPoint3D(
            this IPoint3D start,
            int minRange,
            int maxRange,
            Map map,
            bool checkLOS,
            bool checkSpawn)
        {
            if ((map == null || map == Map.Internal) && start is IEntity)
            {
                map = ((IEntity)start).Map;
            }

            double  a, r;
            int     x, y;
            Point3D s, p;

            var c = 30;

            do
            {
                a = Utility.RandomDouble() * Math.PI * 2;
                r = minRange + (Math.Sqrt(Utility.RandomDouble()) * (maxRange - minRange));

                x = (int)(r * Math.Cos(a));
                y = (int)(r * Math.Sin(a));

                s = start.Clone3D(0, 0, 16);
                p = start.Clone3D(x, y);

                if (map != null)
                {
                    p = p.GetSurfaceTop(map);
                }

                if (map == null || ((!checkLOS || map.LineOfSight(s, p)) && (!checkSpawn || map.CanSpawnMobile(p))))
                {
                    break;
                }
            }while (--c >= 0);

            if (c >= 0)
            {
                return(p);
            }

            if (map != null)
            {
                return(start.GetSurfaceTop(map));
            }

            return(start.ToPoint3D());
        }
Ejemplo n.º 5
0
        public void EndTarget(Mobile m, CellarStyle style, IPoint3D p)
        {
            BaseHouse house;
            var       loc = p.Clone3D();

            if (!CellarAddon.CanPlace(m, loc, out house))
            {
                return;
            }

            Style = style;

            var addon = Addon;

            addon.MoveToWorld(loc, m.Map);

            /*if (house is TownHouse)
             * {
             *      var th = (TownHouse)house;
             *
             *      if (th.ForSaleSign != null)
             *      {
             *              var z = addon.Components.Min(c => c.Z - 1);
             *
             *              if (th.ForSaleSign.MinZ > z)
             *              {
             *                      th.ForSaleSign.MinZ = z;
             *              }
             *      }
             * }*/

            Delete();
        }
Ejemplo n.º 6
0
        public static Point3D GetRandomPoint3D(this IPoint3D start, int minRange, int maxRange)
        {
            var angle  = Utility.RandomDouble() * Math.PI * 2;
            var radius = minRange + (Math.Sqrt(Utility.RandomDouble()) * (maxRange - minRange));

            var x = (int)(radius * Math.Cos(angle));
            var y = (int)(radius * Math.Sin(angle));

            return(start.Clone3D(x, y));
        }
Ejemplo n.º 7
0
        public static Point3D GetSurfaceTop(this IPoint3D p, Map map, bool items = true)
        {
            if (map == null || map == Map.Internal)
            {
                return(p.ToPoint3D());
            }

            Point3D point = Point3D.Zero;

            if (p is Item)
            {
                point = p.Clone3D(0, 0, ((Item)p).ItemData.Height);
            }
            else if (p is Mobile)
            {
                point = p.Clone3D(0, 0, 20);
            }

            /*else
             * {
             *      point = p.Clone3D(0, 0, 5);
             * }*/

            object o = map.GetTopSurface(point);

            if (o != null && o != p)
            {
                if (o is LandTile)
                {
                    point.Z = ((LandTile)o).Z + ((LandTile)o).Height + 1;
                }
                else if (o is StaticTile)
                {
                    point.Z = ((StaticTile)o).Z + ((StaticTile)o).Height + 1;
                }
                else if (o is Item && items)
                {
                    point = ((Item)o).GetSurfaceTop();
                }
            }

            return(point);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Iterates through a Point3D collection representing all locations within 'min' and 'max' range of 'center' on the
        ///     given 'map'.
        /// </summary>
        public static void ScanRange(
            this IPoint3D center,
            Map map,
            int min,
            int max,
            Predicate <ScanRangeResult> handler,
            bool avgZ = true)
        {
            if (map == null || map == Map.Internal)
            {
                return;
            }

            var ml = Math.Abs(Math.Min(min, max));
            var mr = Math.Abs(Math.Max(min, max));

            min = ml;
            max = mr;

            var die = false;

            for (var x = -max; x <= max; x++)
            {
                for (var y = -max; y <= max; y++)
                {
                    var distance = (int)Math.Sqrt(x * x + y * y);

                    if (distance >= min && distance <= max)
                    {
                        var p = center.Clone3D(x, y);

                        p.Z = avgZ ? p.GetAverageZ(map) : center.Z;

                        die = handler(new ScanRangeResult(center, map, p, distance, min, max));
                    }

                    if (die)
                    {
                        break;
                    }
                }

                if (die)
                {
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        public void EndTarget(Mobile m, CellarStyle style, IPoint3D p)
        {
            BaseHouse house;
            Point3D   loc = p.Clone3D();

            if (!CellarAddon.CanPlace(m, loc, out house))
            {
                return;
            }

            Style = style;

            var addon = Addon;

            addon.MoveToWorld(loc, m.Map);

            Delete();
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Iterates through a Point3D collection representing all locations within 'range' range of 'center' on the given
        ///     'map'.
        /// </summary>
        public static void ScanRange(
            this IPoint3D center,
            Map map,
            int range,
            Predicate <ScanRangeResult> handler,
            bool avgZ = true)
        {
            if (center == null || map == null || map == Map.Internal || handler == null)
            {
                return;
            }

            range = Math.Abs(range);

            var die = false;

            for (var x = -range; x <= range; x++)
            {
                for (var y = -range; y <= range; y++)
                {
                    var distance = (int)Math.Sqrt(x * x + y * y);

                    if (distance <= range)
                    {
                        var p = center.Clone3D(x, y);

                        p.Z = avgZ ? p.GetAverageZ(map) : center.Z;

                        die = handler(new ScanRangeResult(center, map, p, distance, range));
                    }

                    if (die)
                    {
                        break;
                    }
                }

                if (die)
                {
                    break;
                }
            }
        }
Ejemplo n.º 11
0
 public Shape3D(IPoint3D center)
 {
     _Center = center.Clone3D();
 }
Ejemplo n.º 12
0
		public virtual void SetSource(IPoint3D source)
		{
			if (IsDisposed || Source == source)
			{
				return;
			}

			if (source == null)
			{
				Source = null;
				return;
			}

			if (source is IEntity)
			{
				Source = (IEntity)source;
				Map = Source.Map;
				return;
			}

			if (Source is Mobile)
			{
				((Mobile)Source).Location = source.Clone3D();
				return;
			}

			if (Source is Item)
			{
				((Item)Source).Location = source.Clone3D();
				return;
			}

			Source = new Entity(Serial.Zero, source.Clone3D(), Source != null ? Source.Map : Map);
		}
Ejemplo n.º 13
0
		public virtual void SetTarget(IPoint3D target)
		{
			if (IsDisposed || Target == target)
			{
				return;
			}

			if (target == null)
			{
				Target = null;
				return;
			}

			if (target is IEntity)
			{
				Target = (IEntity)target;
				return;
			}

			if (Target is Mobile)
			{
				((Mobile)Target).Location = target.Clone3D();
				return;
			}

			if (Target is Item)
			{
				((Item)Target).Location = target.Clone3D();
				return;
			}

			Target = new Entity(Serial.Zero, target.Clone3D(), Map);
		}
Ejemplo n.º 14
0
 public static Point3D Lerp3D(this IPoint3D start, int x, int y, int z, double percent)
 {
     return(start.Clone3D((int)((x - start.X) * percent), (int)((y - start.Y) * percent), (int)((z - start.Z) * percent)));
 }
Ejemplo n.º 15
0
		public Shape3D(IPoint3D center)
		{
			_Center = center.Clone3D();
		}