Пример #1
0
        public Item Construct()
        {
            Item item;

            try
            {
                if (m_Type == typeofStatic)
                {
                    item = new Static(m_ItemID);
                }
                else if (m_Type == typeofLocalizedStatic)
                {
                    int labelNumber = 0;

                    for (int i = 0; i < m_Params.Length; ++i)
                    {
                        if (m_Params[i].StartsWith("LabelNumber"))
                        {
                            int indexOf = m_Params[i].IndexOf('=');

                            if (indexOf >= 0)
                            {
                                labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                                break;
                            }
                        }
                    }

                    item = new LocalizedStatic(m_ItemID, labelNumber);
                }
                else
                {
                    item = (Item)Activator.CreateInstance(m_Type);
                }
            }
            catch (Exception e)
            {
                throw new Exception(String.Format("Bad type: {0}", m_Type), e);
            }

            if (item is Server.Items.SpawnsOverseer)
            {
                Server.Items.SpawnsOverseer sp = (Server.Items.SpawnsOverseer)item;

                for (int i = 0; i < m_Params.Length; ++i)
                {
                    if (m_Params[i].StartsWith("Range"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("InRangeDelay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.InRangeDelay = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                    else if (m_Params[i].StartsWith("OutRangeDelay"))
                    {
                        int indexOf = m_Params[i].IndexOf('=');

                        if (indexOf >= 0)
                        {
                            sp.OutRangeDelay = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        }
                    }
                }
            }

            item.Movable = false;

            for (int i = 0; i < m_Params.Length; ++i)
            {
                if (m_Params[i].StartsWith("Light"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true);
                    }
                }
                else if (m_Params[i].StartsWith("Hue"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        int hue = Utility.ToInt32(m_Params[i].Substring(++indexOf));

                        if (item is DyeTub)
                        {
                            ((DyeTub)item).DyedHue = hue;
                        }
                        else
                        {
                            item.Hue = hue;
                        }
                    }
                }
                else if (m_Params[i].StartsWith("Name"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        item.Name = m_Params[i].Substring(++indexOf);
                    }
                }
                else if (m_Params[i].StartsWith("Amount"))
                {
                    int indexOf = m_Params[i].IndexOf('=');

                    if (indexOf >= 0)
                    {
                        // Must supress stackable warnings

                        bool wasStackable = item.Stackable;

                        item.Stackable = true;
                        item.Amount    = Utility.ToInt32(m_Params[i].Substring(++indexOf));
                        item.Stackable = wasStackable;
                    }
                }
            }

            return(item);
        }
Пример #2
0
            public CheckTimer(SpawnsOverseer Crystal, TimeSpan delay) : base(delay, delay)
            {
                Priority = TimerPriority.OneSecond;

                m_SpawnsOverseer = Crystal;
            }
            public CheckTimer( SpawnsOverseer Crystal, TimeSpan delay )
                : base(delay, delay)
            {
                Priority = TimerPriority.OneSecond;

                m_SpawnsOverseer = Crystal;
            }