Beispiel #1
0
 public BNpc(Collections.BNpcCollection collection, Libra.BNpcName libra)
 {
     this.Collection = collection;
     _LibraRow       = libra;
     this.Key        = libra.Key;
     this.Base       = collection.BaseSheet[(int)libra.BaseKey];
     this.Name       = collection.NameSheet[(int)libra.NameKey];
 }
Beispiel #2
0
 public Enumerator(BNpcCollection collection)
 {
     _Collection = collection;
     if (collection._LibraEntries == null)
     {
         collection._LibraEntries = collection.Collection.Libra.BNpcNames.ToArray();
     }
     _LibraEnumerator = collection._LibraEntries.GetEnumerator();
 }
            internal Fight(JsonReader reader, XivCollection collection)
            {
                if (reader.TokenType != JsonToken.StartObject)
                {
                    throw new InvalidOperationException();
                }

                Collections.BNpcCollection bnpcs = collection.BNpcs;

                while (reader.Read() && reader.TokenType != JsonToken.EndObject)
                {
                    if (reader.TokenType != JsonToken.PropertyName)
                    {
                        throw new InvalidOperationException();
                    }

                    switch (reader.Value.ToString())
                    {
                    case "RewardItems":
                        ReadRewardItems(reader, collection);
                        break;

                    case "ClearB":
                        ReadCurrencyB(reader);
                        break;

                    case "SubBNpcNames":
                        ReadSecondaryBNpcs(reader, bnpcs);
                        break;

                    case "ClearA":
                        ReadCurrencyA(reader);
                        break;

                    case "Treasure":
                        ReadTreasure(reader, collection);
                        break;

                    case "BNpcNames":
                        ReadPrimaryBNpcs(reader, bnpcs);
                        break;

                    case "ClearC":
                        ReadCurrencyC(reader);
                        break;

                    default:
                        Console.Error.WriteLine("Unknown 'InstanceContent.Fight' data key: {0}", reader.Value);
                        throw new NotSupportedException();
                    }
                }
            }
        /// <summary>
        ///     Build an array of sources from which to obtain the current item.
        /// </summary>
        /// <returns>An array of sources from which to obtain the current item.</returns>
        private IItemSource[] BuildSources()
        {
            List <IItemSource> sources = new List <IItemSource>();

            Libra.Item libraRow = null;
            if (Sheet.Collection.IsLibraAvailable)
            {
                libraRow = Sheet.Collection.Libra.Items.FirstOrDefault(i => i.Key == this.Key);
            }

            IXivSheet <Recipe>      recipes      = Sheet.Collection.GetSheet <Recipe>();
            IXivSheet <Quest>       quests       = Sheet.Collection.GetSheet <Quest>();
            IXivSheet <Achievement> achievements = Sheet.Collection.GetSheet <Achievement>();

            Collections.ShopCollection       shops         = Sheet.Collection.Shops;
            IXivSheet <Leve>                 leves         = Sheet.Collection.GetSheet <Leve>();
            IXivSheet <FishingSpot>          fishingSpots  = Sheet.Collection.GetSheet <FishingSpot>();
            IXivSheet <RetainerTask>         retainerTasks = Sheet.Collection.GetSheet <RetainerTask>();
            IXivSheet <CompanyCraftSequence> companyCraft  = Sheet.Collection.GetSheet <CompanyCraftSequence>();

            if (libraRow != null)
            {
                Collections.BNpcCollection  bnpcColl         = Sheet.Collection.BNpcs;
                IXivSheet <InstanceContent> instanceContents = Sheet.Collection.GetSheet <InstanceContent>();

                foreach (long bnpc in libraRow.BNpcs)
                {
                    sources.Add(bnpcColl[bnpc]);
                }
                foreach (int ic in libraRow.InstanceContents)
                {
                    sources.Add(instanceContents[ic]);
                }
            }

            /*sources.AddRange(bnpcColl.Where(i => i.Items.Contains(this)));
             * sources.AddRange(instanceContents.Cast<IItemSource>().Where(i => i.Items.Contains(this)));*/

            // Not using Libra for these because it has a higher likelyhood of being incomplete.
            sources.AddRange(recipes.Where(i => i.ResultItem == this));
            sources.AddRange(quests.Cast <IItemSource>().Where(i => i.Items.Contains(this)));
            sources.AddRange(achievements.Where(i => i.Item == this));
            sources.AddRange(shops.Where(i => i.Items.Contains(this)));

            // Not using Libra for this because it doesn't even have information about it
            sources.AddRange(leves.Where(i => i.Items.Contains(this)));
            sources.AddRange(fishingSpots.Where(i => i.Items.Contains(this)));
            sources.AddRange(retainerTasks.Where(i => i.Items.Contains(this)));
            sources.AddRange(companyCraft.Where(i => i.ResultItem == this));

            return(sources.ToArray());
        }
            private void ReadPrimaryBNpcs(JsonReader reader, Collections.BNpcCollection bnpcs)
            {
                if (!reader.Read() || reader.TokenType != JsonToken.StartArray)
                {
                    throw new InvalidOperationException();
                }

                List <BNpc> values = new List <BNpc>();

                while (reader.Read() && reader.TokenType != JsonToken.EndArray)
                {
                    if (reader.TokenType != JsonToken.Integer)
                    {
                        throw new InvalidOperationException();
                    }

                    long key = Convert.ToInt64(reader.Value);
                    values.Add(bnpcs[key]);
                }
                this.PrimaryBNpcs = values;
            }
Beispiel #6
0
            public Enumerator(BNpcCollection collection)
            {
                _Collection = collection;

                _LibraEnumerator = collection._LibraEntries.GetEnumerator();
            }