Ejemplo n.º 1
0
        public void MakeResidentList()
        {
            Residents = new Dictionary <int, Resident>();

            try
            {
                var sheet = MainWindow.Realm.GameData.GetSheet <SaintCoinach.Xiv.ENpcResident>();
                foreach (var Parse in sheet)
                {
                    Residents.Add(Parse.Key, new Resident {
                        Index = Parse.Key, Name = Parse.Singular
                    });
                }
                var eNpcBases = MainWindow.Realm.GameData.GetSheet <SaintCoinach.Xiv.ENpcBase>();

                foreach (var parse in eNpcBases)
                {
                    //  Console.WriteLine($"{parse.NpcEquip.ModelHead[0]+ parse.NpcEquip.ModelHead[1]* 256},{parse.NpcEquip.ModelHead[2]}");
                    //   Console.WriteLine(parse.NpcEquip.Key);
                    int id = parse.Key;
                    //  int modelid = parse.ModelID;
                    GearSet     gear      = new GearSet();
                    List <byte> customize = new List <byte>();
                    customize.AddRange(new List <byte>()
                    {
                        Convert.ToByte(parse.Race.Key), Convert.ToByte(parse.Gender)
                        , Convert.ToByte(parse.BodyType), Convert.ToByte(parse.Height)
                        , Convert.ToByte(parse.Tribe.Key), Convert.ToByte(parse.Face), Convert.ToByte(parse.HairStyle), Convert.ToByte(parse.HairHighlight)
                        , Convert.ToByte(parse.SkinColor), Convert.ToByte(parse.EyeHeterochromia), Convert.ToByte(parse.HairColor), Convert.ToByte(parse.HairHighlightColor)
                        , Convert.ToByte(parse.FacialFeature), Convert.ToByte(parse.FacialFeatureColor), Convert.ToByte(parse.Eyebrows), Convert.ToByte(parse.EyeColor)
                        , Convert.ToByte(parse.EyeShape), Convert.ToByte(parse.Nose), Convert.ToByte(parse.Jaw), Convert.ToByte(parse.Mouth)
                        , Convert.ToByte(parse.LipColor), Convert.ToByte(parse.BustOrTone1), Convert.ToByte(parse.ExtraFeature1), Convert.ToByte(parse.ExtraFeature2OrBust)
                        , Convert.ToByte(parse.FacePaint), Convert.ToByte(parse.FacePaintColor)
                    });
                    gear.Customize = customize.ToArray();
                    if (parse.NpcEquip.Key > 0)
                    {
                        gear.MainWep   = new WepTuple(parse.NpcEquip.ModelMain.Value1, parse.NpcEquip.ModelMain.Value2, parse.NpcEquip.ModelMain.Value3, parse.NpcEquip.DyeMain.Key);
                        gear.OffWep    = new WepTuple(parse.NpcEquip.ModelSub.Value1, parse.NpcEquip.ModelSub.Value2, parse.NpcEquip.ModelSub.Value3, parse.NpcEquip.DyeOff.Key);
                        gear.HeadGear  = new GearTuple((parse.NpcEquip.ModelHead[0] + parse.NpcEquip.ModelHead[1] * 256), parse.NpcEquip.ModelHead[2], parse.NpcEquip.DyeHead.Key);
                        gear.BodyGear  = new GearTuple((parse.NpcEquip.ModelBody[0] + parse.NpcEquip.ModelBody[1] * 256), parse.NpcEquip.ModelBody[2], parse.NpcEquip.DyeBody.Key);
                        gear.HandsGear = new GearTuple((parse.NpcEquip.ModelHands[0] + parse.NpcEquip.ModelHands[1] * 256), parse.NpcEquip.ModelHands[2], parse.NpcEquip.DyeHands.Key);
                        gear.LegsGear  = new GearTuple((parse.NpcEquip.ModelLegs[0] + parse.NpcEquip.ModelLegs[1] * 256), parse.NpcEquip.ModelLegs[2], parse.NpcEquip.DyeLegs.Key);
                        gear.FeetGear  = new GearTuple((parse.NpcEquip.ModelFeet[0] + parse.NpcEquip.ModelFeet[1] * 256), parse.NpcEquip.ModelFeet[2], parse.NpcEquip.DyeFeet.Key);
                        gear.EarGear   = new GearTuple((parse.NpcEquip.ModelEars[0] + parse.NpcEquip.ModelEars[1] * 256), parse.NpcEquip.ModelEars[2], 0);
                        gear.NeckGear  = new GearTuple((parse.NpcEquip.ModelNeck[0] + parse.NpcEquip.ModelNeck[1] * 256), parse.NpcEquip.ModelNeck[2], 0);
                        gear.WristGear = new GearTuple((parse.NpcEquip.ModelWrists[0] + parse.NpcEquip.ModelWrists[1] * 256), parse.NpcEquip.ModelWrists[2], 0);
                        gear.RRingGear = new GearTuple((parse.NpcEquip.ModelRightRing[0] + parse.NpcEquip.ModelRightRing[1] * 256), parse.NpcEquip.ModelRightRing[2], 0);
                        gear.LRingGear = new GearTuple((parse.NpcEquip.ModelLeftRing[0] + parse.NpcEquip.ModelLeftRing[1] * 256), parse.NpcEquip.ModelLeftRing[2], 0);
                    }
                    else
                    {
                        gear.MainWep   = new WepTuple(parse.ModelMain.Value1, parse.ModelMain.Value2, parse.ModelMain.Value3, parse.DyeMain.Key);
                        gear.OffWep    = new WepTuple(parse.ModelSub.Value1, parse.ModelSub.Value2, parse.ModelSub.Value3, parse.DyeOff.Key);
                        gear.HeadGear  = new GearTuple((parse.ModelHead[0] + parse.ModelHead[1] * 256), parse.ModelHead[2], parse.DyeHead.Key);
                        gear.BodyGear  = new GearTuple((parse.ModelBody[0] + parse.ModelBody[1] * 256), parse.ModelBody[2], parse.DyeBody.Key);
                        gear.HandsGear = new GearTuple((parse.ModelHands[0] + parse.ModelHands[1] * 256), parse.ModelHands[2], parse.DyeHands.Key);
                        gear.LegsGear  = new GearTuple((parse.ModelLegs[0] + parse.ModelLegs[1] * 256), parse.ModelLegs[2], parse.DyeLegs.Key);
                        gear.FeetGear  = new GearTuple((parse.ModelFeet[0] + parse.ModelFeet[1] * 256), parse.ModelFeet[2], parse.DyeFeet.Key);
                        gear.EarGear   = new GearTuple((parse.ModelEars[0] + parse.ModelEars[1] * 256), parse.ModelEars[2], 0);
                        gear.NeckGear  = new GearTuple((parse.ModelNeck[0] + parse.ModelNeck[1] * 256), parse.ModelNeck[2], 0);
                        gear.WristGear = new GearTuple((parse.ModelWrists[0] + parse.ModelWrists[1] * 256), parse.ModelWrists[2], 0);
                        gear.RRingGear = new GearTuple((parse.ModelRightRing[0] + parse.ModelRightRing[1] * 256), parse.ModelRightRing[2], 0);
                        gear.LRingGear = new GearTuple((parse.ModelLeftRing[0] + parse.ModelLeftRing[1] * 256), parse.ModelLeftRing[2], 0);
                    }
                    try
                    {
                        Residents[id].Gear = gear;
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
            catch (Exception e)
            {
                Residents = null;

                //       throw;
            }
        }
Ejemplo n.º 2
0
        public void MakeResidentList()
        {
            Residents = new Dictionary <int, Resident>();

            try
            {
                using (TextFieldParser parser = new TextFieldParser(new StringReader(Resources.enpcresident_exh_en)))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    int rowCount = 0;
                    parser.ReadFields();
                    while (!parser.EndOfData)
                    {
                        //Processing row
                        rowCount++;
                        string[] fields = parser.ReadFields();
                        int      fCount = 0;

                        int    id   = 0;
                        string name = "";

                        foreach (string field in fields)
                        {
                            fCount++;

                            if (fCount == 1)
                            {
                                id = int.Parse(field);
                            }

                            if (fCount == 2)
                            {
                                name = field;
                            }
                        }
                        //  Console.WriteLine($"{id} - {name}");
                        Residents.Add(id, new Resident {
                            Index = id, Name = name
                        });
                    }
                    //    Console.WriteLine($"{rowCount} residentNames read");
                }
                using (TextFieldParser parser = new TextFieldParser(new StringReader(Resources.enpcbase_exh)))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    int rowCount = 0;
                    parser.ReadFields();
                    while (!parser.EndOfData)
                    {
                        //Processing row
                        rowCount++;
                        string[] fields = parser.ReadFields();
                        int      fCount = 0;

                        int         id         = 0;
                        List <byte> customize  = new List <byte>();
                        GearSet     gear       = new GearSet();
                        int         dDataCount = 0;
                        int         modelId    = 0;

                        foreach (string field in fields)
                        {
                            fCount++;

                            if (fCount == 1)
                            {
                                id = int.Parse(field);
                            }

                            if (fCount == 37)
                            {
                                modelId = int.Parse(field);
                            }

                            if (fCount >= 38 && fCount <= 63)
                            {
                                try
                                {
                                    customize.Add(byte.Parse(field));
                                    dDataCount++;
                                }
                                catch (Exception exc)
                                {
                                    throw exc;
                                    //Console.WriteLine("Invalid: " + field);
                                }
                            }

                            if (fCount == 67)
                            {
                                gear.MainWep = EquipmentFlyOut.CommaToWepTuple(field);
                            }

                            if (fCount == 69)
                            {
                                gear.OffWep = EquipmentFlyOut.CommaToWepTuple(field);
                            }

                            if (fCount >= 71 && fCount <= 90)
                            {
                                Int32 fieldint = 0;

                                if (fCount != 73)
                                {
                                    fieldint = Int32.Parse(field);
                                }

                                var bytes = BitConverter.GetBytes(fieldint);

                                var model = BitConverter.ToUInt16(bytes, 0);

                                switch (fCount - 1)
                                {
                                case 70:
                                    gear.HeadGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 71:
                                    gear.HeadGear = new GearTuple(gear.HeadGear.Item1, gear.HeadGear.Item2,
                                                                  int.Parse(field));
                                    break;

                                case 72:
                                    break;

                                case 73:
                                    gear.BodyGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 74:
                                    gear.BodyGear = new GearTuple(gear.BodyGear.Item1, gear.BodyGear.Item2,
                                                                  int.Parse(field));
                                    break;

                                case 75:
                                    gear.HandsGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 76:
                                    gear.HandsGear = new GearTuple(gear.HandsGear.Item1, gear.HandsGear.Item2,
                                                                   int.Parse(field));
                                    break;

                                case 77:
                                    gear.LegsGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 78:
                                    gear.LegsGear = new GearTuple(gear.LegsGear.Item1, gear.LegsGear.Item2,
                                                                  int.Parse(field));
                                    break;

                                case 79:
                                    gear.FeetGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 80:
                                    gear.FeetGear = new GearTuple(gear.FeetGear.Item1, gear.FeetGear.Item2,
                                                                  int.Parse(field));
                                    break;

                                case 81:
                                    gear.EarGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 82:
                                    gear.EarGear = new GearTuple(gear.EarGear.Item1, gear.EarGear.Item2,
                                                                 int.Parse(field));
                                    break;

                                case 83:
                                    gear.NeckGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 84:
                                    gear.NeckGear = new GearTuple(gear.NeckGear.Item1, gear.NeckGear.Item2,
                                                                  int.Parse(field));
                                    break;

                                case 85:
                                    gear.WristGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 86:
                                    gear.WristGear = new GearTuple(gear.WristGear.Item1, gear.WristGear.Item2,
                                                                   int.Parse(field));
                                    break;

                                case 87:
                                    gear.LRingGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 88:
                                    gear.LRingGear = new GearTuple(gear.LRingGear.Item1, gear.LRingGear.Item2,
                                                                   int.Parse(field));
                                    break;

                                case 89:
                                    gear.RRingGear = new GearTuple(model, bytes[2], 0);
                                    break;

                                case 90:
                                    gear.RRingGear = new GearTuple(gear.RRingGear.Item1, gear.RRingGear.Item2,
                                                                   int.Parse(field));
                                    break;
                                }
                            }
                        }
                        //            Console.WriteLine($"{id} - {wepCSV} - {dDataCount}");

                        gear.Customize = customize.ToArray();

                        try
                        {
                            Residents[id].Gear = gear;
                        }
                        catch (KeyNotFoundException)
                        {
                            Console.WriteLine("Did not find corresponding entry for: " + id);
                        }
                    }
                    //    Console.WriteLine($"{rowCount} idLookMappings read");
                }
            }
            catch (Exception exc)
            {
                Residents = null;
#if DEBUG
                throw exc;
#endif
            }
        }