Inheritance: ISpawner
Exemplo n.º 1
0
        protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map)
        {
            Item item = CreateItem();

            item.OnBeforeSpawn(loc, map);
            item.MoveToWorld(loc, map);
            item.OnAfterSpawn();

            return(item);
        }
		public override object Spawn( SpawnEntry entry )
		{
			Region region = entry.Region;
			Map map = region.Map;

			Point3D loc = entry.RandomSpawnLocation( this.Height, this.Land, this.Water );
			if ( loc == Point3D.Zero )
				return null;

			return Construct( entry, loc, map );
		}
Exemplo n.º 3
0
        public override ISpawnable Spawn(SpawnEntry entry)
        {
            Region region = entry.Region;
            Map    map    = region.Map;

            Point3D loc = entry.RandomSpawnLocation(this.Height, this.Land, this.Water);

            if (loc == Point3D.Zero)
            {
                return(null);
            }

            return(Construct(entry, loc, map));
        }
		public override object Spawn( SpawnEntry entry )
		{
			int index = Utility.Random( m_TotalWeight );

			for ( int i = 0; i < m_Elements.Length; i++ )
			{
				SpawnGroupElement element = m_Elements[i];

				if ( index < element.Weight )
					return element.SpawnDefinition.Spawn( entry );

				index -= element.Weight;
			}

			return null;
		}
Exemplo n.º 5
0
        public override ISpawnable Spawn(SpawnEntry entry)
        {
            int index = Utility.Random(m_TotalWeight);

            for (int i = 0; i < m_Elements.Length; i++)
            {
                SpawnGroupElement element = m_Elements[i];

                if (index < element.Weight)
                {
                    return(element.SpawnDefinition.Spawn(entry));
                }

                index -= element.Weight;
            }

            return(null);
        }
		protected override object Construct( SpawnEntry entry, Point3D loc, Map map )
		{
			Mobile mobile = CreateMobile();

			BaseCreature creature = mobile as BaseCreature;
			if ( creature != null )
			{
				creature.Home = entry.Home;
				creature.RangeHome = entry.Range;
			}

			if ( entry.Direction != SpawnEntry.InvalidDirection )
				mobile.Direction = entry.Direction;

			mobile.OnBeforeSpawn( loc, map );
			mobile.MoveToWorld( loc, map );
			mobile.OnAfterSpawn();

			return mobile;
		}
Exemplo n.º 7
0
        protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map)
        {
            Mobile mobile = CreateMobile();

            if (mobile is BaseCreature creature)
            {
                creature.Home      = entry.HomeLocation;
                creature.RangeHome = entry.HomeRange;
            }

            if (entry.Direction != SpawnEntry.InvalidDirection)
            {
                mobile.Direction = entry.Direction;
            }

            mobile.OnBeforeSpawn(loc, map);
            mobile.MoveToWorld(loc, map);
            mobile.OnAfterSpawn();

            return(mobile);
        }
Exemplo n.º 8
0
        public static bool CanSpawn(Region region, params Type[] types)
        {
            while (region != null)
            {
                if (!region.AllowSpawn())
                {
                    return(false);
                }

                BaseRegion br = region as BaseRegion;

                if (br != null)
                {
                    if (br.Spawns != null)
                    {
                        for (int i = 0; i < br.Spawns.Length; i++)
                        {
                            SpawnEntry entry = br.Spawns[i];

                            if (entry.Definition.CanSpawn(types))
                            {
                                return(true);
                            }
                        }
                    }

                    if (br.ExcludeFromParentSpawns)
                    {
                        return(false);
                    }
                }

                region = region.Parent;
            }

            return(false);
        }
Exemplo n.º 9
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int id = reader.ReadInt();

                SpawnEntry entry = (SpawnEntry)SpawnEntry.Table[id];

                if (entry != null)
                {
                    entry.Deserialize(reader, version);
                }
                else
                {
                    SpawnEntry.Remove(reader, version);
                }
            }
        }
Exemplo n.º 10
0
		protected override ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map )
		{
			Item item = CreateItem();

			item.OnBeforeSpawn( loc, map );
			item.MoveToWorld( loc, map );
			item.OnAfterSpawn();

			return item;
		}
Exemplo n.º 11
0
		public abstract ISpawnable Spawn( SpawnEntry entry );
Exemplo n.º 12
0
		protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map)
		{
			Mobile mobile = CreateMobile();

			BaseCreature creature = mobile as BaseCreature;
			if ( creature != null )
			{
				creature.Home = entry.HomeLocation;
				creature.HomeMap = map;
				creature.RangeHome = entry.HomeRange;
			}

			if ( entry.Direction != SpawnEntry.InvalidDirection )
				mobile.Direction = entry.Direction;

			mobile.OnBeforeSpawn( loc, map );
			mobile.MoveToWorld( loc, map );
			mobile.OnAfterSpawn();

			return mobile;
		}
Exemplo n.º 13
0
		public override ISpawnable Spawn( SpawnEntry entry )
		{
			Region region = entry.Region;
			Map map = region.Map;

			Point3D loc = entry.RandomSpawnLocation( this.Height, this.Land, this.Water );
			if ( loc == Point3D.Zero )
				return null;

			return Construct( entry, loc, map );
		}
Exemplo n.º 14
0
		protected abstract ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map );
Exemplo n.º 15
0
 public abstract object Spawn( SpawnEntry entry );
Exemplo n.º 16
0
		protected abstract object Construct( SpawnEntry entry, Point3D loc, Map map );
Exemplo n.º 17
0
 protected abstract object Construct( SpawnEntry entry, Point3D loc, Map map );
Exemplo n.º 18
0
		public abstract object Spawn( SpawnEntry entry );
Exemplo n.º 19
0
		public override ISpawnable Spawn(SpawnEntry entry)
		{
			int index = Utility.Random( m_TotalWeight );

			for ( int i = 0; i < m_Elements.Length; i++ )
			{
				SpawnGroupElement element = m_Elements[i];

				if ( index < element.Weight )
					return element.SpawnDefinition.Spawn( entry );

				index -= element.Weight;
			}

			return null;
		}
Exemplo n.º 20
0
		public BaseRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent )
		{
			ReadString( xml["rune"], "name", ref m_RuneName, false );

			bool logoutDelayActive = true;
			ReadBoolean( xml["logoutDelay"], "active", ref logoutDelayActive, false );
			m_NoLogoutDelay = !logoutDelayActive;


			XmlElement spawning = xml["spawning"];
			if ( spawning != null )
			{
				ReadBoolean( spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false );

                SpawnZLevel zLevel = SpawnZLevel.Lowest;
                ReadEnum(spawning, "zLevel", ref zLevel, false);
                m_SpawnZLevel = zLevel;


				List<SpawnEntry> list = new List<SpawnEntry>();

				foreach ( XmlNode node in spawning.ChildNodes )
				{
					XmlElement el = node as XmlElement;

					if ( el != null )
					{
						SpawnDefinition def = SpawnDefinition.GetSpawnDefinition( el );
						if ( def == null )
							continue;

						int id = 0;
						if ( !ReadInt32( el, "id", ref id, true ) )
							continue;

						int amount = 0;
						if ( !ReadInt32( el, "amount", ref amount, true ) )
							continue;

						TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime;
						ReadTimeSpan( el, "minSpawnTime", ref minSpawnTime, false );

						TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime;
						ReadTimeSpan( el, "maxSpawnTime", ref maxSpawnTime, false );

						Point3D home = Point3D.Zero;
						int range = 0;

						XmlElement homeEl = el["home"];
						if ( ReadPoint3D( homeEl, map, ref home, false ) )
							ReadInt32( homeEl, "range", ref range, false );

                        Direction dir = SpawnEntry.InvalidDirection;
                        ReadEnum(el["direction"], "value", ref dir, false);

						SpawnEntry entry = new SpawnEntry( id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime );
						list.Add( entry );
					}
				}

				if ( list.Count > 0 )
				{
					m_Spawns = list.ToArray();
				}
			}
		}
Exemplo n.º 21
0
 protected abstract ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map);
Exemplo n.º 22
0
        public BaseRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent)
        {
            ReadString(xml["rune"], "name", ref m_RuneName, false);

            bool logoutDelayActive = true;

            ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false);
            m_NoLogoutDelay = !logoutDelayActive;


            XmlElement spawning = xml["spawning"];

            if (spawning != null)
            {
                ReadBoolean(spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false);

                SpawnZLevel zLevel = SpawnZLevel.Lowest;
                ReadEnum(spawning, "zLevel", ref zLevel, false);
                m_SpawnZLevel = zLevel;


                List <SpawnEntry> list = new List <SpawnEntry>();

                foreach (XmlNode node in spawning.ChildNodes)
                {
                    XmlElement el = node as XmlElement;

                    if (el != null)
                    {
                        SpawnDefinition def = SpawnDefinition.GetSpawnDefinition(el);
                        if (def == null)
                        {
                            continue;
                        }

                        int id = 0;
                        if (!ReadInt32(el, "id", ref id, true))
                        {
                            continue;
                        }

                        int amount = 0;
                        if (!ReadInt32(el, "amount", ref amount, true))
                        {
                            continue;
                        }

                        TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime;
                        ReadTimeSpan(el, "minSpawnTime", ref minSpawnTime, false);

                        TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime;
                        ReadTimeSpan(el, "maxSpawnTime", ref maxSpawnTime, false);

                        Point3D home  = Point3D.Zero;
                        int     range = 0;

                        XmlElement homeEl = el["home"];
                        if (ReadPoint3D(homeEl, map, ref home, false))
                        {
                            ReadInt32(homeEl, "range", ref range, false);
                        }

                        Direction dir = SpawnEntry.InvalidDirection;
                        ReadEnum(el["direction"], "value", ref dir, false);

                        SpawnEntry entry = new SpawnEntry(id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime);
                        list.Add(entry);
                    }
                }

                if (list.Count > 0)
                {
                    m_Spawns = list.ToArray();
                }
            }
        }
Exemplo n.º 23
0
 public abstract ISpawnable Spawn(SpawnEntry entry);