Ejemplo n.º 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                Container pack = m_Mobile.Backpack;

                if (pack != null && m_Item.IsChildOf(pack))
                {
                    if (pack.ConsumeTotal(typeof(Silver), m_Definition.SilverCost))
                    {
                        int hue;

                        if (m_Item is SpellScroll)
                        {
                            hue = 0;
                        }
                        else if (info.IsSwitched(1))
                        {
                            hue = m_Faction.Definition.HuePrimary;
                        }
                        else
                        {
                            hue = m_Faction.Definition.HueSecondary;
                        }

                        FactionItem.Imbue(m_Item, m_Faction, true, hue);
                    }
                    else
                    {
                        m_Mobile.SendLocalizedMessage(1042204); // You do not have enough silver.
                    }
                }
            }

            if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
            {
                m_Mobile.SendGump(new CraftGump(m_Mobile, m_CraftSystem, m_Tool, m_Notice));
            }
            else if (m_Notice is string)
            {
                m_Mobile.SendMessage((string)m_Notice);
            }
            else if (m_Notice is int && ((int)m_Notice) > 0)
            {
                m_Mobile.SendLocalizedMessage((int)m_Notice);
            }
        }
Ejemplo n.º 2
0
        public static FactionItem Find(Item item)
        {
            if (item is IFactionItem)
            {
                FactionItem state = ((IFactionItem)item).FactionItemState;

                if (state != null && state.HasExpired)
                {
                    state.Detach();
                    state = null;
                }

                return(state);
            }

            return(null);
        }
Ejemplo n.º 3
0
        public static Item Imbue(Item item, Faction faction, bool expire, int hue)
        {
            if (!(item is IFactionItem))
            {
                return(item);
            }

            FactionItem state = Find(item);

            if (state == null)
            {
                state = new FactionItem(item, faction);
                state.Attach();
            }

            if (expire)
            {
                state.StartExpiration();
            }

            item.Hue = hue;
            return(item);
        }
Ejemplo n.º 4
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 5:
            {
                m_LastAtrophy = reader.ReadDateTime();
                goto case 4;
            }

            case 4:
            {
                int count = reader.ReadEncodedInt();

                for (int i = 0; i < count; ++i)
                {
                    DateTime time = reader.ReadDateTime();

                    if (i < m_LastBroadcasts.Length)
                    {
                        m_LastBroadcasts[i] = time;
                    }
                }

                goto case 3;
            }

            case 3:
            case 2:
            case 1:
            {
                m_Election = new Election(reader);

                goto case 0;
            }

            case 0:
            {
                m_Faction = Faction.ReadReference(reader);

                m_Commander = reader.ReadMobile();

                if (version < 5)
                {
                    m_LastAtrophy = DateTime.UtcNow;
                }

                if (version < 4)
                {
                    DateTime time = reader.ReadDateTime();

                    if (m_LastBroadcasts.Length > 0)
                    {
                        m_LastBroadcasts[0] = time;
                    }
                }

                m_Tithe  = reader.ReadEncodedInt();
                m_Silver = reader.ReadEncodedInt();

                int memberCount = reader.ReadEncodedInt();

                m_Members = new List <PlayerState>();

                for (int i = 0; i < memberCount; ++i)
                {
                    PlayerState pl = new PlayerState(reader, m_Faction, m_Members);

                    if (pl.Mobile != null)
                    {
                        m_Members.Add(pl);
                    }
                }

                m_Faction.State = this;

                m_Faction.ZeroRankOffset = m_Members.Count;
                m_Members.Sort();

                for (int i = m_Members.Count - 1; i >= 0; i--)
                {
                    PlayerState player = m_Members[i];

                    if (player.KillPoints <= 0)
                    {
                        m_Faction.ZeroRankOffset = i;
                    }
                    else
                    {
                        player.RankIndex = i;
                    }
                }

                m_FactionItems = new List <FactionItem>();

                if (version >= 2)
                {
                    int factionItemCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionItemCount; ++i)
                    {
                        FactionItem factionItem = new FactionItem(reader, m_Faction);

                        Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach));         // sandbox attachment
                    }
                }

                m_FactionTraps = new List <BaseFactionTrap>();

                if (version >= 3)
                {
                    int factionTrapCount = reader.ReadEncodedInt();

                    for (int i = 0; i < factionTrapCount; ++i)
                    {
                        BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;

                        if (trap != null && !trap.CheckDecay())
                        {
                            m_FactionTraps.Add(trap);
                        }
                    }
                }

                break;
            }
            }

            if (version < 1)
            {
                m_Election = new Election(m_Faction);
            }
        }