Пример #1
0
 private static Guid buildGuid(string id1, string id2)
 {
     return(Utils.ConvertIdToGuid(buildARKID(id1, id2)));
 }
Пример #2
0
 private static Guid builtGuid(string id1, string id2)
 {
     int.TryParse(id1, out int id1int);
     int.TryParse(id2, out int id2int);
     return(Utils.ConvertIdToGuid((((long)id1int) << 32) | (id2int & 0xFFFFFFFFL)));
 }
Пример #3
0
        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);
        }