public recalculateAncestorGenerations ( ) : void | ||
Résultat | void |
private void closeSettings(bool save) { panel1.Visible = false; if (save) { SuspendLayout(); creature.name = textBoxName.Text; creature.gender = sex; creature.owner = textBoxOwner.Text; Creature parent = null; if (checkBoxIsBred.Checked) { parent = parentComboBoxMother.SelectedParent; } creature.motherGuid = (parent != null ? parent.guid : Guid.Empty); bool parentsChanged = false; if (creature.Mother != parent) { creature.Mother = parent; parentsChanged = true; } parent = null; if (checkBoxIsBred.Checked) { parent = parentComboBoxFather.SelectedParent; } creature.fatherGuid = (parent != null ? parent.guid : Guid.Empty); if (creature.Father != parent) { creature.Father = parent; parentsChanged = true; } if (parentsChanged) { creature.recalculateAncestorGenerations(); } creature.isBred = checkBoxIsBred.Checked; for (int s = 0; s < 7; s++) { creature.levelsDom[s] = (int)numUDLevelsDom[s].Value; } creature.note = textBoxNote.Text; bool creatureStatusChanged = (creature.status != status); creature.status = status; Changed(creature, creatureStatusChanged); updateLabel(); ResumeLayout(); } }
private Creature convertGameObject(GameObject creatureObject, int?levelStep) { GameObject statusObject = creatureObject.CharacterStatusComponent(); string imprinterName = creatureObject.GetPropertyValue <string>("ImprinterName"); string owner = string.IsNullOrWhiteSpace(imprinterName) ? creatureObject.GetPropertyValue <string>("TamerString") : imprinterName; int[] wildLevels = Enumerable.Repeat(-1, statsCount).ToArray(); // -1 is unknown int[] tamedLevels = new int[statsCount]; for (int i = 0; i < statsCount; i++) { wildLevels[i] = statusObject.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsApplied", i)?.ByteValue ?? 0; } wildLevels[(int)StatNames.Torpidity] = statusObject.GetPropertyValue <int>("BaseCharacterLevel", defaultValue: 1) - 1; // torpor for (int i = 0; i < statsCount; i++) { tamedLevels[i] = statusObject.GetPropertyValue <ArkByteValue>("NumberOfLevelUpPointsAppliedTamed", i)?.ByteValue ?? 0; } string convertedSpeciesName = convertSpecies(creatureObject.GetNameForCreature(arkData) ?? creatureObject.ClassString); float ti = statusObject.GetPropertyValue <float>("TamedIneffectivenessModifier", defaultValue: float.NaN); double te = 1f / (1 + (!float.IsNaN(ti) ? ti : creatureObject.GetPropertyValue <float>("TameIneffectivenessModifier"))); Creature creature = new Creature(convertedSpeciesName, creatureObject.GetPropertyValue <string>("TamedName"), owner, creatureObject.GetPropertyValue <string>("TribeName"), creatureObject.IsFemale() ? Sex.Female : Sex.Male, wildLevels, tamedLevels, te, !string.IsNullOrWhiteSpace(creatureObject.GetPropertyValue <string>("ImprinterName")), statusObject.GetPropertyValue <float>("DinoImprintingQuality"), levelStep ) { imprinterName = creatureObject.GetPropertyValue <string>("ImprinterName"), guid = Utils.ConvertArkIdToGuid(creatureObject.GetDinoId()), ArkId = creatureObject.GetDinoId(), ArkIdImported = true, domesticatedAt = DateTime.Now, // TODO: possible to convert ingame-time to realtime? addedToLibrary = DateTime.Now, mutationsMaternal = creatureObject.GetPropertyValue <int>("RandomMutationsFemale"), mutationsPaternal = creatureObject.GetPropertyValue <int>("RandomMutationsMale") }; // If it's a baby and still growing, work out growingUntil if (creatureObject.GetPropertyValue <bool>("bIsBaby") || !creatureObject.GetPropertyValue <bool>("bIsBaby") && !string.IsNullOrWhiteSpace(imprinterName)) { int i = Values.V.speciesNames.IndexOf(convertedSpeciesName); double maturationTime = Values.V.species[i].breeding?.maturationTimeAdjusted ?? 0; float tamedTime = gameTime - (float)creatureObject.GetPropertyValue <double>("TamedAtTime"); if (tamedTime < maturationTime) { creature.growingUntil = DateTime.Now + TimeSpan.FromSeconds(maturationTime - tamedTime); } } // Ancestor linking is done later after entire collection is formed - here we just set the guids ArkArrayStruct femaleAncestors = creatureObject.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestors"); StructPropertyList femaleAncestor = (StructPropertyList)femaleAncestors?.LastOrDefault(); if (femaleAncestor != null) { creature.motherGuid = Utils.ConvertArkIdToGuid(GameObjectExtensions.CreateDinoId( femaleAncestor.GetPropertyValue <int>("FemaleDinoID1"), femaleAncestor.GetPropertyValue <int>("FemaleDinoID2"))); creature.motherName = femaleAncestor.GetPropertyValue <string>("FemaleName"); creature.isBred = true; } ArkArrayStruct maleAncestors = creatureObject.GetPropertyValue <IArkArray, ArkArrayStruct>("DinoAncestorsMale"); StructPropertyList maleAncestor = (StructPropertyList)maleAncestors?.LastOrDefault(); if (maleAncestor != null) { creature.fatherGuid = Utils.ConvertArkIdToGuid(GameObjectExtensions.CreateDinoId( maleAncestor.GetPropertyValue <int>("MaleDinoID1"), maleAncestor.GetPropertyValue <int>("MaleDinoID2"))); creature.fatherName = maleAncestor.GetPropertyValue <string>("MaleName"); creature.isBred = true; } creature.colors = new int[6]; for (int i = 0; i < 6; i++) { creature.colors[i] = colorModulo(creatureObject.GetPropertyValue <ArkByteValue>("ColorSetIndices", i)?.ByteValue ?? 0); } bool isDead = creatureObject.GetPropertyValue <bool>("bIsDead"); if (isDead) { creature.status = CreatureStatus.Dead; // dead is always dead } if (!isDead && creature.status == CreatureStatus.Dead) { creature.status = CreatureStatus.Unavailable; // if found alive when marked dead, mark as unavailable } creature.recalculateAncestorGenerations(); creature.recalculateCreatureValues(levelStep); return(creature); }
private Creature ConvertCreature(ImportedCreature lc, int?levelStep) { var owner = String.IsNullOrWhiteSpace(lc.Imprinter) ? lc.Tamer : lc.Imprinter; int[] wildLevels = new int[] { -1, -1, -1, -1, -1, -1, -1, -1 }; // -1 is unknown int[] tamedLevels = new int[8]; if (lc.WildLevels != null) { wildLevels = ConvertLevels(lc.WildLevels, lc.BaseLevel - 1); } if (lc.TamedLevels != null) { tamedLevels = ConvertLevels(lc.TamedLevels); } string convertedSpeciesName = ConvertSpecies(lc.Type); // fix for wrong TE (bug in ark-tools) TODO. got it fixed in ark-tools? // if it got fixed in ark-tools, use // double te = lc.TamingEffectiveness; double te = 1 / (2 - lc.TamingEffectiveness); var creature = new Creature(convertedSpeciesName, lc.Name, owner, lc.Tribe, lc.Female ? Sex.Female : Sex.Male, wildLevels, tamedLevels, te, !string.IsNullOrWhiteSpace(lc.Imprinter), lc.ImprintingQuality, levelStep); creature.imprinterName = lc.Imprinter; creature.guid = Utils.ConvertIdToGuid(lc.Id); creature.domesticatedAt = DateTime.Now; // TODO: convert ingame-time to realtime? creature.addedToLibrary = DateTime.Now; creature.mutationsMaternal = lc.MutationsFemaleLine; creature.mutationsPaternal = lc.MutationsMaleLine; // If it's a baby and still growing, work out growingUntil if (lc.Baby || (!lc.Baby && !String.IsNullOrWhiteSpace(lc.Imprinter))) { int i = Values.V.speciesNames.IndexOf(convertedSpeciesName); double maturationTime = Values.V.species[i].breeding.maturationTimeAdjusted; if (lc.TamedTime < maturationTime) { creature.growingUntil = DateTime.Now + TimeSpan.FromSeconds(maturationTime - lc.TamedTime); } } // Ancestor linking is done later after entire collection is formed - here we just set the guids if (lc.FemaleAncestors != null && lc.FemaleAncestors.Count > 0) { var femaleAncestor = lc.FemaleAncestors.Last(); creature.motherGuid = Utils.ConvertIdToGuid(femaleAncestor.FemaleId); creature.motherName = femaleAncestor.FemaleName; creature.isBred = true; } if (lc.MaleAncestors != null && lc.MaleAncestors.Count > 0) { var maleAncestor = lc.MaleAncestors.Last(); creature.fatherGuid = Utils.ConvertIdToGuid(maleAncestor.MaleId); creature.fatherName = maleAncestor.MaleName; creature.isBred = true; } if (lc.Colors != null) { creature.colors = ConvertColors(lc.Colors); } if (lc.Dead) { creature.status = CreatureStatus.Dead; // dead is always dead } if (!lc.Dead && creature.status == CreatureStatus.Dead) { creature.status = CreatureStatus.Unavailable; // if found alive when marked dead, mark as unavailable } creature.recalculateAncestorGenerations(); creature.recalculateCreatureValues(levelStep); return(creature); }
private void add2Lib(bool fromExtractor = true) { CreatureInfoInput input; bool bred; double te; string species; if (fromExtractor) { input = creatureInfoInputExtractor; species = Values.V.speciesNames[sE]; bred = checkBoxAlreadyBred.Checked; te = Extraction.E.uniqueTE(); } else { input = creatureInfoInputTester; species = Values.V.speciesNames[cbbStatTestingSpecies.SelectedIndex]; bred = checkBoxStatTestingBred.Checked; te = (double)NumericUpDownTestingTE.Value / 100; } Creature creature = new Creature(species, input.CreatureName, input.CreatureOwner, input.CreatureGender, getCurrentWildLevels(fromExtractor), getCurrentDomLevels(fromExtractor), te, bred); // set parents creature.Mother = input.mother; creature.Father = input.father; // cooldown-, growing-time creature.cooldownUntil = input.Cooldown; creature.growingUntil = input.Grown; creature.domesticatedAt = input.domesticatedAt; recalculateCreatureValues(creature); creature.recalculateAncestorGenerations(); creature.guid = Guid.NewGuid(); creatureCollection.creatures.Add(creature); setCollectionChanged(true, species); updateCreatureListings(Values.V.speciesNames.IndexOf(species)); // show only the added creatures' species listBoxSpeciesLib.SelectedIndex = listBoxSpeciesLib.Items.IndexOf(creature.species); tabControlMain.SelectedTab = tabPageLibrary; creatureInfoInputExtractor.parentListValid = false; creatureInfoInputTester.parentListValid = false; }