Exemple #1
0
        public static void AddRotationFromSim(CraftingSim sim)
        {
            if (sim == null || sim.CurrentRecipe == null || sim.CustomRecipe)
            {
                return;
            }
            if (sim.CurrentProgress < sim.CurrentRecipe.MaxProgress || sim.CurrentQuality < sim.CurrentRecipe.MaxQuality)
            {
                return;
            }
            CraftingSim s = sim.Clone();

            s.AddActions(true, sim.GetCraftingActions());

            var abstractData = s.CurrentRecipe.GetAbstractData();

            if (!GameData.RecipeRotations.ContainsKey(abstractData))
            {
                Debugger.Break();
                return;
            }

            RecipeSolutionInfo infoWithMinLevel    = RecipeSolutionInfo.FromSim(s, true);
            RecipeSolutionInfo infoWithoutMinLevel = RecipeSolutionInfo.FromSim(s, false);

            var list = GameData.RecipeRotations[abstractData];

            if (!list.Contains(infoWithMinLevel) && !list.Any(x => x.IsBetterThan(infoWithMinLevel)))
            {
                list.Add(infoWithMinLevel);
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (infoWithMinLevel.IsBetterThan(list[i]))
                {
                    list.RemoveAt(i);
                    i--;
                }
            }

            if (!list.Contains(infoWithoutMinLevel) && !list.Any(x => x.IsBetterThan(infoWithoutMinLevel)))
            {
                list.Add(infoWithoutMinLevel);
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (infoWithoutMinLevel.IsBetterThan(list[i]))
                {
                    list.RemoveAt(i);
                    i--;
                }
            }
        }
Exemple #2
0
 public RotationInfoContainer(RecipeSolutionInfo rotationInfo, ClassJobInfo classJobInfo)
 {
     RotationInfo = rotationInfo;
     try
     {
         Images = RotationInfo.Rotation.Array.Select(x => new BitmapSourceContainer(G.Actions[CraftingAction.CraftingActions[x].Name].Images[classJobInfo])).ToArray();
     } catch (Exception e)
     {
         Debugger.Break();
     }
 }
Exemple #3
0
        public static void ReadRecipeRotations(bool deleteCurrent = false)
        {
            if (deleteCurrent && File.Exists("RecipeRotations.db"))
            {
                File.Delete("RecipeRotations.db");
            }

            if (File.Exists("RecipeRotations.db"))
            {
                DataStream s      = new DataStream(File.ReadAllBytes("RecipeRotations.db"));
                int        length = s.ReadS32();
                RecipeRotations = new Dictionary <AbstractRecipeInfo, List <RecipeSolutionInfo> >(length);
                for (ushort i = 0; i < length; i++)
                {
                    AbstractRecipeInfo info = new AbstractRecipeInfo
                    {
                        Level = s.ReadS32(),
                        RequiredCraftsmanship = s.ReadS32(),
                        RequiredControl       = s.ReadS32(),
                        Durability            = s.ReadS32(),
                        MaxProgress           = s.ReadS32(),
                        MaxQuality            = s.ReadS32()
                    };
                    var ll = s.ReadS32();
                    RecipeRotations[info] = new List <RecipeSolutionInfo>(ll);
                    for (int j = 0; j < ll; j++)
                    {
                        RecipeSolutionInfo rotation = new RecipeSolutionInfo();
                        rotation.MinLevel         = s.ReadS32();
                        rotation.MaxCraftsmanship = s.ReadS32();
                        rotation.MinCraftsmanship = s.ReadS32();
                        rotation.MinControl       = s.ReadS32();
                        rotation.CP = s.ReadS32();
                        int      l     = s.ReadS32();
                        ushort[] array = new ushort[l];
                        for (int k = 0; k < l; k++)
                        {
                            array[k] = (ushort)s.ReadU30();
                        }
                        rotation.Rotation = array;
                        RecipeRotations[info].Add(rotation);
                    }
                }
                s.Flush();
                s.Close();
            }
            else
            {
                RecipeRotations = new Dictionary <AbstractRecipeInfo, List <RecipeSolutionInfo> >();
                var   sheet = Game.GameData.GetSheet <Recipe>();
                int   count = sheet.Count;
                int[] keys  = sheet.Keys.ToArray();
                for (int i = 0; i < count; i++)
                {
                    var value = sheet[keys[i]];


                    AbstractRecipeInfo abstractInfo = AbstractRecipeInfo.GetAbstractData(value);
                    if (!RecipeRotations.ContainsKey(abstractInfo))
                    {
                        RecipeRotations[abstractInfo] = new List <RecipeSolutionInfo>();
                    }
                }
                WriteRecipeRotations();
            }
        }
Exemple #4
0
 public static void RemoveRotation(AbstractRecipeInfo abstractRecipeInfo, RecipeSolutionInfo rotationInfo)
 {
     GameData.RecipeRotations[abstractRecipeInfo].Remove(rotationInfo);
     MainWindow.UpdateRotationsCount();
 }