Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 9, 2024
2 parents 177d3ed + 965bd78 commit b5034a4
Show file tree
Hide file tree
Showing 17 changed files with 289 additions and 104 deletions.
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@
<setting name="CopyNameToClipboardOnImport" serializeAs="String">
<value>False</value>
</setting>
<setting name="MoveMutationLevelsOnExtractionIfUnique" serializeAs="String">
<value>True</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
6 changes: 5 additions & 1 deletion ARKBreedingStats/CreatureInfoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ private void UpdateRegionColorImage()
PbColorRegion?.SetImageAndDisposeOld(CreatureColored.GetColoredCreature(RegionColors, _selectedSpecies, regionColorChooser1.ColorRegionsUseds, 256, onlyImage: true, creatureSex: CreatureSex));
}

/// <summary>
/// Update the creatures displayed on the inheritance control with possible stat inheritances and mutations.
/// </summary>
/// <param name="creature"></param>
internal void UpdateParentInheritances(Creature creature)
{
if (ParentInheritance == null) return;
Expand Down Expand Up @@ -854,7 +858,7 @@ internal void Clear(bool keepGeneralInfo = false)
ClearColors();
SetRegionColorsExisting();
CreatureGuid = Guid.Empty;
SetArkId(0,false);
SetArkId(0, false);
if (!keepGeneralInfo)
{
textBoxOwner.Clear();
Expand Down
1 change: 0 additions & 1 deletion ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3163,7 +3163,6 @@ private Creature CreateCreatureFromExtractorOrTester(CreatureInfoInput input)
cr.isBred = rbBredExtractor.Checked;
for (int s = 0; s < Stats.StatsCount; s++)
cr.SetTopStat(s, _statIOs[s].TopLevel.HasFlag(LevelStatusFlags.LevelStatus.TopLevel) || _statIOs[s].TopLevel.HasFlag(LevelStatusFlags.LevelStatus.NewTopLevel));

}
else
{
Expand Down
18 changes: 15 additions & 3 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,6 @@ void SetExistingValueIfNewValueIsEmpty(ref string newValue, ref string oldValue)
ExtractLevels(autoExtraction, highPrecisionValues, existingCreature: alreadyExistingCreature, possiblyMutagenApplied: cv.flags.HasFlag(CreatureFlags.MutagenApplied));

UpdateMutationLevels(cv, alreadyExistingCreature);

SetCreatureValuesToInfoInput(cv, creatureInfoInputExtractor);
UpdateParentListInput(creatureInfoInputExtractor); // this function is only used for single-creature extractions, e.g. LastExport
creatureInfoInputExtractor.AlreadyExistingCreature = alreadyExistingCreature;
Expand All @@ -1086,8 +1085,14 @@ void SetExistingValueIfNewValueIsEmpty(ref string newValue, ref string oldValue)
return creatureExists;
}

private void UpdateMutationLevels(CreatureValues cv, Creature alreadyExistingCreature)
/// <summary>
/// Tries to determine mutation levels, i.e. separate wild and mutation levels, depending on the ancestry information.
/// </summary>
/// <returns>True if mutation levels where adjusted, false if no levels were moved.</returns>
private bool UpdateMutationLevels(CreatureValues cv, Creature alreadyExistingCreature)
{
if (!Properties.Settings.Default.MoveMutationLevelsOnExtractionIfUnique) return false;
bool mutationLevelsAdjusted = false;
// Do we have enough information to assume the mutation counts are accurate
bool AreMutationCountsAccurate(Creature creature)
{
Expand Down Expand Up @@ -1116,6 +1121,7 @@ bool AreMutationLevelsAccurate(Creature creature)
{
_statIOs[s].LevelMut = mutationLevels;
_statIOs[s].LevelWild -= mutationLevels;
mutationLevelsAdjusted = true;
}
}
}
Expand Down Expand Up @@ -1212,6 +1218,7 @@ bool AreMutationLevelsAccurate(Creature creature)
statIo.LevelMut = levels.mutated;
statIo.Status = StatIOStatus.Neutral;
}
mutationLevelsAdjusted = true;
}
else
{
Expand Down Expand Up @@ -1239,9 +1246,12 @@ bool AreMutationLevelsAccurate(Creature creature)
statIo.LevelMut = levels.mutated;
statIo.Status = StatIOStatus.Neutral;
}
mutationLevelsAdjusted = true;
}
}
}

return mutationLevelsAdjusted;
}

/// <summary>
Expand Down Expand Up @@ -1497,7 +1507,9 @@ private void LbBlueprintPath_Click(object sender, EventArgs e)

private void ExtractorStatLevelChanged(StatIO _)
{
radarChartExtractor.SetLevels(_statIOs.Select(s => s.LevelWild).ToArray(), _statIOs.Select(s => s.LevelMut).ToArray(), speciesSelector1.SelectedSpecies);
var cr = CreateCreatureFromExtractorOrTester(creatureInfoInputExtractor);
radarChartExtractor.SetLevels(cr.levelsWild, cr.levelsMutated, cr.Species);
creatureInfoInputExtractor.UpdateParentInheritances(cr);
}

#region OCR label sets
Expand Down
1 change: 0 additions & 1 deletion ARKBreedingStats/Form1.tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ private void SetCreatureValuesLevelsAndInfoToExtractor(Creature c)
creatureInfoInputExtractor.SetArkId(c.ArkId, c.ArkIdImported);
SetCreatureLevelsToExtractor(c);
SetAllExtractorLevelsToStatus(StatIOStatus.Unique);
UpdateParentListInput(creatureInfoInputExtractor);
creatureInfoInputExtractor.AlreadyExistingCreature = alreadyExistingCreature;
UpdateStatusInfoOfExtractorCreature();
UpdateAddToLibraryButtonAccordingToExtractorValidity(true);
Expand Down
162 changes: 144 additions & 18 deletions ARKBreedingStats/Pedigree/PedigreeCreation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,42 +307,168 @@ internal static void CreateGeneInheritanceLines(Creature offspring, Creature mot
{
int si = PedigreeCreature.DisplayedStats[s];
if (offspring.valuesDom[si] <= 0) continue; // don't display arrows for non used stats

var levelMother = mother?.levelsWild[si] ?? -1;
var levelFather = father?.levelsWild[si] ?? -1;
var levelMotherMutated = mother?.levelsMutated?[si] ?? -1;
var levelFatherMutated = father?.levelsMutated?[si] ?? -1;
var levelOffspring = offspring.levelsWild[si];
var levelOffspringMutated = offspring.levelsMutated?[si] ?? -1;

int better = 0; // if father < mother: 1, if mother < father: -1
if (mother?.levelsWild != null && father?.levelsWild != null)
if (levelMother != -1 && levelFather != -1)
{
if (mother.levelsWild[si] < father.levelsWild[si])
if (levelMother < levelFather)
better = -1;
else if (mother.levelsWild[si] > father.levelsWild[si])
else if (levelMother > levelFather)
better = 1;
}

// offspring can have stats that are up to 2 levels higher due to mutations. currently there are no decreasing levels due to mutations
if (mother?.levelsWild != null && offspring.levelsWild[si] >= 0 &&
(offspring.levelsWild[si] == mother.levelsWild[si] ||
offspring.levelsWild[si] == mother.levelsWild[si] + 2))
// offspring can have stats that are 2, 4 or 6 levels higher due to mutations. currently there are no decreasing levels due to mutations
bool motherInheritancePossible = false;
bool fatherInheritancePossible = false;
bool motherInheritanceWithMutationPossible = false;
bool fatherInheritanceWithMutationPossible = false;

if (levelOffspringMutated == -1 || levelMotherMutated == -1 || levelFatherMutated == -1)
{
// ASE mutation mechanic, i.e. offspring has 0, 2, 4 or 6 levels more than one parent
for (int m = 0; m <= Ark.MutationRolls; m++)
{
if (levelOffspring == levelMother + Ark.LevelsAddedPerMutation * m)
{
motherInheritancePossible = true;
if (m > 0)
motherInheritanceWithMutationPossible = true;
}
if (levelOffspring == levelFather + Ark.LevelsAddedPerMutation * m)
{
fatherInheritancePossible = true;
if (m > 0)
fatherInheritanceWithMutationPossible = true;
}
}
}
else
{
// ASA mutation mechanic, i.e. mutations are saved separately and inheritance combines higher wild and higher mutation level
int higherWildLevel, lowerWildLevel, higherMutLevel, lowerMutLevel;
LevelInheritedFrom higherWildLevelFrom = LevelInheritedFrom.None;
LevelInheritedFrom higherMutationLevelFrom = LevelInheritedFrom.None;
if (levelMother > levelFather)
{
higherWildLevel = levelMother;
lowerWildLevel = levelFather;
higherWildLevelFrom = LevelInheritedFrom.Mother;
}
else
{
higherWildLevel = levelFather;
lowerWildLevel = levelMother;
if (levelMother < levelFather)
higherWildLevelFrom = LevelInheritedFrom.Father;
}

if (levelMotherMutated > levelFatherMutated)
{
higherMutLevel = levelMotherMutated;
lowerMutLevel = levelFatherMutated;
higherMutationLevelFrom = LevelInheritedFrom.Mother;
}
else
{
higherMutLevel = levelFatherMutated;
lowerMutLevel = levelMotherMutated;
if (levelMotherMutated < levelFatherMutated)
higherMutationLevelFrom = LevelInheritedFrom.Father;
}

var higherInheritancePossible = false;
var lowerInheritancePossible = false;
var higherMutationInheritancePossible = false;
var lowerMutationInheritancePossible = false;

for (int m = 0; m <= Ark.MutationRolls; m++)
{
if (levelOffspring == higherWildLevel
&& levelOffspringMutated == higherMutLevel + Ark.LevelsAddedPerMutation * m)
{
higherInheritancePossible = true;
if (m > 0)
higherMutationInheritancePossible = true;
}
else if (levelOffspring == lowerWildLevel
&& levelOffspringMutated == lowerMutLevel + Ark.LevelsAddedPerMutation * m)
{
lowerInheritancePossible = true;
if (m > 0)
lowerMutationInheritancePossible = true;
}
}

if (higherInheritancePossible)
{
if (higherWildLevelFrom != LevelInheritedFrom.Father)
motherInheritancePossible = true;
if (higherWildLevelFrom != LevelInheritedFrom.Mother)
fatherInheritancePossible = true;
if (higherMutationInheritancePossible)
{
if (higherMutationLevelFrom != LevelInheritedFrom.Father)
motherInheritanceWithMutationPossible = true;
if (higherMutationLevelFrom != LevelInheritedFrom.Mother)
fatherInheritanceWithMutationPossible = true;
}
}

if (lowerInheritancePossible)
{
if (higherWildLevelFrom == LevelInheritedFrom.Father)
motherInheritancePossible = true;
if (higherWildLevelFrom == LevelInheritedFrom.Mother)
fatherInheritancePossible = true;
if (lowerMutationInheritancePossible)
{
if (higherMutationLevelFrom == LevelInheritedFrom.Father)
motherInheritanceWithMutationPossible = true;
if (higherMutationLevelFrom == LevelInheritedFrom.Mother)
fatherInheritanceWithMutationPossible = true;
}
}
}

if (motherInheritancePossible)
{
lines[0].Add(new[]
{
PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 33,
PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 42, (better == -1 ? 1 : 2),
(offspring.levelsWild[si] > mother.levelsWild[si] ? 1 : 0)
});
PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 33,
PedigreeCreature.XOffsetFirstStat + x + PedigreeCreature.HorizontalStatDistance * s, y + 42, better == -1 ? 1 : 2,
motherInheritanceWithMutationPossible ? 1 : 0
});
}

if (father?.levelsWild != null && offspring.levelsWild[si] >= 0 &&
(offspring.levelsWild[si] == father.levelsWild[si] ||
offspring.levelsWild[si] == father.levelsWild[si] + 2))
if (fatherInheritancePossible)
{
lines[0].Add(new[]
{
PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 83,
PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 74, (better == 1 ? 1 : 2),
(offspring.levelsWild[si] > father.levelsWild[si] ? 1 : 0)
});
PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 83,
PedigreeCreature.XOffsetFirstStat + x +PedigreeCreature.HorizontalStatDistance * s, y + 74, better == 1 ? 1 : 2,
fatherInheritanceWithMutationPossible ? 1 : 0
});
}
}
}

/// <summary>
/// Indicates from which parent the level was inherited.
/// </summary>
private enum LevelInheritedFrom
{
None,
Mother,
Father
}

#endregion
}
}
2 changes: 1 addition & 1 deletion ARKBreedingStats/Pedigree/PedigreeCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public Creature Creature
+ $"{_creature.valuesBreeding[si] * (Utils.Precision(si) == 3 ? 100 : 1),7:#,0.0}"
+ (Utils.Precision(si) == 3 ? "%" : string.Empty)
+ (_creature.levelsMutated == null ? string.Empty
: Environment.NewLine + Loc.S("Mutations") + ": " + _creature.levelsMutated[s]
: Environment.NewLine + Loc.S("Mutations") + ": " + _creature.levelsMutated[si]
));
}
// fonts are strange, and this seems to work. The assigned font-object is probably only used to read out the properties and then not used anymore.
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.61.1.0")]
[assembly: AssemblyFileVersion("0.61.2.0")]
[assembly: NeutralResourcesLanguage("en")]

12 changes: 12 additions & 0 deletions ARKBreedingStats/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ARKBreedingStats/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,8 @@
<Setting Name="CopyNameToClipboardOnImport" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="MoveMutationLevelsOnExtractionIfUnique" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ARK Smart Breeding": {
"Id": "ARK Smart Breeding",
"Category": "main",
"version": "0.61.1.0"
"version": "0.61.2.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
Loading

0 comments on commit b5034a4

Please sign in to comment.