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--;
                }
            }
        }
        public virtual void CopyTo(CraftingSim sim, bool copyActions = false)
        {
            sim.Level             = Level;
            sim.BaseCraftsmanship = BaseCraftsmanship;
            sim.BaseControl       = BaseControl;
            sim.BaseMaxCP         = BaseMaxCP;
            sim.CraftsmanshipBuff = CraftsmanshipBuff;
            sim.ControlBuff       = ControlBuff;
            sim.MaxCPBuff         = MaxCPBuff;
            sim.StepSettings      = new CraftingSimStepSettings[MaxActions];

            for (int i = 0; i < MaxActions; i++)
            {
                sim.StepSettings[i] = StepSettings[i].Clone();
            }

            if (copyActions)
            {
                sim.RemoveActions();
                sim.AddActions(false, GetCraftingActions());

                sim.Step = Step;
                sim.CurrentDurability = CurrentDurability;
                sim.CurrentProgress   = CurrentProgress;
                sim.CurrentQuality    = CurrentQuality;
                sim.CurrentCP         = CurrentCP;

                sim.InnerQuietBuff = InnerQuietBuff?.Clone() as InnerQuietBuff;
                if (sim.InnerQuietBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.InnerQuietBuff);
                }

                sim.WasteNotBuff = WasteNotBuff?.Clone() as WasteNotBuff;
                if (sim.WasteNotBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.WasteNotBuff);
                }

                sim.VenerationBuff = VenerationBuff?.Clone() as VenerationBuff;
                if (sim.VenerationBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.VenerationBuff);
                }

                sim.GreatStridesBuff = GreatStridesBuff?.Clone() as GreatStridesBuff;
                if (sim.GreatStridesBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.GreatStridesBuff);
                }

                sim.InnovationBuff = InnovationBuff?.Clone() as InnovationBuff;
                if (sim.InnovationBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.InnovationBuff);
                }

                sim.MuscleMemoryBuff = MuscleMemoryBuff?.Clone() as MuscleMemoryBuff;
                if (sim.MuscleMemoryBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.MuscleMemoryBuff);
                }

                sim.ManipulationBuff = ManipulationBuff?.Clone() as ManipulationBuff;
                if (sim.ManipulationBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.ManipulationBuff);
                }

                sim.ObserveBuff = ObserveBuff?.Clone() as ObserveBuff;
                if (sim.ObserveBuff != null)
                {
                    sim.CraftingBuffs.Add(sim.ObserveBuff);
                }

                sim.NameOfTheElementsBuff = NameOfTheElementsBuff?.Clone() as NameOfTheElementsBuff;

                sim.NameOfTheElementsUsed = NameOfTheElementsUsed;
            }
        }