Esempio n. 1
0
        public static Item Imbue(Item item, Faction faction, bool expire, int hue)
        {
            if ((item is IFactionItem))
            {
                FactionItem state = Find(item);

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

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

                state.m_OrigHue      = item.Hue;
                state.m_OrigLootType = item.LootType;
                item.Hue             = hue;
                item.LootType        = LootType.Blessed;
            }

            return(item);
        }
Esempio n. 2
0
        public static Item Imbue(Item item, Faction faction, bool expire, int hue, int MinRank = 0)
        {
            if (!(item is IFactionItem))
            {
                return(item);
            }

            FactionItem state = Find(item);

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

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

            if (hue >= 0)
            {
                item.Hue = hue;
            }

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

            var state = Find(item);

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

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

            item.Hue = hue;
            return(item);
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public FactionState( GenericReader reader )
        {
            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                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 < 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 PlayerStateCollection();

                    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.UpdateRanks();

                    m_FactionItems = new FactionItemCollection();

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

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

                            if ( !factionItem.HasExpired )
                                factionItem.Attach();
                            else
                                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( factionItem.Detach ) ); // sandbox detachment
                        }
                    }

                    m_FactionTraps = new FactionTrapCollection();

                    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 );
        }
Esempio n. 6
0
		public static Item Imbue( Item item, Faction faction, bool expire, int hue )
		{
			if ( (item is IFactionItem) )
			{
				FactionItem state = Find( item );

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

				if ( expire )
					state.StartExpiration();

				state.m_OrigHue = item.Hue;
				state.m_OrigLootType = item.LootType;
				item.Hue = hue;
				item.LootType = LootType.Blessed;
			}

			return item;
		}
Esempio n. 7
0
        public FactionState(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            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 < 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 PlayerStateCollection();

                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.UpdateRanks();

                m_FactionItems = new FactionItemCollection();

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

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

                        if (!factionItem.HasExpired)
                        {
                            factionItem.Attach();
                        }
                        else
                        {
                            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.Detach));                                         // sandbox detachment
                        }
                    }
                }

                m_FactionTraps = new FactionTrapCollection();

                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);
            }
        }