Exemplo n.º 1
0
        public static async Task ImportCollectionFromSavegame(CreatureCollection creatureCollection, string filename, string serverName)
        {
            string[] rafts = { "Raft_BP_C", "MotorRaft_BP_C", "Barge_BP_C" };
            (GameObjectContainer gameObjectContainer, float gameTime) = await readSavegameFile(filename);

            IEnumerable <GameObject> tamedCreatureObjects = gameObjectContainer
                                                            .Where(o => o.IsCreature() && o.IsTamed() && !o.IsUnclaimedBaby() && !rafts.Contains(o.ClassString));

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ImportTribeNameFilter))
            {
                string[] filters = Properties.Settings.Default.ImportTribeNameFilter.Split(',')
                                   .Select(s => s.Trim())
                                   .Where(s => !string.IsNullOrEmpty(s))
                                   .ToArray();

                tamedCreatureObjects = tamedCreatureObjects.Where(o =>
                {
                    string tribeName = o.GetPropertyValue <string>("TribeName", defaultValue: string.Empty);
                    return(filters.Any(filter => tribeName.Contains(filter)));
                });
            }

            ImportSavegame  importSavegame = new ImportSavegame(gameTime);
            int?            wildLevelStep  = creatureCollection.getWildLevelStep();
            List <Creature> creatures      = tamedCreatureObjects.Select(o => importSavegame.convertGameObject(o, wildLevelStep)).ToList();

            importCollection(creatureCollection, creatures, serverName);
        }
Exemplo n.º 2
0
        public static async Task ImportCollectionFromSavegame(CreatureCollection creatureCollection, string filename, string serverName)
        {
            (GameObjectContainer gameObjectContainer, float gameTime) = await Task.Run(() => ReadSavegameFile(filename));

            var ignoreClasses         = Values.V.IgnoreSpeciesClassesOnImport;
            var importUnclaimedBabies = Properties.Settings.Default.SaveFileImportUnclaimedBabies;

            IEnumerable <GameObject> tamedCreatureObjects = gameObjectContainer
                                                            .Where(o => o.IsCreature() &&
                                                                   o.IsTamed() &&
                                                                   (importUnclaimedBabies || (o.IsCryo && Properties.Settings.Default.SaveImportCryo) || !o.IsUnclaimedBaby()) &&
                                                                   !ignoreClasses.Contains(o.ClassString));

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ImportTribeNameFilter))
            {
                string[] filters = Properties.Settings.Default.ImportTribeNameFilter.Split(',')
                                   .Select(s => s.Trim())
                                   .Where(s => !string.IsNullOrEmpty(s))
                                   .ToArray();

                if (filters.Any())
                {
                    tamedCreatureObjects = tamedCreatureObjects.Where(o =>
                    {
                        string tribeName = o.GetPropertyValue <string>("TribeName", defaultValue: string.Empty);
                        return(filters.Any(filter => tribeName.Contains(filter)));
                    });
                }
            }

            ImportSavegame importSavegame = new ImportSavegame(gameTime);
            int?           wildLevelStep  = creatureCollection.getWildLevelStep();
            var            creatures      = tamedCreatureObjects.Select(o => importSavegame.ConvertGameObject(o, wildLevelStep)).Where(c => c != null).ToArray();

            ArkName.ClearCache();

            // if there are creatures with unknown species, check if the according mod-file is available
            var unknownSpeciesCreatures = creatures.Where(c => c.Species == null).ToArray();

            if (!unknownSpeciesCreatures.Any() ||
                Properties.Settings.Default.IgnoreUnknownBlueprintsOnSaveImport ||
                MessageBox.Show("The species of " + unknownSpeciesCreatures.Length + " creature" + (unknownSpeciesCreatures.Length != 1 ? "s" : "") + " is not recognized, probably because they are from a mod that is not loaded.\n"
                                + "The unrecognized species-classes are as follows, all the according creatures cannot be imported:\n\n" + string.Join("\n", unknownSpeciesCreatures.Select(c => c.name).Distinct().ToArray())
                                + "\n\nTo import the unrecognized creatures, you first need mod values-files, see Settings - Mod value manager… if the mod value is available\n\n"
                                + "Do you want to import the recognized creatures? If you click no, nothing is imported.",
                                "Unrecognized species while importing savegame", MessageBoxButtons.YesNo, MessageBoxIcon.Question
                                ) == DialogResult.Yes
                )
            {
                ImportCollection(creatureCollection, creatures.Where(c => c.Species != null).ToList(), serverName);
            }
        }
Exemplo n.º 3
0
        public static async Task ImportCollectionFromSavegame(CreatureCollection creatureCollection, string filename, string serverName)
        {
            if (Values.V.ignoreSpeciesClassesOnImport == null)
            {
                Values.V.LoadIgnoreSpeciesClassesFile();
            }

            (GameObjectContainer gameObjectContainer, float gameTime) = await readSavegameFile(filename);

            IEnumerable <GameObject> tamedCreatureObjects = gameObjectContainer
                                                            .Where(o => o.IsCreature() && o.IsTamed() && !o.IsUnclaimedBaby() && !Values.V.ignoreSpeciesClassesOnImport.Contains(o.ClassString));

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ImportTribeNameFilter))
            {
                string[] filters = Properties.Settings.Default.ImportTribeNameFilter.Split(',')
                                   .Select(s => s.Trim())
                                   .Where(s => !string.IsNullOrEmpty(s))
                                   .ToArray();

                tamedCreatureObjects = tamedCreatureObjects.Where(o =>
                {
                    string tribeName = o.GetPropertyValue <string>("TribeName", defaultValue: string.Empty);
                    return(filters.Any(filter => tribeName.Contains(filter)));
                });
            }

            ImportSavegame  importSavegame = new ImportSavegame(gameTime);
            int?            wildLevelStep  = creatureCollection.getWildLevelStep();
            List <Creature> creatures      = tamedCreatureObjects.Select(o => importSavegame.convertGameObject(o, wildLevelStep)).ToList();

            // if there are creatures with unknown species, check if the according mod-file is available
            var unknownSpeciesCreatures = creatures.Where(c => c.Species == null).ToList();

            if (!unknownSpeciesCreatures.Any() ||
                MessageBox.Show("The species of " + unknownSpeciesCreatures.Count.ToString() + " creature" + (unknownSpeciesCreatures.Count != 1 ? "s" : "") + " is not recognized, probably because they are from a mod that is not loaded.\n"
                                + "The unrecognized species-classes are as follows, all the according creatures cannot be imported: " + string.Join(", ", unknownSpeciesCreatures.Select(c => c.name).Distinct().ToArray())
                                + "\n(To import the unrecognized creatures, you first need additional values-files.)\n\n"
                                + "Do you want to import the recognized creatures? If you click no, nothing is imported.",
                                "Unrecognized species while importing savegame", MessageBoxButtons.YesNo, MessageBoxIcon.Question
                                ) == DialogResult.Yes
                )
            {
                importCollection(creatureCollection, creatures.Where(c => c.Species != null).ToList(), serverName);
            }
        }
Exemplo n.º 4
0
        private void SetParents(int comboIndex)
        {
            if (comboIndex < 0 || comboIndex >= breedingPairs.Count)
            {
                pedigreeCreatureBest.Clear();
                pedigreeCreatureWorst.Clear();
                lbBreedingPlanInfo.Visible = false;
                lbBPProbabilityBest.Text   = "";
                return;
            }

            int?     levelStep = creatureCollection.getWildLevelStep();
            Creature crB       = new Creature(currentSpecies, "", "", "", 0, new int[Values.STATS_COUNT], null, 100, true, levelStep: levelStep);
            Creature crW       = new Creature(currentSpecies, "", "", "", 0, new int[Values.STATS_COUNT], null, 100, true, levelStep: levelStep);
            Creature mother    = breedingPairs[comboIndex].Female;
            Creature father    = breedingPairs[comboIndex].Male;

            crB.Mother = mother;
            crB.Father = father;
            crW.Mother = mother;
            crW.Father = father;
            double probabilityBest   = 1;
            bool   totalLevelUnknown = false; // if stats are unknown, total level is as well (==> oxygen, speed)

            for (int s = 0; s < Values.STATS_COUNT; s++)
            {
                if (s == (int)StatNames.Torpidity)
                {
                    continue;
                }
                crB.levelsWild[s]       = statWeights[s] < 0 ? Math.Min(mother.levelsWild[s], father.levelsWild[s]) : Math.Max(mother.levelsWild[s], father.levelsWild[s]);
                crB.valuesBreeding[s]   = StatValueCalculation.CalculateValue(currentSpecies, s, crB.levelsWild[s], 0, true, 1, 0);
                crB.topBreedingStats[s] = (crB.levelsWild[s] == bestLevels[s]);
                crW.levelsWild[s]       = statWeights[s] < 0 ? Math.Max(mother.levelsWild[s], father.levelsWild[s]) : Math.Min(mother.levelsWild[s], father.levelsWild[s]);
                crW.valuesBreeding[s]   = StatValueCalculation.CalculateValue(currentSpecies, s, crW.levelsWild[s], 0, true, 1, 0);
                crW.topBreedingStats[s] = (crW.levelsWild[s] == bestLevels[s]);
                if (crB.levelsWild[s] == -1 || crW.levelsWild[s] == -1)
                {
                    totalLevelUnknown = true;
                }
                if (crB.levelsWild[s] > crW.levelsWild[s])
                {
                    probabilityBest *= probabilityHigherLevel;
                }
            }
            crB.levelsWild[(int)StatNames.Torpidity] = crB.levelsWild.Sum();
            crW.levelsWild[(int)StatNames.Torpidity] = crW.levelsWild.Sum();
            crB.name = Loc.s("BestPossible");
            crW.name = Loc.s("WorstPossible");
            crB.RecalculateCreatureValues(levelStep);
            crW.RecalculateCreatureValues(levelStep);
            pedigreeCreatureBest.totalLevelUnknown  = totalLevelUnknown;
            pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown;
            int mutationCounterMaternal = mother.Mutations;
            int mutationCounterPaternal = father.Mutations;

            crB.mutationsMaternal          = mutationCounterMaternal;
            crB.mutationsPaternal          = mutationCounterPaternal;
            crW.mutationsMaternal          = mutationCounterMaternal;
            crW.mutationsPaternal          = mutationCounterPaternal;
            pedigreeCreatureBest.Creature  = crB;
            pedigreeCreatureWorst.Creature = crW;
            lbBPProbabilityBest.Text       = $"{Loc.s("ProbabilityForBest")}: {Math.Round(100 * probabilityBest, 1)}%";

            // set probability barChart
            offspringPossibilities1.Calculate(currentSpecies, mother.levelsWild, father.levelsWild);

            // highlight parents
            int hiliId = comboIndex * 2;

            for (int i = 0; i < pcs.Count; i++)
            {
                pcs[i].highlight = (i == hiliId || i == hiliId + 1);
            }
        }
Exemplo n.º 5
0
        private void setParents(int comboIndex)
        {
            if (comboIndex < 0 || comboIndex > combinedTops[0].Count)
            {
                pedigreeCreatureBest.Clear();
                pedigreeCreatureWorst.Clear();
                labelInfo.Visible         = false;
                labelProbabilityBest.Text = "";
                return;
            }

            int?     levelStep = creatureCollection.getWildLevelStep();
            Creature crB       = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep);
            Creature crW       = new Creature(currentSpecies, "", "", "", 0, new int[8], null, 100, true, levelStep: levelStep);
            Creature mother    = females[combinedTops[0][comboIndex]];
            Creature father    = males[combinedTops[1][comboIndex]];

            crB.Mother = mother;
            crB.Father = father;
            crW.Mother = mother;
            crW.Father = father;
            double probabilityBest   = 1;
            bool   totalLevelUnknown = false; // if stats are unknown, total level is as well (==> oxygen, speed)

            for (int s = 0; s < 7; s++)
            {
                crB.levelsWild[s]       = Math.Max(mother.levelsWild[s], father.levelsWild[s]);
                crB.valuesBreeding[s]   = Stats.calculateValue(speciesIndex, s, crB.levelsWild[s], 0, true, 1, 0);
                crB.topBreedingStats[s] = (crB.levelsWild[s] == bestLevels[s]);
                crW.levelsWild[s]       = Math.Min(mother.levelsWild[s], father.levelsWild[s]);
                crW.valuesBreeding[s]   = Stats.calculateValue(speciesIndex, s, crW.levelsWild[s], 0, true, 1, 0);
                crW.topBreedingStats[s] = (crW.levelsWild[s] == bestLevels[s]);
                if (crB.levelsWild[s] == -1 || crW.levelsWild[s] == -1)
                {
                    totalLevelUnknown = true;
                }
                if (crB.levelsWild[s] > crW.levelsWild[s])
                {
                    probabilityBest *= .7;
                }
            }
            crB.levelsWild[7] = crB.levelsWild.Sum();
            crW.levelsWild[7] = crW.levelsWild.Sum();
            crB.name          = "Best Possible";
            crW.name          = "Worst Possible";
            crB.recalculateCreatureValues(levelStep);
            crW.recalculateCreatureValues(levelStep);
            pedigreeCreatureBest.totalLevelUnknown  = totalLevelUnknown;
            pedigreeCreatureWorst.totalLevelUnknown = totalLevelUnknown;
            int mutationCounter = mother.mutationCounter + father.mutationCounter;

            crB.mutationCounter            = mutationCounter;
            crW.mutationCounter            = mutationCounter;
            pedigreeCreatureBest.Creature  = crB;
            pedigreeCreatureWorst.Creature = crW;
            labelProbabilityBest.Text      = "Probability for this Best Possible outcome: " + Math.Round(100 * probabilityBest, 1).ToString() + "%";

            // set probability barChart
            offspringPossibilities1.wildLevels1 = mother.levelsWild;
            offspringPossibilities1.wildLevels2 = father.levelsWild;
            offspringPossibilities1.calculate();

            // highlight parents
            int hiliId = comboOrder.IndexOf(comboIndex) * 2;

            for (int i = 0; i < pcs.Count; i++)
            {
                pcs[i].highlight = (i == hiliId || i == hiliId + 1);
            }
        }