Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Sep 19, 2023
2 parents 006eb77 + 769ce2f commit 89a1431
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 58 deletions.
70 changes: 70 additions & 0 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,76 @@ private void SetCreatureValuesToExtractor(CreatureValues cv, bool setInfoInput =
numericUpDownImprintingBonusExtractor.ValueSave = (decimal)cv.imprintingBonus * 100;
}

/// <summary>
/// Creates a creature from the infos in inputs, extractor or tester.
/// </summary>
/// <param name="fromExtractor"></param>
/// <param name="species"></param>
/// <param name="levelStep"></param>
/// <param name="motherArkId">Use this Ark Id instead of the ones of the input if not 0</param>
/// <param name="fatherArkId">Use this Ark Id instead of the ones of the input if not 0</param>
/// <returns></returns>
private Creature GetCreatureFromInput(bool fromExtractor, Species species, int? levelStep, long motherArkId = 0, long fatherArkId = 0)
{
CreatureInfoInput input;
bool bred;
double te, imprinting;
if (fromExtractor)
{
input = creatureInfoInputExtractor;
bred = rbBredExtractor.Checked;
te = rbWildExtractor.Checked ? -3 : _extractor.UniqueTamingEffectiveness();
imprinting = _extractor.ImprintingBonus;
}
else
{
input = creatureInfoInputTester;
bred = rbBredTester.Checked;
te = TamingEffectivenessTester;
imprinting = (double)numericUpDownImprintingBonusTester.Value / 100;
}

Creature creature = new Creature(species, input.CreatureName, input.CreatureOwner, input.CreatureTribe, input.CreatureSex, GetCurrentWildLevels(fromExtractor), GetCurrentDomLevels(fromExtractor), te, bred, imprinting, levelStep: levelStep)
{
// set parents
Mother = input.Mother,
Father = input.Father,

// cooldown-, growing-time
cooldownUntil = input.CooldownUntil,
growingUntil = input.GrowingUntil,

flags = input.CreatureFlags,
note = input.CreatureNote,
server = input.CreatureServer,

domesticatedAt = input.DomesticatedAt.HasValue && input.DomesticatedAt.Value.Year > 2014 ? input.DomesticatedAt.Value : default(DateTime?),
addedToLibrary = DateTime.Now,
mutationsMaternal = input.MutationCounterMother,
mutationsPaternal = input.MutationCounterFather,
Status = input.CreatureStatus,
colors = input.RegionColors,
ColorIdsAlsoPossible = input.ColorIdsAlsoPossible,
guid = fromExtractor && input.CreatureGuid != Guid.Empty ? input.CreatureGuid : Guid.NewGuid(),
ArkId = input.ArkId
};

creature.ArkIdImported = Utils.IsArkIdImported(creature.ArkId, creature.guid);
creature.InitializeArkInGame();

// parent guids
if (motherArkId != 0)
creature.motherGuid = Utils.ConvertArkIdToGuid(motherArkId);
else if (input.MotherArkId != 0)
creature.motherGuid = Utils.ConvertArkIdToGuid(input.MotherArkId);
if (fatherArkId != 0)
creature.fatherGuid = Utils.ConvertArkIdToGuid(fatherArkId);
else if (input.FatherArkId != 0)
creature.fatherGuid = Utils.ConvertArkIdToGuid(input.FatherArkId);

return creature;
}

/// <summary>
/// Gives feedback to the user if the current creature in the extractor is already in the library.
/// This uses the ARK-ID and only works if exported creatures are imported
Expand Down
8 changes: 8 additions & 0 deletions ARKBreedingStats/Form1.importExported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ private void ImportExportedAddIfPossible(string filePath)
default: return;
}

if (creature == null)
{
// extraction did not work automatically, user input needed, create creature file for error message
var levelStep = _creatureCollection.getWildLevelStep();
var species = speciesSelector1.SelectedSpecies;
creature = GetCreatureFromInput(true, species, levelStep);
}

OverlayFeedbackForImport(creature, uniqueExtraction, alreadyExists, addedToLibrary, copiedNameToClipboard, out bool hasTopLevels, out bool hasNewTopLevels);

if (addedToLibrary)
Expand Down
58 changes: 2 additions & 56 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,9 @@ public partial class Form1
/// <param name="goToLibraryTab">go to library tab after the creature is added</param>
private Creature AddCreatureToCollection(bool fromExtractor = true, long motherArkId = 0, long fatherArkId = 0, bool goToLibraryTab = true)
{
CreatureInfoInput input;
bool bred;
double te, imprinting;
Species species = speciesSelector1.SelectedSpecies;
if (fromExtractor)
{
input = creatureInfoInputExtractor;
bred = rbBredExtractor.Checked;
te = rbWildExtractor.Checked ? -3 : _extractor.UniqueTamingEffectiveness();
imprinting = _extractor.ImprintingBonus;
}
else
{
input = creatureInfoInputTester;
bred = rbBredTester.Checked;
te = TamingEffectivenessTester;
imprinting = (double)numericUpDownImprintingBonusTester.Value / 100;
}

var levelStep = _creatureCollection.getWildLevelStep();
Creature creature = new Creature(species, input.CreatureName, input.CreatureOwner, input.CreatureTribe, input.CreatureSex, GetCurrentWildLevels(fromExtractor), GetCurrentDomLevels(fromExtractor), te, bred, imprinting, levelStep: levelStep)
{
// set parents
Mother = input.Mother,
Father = input.Father,

// cooldown-, growing-time
cooldownUntil = input.CooldownUntil,
growingUntil = input.GrowingUntil,

flags = input.CreatureFlags,
note = input.CreatureNote,
server = input.CreatureServer,

domesticatedAt = input.DomesticatedAt.HasValue && input.DomesticatedAt.Value.Year > 2014 ? input.DomesticatedAt.Value : default(DateTime?),
addedToLibrary = DateTime.Now,
mutationsMaternal = input.MutationCounterMother,
mutationsPaternal = input.MutationCounterFather,
Status = input.CreatureStatus,
colors = input.RegionColors,
ColorIdsAlsoPossible = input.ColorIdsAlsoPossible,
guid = fromExtractor && input.CreatureGuid != Guid.Empty ? input.CreatureGuid : Guid.NewGuid(),
ArkId = input.ArkId
};

creature.ArkIdImported = Utils.IsArkIdImported(creature.ArkId, creature.guid);
creature.InitializeArkInGame();

// parent guids
if (motherArkId != 0)
creature.motherGuid = Utils.ConvertArkIdToGuid(motherArkId);
else if (input.MotherArkId != 0)
creature.motherGuid = Utils.ConvertArkIdToGuid(input.MotherArkId);
if (fatherArkId != 0)
creature.fatherGuid = Utils.ConvertArkIdToGuid(fatherArkId);
else if (input.FatherArkId != 0)
creature.fatherGuid = Utils.ConvertArkIdToGuid(input.FatherArkId);
var species = speciesSelector1.SelectedSpecies;
var creature = GetCreatureFromInput(fromExtractor, species, levelStep, motherArkId, fatherArkId);

// if creature is placeholder: add it
// if creature's ArkId is already in library, suggest updating of the creature
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.56.1.0")]
[assembly: AssemblyFileVersion("0.56.2.0")]
[assembly: NeutralResourcesLanguage("en")]

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.56.1.0"
"version": "0.56.2.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down

0 comments on commit 89a1431

Please sign in to comment.