コード例 #1
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public void RemoveSpawns()
        {
            Defrag();

            for (int i = 0; i < m_Entries.Count; i++)
            {
                SpawnerEntry entry = m_Entries[i];

                for (int j = entry.Spawned.Count - 1; j >= 0; j--)
                {
                    ISpawnable e = entry.Spawned[j];

                    if (e != null)
                    {
                        m_Spawned.Remove(e);
                        entry.Spawned.RemoveAt(j);
                        e.Delete();
                    }
                }
            }

            if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running)
            {
                DoTimer();
            }

            InvalidateProperties();
        }
コード例 #2
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public SpawnerEntry AddEntry(string creaturename, int probability, int amount, bool dotimer)
        {
            SpawnerEntry entry = new SpawnerEntry(creaturename, probability, amount);

            m_Entries.Add(entry);
            if (dotimer)
            {
                DoTimer(TimeSpan.FromSeconds(1));
            }

            return(entry);
        }
コード例 #3
0
		public static void LoadEntry( Spawner spawner, XmlElement node )
		{
			string name = Utility.GetText( node["SpawnedName"], null );
			int prob = Utility.GetXMLInt32( Utility.GetText( node["SpawnedProbability"], "100" ), 100 );
			int count = Utility.GetXMLInt32( Utility.GetText( node["SpawnedMaxCount"], spawner.Count.ToString() ), spawner.Count );
			string parameters = Utility.GetText( node["Parameters"], null );
			string properties = Utility.GetText( node["Parameters"], null );

			SpawnerEntry entry = new SpawnerEntry( name, prob, count );
			entry.Parameters = parameters;
			entry.Properties = properties;

			spawner.Entries.Add( entry );
		}
コード例 #4
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public void RemoveSpawn(SpawnerEntry entry)
        {
            for (int i = entry.Spawned.Count - 1; i >= 0; i--)
            {
                ISpawnable e = entry.Spawned[i];

                if (e != null)
                {
                    entry.Spawned.RemoveAt(i);
                    m_Spawned.Remove(e);

                    e.Delete();
                }
            }
        }
コード例 #5
0
        public void RemoveCreatures(SpawnerEntry entry)
        {
            for (int i = entry.Creatures.Count - 1; i >= 0; i--)
            {
                IEntity e = entry.Creatures[i];

                if (e != null)
                {
                    entry.Creatures.RemoveAt(i);
                    m_Creatures.Remove(e);

                    e.Delete();
                }
            }
        }
コード例 #6
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public virtual void Spawn()
        {
            Defrag();

            if (m_Entries.Count > 0 && !IsFull)
            {
                int probsum = 0;

                for (int i = 0; i < m_Entries.Count; i++)
                {
                    if (!m_Entries[i].IsFull)
                    {
                        probsum += m_Entries[i].SpawnedProbability;
                    }
                }

                if (probsum > 0)
                {
                    int rand = Utility.RandomMinMax(1, probsum);

                    for (int i = 0; i < m_Entries.Count; i++)
                    {
                        SpawnerEntry entry = m_Entries[i];
                        if (!entry.IsFull)
                        {
                            bool success = true;

                            if (rand <= entry.SpawnedProbability)
                            {
                                EntryFlags flags;
                                success     = Spawn(entry, out flags);
                                entry.Valid = flags;
                                return;
                            }

                            if (success)
                            {
                                rand -= entry.SpawnedProbability;
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public void RemoveEntry(SpawnerEntry entry)
        {
            Defrag();

            for (int i = entry.Spawned.Count - 1; i >= 0; i--)
            {
                ISpawnable e = entry.Spawned[i];
                entry.Spawned.RemoveAt(i);
                if (e != null)
                {
                    e.Delete();
                }
            }

            m_Entries.Remove(entry);

            if (m_Running && !IsFull && m_Timer != null && !m_Timer.Running)
            {
                DoTimer();
            }

            InvalidateProperties();
        }
コード例 #8
0
        public int CountCreatures( SpawnerEntry entry )
        {
            Defrag();

            return entry.Creatures.Count;
        }
コード例 #9
0
        public SpawnerEntry AddEntry( string creaturename, int probability, int amount, bool dotimer )
        {
            SpawnerEntry entry = new SpawnerEntry( creaturename, probability, amount );
            m_Entries.Add( entry );
            if ( dotimer )
                DoTimer( TimeSpan.FromSeconds( 1 ) );

            return entry;
        }
コード例 #10
0
ファイル: Spawner.cs プロジェクト: greeduomacro/UO-Forever
		public int CountSpawns( SpawnerEntry entry )
		{
			Defrag();

			return entry.Spawned.Count;
		}
コード例 #11
0
ファイル: Spawner.cs プロジェクト: greeduomacro/UO-Forever
		public void RemoveSpawn( SpawnerEntry entry )
		{
			for ( int i = entry.Spawned.Count-1; i >= 0; i-- )
			{
				ISpawnable e = entry.Spawned[i];

				if ( e != null )
				{
					entry.Spawned.RemoveAt( i );
					m_Spawned.Remove( e );

					e.Delete();
				}
			}
		}
コード例 #12
0
        public int CountCreatures(SpawnerEntry entry)
        {
            Defrag();

            return(entry.Creatures.Count);
        }
コード例 #13
0
ファイル: SpawnerGump.cs プロジェクト: zerodowned/UO-Forever
        public SpawnerGump(Spawner spawner, SpawnerEntry focusentry, int page) : base(50, 50)
        {
            m_Spawner = spawner;
            m_Entry   = focusentry;
            m_Page    = page;

            AddPage(0);

            AddBackground(0, 0, 343, 371 + (m_Entry != null ? 44 : 0), 5054);

            AddHtml(95, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Creatures List</BASEFONT>", false, false);
            AddHtml(245, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>#</BASEFONT>", false, false);
            AddHtml(282, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Prb</BASEFONT>", false, false);

            //AddLabel( 95, 1, 0, "Creatures List" );

            int offset = 0;

            for (int i = 0; i < 13; i++)
            {
                int textindex  = i * 5;
                int entryindex = (m_Page * 13) + i;

                SpawnerEntry entry = null;

                if (entryindex < spawner.Entries.Count)
                {
                    entry = m_Spawner.Entries[entryindex];
                }

                if (entry == null || m_Entry != entry)
                {
                    AddButton(5, (22 * i) + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID(2, (i * 2)), GumpButtonType.Reply, 0);                           //Expand
                }
                else
                {
                    AddButton(5, (22 * i) + 21 + offset, entry != null ? 0xFBB : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID(2, (i * 2)), GumpButtonType.Reply, 0); //Unexpand
                }
                AddButton(38, (22 * i) + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + (i * 2)), GumpButtonType.Reply, 0);                                                //Delete

                AddImageTiled(71, (22 * i) + 20 + offset, 161, 23, 0xA40);                                                                                                //creature text box
                AddImageTiled(72, (22 * i) + 21 + offset, 159, 21, 0xBBC);                                                                                                //creature text box

                AddImageTiled(235, (22 * i) + 20 + offset, 35, 23, 0xA40);                                                                                                //maxcount text box
                AddImageTiled(236, (22 * i) + 21 + offset, 33, 21, 0xBBC);                                                                                                //maxcount text box

                AddImageTiled(273, (22 * i) + 20 + offset, 35, 23, 0xA40);                                                                                                //probability text box
                AddImageTiled(274, (22 * i) + 21 + offset, 33, 21, 0xBBC);                                                                                                //probability text box

                string     name        = "";
                string     probability = "";
                string     maxcount    = "";
                EntryFlags flags       = EntryFlags.None;

                if (entry != null)
                {
                    name        = (string)entry.SpawnedName;
                    probability = entry.SpawnedProbability.ToString();
                    maxcount    = entry.SpawnedMaxCount.ToString();
                    flags       = entry.Valid;

                    AddLabel(315, (22 * i) + 20 + offset, 0, spawner.CountSpawns(entry).ToString());
                }

                AddTextEntry(75, (22 * i) + 21 + offset, 156, 21, ((flags & EntryFlags.InvalidType) != 0) ? 33 : 0, textindex, name); //creature
                AddTextEntry(239, (22 * i) + 21 + offset, 30, 21, 0, textindex + 1, maxcount);                                        //max count
                AddTextEntry(277, (22 * i) + 21 + offset, 30, 21, 0, textindex + 2, probability);                                     //probability

                if (entry != null && m_Entry == entry)
                {
                    AddLabel(5, (22 * i) + 42, 0x384, "Params");
                    AddImageTiled(55, (22 * i) + 42, 253, 23, 0xA40);                       //Parameters
                    AddImageTiled(56, (22 * i) + 43, 251, 21, 0xBBC);                       //Parameters

                    AddLabel(5, (22 * i) + 64, 0x384, "Props");
                    AddImageTiled(55, (22 * i) + 64, 253, 23, 0xA40);                                                                              //Properties
                    AddImageTiled(56, (22 * i) + 65, 251, 21, 0xBBC);                                                                              //Properties

                    AddTextEntry(59, (22 * i) + 42, 248, 21, ((flags & EntryFlags.InvalidParams) != 0) ? 33 : 0, textindex + 3, entry.Parameters); //parameters
                    AddTextEntry(59, (22 * i) + 62, 248, 21, ((flags & EntryFlags.InvalidProps) != 0) ? 33 : 0, textindex + 4, entry.Properties);  //properties

                    offset += 44;
                }
            }

            AddButton(5, 347 + offset, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0);
            AddLabel(38, 347 + offset, 0x384, "Cancel");

            AddButton(5, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 2), GumpButtonType.Reply, 0);
            AddLabel(38, 325 + offset, 0x384, "Okay");

            AddButton(110, 325 + offset, 0xFB4, 0xFB6, GetButtonID(1, 3), GumpButtonType.Reply, 0);
            AddLabel(143, 325 + offset, 0x384, "Bring to Home");

            AddButton(110, 347 + offset, 0xFA8, 0xFAA, GetButtonID(1, 4), GumpButtonType.Reply, 0);
            AddLabel(143, 347 + offset, 0x384, "Total Respawn");

            AddButton(253, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 5), GumpButtonType.Reply, 0);
            AddLabel(286, 325 + offset, 0x384, "Apply");

            if (m_Page > 0)
            {
                AddButton(276, 308 + offset, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(276, 308 + offset, 0x25EA);
            }

            if ((m_Page + 1) * 13 <= m_Spawner.Entries.Count)
            {
                AddButton(293, 308 + offset, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(293, 308 + offset, 0x25E6);
            }
        }
コード例 #14
0
        public bool Spawn( SpawnerEntry entry, out EntryFlags flags )
        {
            Map map = Map;
            flags = EntryFlags.None;

            if ( map == null || map == Map.Internal || Parent != null )
                return false;

            //Defrag taken care of in Spawn(), beforehand
            //Count check taken care of in Spawn(), beforehand

            Type type = SpawnerType.GetType( entry.CreaturesName );

            if ( type != null )
            {
                try
                {
                    object o = null;
                    string[] paramargs;
                    string[] propargs;

                    if ( String.IsNullOrEmpty( entry.Properties ) )
                        propargs = new string[0];
                    else
                        propargs = CommandSystem.Split( entry.Properties.Trim() );

                    string[,] props = FormatProperties( propargs );

                    PropertyInfo[] realProps = GetTypeProperties( type, props );

                    if ( realProps == null )
                    {
                        flags = EntryFlags.InvalidProps;
                        return false;
                    }

                    if ( String.IsNullOrEmpty( entry.Parameters ) )
                        paramargs = new string[0];
                    else
                        paramargs = entry.Parameters.Trim().Split( ' ' );

                    ConstructorInfo[] ctors = type.GetConstructors();

                    for ( int i = 0; i < ctors.Length; ++i )
                    {
                        ConstructorInfo ctor = ctors[i];

                        if ( Add.IsConstructable( ctor, AccessLevel.GameMaster ) )
                        {
                            ParameterInfo[] paramList = ctor.GetParameters();

                            if ( paramargs.Length == paramList.Length )
                            {
                                object[] paramValues = Add.ParseValues( paramList, paramargs );

                                if ( paramValues != null )
                                {
                                    o = ctor.Invoke( paramValues );
                                    for ( int j = 0; j < realProps.Length; j++ )
                                    {
                                        if ( realProps[j] != null )
                                        {
                                            object toSet = null;
                                            string result = Properties.ConstructFromString( realProps[j].PropertyType, o, props[j, 1], ref toSet );
                                            if ( result == null )
                                                realProps[j].SetValue( o, toSet, null );
                                            else
                                            {
                                                flags = EntryFlags.InvalidProps;

                                                if ( o is IEntity )
                                                    ((IEntity)o).Delete();

                                                return false;
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }

                    if ( o is Mobile )
                    {
                        Mobile m = (Mobile)o;

                        m_Creatures.Add( m, entry );
                        entry.Creatures.Add( m );

                        Point3D loc = ( m is BaseVendor ? this.Location : GetSpawnPosition() );

                        m.OnBeforeSpawn( loc, map );
                        InvalidateProperties();

                        m.MoveToWorld( loc, map );

                        if ( m is BaseCreature )
                        {
                            BaseCreature c = (BaseCreature)m;

                            if( m_WalkingRange >= 0 )
                                c.RangeHome = m_WalkingRange;
                            else
                                c.RangeHome = m_HomeRange;

                            c.CurrentWayPoint = m_WayPoint;

                            if ( m_Team > 0 )
                                c.Team = m_Team;

                            c.Home = this.Location;
                            //c.Spawner = (ISpawner)this;
                        }

                        m.Spawner = this;
                        m.OnAfterSpawn();
                    }
                    else if ( o is Item )
                    {
                        Item item = (Item)o;

                        m_Creatures.Add( item, entry );
                        entry.Creatures.Add( item );

                        Point3D loc = GetSpawnPosition();

                        item.OnBeforeSpawn( loc, map );

                        item.MoveToWorld( loc, map );

                        item.Spawner = this;
                        item.OnAfterSpawn();
                    }
                    else
                    {
                        flags = EntryFlags.InvalidType | EntryFlags.InvalidParams;
                        return false;
                    }
                }
                catch ( Exception e )
                {
                    Console.WriteLine( "EXCEPTION CAUGHT: {0:X}", Serial );
                    Console.WriteLine( e );
                    return false;
                }

                InvalidateProperties(); //If its anywhere before finishing the spawning process, DEFRAG will nuke the entry.
                return true;
            }

            flags = EntryFlags.InvalidType;
            return false;
        }
コード例 #15
0
        public void RemoveCreatures( SpawnerEntry entry )
        {
            for ( int i = entry.Creatures.Count-1; i >= 0; i-- )
            {
                IEntity e = entry.Creatures[i];

                if ( e != null )
                {
                    entry.Creatures.RemoveAt( i );
                    m_Creatures.Remove( e );

                    e.Delete();
                }
            }
        }
コード例 #16
0
		public SpawnerGump( Spawner spawner, SpawnerEntry focusentry, int page ) : base( 50, 50 )
		{
			m_Spawner = spawner;
			m_Entry = focusentry;
			m_Page = page;

			AddPage( 0 );

			AddBackground( 0, 0, 343, 371 + ( m_Entry != null ? 44 : 0 ), 5054 );

			AddHtml( 95, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Creatures List</BASEFONT>", false, false );
			AddHtml( 245, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>#</BASEFONT>", false, false );
			AddHtml( 282, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Prb</BASEFONT>", false, false );

			//AddLabel( 95, 1, 0, "Creatures List" );

			int offset = 0;

			for ( int i = 0; i < 13; i++ )
			{
				int textindex = i * 5;
				int entryindex = ( m_Page * 13 ) + i;

				SpawnerEntry entry = null;

				if ( entryindex < spawner.Entries.Count )
					entry = m_Spawner.Entries[entryindex];

				if ( entry == null || m_Entry != entry )
					AddButton( 5, ( 22 * i ) + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID( 2, (i * 2) ), GumpButtonType.Reply, 0 ); //Expand
				else
					AddButton( 5, ( 22 * i ) + 21 + offset, entry != null ? 0xFBB : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID( 2, (i * 2) ), GumpButtonType.Reply, 0 ); //Unexpand

				AddButton( 38, ( 22 * i ) + 21 + offset, 0xFA2, 0xFA4, GetButtonID( 2, 1 + (i * 2) ), GumpButtonType.Reply, 0 ); //Delete

				AddImageTiled( 71, (22 * i) + 20 + offset, 161, 23, 0xA40 ); //creature text box
				AddImageTiled( 72, (22 * i) + 21 + offset, 159, 21, 0xBBC ); //creature text box

				AddImageTiled( 235, (22 * i) + 20 + offset, 35, 23, 0xA40 ); //maxcount text box
				AddImageTiled( 236, (22 * i) + 21 + offset, 33, 21, 0xBBC ); //maxcount text box

				AddImageTiled( 273, (22 * i) + 20 + offset, 35, 23, 0xA40 ); //probability text box
				AddImageTiled( 274, (22 * i) + 21 + offset, 33, 21, 0xBBC ); //probability text box

				string name = "";
				string probability = "";
				string maxcount = "";
				EntryFlags flags = EntryFlags.None;

				if ( entry != null )
				{
					name = (string)entry.SpawnedName;
					probability = entry.SpawnedProbability.ToString();
					maxcount = entry.SpawnedMaxCount.ToString();
					flags = entry.Valid;

					AddLabel( 315, (22 * i) + 20 + offset, 0, spawner.CountSpawns( entry ).ToString() );
				}

				AddTextEntry( 75, (22 * i) + 21 + offset, 156, 21, ( ( flags & EntryFlags.InvalidType ) != 0 ) ? 33 : 0, textindex, name ); //creature
				AddTextEntry( 239, (22 * i) + 21 + offset, 30, 21, 0, textindex + 1, maxcount); //max count
				AddTextEntry( 277, (22 * i) + 21 + offset, 30, 21, 0, textindex + 2, probability); //probability

				if ( entry != null && m_Entry == entry )
				{
					AddLabel( 5, (22 * i) + 42, 0x384, "Params" );
					AddImageTiled( 55, (22 * i) + 42, 253, 23, 0xA40 ); //Parameters
					AddImageTiled( 56, (22 * i) + 43, 251, 21, 0xBBC ); //Parameters

					AddLabel( 5, (22 * i) + 64, 0x384, "Props" );
					AddImageTiled( 55, (22 * i) + 64, 253, 23, 0xA40 ); //Properties
					AddImageTiled( 56, (22 * i) + 65, 251, 21, 0xBBC ); //Properties

					AddTextEntry( 59, (22 * i) + 42, 248, 21, ( ( flags & EntryFlags.InvalidParams ) != 0 ) ? 33 : 0, textindex + 3, entry.Parameters ); //parameters
					AddTextEntry( 59, (22 * i) + 62, 248, 21, ( ( flags & EntryFlags.InvalidProps ) != 0 ) ? 33 : 0, textindex + 4, entry.Properties ); //properties

					offset += 44;
				}
			}

			AddButton( 5, 347 + offset, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0 );
			AddLabel( 38, 347 + offset, 0x384, "Cancel" );

			AddButton( 5, 325 + offset, 0xFB7, 0xFB9, GetButtonID( 1, 2 ), GumpButtonType.Reply, 0 );
			AddLabel( 38, 325 + offset, 0x384, "Okay" );

			AddButton( 110, 325 + offset, 0xFB4, 0xFB6, GetButtonID( 1, 3 ), GumpButtonType.Reply, 0 );
			AddLabel( 143, 325 + offset, 0x384, "Bring to Home" );

			AddButton( 110, 347 + offset, 0xFA8, 0xFAA, GetButtonID( 1, 4 ), GumpButtonType.Reply, 0 );
			AddLabel( 143, 347 + offset, 0x384, "Total Respawn" );

			AddButton( 253, 325 + offset, 0xFB7, 0xFB9, GetButtonID( 1, 5 ), GumpButtonType.Reply, 0 );
			AddLabel( 286, 325 + offset, 0x384, "Apply" );

			if ( m_Page > 0 )
				AddButton( 276, 308 + offset, 0x15E3, 0x15E7, GetButtonID( 1, 0 ), GumpButtonType.Reply, 0 );
			else
				AddImage( 276, 308 + offset, 0x25EA );

			if ( (m_Page + 1) * 13 <= m_Spawner.Entries.Count )
				AddButton( 293, 308 + offset, 0x15E1, 0x15E5, GetButtonID( 1, 1 ), GumpButtonType.Reply, 0 );
			else
				AddImage( 293, 308 + offset, 0x25E6 );
		}
コード例 #17
0
		public override void OnResponse( NetState state, RelayInfo info )
		{
			if ( m_Spawner.Deleted )
				return;

			Mobile from = state.Mobile;

			int val = info.ButtonID - 1;

			if ( val < 0 )
				return;

			int type = val % 10;
			int index = val / 10;

			switch ( type )
			{
				case 0: //Cancel
					return;
				case 1:
				{
					switch ( index )
					{
						case 0:
						{
							if ( m_Spawner.Entries != null && m_Page > 0 )
							{
								m_Page--;
								m_Entry = null;
							}
							break;
						}
						case 1:
						{
							if ( m_Spawner.Entries != null && (m_Page + 1) * 13 <= m_Spawner.Entries.Count )
							{
								m_Page++;
								m_Entry = null;
							}
							break;
						}
						case 2: //Okay
						{
							CreateArray(info, state.Mobile, m_Spawner);
							return;
						}
						case 3:
						{
							m_Spawner.BringToHome();
							break;
						}
						case 4: // Complete respawn
						{
							m_Spawner.Respawn();
							break;
						}
						case 5:
						{
							CreateArray(info, state.Mobile, m_Spawner);
							break;
						}
					}
					break;
				}
				case 2:
				{
					int entryindex = ( index / 2 ) + ( m_Page * 13 );
					int buttontype = index % 2;

					if ( entryindex >= 0 && entryindex < m_Spawner.Entries.Count )
					{
						SpawnerEntry entry = m_Spawner.Entries[entryindex];
						if ( buttontype == 0 ) // Spawn creature
						{
							if ( m_Entry != null && m_Entry == entry )
								m_Entry = null;
							else
								m_Entry = entry;
						}
						else // Remove creatures
							m_Spawner.RemoveSpawn( entryindex );
					}

					CreateArray( info, state.Mobile, m_Spawner );
					break;
				}
			}

			if ( m_Entry != null && m_Spawner.Entries.Contains( m_Entry ) )
				state.Mobile.SendGump( new SpawnerGump( m_Spawner, m_Entry, m_Page ) );
			else
				state.Mobile.SendGump( new SpawnerGump( m_Spawner, null, m_Page ) );
		}
コード例 #18
0
        public void RemoveEntry( SpawnerEntry entry )
        {
            Defrag();

            for ( int i = entry.Creatures.Count-1; i >= 0; i-- )
            {
                IEntity e = entry.Creatures[i];
                entry.Creatures.RemoveAt( i );
                if ( e != null )
                    e.Delete();
            }

            m_Entries.Remove( entry );

            if ( m_Running && !IsFull && m_Timer != null && !m_Timer.Running )
                DoTimer();

            InvalidateProperties();
        }
コード例 #19
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public bool Spawn(SpawnerEntry entry, out EntryFlags flags)
        {
            Map map = GetSpawnMap();

            flags = EntryFlags.None;

            if (map == null || map == Map.Internal || Parent != null)
            {
                return(false);
            }

            //Defrag taken care of in Spawn(), beforehand
            //Count check taken care of in Spawn(), beforehand

            Type type = SpawnerType.GetType(entry.SpawnedName);

            if (type != null)
            {
                try
                {
                    object   o = null;
                    string[] paramargs;
                    string[] propargs;

                    if (String.IsNullOrEmpty(entry.Properties))
                    {
                        propargs = new string[0];
                    }
                    else
                    {
                        propargs = CommandSystem.Split(entry.Properties.Trim());
                    }

                    string[,] props = FormatProperties(propargs);

                    PropertyInfo[] realProps = GetTypeProperties(type, props);

                    if (realProps == null)
                    {
                        flags = EntryFlags.InvalidProps;
                        return(false);
                    }

                    if (String.IsNullOrEmpty(entry.Parameters))
                    {
                        paramargs = new string[0];
                    }
                    else
                    {
                        paramargs = entry.Parameters.Trim().Split(' ');
                    }

                    ConstructorInfo[] ctors = type.GetConstructors();

                    for (int i = 0; i < ctors.Length; ++i)
                    {
                        ConstructorInfo ctor = ctors[i];

                        if (Add.IsConstructable(ctor, AccessLevel.GameMaster))
                        {
                            ParameterInfo[] paramList = ctor.GetParameters();

                            if (paramargs.Length == paramList.Length)
                            {
                                object[] paramValues = Add.ParseValues(paramList, paramargs);

                                if (paramValues != null)
                                {
                                    o = ctor.Invoke(paramValues);
                                    for (int j = 0; j < realProps.Length; j++)
                                    {
                                        if (realProps[j] != null)
                                        {
                                            object toSet  = null;
                                            string result = Properties.ConstructFromString(realProps[j].PropertyType, o, props[j, 1], ref toSet);
                                            if (result == null)
                                            {
                                                realProps[j].SetValue(o, toSet, null);
                                            }
                                            else
                                            {
                                                flags = EntryFlags.InvalidProps;

                                                if (o is ISpawnable)
                                                {
                                                    ((ISpawnable)o).Delete();
                                                }

                                                return(false);
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }

                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;

                        m_Spawned.Add(m, entry);
                        entry.Spawned.Add(m);

                        Point3D loc = (m is BaseVendor ? this.Location : GetSpawnPosition(m, map));

                        m.OnBeforeSpawn(loc, map);
                        InvalidateProperties();

                        m.MoveToWorld(loc, map);

                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;

                            int walkrange = GetWalkingRange();

                            if (walkrange >= 0)
                            {
                                c.RangeHome = walkrange;
                            }
                            else
                            {
                                c.RangeHome = m_HomeRange;
                            }

                            c.CurrentWayPoint = GetWayPoint();

                            if (m_Team > 0)
                            {
                                c.Team = m_Team;
                            }

                            c.Home    = this.Location;
                            c.HomeMap = this.Map;
                        }

                        m.Spawner = this;
                        m.OnAfterSpawn();
                    }
                    else if (o is Item)
                    {
                        Item item = (Item)o;

                        m_Spawned.Add(item, entry);
                        entry.Spawned.Add(item);

                        Point3D loc = GetSpawnPosition(item, map);

                        item.OnBeforeSpawn(loc, map);

                        item.MoveToWorld(loc, map);

                        item.Spawner = this;
                        item.OnAfterSpawn();
                    }
                    else
                    {
                        flags = EntryFlags.InvalidType | EntryFlags.InvalidParams;
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("EXCEPTION CAUGHT: {0:X}", Serial);
                    Console.WriteLine(e);
                    return(false);
                }

                InvalidateProperties();
                return(true);
            }

            flags = EntryFlags.InvalidType;
            return(false);
        }
コード例 #20
0
ファイル: SpawnerGump.cs プロジェクト: zerodowned/UO-Forever
        public void CreateArray(RelayInfo info, Mobile from, Spawner spawner)
        {
            int ocount = spawner.Entries.Count;

            List <SpawnerEntry> rementries = new List <SpawnerEntry>();

            for (int i = 0; i < 13; i++)
            {
                int index      = i * 5;
                int entryindex = (m_Page * 13) + i;

                TextRelay cte    = info.GetTextEntry(index);
                TextRelay mte    = info.GetTextEntry(index + 1);
                TextRelay poste  = info.GetTextEntry(index + 2);
                TextRelay parmte = info.GetTextEntry(index + 3);
                TextRelay propte = info.GetTextEntry(index + 4);

                if (cte != null)
                {
                    string str = cte.Text.Trim().ToLower();

                    if (str.Length > 0)
                    {
                        Type type = SpawnerType.GetType(str);

                        if (type != null)
                        {
                            SpawnerEntry entry = null;

                            if (entryindex < ocount)
                            {
                                entry             = spawner.Entries[entryindex];
                                entry.SpawnedName = str;

                                if (mte != null)
                                {
                                    entry.SpawnedMaxCount = Utility.ToInt32(mte.Text.Trim());
                                }

                                if (poste != null)
                                {
                                    entry.SpawnedProbability = Utility.ToInt32(poste.Text.Trim());
                                }
                            }
                            else
                            {
                                int maxcount  = 1;
                                int probcount = 100;

                                if (mte != null)
                                {
                                    maxcount = Utility.ToInt32(mte.Text.Trim());
                                }

                                if (poste != null)
                                {
                                    probcount = Utility.ToInt32(poste.Text.Trim());
                                }

                                entry = spawner.AddEntry(str, probcount, maxcount);
                            }

                            if (parmte != null)
                            {
                                entry.Parameters = parmte.Text.Trim();
                            }

                            if (propte != null)
                            {
                                entry.Properties = propte.Text.Trim();
                            }
                        }
                        else
                        {
                            from.SendMessage("{0} is not a valid type name for entry #{1}.", str, i);
                        }
                    }
                    else if (entryindex < ocount && spawner.Entries[entryindex] != null)
                    {
                        rementries.Add(spawner.Entries[entryindex]);
                    }
                }
            }

            if (rementries.Count > 0)
            {
                for (int i = 0; i < rementries.Count; i++)
                {
                    spawner.RemoveEntry(rementries[i]);
                }
            }

            if (ocount == 0 && spawner.Entries.Count > 0)
            {
                spawner.Start();
            }
        }
コード例 #21
0
ファイル: Spawner.cs プロジェクト: zerodowned/UO-Forever
        public int CountSpawns(SpawnerEntry entry)
        {
            Defrag();

            return(entry.Spawned.Count);
        }
コード例 #22
0
ファイル: SpawnerGump.cs プロジェクト: zerodowned/UO-Forever
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (m_Spawner.Deleted)
            {
                return;
            }

            Mobile from = state.Mobile;

            int val = info.ButtonID - 1;

            if (val < 0)
            {
                return;
            }

            int type  = val % 10;
            int index = val / 10;

            switch (type)
            {
            case 0:                     //Cancel
                return;

            case 1:
            {
                switch (index)
                {
                case 0:
                {
                    if (m_Spawner.Entries != null && m_Page > 0)
                    {
                        m_Page--;
                        m_Entry = null;
                    }
                    break;
                }

                case 1:
                {
                    if (m_Spawner.Entries != null && (m_Page + 1) * 13 <= m_Spawner.Entries.Count)
                    {
                        m_Page++;
                        m_Entry = null;
                    }
                    break;
                }

                case 2:                                 //Okay
                {
                    CreateArray(info, state.Mobile, m_Spawner);
                    return;
                }

                case 3:
                {
                    m_Spawner.BringToHome();
                    break;
                }

                case 4:                                 // Complete respawn
                {
                    m_Spawner.Respawn();
                    break;
                }

                case 5:
                {
                    CreateArray(info, state.Mobile, m_Spawner);
                    break;
                }
                }
                break;
            }

            case 2:
            {
                int entryindex = (index / 2) + (m_Page * 13);
                int buttontype = index % 2;

                if (entryindex >= 0 && entryindex < m_Spawner.Entries.Count)
                {
                    SpawnerEntry entry = m_Spawner.Entries[entryindex];
                    if (buttontype == 0)                               // Spawn creature
                    {
                        if (m_Entry != null && m_Entry == entry)
                        {
                            m_Entry = null;
                        }
                        else
                        {
                            m_Entry = entry;
                        }
                    }
                    else                             // Remove creatures
                    {
                        m_Spawner.RemoveSpawn(entryindex);
                    }
                }

                CreateArray(info, state.Mobile, m_Spawner);
                break;
            }
            }

            if (m_Entry != null && m_Spawner.Entries.Contains(m_Entry))
            {
                state.Mobile.SendGump(new SpawnerGump(m_Spawner, m_Entry, m_Page));
            }
            else
            {
                state.Mobile.SendGump(new SpawnerGump(m_Spawner, null, m_Page));
            }
        }
コード例 #23
0
		public static void WriteSpawnerEntry( XmlTextWriter xml, SpawnerEntry entry )
		{
			xml.WriteStartElement( "Entry" );

			xml.WriteStartElement( "SpawnedName" );
			xml.WriteString( entry.SpawnedName );
			xml.WriteEndElement();

			xml.WriteStartElement( "SpawnedProbability" );
			xml.WriteString( entry.SpawnedProbability.ToString() );
			xml.WriteEndElement();

			xml.WriteStartElement( "SpawnedMaxCount" );
			xml.WriteString( entry.SpawnedMaxCount.ToString() );
			xml.WriteEndElement();

			if ( !String.IsNullOrEmpty( entry.Parameters ) )
			{
				xml.WriteStartElement( "Parameters" );
				xml.WriteString( entry.Parameters );
				xml.WriteEndElement();
			}

			if ( !String.IsNullOrEmpty( entry.Properties ) )
			{
				xml.WriteStartElement( "Properties" );
				xml.WriteString( entry.Properties );
				xml.WriteEndElement();
			}

			if ( entry.Valid != EntryFlags.None )
			{
				xml.WriteStartElement( "Invalid" );
				xml.WriteString( ((int)entry.Valid).ToString() );
				xml.WriteEndElement();
			}

			xml.WriteEndElement(); // Entry
		}